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.
- package/bin/post-install.js +5 -7
- package/package.json +12 -12
- package/src/adapter/angular-json.d.ts +1 -2
- package/src/adapter/angular-json.js +0 -1
- package/src/adapter/ngcli-adapter.js +3 -3
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/config/schema-utils.js +2 -2
- package/src/core/graph/3rdpartylicenses.txt +51 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +7 -8
- package/src/daemon/server/shutdown-utils.js +0 -2
- package/src/devkit-exports.d.ts +1 -2
- package/src/executors/run-commands/run-commands.impl.d.ts +3 -0
- package/src/executors/run-commands/run-commands.impl.js +77 -38
- package/src/executors/utils/convert-nx-executor.js +1 -4
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/hasher/hash-task.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +2 -2
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/js/utils/register.js +3 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
- package/src/plugins/package-json-workspaces/index.d.ts +0 -1
- package/src/plugins/package-json-workspaces/index.js +0 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
- package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/project-json.js +0 -1
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
- package/src/project-graph/build-project-graph.d.ts +1 -2
- package/src/project-graph/build-project-graph.js +13 -12
- package/src/project-graph/file-utils.js +3 -3
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.js +15 -19
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +2 -2
- package/src/project-graph/utils/project-configuration-utils.js +55 -11
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +8 -6
- package/src/project-graph/utils/retrieve-workspace-files.js +21 -18
- package/src/tasks-runner/task-orchestrator.js +45 -8
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +7 -6
- package/src/tasks-runner/utils.js +11 -7
- package/src/utils/logger.d.ts +0 -1
- package/src/utils/logger.js +0 -5
- package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +41 -7
- package/src/utils/nx-plugin.deprecated.d.ts +2 -4
- package/src/utils/nx-plugin.deprecated.js +4 -4
- package/src/utils/nx-plugin.js +293 -0
- package/src/utils/output.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +9 -10
- package/src/daemon/server/plugins.d.ts +0 -3
- package/src/daemon/server/plugins.js +0 -22
- package/src/project-graph/plugins/index.d.ts +0 -2
- package/src/project-graph/plugins/index.js +0 -8
- package/src/project-graph/plugins/internal-api.d.ts +0 -22
- package/src/project-graph/plugins/internal-api.js +0 -64
- package/src/project-graph/plugins/messaging.d.ts +0 -94
- package/src/project-graph/plugins/messaging.js +0 -23
- package/src/project-graph/plugins/plugin-pool.d.ts +0 -3
- package/src/project-graph/plugins/plugin-pool.js +0 -189
- package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
- package/src/project-graph/plugins/plugin-worker.js +0 -101
- package/src/project-graph/plugins/public-api.js +0 -4
- package/src/project-graph/plugins/utils.d.ts +0 -9
- package/src/project-graph/plugins/utils.js +0 -55
- package/src/project-graph/plugins/worker-api.d.ts +0 -28
- package/src/project-graph/plugins/worker-api.js +0 -195
@@ -1 +1 @@
|
|
1
|
-
(()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={
|
1
|
+
(()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={2:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[l,a,u]=t,d=0;if(l.some((r=>0!==e[r]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(u)var f=u(o)}for(r&&r(t);d<l.length;d++)i=l[d],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(f)},t=self.webpackChunk=self.webpackChunk||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();
|
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3],{22232:(s,e,k)=>{k.r(e)}},s=>{var e;e=22232,s(s.s=e)}]);
|
@@ -13,7 +13,6 @@ const workspace_context_1 = require("../../utils/workspace-context");
|
|
13
13
|
const workspace_root_1 = require("../../utils/workspace-root");
|
14
14
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
15
15
|
const logger_1 = require("./logger");
|
16
|
-
const plugins_1 = require("./plugins");
|
17
16
|
let cachedSerializedProjectGraphPromise;
|
18
17
|
const collectedUpdatedFiles = new Set();
|
19
18
|
const collectedDeletedFiles = new Set();
|
@@ -31,16 +30,15 @@ async function getCachedSerializedProjectGraphPromise() {
|
|
31
30
|
// reset the wait time
|
32
31
|
waitPeriod = 100;
|
33
32
|
await resetInternalStateIfNxDepsMissing();
|
34
|
-
const plugins = await (0, plugins_1.getPlugins)();
|
35
33
|
if (collectedUpdatedFiles.size == 0 && collectedDeletedFiles.size == 0) {
|
36
34
|
if (!cachedSerializedProjectGraphPromise) {
|
37
35
|
cachedSerializedProjectGraphPromise =
|
38
|
-
processFilesAndCreateAndSerializeProjectGraph(
|
36
|
+
processFilesAndCreateAndSerializeProjectGraph();
|
39
37
|
}
|
40
38
|
}
|
41
39
|
else {
|
42
40
|
cachedSerializedProjectGraphPromise =
|
43
|
-
processFilesAndCreateAndSerializeProjectGraph(
|
41
|
+
processFilesAndCreateAndSerializeProjectGraph();
|
44
42
|
}
|
45
43
|
return await cachedSerializedProjectGraphPromise;
|
46
44
|
}
|
@@ -79,7 +77,7 @@ function addUpdatedAndDeletedFiles(createdFiles, updatedFiles, deletedFiles) {
|
|
79
77
|
waitPeriod = waitPeriod * 2;
|
80
78
|
}
|
81
79
|
cachedSerializedProjectGraphPromise =
|
82
|
-
processFilesAndCreateAndSerializeProjectGraph(
|
80
|
+
processFilesAndCreateAndSerializeProjectGraph();
|
83
81
|
await cachedSerializedProjectGraphPromise;
|
84
82
|
if (createdFiles.length > 0) {
|
85
83
|
(0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFiles, null, null);
|
@@ -127,7 +125,7 @@ async function processCollectedUpdatedAndDeletedFiles({ projects, externalNodes,
|
|
127
125
|
throw e;
|
128
126
|
}
|
129
127
|
}
|
130
|
-
async function processFilesAndCreateAndSerializeProjectGraph(
|
128
|
+
async function processFilesAndCreateAndSerializeProjectGraph() {
|
131
129
|
try {
|
132
130
|
perf_hooks_1.performance.mark('hash-watched-changes-start');
|
133
131
|
const updatedFiles = [...collectedUpdatedFiles.values()];
|
@@ -139,8 +137,9 @@ async function processFilesAndCreateAndSerializeProjectGraph(plugins) {
|
|
139
137
|
logger_1.serverLogger.requestLog([...updatedFiles.values()]);
|
140
138
|
logger_1.serverLogger.requestLog([...deletedFiles]);
|
141
139
|
const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
|
140
|
+
// Set this globally to allow plugins to know if they are being called from the project graph creation
|
142
141
|
global.NX_GRAPH_CREATION = true;
|
143
|
-
const graphNodes = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(
|
142
|
+
const graphNodes = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
|
144
143
|
await processCollectedUpdatedAndDeletedFiles(graphNodes, updatedFileHashes, deletedFiles);
|
145
144
|
const g = createAndSerializeProjectGraph(graphNodes);
|
146
145
|
delete global.NX_GRAPH_CREATION;
|
@@ -177,7 +176,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
|
|
177
176
|
const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
|
178
177
|
const allWorkspaceFiles = copyFileData(exports.fileMapWithFiles.allWorkspaceFiles);
|
179
178
|
const rustReferences = exports.fileMapWithFiles.rustReferences;
|
180
|
-
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), true
|
179
|
+
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), true);
|
181
180
|
exports.currentProjectFileMapCache = projectFileMapCache;
|
182
181
|
exports.currentProjectGraph = projectGraph;
|
183
182
|
perf_hooks_1.performance.mark('create-project-graph-end');
|
@@ -5,7 +5,6 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
5
5
|
const logger_1 = require("./logger");
|
6
6
|
const socket_utils_1 = require("../socket-utils");
|
7
7
|
const cache_1 = require("../cache");
|
8
|
-
const plugins_1 = require("./plugins");
|
9
8
|
exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
|
10
9
|
let watcherInstance;
|
11
10
|
function storeWatcherInstance(instance) {
|
@@ -29,7 +28,6 @@ async function handleServerProcessTermination({ server, reason, }) {
|
|
29
28
|
try {
|
30
29
|
server.close();
|
31
30
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
32
|
-
(0, plugins_1.cleanupPlugins)();
|
33
31
|
if (watcherInstance) {
|
34
32
|
await watcherInstance.stop();
|
35
33
|
logger_1.serverLogger.watcherLog(`Stopping the watcher for ${workspace_root_1.workspaceRoot} (sources)`);
|
package/src/devkit-exports.d.ts
CHANGED
@@ -19,8 +19,7 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
|
|
19
19
|
*/
|
20
20
|
export { Workspaces } from './config/workspaces';
|
21
21
|
export { workspaceLayout } from './config/configuration';
|
22
|
-
export type { NxPlugin, NxPluginV2, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './
|
23
|
-
export type { NxPluginV1, ProjectTargetConfigurator, } from './utils/nx-plugin.deprecated';
|
22
|
+
export type { NxPlugin, NxPluginV1, NxPluginV2, ProjectTargetConfigurator, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './utils/nx-plugin';
|
24
23
|
/**
|
25
24
|
* @category Workspace
|
26
25
|
*/
|
@@ -25,6 +25,8 @@ export interface RunCommandsOptions extends Json {
|
|
25
25
|
args?: string | string[];
|
26
26
|
envFile?: string;
|
27
27
|
__unparsed__: string[];
|
28
|
+
usePty?: boolean;
|
29
|
+
streamOutput?: boolean;
|
28
30
|
}
|
29
31
|
export interface NormalizedRunCommandsOptions extends RunCommandsOptions {
|
30
32
|
commands: {
|
@@ -41,5 +43,6 @@ export interface NormalizedRunCommandsOptions extends RunCommandsOptions {
|
|
41
43
|
}
|
42
44
|
export default function (options: RunCommandsOptions, context: ExecutorContext): Promise<{
|
43
45
|
success: boolean;
|
46
|
+
terminalOutput: string;
|
44
47
|
}>;
|
45
48
|
export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions'>, forwardAllArgs: boolean): string;
|
@@ -34,7 +34,8 @@ const propKeys = [
|
|
34
34
|
'envFile',
|
35
35
|
'__unparsed__',
|
36
36
|
'env',
|
37
|
-
'
|
37
|
+
'usePty',
|
38
|
+
'streamOutput',
|
38
39
|
'verbose',
|
39
40
|
];
|
40
41
|
async function default_1(options, context) {
|
@@ -48,10 +49,10 @@ async function default_1(options, context) {
|
|
48
49
|
throw new Error('ERROR: Bad executor config for run-commands - "prefix", "color" and "bgColor" can only be set when "parallel=true".');
|
49
50
|
}
|
50
51
|
try {
|
51
|
-
const
|
52
|
+
const result = options.parallel
|
52
53
|
? await runInParallel(normalized, context)
|
53
54
|
: await runSerially(normalized, context);
|
54
|
-
return
|
55
|
+
return result;
|
55
56
|
}
|
56
57
|
catch (e) {
|
57
58
|
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
@@ -62,31 +63,48 @@ async function default_1(options, context) {
|
|
62
63
|
}
|
63
64
|
exports.default = default_1;
|
64
65
|
async function runInParallel(options, context) {
|
65
|
-
const procs = options.commands.map((c) => createProcess(c, options.readyWhen, options.color, calculateCwd(options.cwd, context), options.env ?? {}, true).then((result) => ({
|
66
|
+
const procs = options.commands.map((c) => createProcess(c, options.readyWhen, options.color, calculateCwd(options.cwd, context), options.env ?? {}, true, options.usePty, options.streamOutput).then((result) => ({
|
66
67
|
result,
|
67
68
|
command: c.command,
|
68
69
|
})));
|
70
|
+
let terminalOutput = '';
|
69
71
|
if (options.readyWhen) {
|
70
72
|
const r = await Promise.race(procs);
|
71
|
-
|
72
|
-
|
73
|
-
|
73
|
+
terminalOutput += r.result.terminalOutput;
|
74
|
+
if (!r.result.success) {
|
75
|
+
const output = `Warning: command "${r.command}" exited with non-zero status code`;
|
76
|
+
terminalOutput += output;
|
77
|
+
if (options.streamOutput) {
|
78
|
+
process.stderr.write(output);
|
79
|
+
}
|
80
|
+
return { success: false, terminalOutput };
|
74
81
|
}
|
75
82
|
else {
|
76
|
-
return true;
|
83
|
+
return { success: true, terminalOutput };
|
77
84
|
}
|
78
85
|
}
|
79
86
|
else {
|
80
87
|
const r = await Promise.all(procs);
|
81
|
-
|
88
|
+
terminalOutput += r.map((f) => f.result.terminalOutput).join('');
|
89
|
+
const failed = r.filter((v) => !v.result.success);
|
82
90
|
if (failed.length > 0) {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
91
|
+
const output = failed
|
92
|
+
.map((f) => `Warning: command "${f.command}" exited with non-zero status code`)
|
93
|
+
.join('\r\n');
|
94
|
+
terminalOutput += output;
|
95
|
+
if (options.streamOutput) {
|
96
|
+
process.stderr.write(output);
|
97
|
+
}
|
98
|
+
return {
|
99
|
+
success: false,
|
100
|
+
terminalOutput,
|
101
|
+
};
|
87
102
|
}
|
88
103
|
else {
|
89
|
-
return
|
104
|
+
return {
|
105
|
+
success: true,
|
106
|
+
terminalOutput,
|
107
|
+
};
|
90
108
|
}
|
91
109
|
}
|
92
110
|
}
|
@@ -118,46 +136,53 @@ function normalizeOptions(options) {
|
|
118
136
|
return options;
|
119
137
|
}
|
120
138
|
async function runSerially(options, context) {
|
139
|
+
let terminalOutput = '';
|
121
140
|
for (const c of options.commands) {
|
122
|
-
const
|
123
|
-
|
124
|
-
|
125
|
-
|
141
|
+
const result = await createProcess(c, undefined, options.color, calculateCwd(options.cwd, context), options.env ?? {}, false, options.usePty, options.streamOutput);
|
142
|
+
terminalOutput += result.terminalOutput;
|
143
|
+
if (!result.success) {
|
144
|
+
const output = `Warning: command "${c.command}" exited with non-zero status code`;
|
145
|
+
result.terminalOutput += output;
|
146
|
+
if (options.streamOutput) {
|
147
|
+
process.stderr.write(output);
|
148
|
+
}
|
149
|
+
return { success: false, terminalOutput };
|
126
150
|
}
|
127
151
|
}
|
128
|
-
return true;
|
152
|
+
return { success: true, terminalOutput };
|
129
153
|
}
|
130
|
-
async function createProcess(commandConfig, readyWhen, color, cwd, env, isParallel) {
|
154
|
+
async function createProcess(commandConfig, readyWhen, color, cwd, env, isParallel, usePty = true, streamOutput = true) {
|
131
155
|
env = processEnv(color, cwd, env);
|
132
156
|
// The rust runCommand is always a tty, so it will not look nice in parallel and if we need prefixes
|
133
157
|
// currently does not work properly in windows
|
134
158
|
if (process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
|
135
159
|
process.stdout.isTTY &&
|
136
160
|
!commandConfig.prefix &&
|
137
|
-
!isParallel
|
138
|
-
|
161
|
+
!isParallel &&
|
162
|
+
usePty) {
|
163
|
+
const cp = new child_process_2.PseudoTtyProcess((0, native_1.runCommand)(commandConfig.command, cwd, env, !streamOutput));
|
164
|
+
let terminalOutput = '';
|
139
165
|
return new Promise((res) => {
|
140
166
|
cp.onOutput((output) => {
|
167
|
+
terminalOutput += output;
|
141
168
|
if (readyWhen && output.indexOf(readyWhen) > -1) {
|
142
|
-
res(true);
|
169
|
+
res({ success: true, terminalOutput });
|
143
170
|
}
|
144
171
|
});
|
145
172
|
cp.onExit((code) => {
|
146
|
-
if (code
|
147
|
-
res(true);
|
148
|
-
}
|
149
|
-
else if (code >= 128) {
|
173
|
+
if (code >= 128) {
|
150
174
|
process.exit(code);
|
151
175
|
}
|
152
176
|
else {
|
153
|
-
res(
|
177
|
+
res({ success: code === 0, terminalOutput });
|
154
178
|
}
|
155
179
|
});
|
156
180
|
});
|
157
181
|
}
|
158
|
-
return nodeProcess(commandConfig,
|
182
|
+
return nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput);
|
159
183
|
}
|
160
|
-
function nodeProcess(commandConfig,
|
184
|
+
function nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput = true) {
|
185
|
+
let terminalOutput = '';
|
161
186
|
return new Promise((res) => {
|
162
187
|
const childProcess = (0, child_process_1.exec)(commandConfig.command, {
|
163
188
|
maxBuffer: exports.LARGE_BUFFER,
|
@@ -173,24 +198,36 @@ function nodeProcess(commandConfig, color, cwd, env, readyWhen) {
|
|
173
198
|
process.on('SIGINT', processExitListener);
|
174
199
|
process.on('SIGQUIT', processExitListener);
|
175
200
|
childProcess.stdout.on('data', (data) => {
|
176
|
-
|
201
|
+
const output = addColorAndPrefix(data, commandConfig);
|
202
|
+
terminalOutput += output;
|
203
|
+
if (streamOutput) {
|
204
|
+
process.stdout.write(output);
|
205
|
+
}
|
177
206
|
if (readyWhen && data.toString().indexOf(readyWhen) > -1) {
|
178
|
-
res(true);
|
207
|
+
res({ success: true, terminalOutput });
|
179
208
|
}
|
180
209
|
});
|
181
210
|
childProcess.stderr.on('data', (err) => {
|
182
|
-
|
211
|
+
const output = addColorAndPrefix(err, commandConfig);
|
212
|
+
terminalOutput += output;
|
213
|
+
if (streamOutput) {
|
214
|
+
process.stderr.write(output);
|
215
|
+
}
|
183
216
|
if (readyWhen && err.toString().indexOf(readyWhen) > -1) {
|
184
|
-
res(true);
|
217
|
+
res({ success: true, terminalOutput });
|
185
218
|
}
|
186
219
|
});
|
187
220
|
childProcess.on('error', (err) => {
|
188
|
-
|
189
|
-
|
221
|
+
const ouptput = addColorAndPrefix(err.toString(), commandConfig);
|
222
|
+
terminalOutput += ouptput;
|
223
|
+
if (streamOutput) {
|
224
|
+
process.stderr.write(ouptput);
|
225
|
+
}
|
226
|
+
res({ success: false, terminalOutput });
|
190
227
|
});
|
191
228
|
childProcess.on('exit', (code) => {
|
192
229
|
if (!readyWhen) {
|
193
|
-
res(code === 0);
|
230
|
+
res({ success: code === 0, terminalOutput });
|
194
231
|
}
|
195
232
|
});
|
196
233
|
});
|
@@ -218,11 +255,13 @@ function calculateCwd(cwd, context) {
|
|
218
255
|
return path.join(context.root, cwd);
|
219
256
|
}
|
220
257
|
function processEnv(color, cwd, env) {
|
258
|
+
const localEnv = (0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd() });
|
221
259
|
const res = {
|
222
260
|
...process.env,
|
223
|
-
...
|
261
|
+
...localEnv,
|
224
262
|
...env,
|
225
263
|
};
|
264
|
+
res.PATH = localEnv.PATH; // need to override PATH to make sure we are using the local node_modules
|
226
265
|
if (color) {
|
227
266
|
res.FORCE_COLOR = `${color}`;
|
228
267
|
}
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.convertNxExecutor = void 0;
|
7
7
|
const nx_json_1 = require("../../config/nx-json");
|
8
8
|
const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
|
9
|
-
const internal_api_1 = require("../../project-graph/plugins/internal-api");
|
10
9
|
/**
|
11
10
|
* Convert an Nx Executor into an Angular Devkit Builder
|
12
11
|
*
|
@@ -16,12 +15,10 @@ function convertNxExecutor(executor) {
|
|
16
15
|
const builderFunction = (options, builderContext) => {
|
17
16
|
const promise = async () => {
|
18
17
|
const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
|
19
|
-
const [plugins, cleanup] = await (0, internal_api_1.loadNxPluginsInIsolation)(nxJsonConfiguration.plugins, builderContext.workspaceRoot);
|
20
18
|
const projectsConfigurations = {
|
21
19
|
version: 2,
|
22
|
-
projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(
|
20
|
+
projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(builderContext.workspaceRoot, nxJsonConfiguration)).projects,
|
23
21
|
};
|
24
|
-
cleanup();
|
25
22
|
const context = {
|
26
23
|
root: builderContext.workspaceRoot,
|
27
24
|
projectName: builderContext.target.project,
|
@@ -136,8 +136,8 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
136
136
|
...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })),
|
137
137
|
];
|
138
138
|
const projectGlobPatterns = (0, retrieve_workspace_files_1.configurationGlobs)([
|
139
|
-
project_json_1.ProjectJsonProjectsPlugin,
|
140
|
-
{
|
139
|
+
{ plugin: project_json_1.ProjectJsonProjectsPlugin },
|
140
|
+
{ plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(tree.root) },
|
141
141
|
]);
|
142
142
|
const globbedFiles = (0, workspace_context_1.globWithWorkspaceContext)(tree.root, projectGlobPatterns);
|
143
143
|
const createdFiles = findCreatedProjectFiles(tree, patterns);
|
package/src/hasher/hash-task.js
CHANGED
@@ -9,7 +9,7 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
|
|
9
9
|
performance.mark('hashMultipleTasks:start');
|
10
10
|
const tasks = Object.values(taskGraph.tasks);
|
11
11
|
const tasksWithHashers = await Promise.all(tasks.map(async (task) => {
|
12
|
-
const customHasher =
|
12
|
+
const customHasher = (0, utils_1.getCustomHasher)(task, projectGraph);
|
13
13
|
return { task, customHasher };
|
14
14
|
}));
|
15
15
|
const tasksToHash = tasksWithHashers
|
@@ -33,7 +33,7 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
|
|
33
33
|
exports.hashTasksThatDoNotDependOnOutputsOfOtherTasks = hashTasksThatDoNotDependOnOutputsOfOtherTasks;
|
34
34
|
async function hashTask(hasher, projectGraph, taskGraph, task, env) {
|
35
35
|
performance.mark('hashSingleTask:start');
|
36
|
-
const customHasher =
|
36
|
+
const customHasher = (0, utils_1.getCustomHasher)(task, projectGraph);
|
37
37
|
const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
38
38
|
const { value, details } = await (customHasher
|
39
39
|
? customHasher(task, {
|
@@ -5,10 +5,10 @@ const path_1 = require("path");
|
|
5
5
|
const json_1 = require("../../generators/utils/json");
|
6
6
|
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
7
7
|
const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
|
8
|
-
const
|
8
|
+
const nx_plugin_1 = require("../../utils/nx-plugin");
|
9
9
|
async function default_1(tree) {
|
10
10
|
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
11
|
-
const projectFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(tree.root,
|
11
|
+
const projectFiles = await (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(tree.root, await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins));
|
12
12
|
const projectJsons = projectFiles.filter((f) => f.endsWith('project.json'));
|
13
13
|
for (let f of projectJsons) {
|
14
14
|
const projectJson = (0, json_1.readJson)(tree, f);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CreateDependencies, CreateNodes } from '../../
|
1
|
+
import { CreateDependencies, CreateNodes } from '../../utils/nx-plugin';
|
2
2
|
export declare const name = "nx/js/dependencies-and-lockfile";
|
3
3
|
export declare const createNodes: CreateNodes;
|
4
4
|
export declare const createDependencies: CreateDependencies;
|
@@ -6,7 +6,7 @@ import { PackageManager } from '../../../utils/package-manager';
|
|
6
6
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
7
7
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
8
8
|
import { PackageJson } from '../../../utils/package-json';
|
9
|
-
import { CreateDependenciesContext } from '../../../
|
9
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
10
10
|
export declare const LOCKFILES: string[];
|
11
11
|
/**
|
12
12
|
* Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { NormalizedPackageJson } from './utils/package-json';
|
2
2
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
3
3
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
4
|
-
import { CreateDependenciesContext } from '../../../
|
4
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
5
5
|
export declare function getNpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
|
6
6
|
export declare function getNpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
7
7
|
export declare function stringifyNpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { NormalizedPackageJson } from './utils/package-json';
|
2
2
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
3
3
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
4
|
-
import { CreateDependenciesContext } from '../../../
|
4
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
5
5
|
export declare function getPnpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
|
6
6
|
export declare function getPnpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
7
7
|
export declare function stringifyPnpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { NormalizedPackageJson } from './utils/package-json';
|
2
2
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
3
3
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
4
|
-
import { CreateDependenciesContext } from '../../../
|
4
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
5
5
|
export declare function getYarnLockfileNodes(lockFileContent: string, lockFileHash: string, packageJson: NormalizedPackageJson): Record<string, ProjectGraphExternalNode>;
|
6
6
|
export declare function getYarnLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
7
7
|
export declare function stringifyYarnLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CreateDependenciesContext } from '../../../../
|
1
|
+
import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
|
2
2
|
import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
|
3
3
|
export declare function buildExplicitDependencies(jsPluginConfig: {
|
4
4
|
analyzeSourceFiles?: boolean;
|
package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import { CreateDependenciesContext } from '../../../../
|
1
|
+
import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
|
2
2
|
import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
|
3
3
|
export declare function buildExplicitPackageJsonDependencies(ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { CreateDependenciesContext } from '../../../../
|
1
|
+
import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
|
2
2
|
import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
|
3
3
|
export declare function buildExplicitTypeScriptDependencies(ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
@@ -67,7 +67,9 @@ function getTranspiler(compilerOptions) {
|
|
67
67
|
}
|
68
68
|
compilerOptions.lib = ['es2021'];
|
69
69
|
compilerOptions.module = ts.ModuleKind.CommonJS;
|
70
|
-
|
70
|
+
// use NodeJs module resolution until support for TS 4.x is dropped and then
|
71
|
+
// we can switch to Node10
|
72
|
+
compilerOptions.moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
71
73
|
compilerOptions.target = ts.ScriptTarget.ES2021;
|
72
74
|
compilerOptions.inlineSourceMap = true;
|
73
75
|
compilerOptions.skipLibCheck = true;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
2
2
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
3
|
+
import { NxPluginV2 } from '../../utils/nx-plugin';
|
3
4
|
import { PackageJson } from '../../utils/package-json';
|
4
|
-
|
5
|
-
export declare const createNodes: CreateNodes;
|
5
|
+
export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
|
6
6
|
export declare function createNodeFromPackageJson(pkgJsonPath: string, root: string): {
|
7
7
|
projects: {
|
8
8
|
[x: string]: ProjectConfiguration & {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.
|
3
|
+
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
|
4
4
|
const minimatch_1 = require("minimatch");
|
5
5
|
const node_fs_1 = require("node:fs");
|
6
6
|
const node_path_1 = require("node:path");
|
@@ -12,30 +12,37 @@ const logger_1 = require("../../utils/logger");
|
|
12
12
|
const output_1 = require("../../utils/output");
|
13
13
|
const package_json_1 = require("../../utils/package-json");
|
14
14
|
const path_1 = require("../../utils/path");
|
15
|
-
|
16
|
-
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(
|
17
|
-
const patterns = getGlobPatternsFromPackageManagerWorkspaces(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
//
|
24
|
-
|
25
|
-
//
|
26
|
-
(positivePatterns.length ===
|
27
|
-
|
15
|
+
function getNxPackageJsonWorkspacesPlugin(root) {
|
16
|
+
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, f));
|
17
|
+
const patterns = getGlobPatternsFromPackageManagerWorkspaces(root, readJson);
|
18
|
+
// If the user only specified a negative pattern, we should find all package.json
|
19
|
+
// files and only return those that don't match a negative pattern.
|
20
|
+
const negativePatterns = patterns.filter((p) => p.startsWith('!'));
|
21
|
+
let positivePatterns = patterns.filter((p) => !p.startsWith('!'));
|
22
|
+
if (
|
23
|
+
// There are some negative patterns
|
24
|
+
negativePatterns.length > 0 &&
|
25
|
+
// No positive patterns
|
26
|
+
(positivePatterns.length === 0 ||
|
27
|
+
// Or only a single positive pattern that is the default coming from root package
|
28
|
+
(positivePatterns.length === 1 && positivePatterns[0] === 'package.json'))) {
|
29
|
+
positivePatterns.push('**/package.json');
|
30
|
+
}
|
31
|
+
return {
|
32
|
+
name: 'nx/core/package-json-workspaces',
|
33
|
+
createNodes: [
|
34
|
+
(0, globs_1.combineGlobPatterns)(positivePatterns),
|
35
|
+
(p) => {
|
36
|
+
if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
|
37
|
+
return createNodeFromPackageJson(p, root);
|
38
|
+
}
|
39
|
+
// A negative pattern matched, so we should not create a node for this package.json
|
40
|
+
return {};
|
41
|
+
},
|
42
|
+
],
|
43
|
+
};
|
28
44
|
}
|
29
|
-
exports.
|
30
|
-
(0, globs_1.combineGlobPatterns)(positivePatterns),
|
31
|
-
(p, _, { workspaceRoot }) => {
|
32
|
-
if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
|
33
|
-
return createNodeFromPackageJson(p, workspaceRoot);
|
34
|
-
}
|
35
|
-
// A negative pattern matched, so we should not create a node for this package.json
|
36
|
-
return {};
|
37
|
-
},
|
38
|
-
];
|
45
|
+
exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
|
39
46
|
function createNodeFromPackageJson(pkgJsonPath, root) {
|
40
47
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
|
41
48
|
const project = buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root));
|
@@ -24,7 +24,6 @@ exports.PackageJsonProjectsNextToProjectJsonPlugin = {
|
|
24
24
|
},
|
25
25
|
],
|
26
26
|
};
|
27
|
-
exports.default = exports.PackageJsonProjectsNextToProjectJsonPlugin;
|
28
27
|
function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspaceRoot) {
|
29
28
|
const root = (0, path_1.dirname)(projectJsonPath);
|
30
29
|
const packageJsonPath = (0, path_1.join)(workspaceRoot, root, 'package.json');
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { ProjectConfiguration } from '../../../config/workspace-json-project-json';
|
2
|
-
import { NxPluginV2 } from '../../../
|
2
|
+
import { NxPluginV2 } from '../../../utils/nx-plugin';
|
3
3
|
export declare const ProjectJsonProjectsPlugin: NxPluginV2;
|
4
|
-
export default ProjectJsonProjectsPlugin;
|
5
4
|
export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
|