Skip to content

Commit 407fde0

Browse files
authored
Merge branch 'master' into refactor-platform-server
2 parents 5788df0 + c8e5359 commit 407fde0

File tree

27 files changed

+131
-46
lines changed

27 files changed

+131
-46
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ ng serve
5757
```
5858
Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
5959

60-
You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
60+
You can configure the default HTTP host and port used by the development server with two command-line options :
6161

6262
```bash
63-
ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153
63+
ng serve --host 0.0.0.0 --port 4201
6464
```
6565

6666
### Generating Components, Directives, Pipes and Services
@@ -88,6 +88,7 @@ Directive | `ng g directive my-new-directive`
8888
Pipe | `ng g pipe my-new-pipe`
8989
Service | `ng g service my-new-service`
9090
Class | `ng g class my-new-class`
91+
Guard | `ng g guard my-new-guard`
9192
Interface | `ng g interface my-new-interface`
9293
Enum | `ng g enum my-new-enum`
9394
Module | `ng g module my-module`
@@ -111,7 +112,7 @@ npm install -g @angular/cli@latest
111112

112113
Local project package:
113114
```bash
114-
rm -rf node_modules dist # use rmdir on Windows
115+
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
115116
npm install --save-dev @angular/cli@latest
116117
npm install
117118
```

docs/documentation/build.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ or `ng serve --prod` will also make use of uglifying and tree-shaking functional
103103

104104
`--target` (`-t`) Defines the build target.
105105

106-
`--vendor-chunk` (`-vb`) Use a separate bundle containing only vendor libraries.
106+
`--vendor-chunk` (`-vc`) Use a separate bundle containing only vendor libraries.
107107

108108
`--verbose` (`-v`) Adds more details to output logging.
109109

110-
`--watch` (`-w`) Run build when files change.
110+
`--watch` (`-w`) Run build when files change.

docs/documentation/generate/interface.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
## Options
99
`--app` Specifies app name or index to use.
1010

11-
`type` Pptional String to specify the type of interface.
11+
`type` Optional String to specify the type of interface.

docs/documentation/home.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ End-to-end tests are run via [Protractor](https://angular.github.io/protractor/)
5555

5656
### Additional Information
5757
There are several [stories](stories) which will walk you through setting up
58-
additional aspects of Angular applciations.
58+
additional aspects of Angular applications.

docs/documentation/serve.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ All the build Options are available in serve below are the additional options.
2424

2525
`--ssl-cert` SSL certificate to use for serving HTTPS.
2626

27-
`--ssl-key` SSL key to use for serving HTTPS.
27+
`--ssl-key` SSL key to use for serving HTTPS.
28+
29+
## Note
30+
When running `ng serve`, the compiled output is served from memory, not from disk. This means that the application being served is not located on disk in the `dist` folder.

docs/documentation/stories.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
- [Routing](stories/routing)
2121
- [3rd Party Lib](stories/third-party-lib)
2222
- [Corporate Proxy](stories/using-corporate-proxy)
23+
- [Serve from Disk](stories/disk-serve)
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Serve from Disk
2+
3+
The CLI supports running a live browser reload experience to users by running `ng serve`. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via [webpack-dev-server](https://webpack.js.org/guides/development/#webpack-dev-server).
4+
5+
If you wish to get a similar experience with the application output to disk please use the steps below. This practice will allow you to ensure that serving the contents of your `dist` dir will be closer to how your application will behave when it is deployed.
6+
7+
## Environment Setup
8+
### Install a web server
9+
You will not be using webpack-dev-server, so you will need to install a web server for the browser to request the application. There are many to choose from but a good one to try is [lite-server](https://github.com/johnpapa/lite-server) as it will auto-reload your browser when new files are output.
10+
11+
## Usage
12+
You will need two terminals to get the live-reload experience. The first will run the build in a watch mode to compile the application to the `dist` folder. The second will run the web server against the `dist` folder. The combination of these two processes will mimic the same behavior of ng serve.
13+
14+
### 1st terminal - Start the build
15+
```bash
16+
ng build --watch
17+
```
18+
19+
### 2nd terminal - Start the web server
20+
```bash
21+
lite-server --baseDir="dist"
22+
```
23+
When using `lite-server` the default browser will open to the appropriate URL.

docs/documentation/stories/include-angular-material.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { MaterialModule } from '@angular/material';
2424
@NgModule({
2525
imports: [
2626
...
27-
MaterialModule.forRoot()
27+
MaterialModule
2828
],
2929
...
3030
})

docs/documentation/stories/rc-update.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,17 @@ Packages in `dependencies`:
320320
- `@angular/*` packages now have a `^2.4.0` minimum (`^3.4.0` for router)
321321
- `core-js` remains unchanged at `^2.4.1`
322322
- `rxjs` to `^5.1.0`
323+
- `ts-helpers` was **removed**
323324
- `zone.js` to `^0.7.6`
324325

325-
Packages in `dependencies`:
326+
Packages in `devDependencies`:
326327
- `@angular/cli` at `1.0.0-rc.0` replaces `angular-cli`
327328
- `@angular/compiler-cli` is also at `^2.4.0`
328329
- `@types/jasmine` remains unchanged and pinned at `2.5.38`
329330
- `@types/node` was updated to `~6.0.60`
330331
- `codelyzer` was updated to `~2.0.0`
331332
- `jasmine-core` was updated to `~2.5.2`
332-
- `jasmine-spec-reporter` was **removed**
333+
- `jasmine-spec-reporter` was updated to `~3.2.0`
333334
- `karma` was updated to `~1.4.1`
334335
- `karma-chrome-launcher` was updated to `~2.0.0`
335336
- `karma-cli` was updated to `~1.0.1`
@@ -353,6 +354,7 @@ We also updated the scripts section to make it more simple:
353354
"scripts": {
354355
"ng": "ng",
355356
"start": "ng serve",
357+
"build": "ng build",
356358
"test": "ng test",
357359
"lint": "ng lint",
358360
"e2e": "ng e2e"

docs/documentation/test.md

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ You can run tests with coverage via `--code-coverage`. The coverage report will
2020

2121
`--browsers` Override which browsers tests are run against.
2222

23-
`--build` Build prior to running tests.
24-
2523
`--code-coverage` Coverage report will be in the coverage/ directory.
2624

2725
`--colors` Enable or disable colors in the output (reporters and logs).

packages/@angular/cli/blueprints/module/files/__path__/__name__-routing.module.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const routes: Routes = [];
55

66
@NgModule({
77
imports: [RouterModule.forChild(routes)],
8-
exports: [RouterModule],
9-
providers: []
8+
exports: [RouterModule]
109
})
1110
export class <%= classifiedModuleName %>RoutingModule { }

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const routes: Routes = [
1010

1111
@NgModule({
1212
imports: [RouterModule.forRoot(routes)],
13-
exports: [RouterModule],
14-
providers: []
13+
exports: [RouterModule]
1514
})
1615
export class AppRoutingModule { }

packages/@angular/cli/blueprints/ng/files/e2e/tsconfig.e2e.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lib": [
1111
"es2016"
1212
],<% } %>
13-
"outDir": "../dist/out-tsc-e2e",
13+
"outDir": "../out-tsc/e2e",
1414
"module": "commonjs",
1515
"target": "es5",
1616
"types":[

packages/@angular/cli/blueprints/ng/files/gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# compiled output
44
/dist
55
/tmp
6+
/out-tsc
67

78
# dependencies
89
/node_modules

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"karma-coverage-istanbul-reporter": "^0.2.0",
4141
"protractor": "~5.1.0",
4242
"ts-node": "~2.0.0",
43-
"tslint": "~4.4.2",
43+
"tslint": "~4.5.0",
4444
"typescript": "<%= ng4 ? '~2.1.0' : '~2.0.0' %>"
4545
}
4646
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const CompletionCommand = Command.extend({
7878
commandOptions.all = !commandOptions.bash && !commandOptions.zsh;
7979

8080
const commandFiles = fs.readdirSync(__dirname)
81-
.filter(file => file.match(/\.ts$/) && !file.match(/\.run.ts$/))
81+
.filter(file => file.match(/\.(j|t)s$/) && !file.match(/\.d.ts$/))
8282
.map(file => path.parse(file).name)
8383
.filter(file => {
8484
return commandsToIgnore.indexOf(file) < 0;

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

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const aliasMap: { [alias: string]: string } = {
5757
'c': 'component',
5858
'd': 'directive',
5959
'e': 'enum',
60+
'g': 'guard',
6061
'i': 'interface',
6162
'm': 'module',
6263
'p': 'pipe',

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const SetCommand = Command.extend({
6464
case 'number': value = this.asNumber(rawValue); break;
6565
case 'string': value = rawValue; break;
6666

67-
default: value = JSON.parse(rawValue);
67+
default: value = parseValue(rawValue, jsonPath);
6868
}
6969

7070
config.set(jsonPath, value);
@@ -74,4 +74,12 @@ const SetCommand = Command.extend({
7474
}
7575
});
7676

77+
function parseValue(rawValue: string, path: string) {
78+
try {
79+
return JSON.parse(rawValue);
80+
} catch (error) {
81+
throw new SilentError(`No node found at path ${path}`);
82+
}
83+
}
84+
7785
export default SetCommand;

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

-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export interface TestOptions {
1515
log?: string;
1616
port?: number;
1717
reporters?: string;
18-
build?: boolean;
1918
sourcemap?: boolean;
2019
progress?: boolean;
2120
config: string;
@@ -85,12 +84,6 @@ const TestCommand = EmberTestCommand.extend({
8584
type: String,
8685
description: 'List of reporters to use.'
8786
},
88-
{
89-
name: 'build',
90-
type: Boolean,
91-
default: true,
92-
description: 'Build prior to running tests.'
93-
},
9487
{
9588
name: 'sourcemap',
9689
type: Boolean,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
4848
const deployUrl = wco.buildOptions.deployUrl;
4949
const postcssUrlOptions = {
5050
url: (URL: string) => {
51-
// Only convert absolute URLs, which CSS-Loader won't process into require().
52-
if (!URL.startsWith('/')) {
51+
// Only convert root relative URLs, which CSS-Loader won't process into require().
52+
if (!URL.startsWith('/') || URL.startsWith('//')) {
5353
return URL;
5454
}
5555
// Join together base-href, deploy-url and the original URL.

packages/@angular/cli/tasks/extract-i18n.ts

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const Extracti18nTask = Task.extend({
5454
this.ui.writeError('\nAn error occured during the i18n extraction:\n'
5555
+ ((err && err.stack) || err));
5656
}
57-
throw err;
5857
});
5958
}
6059
});

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

+27-12
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ export default Task.extend({
3333
const Linter = tslint.Linter;
3434
const Configuration = tslint.Configuration;
3535

36-
let errors = 0;
37-
let results = '';
38-
39-
lintConfigs
40-
.forEach((config) => {
36+
const result = lintConfigs
37+
.map((config) => {
4138
const program: ts.Program = Linter.createProgram(config.project);
4239
const files = getFilesToLint(program, config, Linter);
4340

@@ -56,19 +53,37 @@ export default Task.extend({
5653
linter.lint(file, fileContents, configLoad.results);
5754
});
5855

59-
const result = linter.getResult();
60-
errors += result.failureCount;
61-
results = results.concat(result.output.trim().concat('\n'));
56+
return linter.getResult();
57+
})
58+
.reduce((total, current) => {
59+
const failures = current.failures
60+
.filter((cf: any) => !total.failures.some((ef: any) => ef.equals(cf)));
61+
total.failures = total.failures.concat(...failures);
62+
63+
if (current.fixes) {
64+
total.fixes = (total.fixes || []).concat(...current.fixes);
65+
}
66+
return total;
67+
}, {
68+
failures: [],
69+
fixes: undefined
6270
});
6371

72+
const Formatter = tslint.findFormatter(commandOptions.format);
73+
const formatter = new Formatter();
74+
75+
const output = formatter.format(result.failures, result.fixes);
76+
if (output) {
77+
ui.writeLine(output);
78+
}
79+
6480
// print formatter output directly for non human-readable formats
6581
if (['prose', 'verbose', 'stylish'].indexOf(commandOptions.format) == -1) {
66-
ui.writeLine(results.trim());
67-
return (errors == 0 || commandOptions.force) ? Promise.resolve(0) : Promise.resolve(2);
82+
return (result.failures.length == 0 || commandOptions.force)
83+
? Promise.resolve(0) : Promise.resolve(2);
6884
}
6985

70-
if (errors > 0) {
71-
ui.writeLine(results.trim());
86+
if (result.failures.length > 0) {
7287
ui.writeLine(chalk.red('Lint errors found in the listed files.'));
7388
return commandOptions.force ? Promise.resolve(0) : Promise.resolve(2);
7489
}

packages/@ngtools/json-schema/src/schema-class-factory.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ function _getSchemaNodeForPath<T>(rootMetaData: SchemaTreeNode<T>,
5151
let fragments = _parseJsonPath(path);
5252
// TODO: make this work with union (oneOf) schemas
5353
return fragments.reduce((md: SchemaTreeNode<any>, current: string) => {
54-
return md && md.children && md.children[current];
54+
if (md && md.children) {
55+
return md.children[current];
56+
} else if (md && md.items) {
57+
return md.items[parseInt(current, 10)];
58+
} else {
59+
return md;
60+
}
5561
}, rootMetaData);
5662
}
5763

packages/@ngtools/webpack/src/extract_i18n_plugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ export class ExtractI18nPlugin implements Tapable {
181181
});
182182
})
183183
.then(() => cb(), (err: any) => {
184-
compilation.errors.push(err);
185-
cb();
184+
this._compilation.errors.push(err);
185+
cb(err);
186186
});
187187

188188
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {silentNg} from '../../../utils/process';
2+
3+
4+
export default function() {
5+
return Promise.resolve()
6+
.then(() => silentNg('completion'))
7+
.then(() => process.chdir('/'))
8+
.then(() => silentNg('completion'));
9+
}

tests/e2e/tests/commands/get/get.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {ng} from '../../../utils/process';
2+
import {expectToFail} from '../../../utils/utils';
3+
4+
export default function() {
5+
return Promise.resolve()
6+
.then(() => expectToFail(() => ng('get', 'apps.zzz.prefix')))
7+
.then(() => ng('get', 'apps.0.prefix'))
8+
.then(({ stdout }) => {
9+
if (!stdout.match(/app/)) {
10+
throw new Error(`Expected "app", received "${JSON.stringify(stdout)}".`);
11+
}
12+
});
13+
}

tests/e2e/tests/commands/set/set.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {ng} from '../../../utils/process';
2+
import {expectToFail} from '../../../utils/utils';
3+
4+
export default function() {
5+
return Promise.resolve()
6+
.then(() => expectToFail(() => ng('set', 'apps.zzz.prefix')))
7+
.then(() => ng('set', 'apps.0.prefix' , 'new-prefix'))
8+
.then(() => ng('get', 'apps.0.prefix'))
9+
.then(({ stdout }) => {
10+
if (!stdout.match(/new-prefix/)) {
11+
throw new Error(`Expected "new-prefix", received "${JSON.stringify(stdout)}".`);
12+
}
13+
});
14+
}

0 commit comments

Comments
 (0)