Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function updateScripts(path: string, config: any, tree: Tree, _options: any, _context: SchematicContext) {
const project = getProject(tree, _options);
if (!config['scripts']) {
config.scripts = {};
}
let additionalFlags = '';
// Ivy support
const postInstall: string = config.scripts['postinstall'] || '';
if (postInstall.startsWith('ngcc')) {
config.scripts['postinstall:bak'] = postInstall;
config.scripts['postinstall'] = 'ngcc';
_context.addTask(new RunSchematicTask('npmRun', {script: 'postinstall'}));
}
if (!_options.host) {
// external web components need single bundle
additionalFlags = '--single-bundle';
}
// Heuristic for default project
if (!project.root) {
config.scripts['build:externals'] = `ng build --extra-webpack-config ${path}webpack.externals.js --prod ${additionalFlags}`;
}
if (_options.project) {
config.scripts[`build:${_options.project}:externals`] = `ng build --extra-webpack-config ${path}webpack.externals.js --prod --project ${_options.project} ${additionalFlags}`;
}
}
return (host: Tree, context: SchematicContext) => {
const packageInstall = context.addTask(new NodePackageInstallTask());
context.addTask(new RunSchematicTask('cap-init', { command: 'npx', args: ['cap', 'init', projectName, '--npm-client', npmTool, '--web-dir', webDir] }), [packageInstall]);
return host;
};
}
(tree: Tree, context: IgxSchematicContext) => {
const installChain = [];
if (!options.skipInstall) {
const installTask = context.addTask(new NodePackageInstallTask(options.name));
installChain.push(installTask);
}
if (!options.skipGit) {
const gitTask = context.addTask(
new RepositoryInitializerTask(options.name, { message: `Initial commit for project: ${options.name}` }),
[...installChain] //copy
);
installChain.push(gitTask);
}
if (!options.skipInstall && !allOptionsProvided) {
context.addTask(new RunSchematicTask("start", { directory: options.name }), installChain);
}
return tree;
}
]);
nextRules.push((tree: Tree, context: SchematicContext) => {
const installTaskId = context.addTask(new NodePackageInstallTask());
context.addTask(new RunSchematicTask('scully', options), [installTaskId]);
});
return (tree: Tree, context: SchematicContext) => {
const v = version();
const angularCoreVersion = getPeerDependencyVersionFromPackageJson('@angular/core');
const angularCdkVersion = getPeerDependencyVersionFromPackageJson('@angular/cdk');
addDevDependencyToPackageJson(tree, 'nyan-builder', v);
addDevDependencyToPackageJson(tree, '@angular/cdk', angularCdkVersion);
addDevDependencyToPackageJson(tree, '@schematics/angular', angularCoreVersion);
const installTaskId = context.addTask(new NodePackageInstallTask());
context.addTask(new RunSchematicTask('setup', options), [installTaskId]);
};
}
return (_, context: SchematicContext) => {
const postInstallTask = context.addTask(
new RunSchematicTask(
join(__dirname, '../../../migrations.json'),
'add-postinstall',
{}
)
);
return chain([
addUpdateTask('@angular/core', '9.0.0-rc.4', [postInstallTask]),
addUpdateTask('@angular/cli', '9.0.0-rc.4', [postInstallTask])
])
};
}
return (tree, context) => {
const pkgJson = require('../../package.json');
const taskDeps: TaskId[] = [];
const addedLocalforage = addToPackageJson(tree, 'localforage', pkgJson.peerDependencies.localforage);
const hasNgforage = hasDependency(tree, 'ngforage');
if (addedLocalforage || !hasNgforage) {
taskDeps.push(context.addTask(new NodePackageInstallTask()));
}
context.addTask(new RunSchematicTask('ng-add-setup-project', options), taskDeps);
};
}
function _migrateOnly(info, context, from, to) {
if (!info) {
return rxjs_1.of();
}
const target = info.installed;
if (!target || !target.updateMetadata.migrations) {
return rxjs_1.of(undefined);
}
const collection = (target.updateMetadata.migrations.match(/^[./]/)
? info.name + '/'
: '') + target.updateMetadata.migrations;
context.addTask(new tasks_1.RunSchematicTask('@schematics/update', 'migrate', {
package: info.name,
collection,
from: from,
to: to || target.version,
}));
return rxjs_1.of(undefined);
}
function _getUpdateMetadata(packageJson, logger) {
function _migrateOnly(info, context, from, to) {
if (!info) {
return rxjs_1.of();
}
const target = info.installed;
if (!target || !target.updateMetadata.migrations) {
return rxjs_1.of(undefined);
}
const collection = (target.updateMetadata.migrations.match(/^[./]/)
? info.name + '/'
: '') + target.updateMetadata.migrations;
context.addTask(new tasks_1.RunSchematicTask('@schematics/update', 'migrate', {
package: info.name,
collection,
from: from,
to: to || target.version,
}));
return rxjs_1.of(undefined);
}
function _getUpdateMetadata(packageJson, logger) {
return (host: Tree, context: SchematicContext) => {
if (!options.skipPackageJson) {
addPackageToPackageJson(host, 'ng-zorro-antd', zorroVersion);
if (options.gestures) {
addPackageToPackageJson(host, 'hammerjs', hammerjsVersion);
}
}
const installTaskId = context.addTask(new NodePackageInstallTask());
context.addTask(new RunSchematicTask('ng-add-setup-project', options), [installTaskId]);
if (options.template) {
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(workspace, options.project);
const style = getProjectStyle(project);
context.addTask(new RunSchematicTask(options.template, {...options, style: style}));
}
};
}