Skip to content

Commit c096afb

Browse files
authored
feat(@angular/cli): add ng4 option to ng new (#4507)
This allows to create a project with Angular 4 in the template. Also fixes a few issues with ng4.
1 parent f2f02a6 commit c096afb

File tree

10 files changed

+21
-19
lines changed

10 files changed

+21
-19
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ matrix:
3333
- node_js: "6"
3434
os: linux
3535
env: NODE_SCRIPT="tests/run_e2e.js --nightly"
36+
- node_js: "6"
37+
os: linux
38+
env: NODE_SCRIPT="tests/run_e2e.js --ng4"
3639
- node_js: "7"
3740
os: linux
3841
env: NODE_SCRIPT=tests/run_e2e.js

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
},
1313
"private": true,
1414
"dependencies": {
15-
"@angular/common": "^2.3.1",
16-
"@angular/compiler": "^2.3.1",
17-
"@angular/core": "^2.3.1",
18-
"@angular/forms": "^2.3.1",
19-
"@angular/http": "^2.3.1",
20-
"@angular/platform-browser": "^2.3.1",
21-
"@angular/platform-browser-dynamic": "^2.3.1",
22-
"@angular/router": "^3.3.1",
15+
"@angular/common": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
16+
"@angular/compiler": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
17+
"@angular/core": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
18+
"@angular/forms": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
19+
"@angular/http": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
20+
"@angular/platform-browser": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
21+
"@angular/platform-browser-dynamic": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
22+
"@angular/router": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^3.4.0' %>",
2323
"core-js": "^2.4.1",
2424
"rxjs": "^5.0.1",
2525
"ts-helpers": "^1.1.1",
2626
"zone.js": "^0.7.2"
2727
},
2828
"devDependencies": {
2929
"@angular/cli": "<%= version %>",
30-
"@angular/compiler-cli": "^2.3.1",
30+
"@angular/compiler-cli": "<%= ng4 ? '>=4.0.0-beta <5.0.0' : '^2.4.0' %>",
3131
"@types/jasmine": "2.5.38",
3232
"@types/node": "^6.0.42",
3333
"codelyzer": "~2.0.0-beta.1",

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

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default Blueprint.extend({
4848
routing: options.routing,
4949
inlineStyle: options.inlineStyle,
5050
inlineTemplate: options.inlineTemplate,
51+
ng4: options.ng4,
5152
tests: this.tests
5253
};
5354
},

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

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const InitCommand: any = Command.extend({
1010
{ name: 'dry-run', type: Boolean, default: false, aliases: ['d'] },
1111
{ name: 'verbose', type: Boolean, default: false, aliases: ['v'] },
1212
{ name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] },
13+
{ name: 'ng4', type: Boolean, default: false },
1314
{ name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] },
1415
{ name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] },
1516
{ name: 'skip-tests', type: Boolean, default: false, aliases: ['st'] },

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

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const NewCommand = Command.extend({
1515
{ name: 'dry-run', type: Boolean, default: false, aliases: ['d'] },
1616
{ name: 'verbose', type: Boolean, default: false, aliases: ['v'] },
1717
{ name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] },
18+
{ name: 'ng4', type: Boolean, default: false },
1819
{ name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] },
1920
{ name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] },
2021
{ name: 'skip-tests', type: Boolean, default: false, aliases: ['st'] },

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

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default Task.extend({
7171
inlineStyle: commandOptions.inlineStyle,
7272
inlineTemplate: commandOptions.inlineTemplate,
7373
ignoredUpdateFiles: ['favicon.ico'],
74+
ng4: commandOptions.ng4,
7475
skipGit: commandOptions.skipGit,
7576
skipTests: commandOptions.skipTests
7677
};

packages/@ngtools/webpack/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"source-map": "^0.5.6"
3232
},
3333
"peerDependencies": {
34-
"@angular/compiler": "^2.3.1",
35-
"@angular/compiler-cli": "^2.3.1",
36-
"@angular/core": "^2.3.1",
34+
"@angular/compiler": "^2.3.1 || >=4.0.0-beta <5.0.0",
35+
"@angular/compiler-cli": "^2.3.1 || >=4.0.0-beta <5.0.0",
36+
"@angular/core": "^2.3.1 || >=4.0.0-beta <5.0.0",
3737
"@angular/tsc-wrapped": "^0.5.0",
3838
"typescript": "^2.0.2",
3939
"webpack": "2.2.0"

tests/e2e/setup/500-create-project.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function() {
2424
} else {
2525
// Otherwise create a project from scratch.
2626
createProject = Promise.resolve()
27-
.then(() => ng('new', 'test-project', '--skip-npm'))
27+
.then(() => ng('new', 'test-project', '--skip-npm', ...(argv['ng4'] ? ['--ng4'] : [])))
2828
.then(() => expectFileToExist(join(process.cwd(), 'test-project')))
2929
.then(() => process.chdir('./test-project'));
3030
}
@@ -37,7 +37,7 @@ export default function() {
3737
});
3838
}))
3939
.then(() => {
40-
if (argv.nightly || argv['ng-sha']) {
40+
if (argv['nightly'] || argv['ng-sha']) {
4141
const label = argv['ng-sha'] ? `#2.0.0-${argv['ng-sha']}` : '';
4242
return updateJsonFile('package.json', json => {
4343
// Install over the project with nightly builds.

tests/e2e/tests/build/rebuild-css-change.ts

-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
import {appendToFile} from '../../utils/fs';
88

99
const webpackGoodRegEx = /webpack: bundle is now VALID|webpack: Compiled successfully./;
10-
const webpackBadRegEx = /webpack: bundle is now INVALID|webpack: Compiling.../;
1110

1211
export default function() {
1312
if (process.platform.startsWith('win')) {
@@ -17,10 +16,8 @@ export default function() {
1716
return silentExecAndWaitForOutputToMatch('ng', ['serve'], webpackGoodRegEx)
1817
// Should trigger a rebuild.
1918
.then(() => exec('touch', 'src/main.ts'))
20-
.then(() => waitForAnyProcessOutputToMatch(webpackBadRegEx, 10000))
2119
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 10000))
2220
.then(() => appendToFile('src/app/app.component.css', ':host { color: blue; }'))
23-
.then(() => waitForAnyProcessOutputToMatch(webpackBadRegEx, 10000))
2421
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 10000))
2522
.then(() => killAllProcesses(), (err: any) => {
2623
killAllProcesses();

tests/e2e/tests/build/rebuild.ts

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ export default function() {
6060
export class AppModule { }
6161
`))
6262
// Should trigger a rebuild with a new bundle.
63-
.then(() => waitForAnyProcessOutputToMatch(
64-
/webpack: bundle is now INVALID|webpack: Compiling.../, 10000))
6563
.then(() => waitForAnyProcessOutputToMatch(
6664
/webpack: bundle is now VALID|webpack: Compiled successfully./, 10000))
6765
// Count the bundles.

0 commit comments

Comments
 (0)