194 Commits

Author SHA1 Message Date
Alan Agius
782c7185c5 fix(@angular/cli): prevent BOM errors in package.json during ng update
To prevent `JSON.parse` errors triggered by Byte Order Marks (BOMs) in package.json files, the `readJson` tree method is now utilized for more reliable BOM handling.

Closes #27052
2024-02-09 15:36:15 +01:00
Alan Agius
b3e206741c feat(@angular/cli): add support to bun package manager
This commit adds support to use `bun` as a package manager.

Closes #26837
2024-01-25 18:02:35 +01:00
Alan Agius
7717dba907 docs: remove ngx-deploy-npm from missing deploy targets
This package will no longer support Angular CLI workspaces in the next major version. Instead they will soley support NX.

See: https://dev.to/dianjuar/whats-coming-to-ngx-deploy-npm-v8-23gn and https://github.com/angular/angular/pull/53999
2024-01-25 13:51:54 +01:00
Alan Agius
640a76aa74 fix(@angular/cli): retain existing EOL when updating JSON files
This commit updates the JSON utility to retain the existing EOF when updating files.
2024-01-05 16:30:06 +01:00
Alan Agius
fc7aa22462 refactor(@angular/cli): use process.versions.pnp to determine if PNP is used in warnOnMissingNodeModules
Instead of checking for existence of PNP config files we now use `process.versions.pnp`. See https://yarnpkg.com/advanced/pnpapi#processversionspnp
2023-12-21 16:37:55 +01:00
Alan Agius
a391b5f0c2 fix(@angular/cli): ng e2e and ng lint prompt requires to hit Enter twice to proceed on Windows
This fixes an issue where prompts in nested child processes on Windows require multiple keystrokes to proceed.

Closes #26724
2023-12-21 16:37:25 +01:00
Alan Agius
f7d538903a fix(@angular/cli): re-add -d alias for --dry-run
This got accidentally deleted during the transition to yargs.

Closes #26496
2023-12-15 16:34:08 +01:00
Alan Agius
30efb76c46 refactor(@angular/cli): remove no longer relevant regexps from ng version checks
Bazel and NgUniversal packages information is not needed in version 17.
2023-12-15 16:30:07 +01:00
Alan Agius
bec9458b6e fix(@angular/cli): handle packages with no version
In some cases pacote will return undefined as `version` which resulted in `Cannot convert undefined or null to object`.

Closes #26337
2023-11-15 16:47:42 +01:00
Charles Lyding
6d8d948ad0 refactor(@angular-devkit/build-angular): cache compiled load ESM file helper
The dynamically compiled ESM import helper is now cached to prevent the need
to recompile the helper function everytime a load ESM helper call is made.
This helper is currently used to workaround dynamic import limitations with
the TypeScript compilation output. Once the build process is updated, it will
no longer be required.
2023-11-03 10:36:27 +01:00
Alan Agius
91dcae16d1 fix(@angular/cli): add Node.js 20 as supported version
Prior to this Node.js 20 was incorrectly being listed as unsupported.

Closes #26114
2023-10-30 12:28:00 +01:00
Charles Lyding
6161e3e031 fix(@angular/cli): ignore peer mismatch when updating @nguniversal/builders
When updating to v17, the `@nguniversal/builders` is now ignored when checking peer
dependency ranges. The `@nguniversal/builders` is no longer used and will be removed
in a migration during the update process.
2023-10-30 09:00:31 +01:00
Alan Agius
a0f8fac4b3 refactor: update inquirer to version 9.0.6
Update the mentioned package.
2023-10-26 16:11:36 +02:00
Alan Agius
842c2045d1 fix(@angular/cli): remove Node.js 16 from supported checks
Node.js support was removed, but it appears that this got through the cracks.
2023-10-24 16:12:09 +02:00
Alan Agius
2c1c676245 fix(@angular/cli): remove the need to specify --migrate-only when --name is used during ng update
This commit updates the behaviour of `ng update --migrate-only` to remove the need for `--migrate-only` option to be specified. `--migrate-only` will be set internally.

Before
```
ng update @angular/cli --migrate-only --name=migration-name
```

Now
```
ng update @angular/cli --name=migration-name
```
2023-10-20 23:11:50 +02:00
Alan Agius
70099af5be docs(@angular/cli): update build description
Replace webpack with esbuild.
2023-10-19 18:15:23 +02:00
Alan Agius
741cca73c1 feat(@schematics/angular): add ng new --ssr
This commit enabled users to opt-in adding SSR and SSG to their application during the `ng new` experience. This can be done either by using the `--ssr` option or answer `Yes` when prompted.
2023-09-25 20:17:01 +02:00
Nikolay Vitkov
6eee74c8f5 docs(@angular/cli): Add Puppeteer schematics to e2e command 2023-09-11 09:13:04 +02:00
Alan Agius
99e153ada7 docs(@angular/cli): update outdated statement about CLI accepting camelCase
The Angular CLI does not accept camelCase args.
2023-09-05 10:02:36 -07:00
Alan Agius
17ffedc3ec refactor(@angular/cli): remove legacy NPM compatibility check
This check should no longer be needed as on supported versions of Node.js NPM 7.5 is no longer installed by default.
2023-09-01 15:17:52 +02:00
aanchal
9506d4bafa docs: fix typos 2023-08-03 14:13:50 -04:00
Alan Agius
d0f005913f fix(@angular/cli): add zone.js to ng version output
This commit add `zone.js` to the `ng version` command output.
2023-07-12 10:06:48 -04:00
aanchal
eaffdc0ff7 docs: remove duplicate words 2023-06-14 11:22:54 +02:00
alkavats1
76a12277f7 refactor: removed unused import statements 2023-06-09 13:39:32 +02:00
Alan Agius
4b9405cce3 docs: improve wording in doc command version description 2023-04-26 18:36:15 +00:00
Alan Agius
c0a0f727f8 fix(@angular/cli): process keeps running when analytics are enabled
In newer Node.js versions ng commands do not terminate properly when analytics are enabled.

This is because the request is never closed unless a `data` event listener is attached.

Closes #25034 and closes #25008
2023-04-18 20:22:20 +00:00
Alan Agius
8cf1254307 refactor(@angular/cli): update E2E command alias
The mistake was introduced in a previous commit that introduced registration of lazy loading of commands.
2023-04-14 21:53:30 +00:00
Alan Agius
5b62074ec2 perf(@angular/cli): register CLI commands lazily
Currently there is a lot of overhead coming from requiring external modules when registering commands such as `ng update` and `ng add`.
This is because these commands do not lazily require all the modules causes the resolution of unneeded packages to be part of the critical path.

With this change we "require” only the command that we we need to execute, which reduce the number of node modules resolutions in the critical path.
2023-04-13 16:24:01 +00:00
Alan Agius
fb19f5f3d3 fix(@angular/cli): collect tech information
Currently tech information such as OS and OS version was not being collected property due to missing required fields.
2023-04-03 11:49:52 +00:00
Alan Agius
7cb5689e02 feat(@angular/cli): show optional migrations during update process
When running `ng update` we now display optional migrations from packages.

When the terminal is interactive, we prompt the users and ask them to choose which migrations they would like to run.
```
$ ng update @angular/core --from=14 --migrate-only --allow-dirty
Using package manager: yarn
Collecting installed dependencies...
Found 22 dependencies.
** Executing migrations of package '@angular/core' **

▸ Since Angular v15, the `RouterLink` contains the logic of the `RouterLinkWithHref` directive.
  This migration replaces all `RouterLinkWithHref` references with `RouterLink`.
  Migration completed (No changes made).

** Optional migrations of package '@angular/core' **

This package have 2 optional migrations that can be executed.
Select the migrations that you'd like to run (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
❯◯ Update server builds to use generate ESM output.
 ◯ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```

In case the terminal is non interactive, we will print the commands that need to be executed to run the optional migrations.
```
$ ng update @angular/core --from=14 --migrate-only --allow-dirty
Using package manager: yarn
Collecting installed dependencies...
Found 22 dependencies.
** Executing migrations of package '@angular/core' **

▸ Since Angular v15, the `RouterLink` contains the logic of the `RouterLinkWithHref` directive.
  This migration replaces all `RouterLinkWithHref` references with `RouterLink`.
  Migration completed (No changes made).

** Optional migrations of package '@angular/core' **

This package have 2 optional migrations that can be executed.

▸ Update server builds to use generate ESM output.
  ng update @angular/core --migration-only --name esm-server-builds

▸ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  ng update @angular/core --migration-only --name migration-v15-router-link-with-href
```

**Note:** Optional migrations are defined by setting the `optional` property to `true`. Example:
```json
{
  "schematics": {
    "esm-server-builds": {
      "version": "15.0.0",
      "description": "Update server builds to use generate ESM output",
      "factory": "./migrations/relative-link-resolution/bundle",
      "optional": true
    }
}
```

Closes #23205
2023-03-08 17:49:07 +00:00
Alan Agius
68024234ed feat(@angular/cli): remove deprecated defaultCollection from workspace configuration
The deprecated 'defaultCollection' workspace option has been removed

BREAKING CHANGE:

The deprecated `defaultCollection` workspace option has been removed. Use `schematicCollections` instead.

Before
```json
"defaultCollection": "@angular/material"
```

After
```json
"schematicCollections": ["@angular/material"]
```
2023-02-17 16:10:21 +00:00
Alan Agius
d58428d3db feat(@angular/cli): remove deprecated defaultProject from workspace configuration
The deprecated 'defaultProject' workspace option has been removed

BREAKING CHANGE: The deprecated `defaultProject` workspace option has been removed. The project to use will be determined from the current working directory.
2023-02-17 16:10:21 +00:00
Alan Agius
8095268fa4 build: update to rxjs 7
G3 is now using RXJS version 7 which makes it possible for the CLI to also be updated to RXJS 7.

NB: this change does not remove all usages of the deprecated APIs.

Closes #24371
2023-02-16 14:59:40 +00:00
Charles Lyding
c29c8e18d8 refactor(@angular/cli): remove Node.js v14 support
BREAKING CHANGE: Node.js v14 support has been removed

Node.js v14 is planned to be End-of-Life on 2023-04-30. Angular will stop supporting Node.js v14 in Angular v16.
Angular v16 will continue to officially support Node.js versions v16 and v18.
2023-02-16 14:08:24 +00:00
Alan Agius
f6624b974f feat(@angular-devkit/core): update SchemaRegistry compile to return Promise
Use promise based methods to reduce RXJS usage and boiler-platting.

BREAKING CHANGE: Several changes to the `SchemaRegistry`.
- `compile` method now returns a `Promise`.
- Deprecated `flatten` has been removed without replacement.
2023-02-15 21:03:30 +00:00
Alan Agius
d9fed6a517 build: update parse5-html-rewriting-stream to version 7
This fixes an issue were the HTML is truncated if it's 128Kb or greater.

Closes #24707
2023-02-14 15:23:09 +00:00
Alan Agius
522463c42b fix(@angular/cli): replace os.version with os.release.
This is more user friendly.
2023-02-14 15:20:59 +00:00
Alan Agius
5f407337f9 fix(@angular/cli): add set SessionEngaged in GA
This is required for realtime reports.
2023-02-14 15:20:59 +00:00
Alan Agius
545c180e2b fix(@angular/cli): convert before option in .npmrc to Date
Previously, the `before` option in the npmrc was not converted properly to a date.

See: https://docs.npmjs.com/cli/v8/using-npm/config#before

Closes #24685
2023-02-10 20:17:41 +00:00
Kristiyan Kostadinov
234f265d16 fix(@angular/cli): error if Angular compiler is used in a schematic
When a schematic is executed, it is wrapped in a custom Node context. This context doesn't expose the same set of global variables. This can lead to an error if a schematic is importing the Angular compiler and the app is using i18n, because the `TextEncoder` isn't exposed through the custom context (see https://github.com/angular/angular/issues/48940).

These changes add the `TextEncoder` to the context.

Fixes https://github.com/angular/angular/issues/48940.
2023-02-07 01:01:20 +00:00
Jason Bedard
fac1e58b73
run e2e tests under bazel (#24338)
* test: run legacy-cli e2e tests via bazel

* fixup! test: run legacy-cli e2e tests via bazel

* fixup! test: run legacy-cli e2e tests via bazel

* fixup! test: run legacy-cli e2e tests via bazel
2023-02-03 07:52:28 +00:00
Alan Agius
7bcb19cddb fix(@angular/cli): only set DebugView when NG_DEBUG is passed
`querystring.stringify` will not remove undefined values.
2023-02-02 14:04:00 +00:00
Alan Agius
89ab29901b docs(@angular/cli): minor updates to ng run description
Minor improvements of `ng run` docs
2023-01-24 20:12:19 +00:00
Alan Agius
983adbd6eb build: update @types/yargs to ^17.0.20 2023-01-20 18:37:40 +00:00
Alan Agius
0f58a17c4c feat(@angular/cli): log number of files update during ng update
This commit updates `ng update` to include the number of files updated when a migration is completed.

Closes #24488
2023-01-19 22:13:19 +00:00
Alan Agius
b5737efae8 fix(@angular/cli): handle extended schematics when retrieving aliases
Previously base collections where not being taken into account and the recent changes caused an exception

```
An unhandled exception occurred: Cannot destructure property 'aliases' of 'collection.description.schematics[schematicName]' as it is undefined.
```

See: https://angular-team.slack.com/archives/CHEEH2LCA/p1674122139247359
2023-01-19 22:12:26 +00:00
Doug Parker
f7c78dd384 Revert "refactor: temporaily disable sending analytics"
This reverts commit df9674bd361b46b1275eed98e503f8897e701af5.

Re-enables anayltics.
2023-01-18 23:13:58 +00:00
Doug Parker
b5dcb29cba refactor: only collect Node version if it's a standard version string
Any other kinds of Node version are collected as "other" to avoid pulling in an unbounded user input.
2023-01-18 17:12:47 +00:00
Alan Agius
3ebb195525 fix(@angular/cli): register schematic aliases when providing collection name in ng generate
Previously, schematic aliases were not registered when a collection name was provided to `ng generate`.  Example: `ng generate c` where `c` is an alias for `component` would work, but `ng generate @schematics/angular:c` would fail. This commits fixes the schematic registration to handle the latter case.

Closes #24518
2023-01-13 14:58:36 +00:00
Alan Agius
697df4f6e5 fix(@angular/cli): remove --to option from being required when using --from in ng update
This change remove the requirement for the `to` option to be provided when using the `from` option in conjunction with `migrate-only`.

Closes #24510
2023-01-13 08:29:25 +00:00