Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
const packageData: any = jsonParse(checkFile);
expect(packageData.scripts['postinstall']).toBeDefined();
expect(packageData.scripts['postinstall.electron']).toBeDefined();
expect(packageData.scripts['postinstall.web']).toBeDefined();
expect(packageData.scripts['build.electron.foo']).toBeDefined();
expect(packageData.scripts['build.electron.foo.local']).toBeDefined();
expect(packageData.scripts['build.electron.foo.linux']).toBeDefined();
expect(packageData.scripts['build.electron.foo.windows']).toBeDefined();
expect(packageData.scripts['build.electron.foo.mac']).toBeDefined();
expect(packageData.scripts['prepare.electron.foo']).toBeDefined();
expect(packageData.scripts['serve.electron.foo.target']).toBeDefined();
expect(packageData.scripts['serve.electron.foo']).toBeDefined();
expect(packageData.scripts['start.electron.foo']).toBeDefined();
// should *NOT* generate angular specific files
expect(
tree.exists('/apps/web-viewer/src/app/app.electron.module.ts')
).toBeFalsy();
expect(tree.exists('/apps/web-viewer/src/main.electron.ts')).toBeFalsy();
// should create correct files
expect(tree.exists('/apps/web-viewer/src/main.ts')).toBeFalsy();
// make sure start script is correct
checkPath = '/package.json';
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
expect(
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
const packageData: any = jsonParse(checkFile);
expect(packageData.scripts['postinstall']).toBeDefined();
expect(packageData.scripts['postinstall.electron']).toBeDefined();
expect(packageData.scripts['postinstall.web']).toBeDefined();
expect(packageData.scripts['build.electron.foo']).toBeDefined();
expect(packageData.scripts['build.electron.foo.local']).toBeDefined();
expect(packageData.scripts['build.electron.foo.linux']).toBeDefined();
expect(packageData.scripts['build.electron.foo.windows']).toBeDefined();
expect(packageData.scripts['build.electron.foo.mac']).toBeDefined();
expect(packageData.scripts['prepare.electron.foo']).toBeDefined();
expect(packageData.scripts['serve.electron.foo.target']).toBeDefined();
expect(packageData.scripts['serve.electron.foo']).toBeDefined();
expect(packageData.scripts['start.electron.foo']).toBeDefined();
// check target web app for supporting files
checkPath = '/apps/web-viewer/src/app/app.electron.module.ts';
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
expect(checkFile.indexOf(`TtElectronCoreModule`)).toBeGreaterThanOrEqual(0);
expect(checkFile.indexOf(`AppElectronModule`)).toBeGreaterThanOrEqual(0);
checkPath = '/apps/web-viewer/src/main.electron.ts';
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
checkPath = '/package.json';
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
const packageData: any = jsonParse(checkFile);
expect(packageData.scripts['postinstall']).toBeDefined();
expect(packageData.scripts['postinstall.electron']).toBeDefined();
expect(packageData.scripts['postinstall.web']).toBeDefined();
expect(packageData.scripts['build.electron.foo']).toBeDefined();
expect(packageData.scripts['build.electron.foo.local']).toBeDefined();
expect(packageData.scripts['build.electron.foo.linux']).toBeDefined();
expect(packageData.scripts['build.electron.foo.windows']).toBeDefined();
expect(packageData.scripts['build.electron.foo.mac']).toBeDefined();
expect(packageData.scripts['prepare.electron.foo']).toBeDefined();
expect(packageData.scripts['serve.electron.foo.target']).toBeDefined();
expect(packageData.scripts['serve.electron.foo']).toBeDefined();
expect(packageData.scripts['start.electron.foo']).toBeDefined();
// should *NOT* generate angular specific files
expect(
tree.exists('/apps/web-viewer/src/app/app.electron.module.ts')
).toBeFalsy();
expect(tree.exists('/apps/web-viewer/src/main.electron.ts')).toBeFalsy();
// should create correct files
expect(tree.exists('/apps/web-viewer/src/main.ts')).toBeFalsy();
// make sure start script is correct
checkPath = '/package.json';
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
checkPath = '/package.json';
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
const packageData: any = jsonParse(checkFile);
expect(packageData.scripts['postinstall']).toBeDefined();
expect(packageData.scripts['postinstall.electron']).toBeDefined();
expect(packageData.scripts['postinstall.web']).toBeDefined();
expect(packageData.scripts['build.electron.foo']).toBeDefined();
expect(packageData.scripts['build.electron.foo.local']).toBeDefined();
expect(packageData.scripts['build.electron.foo.linux']).toBeDefined();
expect(packageData.scripts['build.electron.foo.windows']).toBeDefined();
expect(packageData.scripts['build.electron.foo.mac']).toBeDefined();
expect(packageData.scripts['prepare.electron.foo']).toBeDefined();
expect(packageData.scripts['serve.electron.foo.target']).toBeDefined();
expect(packageData.scripts['serve.electron.foo']).toBeDefined();
expect(packageData.scripts['start.electron.foo']).toBeDefined();
// check target web app for supporting files
checkPath = '/apps/web-viewer/src/app/app.electron.module.ts';
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
// console.log(checkFile);
expect(checkFile.indexOf(`TtElectronCoreModule`)).toBeGreaterThanOrEqual(0);
expect(checkFile.indexOf(`AppElectronModule`)).toBeGreaterThanOrEqual(0);
checkPath = '/apps/web-viewer/src/main.electron.ts';
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
function startServer(dist, port) {
server = serve(dist, {
silent: true,
port,
ignore: ['node_modules']
});
}
async preview(inputConfig?: PhenomicInputConfig) {
try {
const config = await normalizeConfiguration(inputConfig);
await build(config);
log(
`⚡️ Serving on http://localhost:${config.port}` +
config.baseUrl.pathname,
);
serve(config.outdir, {
port: config.port,
});
} catch (e) {
handleError(e);
}
},
};
expect(checkFile.indexOf(`"name": "foo"`)).toBeGreaterThanOrEqual(0);
expect(
files.indexOf("/tools/electron/postinstall.js")
).toBeGreaterThanOrEqual(0);
expect(files.indexOf("/tools/web/postinstall.js")).toBeGreaterThanOrEqual(
0
);
checkPath = "/package.json";
expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
checkFile = getFileContent(tree, checkPath);
const packageData: any = jsonParse(checkFile);
expect(packageData.scripts["serve.nest.foo"]).toBeDefined();
expect(packageData.scripts["start.nest.foo"]).toBeDefined();
});