Skip to content

Commit 38158b3

Browse files
Merge pull request #188 from angular/master
Create a new pull request by comparing changes across two branches. If you need to, you can
2 parents 064883c + 0b884c5 commit 38158b3

Some content is hidden

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

47 files changed

+2282
-690
lines changed

CONTRIBUTING.md

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ Help us keep Angular open and inclusive. Please read and follow our [Code of Con
1818

1919
## <a name="question"></a> Got a Question or Problem?
2020

21-
Please, do not open issues for the general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [StackOverflow](https://stackoverflow.com/questions/tagged/angular-devkit) where the questions should be tagged with tag `angular-devkit`.
21+
Please, do not open issues for the general support questions as we want to keep GitHub issues for
22+
bug reports and feature requests. You've got much better chances of getting your question answered
23+
on [StackOverflow](https://stackoverflow.com/questions/tagged/angular-devkit) where the questions
24+
should be tagged with tag `angular-cli` or `angular-devkit`.
2225

2326
StackOverflow is a much better place to ask questions since:
2427

2528
- there are thousands of people willing to help on StackOverflow
2629
- questions and answers stay available for public viewing so your question / answer might help someone else
2730
- StackOverflow's voting system assures that the best answers are prominently visible.
2831

29-
To save your and our time we will be systematically closing all the issues that are requests for general support and redirecting people to StackOverflow.
32+
To save your and our time we will be systematically closing all the issues that are requests for
33+
general support and redirecting people to StackOverflow.
3034

3135
If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter].
3236

@@ -180,41 +184,65 @@ If the commit reverts a previous commit, it should begin with `revert: `, follow
180184
### Type
181185
Must be one of the following:
182186

183-
* **build**: Changes that affect the build system or external dependencies
184-
* **ci**: Changes to our CI configuration files and scripts
185-
* **docs**: Documentation only changes
186-
* **feat**: A new feature
187-
* **fix**: A bug fix
188-
* **perf**: A code change that improves performance
189-
* **refactor**: A code change that neither fixes a bug nor adds a feature
190-
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
191-
* **test**: Adding missing tests or correcting existing tests
187+
* **build**: Changes that affect the build system or external dependencies. [2]
188+
* **ci**: Changes to our CI configuration files and scripts. [2]
189+
* **docs**: Documentation only changes.
190+
* **feat**: A new feature. [1]
191+
* **fix**: A bug fix. [1]
192+
* **refactor**: A code change that neither fixes a bug nor adds a feature
193+
* **release**: A release commit. Must only include version changes. [2]
194+
* **revert**: A git commit revert. The description must include the original commit message. [2]
195+
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
196+
* **test**: Adding missing tests or correcting existing tests.
197+
198+
199+
<sup>[1] This type MUST have a scope. See the next section for more information.</sup><br/>
200+
<sup>[2] This type MUST NOT have a scope. It only applies to general scripts and tooling.</sup>
192201

193202
### Scope
194203
The scope should be the name of the npm package affected as perceived by the person reading changelog generated from the commit messages.
195204

196205
The following is the list of supported scopes:
197206

198-
* **@angular-devkit/core**
207+
* **@angular/cli**
208+
* **@angular/pwa**
209+
* **@angular-devkit/architect**
210+
* **@angular-devkit/architect-cli**
211+
* **@angular-devkit/build-angular**
212+
* **@angular-devkit/build-ng-packagr**
199213
* **@angular-devkit/build-optimizer**
214+
* **@angular-devkit/build-webpack**
215+
* **@angular-devkit/core**
200216
* **@angular-devkit/schematics**
201217
* **@angular-devkit/schematics-cli**
218+
* **@ngtools/webpack**
202219
* **@schematics/angular**
203220
* **@schematics/schematics**
221+
* **@schematics/update**
204222

205-
There are currently a few exceptions to the "use package name" rule:
206-
207-
* **packaging**: used for changes that change the npm package layout in all of our packages, e.g. public path changes, package.json changes done to all packages, d.ts file/format changes, changes to bundles, etc.
208-
* **changelog**: used for updating the release notes in CHANGELOG.md
209-
* none/empty string: useful for `style`, `test` and `refactor` changes that are done across all packages (e.g. `style: add missing semicolons`)
210223

211224
### Subject
212225
The subject contains succinct description of the change:
213226

214227
* use the imperative, present tense: "change" not "changed" nor "changes"
215228
* don't capitalize first letter
229+
* be concise and direct
216230
* no dot (.) at the end
217231
232+
### Examples
233+
Examples of valid commit messages:
234+
235+
* `fix(@angular/cli): prevent the flubber from grassing`
236+
* `refactor(@schematics/angular): move all JSON classes together`
237+
238+
Examples of invalid commit messages:
239+
* `fix(@angular/cli): add a new XYZ command`
240+
241+
This is a feature, not a fix.
242+
* `ci(@angular/cli): fix publishing workflow`
243+
244+
The `ci` type cannot have a scope.
245+
218246
### Body
219247
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
220248
The body should include the motivation for the change and contrast this with previous behavior.
@@ -240,7 +268,7 @@ changes to be accepted, the CLA must be signed. It's a quick process, we promise
240268
[coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md
241269
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
242270
[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html
243-
[dev-doc]: ttps://github.com/angular/angular-cli/blob/master/packages/angular/cli/README.md#development-hints-for-working-on-angular-cli
271+
[dev-doc]: https://github.com/angular/angular-cli/blob/master/packages/angular/cli/README.md#development-hints-for-working-on-angular-cli
244272
[GitHub]: https://github.com/angular/angular-cli
245273
[gitter]: https://gitter.im/angular/angular-cli
246274
[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html

README.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Any changes to README.md directly will result in a failure on CI.
1111
-->
1212

13-
# Angular DevKit
13+
# Angular CLI
1414
### Development tools and libraries specialized for Angular
1515

1616
This is the home of the DevKit and the Angular CLI code. You can find the Angular CLI specific README
@@ -25,24 +25,48 @@ This is the home of the DevKit and the Angular CLI code. You can find the Angula
2525

2626

2727

28-
----
29-
30-
This is the home for all the tools and libraries built to assist developers with their Angular applications.
31-
3228
### Quick Links
3329
[Gitter](https://gitter.im/angular/angular-cli) | [Contributing](https://github.com/angular/angular-cli/blob/master/CONTRIBUTING.md) | [Angular CLI](http://github.com/angular/angular-cli) |
3430
|---|---|---|
3531

32+
----
33+
34+
## The Goal of Angular CLI
35+
36+
The Angular CLI creates, manages, builds and test your Angular projects. It's built on top of the
37+
Angular DevKit.
3638

3739
## The Goal of DevKit
3840

39-
Our goal is to provide a large set of libraries that can be used to manage, develop, deploy and
41+
DevKit's goal is to provide a large set of libraries that can be used to manage, develop, deploy and
4042
analyze your code.
4143

42-
This is the extension of the Angular CLI Project. Once this set of tools is done, the Angular CLI
43-
as it is today will become one of many interfaces available to perform those tasks. Everything
44-
will also be available to third party tools and IDEs.
44+
# Getting Started - Local Development
45+
46+
## Installation
47+
To get started locally, follow these instructions:
4548

49+
1. If you haven't done it already, [make a fork of this repo](https://github.com/angular/angular-cli/fork).
50+
1. Clone to your local computer using `git`.
51+
1. Make sure that you have Node 10.9 or later installed. See instructions [here](https://nodejs.org/en/download/). The Angular CLI requires Node 8, but development requires Node 10.
52+
1. Make sure that you have `yarn` installed; see instructions [here](https://yarnpkg.com/lang/en/docs/install/).
53+
1. Run `yarn` (no arguments) from the root of your clone of this project.
54+
1. Run `yarn link` to add all custom scripts we use to your global install.
55+
56+
## Creating New Packages
57+
Adding a package to this repository means running two separate commands:
58+
59+
1. `schematics devkit:package PACKAGE_NAME`. This will update the `.monorepo` file, and create the
60+
base files for the new package (package.json, src/index, etc).
61+
1. `devkit-admin templates`. This will update the README and all other template files that might
62+
have changed when adding a new package.
63+
64+
For private packages, you will need to add a `"private": true` key to your package.json manually.
65+
This will require re-running the template admin script.
66+
67+
# Packages
68+
69+
This is a monorepo which contains many tools and packages:
4670

4771

4872

@@ -54,10 +78,7 @@ will also be available to third party tools and IDEs.
5478
**Schematics CLI** | [`@angular-devkit/schematics-cli`](https://npmjs.com/package/@angular-devkit/schematics-cli) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fschematics-cli/latest.svg)](https://npmjs.com/package/@angular-devkit/schematics-cli) | [![snapshot](https://img.shields.io/badge/snapshot--blue.svg)](https://github.com/angular/angular-devkit-schematics-cli-builds)
5579

5680

57-
5881
## Packages
59-
This is a monorepo which contains many packages:
60-
6182

6283

6384
| Project | Package | Version | Links |

lib/bootstrap-local.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !==
2626
let profiler = null;
2727
if (process.env['DEVKIT_PROFILING']) {
2828
try {
29-
profiler = require('v8-profiler');
29+
profiler = require('v8-profiler-node8');
3030
} catch (err) {
31-
throw new Error(`Could not require 'v8-profiler'. You must install it separetely with` +
32-
`'npm install v8-profiler --no-save.\n\nOriginal error:\n\n${err}`);
31+
throw new Error(`Could not require 'v8-profiler-node8'. You must install it separetely with` +
32+
`'npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`);
3333
}
3434

3535
profiler.startProfiling();
@@ -119,9 +119,12 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
119119

120120
Module._resolveFilename = function (request, parent) {
121121
let resolved = null;
122+
let exception;
122123
try {
123124
resolved = oldResolve.call(this, request, parent);
124-
} catch (_) {}
125+
} catch (e) {
126+
exception = e;
127+
}
125128

126129
if (request in packages) {
127130
return packages[request].main;
@@ -135,6 +138,12 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
135138
if (match) {
136139
const p = path.join(packages[match].root, request.substr(match.length));
137140
return oldResolve.call(this, p, parent);
141+
} else if (!resolved) {
142+
if (exception) {
143+
throw exception;
144+
} else {
145+
return resolved;
146+
}
138147
} else {
139148
// Because loading `.ts` ends up AFTER `.json` in the require() logic, requiring a file that has both `.json`
140149
// and `.ts` versions will only get the `.json` content (which wouldn't happen if the .ts was compiled to

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"validate": "node ./bin/devkit-admin validate",
3535
"validate-commits": "./bin/devkit-admin validate-commits",
3636
"prepush": "node ./bin/devkit-admin hooks/pre-push",
37+
"preinstall": "node ./tools/yarn/check-yarn.js",
3738
"webdriver-update-appveyor": "webdriver-manager update --standalone false --gecko false --versions.chrome 2.37",
3839
"webdriver-update-circleci": "webdriver-manager update --standalone false --gecko false --versions.chrome $CHROMEDRIVER_VERSION_ARG "
3940
},

packages/_/benchmark/src/benchmark.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ declare const global: {
1515
const kNanosecondsPerSeconds = 1e9;
1616
const kBenchmarkIterationMaxCount = 10000;
1717
const kBenchmarkTimeoutInMsec = 5000;
18-
const kWarmupIterationCount = 10;
18+
const kWarmupIterationCount = 100;
1919
const kTopMetricCount = 5;
2020

2121

22-
function _run(fn: () => void, collector: number[]) {
22+
function _run(fn: (i: number) => void, collector: number[]) {
2323
const timeout = Date.now();
2424
// Gather the first 5 seconds runs, or kMaxNumberOfIterations runs whichever comes first
2525
// (soft timeout).
@@ -28,7 +28,7 @@ function _run(fn: () => void, collector: number[]) {
2828
i++) {
2929
// Start time.
3030
const start = process.hrtime();
31-
fn();
31+
fn(i);
3232
// Get the stop difference time.
3333
const diff = process.hrtime(start);
3434

@@ -41,13 +41,15 @@ function _run(fn: () => void, collector: number[]) {
4141
function _stats(metrics: number[]) {
4242
metrics.sort((a, b) => a - b);
4343

44-
const middle = metrics.length / 2;
44+
const count = metrics.length;
45+
const middle = count / 2;
4546
const mean = Number.isInteger(middle)
4647
? metrics[middle] : ((metrics[middle - 0.5] + metrics[middle + 0.5]) / 2);
4748
const total = metrics.reduce((acc, curr) => acc + curr, 0);
48-
const average = total / metrics.length;
49+
const average = total / count;
4950

5051
return {
52+
count: count,
5153
fastest: metrics.slice(0, kTopMetricCount),
5254
slowest: metrics.reverse().slice(0, kTopMetricCount),
5355
mean,
@@ -56,12 +58,12 @@ function _stats(metrics: number[]) {
5658
}
5759

5860

59-
export function benchmark(name: string, fn: () => void, base?: () => void) {
61+
export function benchmark(name: string, fn: (i: number) => void, base?: (i: number) => void) {
6062
it(name + ' (time in nanoseconds)', (done) => {
6163
process.nextTick(() => {
6264
for (let i = 0; i < kWarmupIterationCount; i++) {
6365
// Warm it up.
64-
fn();
66+
fn(i);
6567
}
6668

6769
const reporter = global.benchmarkReporter;

packages/angular/cli/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,28 @@ Then you can add breakpoints in `dist/@angular` files.
226226

227227
For more informations about Node.js debugging in VS Code, see the related [VS Code Documentation](https://code.visualstudio.com/docs/nodejs/nodejs-debugging).
228228

229+
### CPU Profiling
230+
231+
In order to investigate performance issues, CPU profiling is often usefull.
232+
233+
To capture a CPU profiling, you can:
234+
1. install the v8-profiler-node8 dependency: `npm install v8-profiler-node8 --no-save`
235+
1. set the NG_CLI_PROFILING Environment variable to the file name you want:
236+
* on Unix systems (Linux & Mac OS X): ̀`export NG_CLI_PROFILING=my-profile`
237+
* on Windows: ̀̀`setx NG_CLI_PROFILING my-profile`
238+
239+
Then, just run the ng command on which you want to capture a CPU profile.
240+
You will then obtain a `my-profile.cpuprofile` file in the folder from wich you ran the ng command.
241+
242+
You can use the Chrome Devtools to process it. To do so:
243+
1. open `chrome://inspect/#devices` in Chrome
244+
1. click on "Open dedicated DevTools for Node"
245+
1. go to the "profiler" tab
246+
1. click on the "Load" button and select the generated .cpuprofile file
247+
1. on the left panel, select the associated file
248+
249+
In addition to this one, another, more elaborated way to capture a CPU profile using the Chrome Devtools is detailed in https://github.com/angular/angular-cli/issues/8259#issue-269908550.
250+
229251
## Documentation
230252

231253
The documentation for the Angular CLI is located in this repo's [wiki](https://github.com/angular/angular-cli/wiki).

packages/angular/cli/commands/update-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
5454
collectionName: this.collectionName,
5555
schematicName: this.schematicName,
5656
schematicOptions: options['--'],
57-
dryRun: options.dryRun,
57+
dryRun: !!options.dryRun,
5858
force: false,
5959
showNothingDone: false,
6060
});

packages/angular/cli/commands/update.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,6 @@
1111

1212
"type": "object",
1313
"allOf": [
14-
{
15-
"properties": {
16-
"packages": {
17-
"type": "array",
18-
"items": {
19-
"type": "string"
20-
},
21-
"description": "The names of package(s) to update",
22-
"$default": {
23-
"$source": "argv"
24-
}
25-
},
26-
"dryRun": {
27-
"type": "boolean",
28-
"default": false,
29-
"aliases": [
30-
"d"
31-
],
32-
"description": "Run through without making any changes."
33-
}
34-
},
35-
"required": [
36-
]
37-
},
3814
{
3915
"$ref": "./definitions.json#/definitions/base"
4016
}

packages/angular/cli/lib/init.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,19 @@ function _fromPackageJson(cwd?: string) {
4343

4444
// Check if we need to profile this CLI run.
4545
if (process.env['NG_CLI_PROFILING']) {
46-
const profiler = require('v8-profiler'); // tslint:disable-line:no-implicit-dependencies
46+
let profiler: {
47+
startProfiling: (name?: string, recsamples?: boolean) => void;
48+
stopProfiling: (name?: string) => any; // tslint:disable-line:no-any
49+
};
50+
try {
51+
profiler = require('v8-profiler-node8'); // tslint:disable-line:no-implicit-dependencies
52+
} catch (err) {
53+
throw new Error(`Could not require 'v8-profiler-node8'. You must install it separetely with` +
54+
`'npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`);
55+
}
56+
4757
profiler.startProfiling();
58+
4859
const exitHandler = (options: { cleanup?: boolean, exit?: boolean }) => {
4960
if (options.cleanup) {
5061
const cpuProfile = profiler.stopProfiling();

packages/angular_devkit/build_angular/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"copy-webpack-plugin": "4.5.2",
1919
"file-loader": "2.0.0",
2020
"glob": "7.1.3",
21-
"html-webpack-plugin": "3.2.0",
2221
"istanbul": "0.4.5",
2322
"istanbul-instrumenter-loader": "3.0.1",
2423
"karma-source-map-support": "1.3.0",

0 commit comments

Comments
 (0)