nx 18.1.0-canary.20240309-235ca8c → 18.1.0-canary.20240313-81df848

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 (82) hide show
  1. package/bin/post-install.js +5 -7
  2. package/package.json +12 -12
  3. package/src/adapter/angular-json.d.ts +1 -2
  4. package/src/adapter/angular-json.js +0 -1
  5. package/src/adapter/ngcli-adapter.js +3 -3
  6. package/src/command-line/generate/generator-utils.js +2 -2
  7. package/src/command-line/run/executor-utils.js +2 -2
  8. package/src/config/schema-utils.js +2 -2
  9. package/src/core/graph/3rdpartylicenses.txt +51 -0
  10. package/src/core/graph/main.js +1 -1
  11. package/src/core/graph/polyfills.js +1 -1
  12. package/src/core/graph/runtime.js +1 -1
  13. package/src/core/graph/styles.js +1 -1
  14. package/src/daemon/server/project-graph-incremental-recomputation.js +7 -8
  15. package/src/daemon/server/shutdown-utils.js +0 -2
  16. package/src/devkit-exports.d.ts +1 -2
  17. package/src/executors/run-commands/run-commands.impl.d.ts +3 -0
  18. package/src/executors/run-commands/run-commands.impl.js +77 -38
  19. package/src/executors/utils/convert-nx-executor.js +1 -4
  20. package/src/generators/utils/project-configuration.js +2 -2
  21. package/src/hasher/hash-task.js +2 -2
  22. package/src/migrations/update-15-1-0/set-project-names.js +2 -2
  23. package/src/plugins/js/index.d.ts +1 -1
  24. package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
  25. package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
  26. package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
  27. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  28. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
  29. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
  30. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
  31. package/src/plugins/js/utils/register.js +3 -1
  32. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  33. package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
  34. package/src/plugins/package-json-workspaces/index.d.ts +0 -1
  35. package/src/plugins/package-json-workspaces/index.js +0 -2
  36. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
  37. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
  38. package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
  39. package/src/plugins/project-json/build-nodes/project-json.js +0 -1
  40. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
  41. package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
  42. package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
  43. package/src/project-graph/build-project-graph.d.ts +1 -2
  44. package/src/project-graph/build-project-graph.js +13 -12
  45. package/src/project-graph/file-utils.js +3 -3
  46. package/src/project-graph/project-graph-builder.d.ts +1 -1
  47. package/src/project-graph/project-graph.js +15 -19
  48. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  49. package/src/project-graph/utils/project-configuration-utils.d.ts +2 -2
  50. package/src/project-graph/utils/project-configuration-utils.js +55 -11
  51. package/src/project-graph/utils/retrieve-workspace-files.d.ts +8 -6
  52. package/src/project-graph/utils/retrieve-workspace-files.js +21 -18
  53. package/src/tasks-runner/task-orchestrator.js +45 -8
  54. package/src/tasks-runner/tasks-schedule.js +3 -3
  55. package/src/tasks-runner/utils.d.ts +7 -6
  56. package/src/tasks-runner/utils.js +11 -7
  57. package/src/utils/logger.d.ts +0 -1
  58. package/src/utils/logger.js +0 -5
  59. package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +41 -7
  60. package/src/utils/nx-plugin.deprecated.d.ts +2 -4
  61. package/src/utils/nx-plugin.deprecated.js +4 -4
  62. package/src/utils/nx-plugin.js +293 -0
  63. package/src/utils/output.js +1 -1
  64. package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
  65. package/src/utils/plugins/plugin-capabilities.js +9 -10
  66. package/src/daemon/server/plugins.d.ts +0 -3
  67. package/src/daemon/server/plugins.js +0 -22
  68. package/src/project-graph/plugins/index.d.ts +0 -2
  69. package/src/project-graph/plugins/index.js +0 -8
  70. package/src/project-graph/plugins/internal-api.d.ts +0 -22
  71. package/src/project-graph/plugins/internal-api.js +0 -64
  72. package/src/project-graph/plugins/messaging.d.ts +0 -94
  73. package/src/project-graph/plugins/messaging.js +0 -23
  74. package/src/project-graph/plugins/plugin-pool.d.ts +0 -3
  75. package/src/project-graph/plugins/plugin-pool.js +0 -189
  76. package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
  77. package/src/project-graph/plugins/plugin-worker.js +0 -101
  78. package/src/project-graph/plugins/public-api.js +0 -4
  79. package/src/project-graph/plugins/utils.d.ts +0 -9
  80. package/src/project-graph/plugins/utils.js +0 -55
  81. package/src/project-graph/plugins/worker-api.d.ts +0 -28
  82. package/src/project-graph/plugins/worker-api.js +0 -195
@@ -1,64 +0,0 @@
1
- "use strict";
2
- // This file contains the bits and bobs of the internal API for loading and interacting with Nx plugins.
3
- // For the public API, used by plugin authors, see `./public-api.ts`.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getDefaultPlugins = exports.loadNxPluginInIsolation = exports.loadNxPluginsInIsolation = exports.nxPluginCache = exports.loadPlugin = exports.loadPlugins = void 0;
6
- const path_1 = require("path");
7
- const workspace_root_1 = require("../../utils/workspace-root");
8
- const angular_json_1 = require("../../adapter/angular-json");
9
- const plugin_pool_1 = require("./plugin-pool");
10
- var worker_api_1 = require("./worker-api");
11
- Object.defineProperty(exports, "loadPlugins", { enumerable: true, get: function () { return worker_api_1.loadPlugins; } });
12
- Object.defineProperty(exports, "loadPlugin", { enumerable: true, get: function () { return worker_api_1.loadPlugin; } });
13
- // Short lived cache (cleared between cmd runs)
14
- // holding resolved nx plugin objects.
15
- // Allows loaded plugins to not be reloaded when
16
- // referenced multiple times.
17
- exports.nxPluginCache = new Map();
18
- /**
19
- * This loads plugins in isolation in their own worker so that they do not disturb other workers or the main process.
20
- */
21
- async function loadNxPluginsInIsolation(plugins, root = workspace_root_1.workspaceRoot) {
22
- const result = [];
23
- plugins ??= [];
24
- plugins.unshift((0, path_1.join)(__dirname, '../../plugins/project-json/build-nodes/package-json-next-to-project-json'));
25
- // We push the nx core node plugins onto the end, s.t. it overwrites any other plugins
26
- plugins.push(...(await getDefaultPlugins(root)));
27
- const cleanupFunctions = [];
28
- for (const plugin of plugins) {
29
- const [loadedPluginPromise, cleanup] = loadNxPluginInIsolation(plugin, root);
30
- result.push(loadedPluginPromise);
31
- cleanupFunctions.push(cleanup);
32
- }
33
- return [
34
- await Promise.all(result),
35
- () => {
36
- for (const fn of cleanupFunctions) {
37
- fn();
38
- }
39
- },
40
- ];
41
- }
42
- exports.loadNxPluginsInIsolation = loadNxPluginsInIsolation;
43
- function loadNxPluginInIsolation(plugin, root = workspace_root_1.workspaceRoot) {
44
- const cacheKey = JSON.stringify(plugin);
45
- if (exports.nxPluginCache.has(cacheKey)) {
46
- return exports.nxPluginCache.get(cacheKey);
47
- }
48
- const [loadingPlugin, cleanup] = (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root);
49
- exports.nxPluginCache.set(cacheKey, [loadingPlugin, cleanup]);
50
- return [loadingPlugin, cleanup];
51
- }
52
- exports.loadNxPluginInIsolation = loadNxPluginInIsolation;
53
- async function getDefaultPlugins(root) {
54
- return [
55
- (0, path_1.join)(__dirname, '../../plugins/js'),
56
- (0, path_1.join)(__dirname, '../../plugins/target-defaults/target-defaults-plugin'),
57
- ...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
58
- ? [(0, path_1.join)(__dirname, '../../adapter/angular-json')]
59
- : []),
60
- (0, path_1.join)(__dirname, '../../plugins/package-json-workspaces'),
61
- (0, path_1.join)(__dirname, '../../plugins/project-json/build-nodes/project-json'),
62
- ];
63
- }
64
- exports.getDefaultPlugins = getDefaultPlugins;
@@ -1,94 +0,0 @@
1
- import { ProjectGraph, ProjectGraphProcessorContext } from '../../config/project-graph';
2
- import { PluginConfiguration } from '../../config/nx-json';
3
- import { CreateDependenciesContext, CreateNodesContext } from './public-api';
4
- import { RemotePlugin } from './internal-api';
5
- export interface PluginWorkerLoadMessage {
6
- type: 'load';
7
- payload: {
8
- plugin: PluginConfiguration;
9
- root: string;
10
- };
11
- }
12
- export interface PluginWorkerLoadResult {
13
- type: 'load-result';
14
- payload: {
15
- name: string;
16
- createNodesPattern: string;
17
- hasCreateDependencies: boolean;
18
- hasProcessProjectGraph: boolean;
19
- success: true;
20
- } | {
21
- success: false;
22
- error: string;
23
- };
24
- }
25
- export interface PluginWorkerCreateNodesMessage {
26
- type: 'createNodes';
27
- payload: {
28
- configFiles: string[];
29
- context: CreateNodesContext;
30
- tx: string;
31
- };
32
- }
33
- export interface PluginWorkerCreateNodesResult {
34
- type: 'createNodesResult';
35
- payload: {
36
- success: true;
37
- result: Awaited<ReturnType<RemotePlugin['createNodes'][1]>>;
38
- tx: string;
39
- } | {
40
- success: false;
41
- error: string;
42
- tx: string;
43
- };
44
- }
45
- export interface PluginCreateDependenciesMessage {
46
- type: 'createDependencies';
47
- payload: {
48
- context: CreateDependenciesContext;
49
- tx: string;
50
- };
51
- }
52
- export interface PluginCreateDependenciesResult {
53
- type: 'createDependenciesResult';
54
- payload: {
55
- dependencies: ReturnType<RemotePlugin['createDependencies']>;
56
- success: true;
57
- tx: string;
58
- } | {
59
- success: false;
60
- error: string;
61
- tx: string;
62
- };
63
- }
64
- export interface PluginWorkerProcessProjectGraphMessage {
65
- type: 'processProjectGraph';
66
- payload: {
67
- graph: ProjectGraph;
68
- ctx: ProjectGraphProcessorContext;
69
- tx: string;
70
- };
71
- }
72
- export interface PluginWorkerProcessProjectGraphResult {
73
- type: 'processProjectGraphResult';
74
- payload: {
75
- graph: ProjectGraph;
76
- success: true;
77
- tx: string;
78
- } | {
79
- success: false;
80
- error: string;
81
- tx: string;
82
- };
83
- }
84
- export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginWorkerProcessProjectGraphMessage;
85
- export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginWorkerProcessProjectGraphResult;
86
- type MaybePromise<T> = T | Promise<T>;
87
- type MessageHandlerReturn<T extends PluginWorkerMessage | PluginWorkerResult> = T extends PluginWorkerResult ? MaybePromise<PluginWorkerMessage | void> : MaybePromise<PluginWorkerResult | void>;
88
- export declare function consumeMessage<T extends PluginWorkerMessage | PluginWorkerResult>(raw: string | T, handlers: {
89
- [K in T['type']]: (payload: Extract<T, {
90
- type: K;
91
- }>['payload']) => MessageHandlerReturn<T>;
92
- }): Promise<void>;
93
- export declare function createMessage(message: PluginWorkerMessage | PluginWorkerResult): string;
94
- export {};
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMessage = exports.consumeMessage = void 0;
4
- // Takes a message and a map of handlers and calls the appropriate handler
5
- // type safe and requires all handlers to be handled
6
- async function consumeMessage(raw, handlers) {
7
- const message = typeof raw === 'string' ? JSON.parse(raw) : raw;
8
- const handler = handlers[message.type];
9
- if (handler) {
10
- const response = await handler(message.payload);
11
- if (response) {
12
- process.send(createMessage(response));
13
- }
14
- }
15
- else {
16
- throw new Error(`Unhandled message type: ${message.type}`);
17
- }
18
- }
19
- exports.consumeMessage = consumeMessage;
20
- function createMessage(message) {
21
- return JSON.stringify(message);
22
- }
23
- exports.createMessage = createMessage;
@@ -1,3 +0,0 @@
1
- import { PluginConfiguration } from '../../config/nx-json';
2
- import { RemotePlugin } from './internal-api';
3
- export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): readonly [Promise<RemotePlugin>, () => void];
@@ -1,189 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadRemoteNxPlugin = void 0;
4
- const child_process_1 = require("child_process");
5
- const path = require("path");
6
- // TODO (@AgentEnder): After scoped verbose logging is implemented, re-add verbose logs here.
7
- // import { logger } from '../../utils/logger';
8
- const internal_api_1 = require("./internal-api");
9
- const messaging_1 = require("./messaging");
10
- const cleanupFunctions = new Set();
11
- const pluginNames = new Map();
12
- function loadRemoteNxPlugin(plugin, root) {
13
- // this should only really be true when running unit tests within
14
- // the Nx repo. We still need to start the worker in this case,
15
- // but its typescript.
16
- const isWorkerTypescript = path.extname(__filename) === '.ts';
17
- const workerPath = path.join(__dirname, 'plugin-worker');
18
- const worker = (0, child_process_1.fork)(workerPath, [], {
19
- stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
20
- env: {
21
- ...process.env,
22
- ...(isWorkerTypescript
23
- ? {
24
- // Ensures that the worker uses the same tsconfig as the main process
25
- TS_NODE_PROJECT: path.join(__dirname, '../../../tsconfig.lib.json'),
26
- }
27
- : {}),
28
- },
29
- execArgv: [
30
- ...process.execArgv,
31
- // If the worker is typescript, we need to register ts-node
32
- ...(isWorkerTypescript ? ['-r', 'ts-node/register'] : []),
33
- ],
34
- });
35
- worker.send((0, messaging_1.createMessage)({ type: 'load', payload: { plugin, root } }));
36
- // logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
37
- const pendingPromises = new Map();
38
- const exitHandler = createWorkerExitHandler(worker, pendingPromises);
39
- const cleanupFunction = () => {
40
- worker.off('exit', exitHandler);
41
- shutdownPluginWorker(worker, pendingPromises);
42
- };
43
- cleanupFunctions.add(cleanupFunction);
44
- return [
45
- new Promise((res, rej) => {
46
- worker.on('message', createWorkerHandler(worker, pendingPromises, res, rej));
47
- worker.on('exit', exitHandler);
48
- }),
49
- () => {
50
- cleanupFunction();
51
- cleanupFunctions.delete(cleanupFunction);
52
- },
53
- ];
54
- }
55
- exports.loadRemoteNxPlugin = loadRemoteNxPlugin;
56
- async function shutdownPluginWorker(worker, pendingPromises) {
57
- // Clears the plugin cache so no refs to the workers are held
58
- internal_api_1.nxPluginCache.clear();
59
- // logger.verbose(`[plugin-pool] starting worker shutdown`);
60
- // Other things may be interacting with the worker.
61
- // Wait for all pending promises to be done before killing the worker
62
- await Promise.all(Array.from(pendingPromises.values()).map(({ promise }) => promise));
63
- worker.kill('SIGINT');
64
- }
65
- /**
66
- * Creates a message handler for the given worker.
67
- * @param worker Instance of plugin-worker
68
- * @param pending Set of pending promises
69
- * @param onload Resolver for RemotePlugin promise
70
- * @param onloadError Rejecter for RemotePlugin promise
71
- * @returns Function to handle messages from the worker
72
- */
73
- function createWorkerHandler(worker, pending, onload, onloadError) {
74
- let pluginName;
75
- return function (message) {
76
- const parsed = JSON.parse(message);
77
- // logger.verbose(
78
- // `[plugin-pool] received message: ${parsed.type} from ${
79
- // pluginName ?? worker.pid
80
- // }`
81
- // );
82
- (0, messaging_1.consumeMessage)(parsed, {
83
- 'load-result': (result) => {
84
- if (result.success) {
85
- const { name, createNodesPattern } = result;
86
- pluginName = name;
87
- pluginNames.set(worker, pluginName);
88
- onload({
89
- name,
90
- createNodes: createNodesPattern
91
- ? [
92
- createNodesPattern,
93
- (configFiles, ctx) => {
94
- const tx = pluginName + ':createNodes:' + performance.now();
95
- return registerPendingPromise(tx, pending, () => {
96
- worker.send((0, messaging_1.createMessage)({
97
- type: 'createNodes',
98
- payload: { configFiles, context: ctx, tx },
99
- }));
100
- });
101
- },
102
- ]
103
- : undefined,
104
- createDependencies: result.hasCreateDependencies
105
- ? (opts, ctx) => {
106
- const tx = pluginName + ':createDependencies:' + performance.now();
107
- return registerPendingPromise(tx, pending, () => {
108
- worker.send((0, messaging_1.createMessage)({
109
- type: 'createDependencies',
110
- payload: { context: ctx, tx },
111
- }));
112
- });
113
- }
114
- : undefined,
115
- processProjectGraph: result.hasProcessProjectGraph
116
- ? (graph, ctx) => {
117
- const tx = pluginName + ':processProjectGraph:' + performance.now();
118
- return registerPendingPromise(tx, pending, () => {
119
- worker.send((0, messaging_1.createMessage)({
120
- type: 'processProjectGraph',
121
- payload: { graph, ctx, tx },
122
- }));
123
- });
124
- }
125
- : undefined,
126
- });
127
- }
128
- else if (result.success === false) {
129
- onloadError(result.error);
130
- }
131
- },
132
- createDependenciesResult: ({ tx, ...result }) => {
133
- const { resolver, rejector } = pending.get(tx);
134
- if (result.success) {
135
- resolver(result.dependencies);
136
- }
137
- else if (result.success === false) {
138
- rejector(result.error);
139
- }
140
- },
141
- createNodesResult: ({ tx, ...result }) => {
142
- const { resolver, rejector } = pending.get(tx);
143
- if (result.success) {
144
- resolver(result.result);
145
- }
146
- else if (result.success === false) {
147
- rejector(result.error);
148
- }
149
- },
150
- processProjectGraphResult: ({ tx, ...result }) => {
151
- const { resolver, rejector } = pending.get(tx);
152
- if (result.success) {
153
- resolver(result.graph);
154
- }
155
- else if (result.success === false) {
156
- rejector(result.error);
157
- }
158
- },
159
- });
160
- };
161
- }
162
- function createWorkerExitHandler(worker, pendingPromises) {
163
- return () => {
164
- for (const [_, pendingPromise] of pendingPromises) {
165
- pendingPromise.rejector(new Error(`Plugin worker ${pluginNames.get(worker) ?? worker.pid} exited unexpectedly with code ${worker.exitCode}`));
166
- }
167
- };
168
- }
169
- process.on('exit', () => {
170
- for (const fn of cleanupFunctions) {
171
- fn();
172
- }
173
- });
174
- function registerPendingPromise(tx, pending, callback) {
175
- let resolver, rejector;
176
- const promise = new Promise((res, rej) => {
177
- resolver = res;
178
- rejector = rej;
179
- callback();
180
- }).finally(() => {
181
- pending.delete(tx);
182
- });
183
- pending.set(tx, {
184
- promise,
185
- resolver,
186
- rejector,
187
- });
188
- return promise;
189
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const messaging_1 = require("./messaging");
4
- const utils_1 = require("./utils");
5
- const worker_api_1 = require("./worker-api");
6
- global.NX_GRAPH_CREATION = true;
7
- let plugin;
8
- let pluginOptions;
9
- process.on('message', async (message) => {
10
- (0, messaging_1.consumeMessage)(message, {
11
- load: async ({ plugin: pluginConfiguration, root }) => {
12
- process.chdir(root);
13
- try {
14
- ({ plugin, options: pluginOptions } = await (0, worker_api_1.loadPlugin)(pluginConfiguration, root));
15
- return {
16
- type: 'load-result',
17
- payload: {
18
- name: plugin.name,
19
- createNodesPattern: plugin.createNodes?.[0],
20
- hasCreateDependencies: 'createDependencies' in plugin && !!plugin.createDependencies,
21
- hasProcessProjectGraph: 'processProjectGraph' in plugin && !!plugin.processProjectGraph,
22
- success: true,
23
- },
24
- };
25
- }
26
- catch (e) {
27
- return {
28
- type: 'load-result',
29
- payload: {
30
- success: false,
31
- error: `Could not load plugin ${plugin} \n ${e instanceof Error ? e.stack : ''}`,
32
- },
33
- };
34
- }
35
- },
36
- createNodes: async ({ configFiles, context, tx }) => {
37
- try {
38
- const result = await runCreateNodesInParallel(configFiles, context);
39
- return {
40
- type: 'createNodesResult',
41
- payload: { result, success: true, tx },
42
- };
43
- }
44
- catch (e) {
45
- return {
46
- type: 'createNodesResult',
47
- payload: { success: false, error: e.stack, tx },
48
- };
49
- }
50
- },
51
- createDependencies: async ({ context, tx }) => {
52
- try {
53
- const result = await plugin.createDependencies(pluginOptions, context);
54
- return {
55
- type: 'createDependenciesResult',
56
- payload: { dependencies: result, success: true, tx },
57
- };
58
- }
59
- catch (e) {
60
- return {
61
- type: 'createDependenciesResult',
62
- payload: { success: false, error: e.stack, tx },
63
- };
64
- }
65
- },
66
- processProjectGraph: async ({ graph, ctx, tx }) => {
67
- try {
68
- const result = await plugin.processProjectGraph(graph, ctx);
69
- return {
70
- type: 'processProjectGraphResult',
71
- payload: { graph: result, success: true, tx },
72
- };
73
- }
74
- catch (e) {
75
- return {
76
- type: 'processProjectGraphResult',
77
- payload: { success: false, error: e.stack, tx },
78
- };
79
- }
80
- },
81
- });
82
- });
83
- function runCreateNodesInParallel(configFiles, context) {
84
- const promises = configFiles.map((file) => {
85
- performance.mark(`${plugin.name}:createNodes:${file} - start`);
86
- // Result is either static or a promise, using Promise.resolve lets us
87
- // handle both cases with same logic
88
- const value = Promise.resolve(plugin.createNodes[1](file, pluginOptions, context));
89
- return value
90
- .catch((e) => {
91
- performance.mark(`${plugin.name}:createNodes:${file} - end`);
92
- throw new utils_1.CreateNodesError(`Unable to create nodes for ${file} using plugin ${plugin.name}.`, e);
93
- })
94
- .then((r) => {
95
- performance.mark(`${plugin.name}:createNodes:${file} - end`);
96
- performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
97
- return { ...r, pluginName: plugin.name, file };
98
- });
99
- });
100
- return Promise.all(promises);
101
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- // This file represents the public API for plugins which live in nx.json's plugins array.
3
- // For methods to interact with plugins from within Nx, see `./internal-api.ts`.
4
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import type { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
2
- import type { NormalizedPlugin, RemotePlugin } from './internal-api';
3
- import type { NxPlugin, NxPluginV2 } from './public-api';
4
- export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
5
- export declare function isNxPluginV1(plugin: NxPlugin | RemotePlugin): plugin is NxPluginV1;
6
- export declare function normalizeNxPlugin(plugin: NxPlugin): NormalizedPlugin;
7
- export declare class CreateNodesError extends Error {
8
- constructor(msg: any, cause: Error | unknown);
9
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CreateNodesError = exports.normalizeNxPlugin = exports.isNxPluginV1 = exports.isNxPluginV2 = void 0;
4
- const node_path_1 = require("node:path");
5
- const workspaces_1 = require("../../config/workspaces");
6
- const globs_1 = require("../../utils/globs");
7
- function isNxPluginV2(plugin) {
8
- return 'createNodes' in plugin || 'createDependencies' in plugin;
9
- }
10
- exports.isNxPluginV2 = isNxPluginV2;
11
- function isNxPluginV1(plugin) {
12
- return 'processProjectGraph' in plugin || 'projectFilePatterns' in plugin;
13
- }
14
- exports.isNxPluginV1 = isNxPluginV1;
15
- function normalizeNxPlugin(plugin) {
16
- if (isNxPluginV2(plugin)) {
17
- return plugin;
18
- }
19
- if (isNxPluginV1(plugin) && plugin.projectFilePatterns) {
20
- return {
21
- ...plugin,
22
- createNodes: [
23
- `*/**/${(0, globs_1.combineGlobPatterns)(plugin.projectFilePatterns)}`,
24
- (configFilePath) => {
25
- const root = (0, node_path_1.dirname)(configFilePath);
26
- return {
27
- projects: {
28
- [root]: {
29
- name: (0, workspaces_1.toProjectName)(configFilePath),
30
- targets: plugin.registerProjectTargets?.(configFilePath),
31
- },
32
- },
33
- };
34
- },
35
- ],
36
- };
37
- }
38
- return plugin;
39
- }
40
- exports.normalizeNxPlugin = normalizeNxPlugin;
41
- class CreateNodesError extends Error {
42
- constructor(msg, cause) {
43
- const message = `${msg} ${!cause
44
- ? ''
45
- : cause instanceof Error
46
- ? `\n\n\t Inner Error: ${cause.stack}`
47
- : cause}`;
48
- // These errors are thrown during a JS callback which is invoked via rust.
49
- // The errors messaging gets lost in the rust -> js -> rust transition, but
50
- // logging the error here will ensure that it is visible in the console.
51
- console.error(message);
52
- super(message, { cause });
53
- }
54
- }
55
- exports.CreateNodesError = CreateNodesError;
@@ -1,28 +0,0 @@
1
- import { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
- import { PackageJson } from '../../utils/package-json';
3
- import { NxPlugin } from './public-api';
4
- import { PluginConfiguration } from '../../config/nx-json';
5
- export declare function readPluginPackageJson(pluginName: string, projects: Record<string, ProjectConfiguration>, paths?: string[]): {
6
- path: string;
7
- json: PackageJson;
8
- };
9
- export declare function resolveLocalNxPlugin(importPath: string, projects: Record<string, ProjectConfiguration>, root?: string): {
10
- path: string;
11
- projectConfig: ProjectConfiguration;
12
- } | null;
13
- /**
14
- * Register swc-node or ts-node if they are not currently registered
15
- * with some default settings which work well for Nx plugins.
16
- */
17
- export declare function registerPluginTSTranspiler(): void;
18
- export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
19
- pluginPath: string;
20
- name: any;
21
- };
22
- export declare function loadPlugins(plugins: PluginConfiguration[], root: string): Promise<LoadedNxPlugin[]>;
23
- export declare function loadPlugin(plugin: PluginConfiguration, root: string): Promise<LoadedNxPlugin>;
24
- export type LoadedNxPlugin = {
25
- plugin: NxPlugin;
26
- options?: unknown;
27
- };
28
- export declare function loadNxPluginAsync(pluginConfiguration: PluginConfiguration, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): Promise<LoadedNxPlugin>;