diff --git a/packages/schematics/angular/ng-new/index.ts b/packages/schematics/angular/ng-new/index.ts index 4ae4a8454ea1..a5229e6dcf86 100644 --- a/packages/schematics/angular/ng-new/index.ts +++ b/packages/schematics/angular/ng-new/index.ts @@ -15,6 +15,7 @@ import { empty, mergeWith, move, + noop, schematic, } from '@angular-devkit/schematics'; import { @@ -60,7 +61,7 @@ export default function (options: NgNewOptions): Rule { mergeWith( apply(empty(), [ schematic('workspace', workspaceOptions), - schematic('application', applicationOptions), + options.createApplication ? schematic('application', applicationOptions) : noop, move(options.directory || options.name), ]), ), diff --git a/packages/schematics/angular/ng-new/index_spec.ts b/packages/schematics/angular/ng-new/index_spec.ts index 268a3dd87508..8903428d9bab 100644 --- a/packages/schematics/angular/ng-new/index_spec.ts +++ b/packages/schematics/angular/ng-new/index_spec.ts @@ -56,4 +56,13 @@ describe('Ng New Schematic', () => { const moduleContent = tree.readContent('/foo/src/app/app.module.ts'); expect(moduleContent).toMatch(/declarations:\s*\[\s*AppComponent\s*\]/m); }); + + it('createApplication=false should create an empty workspace', () => { + const options = { ...defaultOptions, createApplication: false }; + + const tree = schematicRunner.runSchematic('ng-new', options); + const files = tree.files; + expect(files.indexOf('/bar/angular.json')).toBeGreaterThanOrEqual(0); + expect(files.indexOf('/bar/src')).toBe(-1); + }); }); diff --git a/packages/schematics/angular/ng-new/schema.json b/packages/schematics/angular/ng-new/schema.json index 5f4179e8cc74..cefb1a6a8974 100644 --- a/packages/schematics/angular/ng-new/schema.json +++ b/packages/schematics/angular/ng-new/schema.json @@ -131,6 +131,11 @@ "type": "boolean", "default": false, "alias": "S" + }, + "createApplication": { + "description": "Flag to toggle creation of an application in the new workspace.", + "type": "boolean", + "default": true } }, "required": [