@angular/cli 14.0.0-next.4 → 14.0.0-next.7

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 (231) 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 +30 -15
  5. package/lib/config/workspace-schema.d.ts +6 -1
  6. package/lib/init.js +10 -9
  7. package/package.json +18 -20
  8. package/{models → src/analytics}/analytics-collector.d.ts +0 -0
  9. package/{models → src/analytics}/analytics-collector.js +8 -2
  10. package/src/analytics/analytics.d.ts +47 -0
  11. package/src/analytics/analytics.js +304 -0
  12. package/src/command-builder/architect-base-command-module.d.ts +23 -0
  13. package/src/command-builder/architect-base-command-module.js +103 -0
  14. package/src/command-builder/architect-command-module.d.ts +22 -0
  15. package/src/command-builder/architect-command-module.js +108 -0
  16. package/src/command-builder/command-module.d.ts +89 -0
  17. package/src/command-builder/command-module.js +191 -0
  18. package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
  19. package/src/command-builder/command-runner.js +152 -0
  20. package/src/command-builder/schematics-command-module.d.ts +46 -0
  21. package/src/command-builder/schematics-command-module.js +335 -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/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
  29. package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
  30. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  31. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  32. package/src/commands/add/cli.d.ts +33 -0
  33. package/{commands/add-impl.js → src/commands/add/cli.js} +108 -80
  34. package/src/commands/add/long-description.md +7 -0
  35. package/src/commands/analytics/cli.d.ts +16 -0
  36. package/src/commands/analytics/cli.js +35 -0
  37. package/src/commands/analytics/info/cli.d.ts +16 -0
  38. package/src/commands/analytics/info/cli.js +26 -0
  39. package/src/commands/analytics/settings/cli.d.ts +35 -0
  40. package/src/commands/analytics/settings/cli.js +61 -0
  41. package/src/commands/build/cli.d.ts +16 -0
  42. package/src/commands/build/cli.js +23 -0
  43. package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
  44. package/src/commands/cache/clean/cli.d.ts +17 -0
  45. package/src/commands/cache/clean/cli.js +32 -0
  46. package/src/commands/cache/cli.d.ts +17 -0
  47. package/src/commands/cache/cli.js +38 -0
  48. package/src/commands/cache/info/cli.d.ts +20 -0
  49. package/src/commands/cache/info/cli.js +82 -0
  50. package/src/commands/cache/long-description.md +53 -0
  51. package/src/commands/cache/settings/cli.d.ts +27 -0
  52. package/src/commands/cache/settings/cli.js +42 -0
  53. package/src/commands/cache/utilities.d.ts +11 -0
  54. package/src/commands/cache/utilities.js +50 -0
  55. package/src/commands/config/cli.d.ts +24 -0
  56. package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
  57. package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
  58. package/src/commands/deploy/cli.d.ts +16 -0
  59. package/src/commands/deploy/cli.js +35 -0
  60. package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
  61. package/src/commands/doc/cli.d.ts +23 -0
  62. package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
  63. package/src/commands/e2e/cli.d.ts +17 -0
  64. package/src/commands/e2e/cli.js +34 -0
  65. package/src/commands/extract-i18n/cli.d.ts +15 -0
  66. package/src/commands/extract-i18n/cli.js +20 -0
  67. package/src/commands/generate/cli.d.ts +39 -0
  68. package/src/commands/generate/cli.js +145 -0
  69. package/src/commands/lint/cli.d.ts +16 -0
  70. package/src/commands/lint/cli.js +31 -0
  71. package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
  72. package/src/commands/make-this-awesome/cli.d.ts +17 -0
  73. package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
  74. package/src/commands/new/cli.d.ts +27 -0
  75. package/src/commands/new/cli.js +77 -0
  76. package/src/commands/run/cli.d.ts +23 -0
  77. package/src/commands/run/cli.js +59 -0
  78. package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
  79. package/src/commands/serve/cli.d.ts +16 -0
  80. package/src/commands/serve/cli.js +21 -0
  81. package/src/commands/test/cli.d.ts +16 -0
  82. package/src/commands/test/cli.js +23 -0
  83. package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
  84. package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +26 -9
  85. package/{commands/update-impl.js → src/commands/update/cli.js} +362 -316
  86. package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
  87. package/src/commands/update/schematic/index.js +33 -20
  88. package/src/commands/version/cli.d.ts +18 -0
  89. package/{commands/version-impl.js → src/commands/version/cli.js} +56 -74
  90. package/src/typings-bazel.d.ts +14 -0
  91. package/src/typings.d.ts +1 -14
  92. package/{utilities → src/utilities}/color.d.ts +0 -0
  93. package/{utilities → src/utilities}/color.js +5 -1
  94. package/{utilities → src/utilities}/config.d.ts +2 -2
  95. package/{utilities → src/utilities}/config.js +24 -16
  96. package/src/utilities/environment-options.d.ts +12 -0
  97. package/src/utilities/environment-options.js +24 -0
  98. package/{utilities → src/utilities}/find-up.d.ts +0 -0
  99. package/{utilities → src/utilities}/find-up.js +5 -1
  100. package/{utilities → src/utilities}/json-file.d.ts +0 -0
  101. package/{utilities → src/utilities}/json-file.js +0 -0
  102. package/{utilities → src/utilities}/log-file.d.ts +0 -0
  103. package/{utilities → src/utilities}/log-file.js +0 -0
  104. package/src/utilities/package-manager.d.ts +41 -0
  105. package/src/utilities/package-manager.js +276 -0
  106. package/{utilities → src/utilities}/package-metadata.d.ts +15 -37
  107. package/{utilities → src/utilities}/package-metadata.js +15 -27
  108. package/{utilities → src/utilities}/package-tree.d.ts +2 -2
  109. package/{utilities → src/utilities}/package-tree.js +5 -1
  110. package/{utilities → src/utilities}/project.d.ts +0 -0
  111. package/{utilities → src/utilities}/project.js +5 -1
  112. package/{utilities → src/utilities}/prompt.d.ts +0 -0
  113. package/{utilities → src/utilities}/prompt.js +7 -3
  114. package/{utilities → src/utilities}/spinner.d.ts +0 -0
  115. package/{utilities → src/utilities}/spinner.js +0 -0
  116. package/{utilities → src/utilities}/tty.d.ts +0 -0
  117. package/{utilities → src/utilities}/tty.js +0 -0
  118. package/{models → src/utilities}/version.d.ts +2 -1
  119. package/{models → src/utilities}/version.js +6 -6
  120. package/bin/postinstall/analytics-prompt.js +0 -27
  121. package/bin/postinstall/script.js +0 -16
  122. package/commands/add-impl.d.ts +0 -21
  123. package/commands/add.d.ts +0 -42
  124. package/commands/add.js +0 -10
  125. package/commands/add.json +0 -54
  126. package/commands/add.md +0 -10
  127. package/commands/analytics-impl.d.ts +0 -13
  128. package/commands/analytics-impl.js +0 -80
  129. package/commands/analytics-long.md +0 -8
  130. package/commands/analytics.d.ts +0 -46
  131. package/commands/analytics.js +0 -31
  132. package/commands/analytics.json +0 -37
  133. package/commands/build-impl.d.ts +0 -14
  134. package/commands/build-impl.js +0 -21
  135. package/commands/build.d.ts +0 -30
  136. package/commands/build.js +0 -10
  137. package/commands/build.json +0 -16
  138. package/commands/config-impl.d.ts +0 -15
  139. package/commands/config.d.ts +0 -34
  140. package/commands/config.js +0 -10
  141. package/commands/config.json +0 -43
  142. package/commands/definitions.json +0 -66
  143. package/commands/deploy-impl.d.ts +0 -15
  144. package/commands/deploy-impl.js +0 -36
  145. package/commands/deploy.d.ts +0 -30
  146. package/commands/deploy.js +0 -10
  147. package/commands/deploy.json +0 -34
  148. package/commands/doc-impl.d.ts +0 -13
  149. package/commands/doc.d.ts +0 -39
  150. package/commands/doc.js +0 -14
  151. package/commands/doc.json +0 -46
  152. package/commands/e2e-impl.d.ts +0 -16
  153. package/commands/e2e-impl.js +0 -36
  154. package/commands/e2e-long.md +0 -4
  155. package/commands/e2e.d.ts +0 -29
  156. package/commands/e2e.js +0 -10
  157. package/commands/e2e.json +0 -17
  158. package/commands/easter-egg-impl.d.ts +0 -12
  159. package/commands/easter-egg.d.ts +0 -14
  160. package/commands/easter-egg.js +0 -10
  161. package/commands/easter-egg.json +0 -12
  162. package/commands/extract-i18n-impl.d.ts +0 -14
  163. package/commands/extract-i18n-impl.js +0 -21
  164. package/commands/extract-i18n.d.ts +0 -29
  165. package/commands/extract-i18n.js +0 -10
  166. package/commands/extract-i18n.json +0 -15
  167. package/commands/generate-impl.d.ts +0 -18
  168. package/commands/generate-impl.js +0 -89
  169. package/commands/generate.d.ts +0 -37
  170. package/commands/generate.js +0 -10
  171. package/commands/generate.json +0 -31
  172. package/commands/help-impl.d.ts +0 -12
  173. package/commands/help-impl.js +0 -26
  174. package/commands/help-long.md +0 -7
  175. package/commands/help.d.ts +0 -17
  176. package/commands/help.js +0 -10
  177. package/commands/help.json +0 -13
  178. package/commands/lint-impl.d.ts +0 -16
  179. package/commands/lint-impl.js +0 -69
  180. package/commands/lint.d.ts +0 -29
  181. package/commands/lint.js +0 -10
  182. package/commands/lint.json +0 -36
  183. package/commands/new-impl.d.ts +0 -16
  184. package/commands/new-impl.js +0 -37
  185. package/commands/new.d.ts +0 -41
  186. package/commands/new.js +0 -10
  187. package/commands/new.json +0 -34
  188. package/commands/new.md +0 -16
  189. package/commands/run-impl.d.ts +0 -13
  190. package/commands/run-impl.js +0 -22
  191. package/commands/run.d.ts +0 -30
  192. package/commands/run.js +0 -10
  193. package/commands/run.json +0 -36
  194. package/commands/serve-impl.d.ts +0 -15
  195. package/commands/serve-impl.js +0 -24
  196. package/commands/serve.d.ts +0 -29
  197. package/commands/serve.js +0 -10
  198. package/commands/serve.json +0 -17
  199. package/commands/test-impl.d.ts +0 -15
  200. package/commands/test-impl.js +0 -22
  201. package/commands/test.d.ts +0 -29
  202. package/commands/test.js +0 -10
  203. package/commands/test.json +0 -17
  204. package/commands/update.d.ts +0 -61
  205. package/commands/update.js +0 -10
  206. package/commands/update.json +0 -78
  207. package/commands/version-impl.d.ts +0 -17
  208. package/commands/version.d.ts +0 -17
  209. package/commands/version.js +0 -10
  210. package/commands/version.json +0 -13
  211. package/commands.json +0 -20
  212. package/models/analytics.d.ts +0 -58
  213. package/models/analytics.js +0 -358
  214. package/models/architect-command.d.ts +0 -35
  215. package/models/architect-command.js +0 -364
  216. package/models/command-runner.d.ts +0 -24
  217. package/models/command-runner.js +0 -241
  218. package/models/command.d.ts +0 -34
  219. package/models/command.js +0 -143
  220. package/models/interface.d.ts +0 -196
  221. package/models/interface.js +0 -31
  222. package/models/parser.d.ts +0 -39
  223. package/models/parser.js +0 -349
  224. package/models/schematic-command.d.ts +0 -55
  225. package/models/schematic-command.js +0 -485
  226. package/utilities/install-package.d.ts +0 -16
  227. package/utilities/install-package.js +0 -193
  228. package/utilities/json-schema.d.ts +0 -17
  229. package/utilities/package-json.d.ts +0 -249
  230. package/utilities/package-manager.d.ts +0 -13
  231. package/utilities/package-manager.js +0 -106
@@ -1,193 +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
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.runTempPackageBin = exports.installTempPackage = exports.installPackage = exports.installAllPackages = void 0;
11
- const child_process_1 = require("child_process");
12
- const fs_1 = require("fs");
13
- const os_1 = require("os");
14
- const path_1 = require("path");
15
- const workspace_schema_1 = require("../lib/config/workspace-schema");
16
- const spinner_1 = require("./spinner");
17
- async function installAllPackages(packageManager = workspace_schema_1.PackageManager.Npm, extraArgs = [], cwd = process.cwd()) {
18
- const packageManagerArgs = getPackageManagerArguments(packageManager);
19
- const installArgs = [];
20
- if (packageManagerArgs.installAll) {
21
- installArgs.push(packageManagerArgs.installAll);
22
- }
23
- installArgs.push(packageManagerArgs.silent);
24
- const spinner = new spinner_1.Spinner();
25
- spinner.start('Installing packages...');
26
- const bufferedOutput = [];
27
- return new Promise((resolve, reject) => {
28
- var _a, _b;
29
- const childProcess = (0, child_process_1.spawn)(packageManager, [...installArgs, ...extraArgs], {
30
- stdio: 'pipe',
31
- shell: true,
32
- cwd,
33
- }).on('close', (code) => {
34
- if (code === 0) {
35
- spinner.succeed('Packages successfully installed.');
36
- resolve(0);
37
- }
38
- else {
39
- spinner.stop();
40
- bufferedOutput.forEach(({ stream, data }) => stream.write(data));
41
- spinner.fail('Package install failed, see above.');
42
- reject(1);
43
- }
44
- });
45
- (_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
46
- (_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
47
- });
48
- }
49
- exports.installAllPackages = installAllPackages;
50
- async function installPackage(packageName, packageManager = workspace_schema_1.PackageManager.Npm, save = true, extraArgs = [], cwd = process.cwd()) {
51
- const packageManagerArgs = getPackageManagerArguments(packageManager);
52
- const installArgs = [
53
- packageManagerArgs.install,
54
- packageName,
55
- packageManagerArgs.silent,
56
- ];
57
- const spinner = new spinner_1.Spinner();
58
- spinner.start('Installing package...');
59
- if (save === 'devDependencies') {
60
- installArgs.push(packageManagerArgs.saveDev);
61
- }
62
- const bufferedOutput = [];
63
- return new Promise((resolve, reject) => {
64
- var _a, _b;
65
- const childProcess = (0, child_process_1.spawn)(packageManager, [...installArgs, ...extraArgs], {
66
- stdio: 'pipe',
67
- shell: true,
68
- cwd,
69
- }).on('close', (code) => {
70
- if (code === 0) {
71
- spinner.succeed('Package successfully installed.');
72
- resolve(0);
73
- }
74
- else {
75
- spinner.stop();
76
- bufferedOutput.forEach(({ stream, data }) => stream.write(data));
77
- spinner.fail('Package install failed, see above.');
78
- reject(1);
79
- }
80
- });
81
- (_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
82
- (_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
83
- });
84
- }
85
- exports.installPackage = installPackage;
86
- async function installTempPackage(packageName, packageManager = workspace_schema_1.PackageManager.Npm, extraArgs) {
87
- const tempPath = (0, fs_1.mkdtempSync)((0, path_1.join)((0, fs_1.realpathSync)((0, os_1.tmpdir)()), 'angular-cli-packages-'));
88
- // clean up temp directory on process exit
89
- process.on('exit', () => {
90
- try {
91
- (0, fs_1.rmdirSync)(tempPath, { recursive: true, maxRetries: 3 });
92
- }
93
- catch { }
94
- });
95
- // NPM will warn when a `package.json` is not found in the install directory
96
- // Example:
97
- // npm WARN enoent ENOENT: no such file or directory, open '/tmp/.ng-temp-packages-84Qi7y/package.json'
98
- // npm WARN .ng-temp-packages-84Qi7y No description
99
- // npm WARN .ng-temp-packages-84Qi7y No repository field.
100
- // npm WARN .ng-temp-packages-84Qi7y No license field.
101
- // While we can use `npm init -y` we will end up needing to update the 'package.json' anyways
102
- // because of missing fields.
103
- (0, fs_1.writeFileSync)((0, path_1.join)(tempPath, 'package.json'), JSON.stringify({
104
- name: 'temp-cli-install',
105
- description: 'temp-cli-install',
106
- repository: 'temp-cli-install',
107
- license: 'MIT',
108
- }));
109
- // setup prefix/global modules path
110
- const packageManagerArgs = getPackageManagerArguments(packageManager);
111
- const tempNodeModules = (0, path_1.join)(tempPath, 'node_modules');
112
- // Yarn will not append 'node_modules' to the path
113
- const prefixPath = packageManager === workspace_schema_1.PackageManager.Yarn ? tempNodeModules : tempPath;
114
- const installArgs = [
115
- ...(extraArgs || []),
116
- `${packageManagerArgs.prefix}="${prefixPath}"`,
117
- packageManagerArgs.noLockfile,
118
- ];
119
- return {
120
- status: await installPackage(packageName, packageManager, true, installArgs, tempPath),
121
- tempNodeModules,
122
- };
123
- }
124
- exports.installTempPackage = installTempPackage;
125
- async function runTempPackageBin(packageName, packageManager = workspace_schema_1.PackageManager.Npm, args = []) {
126
- const { status: code, tempNodeModules } = await installTempPackage(packageName, packageManager);
127
- if (code !== 0) {
128
- return code;
129
- }
130
- // Remove version/tag etc... from package name
131
- // Ex: @angular/cli@latest -> @angular/cli
132
- const packageNameNoVersion = packageName.substring(0, packageName.lastIndexOf('@'));
133
- const pkgLocation = (0, path_1.join)(tempNodeModules, packageNameNoVersion);
134
- const packageJsonPath = (0, path_1.join)(pkgLocation, 'package.json');
135
- // Get a binary location for this package
136
- let binPath;
137
- if ((0, fs_1.existsSync)(packageJsonPath)) {
138
- const content = (0, fs_1.readFileSync)(packageJsonPath, 'utf-8');
139
- if (content) {
140
- const { bin = {} } = JSON.parse(content);
141
- const binKeys = Object.keys(bin);
142
- if (binKeys.length) {
143
- binPath = (0, path_1.resolve)(pkgLocation, bin[binKeys[0]]);
144
- }
145
- }
146
- }
147
- if (!binPath) {
148
- throw new Error(`Cannot locate bin for temporary package: ${packageNameNoVersion}.`);
149
- }
150
- const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [binPath, ...args], {
151
- stdio: 'inherit',
152
- env: {
153
- ...process.env,
154
- NG_DISABLE_VERSION_CHECK: 'true',
155
- NG_CLI_ANALYTICS: 'false',
156
- },
157
- });
158
- if (status === null && error) {
159
- throw error;
160
- }
161
- return status || 0;
162
- }
163
- exports.runTempPackageBin = runTempPackageBin;
164
- function getPackageManagerArguments(packageManager) {
165
- switch (packageManager) {
166
- case workspace_schema_1.PackageManager.Yarn:
167
- return {
168
- silent: '--silent',
169
- saveDev: '--dev',
170
- install: 'add',
171
- prefix: '--modules-folder',
172
- noLockfile: '--no-lockfile',
173
- };
174
- case workspace_schema_1.PackageManager.Pnpm:
175
- return {
176
- silent: '--silent',
177
- saveDev: '--save-dev',
178
- install: 'add',
179
- installAll: 'install',
180
- prefix: '--prefix',
181
- noLockfile: '--no-lockfile',
182
- };
183
- default:
184
- return {
185
- silent: '--quiet',
186
- saveDev: '--save-dev',
187
- install: 'install',
188
- installAll: 'install',
189
- prefix: '--prefix',
190
- noLockfile: '--no-package-lock',
191
- };
192
- }
193
- }
@@ -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 { BaseException, json } from '@angular-devkit/core';
9
- import { CommandDescription, Option, SubCommandDescription } from '../models/interface';
10
- export declare class CommandJsonPathException extends BaseException {
11
- readonly path: string;
12
- readonly name: string;
13
- constructor(path: string, name: string);
14
- }
15
- export declare function parseJsonSchemaToSubCommandDescription(name: string, jsonPath: string, registry: json.schema.SchemaRegistry, schema: json.JsonObject): Promise<SubCommandDescription>;
16
- export declare function parseJsonSchemaToCommandDescription(name: string, jsonPath: string, registry: json.schema.SchemaRegistry, schema: json.JsonObject): Promise<CommandDescription>;
17
- export declare function parseJsonSchemaToOptions(registry: json.schema.SchemaRegistry, schema: json.JsonObject): Promise<Option[]>;
@@ -1,249 +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
- /**
9
- * This file was automatically generated by json-schema-to-typescript.
10
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
11
- * and run json-schema-to-typescript to regenerate this file.
12
- */
13
- export declare type JsonSchemaForNpmPackageJsonFiles = CoreProperties & JspmDefinition & ({
14
- bundleDependencies?: BundledDependency;
15
- [k: string]: any;
16
- } | {
17
- bundledDependencies?: BundledDependency;
18
- [k: string]: any;
19
- }) & {
20
- [k: string]: any;
21
- };
22
- /**
23
- * A person who has been involved in creating or maintaining this package
24
- */
25
- export declare type Person = {
26
- [k: string]: any;
27
- } | string;
28
- /**
29
- * Run AFTER the package is published
30
- */
31
- export declare type ScriptsPublishAfter = string;
32
- /**
33
- * Run AFTER the package is installed
34
- */
35
- export declare type ScriptsInstallAfter = string;
36
- /**
37
- * Run BEFORE the package is uninstalled
38
- */
39
- export declare type ScriptsUninstallBefore = string;
40
- /**
41
- * Run BEFORE bump the package version
42
- */
43
- export declare type ScriptsVersionBefore = string;
44
- /**
45
- * Run by the 'npm test' command
46
- */
47
- export declare type ScriptsTest = string;
48
- /**
49
- * Run by the 'npm stop' command
50
- */
51
- export declare type ScriptsStop = string;
52
- /**
53
- * Run by the 'npm start' command
54
- */
55
- export declare type ScriptsStart = string;
56
- /**
57
- * Run by the 'npm restart' command. Note: 'npm restart' will run the stop and start scripts if no restart script is provided.
58
- */
59
- export declare type ScriptsRestart = string;
60
- /**
61
- * Array of package names that will be bundled when publishing the package.
62
- */
63
- export declare type BundledDependency = string[];
64
- export interface CoreProperties {
65
- /**
66
- * The name of the package.
67
- */
68
- name?: string;
69
- /**
70
- * Version must be parseable by node-semver, which is bundled with npm as a dependency.
71
- */
72
- version?: string;
73
- /**
74
- * This helps people discover your package, as it's listed in 'npm search'.
75
- */
76
- description?: string;
77
- /**
78
- * This helps people discover your package as it's listed in 'npm search'.
79
- */
80
- keywords?: string[];
81
- /**
82
- * The url to the project homepage.
83
- */
84
- homepage?: string;
85
- /**
86
- * The url to your project's issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
87
- */
88
- bugs?: {
89
- [k: string]: any;
90
- } | string;
91
- /**
92
- * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it.
93
- */
94
- license?: string;
95
- /**
96
- * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it.
97
- */
98
- licenses?: {
99
- type?: string;
100
- url?: string;
101
- [k: string]: any;
102
- }[];
103
- author?: Person;
104
- /**
105
- * A list of people who contributed to this package.
106
- */
107
- contributors?: Person[];
108
- /**
109
- * A list of people who maintains this package.
110
- */
111
- maintainers?: Person[];
112
- /**
113
- * The 'files' field is an array of files to include in your project. If you name a folder in the array, then it will also include the files inside that folder.
114
- */
115
- files?: string[];
116
- /**
117
- * The main field is a module ID that is the primary entry point to your program.
118
- */
119
- main?: string;
120
- bin?: string | {
121
- [k: string]: any;
122
- };
123
- /**
124
- * Specify either a single file or an array of filenames to put in place for the man program to find.
125
- */
126
- man?: string[];
127
- directories?: {
128
- /**
129
- * If you specify a 'bin' directory, then all the files in that folder will be used as the 'bin' hash.
130
- */
131
- bin?: string;
132
- /**
133
- * Put markdown files in here. Eventually, these will be displayed nicely, maybe, someday.
134
- */
135
- doc?: string;
136
- /**
137
- * Put example scripts in here. Someday, it might be exposed in some clever way.
138
- */
139
- example?: string;
140
- /**
141
- * Tell people where the bulk of your library is. Nothing special is done with the lib folder in any way, but it's useful meta info.
142
- */
143
- lib?: string;
144
- /**
145
- * A folder that is full of man pages. Sugar to generate a 'man' array by walking the folder.
146
- */
147
- man?: string;
148
- test?: string;
149
- [k: string]: any;
150
- };
151
- /**
152
- * Specify the place where your code lives. This is helpful for people who want to contribute.
153
- */
154
- repository?: {
155
- [k: string]: any;
156
- } | string;
157
- /**
158
- * The 'scripts' member is an object hash of script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point.
159
- */
160
- scripts?: {
161
- /**
162
- * Run BEFORE the package is published (Also run on local npm install without any arguments)
163
- */
164
- prepublish?: string;
165
- publish?: ScriptsPublishAfter;
166
- postpublish?: ScriptsPublishAfter;
167
- /**
168
- * Run BEFORE the package is installed
169
- */
170
- preinstall?: string;
171
- install?: ScriptsInstallAfter;
172
- postinstall?: ScriptsInstallAfter;
173
- preuninstall?: ScriptsUninstallBefore;
174
- uninstall?: ScriptsUninstallBefore;
175
- /**
176
- * Run AFTER the package is uninstalled
177
- */
178
- postuninstall?: string;
179
- preversion?: ScriptsVersionBefore;
180
- version?: ScriptsVersionBefore;
181
- /**
182
- * Run AFTER bump the package version
183
- */
184
- postversion?: string;
185
- pretest?: ScriptsTest;
186
- test?: ScriptsTest;
187
- posttest?: ScriptsTest;
188
- prestop?: ScriptsStop;
189
- stop?: ScriptsStop;
190
- poststop?: ScriptsStop;
191
- prestart?: ScriptsStart;
192
- start?: ScriptsStart;
193
- poststart?: ScriptsStart;
194
- prerestart?: ScriptsRestart;
195
- restart?: ScriptsRestart;
196
- postrestart?: ScriptsRestart;
197
- [k: string]: string | undefined;
198
- };
199
- /**
200
- * A 'config' hash can be used to set configuration parameters used in package scripts that persist across upgrades.
201
- */
202
- config?: {
203
- [k: string]: any;
204
- };
205
- dependencies?: Dependency;
206
- devDependencies?: Dependency;
207
- optionalDependencies?: Dependency;
208
- peerDependencies?: Dependency;
209
- engines?: {
210
- [k: string]: string;
211
- };
212
- engineStrict?: boolean;
213
- /**
214
- * You can specify which operating systems your module will run on
215
- */
216
- os?: string[];
217
- /**
218
- * If your code only runs on certain cpu architectures, you can specify which ones.
219
- */
220
- cpu?: string[];
221
- /**
222
- * If your package is primarily a command-line application that should be installed globally, then set this value to true to provide a warning if it is installed locally.
223
- */
224
- preferGlobal?: boolean;
225
- /**
226
- * If set to true, then npm will refuse to publish it.
227
- */
228
- private?: boolean;
229
- publishConfig?: {
230
- [k: string]: any;
231
- };
232
- dist?: {
233
- shasum?: string;
234
- tarball?: string;
235
- [k: string]: any;
236
- };
237
- readme?: string;
238
- [k: string]: any;
239
- }
240
- /**
241
- * Dependencies are specified with a simple hash of package name to version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
242
- */
243
- export interface Dependency {
244
- [k: string]: string;
245
- }
246
- export interface JspmDefinition {
247
- jspm?: CoreProperties;
248
- [k: string]: any;
249
- }
@@ -1,13 +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 { PackageManager } from '../lib/config/workspace-schema';
9
- export declare function getPackageManager(root: string): Promise<PackageManager>;
10
- /**
11
- * Checks if the npm version is a supported 7.x version. If not, display a warning.
12
- */
13
- export declare function ensureCompatibleNpm(root: string): Promise<void>;
@@ -1,106 +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
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ensureCompatibleNpm = exports.getPackageManager = void 0;
11
- const child_process_1 = require("child_process");
12
- const fs_1 = require("fs");
13
- const path_1 = require("path");
14
- const semver_1 = require("semver");
15
- const util_1 = require("util");
16
- const workspace_schema_1 = require("../lib/config/workspace-schema");
17
- const config_1 = require("./config");
18
- const exec = (0, util_1.promisify)(child_process_1.exec);
19
- async function supports(name) {
20
- try {
21
- await exec(`${name} --version`);
22
- return true;
23
- }
24
- catch {
25
- return false;
26
- }
27
- }
28
- async function hasLockfile(root, packageManager) {
29
- try {
30
- let lockfileName;
31
- switch (packageManager) {
32
- case workspace_schema_1.PackageManager.Yarn:
33
- lockfileName = 'yarn.lock';
34
- break;
35
- case workspace_schema_1.PackageManager.Pnpm:
36
- lockfileName = 'pnpm-lock.yaml';
37
- break;
38
- case workspace_schema_1.PackageManager.Npm:
39
- default:
40
- lockfileName = 'package-lock.json';
41
- break;
42
- }
43
- await fs_1.promises.access((0, path_1.join)(root, lockfileName), fs_1.constants.F_OK);
44
- return true;
45
- }
46
- catch {
47
- return false;
48
- }
49
- }
50
- async function getPackageManager(root) {
51
- const packageManager = await (0, config_1.getConfiguredPackageManager)();
52
- if (packageManager) {
53
- return packageManager;
54
- }
55
- const [hasYarnLock, hasNpmLock, hasPnpmLock] = await Promise.all([
56
- hasLockfile(root, workspace_schema_1.PackageManager.Yarn),
57
- hasLockfile(root, workspace_schema_1.PackageManager.Npm),
58
- hasLockfile(root, workspace_schema_1.PackageManager.Pnpm),
59
- ]);
60
- const hasYarn = await supports(workspace_schema_1.PackageManager.Yarn);
61
- if (hasYarn && hasYarnLock && !hasNpmLock) {
62
- return workspace_schema_1.PackageManager.Yarn;
63
- }
64
- const hasPnpm = await supports(workspace_schema_1.PackageManager.Pnpm);
65
- if (hasPnpm && hasPnpmLock && !hasNpmLock) {
66
- return workspace_schema_1.PackageManager.Pnpm;
67
- }
68
- const hasNpm = await supports(workspace_schema_1.PackageManager.Npm);
69
- if (hasNpm && hasNpmLock && !hasYarnLock && !hasPnpmLock) {
70
- return workspace_schema_1.PackageManager.Npm;
71
- }
72
- if (hasYarn && !hasNpm && !hasPnpm) {
73
- return workspace_schema_1.PackageManager.Yarn;
74
- }
75
- if (hasPnpm && !hasYarn && !hasNpm) {
76
- return workspace_schema_1.PackageManager.Pnpm;
77
- }
78
- // TODO: This should eventually inform the user of ambiguous package manager usage.
79
- // Potentially with a prompt to choose and optionally set as the default.
80
- return workspace_schema_1.PackageManager.Npm;
81
- }
82
- exports.getPackageManager = getPackageManager;
83
- /**
84
- * Checks if the npm version is a supported 7.x version. If not, display a warning.
85
- */
86
- async function ensureCompatibleNpm(root) {
87
- if ((await getPackageManager(root)) !== workspace_schema_1.PackageManager.Npm) {
88
- return;
89
- }
90
- try {
91
- const versionText = (0, child_process_1.execSync)('npm --version', { encoding: 'utf8', stdio: 'pipe' }).trim();
92
- const version = (0, semver_1.valid)(versionText);
93
- if (!version) {
94
- return;
95
- }
96
- if ((0, semver_1.satisfies)(version, '>=7 <7.5.6')) {
97
- // eslint-disable-next-line no-console
98
- console.warn(`npm version ${version} detected.` +
99
- ' When using npm 7 with the Angular CLI, npm version 7.5.6 or higher is recommended.');
100
- }
101
- }
102
- catch {
103
- // npm is not installed
104
- }
105
- }
106
- exports.ensureCompatibleNpm = ensureCompatibleNpm;