nx 13.8.8 → 13.9.0-beta.2

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 (100) hide show
  1. package/bin/nx.d.ts +1 -0
  2. package/bin/nx.js +78 -1
  3. package/bin/nx.js.map +1 -1
  4. package/package.json +19 -2
  5. package/src/cli/decorate-cli.d.ts +1 -0
  6. package/src/cli/decorate-cli.js +19 -0
  7. package/src/cli/decorate-cli.js.map +1 -0
  8. package/src/cli/find-workspace-root.d.ts +8 -0
  9. package/src/cli/find-workspace-root.js +25 -0
  10. package/src/cli/find-workspace-root.js.map +1 -0
  11. package/src/cli/index.d.ts +3 -0
  12. package/src/cli/index.js +74 -0
  13. package/src/cli/index.js.map +1 -0
  14. package/src/cli/init-local.d.ts +2 -0
  15. package/src/cli/init-local.js +109 -0
  16. package/src/cli/init-local.js.map +1 -0
  17. package/src/cli/is_ci.d.ts +1 -0
  18. package/src/cli/is_ci.js +20 -0
  19. package/src/cli/is_ci.js.map +1 -0
  20. package/src/cli/output.d.ts +58 -0
  21. package/src/cli/output.js +129 -0
  22. package/src/cli/output.js.map +1 -0
  23. package/src/cli/parse-run-one-options.d.ts +6 -0
  24. package/src/cli/parse-run-one-options.js +139 -0
  25. package/src/cli/parse-run-one-options.js.map +1 -0
  26. package/src/cli/run-cli.d.ts +1 -0
  27. package/src/cli/run-cli.js +69 -0
  28. package/src/cli/run-cli.js.map +1 -0
  29. package/src/cli/workspace.d.ts +4 -0
  30. package/src/cli/workspace.js +3 -0
  31. package/src/cli/workspace.js.map +1 -0
  32. package/src/commands/generate.d.ts +15 -0
  33. package/src/commands/generate.js +170 -0
  34. package/src/commands/generate.js.map +1 -0
  35. package/src/commands/help.d.ts +1 -0
  36. package/src/commands/help.js +34 -0
  37. package/src/commands/help.js.map +1 -0
  38. package/src/commands/migrate.d.ts +77 -0
  39. package/src/commands/migrate.js +584 -0
  40. package/src/commands/migrate.js.map +1 -0
  41. package/src/commands/ngcli-adapter.d.ts +111 -0
  42. package/src/commands/ngcli-adapter.js +940 -0
  43. package/src/commands/ngcli-adapter.js.map +1 -0
  44. package/src/commands/run.d.ts +51 -0
  45. package/src/commands/run.js +224 -0
  46. package/src/commands/run.js.map +1 -0
  47. package/src/compat/compat.d.ts +1 -0
  48. package/src/compat/compat.js +86 -0
  49. package/src/compat/compat.js.map +1 -0
  50. package/src/shared/logger.d.ts +11 -0
  51. package/src/shared/logger.js +48 -0
  52. package/src/shared/logger.js.map +1 -0
  53. package/src/shared/nx-plugin.d.ts +18 -0
  54. package/src/shared/nx-plugin.js +53 -0
  55. package/src/shared/nx-plugin.js.map +1 -0
  56. package/src/shared/nx.d.ts +110 -0
  57. package/src/shared/nx.js +3 -0
  58. package/src/shared/nx.js.map +1 -0
  59. package/src/shared/package-json.d.ts +28 -0
  60. package/src/shared/package-json.js +10 -0
  61. package/src/shared/package-json.js.map +1 -0
  62. package/src/shared/package-manager.d.ts +32 -0
  63. package/src/shared/package-manager.js +83 -0
  64. package/src/shared/package-manager.js.map +1 -0
  65. package/src/shared/params.d.ts +113 -0
  66. package/src/shared/params.js +587 -0
  67. package/src/shared/params.js.map +1 -0
  68. package/src/shared/print-help.d.ts +2 -0
  69. package/src/shared/print-help.js +32 -0
  70. package/src/shared/print-help.js.map +1 -0
  71. package/src/shared/project-graph.d.ts +135 -0
  72. package/src/shared/project-graph.js +22 -0
  73. package/src/shared/project-graph.js.map +1 -0
  74. package/src/shared/tasks.d.ts +82 -0
  75. package/src/shared/tasks.js +3 -0
  76. package/src/shared/tasks.js.map +1 -0
  77. package/src/shared/tree.d.ts +115 -0
  78. package/src/shared/tree.js +259 -0
  79. package/src/shared/tree.js.map +1 -0
  80. package/src/shared/workspace.d.ts +257 -0
  81. package/src/shared/workspace.js +522 -0
  82. package/src/shared/workspace.js.map +1 -0
  83. package/src/utils/app-root.d.ts +2 -0
  84. package/src/utils/app-root.js +30 -0
  85. package/src/utils/app-root.js.map +1 -0
  86. package/src/utils/fileutils.d.ts +31 -0
  87. package/src/utils/fileutils.js +45 -0
  88. package/src/utils/fileutils.js.map +1 -0
  89. package/src/utils/json.d.ts +39 -0
  90. package/src/utils/json.js +48 -0
  91. package/src/utils/json.js.map +1 -0
  92. package/src/utils/object-sort.d.ts +1 -0
  93. package/src/utils/object-sort.js +12 -0
  94. package/src/utils/object-sort.js.map +1 -0
  95. package/src/utils/register.d.ts +9 -0
  96. package/src/utils/register.js +36 -0
  97. package/src/utils/register.js.map +1 -0
  98. package/src/utils/split-target.d.ts +1 -0
  99. package/src/utils/split-target.js +26 -0
  100. package/src/utils/split-target.js.map +1 -0
@@ -0,0 +1,522 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renamePropertyWithStableKeys = exports.buildWorkspaceConfigurationFromGlobs = exports.inferProjectFromNonStandardFile = exports.deduplicateProjectFiles = exports.globForProjectFiles = exports.toProjectName = exports.resolveNewFormatWithInlineProjects = exports.resolveOldFormatWithInlineProjects = exports.toOldFormatOrNull = exports.toNewFormatOrNull = exports.toNewFormat = exports.reformattedWorkspaceJsonOrNull = exports.Workspaces = exports.workspaceConfigName = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const path = require("path");
7
+ const app_root_1 = require("../utils/app-root");
8
+ const fileutils_1 = require("../utils/fileutils");
9
+ const logger_1 = require("./logger");
10
+ const fast_glob_1 = require("fast-glob");
11
+ const ignore_1 = require("ignore");
12
+ const path_1 = require("path");
13
+ const perf_hooks_1 = require("perf_hooks");
14
+ const nx_plugin_1 = require("./nx-plugin");
15
+ function workspaceConfigName(root) {
16
+ if ((0, fs_1.existsSync)(path.join(root, 'angular.json'))) {
17
+ return 'angular.json';
18
+ }
19
+ else if ((0, fs_1.existsSync)(path.join(root, 'workspace.json'))) {
20
+ return 'workspace.json';
21
+ }
22
+ else {
23
+ return null;
24
+ }
25
+ }
26
+ exports.workspaceConfigName = workspaceConfigName;
27
+ class Workspaces {
28
+ constructor(root) {
29
+ this.root = root;
30
+ }
31
+ relativeCwd(cwd) {
32
+ return path.relative(this.root, cwd).replace(/\\/g, '/') || null;
33
+ }
34
+ calculateDefaultProjectName(cwd, wc) {
35
+ const relativeCwd = this.relativeCwd(cwd);
36
+ if (relativeCwd) {
37
+ const matchingProject = Object.keys(wc.projects).find((p) => {
38
+ const projectRoot = wc.projects[p].root;
39
+ return (relativeCwd == projectRoot ||
40
+ relativeCwd.startsWith(`${projectRoot}/`));
41
+ });
42
+ if (matchingProject)
43
+ return matchingProject;
44
+ }
45
+ return wc.defaultProject;
46
+ }
47
+ readWorkspaceConfiguration() {
48
+ if (this.cachedWorkspaceConfig)
49
+ return this.cachedWorkspaceConfig;
50
+ const nxJsonPath = path.join(this.root, 'nx.json');
51
+ const nxJson = readNxJson(nxJsonPath);
52
+ const workspaceFile = workspaceConfigName(this.root);
53
+ const workspacePath = workspaceFile
54
+ ? path.join(this.root, workspaceFile)
55
+ : null;
56
+ const workspace = workspacePath && (0, fs_1.existsSync)(workspacePath)
57
+ ? this.readFromWorkspaceJson()
58
+ : buildWorkspaceConfigurationFromGlobs(nxJson, globForProjectFiles(this.root, nxJson), (path) => (0, fileutils_1.readJsonFile)((0, path_1.join)(this.root, path)));
59
+ assertValidWorkspaceConfiguration(nxJson);
60
+ this.cachedWorkspaceConfig = Object.assign(Object.assign({}, workspace), nxJson);
61
+ return this.cachedWorkspaceConfig;
62
+ }
63
+ isNxExecutor(nodeModule, executor) {
64
+ const schema = this.readExecutor(nodeModule, executor).schema;
65
+ return schema['cli'] === 'nx';
66
+ }
67
+ isNxGenerator(collectionName, generatorName) {
68
+ const schema = this.readGenerator(collectionName, generatorName).schema;
69
+ return schema['cli'] === 'nx';
70
+ }
71
+ readExecutor(nodeModule, executor) {
72
+ try {
73
+ const { executorsFilePath, executorConfig } = this.readExecutorsJson(nodeModule, executor);
74
+ const executorsDir = path.dirname(executorsFilePath);
75
+ const schemaPath = path.join(executorsDir, executorConfig.schema || '');
76
+ const schema = (0, fileutils_1.readJsonFile)(schemaPath);
77
+ if (!schema.properties || typeof schema.properties !== 'object') {
78
+ schema.properties = {};
79
+ }
80
+ const implementationFactory = this.getImplementationFactory(executorConfig.implementation, executorsDir);
81
+ const batchImplementationFactory = executorConfig.batchImplementation
82
+ ? this.getImplementationFactory(executorConfig.batchImplementation, executorsDir)
83
+ : null;
84
+ const hasherFactory = executorConfig.hasher
85
+ ? this.getImplementationFactory(executorConfig.hasher, executorsDir)
86
+ : null;
87
+ return {
88
+ schema,
89
+ implementationFactory,
90
+ batchImplementationFactory,
91
+ hasherFactory,
92
+ };
93
+ }
94
+ catch (e) {
95
+ throw new Error(`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`);
96
+ }
97
+ }
98
+ readGenerator(collectionName, generatorName) {
99
+ var _a, _b;
100
+ try {
101
+ const { generatorsFilePath, generatorsJson, normalizedGeneratorName } = this.readGeneratorsJson(collectionName, generatorName);
102
+ const generatorsDir = path.dirname(generatorsFilePath);
103
+ const generatorConfig = ((_a = generatorsJson.generators) === null || _a === void 0 ? void 0 : _a[normalizedGeneratorName]) ||
104
+ ((_b = generatorsJson.schematics) === null || _b === void 0 ? void 0 : _b[normalizedGeneratorName]);
105
+ const schemaPath = path.join(generatorsDir, generatorConfig.schema || '');
106
+ const schema = (0, fileutils_1.readJsonFile)(schemaPath);
107
+ if (!schema.properties || typeof schema.properties !== 'object') {
108
+ schema.properties = {};
109
+ }
110
+ generatorConfig.implementation =
111
+ generatorConfig.implementation || generatorConfig.factory;
112
+ const implementationFactory = this.getImplementationFactory(generatorConfig.implementation, generatorsDir);
113
+ return { normalizedGeneratorName, schema, implementationFactory };
114
+ }
115
+ catch (e) {
116
+ throw new Error(`Unable to resolve ${collectionName}:${generatorName}.\n${e.message}`);
117
+ }
118
+ }
119
+ getImplementationFactory(implementation, directory) {
120
+ const [implementationModulePath, implementationExportName] = implementation.split('#');
121
+ return () => {
122
+ const module = require(path.join(directory, implementationModulePath));
123
+ return module[implementationExportName || 'default'];
124
+ };
125
+ }
126
+ readExecutorsJson(nodeModule, executor) {
127
+ var _a, _b, _c;
128
+ const packageJsonPath = require.resolve(`${nodeModule}/package.json`, {
129
+ paths: this.resolvePaths(),
130
+ });
131
+ const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
132
+ const executorsFile = (_a = packageJson.executors) !== null && _a !== void 0 ? _a : packageJson.builders;
133
+ if (!executorsFile) {
134
+ throw new Error(`The "${nodeModule}" package does not support Nx executors.`);
135
+ }
136
+ const executorsFilePath = require.resolve(path.join(path.dirname(packageJsonPath), executorsFile));
137
+ const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
138
+ const executorConfig = ((_b = executorsJson.executors) === null || _b === void 0 ? void 0 : _b[executor]) || ((_c = executorsJson.builders) === null || _c === void 0 ? void 0 : _c[executor]);
139
+ if (!executorConfig) {
140
+ throw new Error(`Cannot find executor '${executor}' in ${executorsFilePath}.`);
141
+ }
142
+ return { executorsFilePath, executorConfig };
143
+ }
144
+ readGeneratorsJson(collectionName, generator) {
145
+ var _a;
146
+ let generatorsFilePath;
147
+ if (collectionName.endsWith('.json')) {
148
+ generatorsFilePath = require.resolve(collectionName, {
149
+ paths: this.resolvePaths(),
150
+ });
151
+ }
152
+ else {
153
+ const packageJsonPath = require.resolve(`${collectionName}/package.json`, {
154
+ paths: this.resolvePaths(),
155
+ });
156
+ const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
157
+ const generatorsFile = (_a = packageJson.generators) !== null && _a !== void 0 ? _a : packageJson.schematics;
158
+ if (!generatorsFile) {
159
+ throw new Error(`The "${collectionName}" package does not support Nx generators.`);
160
+ }
161
+ generatorsFilePath = require.resolve(path.join(path.dirname(packageJsonPath), generatorsFile));
162
+ }
163
+ const generatorsJson = (0, fileutils_1.readJsonFile)(generatorsFilePath);
164
+ let normalizedGeneratorName = findFullGeneratorName(generator, generatorsJson.generators) ||
165
+ findFullGeneratorName(generator, generatorsJson.schematics);
166
+ if (!normalizedGeneratorName) {
167
+ for (let parent of generatorsJson.extends || []) {
168
+ try {
169
+ return this.readGeneratorsJson(parent, generator);
170
+ }
171
+ catch (e) { }
172
+ }
173
+ throw new Error(`Cannot find generator '${generator}' in ${generatorsFilePath}.`);
174
+ }
175
+ return { generatorsFilePath, generatorsJson, normalizedGeneratorName };
176
+ }
177
+ resolvePaths() {
178
+ return this.root ? [this.root, __dirname] : [__dirname];
179
+ }
180
+ readFromWorkspaceJson() {
181
+ const rawWorkspace = (0, fileutils_1.readJsonFile)(path.join(this.root, workspaceConfigName(this.root)));
182
+ return resolveNewFormatWithInlineProjects(rawWorkspace, this.root);
183
+ }
184
+ }
185
+ exports.Workspaces = Workspaces;
186
+ function assertValidWorkspaceConfiguration(nxJson) {
187
+ // Assert valid workspace configuration
188
+ if (nxJson.projects) {
189
+ logger_1.logger.warn('NX As of Nx 13, project configuration should be moved from nx.json to workspace.json/project.json. Please run "nx format" to fix this.');
190
+ }
191
+ }
192
+ function findFullGeneratorName(name, generators) {
193
+ if (generators) {
194
+ for (let [key, data] of Object.entries(generators)) {
195
+ if (key === name ||
196
+ (data.aliases && data.aliases.includes(name))) {
197
+ return key;
198
+ }
199
+ }
200
+ }
201
+ }
202
+ function reformattedWorkspaceJsonOrNull(w) {
203
+ return w.version === 2 ? toNewFormatOrNull(w) : toOldFormatOrNull(w);
204
+ }
205
+ exports.reformattedWorkspaceJsonOrNull = reformattedWorkspaceJsonOrNull;
206
+ function toNewFormat(w) {
207
+ const f = toNewFormatOrNull(w);
208
+ return f !== null && f !== void 0 ? f : w;
209
+ }
210
+ exports.toNewFormat = toNewFormat;
211
+ function toNewFormatOrNull(w) {
212
+ let formatted = false;
213
+ Object.values(w.projects || {}).forEach((projectConfig) => {
214
+ if (projectConfig.architect) {
215
+ renamePropertyWithStableKeys(projectConfig, 'architect', 'targets');
216
+ formatted = true;
217
+ }
218
+ if (projectConfig.schematics) {
219
+ renamePropertyWithStableKeys(projectConfig, 'schematics', 'generators');
220
+ formatted = true;
221
+ }
222
+ Object.values(projectConfig.targets || {}).forEach((target) => {
223
+ if (target.builder !== undefined) {
224
+ renamePropertyWithStableKeys(target, 'builder', 'executor');
225
+ formatted = true;
226
+ }
227
+ });
228
+ });
229
+ if (w.schematics) {
230
+ renamePropertyWithStableKeys(w, 'schematics', 'generators');
231
+ formatted = true;
232
+ }
233
+ if (w.version !== 2) {
234
+ w.version = 2;
235
+ formatted = true;
236
+ }
237
+ return formatted ? w : null;
238
+ }
239
+ exports.toNewFormatOrNull = toNewFormatOrNull;
240
+ function toOldFormatOrNull(w) {
241
+ let formatted = false;
242
+ Object.values(w.projects || {}).forEach((projectConfig) => {
243
+ if (typeof projectConfig === 'string') {
244
+ throw new Error("'project.json' files are incompatible with version 1 workspace schemas.");
245
+ }
246
+ if (projectConfig.targets) {
247
+ renamePropertyWithStableKeys(projectConfig, 'targets', 'architect');
248
+ formatted = true;
249
+ }
250
+ if (projectConfig.generators) {
251
+ renamePropertyWithStableKeys(projectConfig, 'generators', 'schematics');
252
+ formatted = true;
253
+ }
254
+ Object.values(projectConfig.architect || {}).forEach((target) => {
255
+ if (target.executor !== undefined) {
256
+ renamePropertyWithStableKeys(target, 'executor', 'builder');
257
+ formatted = true;
258
+ }
259
+ });
260
+ });
261
+ if (w.generators) {
262
+ renamePropertyWithStableKeys(w, 'generators', 'schematics');
263
+ formatted = true;
264
+ }
265
+ if (w.version !== 1) {
266
+ w.version = 1;
267
+ formatted = true;
268
+ }
269
+ return formatted ? w : null;
270
+ }
271
+ exports.toOldFormatOrNull = toOldFormatOrNull;
272
+ function resolveOldFormatWithInlineProjects(w, root = app_root_1.appRootPath) {
273
+ const inlined = inlineProjectConfigurations(w, root);
274
+ const formatted = toOldFormatOrNull(inlined);
275
+ return formatted ? formatted : inlined;
276
+ }
277
+ exports.resolveOldFormatWithInlineProjects = resolveOldFormatWithInlineProjects;
278
+ function resolveNewFormatWithInlineProjects(w, root = app_root_1.appRootPath) {
279
+ return toNewFormat(inlineProjectConfigurations(w, root));
280
+ }
281
+ exports.resolveNewFormatWithInlineProjects = resolveNewFormatWithInlineProjects;
282
+ function inlineProjectConfigurations(w, root = app_root_1.appRootPath) {
283
+ Object.entries(w.projects || {}).forEach(([project, config]) => {
284
+ if (typeof config === 'string') {
285
+ const configFilePath = path.join(root, config, 'project.json');
286
+ const fileConfig = (0, fileutils_1.readJsonFile)(configFilePath);
287
+ w.projects[project] = fileConfig;
288
+ }
289
+ });
290
+ return w;
291
+ }
292
+ /**
293
+ * Reads an nx.json file from a given path or extends a local nx.json config.
294
+ */
295
+ function readNxJson(nxJson) {
296
+ let nxJsonConfig;
297
+ if ((0, fs_1.existsSync)(nxJson)) {
298
+ nxJsonConfig = (0, fileutils_1.readJsonFile)(nxJson);
299
+ }
300
+ else {
301
+ nxJsonConfig = {};
302
+ }
303
+ if (nxJsonConfig.extends) {
304
+ const extendedNxJsonPath = require.resolve(nxJsonConfig.extends, {
305
+ paths: [(0, path_1.dirname)(nxJson)],
306
+ });
307
+ const baseNxJson = (0, fileutils_1.readJsonFile)(extendedNxJsonPath);
308
+ nxJsonConfig = Object.assign(Object.assign({}, baseNxJson), nxJsonConfig);
309
+ }
310
+ return nxJsonConfig;
311
+ }
312
+ /**
313
+ * Pulled from toFileName in names from @nrwl/devkit.
314
+ * Todo: Should refactor, not duplicate.
315
+ */
316
+ function toProjectName(fileName, nxJson) {
317
+ const directory = (0, path_1.dirname)(fileName);
318
+ let { appsDir, libsDir } = (nxJson === null || nxJson === void 0 ? void 0 : nxJson.workspaceLayout) || {};
319
+ appsDir !== null && appsDir !== void 0 ? appsDir : (appsDir = 'apps');
320
+ libsDir !== null && libsDir !== void 0 ? libsDir : (libsDir = 'libs');
321
+ const parts = directory.split(/[\/\\]/g);
322
+ if ([appsDir, libsDir].includes(parts[0])) {
323
+ parts.splice(0, 1);
324
+ }
325
+ return parts.join('-').toLowerCase();
326
+ }
327
+ exports.toProjectName = toProjectName;
328
+ let projectGlobCache;
329
+ let projectGlobCacheKey;
330
+ function getGlobPatternsFromPlugins(nxJson) {
331
+ const plugins = (0, nx_plugin_1.loadNxPlugins)(nxJson === null || nxJson === void 0 ? void 0 : nxJson.plugins);
332
+ const patterns = [];
333
+ for (const plugin of plugins) {
334
+ if (!plugin.projectFilePatterns) {
335
+ continue;
336
+ }
337
+ for (const filePattern of plugin.projectFilePatterns) {
338
+ patterns.push('**/' + filePattern);
339
+ }
340
+ }
341
+ return patterns;
342
+ }
343
+ /**
344
+ * Get the package.json globs from package manager workspaces
345
+ */
346
+ function getGlobPatternsFromPackageManagerWorkspaces(root) {
347
+ var _a;
348
+ // TODO: add support for pnpm
349
+ try {
350
+ const { workspaces } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
351
+ return ((_a = workspaces === null || workspaces === void 0 ? void 0 : workspaces.map((pattern) => pattern + '/package.json')) !== null && _a !== void 0 ? _a : [
352
+ '**/package.json',
353
+ ]);
354
+ }
355
+ catch (_b) {
356
+ return ['**/package.json'];
357
+ }
358
+ }
359
+ function globForProjectFiles(root, nxJson) {
360
+ // Deal w/ Caching
361
+ const cacheKey = [root, ...((nxJson === null || nxJson === void 0 ? void 0 : nxJson.plugins) || [])].join(',');
362
+ if (projectGlobCache && cacheKey === projectGlobCacheKey)
363
+ return projectGlobCache;
364
+ projectGlobCacheKey = cacheKey;
365
+ const projectGlobPatterns = [
366
+ '**/project.json',
367
+ ...getGlobPatternsFromPackageManagerWorkspaces(root),
368
+ ...getGlobPatternsFromPlugins(nxJson),
369
+ ];
370
+ const combinedProjectGlobPattern = '{' + projectGlobPatterns.join(',') + '}';
371
+ perf_hooks_1.performance.mark('start-glob-for-projects');
372
+ /**
373
+ * This configures the files and directories which we always want to ignore as part of file watching
374
+ * and which we know the location of statically (meaning irrespective of user configuration files).
375
+ * This has the advantage of being ignored directly within globSync
376
+ *
377
+ * Other ignored entries will need to be determined dynamically by reading and evaluating the user's
378
+ * .gitignore and .nxignore files below.
379
+ */
380
+ const ALWAYS_IGNORE = [
381
+ (0, path_1.join)(root, 'node_modules'),
382
+ '**/node_modules',
383
+ (0, path_1.join)(root, 'dist'),
384
+ (0, path_1.join)(root, '.git'),
385
+ ];
386
+ /**
387
+ * TODO: This utility has been implemented multiple times across the Nx codebase,
388
+ * discuss whether it should be moved to a shared location.
389
+ */
390
+ const ig = (0, ignore_1.default)();
391
+ try {
392
+ ig.add((0, fs_1.readFileSync)(`${root}/.gitignore`, 'utf-8'));
393
+ }
394
+ catch (_a) { }
395
+ try {
396
+ ig.add((0, fs_1.readFileSync)(`${root}/.nxignore`, 'utf-8'));
397
+ }
398
+ catch (_b) { }
399
+ const globResults = (0, fast_glob_1.sync)(combinedProjectGlobPattern, {
400
+ ignore: ALWAYS_IGNORE,
401
+ absolute: false,
402
+ cwd: root,
403
+ });
404
+ projectGlobCache = deduplicateProjectFiles(globResults, ig);
405
+ perf_hooks_1.performance.mark('finish-glob-for-projects');
406
+ perf_hooks_1.performance.measure('glob-for-project-files', 'start-glob-for-projects', 'finish-glob-for-projects');
407
+ return projectGlobCache;
408
+ }
409
+ exports.globForProjectFiles = globForProjectFiles;
410
+ function deduplicateProjectFiles(files, ig) {
411
+ const filtered = new Map();
412
+ files.forEach((file) => {
413
+ const projectFolder = (0, path_1.dirname)(file);
414
+ const projectFile = (0, path_1.basename)(file);
415
+ if ((ig === null || ig === void 0 ? void 0 : ig.ignores(file)) || // file is in .gitignore or .nxignore
416
+ file === 'package.json' || // file is workspace root package json
417
+ // project.json or equivallent inferred project file has been found
418
+ (filtered.has(projectFolder) && projectFile !== 'project.json')) {
419
+ return;
420
+ }
421
+ filtered.set(projectFolder, projectFile);
422
+ });
423
+ return Array.from(filtered.entries()).map(([folder, file]) => (0, path_1.join)(folder, file));
424
+ }
425
+ exports.deduplicateProjectFiles = deduplicateProjectFiles;
426
+ function buildProjectConfigurationFromPackageJson(path, packageJson, nxJson) {
427
+ var _a;
428
+ const directory = (0, path_1.dirname)(path).split('\\').join('/');
429
+ const npmPrefix = `@${nxJson.npmScope}/`;
430
+ let name = (_a = packageJson.name) !== null && _a !== void 0 ? _a : toProjectName(directory, nxJson);
431
+ if (name.startsWith(npmPrefix)) {
432
+ name = name.replace(npmPrefix, '');
433
+ }
434
+ return {
435
+ root: directory,
436
+ sourceRoot: directory,
437
+ name,
438
+ };
439
+ }
440
+ function inferProjectFromNonStandardFile(file, nxJson) {
441
+ const directory = (0, path_1.dirname)(file).split('\\').join('/');
442
+ return {
443
+ name: toProjectName(file, nxJson),
444
+ root: directory,
445
+ };
446
+ }
447
+ exports.inferProjectFromNonStandardFile = inferProjectFromNonStandardFile;
448
+ function buildWorkspaceConfigurationFromGlobs(nxJson, projectFiles = globForProjectFiles(app_root_1.appRootPath, nxJson), // making this parameter allows devkit to pick up newly created projects
449
+ readJson = fileutils_1.readJsonFile // making this an arg allows us to reuse in devkit
450
+ ) {
451
+ const projects = {};
452
+ for (const file of projectFiles) {
453
+ const directory = (0, path_1.dirname)(file).split('\\').join('/');
454
+ const fileName = (0, path_1.basename)(file);
455
+ if (fileName === 'project.json') {
456
+ // Nx specific project configuration (`project.json` files) in the same
457
+ // directory as a package.json should overwrite the inferred package.json
458
+ // project configuration.
459
+ const configuration = readJson(file);
460
+ let name = configuration.name;
461
+ if (!configuration.name) {
462
+ name = toProjectName(file, nxJson);
463
+ }
464
+ if (!projects[name]) {
465
+ projects[name] = configuration;
466
+ }
467
+ else {
468
+ logger_1.logger.warn(`Skipping project found at ${directory} since project ${name} already exists at ${projects[name].root}! Specify a unique name for the project to allow Nx to differentiate between the two projects.`);
469
+ }
470
+ }
471
+ else {
472
+ // We can infer projects from package.json files,
473
+ // if a package.json file is in a directory w/o a `project.json` file.
474
+ // this results in targets being inferred by Nx from package scripts,
475
+ // and the root / sourceRoot both being the directory.
476
+ if (fileName === 'package.json') {
477
+ const _a = buildProjectConfigurationFromPackageJson(file, readJson(file), nxJson), { name } = _a, config = (0, tslib_1.__rest)(_a, ["name"]);
478
+ if (!projects[name]) {
479
+ projects[name] = config;
480
+ }
481
+ else {
482
+ logger_1.logger.warn(`Skipping project found at ${directory} since project ${name} already exists at ${projects[name].root}! Specify a unique name for the project to allow Nx to differentiate between the two projects.`);
483
+ }
484
+ }
485
+ else {
486
+ // This project was created from an nx plugin.
487
+ // The only thing we know about the file is its location
488
+ const _b = inferProjectFromNonStandardFile(file, nxJson), { name } = _b, config = (0, tslib_1.__rest)(_b, ["name"]);
489
+ if (!projects[name]) {
490
+ projects[name] = config;
491
+ }
492
+ else {
493
+ logger_1.logger.error(`Skipping project inferred from ${file} since project ${name} already exists.`);
494
+ throw new Error();
495
+ }
496
+ }
497
+ }
498
+ }
499
+ return {
500
+ version: 2,
501
+ projects: projects,
502
+ };
503
+ }
504
+ exports.buildWorkspaceConfigurationFromGlobs = buildWorkspaceConfigurationFromGlobs;
505
+ // we have to do it this way to preserve the order of properties
506
+ // not to screw up the formatting
507
+ function renamePropertyWithStableKeys(obj, from, to) {
508
+ const copy = Object.assign({}, obj);
509
+ Object.keys(obj).forEach((k) => {
510
+ delete obj[k];
511
+ });
512
+ Object.keys(copy).forEach((k) => {
513
+ if (k === from) {
514
+ obj[to] = copy[k];
515
+ }
516
+ else {
517
+ obj[k] = copy[k];
518
+ }
519
+ });
520
+ }
521
+ exports.renamePropertyWithStableKeys = renamePropertyWithStableKeys;
522
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../../../packages/nx/src/shared/workspace.ts"],"names":[],"mappings":";;;;AAAA,2BAA8C;AAC9C,6BAA6B;AAC7B,gDAAgD;AAChD,kDAAkD;AAGlD,qCAAkC;AAClC,yCAA6C;AAC7C,mCAAwC;AACxC,+BAA+C;AAC/C,2CAAyC;AACzC,2CAA4C;AAkJ5C,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,IAAI,IAAA,eAAU,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,EAAE;QAC/C,O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0,0 +1,2 @@
1
+ export declare const appRootPath: string;
2
+ export declare function fileExists(filePath: string): boolean;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fileExists = exports.appRootPath = void 0;
4
+ const path = require("path");
5
+ const fs_1 = require("fs");
6
+ exports.appRootPath = pathInner(__dirname);
7
+ function pathInner(dir) {
8
+ if (process.env.NX_WORKSPACE_ROOT_PATH)
9
+ return process.env.NX_WORKSPACE_ROOT_PATH;
10
+ if (path.dirname(dir) === dir)
11
+ return process.cwd();
12
+ if (fileExists(path.join(dir, 'workspace.json')) ||
13
+ fileExists(path.join(dir, 'nx.json')) ||
14
+ fileExists(path.join(dir, 'angular.json'))) {
15
+ return dir;
16
+ }
17
+ else {
18
+ return pathInner(path.dirname(dir));
19
+ }
20
+ }
21
+ function fileExists(filePath) {
22
+ try {
23
+ return (0, fs_1.statSync)(filePath).isFile();
24
+ }
25
+ catch (err) {
26
+ return false;
27
+ }
28
+ }
29
+ exports.fileExists = fileExists;
30
+ //# sourceMappingURL=app-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/app-root.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,2BAA8B;AAEjB,QAAA,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AAEhD,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;QACpC,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACpD,IACE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QAC5C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACrC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAC1C;QACA,OAAO,GAAG,CAAC;KACZ;SAAM;QACL,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KACrC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,QAAgB;IACzC,IAAI;QACF,OAAO,IAAA,aAAQ,EAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;KACpC;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAND,gCAMC"}
@@ -0,0 +1,31 @@
1
+ import type { JsonParseOptions, JsonSerializeOptions } from './json';
2
+ export interface JsonReadOptions extends JsonParseOptions {
3
+ /**
4
+ * mutable field recording whether JSON ends with new line
5
+ * @default false
6
+ */
7
+ endsWithNewline?: boolean;
8
+ }
9
+ export interface JsonWriteOptions extends JsonSerializeOptions {
10
+ /**
11
+ * whether to append new line at the end of JSON file
12
+ * @default false
13
+ */
14
+ appendNewLine?: boolean;
15
+ }
16
+ /**
17
+ * Reads a JSON file and returns the object the JSON content represents.
18
+ *
19
+ * @param path A path to a file.
20
+ * @param options JSON parse options
21
+ * @returns Object the JSON content of the file represents
22
+ */
23
+ export declare function readJsonFile<T extends object = any>(path: string, options?: JsonReadOptions): T;
24
+ /**
25
+ * Serializes the given data to JSON and writes it to a file.
26
+ *
27
+ * @param path A path to a file.
28
+ * @param data data which should be serialized to JSON and written to the file
29
+ * @param options JSON serialize options
30
+ */
31
+ export declare function writeJsonFile<T extends object = object>(path: string, data: T, options?: JsonWriteOptions): void;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeJsonFile = exports.readJsonFile = void 0;
4
+ const json_1 = require("./json");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const fs_extra_1 = require("fs-extra");
8
+ /**
9
+ * Reads a JSON file and returns the object the JSON content represents.
10
+ *
11
+ * @param path A path to a file.
12
+ * @param options JSON parse options
13
+ * @returns Object the JSON content of the file represents
14
+ */
15
+ function readJsonFile(path, options) {
16
+ const content = (0, fs_1.readFileSync)(path, 'utf-8');
17
+ if (options) {
18
+ options.endsWithNewline = content.charCodeAt(content.length - 1) === 10;
19
+ }
20
+ try {
21
+ return (0, json_1.parseJson)(content, options);
22
+ }
23
+ catch (e) {
24
+ e.message = e.message.replace('JSON', path);
25
+ throw e;
26
+ }
27
+ }
28
+ exports.readJsonFile = readJsonFile;
29
+ /**
30
+ * Serializes the given data to JSON and writes it to a file.
31
+ *
32
+ * @param path A path to a file.
33
+ * @param data data which should be serialized to JSON and written to the file
34
+ * @param options JSON serialize options
35
+ */
36
+ function writeJsonFile(path, data, options) {
37
+ (0, fs_extra_1.ensureDirSync)((0, path_1.dirname)(path));
38
+ const serializedJson = (0, json_1.serializeJson)(data, options);
39
+ const content = (options === null || options === void 0 ? void 0 : options.appendNewLine)
40
+ ? `${serializedJson}\n`
41
+ : serializedJson;
42
+ (0, fs_1.writeFileSync)(path, content, { encoding: 'utf-8' });
43
+ }
44
+ exports.writeJsonFile = writeJsonFile;
45
+ //# sourceMappingURL=fileutils.js.map