167 Commits

Author SHA1 Message Date
Paul Gschwendtner
e8a97aa465 build: migrate @angular-devkit/core/node tests to rules_js
Migrates the sub-entry point tests for core/node to `rules_js`.
2025-01-21 18:19:11 +01:00
Paul Gschwendtner
397ea00552 build: migrate @angular-devkit/architect/node tests to rules_js
Migrates the sub-entry point tests for architect/node to `rules_js`.
2025-01-21 18:19:11 +01:00
Paul Gschwendtner
0f5106d970 test: improve stability of strategy tests
The strategy tests are extremely time-sensitive with regards to the RxJS
job logic executing, and the tests currently rely on `setImmediate` to
flush/trigger job execution. This seems to be rather unstable via Remote
execution, and sensitive to changes with the execution (e.g. injecting
source map support or not), so we are stabilizing the tests further by
having better time delays for job execution, and by using `setTimeout`
for flushing. This seems very sufficient.
2025-01-17 16:29:45 +01:00
Paul Gschwendtner
1a4157d88c build: migrate @angular/cli tests to use rules_js
Integrates `@angular/cli` into the pnpm workspace and wires up the
native `rules_js` rules.

One nice benefits that highlight here:

- `resolve` runtime dependency is only installed in the CLI folder, and
  we can pull it from there. --> Locally managed deps! :yay:
2025-01-17 16:29:45 +01:00
Paul Gschwendtner
ac37218e41 build: migrate @angular-devkit/architect jasmine test to native rules_js
Instead of using `rules_nodejs` interop and the linker at runtime, the
test target is migrated to the new `jasmine_test` rule, leveraging the
pnpm workspace for first-party dependencies.

Note that in the future we may be able to rename the local node modules
to something more clear. e.g. `:local_modules/@angular-devkit/core`, but
for now this is not possible :(

This commit shows how similar packages can be migrated in the future.
2025-01-15 19:20:40 +01:00
Paul Gschwendtner
96b6a16a65 refactor: add explicit types for createBuilder exports
This is necessary as with the new compilation, leveraging pnpm-linked
first party dependencies, there are cases **during migration** where
multiple locations of the same package exist. e.g.

- `@angular_devkit/architect/node_modules/@angular-devkit/core` (pnpm package output)
- `@angular_devkit/core` (plain js sources)

This is fine, and there is no risk of wrong types, and this should only
occur during migration anyway, but it causes a few type issues as
TypeScript is unable to emit proper types for inference. This is okay,
as we'd likely even want to make use of `isolatedDeclarations` at some
point, but we just add explicit types right now.

(also making `Builder` type more type safe, checking assignability
properly).
2025-01-15 19:20:40 +01:00
Paul Gschwendtner
4fee94a96c build: rename //:root_modules to //:node_modules.
This is necessary as `rules_js` requires this "common name" when dealing
with Yarn workspaces, linking first party dependencies automatically.

In the future, we may be able to send a PR to `rules_js` to support a
custom name somehow.
2025-01-15 19:20:40 +01:00
Paul Gschwendtner
b55bd318f1 fixup! build: migrate @angular-devkit/architect to npm_package
Include JSON files
2025-01-10 13:15:00 +01:00
Paul Gschwendtner
2218b0d0df build: migrate @angular-devkit/architect to npm_package
Migrates the `@angular-devkit/architect` package to the `rules_js` npm
package rule, consuming the direct `rules_ts` output JS files.

Notably, substitution is FAR different than what it used to be with
`rules_nodejs`, so we needed some extra work to leverage `make_template`
for substitutions in `package.json` files. **Keep in mind** that for
now, this does not apply to any other files; so we only substitute in
the `package.json`, but not in e.g. `.js` files as before. We will
follow-up on this.

The other jq merging/filtering for snapshot or tar references in
`package.json` files is kept as is, and is temporarily duplicated. This
is acceptable as the migration should be pretty smooth and quick.
2025-01-10 13:15:00 +01:00
Paul Gschwendtner
a8335cf950 build: never use interop targets for ts compilations
* Removes `interop_deps` from the `ts_project` interop macro.
* Keeps `_rjs` suffix for now as we still need the interop targets for
  e.g. `jasmine_node_test` and the `rules_nodejs` linker.

In follow-ups we can remove the suffix, and interop layer.
2025-01-09 09:42:06 +01:00
Alan Agius
aa6bf07f35 fix(@angular-devkit/architect): provide better error when builder is not defined
When a builder is not defined a more actionable error message is now displayed.

Closes #29226
2025-01-06 15:19:00 +01:00
Charles Lyding
fe1ae69339 fix(@angular-devkit/architect): avoid Node.js resolution for relative builder schema
To avoid the need to perform Node.js resolution for the typical case of a relative
builder schema, a check is now performed to determine if a schema path within the
build manifest appears to be relative.
2024-12-17 16:28:37 -05:00
Paul Gschwendtner
7a0adb9ca3 build: migrate remaining angular-devkit/architect to ts_project
This completes `ts_library` to `ts_project` for the architect devkit
package.
2024-12-17 11:47:09 -05:00
Paul Gschwendtner
410040289a build: rename //:node_modules to root modules
In our dev-infra sync we decided that we want to have less
ambiguous naming for node modules from the workspace root vs. node
modules that are local to the package.

Consider the confusion between: `//:node_modules` and `:node_modules`.
This commit fixes this by naming the workspace `node_modules` as
`:root_modules`. This does not have an effect on runtime of NodeJS
output because `rules_js` continues to lay out the root modules as
`/node_modules` folder; as it should.
2024-12-16 12:17:17 -05:00
Paul Gschwendtner
a19a72d8fc build: migrate angular-devkit/architect to ts_project
This commit updates the architect devkit package code to use
`ts_project`. We specificially don't migrate the jasmine node test yet
as we want to experiment further with the incremental migration.
2024-12-16 12:17:17 -05:00
dai1ooleet0aesei
2b8a02bac0 feat(@angular-devkit/architect): require build schemas from modules 2024-12-12 08:18:56 -08:00
Jan Martin
78f76485fe feat(@angular-devkit/architect): merge object options from CLI
We recently introduced the ability to pass object values from the
command line (#28362). @clydin noticed that the initial behavior
didn't work well for `--define`: It completely replaced all values
even if just one of multiple defines is specified.

This updates the architect to support merging of object options.
If both the base option (e.g. from `angular.json`) and the override
(e.g. from a CLI `--flag`) are objects, the objects are merged.

See: https://github.com/angular/angular-cli/pull/28362
2024-09-12 09:50:05 +02:00
Alan Agius
743188ba62 refactor: Add lines-around-comment rule
I often struggle with spacing around block comments, so I've decided to add the `lines-around-comment` lint rule to help manage this.

For more details, see the https://eslint.style/rules/js/lines-around-comment
2024-09-11 12:10:54 +02:00
Charles Lyding
fa9bce0e9a test: enable @typescript-eslint/no-unnecessary-type-assertion lint rule
The `@typescript-eslint/no-unnecessary-type-assertion` rule is now enabled and all failures
have been addressed within the code.
2024-06-25 16:57:03 -04:00
Charles Lyding
17e168379e build: additional fixes for tsetse rule compliance
Due to bazel rules_nodejs caching, several additional `JSON.parse` usages were not
caught in the first set of fixes. These have now been addressed. Also,
the `must-use-promises` rule has been patched to match the behavior of the
`@typescript-eslint/no-floating-promises` for consistency.
The bazel option `suppressTsconfigOverrideWarnings` was also removed from the
`tsconfig` as it is a no-op and was previously used for now removed feature.
Test files are currently excluded from the `JSON.parse` rule to avoid large
changes to test code.
2024-06-25 11:17:33 -04:00
Charles Lyding
39f946a848 build: enabled isolated modules TypeScript option
The TypeScript `isolatedModules` option is now enabled for all TypeScript
code within the repository. As a result, all packages will now be built
with the option enabled. This does not affect projects created with the CLI
and is only related to the building of the actual Angular CLI code.
The `isolatedModules` option ensures that code can be emitted without the
TypeScript typechecker and allows tools other than TypeScript to potentially
be used. Code was updated to correct all errors after the option was enabled.
Additionally, some early code fixes were done to add function and accessor
return types to prepare for future `isolatedDeclarations` usage. More changes
would be needed to consider turning on `isolatedDeclarations`, however.
2024-06-23 15:34:49 +02:00
Ash Ramirez
434a3740f0 refactor(@angular/cli): update aio links -> adev links
Updates for all angular.io links to the new angular.dev domain. Additionally, adjustment to new resources where the equivalent does not exist on the new site (e.g. Tour of Heroes tutorial)
2024-06-06 11:12:06 +02:00
Charles Lyding
57d57b4211 fix(@angular-devkit/architect): resolve builder aliases from containing package
When resolving a builder alias, the base path for the resolution will now
use the containing package. This prevents potential resolution failure due
to varying package manager installation strategies.
2024-05-02 10:00:18 -04:00
Charles Lyding
6d9a06a437 refactor(@angular-devkit/architect): allow aliasing builder names in package builder manifest
A builder's manifest definition within a package (typically `builders.json`) can now contain
a string value that will be used as a builder specifier when loading the named builder. This
allows a builder name to be aliased to another builder. The other builder may also be in
another package.
The build resolution logic has also been updated to remove use of the global `require` to
support eventual direct ESM usage.
2024-04-09 07:50:10 -04:00
Charles Lyding
910531a3c8 refactor: remove outdated namespace syntax usage
The `namespace` TypeScript usage within the CLI has been removed. This
syntax is not recommended outside of type definition files.
2024-01-26 08:55:53 +01:00
Charles Lyding
8f47f1e965 feat(@angular-devkit/build-angular): provide default and abbreviated build target support for dev-server and extract-i18n
The `buildTarget` options for both the `dev-server` and `extract-i8n` builders
now have default values that reflect the recommended and new project generated
values. The defaults are as follows where `<current-project>` is the name of the project
where the `dev-server` or `extract-i18n` builder target is located:
* `dev-server` --> `<current-project>:build:development`
* `extract-i18n` --> `<current-project>:build`

Additionally, abbreviated target specifiers are now supported for these
options. This allows target specifiers such as `::production` which would expand
to `<current-project>:build:production` for either builder.
Abbreviated target specifiers are only supported for the `buildTarget` option in
the `dev-server` and `extract-i18n` builders.
2024-01-12 10:58:29 -08: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
11420667f9 build: use single Node.js toolchain to run unit tests
E2E tests are used to run tests on multiple platforms and node.js versions.
2023-10-30 17:50:47 +01:00
aanchal
efeae1e1f1 docs: remove duplicate words 2023-08-04 14:49:14 -04:00
aanchal
9506d4bafa docs: fix typos 2023-08-03 14:13:50 -04:00
aanchal
b94958d419 docs: fix typo in api.ts 2023-08-03 14:11:43 -04:00
Angular Robot
367ddabed0 build: update dependency rxjs to v7.8.1 2023-04-27 10:01:39 +00:00
Charles Lyding
48871381a1 fix(@angular-devkit/architect): allow registered builder teardowns to execute
Previously, the base job handler was completing the entire job before any teardowns
could attempt to execute.
2023-04-05 09:25:37 +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
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
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
Charles Lyding
774e83df8b fix(@angular-devkit/architect): default to failure if no builder result is provided
Currently, if an architect builder does not provide any results, the CLI will crash
trying to access an error message property on the result. Instead architect will now
provide a default failure result `{ success: false }` in the event that the builder
exits prior to generating a result. Thrown errors continue to be propagated as before.
2022-11-08 09:33:18 +01:00
Alan Agius
c969152de6 refactor: remove analytics API from core and architect
All analytics is now in the @angular/cli package

BREAKING CHANGE: analytics APIs have been removed without replacement from `@angular-devkit/core` and `@angular-devkit/architect`.
2022-10-11 18:52:30 +02:00
Alan Agius
93adeeb798 refactor: move experimental jobs API from @angular-devkit/core to @angular-devkit/architect
With this change we move `jobs` APIs to `@angular-devkit/architect` as this are intended to used with `@angular-devkit/architect`.
2022-10-07 11:09:53 -04:00
Jason Bedard
4de9045de8 test: unit test multiple node versions in separate jobs 2022-09-14 10:43:17 -07:00
Charles Lyding
b2add316e7 build: remove unneeded BUILD file licenses rule comments 2022-09-13 10:33:49 -07: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
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
Charles Lyding
ecdbe721a1 fix(@angular-devkit/architect): complete builders on the next event loop iteration
Waiting to complete the builder until the next tick allows the logging
subscription to flush and provide queued logging entries to the builder
consumer.
2022-06-29 07:58:53 -04:00
Charles Lyding
1e21440c10 build: mark external only bazel rules 2022-06-17 16:25:41 +02:00
Charles Lyding
1b9880c5cb refactor(@angular-devkit/architect): assert catch clause variable type before usage
Prepares the `@angular-devkit/architect` 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
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
Alan Agius
7fa3e65879 feat(@angular/cli): support TypeScript 4.6.2
BREAKING CHANGE:

Support for TypeScript 4.4 and 4.5 has been removed. Please update to TypeScript 4.6.
2022-03-10 15:36:19 -05:00
Alan Agius
5def2de1bf fix(@angular-devkit/architect): correctly handle ESM builders
Previoiusly, we didn't correctly handle ESM builders as the `import` was always downlevelled to `require` by TypeScript.
2022-01-24 20:33:21 +01:00