Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (tree: Tree, context: SchematicContext) => {
const dependencies = {};
const devDependencies = {};
const xplatFoldername = XplatHelpers.getXplatFoldername('web', 'angular');
if (options.useXplat) {
dependencies[
`@${getNpmScope()}/web-scss`
] = `file:xplat/${xplatFoldername}/scss`;
const ionicXplatFoldername = XplatHelpers.getXplatFoldername(
'ionic',
'angular'
);
dependencies[
`@${getNpmScope()}/ionic-scss`
] = `file:xplat/${ionicXplatFoldername}/scss`;
}
const packageJson = getJsonFromFile(tree, 'package.json');
const hasAngularDeps = packageJson.dependencies['@angular/core'];
if (!hasAngularDeps) {
dependencies[`@angular/animations`] = angularVersion;
dependencies[`@angular/common`] = angularVersion;
dependencies[`@angular/compiler`] = angularVersion;
dependencies[`@angular/core`] = angularVersion;
dependencies[`@angular/forms`] = angularVersion;
function addAppFiles(options: Schema, appPath: string) {
const appname = getAppName(options, 'ionic');
const directory = options.directory ? `${options.directory}/` : '';
return branchAndMerge(
mergeWith(
apply(url(`./_files`), [
template({
...(options as any),
...getDefaultTemplateOptions(),
pathOffset: directory ? '../../../' : '../../',
appname,
xplatFolderName: XplatHelpers.getXplatFoldername('ionic')
}),
move(`apps/${directory}${appPath}`)
])
)
);
}
options: Schema,
appPath: string,
extra: string = ''
): Rule {
extra = extra ? `${extra}_` : '';
const appname = getAppName(options, 'nativescript');
const directory = options.directory ? `${options.directory}/` : '';
return branchAndMerge(
mergeWith(
apply(url(`./_${extra}files`), [
template({
...(options as any),
...getDefaultTemplateOptions(),
appname,
pathOffset: directory ? '../../../' : '../../',
xplatFolderName: XplatHelpers.getXplatFoldername('nativescript')
}),
move(`apps/${directory}${appPath}`)
])
)
);
}
chains.push((tree: Tree, context: SchematicContext) => {
const xplatFolderName = XplatHelpers.getXplatFoldername(
platform,
'angular'
);
return adjustBarrelIndex(
'component',
options,
`xplat/${xplatFolderName}/features/${componentSettings.featureName}/components/index.ts`,
true,
false,
true
)(tree, context);
});
chains.push((tree: Tree, context: SchematicContext) => {
const xplatFolderName = XplatHelpers.getXplatFoldername(
platform,
'angular'
);
return options.needsIndex
? addToFeature(
xplatFolderName,
'component',
options,
`xplat/${xplatFolderName}`,
tree,
'_index'
)(tree, context)
: noop()(tree, context);
});
}
options: Schema,
appPath: string,
extra: string = ''
): Rule {
extra = extra ? `${extra}_` : '';
const appname = getAppName(options, 'nativescript');
const directory = options.directory ? `${options.directory}/` : '';
return branchAndMerge(
mergeWith(
apply(url(`./_${extra}files`), [
template({
...(options as any),
...getDefaultTemplateOptions(),
appname,
pathOffset: directory ? '../../../' : '../../',
xplatFolderName: XplatHelpers.getXplatFoldername(
'nativescript',
'angular'
)
}),
move(`apps/${directory}${appPath}`)
])
)
);
}
function addAppFiles(
options: XplatElectrontHelpers.SchemaApp,
appPath: string
): Rule {
const appname = getAppName(options, 'electron');
const directory = options.directory ? `${options.directory}/` : '';
return branchAndMerge(
mergeWith(
apply(url(`./_files`), [
template({
...(options as any),
...getDefaultTemplateOptions(),
appname,
xplatFolderName: XplatHelpers.getXplatFoldername(
'electron',
'angular'
)
}),
move(`apps/${directory}${appPath}`)
])
)
);
}