204 Commits

Author SHA1 Message Date
Katerina Skroumpelou
9defbdf534 fix(@angular-devkit/core): log name of invalid extension too 2022-07-14 15:15:29 -07:00
Fortunato Ventre
3ec69320f0 fix(@angular-devkit/core): add i18n as valid project extension
When parsing the angular.json file, the 'i18n' key used to configure localization in a localized project should be treated as a special project extension key.

This fixes the warning "Project extension with invalid name found." printed when starting/building the project.
2022-07-14 15:15:07 -07:00
Alan Agius
624e0b0ec6 fix(@angular-devkit/core): provide actionable warning when a workspace project has missing root property
The `root` property is required in a workspace project. Now we issue an actionable warning message when this is missing.

Note: this will become an error in the next major version.

Closes: #21310
2022-07-08 15:57:51 +02:00
Alan Agius
1af3f71aa2 fix(@angular-devkit/core): workspace writer skip creating empty projects property
Before
```json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "projects": {},
  "cli": {
    "analytics": false,
    "warnings": {
      "versionMismatch": false
    }
  }
}
````

After
```json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "cli": {
    "analytics": false,
    "warnings": {
      "versionMismatch": false
    }
  }
}
```
2022-06-22 10:37:25 -07:00
Charles Lyding
e81a6f1c46 test(@angular-devkit/core): update several tests to use async expectations
Using Jasmine's `expectAsync` allows for reduced test code when testing that
a function returning a promise rejects with a specific error.
2022-06-14 11:28:21 +02:00
Charles Lyding
2edb2a0508 refactor(@angular-devkit/core): assert catch clause variable type before usage
Prepares the `@angular-devkit/core` 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
Charles Lyding
13fce451d8 refactor(@angular-devkit/core): delete deepCopy temporary symbol property after use
The `deepCopy` utility function previously set its internal tracking symbol property to `undefined` after completion.
However, this still caused the property to exist with a value of `undefined`. Jasmine 4.1 now checks for symbols with
its `toEqual` expectation which resulted in failing tests. The internal tracking symbol property is now removed instead
via `delete`.
2022-05-04 10:13:18 -07:00
Alan Agius
c0eb926121 refactor(@angular-devkit/core): remove custom json parser
With this change we replace the workspace reader and write to use `jsonc-parser` instead of our custom build JSON parser
2022-04-14 17:13:52 +02:00
Alan Agius
108a0b6acd refactor(@angular-devkit/core): remove fast-json-stable-stringify usage in memoize helper
This is not needed as inputs are typed checked to be `JsonValue`. With this change we get a step closer to remove `fast-json-stable-stringify` dependency.
2022-04-13 12:08:07 -07:00
Alan Agius
a66cfd0c6d refactor(@angular-devkit/core): replace fast-json-stable-stringify import to es6 2022-04-08 09:37:22 -07:00
Alan Agius
67144b9e54 refactor(@angular-devkit/core): remove deprecated parseJson and ParseJsonOptions APIs
BREAKING CHANGE:

`parseJson` and `ParseJsonOptions` APIs have been removed in favor of 3rd party JSON parsers such as `jsonc-parser`.
2022-04-05 11:19:19 -04:00
Alan Agius
c5b3e92991 refactor(@angular-devkit/core): deprecate unused exception classes
With this change we deprecate exception classes that are not used in the CLI repo.

DEPRECATED:

- `ContentHasMutatedException`, `InvalidUpdateRecordException`, `UnimplementedException` and `MergeConflictException` symbol from `@angular-devkit/core` have been deprecated in favor of the  symbol from `@angular-devkit/schematics`.
- `UnsupportedPlatformException` - A custom error exception should be created instead.
2022-03-30 17:17:04 +02: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
455aeea12d fix(@angular-devkit/core): add Angular CLI major version as analytics dimension
With this change we replace the custom dimension 8 `AOT Enabled`, with `Angular CLI Major Version`. The motivation behind replacing this dimension is that the there is already an `aot` dimension with id 13 which serves for the same purpose.

More information to why we need a new dimension for the Angular CLI major version can be found #22130

Closes #22130
2022-03-24 08:53:10 +01: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
Daniele Maltese
b20f34ec17 docs(@angular-devkit/core): typo in string.ts doc
Typo in underscore function code documentation.
2022-02-24 11:15:33 -08:00
Alan Agius
bf733d6758 fix(@angular-devkit/core): correctly resolve schema references defaults
Closes #22600
2022-02-02 11:48:32 -08:00
Alan Agius
a0c02af7e3 refactor(@angular-devkit/core): remove deprecated fs, object and array APIs
BREAKING CHANGE:

The below APIs have been removed without replacement. Users should leverage other Node.js or other APIs.
- `fs` namespace
- `clean`
- `mapObject`
2022-01-31 11:35:18 -08:00
Doug Parker
f9187bcc9b refactor(@angular-devkit/core): update missing workspace file error to explicitly call out angular.json
Internally, we've gotten a lot of bugs of users running the CLI in the wrong directory and not understanding this error. Hopefully calling this out more explicitly will key users to double-check their working directory before filing a bug.
2021-12-11 09:20:16 +01:00
Alan Agius
079ef070c9 refactor(@angular-devkit/build-angular): replace Ivy Enabled analytics dimension with AOT Enabled
The motivation behind this change is that since version 12, application are always built using Ivy, in addition to this, adding AOT as dimension might be  helpful in our decision process if we want to remove JIT.
2021-10-13 21:03:50 +02:00
Alan Agius
cd000d283e test(@angular-devkit/core): address lint issues 2021-10-13 16:50:37 +02: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
Alan Agius
d722fdf1f6 refactor(@angular-devkit/core): remove deprecated JSON parser
BREAKING CHANGE: The deprecated JSON parser has been removed from public API. [jsonc-parser](https://www.npmjs.com/package/jsonc-parser) should be used instead.
2021-08-16 10:01:04 -04:00
Alan Agius
0c92ea5ca3 feat(@angular-devkit/core): remove deprecated schema id handling
BREAKING CHANGE: With this change we drop support for the deprecated behaviour to transform `id` in schemas. Use `$id` instead.

Note: this only effects schematics and builders authors.
2021-08-10 21:40:19 +02:00
Charles Lyding
1cb07caddc build: transition from ts-api-guardian to dev-infra api-golden utility
The dev-infra tooling now directly provides public API change testing capabilities that leverage the `api-extractor` utility. These new testing capabilities are shared with framework and components.
`ts-api-guardian` has been removed as a dependency as a result.
2021-07-21 14:55:18 -07: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
1dd3bda57f test: fix failing tests which were not shown
Previously when an unhandled error occured Bazel would mark the suit as passed instead of failed.

See: https://togithub.com/bazelbuild/rules_nodejs/commit/3c4ef58
2021-06-10 16:25:19 +02:00
Alan Agius
f209cb5545 test(@angular-devkit/core): update host tests to not use deprecated Jasmine behaviour
```
DEPRECATION: An asynchronous before/it/after function was defined with the async keyword but also took a done callback. This is not supported and will stop working in the future. Either remove the done callback (recommended) or remove the async keyword.
```
2021-05-31 12:48:18 +01:00
Alan Agius
06af7d7e7b fix(@angular-devkit/core): handle async schema validations 2021-05-31 12:48:18 +01:00
Alan Agius
9f85bc5625 fix(@angular-devkit/core): handle complex smart defaults in schemas 2021-05-31 12:48:18 +01:00
Alan Agius
600d266ca4 fix(@angular-devkit/core): show allowed enum values when validation on enum fails 2021-05-31 12:48:18 +01:00
Alan Agius
621938dd5e test(@angular-devkit/core): fix memory host spec
This previously caused an `UnhandledPromiseRejection` which caused tests not to run. But Jasmine, still reported success.

```
yarn bazel test //packages/angular_devkit/core:core_test --test_summary=detailed --test_output=all

INFO: Analyzed target //packages/angular_devkit/core:core_test (1 packages loaded, 10 targets configured).
INFO: Found 1 test target...
Target //packages/angular_devkit/core:core_test up-to-date:
  dist/bin/packages/angular_devkit/core/core_test.sh
  dist/bin/packages/angular_devkit/core/core_test_loader.js
  dist/bin/packages/angular_devkit/core/core_test_require_patch.js
INFO: Elapsed time: 0.327s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
PASSED: //packages/angular_devkit/core:core_test (see /private/var/tmp/_bazel_alanagius/5168427e57f204ca069c602aa7ed1931/execroot/angular_cli/bazel-out/darwin-fastbuild/testlogs/packages/angular_devkit/core/core_test/test.log)
INFO: From Testing //packages/angular_devkit/core:core_test
==================== Test output for //packages/angular_devkit/core:core_test:
(node:12829) UnhandledPromiseRejectionWarning: Error: Cannot find module '/private/var/tmp/_bazel_alanagius/5168427e57f204ca069c602aa7ed1931/execroot/angular_cli/node_modules/@angular-devkit/core/src/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:303:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:516:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (packages/angular_devkit/core/src/virtual-fs/host/memory_spec.ts:10:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Loader.requireShim [as require_] (node_modules/jasmine/lib/loader.js:35:3)
    at node_modules/jasmine/lib/loader.js:28:12
    at new Promise (<anonymous>)
    at Loader.load (node_modules/jasmine/lib/loader.js:27:12)
    at Jasmine.loadSpecs (node_modules/jasmine/lib/jasmine.js:91:23)
    at Jasmine.execute (node_modules/jasmine/lib/jasmine.js:267:3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12829) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:12829) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
================================================================================
Test cases: finished with 1 passing and 0 failing out of 1 test cases

Executed 0 out of 1 test: 1 test passes.
```
2021-05-31 12:48:18 +01:00
Alan Agius
43926a21ba fix(@angular-devkit/build-angular): compile schema in synchronously
AJV only support a single schema with the same ID, compiling schemas async can cause a race condition were multiple schemas with the same name as compiled at the same time.

Closes #20847
2021-05-19 16:34:55 +02: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
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
09676c90a9 fix(@angular-devkit/core): improve handling of set schema values
Closes #20594
2021-04-23 07:22:47 +02:00
Alan Agius
08753138d3 feat(@angular-devkit/core): update schema validator
With this change we update ajv to version 8

BREAKING CHANGE: support for JSON Schema draft-04 and draft-06 is removed. If you have schemas using the `id` keyword replace them with `$id`. For an interim period we will auto rename any top level `id` keyword to `$id`.

**NB**: This change only effects schematics and builders authors.
2021-04-13 10:51:12 -04:00
Alan Agius
79856644b4 feat(@angular/cli): support TypeScript 4.2
BREAKING CHANGE

Drop support for TypeScript versions prior to 4.2.3
2021-03-17 19:32:01 +01:00
Alan Agius
8e981d0880 feat(@angular-devkit/core): add handling for defaultConfiguration target definition property 2021-03-08 08:45:54 -06:00
Charles Lyding
c2b7260f79 refactor(@angular-devkit/core): deprecate unused utility functions
The `clean` and `mapObject` utility functions are unused by the Angular CLI.
2021-03-03 09:18:40 -05:00
Charles Lyding
5ba886cbb5 refactor(@angular-devkit/core): convert json schema registry to use async/await 2021-02-04 08:43:15 +01:00
Charles Lyding
5fc18efa6f test(@angular-devkit/core): allow asynchronous jobs to start execution before expect 2021-02-04 08:43:15 +01:00
Charles Lyding
3bb3c6cd51 fix(@angular-devkit/core): ensure job input values are processed in order
If schema validation happens to be asynchronous then the switchMap could cause loss of input values.
2021-02-04 08:43:15 +01:00
Alan Agius
f766fc1617 refactor(@angular-devkit/core): deprecate flatten schema method.
The flatten schema method has been deprecated without replacement.

Producing a flatten schema document does not in all cases produce a schema with identical behavior to the original.

See: https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.B.2
2021-01-25 09:17:45 -06:00
Charles Lyding
d62441f183 feat(@angular-devkit/core): provide prompt validation errors to provider
This change provides the first schema validation error to a prompt provider when using a prompt definition's `validate` function.  This allows a prompt provider to show additional context to a user when an entered value is invalid.
2021-01-14 15:37:41 -05:00
Alan Agius
1f42e071b4 fix(@angular-devkit/core): correctly handle null prototype in deepCopy
Closes #19492
2020-11-30 11:18:13 +01:00
Charles Lyding
8874ef430a refactor(@angular-devkit/core): add generic type to Promise constructors
This is in preparation to support TypeScript 4.1.  Within TypeScript 4.1 constructed Promises must specify the resolved type.
2020-11-05 08:31:35 +01:00