Skip to content

Commit 7da07d9

Browse files
committed
feat(@angular/cli): adds --animation flag to ng new
1 parent 0633130 commit 7da07d9

File tree

8 files changed

+47
-6
lines changed

8 files changed

+47
-6
lines changed

docs/documentation/new.md

+10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ Default applications are created in a directory of the same name, with an initia
6868
</p>
6969
</details>
7070

71+
<details>
72+
<summary>animation</summary>
73+
<p>
74+
`--animation` _default value: false_
75+
</p>
76+
<p>
77+
Generate with animation support.
78+
</p>
79+
</details>
80+
7181
<details>
7282
<summary>skip-commit</summary>
7383
<p>

packages/@angular/cli/blueprints/ng/files/__path__/app/app.component.spec.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import { TestBed, async } from '@angular/core/testing';<% if (routing) { %>
2-
import { RouterTestingModule } from '@angular/router/testing';<% } %>
2+
import { RouterTestingModule } from '@angular/router/testing';<% } %><% if (animation) { %>
3+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';<% } %>
34

45
import { AppComponent } from './app.component';
56

67
describe('AppComponent', () => {
78
beforeEach(async(() => {
8-
TestBed.configureTestingModule({<% if (routing) { %>
9+
TestBed.configureTestingModule({<% if (routing && animation) { %>
10+
imports: [
11+
RouterTestingModule,
12+
BrowserAnimationsModule
13+
],<% } %><% if (routing && !animation) { %>
914
imports: [
1015
RouterTestingModule
16+
],<% } %><% if (animation && !routing) { %>
17+
imports: [
18+
BrowserAnimationsModule
1119
],<% } %>
1220
declarations: [
1321
AppComponent

packages/@angular/cli/blueprints/ng/files/__path__/app/app.module.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { BrowserModule } from '@angular/platform-browser';
1+
<% if (animation) { %>import { BrowserAnimationsModule } from '@angular/platform-browser/animations';<%
2+
} else { %>import { BrowserModule } from '@angular/platform-browser';<% } %>
23
import { NgModule } from '@angular/core';
34
import { FormsModule } from '@angular/forms';
45
import { HttpModule } from '@angular/http';
@@ -10,8 +11,9 @@ import { AppComponent } from './app.component';
1011
declarations: [
1112
AppComponent
1213
],
13-
imports: [
14-
BrowserModule,
14+
imports: [<% if (animation) { %>
15+
BrowserAnimationsModule,<% } else { %>
16+
BrowserModule,<% } %>
1517
FormsModule,
1618
HttpModule<% if (routing) { %>,
1719
AppRoutingModule<% } %>

packages/@angular/cli/blueprints/ng/files/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"@angular/http": "^4.0.0",
2020
"@angular/platform-browser": "^4.0.0",
2121
"@angular/platform-browser-dynamic": "^4.0.0",
22-
"@angular/router": "^4.0.0",
22+
"@angular/router": "^4.0.0",<% if (animation) { %>
23+
"@angular/animations": "^4.0.0",<% } %>
2324
"core-js": "^2.4.1",
2425
"rxjs": "^5.1.0",
2526
"zone.js": "^0.8.4"

packages/@angular/cli/blueprints/ng/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default Blueprint.extend({
1313
{ name: 'prefix', type: String, default: 'app', aliases: ['p'] },
1414
{ name: 'style', type: String },
1515
{ name: 'routing', type: Boolean, default: false },
16+
{ name: 'animation', type: Boolean, default: false },
1617
{ name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
1718
{ name: 'inline-template', type: Boolean, default: false, aliases: ['it'] },
1819
{ name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] }
@@ -53,6 +54,7 @@ export default Blueprint.extend({
5354
styleExt: this.styleExt,
5455
relativeRootPath: relativeRootPath,
5556
routing: options.routing,
57+
animation: options.animation,
5658
inlineStyle: options.inlineStyle,
5759
inlineTemplate: options.inlineTemplate,
5860
tests: this.tests,

packages/@angular/cli/commands/new.ts

+6
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ const NewCommand = Command.extend({
108108
default: false,
109109
description: 'Generate a routing module.'
110110
},
111+
{
112+
name: 'animation',
113+
type: Boolean,
114+
default: false,
115+
description: 'Generate with animation support.'
116+
},
111117
{
112118
name: 'inline-style',
113119
type: Boolean,

packages/@angular/cli/tasks/init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export default Task.extend({
7474
style: commandOptions.style,
7575
prefix: commandOptions.prefix.trim() || 'app',
7676
routing: commandOptions.routing,
77+
animation: commandOptions.animation,
7778
inlineStyle: commandOptions.inlineStyle,
7879
inlineTemplate: commandOptions.inlineTemplate,
7980
ignoredUpdateFiles: ['favicon.ico'],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {ng} from '../../../utils/process';
2+
import {createProject} from '../../../utils/project';
3+
4+
5+
export default function() {
6+
return Promise.resolve()
7+
.then(() => createProject('animation-project', '--animation'))
8+
9+
// Try to run the unit tests.
10+
.then(() => ng('test', '--single-run'));
11+
}

0 commit comments

Comments
 (0)