Skip to content

Commit ac25cf0

Browse files
authored
Merge branch 'master' into live-reload
2 parents 3c79e5b + 121c390 commit ac25cf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+990
-92
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ matrix:
2525
- node_js: "6"
2626
os: linux
2727
env: NODE_SCRIPT="tests/run_e2e.js --glob=tests/build/**"
28+
- node_js: "6"
29+
os: linux
30+
env: NODE_SCRIPT="tests/run_e2e.js --eject --glob=tests/build/**"
2831
- node_js: "6"
2932
os: linux
3033
env: NODE_SCRIPT="tests/run_e2e.js --ignore=**/tests/build/**"

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ with NPM 3 or higher.
3535

3636
* [Installation](#installation)
3737
* [Usage](#usage)
38-
* [Generating a New Project](#generating-and-serving-an-angular2-project-via-a-development-server)
38+
* [Generating a New Project](#generating-and-serving-an-angular-project-via-a-development-server)
3939
* [Generating Components, Directives, Pipes and Services](#generating-components-directives-pipes-and-services)
4040
* [Updating Angular CLI](#updating-angular-cli)
4141
* [Development Hints for hacking on Angular CLI](#development-hints-for-hacking-on-angular-cli)
@@ -54,7 +54,7 @@ npm install -g @angular/cli
5454
ng help
5555
```
5656

57-
### Generating and serving an Angular2 project via a development server
57+
### Generating and serving an Angular project via a development server
5858

5959
```bash
6060
ng new PROJECT_NAME

docs/documentation/build.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ By default, the development build target and environment are used.
2222
The mapping used to determine which environment file is used can be found in `.angular-cli.json`:
2323

2424
```json
25+
"environmentSource": "environments/environment.ts",
2526
"environments": {
26-
"source": "environments/environment.ts",
2727
"dev": "environments/environment.ts",
2828
"prod": "environments/environment.prod.ts"
2929
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"@types/express": "^4.0.32",
118118
"@types/fs-extra": "0.0.37",
119119
"@types/glob": "^5.0.29",
120-
"@types/jasmine": "^2.2.32",
120+
"@types/jasmine": "~2.2.0",
121121
"@types/lodash": "4.14.50",
122122
"@types/mock-fs": "^3.6.30",
123123
"@types/node": "^6.0.36",

packages/@angular/cli/addon/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = {
2121
return {
2222
'build': require('../commands/build').default,
2323
'serve': require('../commands/serve').default,
24+
'eject': require('../commands/eject').default,
2425
'new': require('../commands/new').default,
2526
'generate': require('../commands/generate').default,
2627
'destroy': require('../commands/destroy').default,

packages/@angular/cli/blueprints/ng2/files/__path__/polyfills.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import 'core-js/es7/reflect';
5353
/***************************************************************************************************
5454
* Zone JS is required by Angular itself.
5555
*/
56-
import 'zone.js/dist/zone'; // Included with Angular-CLI.
56+
import 'zone.js/dist/zone'; // Included with Angular CLI.
5757

5858

5959

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"styles.<%= styleExt %>"
2323
],
2424
"scripts": [],
25+
"environmentSource": "environments/environment.ts",
2526
"environments": {
26-
"source": "environments/environment.ts",
2727
"dev": "environments/environment.ts",
2828
"prod": "environments/environment.prod.ts"
2929
}

packages/@angular/cli/blueprints/ng2/files/protractor.conf.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ exports.config = {
2020
defaultTimeoutInterval: 30000,
2121
print: function() {}
2222
},
23-
useAllAngular2AppRoots: true,
2423
beforeLaunch: function() {
2524
require('ts-node').register({
2625
project: 'e2e'

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export const baseBuildCommandOptions: any = [
3535
description: 'define the output filename cache-busting hashing mode',
3636
aliases: ['oh']
3737
},
38-
{ name: 'stats-json', type: Boolean, default: false },
3938
{
4039
name: 'poll',
4140
type: Number,
@@ -55,7 +54,8 @@ const BuildCommand = Command.extend({
5554
aliases: ['b'],
5655

5756
availableOptions: baseBuildCommandOptions.concat([
58-
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] }
57+
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
58+
{ name: 'stats-json', type: Boolean, default: false }
5959
]),
6060

6161
run: function (commandOptions: BuildTaskOptions) {
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { BuildOptions } from '../models/build-options';
2+
import { Version } from '../upgrade/version';
3+
import {baseBuildCommandOptions} from './build';
4+
5+
const Command = require('../ember-cli/lib/models/command');
6+
7+
// defaults for BuildOptions
8+
export const baseEjectCommandOptions: any = [
9+
...baseBuildCommandOptions,
10+
{ name: 'force', 'type': Boolean }
11+
];
12+
13+
export interface EjectTaskOptions extends BuildOptions {
14+
force?: boolean;
15+
}
16+
17+
18+
const EjectCommand = Command.extend({
19+
name: 'eject',
20+
description: 'Ejects your app and output the proper webpack configuration and scripts.',
21+
22+
availableOptions: baseEjectCommandOptions,
23+
24+
run: function (commandOptions: EjectTaskOptions) {
25+
const project = this.project;
26+
const EjectTask = require('../tasks/eject').default;
27+
const ejectTask = new EjectTask({
28+
cliProject: project,
29+
ui: this.ui,
30+
});
31+
32+
return ejectTask.run(commandOptions);
33+
}
34+
});
35+
36+
37+
export default EjectCommand;

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ const HelpCommand = Command.extend({
5656

5757
if (rawArgs.length > 0) {
5858
if (cmd === rawArgs[0]) {
59-
this.ui.writeLine(command.printDetailedHelp(commandOptions));
59+
if (command.printDetailedHelp(commandOptions)) {
60+
this.ui.writeLine(command.printDetailedHelp(commandOptions));
61+
} else {
62+
this.ui.writeLine(command.printBasicHelp(commandOptions));
63+
}
6064
}
6165
} else {
6266
this.ui.writeLine(command.printBasicHelp(commandOptions));

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

+19-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const Command = require('../ember-cli/lib/models/command');
22
import * as path from 'path';
33
import * as child_process from 'child_process';
44
import * as chalk from 'chalk';
5+
import { CliConfig } from '../models/config';
6+
57

68
const VersionCommand = Command.extend({
79
name: 'version',
@@ -40,6 +42,13 @@ const VersionCommand = Command.extend({
4042

4143
ngCliVersion = `local (v${pkg.version}, branch: ${gitBranch})`;
4244
}
45+
const config = CliConfig.fromProject();
46+
if (config && config.config.project.version !== pkg.version) {
47+
ngCliVersion += ` [${config.config.project.version}]`;
48+
}
49+
if (config && config.config.project.ejected) {
50+
ngCliVersion += ' (e)';
51+
}
4352

4453
if (projPkg) {
4554
roots.forEach(root => {
@@ -76,12 +85,16 @@ const VersionCommand = Command.extend({
7685
},
7786

7887
getVersion: function(moduleName: string): string {
79-
const modulePkg = require(path.resolve(
80-
this.project.root,
81-
'node_modules',
82-
moduleName,
83-
'package.json'));
84-
return modulePkg.version;
88+
try {
89+
const modulePkg = require(path.resolve(
90+
this.project.root,
91+
'node_modules',
92+
moduleName,
93+
'package.json'));
94+
return modulePkg.version;
95+
} catch (e) {
96+
return 'error';
97+
}
8598
},
8699

87100
printVersion: function (module: string, version: string) {

packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface BaseHrefWebpackPluginOptions {
33
}
44

55
export class BaseHrefWebpackPlugin {
6-
constructor(private options: BaseHrefWebpackPluginOptions) { }
6+
constructor(public readonly options: BaseHrefWebpackPluginOptions) { }
77

88
apply(compiler: any): void {
99
// Ignore if baseHref is not passed

packages/@angular/cli/lib/config/schema.json

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
},
1414
"name": {
1515
"type": "string"
16+
},
17+
"ejected": {
18+
"description": "Whether or not this project was ejected.",
19+
"type": "boolean",
20+
"default": false
1621
}
1722
},
1823
"additionalProperties": false
@@ -147,6 +152,10 @@
147152
},
148153
"additionalProperties": false
149154
},
155+
"environmentSource":{
156+
"description": "Source file for environment config.",
157+
"type": "string"
158+
},
150159
"environments": {
151160
"description": "Name and corresponding file for environment config.",
152161
"type": "object",

packages/@angular/cli/models/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function getUserHome() {
3636

3737
export class CliConfig extends CliConfigBase<ConfigInterface> {
3838
static configFilePath(projectPath?: string): string {
39-
// Find the configuration, either where specified, in the angular-cli project
39+
// Find the configuration, either where specified, in the Angular CLI project
4040
// (if it's in node_modules) or from the current process.
4141
return (projectPath && _findUp(CLI_CONFIG_FILE_NAME, projectPath))
4242
|| (projectPath && _findUp(CLI_CONFIG_FILE_NAME_ALT, projectPath))

packages/@angular/cli/models/webpack-configs/common.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { WebpackConfigOptions } from '../webpack-config';
99
const autoprefixer = require('autoprefixer');
1010
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
1111
const HtmlWebpackPlugin = require('html-webpack-plugin');
12-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
12+
1313

1414
/**
1515
* Enumerate loaders and their dependencies from this file to let the dependency validator
@@ -97,7 +97,6 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
9797
path: path.resolve(projectRoot, buildOptions.outputPath),
9898
publicPath: buildOptions.deployUrl,
9999
filename: `[name]${hashFormat.chunk}.bundle.js`,
100-
sourceMapFilename: `[name]${hashFormat.chunk}.bundle.map`,
101100
chunkFilename: `[id]${hashFormat.chunk}.chunk.js`
102101
},
103102
module: {

packages/@angular/cli/models/webpack-configs/styles.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '../../plugins/suppress-entry-chunks-webpack-plugin';
66
import { extraEntryParser, getOutputHashFormat } from './utils';
77
import { WebpackConfigOptions } from '../webpack-config';
8+
import { pluginArgs } from '../../tasks/eject';
89

910
const cssnano = require('cssnano');
1011
const autoprefixer = require('autoprefixer');
@@ -104,17 +105,23 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
104105

105106
// load global css as css files
106107
if (globalStylePaths.length > 0) {
107-
rules.push(...baseRules.map(({test, loaders}) => ({
108-
include: globalStylePaths, test, loaders: ExtractTextPlugin.extract({
108+
rules.push(...baseRules.map(({test, loaders}) => {
109+
const extractTextPlugin = {
109110
use: [
110111
...commonLoaders,
111112
...loaders
112113
],
113114
fallback: 'style-loader',
114115
// publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
115116
publicPath: ''
116-
})
117-
})));
117+
};
118+
const ret: any = {
119+
include: globalStylePaths, test, loaders: ExtractTextPlugin.extract(extractTextPlugin)
120+
};
121+
// Save the original options as arguments for eject.
122+
ret[pluginArgs] = extractTextPlugin;
123+
return ret;
124+
}));
118125
}
119126

120127
// supress empty .js files in css only entry points

packages/@angular/cli/models/webpack-configs/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const getTestConfig = function (projectRoot, environment, appConfig, testConfig)
103103
// This plugin is responsible for swapping the environment files.
104104
// Since it takes a RegExp as first parameter, we need to escape the path.
105105
// See https://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin
106-
new RegExp(path.resolve(appRoot, appConfig.environments['source'])
106+
new RegExp(path.resolve(appRoot, appConfig.environmentSource)
107107
.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')),
108108
path.resolve(appRoot, appConfig.environments[environment])
109109
),

packages/@angular/cli/models/webpack-configs/typescript.ts

+41-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
3+
import { stripIndent } from 'common-tags';
34
import {AotPlugin, AotPluginOptions} from '@ngtools/webpack';
45
import { WebpackConfigOptions } from '../webpack-config';
56

@@ -16,22 +17,51 @@ function _createAotPlugin(wco: WebpackConfigOptions, options: any) {
1617
const { appConfig, projectRoot, buildOptions } = wco;
1718

1819
// Read the environment, and set it in the compiler host.
19-
let hostOverrideFileSystem: any = {};
20+
let hostReplacementPaths: any = {};
2021
// process environment file replacement
2122
if (appConfig.environments) {
22-
if (!('source' in appConfig.environments)) {
23-
throw new SilentError(`Environment configuration does not contain "source" entry.`);
23+
if (!appConfig.environmentSource) {
24+
let migrationMessage = '';
25+
if ('source' in appConfig.environments) {
26+
migrationMessage = '\n\n' + stripIndent`
27+
A new environmentSource entry replaces the previous source entry inside environments.
28+
29+
To migrate angular-cli.json follow the example below:
30+
31+
Before:
32+
33+
"environments": {
34+
"source": "environments/environment.ts",
35+
"dev": "environments/environment.ts",
36+
"prod": "environments/environment.prod.ts"
37+
}
38+
39+
40+
After:
41+
42+
"environmentSource": "environments/environment.ts",
43+
"environments": {
44+
"dev": "environments/environment.ts",
45+
"prod": "environments/environment.prod.ts"
46+
}
47+
`;
48+
}
49+
throw new SilentError(
50+
`Environment configuration does not contain "environmentSource" entry.${migrationMessage}`
51+
);
52+
2453
}
2554
if (!(buildOptions.environment in appConfig.environments)) {
2655
throw new SilentError(`Environment "${buildOptions.environment}" does not exist.`);
2756
}
2857

2958
const appRoot = path.resolve(projectRoot, appConfig.root);
30-
const sourcePath = appConfig.environments['source'];
59+
const sourcePath = appConfig.environmentSource;
3160
const envFile = appConfig.environments[buildOptions.environment];
32-
const environmentContent = fs.readFileSync(path.join(appRoot, envFile)).toString();
3361

34-
hostOverrideFileSystem = { [path.join(appRoot, sourcePath)]: environmentContent };
62+
hostReplacementPaths = {
63+
[path.join(appRoot, sourcePath)]: path.join(appRoot, envFile)
64+
};
3565
}
3666

3767
return new AotPlugin(Object.assign({}, {
@@ -40,15 +70,18 @@ function _createAotPlugin(wco: WebpackConfigOptions, options: any) {
4070
i18nFile: buildOptions.i18nFile,
4171
i18nFormat: buildOptions.i18nFormat,
4272
locale: buildOptions.locale,
43-
hostOverrideFileSystem
73+
hostReplacementPaths
4474
}, options));
4575
}
4676

4777

4878
export const getNonAotConfig = function(wco: WebpackConfigOptions) {
4979
const { projectRoot, appConfig } = wco;
5080
let exclude = [ '**/*.spec.ts' ];
51-
if (appConfig.test) { exclude.push(path.join(projectRoot, appConfig.root, appConfig.test)); };
81+
if (appConfig.test) {
82+
exclude.push(path.join(projectRoot, appConfig.root, appConfig.test));
83+
}
84+
5285
return {
5386
module: {
5487
rules: [

packages/@angular/cli/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"keywords": [
1111
"angular",
12-
"angular-cli"
12+
"angular-cli",
13+
"Angular CLI"
1314
],
1415
"repository": {
1516
"type": "git",

0 commit comments

Comments
 (0)