256 Commits

Author SHA1 Message Date
Charles Lyding
084eff6965 fix(@angular/cli): exclude packages from ng add that contain invalid peer dependencies
Certain older versions of packages may contain missing or invalid peer dependencies. As a result these packages may be incorrectly added to the project when no newer compatible version is found. An exclusion list is now present within `ng add` that will exclude packages with known peer dependency concerns from consideration when adding a package. Currently, only `@angular/localize@9.x` is included in the list.
2021-10-27 04:43:37 -05:00
Alan Agius
57d7eb5b16 fix(@angular/cli): error when updating Angular packages across multi-major migrations
With this change we show an error message when users try to update `@angular/` and `@nguniversal/` packages across multiple major versions.
2021-10-26 04:45:18 -05:00
Alan Agius
ebf2d62535 fix(@angular/cli): run stable migrations when package version is prerelease
With this change we fix an issue were migrations are not run when the version specified in migration collection is specified as stable example `13.0.0`, but the version specified in the `package.json` is still a prerelease example `13.0.0-rc.0`.

Closes: #21969
2021-10-18 11:24:16 -04:00
Alan Agius
3f72ccc5d2 fix(@angular/cli): generate new random user ID when passing empty string to uuid
`ng config cli.analyticsSharing.uuid ""` should generate new random user ID.

See: https://angular.io/cli/usage-analytics-gathering#per-user-tracking
2021-10-13 15:29:46 +02:00
Alan Agius
5904afd1de feat(@angular-devkit/build-angular): enable disk cache by default and provide configurable options
Persistent disk build cache is now enabled by default. A number of options have been added to allow fine tuning of the cache.

The options can be configuration in `cli.cache` section in the `angular.json` as shown below.

- `enabled`: Configure whether disk caching is enabled. Defaults to `true`
- `environment`: Configure in which environment disk cache is enabled. Valid values `ci`, `local` or `all`. Defaults to: `local`
- `path`: cache base path. Defaults to `.angular/cache`

DEPRECATED: `NG_BUILD_CACHE` environment variable option will be removed in the next major version. Configure `cli.cache` in the workspace configuration instead.

BREAKING CHANGE:  `NG_PERSISTENT_BUILD_CACHE` environment variable option no longer  have effect. Configure `cli.cache` in the workspace configuration instead.

```json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "cli": {
    "cache": {
      "enabled": true,
      "path": ".custom-cache-path",
      "environment": "all"
    }
  }
  ...
}
```
2021-10-06 08:02:22 -05:00
Charles Lyding
d8c9f6eaf4 fix(@angular/cli): update the update command to fully support Node.js v16
Node.js v16's `fs.rmdir` will now throw an `ENOENT` error if the path does not exist. `fs.rm` is now the preferred option when using Node.js v16 but since this function is not available on Node.js v12 both are tried with `fs.rm` given preference.
In the case of the update command, the usage was guarded by a try/catch block with the downside of leaving the `fs.rmdir` being that a deprecation warning would be shown when running the command which is not ideal.
2021-10-06 06:11:09 -05:00
Charles Lyding
9fe55752db feat(@angular/cli): officially support Node.js v16
Node.js v16 will be entering an LTS state prior to the release of Angular v13 which allows Node.js v16 to be marked as officially supported by the Angular CLI. The initial bootstrapping check now adds Node.js v16 to the output message in the event of an unsupported Node.js version.
NOTE: Prior to the final v13 release, the Node.js v16 minor should be updated to the actual LTS version once available.
2021-10-06 06:11:09 -05:00
Alan Agius
31ec09c111 refactor(@schematics/angular): remove migrations for unsupported versions 2021-09-24 15:38:33 -04:00
Alan Agius
b8e06a3155 docs: replace deprecated camel-case argument
`--createApplication` is deprecated in favor of `--create-application`
2021-09-21 17:03:01 +02:00
Charles Lyding
6f4bf38e9c refactor(@angular/cli): convert npm-pick-manifest usage from require to import
The removal of require usage supports the eventual shift to an ESM output for the CLI package.
2021-08-25 11:40:51 +01:00
Charles Lyding
0ba837b2e4 refactor(@angular/cli): use custom scoped require instead of global
To support the eventual conversion of the `@angular/cli` package to ESM, the usage of the global require function must be removed as it is not supported in ESM code. Node.js does have the facility to create custom require functions that can be used when the need to synchronously load a file at runtime is required. Such cases have now been converted to use custom require functions where appropriate.
2021-08-25 11:40:51 +01:00
Charles Lyding
51f89d633f test: enable no-useless-escape lint rule
The `no-useless-escape` eslint rule has now been enabled which removes unneeded characters and complexity from string literals and regular expressions. All files that were in violation of this rule have also been corrected.
2021-08-24 10:51:14 +01:00
Trevor Karjanis
9c62ddcd69 docs: update the description of the lint command
Update the description of the lint command for when a project name is not provided.

Closes #21619
2021-08-23 11:06:33 +01:00
Alan Agius
c0f1b5ea52 fix(@angular/cli): show error when using non-TTY terminal without passing --skip-confirmation during ng add
Closes #21512
2021-08-06 07:23:18 +02:00
Alan Agius
a15875a46c docs(@angular/cli): update e2e long description 2021-08-02 16:59:20 +01:00
Charles Lyding
9a828a4459 refactor(@angular/cli): convert npm-package-arg usage from require to import
The typings package was already present for `npm-package-arg` and the removal of require usage supports the eventual shift to an ESM output for the CLI package.
2021-07-27 12:52:02 -04:00
Charles Lyding
9afe185fc6 build: enable noImplicitOverride TypeScript option
The `noImplicitOverride` TypeScript option improves code quality by ensuring that properties from base classes are not accidentally overriden.
Reference: https://www.typescriptlang.org/tsconfig#noImplicitOverride
2021-07-02 06:40:36 -04:00
Alan Agius
88ee85c417 fix(@angular/cli): disable update notifier when retrieving package manager version during ng version
NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.

Closes #21172
2021-06-25 07:45:09 +02:00
Vaibhav Singh
4ce7681cc8 docs(@angular/cli): Add Nightwatch schematics to e2e command 2021-06-24 13:41:00 +01:00
Charles Lyding
c1623c429e refactor(@angular/cli): use version class instead of requiring package.json
The CLI contains a helper class instance that provides the version of the executing CLI. By using this helper throughtout the code, repeat `require` calls are no longer necessary.
2021-06-22 17:39:38 +01:00
Charles Lyding
b3d7080147 build: enable esModuleInterop TypeScript option
The `esModuleInterop` option is recommended to be enable by TypeScript and corrects several assumptions TypeScript would otherwise make when importing CommonJS files.
This option change helps ensure compatibility as packages move towards ESM.
Reference: https://www.typescriptlang.org/tsconfig#esModuleInterop
2021-06-13 11:45:55 -04:00
Charles Lyding
57640bebfd feat(@angular/cli): show Node.js version support status in version command
Unsupported versions of Node.js will now show an unsupported warning when the `ng version` command is executed.
Currently Node.js major versions 12 and 14 are considered supported and tested.

Closes #20879
2021-05-21 20:04:54 -04:00
Charles Lyding
6926b37c0c fix(@angular/cli): clean node modules directory prior to updating
Prior to performing the initial updated package installation during the `ng update` process, the workspace node modules directory will be removed. This cleaning increases the guarantees that the package manager will hoist packages into the correct locations and avoid peer dependency inconsistencies.
2021-05-17 08:38:04 +02:00
Alan Agius
6e34d1bf89 fix(@angular/cli): cannot locate bin for temporary package
This fixes an issue where the installation of the temporary Angular CLI failed with `Cannot locate bin for temporary package: @angular/cli.`
2021-05-14 13:10:56 +02:00
Keen Yee Liau
123735eeb1 docs(@angular/cli): Add Cypress schematic to e2e command
Add Cypress schematic/builder, see
https://github.com/cypress-io/cypress/tree/master/npm/cypress-schematic
and
https://www.npmjs.com/package/@cypress/schematic
2021-05-13 07:41:27 +02:00
Alan Agius
0a0fc41907 fix(@angular/cli): allow config object to be of JSON.
With this change we allow unset a config value to be a JSON.

Example, `ng config -g schematics {}` will remove the entire `schematics` section from the configuration.
2021-05-10 20:57:33 +01:00
Alan Agius
4af963e70b fix(@angular/cli): allow unsetting config when value is undefined
With this change we allow unset a config value when the provided value is `undefined`.

Example, `ng config -g schematics undefined` will remove the entire `schematics` section from the configuration.
2021-05-10 20:57:33 +01:00
Charles Lyding
3d8c16a433 fix(@angular/cli): propagate update's force option to package managers
When the CLI update command's `--force` option is used, the underlying package manager will also be executed with its force option. This behavior is especially important with the advent of npm 7 which will fail installation if any peer dependency version ranges are mismatched.
2021-05-10 16:21:25 +01:00
Alan Agius
d7ef0d0730 fix(@angular/cli): change package installation to async
With this change we change the package installation to async. This is needed as otherwise during `ng-add` the spinner gets stuck. With this change we also add the spinner in the installation methods.
2021-05-05 11:49:08 -04:00
Alan Agius
e992c9a70b build: update files to be fix eslint header/header failures 2021-05-04 09:59:40 -04:00
Charles Lyding
c1512e4274 build: update files to be eslint compliant
All TypeScript files have been updated to pass the new eslint-based linting checks. eslint compatible disabling comments have also been added in place of the previous tslint comments.
2021-05-03 07:31:02 -04:00
Charles Lyding
37a06a7c37 build: format all files
All files are now formatted using the ng-dev tools via prettier.
2021-04-28 16:05:49 -07:00
Charles Lyding
203f9626df refactor(@angular/cli): correct various uncaught code style issues
This change cleans up some of the code by removing unused variables/imports, unnecessary double negation, and some long line lengths.
2021-04-28 09:58:15 +02:00
Joey Perrott
003854257c build: migrate all file header to use Google LLC rather than Google Inc 2021-04-27 08:35:22 +02:00
Alan Agius
5558047eef fix(@angular/cli): add package manager name and version in ng version output 2021-04-22 14:23:13 +02:00
Keen Yee Liau
49ba5e20aa refactor(@schematics/angular): Do not include Protractor test in new project
Do not include Protractor for new projects since we do not have a concrete
plan for Protractor yet.
2021-04-21 12:38:46 -07:00
David Shevitz
bb3f36f30a docs: remove reference to protractor. 2021-04-21 12:35:50 -07:00
Alan Agius
131379f49f fix(@angular/cli): run all migrations when updating from or between prereleases
With this change we consider the update schematics are idempotent. When updating from or between prereleases we will execute all migrations for the version.
2021-04-19 20:28:53 +02:00
Alan Agius
d68cb92dc2 fix(@angular/cli): add message update updating from non LTS versions of the CLI 2021-04-14 17:20:33 -04:00
Alan Agius
076ab0f11f refactor: add correct schema keys
With this change
- We replace `id` with `$id`,  this no longer valid in draft-07.
- Replace all `$schemas` to `http://json-schema.org/draft-07/schema`, this is needed to "pin" the schema to `draft-07`.

More information about `draft-07` can be found https://json-schema.org/draft-07/json-schema-release-notes.html
2021-04-13 10:51:12 -04:00
Alan Agius
14c8a09014 refactor(@angular/cli): remove Ivy Workspace from ng version
In version 12, only Ivy will be allowed to be used to compile an application.
2021-03-30 14:36:48 -06:00
Charles Lyding
2dd0cbd2e9 refactor(@angular/cli): inline @schematics/update:update schematic
This change removes the need for the `@schematics/update` package within the Angular tooling and removes the dependency from the `@angular/cli` package.
Only the `update` schematic from the `@schematics/update` package was used and this schematic's logic will eventually be folded into the update command logic directly.
2021-03-29 08:18:11 -06:00
Alan Agius
cc10302fd7 refactor(@angular/cli): add more actionable missing lint target message 2021-03-16 15:49:46 +01:00
Alan Agius
4b0223b64e build: automate @angular/cli schema.json generation
With this change we automate the generation of `@angular/cli/lib/config/schema.json`. While on paper we could use quicktype for this. Quicktype doesn't handle `patternProperties` and `oneOf` that well.

How does this works?
Relative `$ref` will be resolved and inlined as part of the root schema definitions.

Example
```json
"@schematics/angular:enum": {
    "$ref": "../../../../schematics/angular/enum/schema.json"
},
```

Will be parsed and transformed to
```json
"@schematics/angular:enum": {
  "$ref": "#/definitions/SchematicsAngularEnumSchema"
},
"definitions: {
  "SchematicsAngularEnumSchema": {
    "title": "Angular Enum Options Schema",
    "type": "object",
    "description": "Generates a new, generic enum definition for the given or default project.",
    "properties": {...}
   }
}
```
2021-03-11 21:51:37 +01:00
Charles Lyding
985dc1a4c7 feat(@angular/cli): confirm ng add action before installation
BREAKING CHANGE:
The `ng add` command will now ask the user to confirm the package and version prior to installing and executing an uninstalled package.
This new behavior allows a user to abort the action if the version selected is not appropriate or if a typo occurred on the command line and an incorrect package would be installed.
A `--skip-confirmation` option has been added to skip the prompt and directly install and execute the package. This option is useful in CI and non-TTY scenarios such as automated scripts.
2021-03-11 08:54:07 +01:00
Charles Lyding
06335515eb fix(@angular/cli): avoid exceptions for expected errors in architect commands
Errors caused by invalid options or workspace configuration will now be presented as fatal console messages and the CLI will exit gracefully with an exit code of 1.
2021-03-10 08:19:42 -06:00
Alan Agius
a5877bf917 feat(@angular/cli): deprecate --prod command line argument
With this change we deprecated the `--prod` command line argument. This argument is confusing especially to new users, since users expect that this builds an application in production mode. This however, is only an alias for `--configuration="production"`
2021-03-10 08:16:38 -06:00
Charles Lyding
3d99468b45 fix(@angular/cli): support update migration packages with no entry points
Some schematic only packages may not have entry points defined (`main`/`exports`).  These type of packages will now be correctly resolved when attempting to locate update migrations.

Fixes #20032
2021-02-17 12:43:13 -06:00
Charles Lyding
9a44bf4aaf fix(@angular/cli): improve error logging when resolving update migrations
Failure to resolve a migration package from the workspace root will now not crash and instead error with a message.  Verbose logging (`--verbose`) is also added to provide more details regarding the resolution process.
2021-02-11 14:25:55 -05:00
Charles Lyding
52aaa8c167 fix(@angular/cli): update NPM 7 guidance
Update NPM 7 behavior based on https://github.com/angular/angular-cli/issues/19957#issuecomment-775407654
2021-02-08 19:48:42 -05:00