@nx/js 16.5.0-beta.3 → 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 +85 -50
- 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/src/utils/get-main-file-dir.d.ts +1 -0
- package/src/utils/get-main-file-dir.js +11 -0
- package/src/utils/package-json/update-package-json.js +2 -6
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
|
}
|
|
@@ -5,14 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const child_process_1 = require("child_process");
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
8
9
|
const client_1 = require("nx/src/daemon/client/client");
|
|
9
10
|
const crypto_1 = require("crypto");
|
|
10
11
|
const path = require("path");
|
|
11
12
|
const path_1 = require("path");
|
|
12
|
-
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
13
13
|
const buildable_libs_utils_1 = require("../../utils/buildable-libs-utils");
|
|
14
14
|
const kill_tree_1 = require("./lib/kill-tree");
|
|
15
15
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
16
|
+
const get_main_file_dir_1 = require("../../utils/get-main-file-dir");
|
|
16
17
|
function debounce(fn, wait) {
|
|
17
18
|
let timeoutId;
|
|
18
19
|
return () => {
|
|
@@ -27,13 +28,11 @@ function nodeExecutor(options, context) {
|
|
|
27
28
|
(_a = (_d = process.env).NODE_ENV) !== null && _a !== void 0 ? _a : (_d.NODE_ENV = (_b = context === null || context === void 0 ? void 0 : context.configurationName) !== null && _b !== void 0 ? _b : 'development');
|
|
28
29
|
const project = context.projectGraph.nodes[context.projectName];
|
|
29
30
|
const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph);
|
|
30
|
-
|
|
31
|
-
if (project.data.targets[buildTarget.target]) {
|
|
32
|
-
buildOptions = Object.assign(Object.assign({}, (_c = project.data.targets[buildTarget.target]) === null || _c === void 0 ? void 0 : _c.options), options.buildTargetOptions);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
31
|
+
if (!project.data.targets[buildTarget.target]) {
|
|
35
32
|
throw new Error(`Cannot find build target ${chalk.bold(options.buildTarget)} for project ${chalk.bold(context.projectName)}`);
|
|
36
33
|
}
|
|
34
|
+
const buildTargetExecutor = (_c = project.data.targets[buildTarget.target]) === null || _c === void 0 ? void 0 : _c.executor;
|
|
35
|
+
const buildOptions = Object.assign(Object.assign({}, (0, devkit_1.readTargetOptions)(buildTarget, context)), options.buildTargetOptions);
|
|
37
36
|
if (options.waitUntilTargets && options.waitUntilTargets.length > 0) {
|
|
38
37
|
const results = yield tslib_1.__await(runWaitUntilTargets(options, context));
|
|
39
38
|
for (const [i, result] of results.entries()) {
|
|
@@ -44,15 +43,7 @@ function nodeExecutor(options, context) {
|
|
|
44
43
|
}
|
|
45
44
|
// Re-map buildable workspace projects to their output directory.
|
|
46
45
|
const mappings = calculateResolveMappings(context, options);
|
|
47
|
-
|
|
48
|
-
if (!buildOptions.outputFileName) {
|
|
49
|
-
const matches = buildOptions.main.match(/^(?!.*src)(.*)\/([^/]*)$/); //ignore strings that contain src and split paths into [folders before main, main.ts]
|
|
50
|
-
if (matches) {
|
|
51
|
-
const [mainFolder, mainFileName] = matches.slice(1);
|
|
52
|
-
outputFileName = path.join(mainFolder, `${path.parse(mainFileName).name}.js`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const fileToRun = (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
|
|
46
|
+
const fileToRun = getFileToRun(context, project, buildOptions, buildTargetExecutor);
|
|
56
47
|
const tasks = [];
|
|
57
48
|
let currentTask = null;
|
|
58
49
|
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues((0, async_iterable_1.createAsyncIterable)(({ done, next, error }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -74,37 +65,60 @@ function nodeExecutor(options, context) {
|
|
|
74
65
|
childProcess: null,
|
|
75
66
|
promise: null,
|
|
76
67
|
start: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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)
|
|
99
101
|
reject();
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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)
|
|
108
122
|
return;
|
|
109
123
|
// Run the program
|
|
110
124
|
task.promise = new Promise((resolve, reject) => {
|
|
@@ -114,15 +128,17 @@ function nodeExecutor(options, context) {
|
|
|
114
128
|
stdio: [0, 1, 'pipe', 'ipc'],
|
|
115
129
|
env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: fileToRunCorrectPath(fileToRun), NX_MAPPINGS: JSON.stringify(mappings) }),
|
|
116
130
|
});
|
|
117
|
-
|
|
131
|
+
const handleStdErr = (data) => {
|
|
118
132
|
// Don't log out error if task is killed and new one has started.
|
|
119
133
|
// This could happen if a new build is triggered while new process is starting, since the operation is not atomic.
|
|
120
134
|
// Log the error in normal mode
|
|
121
135
|
if (!options.watch || !task.killed) {
|
|
122
136
|
devkit_1.logger.error(data.toString());
|
|
123
137
|
}
|
|
124
|
-
}
|
|
138
|
+
};
|
|
139
|
+
task.childProcess.stderr.on('data', handleStdErr);
|
|
125
140
|
task.childProcess.once('exit', (code) => {
|
|
141
|
+
task.childProcess.off('data', handleStdErr);
|
|
126
142
|
if (options.watch && !task.killed) {
|
|
127
143
|
devkit_1.logger.info(`NX Process exited with code ${code}, waiting for changes to restart...`);
|
|
128
144
|
}
|
|
@@ -141,7 +157,12 @@ function nodeExecutor(options, context) {
|
|
|
141
157
|
if (task.childProcess) {
|
|
142
158
|
yield (0, kill_tree_1.killTree)(task.childProcess.pid, signal);
|
|
143
159
|
}
|
|
144
|
-
|
|
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
|
+
}
|
|
145
166
|
}),
|
|
146
167
|
};
|
|
147
168
|
tasks.push(task);
|
|
@@ -151,13 +172,13 @@ function nodeExecutor(options, context) {
|
|
|
151
172
|
watchProjects: [context.projectName],
|
|
152
173
|
includeDependentProjects: true,
|
|
153
174
|
}, (err, data) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
var
|
|
175
|
+
var _j;
|
|
155
176
|
if (err === 'closed') {
|
|
156
177
|
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
157
178
|
process.exit(1);
|
|
158
179
|
}
|
|
159
180
|
else if (err) {
|
|
160
|
-
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'}`);
|
|
161
182
|
}
|
|
162
183
|
else {
|
|
163
184
|
devkit_1.logger.info(`NX File change detected. Restarting...`);
|
|
@@ -229,6 +250,20 @@ function runWaitUntilTargets(options, context) {
|
|
|
229
250
|
}));
|
|
230
251
|
})));
|
|
231
252
|
}
|
|
253
|
+
function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
|
|
254
|
+
let outputFileName = buildOptions.outputFileName;
|
|
255
|
+
if (!outputFileName) {
|
|
256
|
+
const fileName = `${path.parse(buildOptions.main).name}.js`;
|
|
257
|
+
if (buildTargetExecutor === '@nx/js:tsc' ||
|
|
258
|
+
buildTargetExecutor === '@nx/js:swc') {
|
|
259
|
+
outputFileName = path.join((0, get_main_file_dir_1.getMainFileDirRelativeToProjectRoot)(buildOptions.main, project.data.root), fileName);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
outputFileName = fileName;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
|
|
266
|
+
}
|
|
232
267
|
function fileToRunCorrectPath(fileToRun) {
|
|
233
268
|
if (!(0, fileutils_1.fileExists)(fileToRun)) {
|
|
234
269
|
const cjsFile = fileToRun.replace(/\.js$/, '.cjs');
|
|
@@ -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}`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getMainFileDirRelativeToProjectRoot(main: string, projectRoot: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMainFileDirRelativeToProjectRoot = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const path_2 = require("nx/src/utils/path");
|
|
6
|
+
function getMainFileDirRelativeToProjectRoot(main, projectRoot) {
|
|
7
|
+
const mainFileDir = (0, path_1.dirname)(main);
|
|
8
|
+
const relativeDir = (0, path_2.normalizePath)((0, path_1.relative)(projectRoot, mainFileDir));
|
|
9
|
+
return relativeDir === '' ? `./` : `./${relativeDir}/`;
|
|
10
|
+
}
|
|
11
|
+
exports.getMainFileDirRelativeToProjectRoot = getMainFileDirRelativeToProjectRoot;
|
|
@@ -12,11 +12,7 @@ const operators_1 = require("nx/src/project-graph/operators");
|
|
|
12
12
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
14
|
const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
|
|
15
|
-
|
|
16
|
-
const mainFileDir = (0, path_1.dirname)(main);
|
|
17
|
-
const relativeDir = (0, devkit_1.normalizePath)((0, path_1.relative)(projectRoot, mainFileDir));
|
|
18
|
-
return relativeDir === '' ? `./` : `./${relativeDir}/`;
|
|
19
|
-
}
|
|
15
|
+
const get_main_file_dir_1 = require("../get-main-file-dir");
|
|
20
16
|
function updatePackageJson(options, context, target, dependencies, fileMap = null) {
|
|
21
17
|
var _a;
|
|
22
18
|
let packageJson;
|
|
@@ -99,7 +95,7 @@ function getUpdatedPackageJsonContent(packageJson, options) {
|
|
|
99
95
|
const hasCjsFormat = !options.format || ((_a = options.format) === null || _a === void 0 ? void 0 : _a.includes('cjs'));
|
|
100
96
|
const hasEsmFormat = (_b = options.format) === null || _b === void 0 ? void 0 : _b.includes('esm');
|
|
101
97
|
const mainFile = (0, path_1.basename)(options.main).replace(/\.[tj]s$/, '');
|
|
102
|
-
const relativeMainFileDir = getMainFileDirRelativeToProjectRoot(options.main, options.projectRoot);
|
|
98
|
+
const relativeMainFileDir = (0, get_main_file_dir_1.getMainFileDirRelativeToProjectRoot)(options.main, options.projectRoot);
|
|
103
99
|
const typingsFile = `${relativeMainFileDir}${mainFile}.d.ts`;
|
|
104
100
|
const exports = typeof packageJson.exports === 'string'
|
|
105
101
|
? packageJson.exports
|