diff --git a/docs/documentation/new.md b/docs/documentation/new.md index 5f1d644ea5be..151ab296131d 100644 --- a/docs/documentation/new.md +++ b/docs/documentation/new.md @@ -68,6 +68,16 @@ Default applications are created in a directory of the same name, with an initia

+
+ animation +

+ --animation (aliases: -a) default value: false +

+

+ Generate with animation support. +

+
+
skip-commit

diff --git a/packages/@angular/cli/blueprints/ng/files/__path__/app/app.component.spec.ts b/packages/@angular/cli/blueprints/ng/files/__path__/app/app.component.spec.ts index d61b4a947135..64066ed656bf 100644 --- a/packages/@angular/cli/blueprints/ng/files/__path__/app/app.component.spec.ts +++ b/packages/@angular/cli/blueprints/ng/files/__path__/app/app.component.spec.ts @@ -1,13 +1,21 @@ import { TestBed, async } from '@angular/core/testing';<% if (routing) { %> -import { RouterTestingModule } from '@angular/router/testing';<% } %> +import { RouterTestingModule } from '@angular/router/testing';<% } %><% if (animation) { %> +import { NoopAnimationsModule } from '@angular/platform-browser/animations';<% } %> import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(async(() => { - TestBed.configureTestingModule({<% if (routing) { %> + TestBed.configureTestingModule({<% if (routing && animation) { %> + imports: [ + RouterTestingModule, + NoopAnimationsModule + ],<% } %><% if (routing && !animation) { %> imports: [ RouterTestingModule + ],<% } %><% if (animation && !routing) { %> + imports: [ + NoopAnimationsModule ],<% } %> declarations: [ AppComponent diff --git a/packages/@angular/cli/blueprints/ng/files/__path__/app/app.module.ts b/packages/@angular/cli/blueprints/ng/files/__path__/app/app.module.ts index 2c4bc05c64e6..cee74941f775 100644 --- a/packages/@angular/cli/blueprints/ng/files/__path__/app/app.module.ts +++ b/packages/@angular/cli/blueprints/ng/files/__path__/app/app.module.ts @@ -1,4 +1,5 @@ -import { BrowserModule } from '@angular/platform-browser'; +import { BrowserModule } from '@angular/platform-browser';<% if (animation) { %> +import { BrowserAnimationsModule } from '@angular/platform-browser/animations';<% } %> import { NgModule } from '@angular/core'; <% if (routing) { %> import { AppRoutingModule } from './app-routing.module';<% } %> @@ -9,7 +10,8 @@ import { AppComponent } from './app.component'; AppComponent ], imports: [ - BrowserModule<% if (routing) { %>, + BrowserModule<% if (animation) { %>, + BrowserAnimationsModule<% } %><% if (routing) { %>, AppRoutingModule<% } %> ], providers: [], diff --git a/packages/@angular/cli/blueprints/ng/index.ts b/packages/@angular/cli/blueprints/ng/index.ts index 53516a38fe38..988aeb148b9c 100644 --- a/packages/@angular/cli/blueprints/ng/index.ts +++ b/packages/@angular/cli/blueprints/ng/index.ts @@ -13,6 +13,7 @@ export default Blueprint.extend({ { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'style', type: String }, { name: 'routing', type: Boolean, default: false }, + { name: 'animation', type: Boolean, default: false, aliases: ['a'] }, { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] }, { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] }, { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] } @@ -52,6 +53,7 @@ export default Blueprint.extend({ styleExt: this.styleExt, relativeRootPath: relativeRootPath, routing: options.routing, + animation: options.animation, inlineStyle: options.inlineStyle, inlineTemplate: options.inlineTemplate, tests: this.tests diff --git a/packages/@angular/cli/commands/new.ts b/packages/@angular/cli/commands/new.ts index 02ff828c130b..02734fe23e07 100644 --- a/packages/@angular/cli/commands/new.ts +++ b/packages/@angular/cli/commands/new.ts @@ -102,6 +102,13 @@ const NewCommand = Command.extend({ default: false, description: 'Generate a routing module.' }, + { + name: 'animation', + type: Boolean, + default: false, + aliases: ['a'], + description: 'Generate with animation support.' + }, { name: 'inline-style', type: Boolean, diff --git a/packages/@angular/cli/tasks/init.ts b/packages/@angular/cli/tasks/init.ts index 1bd981a8bb12..1fd9ff856576 100644 --- a/packages/@angular/cli/tasks/init.ts +++ b/packages/@angular/cli/tasks/init.ts @@ -74,6 +74,7 @@ export default Task.extend({ style: commandOptions.style, prefix: commandOptions.prefix.trim() || 'app', routing: commandOptions.routing, + animation: commandOptions.animation, inlineStyle: commandOptions.inlineStyle, inlineTemplate: commandOptions.inlineTemplate, ignoredUpdateFiles: ['favicon.ico'], diff --git a/tests/e2e/tests/commands/new/new-animation.ts b/tests/e2e/tests/commands/new/new-animation.ts new file mode 100644 index 000000000000..8e6499dc7922 --- /dev/null +++ b/tests/e2e/tests/commands/new/new-animation.ts @@ -0,0 +1,11 @@ +import {ng} from '../../../utils/process'; +import {createProject} from '../../../utils/project'; + + +export default function() { + return Promise.resolve() + .then(() => createProject('animation-project', '--animation')) + + // Try to run the unit tests. + .then(() => ng('test', '--single-run')); +}