Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
// TODO: find a way to unit test schematictask runners with install tasks
packageHandling.push((tree: Tree, context: SchematicContext) => {
const installPackageTask = context.addTask(new NodePackageInstallTask());
// console.log('packagesToRunXplat:', packagesToRunXplat);
context.addTask(
new RunSchematicTask('@nstudio/electron', 'tools', options),
[installPackageTask]
);
});
}
return chain([
prerun(options),
XplatHelpers.applyAppNamingConvention(options, 'electron'),
(tree: Tree, context: SchematicContext) =>
addAppFiles(options, options.name)(tree, context),
XplatElectrontHelpers.updateRootDeps(options),
...packageHandling,
XplatElectrontHelpers.addNpmScripts(options),
(tree: Tree, context: SchematicContext) => {
// grab the target app configuration
const workspaceConfig = readWorkspaceJson(tree);
// find app
const fullTargetAppName = options.target;
let targetConfig;
if (workspaceConfig && workspaceConfig.projects) {
targetConfig = workspaceConfig.projects[fullTargetAppName];
}
if (!targetConfig) {
throw new SchematicsException(
} else {
// TODO: find a way to unit test schematictask runners with install tasks
packageHandling.push((tree: Tree, context: SchematicContext) => {
const installPackageTask = context.addTask(new NodePackageInstallTask());
// console.log('packagesToRunXplat:', packagesToRunXplat);
context.addTask(
new RunSchematicTask('@nstudio/electron', 'tools', options),
[installPackageTask]
);
});
}
return chain([
prerun(options),
XplatHelpers.applyAppNamingConvention(options, 'electron'),
(tree: Tree, context: SchematicContext) =>
externalSchematic('@nstudio/electron', 'xplat', {
...options,
skipDependentPlatformFiles: true
}),
// use xplat or not
options.useXplat
? externalSchematic('@nstudio/electron-angular', 'xplat', options)
: noop(),
(tree: Tree, context: SchematicContext) =>
addAppFiles(options, options.name)(tree, context),
XplatElectronAngularHelpers.updateRootDeps(options),
...packageHandling,
XplatElectrontHelpers.addNpmScripts(options),
(tree: Tree, context: SchematicContext) => {
// grab the target app configuration
missingArgument(
'name',
'Provide a name for your app.',
'nx g @nstudio/angular:app my-app'
)
);
}
if (options.useXplat) {
// xplat is configured for sass only (at moment)
options.style = 'scss';
}
return chain([
prerun(options),
// adjust naming convention
XplatHelpers.applyAppNamingConvention(options, 'web'),
// use xplat or not
options.useXplat
? externalSchematic('@nstudio/angular', 'xplat', {
platforms: 'web',
framework: 'angular'
})
: noop(),
(tree: Tree, context: SchematicContext) => {
const nrwlWebOptions = {
...options,
skipInstall: true
};
let executionOptions: Partial;
if (options.useXplat) {
// when generating xplat architecture, ensure:
// 1. sass is used
missingArgument(
'name',
'Provide a name for your NativeScript app.',
'nx g @nstudio/nativescript-angular:app name'
)
);
}
if (options.setupSandbox) {
// always setup routing with sandbox
options.routing = true;
}
return chain([
prerun(options),
// adjust naming convention
XplatHelpers.applyAppNamingConvention(options, 'nativescript'),
// use xplat or not
options.useXplat
? externalSchematic('@nstudio/nativescript-angular', 'xplat', options)
: noop(),
// create app files
(tree: Tree, context: SchematicContext) =>
addAppFiles(options, options.name, options.useXplat ? '' : 'skipxplat'),
// add features
(tree: Tree, context: SchematicContext) =>
options.routing && options.useXplat
? addAppFiles(options, options.name, 'routing')(tree, context)
: noop()(tree, context),
// add app resources
(tree: Tree, context: SchematicContext) => {
// inside closure to ensure it uses the modifed options.name from applyAppNamingConvention
const directory = options.directory ? `${options.directory}/` : '';
export default function(options: Schema) {
if (!options.name) {
throw new SchematicsException(
missingArgument(
'name',
'Provide a name for your Ionic app.',
'nx g @nstudio/ionic:app name'
)
);
}
return chain([
prerun(options),
// adjust naming convention
XplatHelpers.applyAppNamingConvention(options, 'ionic'),
// create app files
(tree: Tree, context: SchematicContext) =>
addAppFiles(options, options.name)(tree, context),
// add root package dependencies
XplatIonicHelpers.updateRootDeps(options),
XplatHelpers.addPackageInstallTask(options),
// add start/clean scripts
(tree: Tree) => {
const scripts = {};
const platformApp = options.name.replace('-', '.');
const directory = options.directory ? `${options.directory}/` : '';
// ensure convenient clean script is added for workspace
scripts[
`clean`
] = `npx rimraf -- hooks node_modules package-lock.json && npm i`;
scripts[
missingArgument(
'name',
'Provide a name for your NativeScript app.',
'nx g @nstudio/nativescript:app name'
)
);
}
// if (options.setupSandbox) {
// // always setup routing with sandbox
// options.routing = true;
// }
return chain([
prerun(options),
// adjust naming convention
XplatHelpers.applyAppNamingConvention(options, 'nativescript'),
// create app files
(tree: Tree, context: SchematicContext) =>
addAppFiles(options, options.name),
// add app resources
(tree: Tree, context: SchematicContext) =>
// inside closure to ensure it uses the modifed options.name from applyAppNamingConvention
externalSchematic(
'@nstudio/nativescript',
'app-resources',
{
path: `apps/${options.name}`
},
{ interactive: false }
)(tree, context),
// add root package dependencies
XplatNativeScriptHelpers.updateRootDeps(options),