From bdf9203724261ae4a75845f3a3cfe5bde6db7fb5 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 8 Sep 2023 10:19:13 +0000 Subject: [PATCH] feat(@schematics/angular): enable routing by default for new applications This commits updates the `routing` option in the `ng new` and `ng generation application` schematics to `true` by default and also removed the `Would you like to add Angular routing?` prompt. BREAKING CHANGE: Routing is enabled by default for new applications when using `ng generate application` and `ng new`. The `--no-routing` command line option can be used to disable this behaviour. --- packages/schematics/angular/application/index_spec.ts | 5 ++--- packages/schematics/angular/application/schema.json | 5 ++--- packages/schematics/angular/ng-new/index_spec.ts | 1 + packages/schematics/angular/ng-new/schema.json | 2 +- packages/schematics/angular/utility/standalone/rules_spec.ts | 1 + 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/schematics/angular/application/index_spec.ts b/packages/schematics/angular/application/index_spec.ts index 41d431f37e8c..857eb8122696 100644 --- a/packages/schematics/angular/application/index_spec.ts +++ b/packages/schematics/angular/application/index_spec.ts @@ -31,7 +31,6 @@ describe('Application Schematic', () => { const defaultOptions: ApplicationOptions = { name: 'foo', - routing: false, skipPackageJson: false, }; @@ -566,8 +565,8 @@ describe('Application Schematic', () => { expect(component).toMatch(/standalone: true/); }); - it('should create routing information when routing is true', async () => { - const options = { ...defaultOptions, standalone: true, routing: true }; + it('should create routing information by default', async () => { + const options = { ...defaultOptions, standalone: true }; const tree = await schematicRunner.runSchematic('application', options, workspaceTree); diff --git a/packages/schematics/angular/application/schema.json b/packages/schematics/angular/application/schema.json index 1ef4cc1e5317..95936b544b45 100644 --- a/packages/schematics/angular/application/schema.json +++ b/packages/schematics/angular/application/schema.json @@ -39,9 +39,8 @@ }, "routing": { "type": "boolean", - "description": "Create a routing NgModule.", - "default": false, - "x-prompt": "Would you like to add Angular routing?", + "description": "Creates an application with routing enabled.", + "default": true, "x-user-analytics": "ep.ng_routing" }, "prefix": { diff --git a/packages/schematics/angular/ng-new/index_spec.ts b/packages/schematics/angular/ng-new/index_spec.ts index 8d80fdd15f6f..a53b8de6f5c6 100644 --- a/packages/schematics/angular/ng-new/index_spec.ts +++ b/packages/schematics/angular/ng-new/index_spec.ts @@ -51,6 +51,7 @@ describe('Ng New Schematic', () => { jasmine.arrayContaining([ '/bar/tsconfig.app.json', '/bar/src/main.ts', + '/bar/src/app/app.routes.ts', '/bar/src/app/app.config.ts', ]), ); diff --git a/packages/schematics/angular/ng-new/schema.json b/packages/schematics/angular/ng-new/schema.json index ddc63cf6eec5..e827f696c0b7 100644 --- a/packages/schematics/angular/ng-new/schema.json +++ b/packages/schematics/angular/ng-new/schema.json @@ -91,7 +91,7 @@ }, "routing": { "type": "boolean", - "description": "Generate a routing module for the initial project.", + "description": "Enable routing in the initial project.", "x-user-analytics": "ep.ng_routing" }, "prefix": { diff --git a/packages/schematics/angular/utility/standalone/rules_spec.ts b/packages/schematics/angular/utility/standalone/rules_spec.ts index 66ea591aadd7..d79557a5f730 100644 --- a/packages/schematics/angular/utility/standalone/rules_spec.ts +++ b/packages/schematics/angular/utility/standalone/rules_spec.ts @@ -31,6 +31,7 @@ describe('standalone utilities', () => { { name: projectName, standalone, + routing: false, }, host, );