@angular/cli 14.0.0-next.7 → 14.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/config/schema.json +18 -0
  2. package/lib/config/workspace-schema.d.ts +12 -0
  3. package/package.json +17 -17
  4. package/src/analytics/analytics.d.ts +1 -1
  5. package/src/analytics/analytics.js +22 -20
  6. package/src/command-builder/architect-base-command-module.d.ts +9 -2
  7. package/src/command-builder/architect-base-command-module.js +65 -3
  8. package/src/command-builder/architect-command-module.d.ts +4 -1
  9. package/src/command-builder/architect-command-module.js +37 -11
  10. package/src/command-builder/command-module.d.ts +1 -1
  11. package/src/command-builder/command-module.js +21 -7
  12. package/src/command-builder/command-runner.js +41 -30
  13. package/src/command-builder/schematics-command-module.d.ts +0 -3
  14. package/src/command-builder/schematics-command-module.js +21 -23
  15. package/src/command-builder/utilities/command.d.ts +1 -1
  16. package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
  17. package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
  18. package/src/command-builder/utilities/schematic-engine-host.d.ts +2 -2
  19. package/src/command-builder/utilities/schematic-engine-host.js +33 -18
  20. package/src/commands/analytics/settings/cli.js +2 -2
  21. package/src/commands/cache/settings/cli.d.ts +2 -2
  22. package/src/commands/cache/settings/cli.js +2 -2
  23. package/src/commands/cache/utilities.d.ts +1 -1
  24. package/src/commands/cache/utilities.js +7 -8
  25. package/src/commands/completion/cli.d.ts +16 -0
  26. package/src/commands/completion/cli.js +61 -0
  27. package/src/commands/completion/long-description.md +5 -0
  28. package/src/commands/config/cli.js +15 -14
  29. package/src/commands/deploy/cli.d.ts +2 -1
  30. package/src/commands/deploy/cli.js +27 -13
  31. package/src/commands/e2e/cli.d.ts +2 -1
  32. package/src/commands/e2e/cli.js +14 -13
  33. package/src/commands/lint/cli.d.ts +2 -1
  34. package/src/commands/lint/cli.js +6 -9
  35. package/src/commands/new/cli.js +7 -2
  36. package/src/commands/run/cli.d.ts +2 -0
  37. package/src/commands/run/cli.js +24 -0
  38. package/src/commands/update/cli.js +3 -2
  39. package/src/utilities/completion.d.ts +22 -0
  40. package/src/utilities/completion.js +219 -0
  41. package/src/utilities/config.d.ts +4 -3
  42. package/src/utilities/config.js +11 -5
  43. package/src/utilities/environment-options.d.ts +1 -0
  44. package/src/utilities/environment-options.js +8 -1
  45. package/src/utilities/json-file.js +1 -0
  46. package/src/utilities/memoize.d.ts +15 -0
  47. package/src/utilities/memoize.js +69 -0
  48. package/src/utilities/package-manager.js +13 -2
  49. package/src/utilities/prompt.d.ts +2 -0
  50. package/src/utilities/prompt.js +18 -1
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ /**
9
+ * A decorator that memoizes methods and getters.
10
+ *
11
+ * **Note**: Be cautious where and how to use this decorator as the size of the cache will grow unbounded.
12
+ *
13
+ * @see https://en.wikipedia.org/wiki/Memoization
14
+ */
15
+ export declare function memoize<T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.memoize = void 0;
11
+ /**
12
+ * A decorator that memoizes methods and getters.
13
+ *
14
+ * **Note**: Be cautious where and how to use this decorator as the size of the cache will grow unbounded.
15
+ *
16
+ * @see https://en.wikipedia.org/wiki/Memoization
17
+ */
18
+ function memoize(target, propertyKey, descriptor) {
19
+ const descriptorPropertyName = descriptor.get ? 'get' : 'value';
20
+ const originalMethod = descriptor[descriptorPropertyName];
21
+ if (typeof originalMethod !== 'function') {
22
+ throw new Error('Memoize decorator can only be used on methods or get accessors.');
23
+ }
24
+ const cache = new Map();
25
+ return {
26
+ ...descriptor,
27
+ [descriptorPropertyName]: function (...args) {
28
+ for (const arg of args) {
29
+ if (!isJSONSerializable(arg)) {
30
+ throw new Error(`Argument ${isNonPrimitive(arg) ? arg.toString() : arg} is JSON serializable.`);
31
+ }
32
+ }
33
+ const key = JSON.stringify(args);
34
+ if (cache.has(key)) {
35
+ return cache.get(key);
36
+ }
37
+ const result = originalMethod.apply(this, args);
38
+ cache.set(key, result);
39
+ return result;
40
+ },
41
+ };
42
+ }
43
+ exports.memoize = memoize;
44
+ /** Method to check if value is a non primitive. */
45
+ function isNonPrimitive(value) {
46
+ return ((value !== null && typeof value === 'object') ||
47
+ typeof value === 'function' ||
48
+ typeof value === 'symbol');
49
+ }
50
+ /** Method to check if the values are JSON serializable */
51
+ function isJSONSerializable(value) {
52
+ if (!isNonPrimitive(value)) {
53
+ // Can be seralized since it's a primitive.
54
+ return true;
55
+ }
56
+ let nestedValues;
57
+ if (Array.isArray(value)) {
58
+ // It's an array, check each item.
59
+ nestedValues = value;
60
+ }
61
+ else if (Object.prototype.toString.call(value) === '[object Object]') {
62
+ // It's a plain object, check each value.
63
+ nestedValues = Object.values(value);
64
+ }
65
+ if (!nestedValues || nestedValues.some((v) => !isJSONSerializable(v))) {
66
+ return false;
67
+ }
68
+ return true;
69
+ }
@@ -6,6 +6,12 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
14
+ };
9
15
  Object.defineProperty(exports, "__esModule", { value: true });
10
16
  exports.PackageManagerUtils = void 0;
11
17
  const core_1 = require("@angular-devkit/core");
@@ -16,6 +22,7 @@ const path_1 = require("path");
16
22
  const semver_1 = require("semver");
17
23
  const workspace_schema_1 = require("../../lib/config/workspace-schema");
18
24
  const config_1 = require("./config");
25
+ const memoize_1 = require("./memoize");
19
26
  const spinner_1 = require("./spinner");
20
27
  class PackageManagerUtils {
21
28
  constructor(context) {
@@ -168,7 +175,6 @@ class PackageManagerUtils {
168
175
  (_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
169
176
  });
170
177
  }
171
- // TODO(alan-agius4): use the memoize decorator when it's merged.
172
178
  getVersion(name) {
173
179
  try {
174
180
  return (0, child_process_1.execSync)(`${name} --version`, {
@@ -186,7 +192,6 @@ class PackageManagerUtils {
186
192
  return undefined;
187
193
  }
188
194
  }
189
- // TODO(alan-agius4): use the memoize decorator when it's merged.
190
195
  getName() {
191
196
  const packageManager = this.getConfiguredPackageManager();
192
197
  if (packageManager) {
@@ -273,4 +278,10 @@ class PackageManagerUtils {
273
278
  return result;
274
279
  }
275
280
  }
281
+ __decorate([
282
+ memoize_1.memoize
283
+ ], PackageManagerUtils.prototype, "getVersion", null);
284
+ __decorate([
285
+ memoize_1.memoize
286
+ ], PackageManagerUtils.prototype, "getName", null);
276
287
  exports.PackageManagerUtils = PackageManagerUtils;
@@ -5,4 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
+ import type { ListChoiceOptions } from 'inquirer';
8
9
  export declare function askConfirmation(message: string, defaultResponse: boolean, noTTYResponse?: boolean): Promise<boolean>;
10
+ export declare function askQuestion(message: string, choices: ListChoiceOptions[], defaultResponseIndex: number, noTTYResponse: null | string): Promise<string | null>;
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
30
30
  return result;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.askConfirmation = void 0;
33
+ exports.askQuestion = exports.askConfirmation = void 0;
34
34
  const tty_1 = require("./tty");
35
35
  async function askConfirmation(message, defaultResponse, noTTYResponse) {
36
36
  if (!(0, tty_1.isTTY)()) {
@@ -48,3 +48,20 @@ async function askConfirmation(message, defaultResponse, noTTYResponse) {
48
48
  return answers['confirmation'];
49
49
  }
50
50
  exports.askConfirmation = askConfirmation;
51
+ async function askQuestion(message, choices, defaultResponseIndex, noTTYResponse) {
52
+ if (!(0, tty_1.isTTY)()) {
53
+ return noTTYResponse;
54
+ }
55
+ const question = {
56
+ type: 'list',
57
+ name: 'answer',
58
+ prefix: '',
59
+ message,
60
+ choices,
61
+ default: defaultResponseIndex,
62
+ };
63
+ const { prompt } = await Promise.resolve().then(() => __importStar(require('inquirer')));
64
+ const answers = await prompt([question]);
65
+ return answers['answer'];
66
+ }
67
+ exports.askQuestion = askQuestion;