240 Commits

Author SHA1 Message Date
Angular Robot
6c5c71103f build: update all non-major dependencies 2023-08-03 12:36:35 -04:00
Alan Agius
ba7686283b build: update all non-major dependencies 2023-07-10 09:54:57 -04:00
Charles Lyding
11e0a51b17 build: minor cleanup of bazel build rules
BUILD files for each package have had outdated glob excludes removed.
Additionally, some src args have been reduced to a single file where possible.
The root bazel ignore file has also been expanded to include all node module
directories in each package. The ignore file does not appear to currently support
globs so each path has been individually specified.
2023-05-22 09:36:44 -04:00
Alan Agius
22c1cb66c5 fix(@angular-devkit/schematics): do not generate an UpdateBuffer for created and overridden files
`UpdateBuffer` only supports UTF-8 encoded files, which causes schematics to emit corrupted binary like files such as images.

This commit also introduce an errors when the `UpdateRecorder` is used for non UTF-8 files.

Closes #25174
2023-05-10 11:20:29 +00:00
Angular Robot
367ddabed0 build: update dependency rxjs to v7.8.1 2023-04-27 10:01:39 +00:00
Angular Robot
b564b9afb8 build: update all non-major dependencies 2023-02-22 13:06:18 +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
Lukas Spirig
d2ef386f46 refactor(@angular-devkit/schematics): remove UpdateBuffer and rename UpdateBuffer2 to UpdateBuffer
This PR removes the internally built `UpdateBuffer` and renames
`UpdateBuffer2` (based on magic-string) to `UpdateBuffer`. This
should have little to no impact for consumers.

BREAKING CHANGE:
The depracated `UpdateBuffer` has been removed and `UpdateBuffer2`
is renamed to `UpdateBuffer`. With this change the related and
deprecated symbols `ContentCannotBeRemovedException` and `Chunk`
have also been removed.
2023-02-15 21:04:06 +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
Angular Robot
d439cb9727 build: update all non-major dependencies 2023-02-13 14:16:12 +00:00
Charles Lyding
7f93735e98 build: use bazel to perform release builds
When performing a release via the dev-infra `ng-dev` tooling, the release
builds for the packages that will be published are now performed using bazel.
Prior to this, the release builds were performed using a custom build script
that programmatically invoked TypeScript APIs. The Bazel build and discovery
process for the releasable packages is performed by a script that is based on
the scripts from components and framework repositories. Several small modifications
were performed to match the behavior and structure of the cli repository:
* Use of `packages` as the source root in the bazel query
* Use of `pkg_npm` rule in the bazel query
* Partial transition to native Node.js `fs` APIs instead of `shelljs`
* Directory creation per package when copying output (supports multiple package scopes)
* Copying of archives (tgz) for each package

The snapshot and local build capabilities are not modified as part of this change
but will be merged in a followup as part of a larger transition to use bazel
throughout the package build process.
2023-01-05 03:21:58 +00:00
Alan Agius
207358afb8 feat(@angular-devkit/schematics): add runSchematic and runExternalSchematic methods
These async methods are a replacement for the Observable based `runSchematicAsync` and `runExternalSchematicAsync` methods.

DEPRECATED:
The Observable based `SchematicTestRunner.runSchematicAsync` and `SchematicTestRunner.runExternalSchematicAsync` method have been deprecated in favor of the Promise based `SchematicTestRunner.runSchematic` and `SchematicTestRunner.runExternalSchematic`.
2022-12-08 14:49:43 -08:00
Angular Robot
3d885fbb21 build: update all non-major dependencies 2022-12-08 12:09:04 -08:00
Alan Agius
f347538867 Revert "refactor(@angular-devkit/schematics): remove UpdateBuffer and rename UpdateBuffer2 to UpdateBuffer"
This reverts commit 9b07b469b622e083a9915ed3c24e1d53d8abf38f.
2022-10-10 20:22:03 +02:00
Günhan Gülsoy
2230374e18 refactor: remove add implicate types for better code readability
When strictNullChecks in enabled in TS compiler, the following files
cause some failures in certain environments. Fix these failures.
Also update outdated goldens.
2022-10-10 12:22:56 +02:00
Angular Robot
cdf78d4641 build: update all non-major dependencies 2022-10-10 12:22:40 +02:00
Lukas Spirig
9b07b469b6 refactor(@angular-devkit/schematics): remove UpdateBuffer and rename UpdateBuffer2 to UpdateBuffer
This PR removes the internally built `UpdateBuffer` and renames
`UpdateBuffer2` (based on magic-string) to `UpdateBuffer`. This
should have little to no impact for consumers.

BREAKING CHANGE:
The depracated `UpdateBuffer` has been removed and `UpdateBuffer2`
is renamed to `UpdateBuffer`. With this change the related and
deprecated symbols `ContentCannotBeRemovedException` and `Chunk`
have also been removed.
2022-10-07 10:38:18 -04:00
Angular Robot
cd1ae437e3 build: update all non-major dependencies 2022-10-07 10:36:46 -04:00
Charles Lyding
8eb58bdbe0 fix(@angular-devkit/schematics): throw more relevant error when Rule returns invalid null value
A `null` value is not considered a valid return value for a schematics Rule. While the Rule
type should prevent this, casting could allow this to potentially occur. Previously, this
would accidentally be treated the same as a void return due to incomplete result checking.
However, recent refactoring caused the `null` case to fail with a non-obvious error message
when it should have failed with the existing `InvalidRuleResultException`. Non-tree result
objects including `null` will now fail with `InvalidRuleResultException`.
2022-10-05 13:44:15 -04:00
Brent Schmidt
4a2f4dcaac refactor(@angular-devkit/schematics): Delete 'rename' rule
- Based on discussion in closed PR #23673, delete `rename` rule.
2022-10-04 09:16:51 -04:00
Angular Robot
1a4615c787 build: update all non-major dependencies 2022-09-30 16:23:52 +02:00
Angular Robot
45e39426a9 build: update all non-major dependencies 2022-09-23 21:20:48 -04:00
Jason Bedard
4de9045de8 test: unit test multiple node versions in separate jobs 2022-09-14 10:43:17 -07:00
Charles Lyding
f33fb34ae1 build: adjust BUILD file external comment markers
Improvements to the syncing process allow for reduced usage of the comment markers.
2022-09-01 06:24:31 -04:00
Charles Lyding
e402c2358c build: adjust BUILD file external comment markers
Improvements to the syncing process allow for reduced usage of the comment markers.
2022-08-31 08:37:19 -04:00
Angular Robot
56b3299f12 build: update all non-major dependencies 2022-08-30 08:54:10 -04:00
Alan Agius
4368c85983 refactor: remove unused local variables 2022-08-12 08:19:26 -04:00
Charles Lyding
398d66af4f refactor(@angular-devkit/schematics): reduce RxJS usage in callRule/callSource functions
The amount of additional RxJS operators and chaining has been reduced within the `callRule`
and `callSource` functions. This also reduces the complexity of the code and removes
several repetitive code segments.
2022-08-12 08:12:56 -04:00
Jason Bedard
db5c1fc13c test: run tests on multiple node versions 2022-08-03 10:33:46 -07:00
Paul Gschwendtner
087ab46ca9 build: update dev-infra packages and account for build-tooling split from ng-dev
The dev-infra build tooling is now decoupled from `ng-dev`. This will
make it easier to update `ng-dev` without necessarily needing to upgrade
the whole build system, Bazel etc. This is useful when e.g. new release
tool features have been added and should also be ported to active LTS
branches.
2022-07-27 12:35:15 +02:00
Angular Robot
0a990c525a build: update all non-major dependencies 2022-07-14 15:21:03 -07:00
Charles Lyding
1e21440c10 build: mark external only bazel rules 2022-06-17 16:25:41 +02:00
Charles Lyding
cb9ee245d1 refactor(@angular-devkit/schematics): assert catch clause variable type before usage
Prepares the `@angular-devkit/schematics` package for the eventual change of enabling the
TypeScript `useUnknownInCatchVariables` option. This option provides additional
code safety by ensuring that the catch clause variable is the proper type before
attempting to access its properties. Similar changes will be needed in the other
packages in the repository prior to enabling `useUnknownInCatchVariables`.
2022-06-14 11:28:21 +02:00
Charles Lyding
901f5dd7fc fix(@angular-devkit/schematics): support ignore scripts package installs with Yarn 2+
Yarn 2 and higher no longer support the `--ignore-scripts` flag.
The `NodePackageInstallTask` will now spawn Yarn with environment variables to ignore
scripts instead of the commandline option. Other package managers remain unchanged.
This provides the necessary functionality for the task without relying on Yarn
commandline options.
2022-05-27 14:08:29 -04:00
Charles Lyding
9ff2c55e85 fix(@angular-devkit/schematics): support quiet package installs with Yarn 2+
Yarn 2 and higher no longer support the `--silent` flag.
The `NodePackageInstallTask` will now spawn package managers with the stdout ignored when quiet
mode is needed and only show stderr when the process exits unsuccessfully. This
provides the necessary functionality for the task without relying on package manager
options.
2022-05-27 14:08:11 -04:00
Charles Lyding
526cdb263a feat(@angular-devkit/schematics): allow chain rule to accept iterables of rules
Previously, the `chain` base rule only accepted an `Array` of schematics rules.
In addition to still allowing an `Array`, `chain` now can accept either an `Iterable<Rule>`
or `AsyncIterable<Rule>`. This provides support for sync and async generator functions
with the `chain` rule.
2022-05-24 09:58:18 -07:00
Renovate Bot
4be7cdce82 build: update all non-major dependencies 2022-05-12 09:43:13 -04:00
Kristiyan Kostadinov
0301cf6c10 build: prepare TypeScript 4.7
Expands the version range to allow TypeScript 4.7 and makes the necessary code changes in order to support it.
2022-05-06 15:51:02 -07:00
Paul Gschwendtner
156f15e47f build: cleanup references to old master branch
Cleans up all referneces to the old `master` branch.
2022-05-04 09:55:54 -07:00
Charles Lyding
0e6425fd88 feat(@angular-devkit/schematics): disable package script execution by default in NodePackageInstallTask
In an effort to improve supply chain security, the `NodePackageInstallTask` will now use the package
manager's `--ignore-scripts` option by default. Without the option, all direct and transitive
dependencies would have their scripts executed during the task's package manager installation operation.
The change only affects the package manager behavior controlled by the Schematics `NodePackageInstallTask`.

First-party Angular schematics do not currently require any direct or transitive dependency
`install`/`postinstall` scripts to execute. Only two dependencies within a v14.0 new project would
potentially be affected by this: `nice-napi` (transitive from `piscina`) and `esbuild`. The `nice-napi`
functionality of `piscina` is unused within the Angular CLI with no plans to use it in the future.
Even if it was used, the `install` script runs `node-gyp-build` which would only have an effect
(based on the current version 1.0.2) on platforms that are not Windows, darwin-x64, or linux-x64.
In the event this functionality is eventually used, the Angular CLI could be setup to automatically execute
this particular script for unsupported platforms. For `esbuild`, the `postinstall` functionality
performs an optional native binary bootstrap optimization but would only be performed if not
using Windows or Yarn. As such, it would not be performed for many users regardless of the change in
this commit. If noticeable performance regressions on platforms where the optimization was previously
performed are reported, the script could also be setup to be automatically run by the Angular CLI during
project creation and/or first build.

BREAKING CHANGE: Schematics `NodePackageInstallTask` will not execute package scripts by default
The `NodePackageInstallTask` will now use the package manager's `--ignore-scripts` option by default.
The `--ignore-scripts` option will prevent package scripts from executing automatically during an install.
If a schematic installs packages that need their `install`/`postinstall` scripts to be executed, the
`NodePackageInstallTask` now contains an `allowScripts` boolean option which can be enabled to provide the
previous behavior for that individual task. As with previous behavior, the `allowScripts` option will
prevent the individual task's usage of the `--ignore-scripts` option but will not override the package
manager's existing configuration.
2022-04-29 16:37:56 -07:00
Charles Lyding
33f9f3de86 feat(@angular-devkit/schematics): support reading JSON content directly from a Tree
The schematics `Tree` now contains an additional `readJSON` method that supports directly
reading and parsing the content of a file as UTF-8 JSON with comment support. This avoids the need to manually
decode a Buffer, parse and handle JSON comments within a schematic when JSON content is needed.
If a file path does not exist, an exception will be thrown. While this differs from the semantics of `read`,
it helps reduce the amount of code needed for common schematic use cases. JSON parse errors will also result
in an exception being thrown with a message detailing the error.
2022-04-26 19:24:55 -04:00
Charles Lyding
01297f4503 feat(@angular-devkit/schematics): support reading text content directly from a Tree
The schematics `Tree` now contains an additional `readText` method that supports directly
reading the content of a file as UTF-8 text. This avoids the need to manually decode a Buffer
within a schematic when text content is needed. If a file path does not exist, an exception
will be thrown. While this differs from the semantics of `read`, it helps reduce the amount
of code needed for common schematic use cases.
2022-04-26 19:24:55 -04:00
Charles Lyding
25498ad5b2 feat(@angular-devkit/schematics): re-export core string helpers from schematics package
The string helpers are predominantly used within schematics that will already depend and import from
the `@angular-devkit/schematics` package. By re-exporting from `@angular-devkit/schematics`, the need
to directly depend and import `@angular-devkit/core` within a schematic can be reduced and in many
cases eliminated.
2022-04-22 11:31:53 -04:00
Daniil Dubrava
464cf330a1 feat(@angular-devkit/schematics): support null for options parameter from OptionTransform type 2022-04-18 09:38:31 +02:00
Charles Lyding
9a5251cff9 refactor(@angular-devkit/schematics): provide schematic collection description to FileSystemEngineHost resolver
The `_resolveReferenceString` abstract method of the `FileSystemEngineHostBase` class now has a third parameter
that provides the collection description of the schematic currently being resolved. This allows the resolver to
use any fields/options present within the collection description to adjust the resolution of the schematic. The
`encapsulation` optional field is also added to the `FileSystemCollectionDescription` type which will in the future
allow control of the `@angular/cli` VM context wrapping on an individual schematic collection basis.
2022-04-11 11:45:43 -07:00
Alan Agius
4b4cecf88f test: update tests to work with Jasmine version 4
These changes include fixes to tests, timeout and stop of architect to make tests work with Jasmine 4.

One noticeable change that when we didn't stop architect through `run.stop()` this causes Bazel to timeout now.

Example
```
-- Test timed out at 2022-03-24 12:07:07 UTC --
/private/var/tmp/_bazel_alanagius/5168427e57f204ca069c602aa7ed1931/sandbox/darwin-sandbox/398/execroot/angular_cli/bazel-out/darwin-fastbuild/bin/packages/angular_devkit/build_angular/build_angular_browser_test.sh.runfiles/angular_cli/packages/angular_devkit/build_angular/build_angular_browser_test.sh: line 424: 41835 Terminated: 15          "${node}" ${LAUNCHER_NODE_OPTIONS[@]+"${LAUNCHER_NODE_OPTIONS[@]}"} ${USER_NODE_OPTIONS[@]+"${USER_NODE_OPTIONS[@]}"} "${MAIN}" ${ARGS[@]+"${ARGS[@]}"} 0<&0
```
2022-03-24 14:41:26 +01:00
Alan Agius
c9c781c7d5 feat(@angular-devkit/schematics): add parameter to listSchematicNames to allow returning hidden schematics.
The return value of `listSchematicNames` will include hidden schematics when is invoked with true as first parameter.

By default, hidden schematics are not returned.
2022-03-22 09:37:57 -07:00
Tobias Speicher
137651645c refactor: replace deprecated String.prototype.substr()
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-21 12:27:52 -07:00
Renovate Bot
a3c0aa9f86 build: update all non-major dependencies 2022-03-03 18:53:49 +01:00
Alan Agius
44c1e6d0d2 refactor(@angular-devkit/schematics): remove deprecated analytics property
BREAKING CHANGE:

Deprecated `analytics` property has been removed from `TypedSchematicContext` interface
2022-01-28 11:01:52 -08:00