@nx/js 16.5.0 → 16.5.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.
- package/generators.json +0 -1
- package/package.json +5 -5
- package/src/executors/node/node.impl.js +65 -35
- package/src/executors/node/schema.d.ts +1 -0
- package/src/executors/node/schema.json +21 -8
- package/src/executors/tsc/tsc.batch-impl.js +52 -18
- package/src/executors/verdaccio/verdaccio.impl.js +6 -2
package/generators.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "16.5.
|
|
3
|
+
"version": "16.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.15.0",
|
|
40
40
|
"@babel/preset-typescript": "^7.15.0",
|
|
41
41
|
"@babel/runtime": "^7.14.8",
|
|
42
|
-
"@nrwl/js": "16.5.
|
|
43
|
-
"@nx/devkit": "16.5.
|
|
44
|
-
"@nx/workspace": "16.5.
|
|
42
|
+
"@nrwl/js": "16.5.1",
|
|
43
|
+
"@nx/devkit": "16.5.1",
|
|
44
|
+
"@nx/workspace": "16.5.1",
|
|
45
45
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
46
46
|
"babel-plugin-const-enum": "^1.0.1",
|
|
47
47
|
"babel-plugin-macros": "^2.8.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
71
|
"types": "./src/index.d.ts",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "7b7f1e7f72a34cb31cff43ea0ebb80d0eab1ac79"
|
|
73
73
|
}
|
|
@@ -65,37 +65,60 @@ function nodeExecutor(options, context) {
|
|
|
65
65
|
childProcess: null,
|
|
66
66
|
promise: null,
|
|
67
67
|
start: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
if (options.runBuildTargetDependencies) {
|
|
69
|
+
// If task dependencies are to be run, then we need to run through CLI since `runExecutor` doesn't support it.
|
|
70
|
+
task.promise = new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
task.childProcess = (0, child_process_1.fork)(require.resolve('nx'), [
|
|
72
|
+
'run',
|
|
73
|
+
`${context.projectName}:${buildTarget.target}${buildTarget.configuration
|
|
74
|
+
? `:${buildTarget.configuration}`
|
|
75
|
+
: ''}`,
|
|
76
|
+
], {
|
|
77
|
+
cwd: context.root,
|
|
78
|
+
stdio: 'inherit',
|
|
79
|
+
});
|
|
80
|
+
task.childProcess.once('exit', (code) => {
|
|
81
|
+
if (code === 0)
|
|
82
|
+
resolve();
|
|
83
|
+
else
|
|
84
|
+
reject();
|
|
85
|
+
});
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const output = yield (0, devkit_1.runExecutor)(buildTarget, Object.assign(Object.assign({}, options.buildTargetOptions), { watch: false }), context);
|
|
90
|
+
task.promise = new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
var _g;
|
|
92
|
+
let error = false;
|
|
93
|
+
let event;
|
|
94
|
+
do {
|
|
95
|
+
event = yield output.next();
|
|
96
|
+
if (((_g = event.value) === null || _g === void 0 ? void 0 : _g.success) === false) {
|
|
97
|
+
error = true;
|
|
98
|
+
}
|
|
99
|
+
} while (!event.done);
|
|
100
|
+
if (error)
|
|
90
101
|
reject();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
else
|
|
103
|
+
resolve();
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
// Wait for build to finish.
|
|
107
|
+
try {
|
|
108
|
+
yield task.promise;
|
|
109
|
+
}
|
|
110
|
+
catch (_f) {
|
|
111
|
+
// If in watch-mode, don't throw or else the process exits.
|
|
112
|
+
if (options.watch) {
|
|
113
|
+
devkit_1.logger.error(`Build failed, waiting for changes to restart...`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new Error(`Build failed. See above for errors.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Before running the program, check if the task has been killed (by a new change during watch).
|
|
121
|
+
if (task.killed)
|
|
99
122
|
return;
|
|
100
123
|
// Run the program
|
|
101
124
|
task.promise = new Promise((resolve, reject) => {
|
|
@@ -105,15 +128,17 @@ function nodeExecutor(options, context) {
|
|
|
105
128
|
stdio: [0, 1, 'pipe', 'ipc'],
|
|
106
129
|
env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: fileToRunCorrectPath(fileToRun), NX_MAPPINGS: JSON.stringify(mappings) }),
|
|
107
130
|
});
|
|
108
|
-
|
|
131
|
+
const handleStdErr = (data) => {
|
|
109
132
|
// Don't log out error if task is killed and new one has started.
|
|
110
133
|
// This could happen if a new build is triggered while new process is starting, since the operation is not atomic.
|
|
111
134
|
// Log the error in normal mode
|
|
112
135
|
if (!options.watch || !task.killed) {
|
|
113
136
|
devkit_1.logger.error(data.toString());
|
|
114
137
|
}
|
|
115
|
-
}
|
|
138
|
+
};
|
|
139
|
+
task.childProcess.stderr.on('data', handleStdErr);
|
|
116
140
|
task.childProcess.once('exit', (code) => {
|
|
141
|
+
task.childProcess.off('data', handleStdErr);
|
|
117
142
|
if (options.watch && !task.killed) {
|
|
118
143
|
devkit_1.logger.info(`NX Process exited with code ${code}, waiting for changes to restart...`);
|
|
119
144
|
}
|
|
@@ -132,7 +157,12 @@ function nodeExecutor(options, context) {
|
|
|
132
157
|
if (task.childProcess) {
|
|
133
158
|
yield (0, kill_tree_1.killTree)(task.childProcess.pid, signal);
|
|
134
159
|
}
|
|
135
|
-
|
|
160
|
+
try {
|
|
161
|
+
yield task.promise;
|
|
162
|
+
}
|
|
163
|
+
catch (_h) {
|
|
164
|
+
// Doesn't matter if task fails, we just need to wait until it finishes.
|
|
165
|
+
}
|
|
136
166
|
}),
|
|
137
167
|
};
|
|
138
168
|
tasks.push(task);
|
|
@@ -142,13 +172,13 @@ function nodeExecutor(options, context) {
|
|
|
142
172
|
watchProjects: [context.projectName],
|
|
143
173
|
includeDependentProjects: true,
|
|
144
174
|
}, (err, data) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
var
|
|
175
|
+
var _j;
|
|
146
176
|
if (err === 'closed') {
|
|
147
177
|
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
148
178
|
process.exit(1);
|
|
149
179
|
}
|
|
150
180
|
else if (err) {
|
|
151
|
-
devkit_1.logger.error(`Watch error: ${(
|
|
181
|
+
devkit_1.logger.error(`Watch error: ${(_j = err === null || err === void 0 ? void 0 : err.message) !== null && _j !== void 0 ? _j : 'Unknown'}`);
|
|
152
182
|
}
|
|
153
183
|
else {
|
|
154
184
|
devkit_1.logger.info(`NX File change detected. Restarting...`);
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
"host": {
|
|
28
28
|
"type": "string",
|
|
29
29
|
"default": "localhost",
|
|
30
|
-
"description": "The host to inspect the process on."
|
|
30
|
+
"description": "The host to inspect the process on.",
|
|
31
|
+
"x-priority": "important"
|
|
31
32
|
},
|
|
32
33
|
"port": {
|
|
33
34
|
"type": "number",
|
|
34
35
|
"default": 9229,
|
|
35
|
-
"description": "The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes."
|
|
36
|
+
"description": "The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.",
|
|
37
|
+
"x-priority": "important"
|
|
36
38
|
},
|
|
37
39
|
"inspect": {
|
|
38
40
|
"oneOf": [
|
|
@@ -45,7 +47,8 @@
|
|
|
45
47
|
}
|
|
46
48
|
],
|
|
47
49
|
"description": "Ensures the app is starting with debugging.",
|
|
48
|
-
"default": "inspect"
|
|
50
|
+
"default": "inspect",
|
|
51
|
+
"x-priority": "important"
|
|
49
52
|
},
|
|
50
53
|
"runtimeArgs": {
|
|
51
54
|
"type": "array",
|
|
@@ -53,7 +56,8 @@
|
|
|
53
56
|
"default": [],
|
|
54
57
|
"items": {
|
|
55
58
|
"type": "string"
|
|
56
|
-
}
|
|
59
|
+
},
|
|
60
|
+
"x-priority": "important"
|
|
57
61
|
},
|
|
58
62
|
"args": {
|
|
59
63
|
"type": "array",
|
|
@@ -61,19 +65,28 @@
|
|
|
61
65
|
"default": [],
|
|
62
66
|
"items": {
|
|
63
67
|
"type": "string"
|
|
64
|
-
}
|
|
68
|
+
},
|
|
69
|
+
"x-priority": "important"
|
|
65
70
|
},
|
|
66
71
|
"watch": {
|
|
67
72
|
"type": "boolean",
|
|
68
73
|
"description": "Enable re-building when files change.",
|
|
69
|
-
"default": true
|
|
74
|
+
"default": true,
|
|
75
|
+
"x-priority": "important"
|
|
70
76
|
},
|
|
71
77
|
"debounce": {
|
|
72
78
|
"type": "number",
|
|
73
79
|
"description": "Delay in milliseconds to wait before restarting. Useful to batch multiple file changes events together. Set to zero (0) to disable.",
|
|
74
|
-
"default": 500
|
|
80
|
+
"default": 500,
|
|
81
|
+
"x-priority": "important"
|
|
82
|
+
},
|
|
83
|
+
"runBuildTargetDependencies": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"description": "Whether to run dependencies before running the build. Set this to true if the project does not build libraries from source (e.g. 'buildLibsFromSource: false').",
|
|
86
|
+
"default": false
|
|
75
87
|
}
|
|
76
88
|
},
|
|
77
89
|
"additionalProperties": false,
|
|
78
|
-
"required": ["buildTarget"]
|
|
90
|
+
"required": ["buildTarget"],
|
|
91
|
+
"examplesFile": "../../../docs/node-examples.md"
|
|
79
92
|
}
|
|
@@ -43,20 +43,21 @@ function tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
|
+
const processTaskPostCompilation = (tsConfig) => {
|
|
47
|
+
if (tsConfigTaskInfoMap[tsConfig]) {
|
|
48
|
+
const taskInfo = tsConfigTaskInfoMap[tsConfig];
|
|
49
|
+
taskInfo.assetsHandler.processAllAssetsOnceSync();
|
|
50
|
+
(0, update_package_json_1.updatePackageJson)(taskInfo.options, taskInfo.context, taskInfo.projectGraphNode, taskInfo.buildableProjectNodeDependencies);
|
|
51
|
+
taskInfo.endTime = Date.now();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
46
54
|
const typescriptCompilation = (0, lib_1.compileTypescriptSolution)(tsCompilationContext, shouldWatch, logger, {
|
|
47
55
|
beforeProjectCompilationCallback: (tsConfig) => {
|
|
48
56
|
if (tsConfigTaskInfoMap[tsConfig]) {
|
|
49
57
|
tsConfigTaskInfoMap[tsConfig].startTime = Date.now();
|
|
50
58
|
}
|
|
51
59
|
},
|
|
52
|
-
afterProjectCompilationCallback:
|
|
53
|
-
if (tsConfigTaskInfoMap[tsConfig]) {
|
|
54
|
-
const taskInfo = tsConfigTaskInfoMap[tsConfig];
|
|
55
|
-
taskInfo.assetsHandler.processAllAssetsOnceSync();
|
|
56
|
-
(0, update_package_json_1.updatePackageJson)(taskInfo.options, taskInfo.context, taskInfo.projectGraphNode, taskInfo.buildableProjectNodeDependencies);
|
|
57
|
-
taskInfo.endTime = Date.now();
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
+
afterProjectCompilationCallback: processTaskPostCompilation,
|
|
60
61
|
});
|
|
61
62
|
if (shouldWatch) {
|
|
62
63
|
const taskInfos = Object.values(tsConfigTaskInfoMap);
|
|
@@ -79,21 +80,54 @@ function tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
|
79
80
|
return { value: undefined, done: true };
|
|
80
81
|
}))))));
|
|
81
82
|
}
|
|
83
|
+
const toBatchExecutorTaskResult = (tsConfig, success) => ({
|
|
84
|
+
task: tsConfigTaskInfoMap[tsConfig].task,
|
|
85
|
+
result: {
|
|
86
|
+
success: success,
|
|
87
|
+
terminalOutput: tsConfigTaskInfoMap[tsConfig].terminalOutput,
|
|
88
|
+
startTime: tsConfigTaskInfoMap[tsConfig].startTime,
|
|
89
|
+
endTime: tsConfigTaskInfoMap[tsConfig].endTime,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
let isCompilationDone = false;
|
|
93
|
+
const taskTsConfigsToReport = new Set(Object.keys(taskGraph.tasks).map((t) => taskInMemoryTsConfigMap[t].path));
|
|
94
|
+
let tasksToReportIterator;
|
|
95
|
+
const processSkippedTasks = () => {
|
|
96
|
+
const { value: tsConfig, done } = tasksToReportIterator.next();
|
|
97
|
+
if (done) {
|
|
98
|
+
return { value: undefined, done: true };
|
|
99
|
+
}
|
|
100
|
+
tsConfigTaskInfoMap[tsConfig].startTime = Date.now();
|
|
101
|
+
processTaskPostCompilation(tsConfig);
|
|
102
|
+
return { value: toBatchExecutorTaskResult(tsConfig, true), done: false };
|
|
103
|
+
};
|
|
82
104
|
return yield tslib_1.__await(yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(mapAsyncIterable(typescriptCompilation, (iterator) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (isCompilationDone) {
|
|
106
|
+
return processSkippedTasks();
|
|
107
|
+
}
|
|
83
108
|
const { value, done } = yield iterator.next();
|
|
84
109
|
if (done) {
|
|
85
|
-
|
|
110
|
+
if (taskTsConfigsToReport.size > 0) {
|
|
111
|
+
/**
|
|
112
|
+
* TS compilation is done but we still have tasks to report. This can
|
|
113
|
+
* happen if, for example, a project is identified as affected, but
|
|
114
|
+
* no file in the TS project is actually changed or if running a
|
|
115
|
+
* task with `--skip-nx-cache` and the outputs are already there. There
|
|
116
|
+
* can still be changes to assets or other files we need to process.
|
|
117
|
+
*
|
|
118
|
+
* Switch to handle the iterator for the tasks we still need to report.
|
|
119
|
+
*/
|
|
120
|
+
isCompilationDone = true;
|
|
121
|
+
tasksToReportIterator = taskTsConfigsToReport.values();
|
|
122
|
+
return processSkippedTasks();
|
|
123
|
+
}
|
|
124
|
+
return { value: undefined, done: true };
|
|
86
125
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
terminalOutput: tsConfigTaskInfoMap[value.tsConfig].terminalOutput,
|
|
92
|
-
startTime: tsConfigTaskInfoMap[value.tsConfig].startTime,
|
|
93
|
-
endTime: tsConfigTaskInfoMap[value.tsConfig].endTime,
|
|
94
|
-
},
|
|
126
|
+
taskTsConfigsToReport.delete(value.tsConfig);
|
|
127
|
+
return {
|
|
128
|
+
value: toBatchExecutorTaskResult(value.tsConfig, value.success),
|
|
129
|
+
done: false,
|
|
95
130
|
};
|
|
96
|
-
return { value: taskResult, done: false };
|
|
97
131
|
}))))));
|
|
98
132
|
});
|
|
99
133
|
}
|
|
@@ -120,8 +120,10 @@ function setupNpm(options) {
|
|
|
120
120
|
throw new Error(`Failed to set npm registry to http://localhost:${options.port}/: ${e.message}`);
|
|
121
121
|
}
|
|
122
122
|
return () => {
|
|
123
|
+
var _a, _b, _c;
|
|
123
124
|
try {
|
|
124
|
-
|
|
125
|
+
const currentNpmRegistryPath = (_c = (_b = (_a = (0, child_process_1.execSync)(`npm config get registry --location ${options.location}`)) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
|
|
126
|
+
if (npmRegistryPath && currentNpmRegistryPath.includes('localhost')) {
|
|
125
127
|
(0, child_process_1.execSync)(`npm config set registry ${npmRegistryPath} --location ${options.location}`);
|
|
126
128
|
devkit_1.logger.info(`Reset npm registry to ${npmRegistryPath}`);
|
|
127
129
|
}
|
|
@@ -174,8 +176,10 @@ function setupYarn(options) {
|
|
|
174
176
|
devkit_1.logger.info(`Whitelisted http://localhost:${options.port}/ as an unsafe http server`);
|
|
175
177
|
}
|
|
176
178
|
return () => {
|
|
179
|
+
var _a, _b, _c;
|
|
177
180
|
try {
|
|
178
|
-
|
|
181
|
+
const currentYarnRegistryPath = (_c = (_b = (_a = (0, child_process_1.execSync)(`yarn config get ${registryConfigName}`)) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
|
|
182
|
+
if (yarnRegistryPath && currentYarnRegistryPath.includes('localhost')) {
|
|
179
183
|
(0, child_process_1.execSync)(`yarn config set ${registryConfigName} ${yarnRegistryPath}` +
|
|
180
184
|
(options.location === 'user' ? ' --home' : ''));
|
|
181
185
|
devkit_1.logger.info(`Reset yarn ${registryConfigName} to ${yarnRegistryPath}`);
|