@angular/cli 13.3.3 → 14.0.0-next.10

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 (240) hide show
  1. package/bin/ng.js +3 -5
  2. package/lib/cli/index.d.ts +1 -2
  3. package/lib/cli/index.js +16 -45
  4. package/lib/config/schema.json +136 -77
  5. package/lib/config/workspace-schema.d.ts +5 -0
  6. package/lib/init.js +5 -8
  7. package/package.json +21 -23
  8. package/{models → src/analytics}/analytics-collector.d.ts +0 -0
  9. package/{models → src/analytics}/analytics-collector.js +1 -1
  10. package/src/analytics/analytics.d.ts +47 -0
  11. package/src/analytics/analytics.js +306 -0
  12. package/src/command-builder/architect-base-command-module.d.ts +30 -0
  13. package/src/command-builder/architect-base-command-module.js +165 -0
  14. package/src/command-builder/architect-command-module.d.ts +25 -0
  15. package/src/command-builder/architect-command-module.js +134 -0
  16. package/src/command-builder/command-module.d.ts +89 -0
  17. package/src/command-builder/command-module.js +198 -0
  18. package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
  19. package/src/command-builder/command-runner.js +168 -0
  20. package/src/command-builder/schematics-command-module.d.ts +43 -0
  21. package/src/command-builder/schematics-command-module.js +333 -0
  22. package/src/command-builder/utilities/command.d.ts +13 -0
  23. package/src/command-builder/utilities/command.js +27 -0
  24. package/src/command-builder/utilities/json-help.d.ts +36 -0
  25. package/src/command-builder/utilities/json-help.js +94 -0
  26. package/src/command-builder/utilities/json-schema.d.ts +40 -0
  27. package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
  28. package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
  29. package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
  30. package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +2 -2
  31. package/{models → src/command-builder/utilities}/schematic-engine-host.js +30 -17
  32. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  33. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  34. package/src/commands/add/cli.d.ts +33 -0
  35. package/{commands/add-impl.js → src/commands/add/cli.js} +108 -80
  36. package/src/commands/add/long-description.md +7 -0
  37. package/src/commands/analytics/cli.d.ts +16 -0
  38. package/src/commands/analytics/cli.js +35 -0
  39. package/src/commands/analytics/info/cli.d.ts +16 -0
  40. package/src/commands/analytics/info/cli.js +26 -0
  41. package/src/commands/analytics/settings/cli.d.ts +35 -0
  42. package/src/commands/analytics/settings/cli.js +61 -0
  43. package/src/commands/build/cli.d.ts +16 -0
  44. package/src/commands/build/cli.js +23 -0
  45. package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
  46. package/src/commands/cache/clean/cli.d.ts +17 -0
  47. package/src/commands/cache/clean/cli.js +32 -0
  48. package/src/commands/cache/cli.d.ts +17 -0
  49. package/src/commands/cache/cli.js +38 -0
  50. package/src/commands/cache/info/cli.d.ts +20 -0
  51. package/src/commands/cache/info/cli.js +82 -0
  52. package/src/commands/cache/long-description.md +53 -0
  53. package/src/commands/cache/settings/cli.d.ts +27 -0
  54. package/src/commands/cache/settings/cli.js +42 -0
  55. package/src/commands/cache/utilities.d.ts +11 -0
  56. package/src/commands/cache/utilities.js +49 -0
  57. package/src/commands/completion/cli.d.ts +16 -0
  58. package/src/commands/completion/cli.js +31 -0
  59. package/src/commands/completion/long-description.md +1 -0
  60. package/src/commands/config/cli.d.ts +24 -0
  61. package/src/commands/config/cli.js +168 -0
  62. package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
  63. package/src/commands/deploy/cli.d.ts +17 -0
  64. package/src/commands/deploy/cli.js +49 -0
  65. package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
  66. package/src/commands/doc/cli.d.ts +23 -0
  67. package/{commands/doc-impl.js → src/commands/doc/cli.js} +36 -11
  68. package/src/commands/e2e/cli.d.ts +18 -0
  69. package/src/commands/e2e/cli.js +35 -0
  70. package/src/commands/extract-i18n/cli.d.ts +15 -0
  71. package/src/commands/extract-i18n/cli.js +20 -0
  72. package/src/commands/generate/cli.d.ts +39 -0
  73. package/src/commands/generate/cli.js +145 -0
  74. package/src/commands/lint/cli.d.ts +17 -0
  75. package/src/commands/lint/cli.js +28 -0
  76. package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
  77. package/src/commands/make-this-awesome/cli.d.ts +17 -0
  78. package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
  79. package/src/commands/new/cli.d.ts +27 -0
  80. package/src/commands/new/cli.js +82 -0
  81. package/src/commands/run/cli.d.ts +25 -0
  82. package/src/commands/run/cli.js +83 -0
  83. package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
  84. package/src/commands/serve/cli.d.ts +16 -0
  85. package/src/commands/serve/cli.js +21 -0
  86. package/src/commands/test/cli.d.ts +16 -0
  87. package/src/commands/test/cli.js +23 -0
  88. package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
  89. package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +26 -9
  90. package/{commands/update-impl.js → src/commands/update/cli.js} +357 -325
  91. package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
  92. package/src/commands/update/schematic/index.js +29 -22
  93. package/src/commands/version/cli.d.ts +18 -0
  94. package/{commands/version-impl.js → src/commands/version/cli.js} +56 -74
  95. package/src/typings-bazel.d.ts +14 -0
  96. package/src/typings.d.ts +1 -14
  97. package/{utilities → src/utilities}/color.d.ts +0 -0
  98. package/{utilities → src/utilities}/color.js +0 -0
  99. package/{utilities → src/utilities}/config.d.ts +7 -6
  100. package/{utilities → src/utilities}/config.js +34 -92
  101. package/src/utilities/environment-options.d.ts +12 -0
  102. package/src/utilities/environment-options.js +24 -0
  103. package/{utilities → src/utilities}/find-up.d.ts +0 -0
  104. package/{utilities → src/utilities}/find-up.js +0 -0
  105. package/{utilities → src/utilities}/json-file.d.ts +0 -0
  106. package/{utilities → src/utilities}/json-file.js +1 -0
  107. package/{utilities → src/utilities}/log-file.d.ts +0 -0
  108. package/{utilities → src/utilities}/log-file.js +0 -0
  109. package/src/utilities/memoize.d.ts +15 -0
  110. package/src/utilities/memoize.js +69 -0
  111. package/src/utilities/package-manager.d.ts +41 -0
  112. package/src/utilities/package-manager.js +287 -0
  113. package/{utilities → src/utilities}/package-metadata.d.ts +15 -37
  114. package/{utilities → src/utilities}/package-metadata.js +10 -26
  115. package/{utilities → src/utilities}/package-tree.d.ts +2 -2
  116. package/{utilities → src/utilities}/package-tree.js +0 -0
  117. package/{utilities → src/utilities}/project.d.ts +0 -0
  118. package/{utilities → src/utilities}/project.js +1 -6
  119. package/{utilities → src/utilities}/prompt.d.ts +2 -0
  120. package/{utilities → src/utilities}/prompt.js +20 -3
  121. package/{utilities → src/utilities}/spinner.d.ts +0 -0
  122. package/{utilities → src/utilities}/spinner.js +0 -0
  123. package/{utilities → src/utilities}/tty.d.ts +0 -0
  124. package/{utilities → src/utilities}/tty.js +0 -0
  125. package/{models → src/utilities}/version.d.ts +2 -1
  126. package/{models → src/utilities}/version.js +6 -6
  127. package/bin/postinstall/analytics-prompt.js +0 -27
  128. package/bin/postinstall/script.js +0 -16
  129. package/commands/add-impl.d.ts +0 -21
  130. package/commands/add.d.ts +0 -42
  131. package/commands/add.js +0 -10
  132. package/commands/add.json +0 -54
  133. package/commands/add.md +0 -10
  134. package/commands/analytics-impl.d.ts +0 -13
  135. package/commands/analytics-impl.js +0 -80
  136. package/commands/analytics-long.md +0 -8
  137. package/commands/analytics.d.ts +0 -46
  138. package/commands/analytics.js +0 -31
  139. package/commands/analytics.json +0 -37
  140. package/commands/build-impl.d.ts +0 -14
  141. package/commands/build-impl.js +0 -21
  142. package/commands/build.d.ts +0 -38
  143. package/commands/build.js +0 -10
  144. package/commands/build.json +0 -16
  145. package/commands/config-impl.d.ts +0 -15
  146. package/commands/config-impl.js +0 -167
  147. package/commands/config.d.ts +0 -34
  148. package/commands/config.js +0 -10
  149. package/commands/config.json +0 -43
  150. package/commands/definitions.json +0 -71
  151. package/commands/deploy-impl.d.ts +0 -15
  152. package/commands/deploy-impl.js +0 -36
  153. package/commands/deploy.d.ts +0 -30
  154. package/commands/deploy.js +0 -10
  155. package/commands/deploy.json +0 -34
  156. package/commands/doc-impl.d.ts +0 -13
  157. package/commands/doc.d.ts +0 -39
  158. package/commands/doc.js +0 -14
  159. package/commands/doc.json +0 -46
  160. package/commands/e2e-impl.d.ts +0 -16
  161. package/commands/e2e-impl.js +0 -36
  162. package/commands/e2e-long.md +0 -4
  163. package/commands/e2e.d.ts +0 -37
  164. package/commands/e2e.js +0 -10
  165. package/commands/e2e.json +0 -17
  166. package/commands/easter-egg-impl.d.ts +0 -12
  167. package/commands/easter-egg.d.ts +0 -14
  168. package/commands/easter-egg.js +0 -10
  169. package/commands/easter-egg.json +0 -12
  170. package/commands/extract-i18n-impl.d.ts +0 -14
  171. package/commands/extract-i18n-impl.js +0 -32
  172. package/commands/extract-i18n.d.ts +0 -37
  173. package/commands/extract-i18n.js +0 -10
  174. package/commands/extract-i18n.json +0 -17
  175. package/commands/generate-impl.d.ts +0 -18
  176. package/commands/generate-impl.js +0 -89
  177. package/commands/generate.d.ts +0 -37
  178. package/commands/generate.js +0 -10
  179. package/commands/generate.json +0 -31
  180. package/commands/help-impl.d.ts +0 -12
  181. package/commands/help-impl.js +0 -26
  182. package/commands/help-long.md +0 -7
  183. package/commands/help.d.ts +0 -17
  184. package/commands/help.js +0 -10
  185. package/commands/help.json +0 -13
  186. package/commands/lint-impl.d.ts +0 -16
  187. package/commands/lint-impl.js +0 -74
  188. package/commands/lint.d.ts +0 -29
  189. package/commands/lint.js +0 -10
  190. package/commands/lint.json +0 -36
  191. package/commands/new-impl.d.ts +0 -16
  192. package/commands/new-impl.js +0 -37
  193. package/commands/new.d.ts +0 -41
  194. package/commands/new.js +0 -10
  195. package/commands/new.json +0 -34
  196. package/commands/new.md +0 -16
  197. package/commands/run-impl.d.ts +0 -13
  198. package/commands/run-impl.js +0 -22
  199. package/commands/run.d.ts +0 -30
  200. package/commands/run.js +0 -10
  201. package/commands/run.json +0 -36
  202. package/commands/serve-impl.d.ts +0 -15
  203. package/commands/serve-impl.js +0 -24
  204. package/commands/serve.d.ts +0 -37
  205. package/commands/serve.js +0 -10
  206. package/commands/serve.json +0 -17
  207. package/commands/test-impl.d.ts +0 -15
  208. package/commands/test-impl.js +0 -22
  209. package/commands/test.d.ts +0 -37
  210. package/commands/test.js +0 -10
  211. package/commands/test.json +0 -17
  212. package/commands/update.d.ts +0 -65
  213. package/commands/update.js +0 -10
  214. package/commands/update.json +0 -84
  215. package/commands/version-impl.d.ts +0 -17
  216. package/commands/version.d.ts +0 -17
  217. package/commands/version.js +0 -10
  218. package/commands/version.json +0 -13
  219. package/commands.json +0 -20
  220. package/models/analytics.d.ts +0 -58
  221. package/models/analytics.js +0 -362
  222. package/models/architect-command.d.ts +0 -35
  223. package/models/architect-command.js +0 -392
  224. package/models/command-runner.d.ts +0 -24
  225. package/models/command-runner.js +0 -245
  226. package/models/command.d.ts +0 -34
  227. package/models/command.js +0 -143
  228. package/models/interface.d.ts +0 -196
  229. package/models/interface.js +0 -31
  230. package/models/parser.d.ts +0 -39
  231. package/models/parser.js +0 -349
  232. package/models/schematic-command.d.ts +0 -55
  233. package/models/schematic-command.js +0 -489
  234. package/utilities/INITIAL_COMMIT_MESSAGE.txt +0 -8
  235. package/utilities/install-package.d.ts +0 -16
  236. package/utilities/install-package.js +0 -193
  237. package/utilities/json-schema.d.ts +0 -17
  238. package/utilities/package-json.d.ts +0 -249
  239. package/utilities/package-manager.d.ts +0 -15
  240. package/utilities/package-manager.js +0 -83
@@ -1,17 +0,0 @@
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
- import { Command } from '../models/command';
9
- import { Schema as VersionCommandSchema } from './version';
10
- export declare class VersionCommand extends Command<VersionCommandSchema> {
11
- static aliases: string[];
12
- private readonly localRequire;
13
- private readonly workspaceRequire;
14
- run(): Promise<void>;
15
- private getVersion;
16
- private getPackageManager;
17
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Outputs Angular CLI version.
3
- */
4
- export interface Schema {
5
- /**
6
- * Shows a help message for this command in the console.
7
- */
8
- help?: HelpUnion;
9
- }
10
- /**
11
- * Shows a help message for this command in the console.
12
- */
13
- export declare type HelpUnion = boolean | HelpEnum;
14
- export declare enum HelpEnum {
15
- HelpJson = "JSON",
16
- Json = "json"
17
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
3
- // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.HelpEnum = void 0;
6
- var HelpEnum;
7
- (function (HelpEnum) {
8
- HelpEnum["HelpJson"] = "JSON";
9
- HelpEnum["Json"] = "json";
10
- })(HelpEnum = exports.HelpEnum || (exports.HelpEnum = {}));
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "ng-cli://commands/version.json",
4
- "description": "Outputs Angular CLI version.",
5
- "$longDescription": "",
6
-
7
- "$aliases": ["v"],
8
- "$scope": "all",
9
- "$impl": "./version-impl#VersionCommand",
10
-
11
- "type": "object",
12
- "allOf": [{ "$ref": "./definitions.json#/definitions/base" }]
13
- }
package/commands.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "add": "./commands/add.json",
3
- "analytics": "./commands/analytics.json",
4
- "build": "./commands/build.json",
5
- "config": "./commands/config.json",
6
- "deploy": "./commands/deploy.json",
7
- "doc": "./commands/doc.json",
8
- "e2e": "./commands/e2e.json",
9
- "extract-i18n": "./commands/extract-i18n.json",
10
- "make-this-awesome": "./commands/easter-egg.json",
11
- "generate": "./commands/generate.json",
12
- "help": "./commands/help.json",
13
- "lint": "./commands/lint.json",
14
- "new": "./commands/new.json",
15
- "run": "./commands/run.json",
16
- "serve": "./commands/serve.json",
17
- "test": "./commands/test.json",
18
- "update": "./commands/update.json",
19
- "version": "./commands/version.json"
20
- }
@@ -1,58 +0,0 @@
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
- import { AnalyticsCollector } from './analytics-collector';
9
- export declare const AnalyticsProperties: {
10
- AngularCliProd: string;
11
- AngularCliStaging: string;
12
- readonly AngularCliDefault: string;
13
- };
14
- /**
15
- * This is the ultimate safelist for checking if a package name is safe to report to analytics.
16
- */
17
- export declare const analyticsPackageSafelist: (string | RegExp)[];
18
- export declare function isPackageNameSafeForAnalytics(name: string): boolean;
19
- /**
20
- * Set analytics settings. This does not work if the user is not inside a project.
21
- * @param level Which config to use. "global" for user-level, and "local" for project-level.
22
- * @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
23
- */
24
- export declare function setAnalyticsConfig(level: 'global' | 'local', value: string | boolean): void;
25
- /**
26
- * Prompt the user for usage gathering permission.
27
- * @param force Whether to ask regardless of whether or not the user is using an interactive shell.
28
- * @return Whether or not the user was shown a prompt.
29
- */
30
- export declare function promptGlobalAnalytics(force?: boolean): Promise<boolean>;
31
- /**
32
- * Prompt the user for usage gathering permission for the local project. Fails if there is no
33
- * local workspace.
34
- * @param force Whether to ask regardless of whether or not the user is using an interactive shell.
35
- * @return Whether or not the user was shown a prompt.
36
- */
37
- export declare function promptProjectAnalytics(force?: boolean): Promise<boolean>;
38
- export declare function hasGlobalAnalyticsConfiguration(): Promise<boolean>;
39
- /**
40
- * Get the global analytics object for the user. This returns an instance of UniversalAnalytics,
41
- * or undefined if analytics are disabled.
42
- *
43
- * If any problem happens, it is considered the user has been opting out of analytics.
44
- */
45
- export declare function getGlobalAnalytics(): Promise<AnalyticsCollector | undefined>;
46
- export declare function hasWorkspaceAnalyticsConfiguration(): Promise<boolean>;
47
- /**
48
- * Get the workspace analytics object for the user. This returns an instance of AnalyticsCollector,
49
- * or undefined if analytics are disabled.
50
- *
51
- * If any problem happens, it is considered the user has been opting out of analytics.
52
- */
53
- export declare function getWorkspaceAnalytics(): Promise<AnalyticsCollector | undefined>;
54
- /**
55
- * Return the usage analytics sharing setting, which is either a property string (GA-XXXXXXX-XX),
56
- * or undefined if no sharing.
57
- */
58
- export declare function getSharedAnalytics(): Promise<AnalyticsCollector | undefined>;
@@ -1,362 +0,0 @@
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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getSharedAnalytics = exports.getWorkspaceAnalytics = exports.hasWorkspaceAnalyticsConfiguration = exports.getGlobalAnalytics = exports.hasGlobalAnalyticsConfiguration = exports.promptProjectAnalytics = exports.promptGlobalAnalytics = exports.setAnalyticsConfig = exports.isPackageNameSafeForAnalytics = exports.analyticsPackageSafelist = exports.AnalyticsProperties = void 0;
37
- const core_1 = require("@angular-devkit/core");
38
- const debug_1 = __importDefault(require("debug"));
39
- const inquirer = __importStar(require("inquirer"));
40
- const uuid_1 = require("uuid");
41
- const version_1 = require("../models/version");
42
- const color_1 = require("../utilities/color");
43
- const config_1 = require("../utilities/config");
44
- const tty_1 = require("../utilities/tty");
45
- const analytics_collector_1 = require("./analytics-collector");
46
- /* eslint-disable no-console */
47
- const analyticsDebug = (0, debug_1.default)('ng:analytics'); // Generate analytics, including settings and users.
48
- let _defaultAngularCliPropertyCache;
49
- exports.AnalyticsProperties = {
50
- AngularCliProd: 'UA-8594346-29',
51
- AngularCliStaging: 'UA-8594346-32',
52
- get AngularCliDefault() {
53
- if (_defaultAngularCliPropertyCache) {
54
- return _defaultAngularCliPropertyCache;
55
- }
56
- const v = version_1.VERSION.full;
57
- // The logic is if it's a full version then we should use the prod GA property.
58
- if (/^\d+\.\d+\.\d+$/.test(v) && v !== '0.0.0') {
59
- _defaultAngularCliPropertyCache = exports.AnalyticsProperties.AngularCliProd;
60
- }
61
- else {
62
- _defaultAngularCliPropertyCache = exports.AnalyticsProperties.AngularCliStaging;
63
- }
64
- return _defaultAngularCliPropertyCache;
65
- },
66
- };
67
- /**
68
- * This is the ultimate safelist for checking if a package name is safe to report to analytics.
69
- */
70
- exports.analyticsPackageSafelist = [
71
- /^@angular\//,
72
- /^@angular-devkit\//,
73
- /^@ngtools\//,
74
- '@schematics/angular',
75
- ];
76
- function isPackageNameSafeForAnalytics(name) {
77
- return exports.analyticsPackageSafelist.some((pattern) => {
78
- if (typeof pattern == 'string') {
79
- return pattern === name;
80
- }
81
- else {
82
- return pattern.test(name);
83
- }
84
- });
85
- }
86
- exports.isPackageNameSafeForAnalytics = isPackageNameSafeForAnalytics;
87
- /**
88
- * Set analytics settings. This does not work if the user is not inside a project.
89
- * @param level Which config to use. "global" for user-level, and "local" for project-level.
90
- * @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
91
- */
92
- function setAnalyticsConfig(level, value) {
93
- analyticsDebug('setting %s level analytics to: %s', level, value);
94
- const [config, configPath] = (0, config_1.getWorkspaceRaw)(level);
95
- if (!config || !configPath) {
96
- throw new Error(`Could not find ${level} workspace.`);
97
- }
98
- const cli = config.get(['cli']);
99
- if (cli !== undefined && !core_1.json.isJsonObject(cli)) {
100
- throw new Error(`Invalid config found at ${configPath}. CLI should be an object.`);
101
- }
102
- if (value === true) {
103
- value = (0, uuid_1.v4)();
104
- }
105
- config.modify(['cli', 'analytics'], value);
106
- config.save();
107
- analyticsDebug('done');
108
- }
109
- exports.setAnalyticsConfig = setAnalyticsConfig;
110
- /**
111
- * Prompt the user for usage gathering permission.
112
- * @param force Whether to ask regardless of whether or not the user is using an interactive shell.
113
- * @return Whether or not the user was shown a prompt.
114
- */
115
- async function promptGlobalAnalytics(force = false) {
116
- analyticsDebug('prompting global analytics.');
117
- if (force || (0, tty_1.isTTY)()) {
118
- const answers = await inquirer.prompt([
119
- {
120
- type: 'confirm',
121
- name: 'analytics',
122
- message: core_1.tags.stripIndents `
123
- Would you like to share anonymous usage data with the Angular Team at Google under
124
- Google’s Privacy Policy at https://policies.google.com/privacy? For more details and
125
- how to change this setting, see https://angular.io/analytics.
126
- `,
127
- default: false,
128
- },
129
- ]);
130
- setAnalyticsConfig('global', answers.analytics);
131
- if (answers.analytics) {
132
- console.log('');
133
- console.log(core_1.tags.stripIndent `
134
- Thank you for sharing anonymous usage data. If you change your mind, the following
135
- command will disable this feature entirely:
136
-
137
- ${color_1.colors.yellow('ng analytics off')}
138
- `);
139
- console.log('');
140
- // Send back a ping with the user `optin`.
141
- const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optin');
142
- ua.pageview('/telemetry/optin');
143
- await ua.flush();
144
- }
145
- else {
146
- // Send back a ping with the user `optout`. This is the only thing we send.
147
- const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optout');
148
- ua.pageview('/telemetry/optout');
149
- await ua.flush();
150
- }
151
- return true;
152
- }
153
- else {
154
- analyticsDebug('Either STDOUT or STDIN are not TTY and we skipped the prompt.');
155
- }
156
- return false;
157
- }
158
- exports.promptGlobalAnalytics = promptGlobalAnalytics;
159
- /**
160
- * Prompt the user for usage gathering permission for the local project. Fails if there is no
161
- * local workspace.
162
- * @param force Whether to ask regardless of whether or not the user is using an interactive shell.
163
- * @return Whether or not the user was shown a prompt.
164
- */
165
- async function promptProjectAnalytics(force = false) {
166
- analyticsDebug('prompting user');
167
- const [config, configPath] = (0, config_1.getWorkspaceRaw)('local');
168
- if (!config || !configPath) {
169
- throw new Error(`Could not find a local workspace. Are you in a project?`);
170
- }
171
- if (force || (0, tty_1.isTTY)()) {
172
- const answers = await inquirer.prompt([
173
- {
174
- type: 'confirm',
175
- name: 'analytics',
176
- message: core_1.tags.stripIndents `
177
- Would you like to share anonymous usage data about this project with the Angular Team at
178
- Google under Google’s Privacy Policy at https://policies.google.com/privacy? For more
179
- details and how to change this setting, see https://angular.io/analytics.
180
-
181
- `,
182
- default: false,
183
- },
184
- ]);
185
- setAnalyticsConfig('local', answers.analytics);
186
- if (answers.analytics) {
187
- console.log('');
188
- console.log(core_1.tags.stripIndent `
189
- Thank you for sharing anonymous usage data. Should you change your mind, the following
190
- command will disable this feature entirely:
191
-
192
- ${color_1.colors.yellow('ng analytics project off')}
193
- `);
194
- console.log('');
195
- // Send back a ping with the user `optin`.
196
- const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optin');
197
- ua.pageview('/telemetry/project/optin');
198
- await ua.flush();
199
- }
200
- else {
201
- // Send back a ping with the user `optout`. This is the only thing we send.
202
- const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optout');
203
- ua.pageview('/telemetry/project/optout');
204
- await ua.flush();
205
- }
206
- return true;
207
- }
208
- return false;
209
- }
210
- exports.promptProjectAnalytics = promptProjectAnalytics;
211
- async function hasGlobalAnalyticsConfiguration() {
212
- try {
213
- const globalWorkspace = await (0, config_1.getWorkspace)('global');
214
- const analyticsConfig = globalWorkspace && globalWorkspace.getCli() && globalWorkspace.getCli()['analytics'];
215
- if (analyticsConfig !== null && analyticsConfig !== undefined) {
216
- return true;
217
- }
218
- }
219
- catch { }
220
- return false;
221
- }
222
- exports.hasGlobalAnalyticsConfiguration = hasGlobalAnalyticsConfiguration;
223
- /**
224
- * Get the global analytics object for the user. This returns an instance of UniversalAnalytics,
225
- * or undefined if analytics are disabled.
226
- *
227
- * If any problem happens, it is considered the user has been opting out of analytics.
228
- */
229
- async function getGlobalAnalytics() {
230
- analyticsDebug('getGlobalAnalytics');
231
- const propertyId = exports.AnalyticsProperties.AngularCliDefault;
232
- if ('NG_CLI_ANALYTICS' in process.env) {
233
- if (process.env['NG_CLI_ANALYTICS'] == 'false' || process.env['NG_CLI_ANALYTICS'] == '') {
234
- analyticsDebug('NG_CLI_ANALYTICS is false');
235
- return undefined;
236
- }
237
- if (process.env['NG_CLI_ANALYTICS'] === 'ci') {
238
- analyticsDebug('Running in CI mode');
239
- return new analytics_collector_1.AnalyticsCollector(propertyId, 'ci');
240
- }
241
- }
242
- // If anything happens we just keep the NOOP analytics.
243
- try {
244
- const globalWorkspace = await (0, config_1.getWorkspace)('global');
245
- const analyticsConfig = globalWorkspace && globalWorkspace.getCli() && globalWorkspace.getCli()['analytics'];
246
- analyticsDebug('Client Analytics config found: %j', analyticsConfig);
247
- if (analyticsConfig === false) {
248
- analyticsDebug('Analytics disabled. Ignoring all analytics.');
249
- return undefined;
250
- }
251
- else if (analyticsConfig === undefined || analyticsConfig === null) {
252
- analyticsDebug('Analytics settings not found. Ignoring all analytics.');
253
- // globalWorkspace can be null if there is no file. analyticsConfig would be null in this
254
- // case. Since there is no file, the user hasn't answered and the expected return value is
255
- // undefined.
256
- return undefined;
257
- }
258
- else {
259
- let uid = undefined;
260
- if (typeof analyticsConfig == 'string') {
261
- uid = analyticsConfig;
262
- }
263
- else if (typeof analyticsConfig == 'object' && typeof analyticsConfig['uid'] == 'string') {
264
- uid = analyticsConfig['uid'];
265
- }
266
- analyticsDebug('client id: %j', uid);
267
- if (uid == undefined) {
268
- return undefined;
269
- }
270
- return new analytics_collector_1.AnalyticsCollector(propertyId, uid);
271
- }
272
- }
273
- catch (err) {
274
- analyticsDebug('Error happened during reading of analytics config: %s', err.message);
275
- return undefined;
276
- }
277
- }
278
- exports.getGlobalAnalytics = getGlobalAnalytics;
279
- async function hasWorkspaceAnalyticsConfiguration() {
280
- try {
281
- const globalWorkspace = await (0, config_1.getWorkspace)('local');
282
- const analyticsConfig = globalWorkspace && globalWorkspace.getCli() && globalWorkspace.getCli()['analytics'];
283
- if (analyticsConfig !== undefined) {
284
- return true;
285
- }
286
- }
287
- catch { }
288
- return false;
289
- }
290
- exports.hasWorkspaceAnalyticsConfiguration = hasWorkspaceAnalyticsConfiguration;
291
- /**
292
- * Get the workspace analytics object for the user. This returns an instance of AnalyticsCollector,
293
- * or undefined if analytics are disabled.
294
- *
295
- * If any problem happens, it is considered the user has been opting out of analytics.
296
- */
297
- async function getWorkspaceAnalytics() {
298
- analyticsDebug('getWorkspaceAnalytics');
299
- try {
300
- const globalWorkspace = await (0, config_1.getWorkspace)('local');
301
- const analyticsConfig = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()['analytics'];
302
- analyticsDebug('Workspace Analytics config found: %j', analyticsConfig);
303
- if (analyticsConfig === false) {
304
- analyticsDebug('Analytics disabled. Ignoring all analytics.');
305
- return undefined;
306
- }
307
- else if (analyticsConfig === undefined || analyticsConfig === null) {
308
- analyticsDebug('Analytics settings not found. Ignoring all analytics.');
309
- return undefined;
310
- }
311
- else {
312
- let uid = undefined;
313
- if (typeof analyticsConfig == 'string') {
314
- uid = analyticsConfig;
315
- }
316
- else if (typeof analyticsConfig == 'object' && typeof analyticsConfig['uid'] == 'string') {
317
- uid = analyticsConfig['uid'];
318
- }
319
- analyticsDebug('client id: %j', uid);
320
- if (uid == undefined) {
321
- return undefined;
322
- }
323
- return new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, uid);
324
- }
325
- }
326
- catch (err) {
327
- analyticsDebug('Error happened during reading of analytics config: %s', err.message);
328
- return undefined;
329
- }
330
- }
331
- exports.getWorkspaceAnalytics = getWorkspaceAnalytics;
332
- /**
333
- * Return the usage analytics sharing setting, which is either a property string (GA-XXXXXXX-XX),
334
- * or undefined if no sharing.
335
- */
336
- async function getSharedAnalytics() {
337
- analyticsDebug('getSharedAnalytics');
338
- const envVarName = 'NG_CLI_ANALYTICS_SHARE';
339
- if (envVarName in process.env) {
340
- if (process.env[envVarName] == 'false' || process.env[envVarName] == '') {
341
- analyticsDebug('NG_CLI_ANALYTICS is false');
342
- return undefined;
343
- }
344
- }
345
- // If anything happens we just keep the NOOP analytics.
346
- try {
347
- const globalWorkspace = await (0, config_1.getWorkspace)('global');
348
- const analyticsConfig = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()['analyticsSharing'];
349
- if (!analyticsConfig || !analyticsConfig.tracking || !analyticsConfig.uuid) {
350
- return undefined;
351
- }
352
- else {
353
- analyticsDebug('Analytics sharing info: %j', analyticsConfig);
354
- return new analytics_collector_1.AnalyticsCollector(analyticsConfig.tracking, analyticsConfig.uuid);
355
- }
356
- }
357
- catch (err) {
358
- analyticsDebug('Error happened during reading of analytics sharing config: %s', err.message);
359
- return undefined;
360
- }
361
- }
362
- exports.getSharedAnalytics = getSharedAnalytics;
@@ -1,35 +0,0 @@
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
- import { Architect, Target } from '@angular-devkit/architect';
9
- import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
10
- import { json } from '@angular-devkit/core';
11
- import { BaseCommandOptions, Command } from './command';
12
- import { Arguments } from './interface';
13
- export interface ArchitectCommandOptions extends BaseCommandOptions {
14
- project?: string;
15
- configuration?: string;
16
- prod?: boolean;
17
- target?: string;
18
- }
19
- export declare abstract class ArchitectCommand<T extends ArchitectCommandOptions = ArchitectCommandOptions> extends Command<T> {
20
- protected _architect: Architect;
21
- protected _architectHost: WorkspaceNodeModulesArchitectHost;
22
- protected _registry: json.schema.SchemaRegistry;
23
- protected readonly useReportAnalytics = false;
24
- protected multiTarget: boolean;
25
- target: string | undefined;
26
- missingTargetError: string | undefined;
27
- protected onMissingTarget(projectName?: string): Promise<void | number>;
28
- initialize(options: T & Arguments): Promise<number | void>;
29
- private warnOnMissingNodeModules;
30
- run(options: ArchitectCommandOptions & Arguments): Promise<number>;
31
- protected runSingleTarget(target: Target, targetOptions: string[]): Promise<0 | 1>;
32
- protected runArchitectTarget(options: ArchitectCommandOptions & Arguments): Promise<number>;
33
- private getProjectNamesByTarget;
34
- private _makeTargetSpecifier;
35
- }