diff --git a/docs/documentation/new.md b/docs/documentation/new.md index c9361d377939..74cff51bfbca 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
(aliases: -a
) default value: false
+
+ Generate with animation support. +
+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 7f6fef4348cd..6e1aa2b1d638 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 { BrowserAnimationsModule } 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, + BrowserAnimationsModule + ],<% } %><% if (routing && !animation) { %> imports: [ RouterTestingModule + ],<% } %><% if (animation && !routing) { %> + imports: [ + BrowserAnimationsModule ],<% } %> 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 d1993885a14f..2b5aaa6e45ef 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'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; @@ -11,7 +12,8 @@ import { AppComponent } from './app.component'; AppComponent ], imports: [ - BrowserModule, + BrowserModule,<% if (animation) { %> + BrowserAnimationsModule,<% } %> FormsModule, HttpModule<% if (routing) { %>, AppRoutingModule<% } %> diff --git a/packages/@angular/cli/blueprints/ng/files/package.json b/packages/@angular/cli/blueprints/ng/files/package.json index b12fb3dbd234..871bbc4dfd07 100644 --- a/packages/@angular/cli/blueprints/ng/files/package.json +++ b/packages/@angular/cli/blueprints/ng/files/package.json @@ -19,7 +19,8 @@ "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", - "@angular/router": "^4.0.0", + "@angular/router": "^4.0.0",<% if (animation) { %> + "@angular/animations": "^4.0.0",<% } %> "core-js": "^2.4.1", "rxjs": "^5.1.0", "zone.js": "^0.8.4" diff --git a/packages/@angular/cli/blueprints/ng/index.ts b/packages/@angular/cli/blueprints/ng/index.ts index 2fb760175ead..0f54400fef8b 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'] } @@ -53,6 +54,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 cdc6a8edd578..a994d72a1d01 100644 --- a/packages/@angular/cli/commands/new.ts +++ b/packages/@angular/cli/commands/new.ts @@ -108,6 +108,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 742605e010b5..f279dedba40d 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')); +}