nx 18.1.0 → 18.1.1

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 (121) hide show
  1. package/bin/init-local.js +13 -1
  2. package/package.json +12 -12
  3. package/release/changelog-renderer/index.d.ts +2 -0
  4. package/release/changelog-renderer/index.js +4 -18
  5. package/schemas/nx-schema.json +62 -1
  6. package/schemas/project-schema.json +20 -0
  7. package/src/adapter/angular-json.d.ts +1 -2
  8. package/src/adapter/angular-json.js +0 -1
  9. package/src/adapter/ngcli-adapter.js +3 -3
  10. package/src/command-line/generate/generator-utils.js +2 -2
  11. package/src/command-line/init/implementation/add-nx-to-nest.js +2 -2
  12. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
  13. package/src/command-line/init/implementation/utils.d.ts +1 -3
  14. package/src/command-line/init/implementation/utils.js +9 -16
  15. package/src/command-line/init/init-v2.js +3 -2
  16. package/src/command-line/release/changelog.js +17 -14
  17. package/src/command-line/release/command-object.d.ts +1 -0
  18. package/src/command-line/release/config/config.d.ts +12 -15
  19. package/src/command-line/release/config/config.js +151 -22
  20. package/src/command-line/release/config/conventional-commits.d.ts +2 -0
  21. package/src/command-line/release/config/conventional-commits.js +98 -0
  22. package/src/command-line/release/publish.js +4 -3
  23. package/src/command-line/release/release.js +12 -11
  24. package/src/command-line/release/utils/git.js +30 -1
  25. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
  26. package/src/command-line/release/utils/resolve-semver-specifier.js +2 -13
  27. package/src/command-line/release/utils/semver.d.ts +2 -8
  28. package/src/command-line/release/utils/semver.js +4 -1
  29. package/src/command-line/release/utils/shared.d.ts +5 -1
  30. package/src/command-line/release/version.d.ts +6 -1
  31. package/src/command-line/release/version.js +71 -19
  32. package/src/command-line/run/executor-utils.js +2 -2
  33. package/src/command-line/run/run.js +3 -3
  34. package/src/config/nx-json.d.ts +31 -0
  35. package/src/config/schema-utils.js +2 -2
  36. package/src/core/graph/main.js +1 -1
  37. package/src/core/graph/polyfills.js +1 -1
  38. package/src/core/graph/styles.css +1 -1
  39. package/src/daemon/server/project-graph-incremental-recomputation.js +1 -0
  40. package/src/devkit-exports.d.ts +1 -2
  41. package/src/devkit-internals.d.ts +0 -1
  42. package/src/devkit-internals.js +1 -3
  43. package/src/executors/run-commands/run-commands.impl.d.ts +7 -1
  44. package/src/executors/run-commands/run-commands.impl.js +120 -57
  45. package/src/executors/run-script/run-script.impl.js +5 -5
  46. package/src/generators/utils/project-configuration.js +2 -2
  47. package/src/hasher/hash-task.js +2 -2
  48. package/src/migrations/update-15-1-0/set-project-names.js +2 -4
  49. package/src/migrations/update-17-2-0/move-default-base.d.ts +1 -1
  50. package/src/migrations/update-17-2-0/move-default-base.js +3 -1
  51. package/src/migrations/update-17-3-0/nx-release-path.js +0 -1
  52. package/src/native/index.d.ts +14 -11
  53. package/src/native/index.js +3 -4
  54. package/src/plugins/js/index.d.ts +1 -1
  55. package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
  56. package/src/plugins/js/lock-file/lock-file.js +13 -1
  57. package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
  58. package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
  59. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  60. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
  61. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
  62. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
  63. package/src/plugins/js/utils/register.js +3 -1
  64. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  65. package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
  66. package/src/plugins/package-json-workspaces/index.d.ts +0 -1
  67. package/src/plugins/package-json-workspaces/index.js +0 -2
  68. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
  69. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
  70. package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
  71. package/src/plugins/project-json/build-nodes/project-json.js +0 -1
  72. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
  73. package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
  74. package/src/project-graph/affected/locators/project-glob-changes.js +3 -2
  75. package/src/project-graph/build-project-graph.js +8 -11
  76. package/src/project-graph/file-utils.js +6 -4
  77. package/src/project-graph/project-graph-builder.d.ts +1 -1
  78. package/src/project-graph/project-graph.js +3 -0
  79. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  80. package/src/project-graph/utils/project-configuration-utils.d.ts +4 -4
  81. package/src/project-graph/utils/project-configuration-utils.js +58 -17
  82. package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -8
  83. package/src/project-graph/utils/retrieve-workspace-files.js +18 -20
  84. package/src/tasks-runner/fork.js +7 -7
  85. package/src/tasks-runner/forked-process-task-runner.d.ts +2 -4
  86. package/src/tasks-runner/forked-process-task-runner.js +13 -17
  87. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +16 -13
  88. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +8 -7
  89. package/src/tasks-runner/{psuedo-ipc.d.ts → pseudo-ipc.d.ts} +7 -7
  90. package/src/tasks-runner/{psuedo-ipc.js → pseudo-ipc.js} +9 -9
  91. package/src/tasks-runner/pseudo-terminal.d.ts +42 -0
  92. package/src/tasks-runner/pseudo-terminal.js +133 -0
  93. package/src/tasks-runner/task-orchestrator.js +45 -9
  94. package/src/tasks-runner/tasks-schedule.js +3 -3
  95. package/src/tasks-runner/utils.d.ts +7 -6
  96. package/src/tasks-runner/utils.js +11 -7
  97. package/src/utils/ignore.js +1 -1
  98. package/src/utils/logger.d.ts +0 -1
  99. package/src/utils/logger.js +0 -5
  100. package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +45 -7
  101. package/src/utils/nx-plugin.deprecated.d.ts +2 -4
  102. package/src/utils/nx-plugin.deprecated.js +4 -4
  103. package/src/utils/nx-plugin.js +293 -0
  104. package/src/utils/output.js +1 -1
  105. package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
  106. package/src/utils/plugins/plugin-capabilities.js +7 -8
  107. package/src/project-graph/plugins/index.d.ts +0 -2
  108. package/src/project-graph/plugins/index.js +0 -8
  109. package/src/project-graph/plugins/internal-api.d.ts +0 -18
  110. package/src/project-graph/plugins/internal-api.js +0 -48
  111. package/src/project-graph/plugins/messaging.d.ts +0 -94
  112. package/src/project-graph/plugins/messaging.js +0 -23
  113. package/src/project-graph/plugins/plugin-pool.d.ts +0 -4
  114. package/src/project-graph/plugins/plugin-pool.js +0 -216
  115. package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
  116. package/src/project-graph/plugins/plugin-worker.js +0 -115
  117. package/src/project-graph/plugins/public-api.js +0 -4
  118. package/src/project-graph/plugins/utils.d.ts +0 -9
  119. package/src/project-graph/plugins/utils.js +0 -55
  120. package/src/project-graph/plugins/worker-api.d.ts +0 -26
  121. package/src/project-graph/plugins/worker-api.js +0 -177
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerminal = exports.getPseudoTerminal = void 0;
4
+ const native_1 = require("../native");
5
+ const pseudo_ipc_1 = require("./pseudo-ipc");
6
+ const socket_utils_1 = require("../daemon/socket-utils");
7
+ let pseudoTerminal;
8
+ function getPseudoTerminal() {
9
+ pseudoTerminal ??= new PseudoTerminal(new native_1.RustPseudoTerminal());
10
+ return pseudoTerminal;
11
+ }
12
+ exports.getPseudoTerminal = getPseudoTerminal;
13
+ class PseudoTerminal {
14
+ constructor(rustPseudoTerminal) {
15
+ this.rustPseudoTerminal = rustPseudoTerminal;
16
+ this.pseudoIPCPath = (0, socket_utils_1.FORKED_PROCESS_OS_SOCKET_PATH)(process.pid.toString());
17
+ this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
18
+ this.initialized = false;
19
+ this.setupProcessListeners();
20
+ }
21
+ async init() {
22
+ if (this.initialized) {
23
+ return;
24
+ }
25
+ await this.pseudoIPC.init();
26
+ this.initialized = true;
27
+ }
28
+ runCommand(command, { cwd, jsEnv, quiet, } = {}) {
29
+ return new PseudoTtyProcess(this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, quiet));
30
+ }
31
+ async fork(id, script, { cwd, jsEnv, quiet, }) {
32
+ if (!this.initialized) {
33
+ throw new Error('Call init() before forking processes');
34
+ }
35
+ const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, quiet), id, this.pseudoIPC);
36
+ await this.pseudoIPC.waitForChildReady(id);
37
+ return cp;
38
+ }
39
+ sendMessageToChildren(message) {
40
+ this.pseudoIPC.sendMessageToChildren(message);
41
+ }
42
+ onMessageFromChildren(callback) {
43
+ this.pseudoIPC.onMessageFromChildren(callback);
44
+ }
45
+ setupProcessListeners() {
46
+ const shutdown = () => {
47
+ this.shutdownPseudoIPC();
48
+ };
49
+ process.on('SIGINT', () => {
50
+ this.shutdownPseudoIPC();
51
+ });
52
+ process.on('SIGTERM', () => {
53
+ this.shutdownPseudoIPC();
54
+ });
55
+ process.on('SIGHUP', () => {
56
+ this.shutdownPseudoIPC();
57
+ });
58
+ process.on('exit', () => {
59
+ this.shutdownPseudoIPC();
60
+ });
61
+ }
62
+ shutdownPseudoIPC() {
63
+ if (this.initialized) {
64
+ this.pseudoIPC.close();
65
+ }
66
+ }
67
+ }
68
+ exports.PseudoTerminal = PseudoTerminal;
69
+ class PseudoTtyProcess {
70
+ constructor(childProcess) {
71
+ this.childProcess = childProcess;
72
+ this.isAlive = true;
73
+ this.exitCallbacks = [];
74
+ childProcess.onExit((message) => {
75
+ this.isAlive = false;
76
+ const exitCode = messageToCode(message);
77
+ this.exitCallbacks.forEach((cb) => cb(exitCode));
78
+ });
79
+ }
80
+ onExit(callback) {
81
+ this.exitCallbacks.push(callback);
82
+ }
83
+ onOutput(callback) {
84
+ this.childProcess.onOutput(callback);
85
+ }
86
+ kill() {
87
+ try {
88
+ this.childProcess.kill();
89
+ }
90
+ catch {
91
+ // when the child process completes before we explicitly call kill, this will throw
92
+ // do nothing
93
+ }
94
+ finally {
95
+ if (this.isAlive == true) {
96
+ this.isAlive = false;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ exports.PseudoTtyProcess = PseudoTtyProcess;
102
+ class PseudoTtyProcessWithSend extends PseudoTtyProcess {
103
+ constructor(_childProcess, id, pseudoIpc) {
104
+ super(_childProcess);
105
+ this.id = id;
106
+ this.pseudoIpc = pseudoIpc;
107
+ }
108
+ send(message) {
109
+ this.pseudoIpc.sendMessageToChild(this.id, message);
110
+ }
111
+ }
112
+ exports.PseudoTtyProcessWithSend = PseudoTtyProcessWithSend;
113
+ function messageToCode(message) {
114
+ if (message.startsWith('Terminated by ')) {
115
+ switch (message.replace('Terminated by ', '').trim()) {
116
+ case 'Termination':
117
+ return 143;
118
+ case 'Interrupt':
119
+ return 130;
120
+ default:
121
+ return 128;
122
+ }
123
+ }
124
+ else if (message.startsWith('Exited with code ')) {
125
+ return parseInt(message.replace('Exited with code ', '').trim());
126
+ }
127
+ else if (message === 'Success') {
128
+ return 0;
129
+ }
130
+ else {
131
+ return 1;
132
+ }
133
+ }
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskOrchestrator = void 0;
4
4
  const events_1 = require("events");
5
5
  const perf_hooks_1 = require("perf_hooks");
6
+ const path_1 = require("path");
7
+ const run_commands_impl_1 = require("../executors/run-commands/run-commands.impl");
6
8
  const forked_process_task_runner_1 = require("./forked-process-task-runner");
7
9
  const cache_1 = require("./cache");
8
10
  const utils_1 = require("./utils");
@@ -10,6 +12,9 @@ const tasks_schedule_1 = require("./tasks-schedule");
10
12
  const hash_task_1 = require("../hasher/hash-task");
11
13
  const task_env_1 = require("./task-env");
12
14
  const os = require("os");
15
+ const workspace_root_1 = require("../utils/workspace-root");
16
+ const output_1 = require("../utils/output");
17
+ const params_1 = require("../utils/params");
13
18
  class TaskOrchestrator {
14
19
  // endregion internal state
15
20
  constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon) {
@@ -49,7 +54,6 @@ class TaskOrchestrator {
49
54
  await Promise.all(threads);
50
55
  perf_hooks_1.performance.mark('task-execution:end');
51
56
  perf_hooks_1.performance.measure('task-execution', 'task-execution:start', 'task-execution:end');
52
- this.forkedProcessTaskRunner.destroy();
53
57
  this.cache.removeOldCacheRecords();
54
58
  return this.completedTasks;
55
59
  }
@@ -205,13 +209,45 @@ class TaskOrchestrator {
205
209
  let results = doNotSkipCache ? await this.applyCachedResults([task]) : [];
206
210
  // the task wasn't cached
207
211
  if (results.length === 0) {
208
- // cache prep
209
- const { code, terminalOutput } = await this.runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput);
210
- results.push({
211
- task,
212
- status: code === 0 ? 'success' : 'failure',
213
- terminalOutput,
214
- });
212
+ const shouldPrefix = streamOutput && process.env.NX_PREFIX_OUTPUT === 'true';
213
+ const targetConfiguration = (0, utils_1.getTargetConfigurationForTask)(task, this.projectGraph);
214
+ if (process.env.NX_RUN_COMMANDS_DIRECTLY !== 'false' &&
215
+ targetConfiguration.executor === 'nx:run-commands' &&
216
+ !shouldPrefix) {
217
+ const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
218
+ const isRunOne = this.initiatingProject != null;
219
+ const combinedOptions = (0, params_1.combineOptionsForExecutor)(task.overrides, task.target.configuration ?? targetConfiguration.defaultConfiguration, targetConfiguration, schema, task.target.project, (0, path_1.relative)(task.projectRoot ?? workspace_root_1.workspaceRoot, process.cwd()), process.env.NX_VERBOSE_LOGGING === 'true');
220
+ if (streamOutput) {
221
+ const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
222
+ output_1.output.logCommand(args.join(' '));
223
+ }
224
+ const { success, terminalOutput } = await (0, run_commands_impl_1.default)({
225
+ ...combinedOptions,
226
+ env,
227
+ usePty: isRunOne && !this.tasksSchedule.hasTasks(),
228
+ streamOutput,
229
+ }, {
230
+ root: workspace_root_1.workspaceRoot, // only root is needed in runCommandsImpl
231
+ });
232
+ const status = success ? 'success' : 'failure';
233
+ if (!streamOutput) {
234
+ this.options.lifeCycle.printTaskTerminalOutput(task, status, terminalOutput);
235
+ }
236
+ results.push({
237
+ task,
238
+ status,
239
+ terminalOutput,
240
+ });
241
+ }
242
+ else {
243
+ // cache prep
244
+ const { code, terminalOutput } = await this.runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput);
245
+ results.push({
246
+ task,
247
+ status: code === 0 ? 'success' : 'failure',
248
+ terminalOutput,
249
+ });
250
+ }
215
251
  }
216
252
  await this.postRunSteps([task], results, doNotSkipCache, { groupId });
217
253
  }
@@ -338,7 +374,7 @@ class TaskOrchestrator {
338
374
  if (process.env.NX_NATIVE_COMMAND_RUNNER !== 'false') {
339
375
  return true;
340
376
  }
341
- const { schema } = await (0, utils_1.getExecutorForTask)(task, this.projectGraph);
377
+ const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
342
378
  return (schema.outputCapture === 'pipe' ||
343
379
  process.env.NX_STREAM_OUTPUT === 'true');
344
380
  }
@@ -89,7 +89,7 @@ class TasksSchedule {
89
89
  const batchMap = {};
90
90
  for (const root of this.notScheduledTaskGraph.roots) {
91
91
  const rootTask = this.notScheduledTaskGraph.tasks[root];
92
- const executorName = await (0, utils_1.getExecutorNameForTask)(rootTask, this.projectGraph);
92
+ const executorName = (0, utils_1.getExecutorNameForTask)(rootTask, this.projectGraph);
93
93
  await this.processTaskForBatches(batchMap, rootTask, executorName, true);
94
94
  }
95
95
  for (const [executorName, taskGraph] of Object.entries(batchMap)) {
@@ -105,8 +105,8 @@ class TasksSchedule {
105
105
  if (!this.canBatchTaskBeScheduled(task.id, batches[rootExecutorName])) {
106
106
  return;
107
107
  }
108
- const { batchImplementationFactory } = await (0, utils_1.getExecutorForTask)(task, this.projectGraph);
109
- const executorName = await (0, utils_1.getExecutorNameForTask)(task, this.projectGraph);
108
+ const { batchImplementationFactory } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
109
+ const executorName = (0, utils_1.getExecutorNameForTask)(task, this.projectGraph);
110
110
  if (rootExecutorName !== executorName) {
111
111
  return;
112
112
  }
@@ -1,7 +1,7 @@
1
1
  import { Task, TaskGraph } from '../config/task-graph';
2
2
  import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
3
- import { TargetDependencyConfig } from '../config/workspace-json-project-json';
4
- import { CustomHasher } from '../config/misc-interfaces';
3
+ import { TargetConfiguration, TargetDependencyConfig } from '../config/workspace-json-project-json';
4
+ import { CustomHasher, ExecutorConfig } from '../config/misc-interfaces';
5
5
  export declare function getCommandAsString(execCommand: string, task: Task): string;
6
6
  export declare function getDependencyConfigs({ project, target }: {
7
7
  project: string;
@@ -23,12 +23,13 @@ export declare function transformLegacyOutputs(projectRoot: string, error: Inval
23
23
  export declare function getOutputsForTargetAndConfiguration(task: Task, node: ProjectGraphProjectNode): string[];
24
24
  export declare function getOutputsForTargetAndConfiguration(target: Task['target'] | Task, overrides: Task['overrides'] | ProjectGraphProjectNode, node: ProjectGraphProjectNode): string[];
25
25
  export declare function interpolate(template: string, data: any): string;
26
- export declare function getExecutorNameForTask(task: Task, projectGraph: ProjectGraph): Promise<string>;
27
- export declare function getExecutorForTask(task: Task, projectGraph: ProjectGraph): Promise<import("../config/misc-interfaces").ExecutorConfig & {
26
+ export declare function getTargetConfigurationForTask(task: Task, projectGraph: ProjectGraph): TargetConfiguration | undefined;
27
+ export declare function getExecutorNameForTask(task: Task, projectGraph: ProjectGraph): string;
28
+ export declare function getExecutorForTask(task: Task, projectGraph: ProjectGraph): ExecutorConfig & {
28
29
  isNgCompat: boolean;
29
30
  isNxExecutor: boolean;
30
- }>;
31
- export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph): Promise<CustomHasher> | null;
31
+ };
32
+ export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph): CustomHasher | null;
32
33
  export declare function removeTasksFromTaskGraph(graph: TaskGraph, ids: string[]): TaskGraph;
33
34
  export declare function removeIdsFromGraph<T>(graph: {
34
35
  roots: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = exports.getCommandAsString = void 0;
3
+ exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.getTargetConfigurationForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = exports.getCommandAsString = void 0;
4
4
  const output_1 = require("../utils/output");
5
5
  const path_1 = require("path");
6
6
  const workspace_root_1 = require("../utils/workspace-root");
@@ -177,19 +177,23 @@ function interpolate(template, data) {
177
177
  });
178
178
  }
179
179
  exports.interpolate = interpolate;
180
- async function getExecutorNameForTask(task, projectGraph) {
180
+ function getTargetConfigurationForTask(task, projectGraph) {
181
181
  const project = projectGraph.nodes[task.target.project].data;
182
- return project.targets[task.target.target].executor;
182
+ return project.targets[task.target.target];
183
+ }
184
+ exports.getTargetConfigurationForTask = getTargetConfigurationForTask;
185
+ function getExecutorNameForTask(task, projectGraph) {
186
+ return getTargetConfigurationForTask(task, projectGraph)?.executor;
183
187
  }
184
188
  exports.getExecutorNameForTask = getExecutorNameForTask;
185
- async function getExecutorForTask(task, projectGraph) {
186
- const executor = await getExecutorNameForTask(task, projectGraph);
189
+ function getExecutorForTask(task, projectGraph) {
190
+ const executor = getExecutorNameForTask(task, projectGraph);
187
191
  const [nodeModule, executorName] = executor.split(':');
188
192
  return (0, executor_utils_1.getExecutorInformation)(nodeModule, executorName, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects);
189
193
  }
190
194
  exports.getExecutorForTask = getExecutorForTask;
191
- async function getCustomHasher(task, projectGraph) {
192
- const factory = (await getExecutorForTask(task, projectGraph)).hasherFactory;
195
+ function getCustomHasher(task, projectGraph) {
196
+ const factory = getExecutorForTask(task, projectGraph).hasherFactory;
193
197
  return factory ? factory() : null;
194
198
  }
195
199
  exports.getCustomHasher = getCustomHasher;
@@ -27,7 +27,7 @@ function getIgnoredGlobs(root = workspace_root_1.workspaceRoot, prependRoot = tr
27
27
  }
28
28
  exports.getIgnoredGlobs = getIgnoredGlobs;
29
29
  function getAlwaysIgnore(root) {
30
- const paths = ['node_modules', '**/node_modules', '.git'];
30
+ const paths = ['node_modules', '**/node_modules', '.git', '.nx', '.vscode'];
31
31
  return root ? paths.map((x) => (0, path_1.joinPathFragments)(root, x)) : paths;
32
32
  }
33
33
  exports.getAlwaysIgnore = getAlwaysIgnore;
@@ -7,6 +7,5 @@ export declare const logger: {
7
7
  log: (...s: any[]) => void;
8
8
  debug: (...s: any[]) => void;
9
9
  fatal: (...s: any[]) => void;
10
- verbose: (...s: any[]) => void;
11
10
  };
12
11
  export declare function stripIndent(str: string): string;
@@ -34,11 +34,6 @@ exports.logger = {
34
34
  fatal: (...s) => {
35
35
  console.error(...s);
36
36
  },
37
- verbose: (...s) => {
38
- if (process.env.NX_VERBOSE_LOGGING) {
39
- console.log(...s);
40
- }
41
- },
42
37
  };
43
38
  function stripIndent(str) {
44
39
  const match = str.match(/^[ \t]*(?=\S)/gm);
@@ -1,21 +1,25 @@
1
- import { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
2
- import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../../config/project-graph';
3
- import { ProjectConfiguration } from '../../config/workspace-json-project-json';
4
- import { NxJsonConfiguration } from '../../config/nx-json';
5
- import { RawProjectGraphDependency } from '../project-graph-builder';
1
+ import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/project-graph';
2
+ import { PackageJson } from './package-json';
3
+ import { ProjectConfiguration } from '../config/workspace-json-project-json';
4
+ import { NxJsonConfiguration, PluginConfiguration } from '../config/nx-json';
5
+ import { NxPluginV1 } from './nx-plugin.deprecated';
6
+ import { RawProjectGraphDependency } from '../project-graph/project-graph-builder';
6
7
  /**
7
8
  * Context for {@link CreateNodesFunction}
8
9
  */
9
10
  export interface CreateNodesContext {
10
11
  readonly nxJsonConfiguration: NxJsonConfiguration;
11
12
  readonly workspaceRoot: string;
13
+ /**
14
+ * The subset of configuration files which match the createNodes pattern
15
+ */
16
+ readonly configFiles: string[];
12
17
  }
13
18
  /**
14
19
  * A function which parses a configuration file into a set of nodes.
15
20
  * Used for creating nodes for the {@link ProjectGraph}
16
21
  */
17
22
  export type CreateNodesFunction<T = unknown> = (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext) => CreateNodesResult | Promise<CreateNodesResult>;
18
- export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
19
23
  export interface CreateNodesResult {
20
24
  /**
21
25
  * A map of project root -> project configuration
@@ -30,7 +34,7 @@ export interface CreateNodesResult {
30
34
  * A pair of file patterns and {@link CreateNodesFunction}
31
35
  */
32
36
  export type CreateNodes<T = unknown> = readonly [
33
- projectFilePattern: string,
37
+ configFilePattern: string,
34
38
  createNodesFunction: CreateNodesFunction<T>
35
39
  ];
36
40
  /**
@@ -79,7 +83,41 @@ export type NxPluginV2<TOptions = unknown> = {
79
83
  */
80
84
  createDependencies?: CreateDependencies<TOptions>;
81
85
  };
86
+ export * from './nx-plugin.deprecated';
82
87
  /**
83
88
  * A plugin for Nx
84
89
  */
85
90
  export type NxPlugin = NxPluginV1 | NxPluginV2;
91
+ export type LoadedNxPlugin = {
92
+ plugin: NxPluginV2 & Pick<NxPluginV1, 'processProjectGraph'>;
93
+ options?: unknown;
94
+ };
95
+ export declare const nxPluginCache: Map<string, LoadedNxPlugin['plugin']>;
96
+ export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
97
+ pluginPath: string;
98
+ name: any;
99
+ };
100
+ export declare function loadNxPluginAsync(pluginConfiguration: PluginConfiguration, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): Promise<LoadedNxPlugin>;
101
+ export declare function loadNxPlugins(plugins: PluginConfiguration[], paths?: string[], root?: string, projects?: Record<string, ProjectConfiguration>): Promise<LoadedNxPlugin[]>;
102
+ export declare function ensurePluginIsV2(plugin: NxPlugin): NxPluginV2;
103
+ export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
104
+ export declare function isNxPluginV1(plugin: NxPlugin): plugin is NxPluginV1;
105
+ export declare function readPluginPackageJson(pluginName: string, projects: Record<string, ProjectConfiguration>, paths?: string[]): {
106
+ path: string;
107
+ json: PackageJson;
108
+ };
109
+ export declare function resolveLocalNxPlugin(importPath: string, nxJsonConfiguration: NxJsonConfiguration, projects: Record<string, ProjectConfiguration>, root?: string): {
110
+ path: string;
111
+ projectConfig: ProjectConfiguration;
112
+ } | null;
113
+ /**
114
+ * Register swc-node or ts-node if they are not currently registered
115
+ * with some default settings which work well for Nx plugins.
116
+ */
117
+ export declare function registerPluginTSTranspiler(): void;
118
+ /**
119
+ * Unregister the ts-node transpiler if it is registered
120
+ */
121
+ export declare function unregisterPluginTSTranspiler(): void;
122
+ export declare function getDefaultPlugins(root: string): Promise<LoadedNxPlugin[]>;
123
+ type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
@@ -1,6 +1,6 @@
1
1
  import { ProjectGraphProcessor } from '../config/project-graph';
2
2
  import { TargetConfiguration } from '../config/workspace-json-project-json';
3
- import { NxPluginV2 } from '../project-graph/plugins';
3
+ import { LoadedNxPlugin } from './nx-plugin';
4
4
  /**
5
5
  * @deprecated Add targets to the projects in a {@link CreateNodes} function instead. This will be removed in Nx 19
6
6
  */
@@ -28,6 +28,4 @@ export type NxPluginV1 = {
28
28
  /**
29
29
  * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
30
30
  */
31
- export declare function getDefaultPluginsSync(root: string): {
32
- plugin: NxPluginV2;
33
- }[];
31
+ export declare function getDefaultPluginsSync(root: string): LoadedNxPlugin[];
@@ -4,7 +4,7 @@ exports.getDefaultPluginsSync = void 0;
4
4
  const angular_json_1 = require("../adapter/angular-json");
5
5
  const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
6
6
  const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
7
- const PackageJsonWorkspacesPlugin = require("../plugins/package-json-workspaces");
7
+ const package_json_workspaces_1 = require("../plugins/package-json-workspaces");
8
8
  /**
9
9
  * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
10
10
  */
@@ -14,9 +14,9 @@ function getDefaultPluginsSync(root) {
14
14
  ...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
15
15
  ? [require('../adapter/angular-json').NxAngularJsonPlugin]
16
16
  : []),
17
- target_defaults_plugin_1.default,
18
- PackageJsonWorkspacesPlugin,
19
- project_json_1.default,
17
+ target_defaults_plugin_1.TargetDefaultsPlugin,
18
+ (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root),
19
+ project_json_1.ProjectJsonProjectsPlugin,
20
20
  ];
21
21
  return plugins.map((p) => ({
22
22
  plugin: p,