diff --git a/packages/workspace/src/schematics/ng-new/ng-new.ts b/packages/workspace/src/schematics/ng-new/ng-new.ts index 7a820890ec0ef..30c200239458a 100644 --- a/packages/workspace/src/schematics/ng-new/ng-new.ts +++ b/packages/workspace/src/schematics/ng-new/ng-new.ts @@ -100,21 +100,24 @@ function addDependencies(options: Schema) { { '@nrwl/angular': nxVersion }, - {} + {}, + false ); } else if (options.preset === 'react') { return addDepsToPackageJson( {}, { '@nrwl/react': nxVersion - } + }, + false ); } else if (options.preset === 'web-components') { return addDepsToPackageJson( {}, { '@nrwl/web': nxVersion - } + }, + false ); } else { return addDepsToPackageJson( @@ -123,7 +126,8 @@ function addDependencies(options: Schema) { }, { '@nrwl/nest': nxVersion - } + }, + false ); } } diff --git a/packages/workspace/src/utils/ast-utils.ts b/packages/workspace/src/utils/ast-utils.ts index ab025b6a8d44f..c9b992fe7841b 100644 --- a/packages/workspace/src/utils/ast-utils.ts +++ b/packages/workspace/src/utils/ast-utils.ts @@ -93,6 +93,7 @@ export function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[] { export interface Change { apply(host: any): Promise; + readonly type: string; readonly path: string | null; readonly order: number; @@ -104,6 +105,7 @@ export class NoopChange implements Change { description = 'No operation.'; order = Infinity; path = null; + apply() { return Promise.resolve(); } @@ -392,7 +394,11 @@ export function updateJsonInTree( let installAdded = false; -export function addDepsToPackageJson(deps: any, devDeps: any): Rule { +export function addDepsToPackageJson( + deps: any, + devDeps: any, + addInstall = true +): Rule { return updateJsonInTree('package.json', (json, context: SchematicContext) => { json.dependencies = { ...deps, @@ -402,7 +408,7 @@ export function addDepsToPackageJson(deps: any, devDeps: any): Rule { ...devDeps, ...(json.devDependencies || {}) }; - if (!installAdded) { + if (addInstall && !installAdded) { context.addTask(new NodePackageInstallTask()); installAdded = true; }