Skip to content

Commit a0dde2b

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

File tree

7 files changed

+45
-4
lines changed

7 files changed

+45
-4
lines changed

docs/documentation/new.md

Lines changed: 10 additions & 0 deletions
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+
<code>--animation</code> (aliases: <code>-a</code>) <em>default value: false</em>
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

Lines changed: 10 additions & 2 deletions
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 { NoopAnimationsModule } 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+
NoopAnimationsModule
13+
],<% } %><% if (routing && !animation) { %>
914
imports: [
1015
RouterTestingModule
16+
],<% } %><% if (animation && !routing) { %>
17+
imports: [
18+
NoopAnimationsModule
1119
],<% } %>
1220
declarations: [
1321
AppComponent

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { BrowserModule } from '@angular/platform-browser';
1+
import { BrowserModule } from '@angular/platform-browser';<% if (animation) { %>
2+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';<% } %>
23
import { NgModule } from '@angular/core';
34
<% if (routing) { %>
45
import { AppRoutingModule } from './app-routing.module';<% } %>
@@ -9,7 +10,8 @@ import { AppComponent } from './app.component';
910
AppComponent
1011
],
1112
imports: [
12-
BrowserModule<% if (routing) { %>,
13+
BrowserModule<% if (animation) { %>,
14+
BrowserAnimationsModule<% } %><% if (routing) { %>,
1315
AppRoutingModule<% } %>
1416
],
1517
providers: [],

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

Lines changed: 2 additions & 0 deletions
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, aliases: ['a'] },
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'] }
@@ -52,6 +53,7 @@ export default Blueprint.extend({
5253
styleExt: this.styleExt,
5354
relativeRootPath: relativeRootPath,
5455
routing: options.routing,
56+
animation: options.animation,
5557
inlineStyle: options.inlineStyle,
5658
inlineTemplate: options.inlineTemplate,
5759
tests: this.tests

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ const NewCommand = Command.extend({
102102
default: false,
103103
description: 'Generate a routing module.'
104104
},
105+
{
106+
name: 'animation',
107+
type: Boolean,
108+
default: false,
109+
aliases: ['a'],
110+
description: 'Generate with animation support.'
111+
},
105112
{
106113
name: 'inline-style',
107114
type: Boolean,

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

Lines changed: 1 addition & 0 deletions
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'],
Lines changed: 11 additions & 0 deletions
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)