@nx/js 19.7.0-beta.3 → 19.7.0-beta.5
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/package.json +4 -4
- package/src/executors/node/node-with-require-overrides.d.ts +5 -2
- package/src/executors/node/node-with-require-overrides.js +19 -5
- package/src/executors/node/node.impl.js +7 -8
- package/src/executors/release-publish/release-publish.impl.js +3 -0
- package/src/executors/release-publish/schema.d.ts +1 -0
- package/src/executors/release-publish/schema.json +5 -0
- package/src/generators/release-version/release-version.js +45 -1
- package/src/executors/node/patch-require.d.ts +0 -5
- package/src/executors/node/patch-require.js +0 -26
- package/src/executors/node/patch-sigint.d.ts +0 -5
- package/src/executors/node/patch-sigint.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "19.7.0-beta.
|
|
3
|
+
"version": "19.7.0-beta.5",
|
|
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,8 +39,8 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.2",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@babel/runtime": "^7.22.6",
|
|
42
|
-
"@nx/devkit": "19.7.0-beta.
|
|
43
|
-
"@nx/workspace": "19.7.0-beta.
|
|
42
|
+
"@nx/devkit": "19.7.0-beta.5",
|
|
43
|
+
"@nx/workspace": "19.7.0-beta.5",
|
|
44
44
|
"babel-plugin-const-enum": "^1.0.1",
|
|
45
45
|
"babel-plugin-macros": "^2.8.0",
|
|
46
46
|
"babel-plugin-transform-typescript-metadata": "^0.3.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"ts-node": "10.9.1",
|
|
62
62
|
"tsconfig-paths": "^4.1.2",
|
|
63
63
|
"tslib": "^2.3.0",
|
|
64
|
-
"@nrwl/js": "19.7.0-beta.
|
|
64
|
+
"@nrwl/js": "19.7.0-beta.5"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"verdaccio": "^5.0.4"
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
declare const Module: any;
|
|
1
2
|
declare const url: any;
|
|
2
|
-
declare const
|
|
3
|
-
declare const patchRequire: any;
|
|
3
|
+
declare const originalLoader: any;
|
|
4
4
|
declare const dynamicImport: Function;
|
|
5
|
+
declare const mappings: any;
|
|
6
|
+
declare const keys: string[];
|
|
7
|
+
declare const fileToRun: any;
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
const Module = require('module');
|
|
1
2
|
const url = require('node:url');
|
|
2
|
-
const
|
|
3
|
-
const { patchRequire } = require('./patch-require');
|
|
4
|
-
patchSigint();
|
|
5
|
-
patchRequire();
|
|
3
|
+
const originalLoader = Module._load;
|
|
6
4
|
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
7
|
-
|
|
5
|
+
const mappings = JSON.parse(process.env.NX_MAPPINGS);
|
|
6
|
+
const keys = Object.keys(mappings);
|
|
7
|
+
const fileToRun = url.pathToFileURL(process.env.NX_FILE_TO_RUN);
|
|
8
|
+
Module._load = function (request, parent) {
|
|
9
|
+
if (!parent)
|
|
10
|
+
return originalLoader.apply(this, arguments);
|
|
11
|
+
const match = keys.find((k) => request === k);
|
|
12
|
+
if (match) {
|
|
13
|
+
const newArguments = [...arguments];
|
|
14
|
+
newArguments[0] = mappings[match];
|
|
15
|
+
return originalLoader.apply(this, newArguments);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return originalLoader.apply(this, arguments);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
dynamicImport(fileToRun);
|
|
@@ -111,14 +111,11 @@ async function* nodeExecutor(options, context) {
|
|
|
111
111
|
task.childProcess.stderr.on('data', handleStdErr);
|
|
112
112
|
task.childProcess.once('exit', (code) => {
|
|
113
113
|
task.childProcess.off('data', handleStdErr);
|
|
114
|
-
if (options.watch &&
|
|
115
|
-
!task.killed &&
|
|
116
|
-
// SIGINT should exist the process rather than watch for changes.
|
|
117
|
-
code !== 130) {
|
|
114
|
+
if (options.watch && !task.killed) {
|
|
118
115
|
devkit_1.logger.info(`NX Process exited with code ${code}, waiting for changes to restart...`);
|
|
119
116
|
}
|
|
120
|
-
if (!options.watch
|
|
121
|
-
if (code !== 0
|
|
117
|
+
if (!options.watch) {
|
|
118
|
+
if (code !== 0) {
|
|
122
119
|
error(new Error(`Process exited with code ${code}`));
|
|
123
120
|
}
|
|
124
121
|
else {
|
|
@@ -204,8 +201,10 @@ async function* nodeExecutor(options, context) {
|
|
|
204
201
|
devkit_1.logger.error(`Watch error: ${err?.message ?? 'Unknown'}`);
|
|
205
202
|
}
|
|
206
203
|
else {
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
if (options.watch) {
|
|
205
|
+
devkit_1.logger.info(`NX File change detected. Restarting...`);
|
|
206
|
+
await runBuild();
|
|
207
|
+
}
|
|
209
208
|
}
|
|
210
209
|
});
|
|
211
210
|
}
|
|
@@ -163,6 +163,9 @@ async function runExecutor(options, context) {
|
|
|
163
163
|
if (options.otp) {
|
|
164
164
|
npmPublishCommandSegments.push(`--otp=${options.otp}`);
|
|
165
165
|
}
|
|
166
|
+
if (options.access) {
|
|
167
|
+
npmPublishCommandSegments.push(`--access=${options.access}`);
|
|
168
|
+
}
|
|
166
169
|
if (isDryRun) {
|
|
167
170
|
npmPublishCommandSegments.push(`--dry-run`);
|
|
168
171
|
}
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"type": "string",
|
|
18
18
|
"description": "The distribution tag to apply to the published package."
|
|
19
19
|
},
|
|
20
|
+
"access": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["public", "restricted"],
|
|
23
|
+
"description": "Overrides the access level of the published package. Unscoped packages cannot be set to restricted. See the npm publish documentation for more information."
|
|
24
|
+
},
|
|
20
25
|
"dryRun": {
|
|
21
26
|
"type": "boolean",
|
|
22
27
|
"description": "Whether to run the command without actually publishing the package to the registry."
|
|
@@ -468,6 +468,21 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
468
468
|
// Auto (i.e.infer existing) by default
|
|
469
469
|
let versionPrefix = options.versionPrefix ?? 'auto';
|
|
470
470
|
const currentDependencyVersion = json[dependentProject.dependencyCollection][dependencyPackageName];
|
|
471
|
+
// Depending on the package manager, locally linked packages could reference packages with `"private": true` and no version field at all
|
|
472
|
+
const currentPackageVersion = json.version ?? null;
|
|
473
|
+
if (!currentPackageVersion &&
|
|
474
|
+
isLocallyLinkedPackageVersion(currentDependencyVersion)) {
|
|
475
|
+
if (forceVersionBump) {
|
|
476
|
+
// Look up any dependent projects from the transitiveLocalPackageDependents list
|
|
477
|
+
const transitiveDependentProjects = transitiveLocalPackageDependents.filter((localPackageDependency) => localPackageDependency.target === dependentProject.source);
|
|
478
|
+
versionData[dependentProject.source] = {
|
|
479
|
+
currentVersion: currentPackageVersion,
|
|
480
|
+
newVersion: currentDependencyVersion,
|
|
481
|
+
dependentProjects: transitiveDependentProjects,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
return json;
|
|
485
|
+
}
|
|
471
486
|
// For auto, we infer the prefix based on the current version of the dependent
|
|
472
487
|
if (versionPrefix === 'auto') {
|
|
473
488
|
versionPrefix = ''; // we don't want to end up printing auto
|
|
@@ -487,7 +502,6 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
487
502
|
newDepVersion;
|
|
488
503
|
// Bump the dependent's version if applicable and record it in the version data
|
|
489
504
|
if (forceVersionBump) {
|
|
490
|
-
const currentPackageVersion = json.version;
|
|
491
505
|
const newPackageVersion = (0, version_1.deriveNewSemverVersion)(currentPackageVersion, forceVersionBump, options.preid);
|
|
492
506
|
json.version = newPackageVersion;
|
|
493
507
|
// Look up any dependent projects from the transitiveLocalPackageDependents list
|
|
@@ -655,3 +669,33 @@ class ProjectLogger {
|
|
|
655
669
|
});
|
|
656
670
|
}
|
|
657
671
|
}
|
|
672
|
+
let pm;
|
|
673
|
+
let pmVersion;
|
|
674
|
+
const localPackageProtocols = [
|
|
675
|
+
'file:', // all package managers
|
|
676
|
+
'workspace:', // not npm
|
|
677
|
+
'portal:', // modern yarn only
|
|
678
|
+
];
|
|
679
|
+
function isLocallyLinkedPackageVersion(version) {
|
|
680
|
+
// Not using a supported local protocol
|
|
681
|
+
if (!localPackageProtocols.some((protocol) => version.startsWith(protocol))) {
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
// Supported by all package managers
|
|
685
|
+
if (version.startsWith('file:')) {
|
|
686
|
+
return true;
|
|
687
|
+
}
|
|
688
|
+
// Determine specific package manager in use
|
|
689
|
+
if (!pm) {
|
|
690
|
+
pm = (0, devkit_1.detectPackageManager)();
|
|
691
|
+
pmVersion = (0, devkit_1.getPackageManagerVersion)(pm);
|
|
692
|
+
}
|
|
693
|
+
if (pm === 'npm' && version.startsWith('workspace:')) {
|
|
694
|
+
throw new Error(`The "workspace:" protocol is not yet supported by npm (https://github.com/npm/rfcs/issues/765). Please ensure you have a valid setup according to your package manager before attempting to release packages.`);
|
|
695
|
+
}
|
|
696
|
+
if (version.startsWith('portal:') &&
|
|
697
|
+
(pm !== 'yarn' || (0, semver_2.lt)(pmVersion, '2.0.0'))) {
|
|
698
|
+
throw new Error(`The "portal:" protocol is only supported by yarn@2.0.0 and above. Please ensure you have a valid setup according to your package manager before attempting to release packages.`);
|
|
699
|
+
}
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.patchRequire = patchRequire;
|
|
4
|
-
const Module = require('node:module');
|
|
5
|
-
const originalLoader = Module._load;
|
|
6
|
-
/**
|
|
7
|
-
* Overrides require calls to map buildable workspace libs to their output location.
|
|
8
|
-
* This is useful for running programs compiled via TSC/SWC that aren't bundled.
|
|
9
|
-
*/
|
|
10
|
-
function patchRequire() {
|
|
11
|
-
const mappings = JSON.parse(process.env.NX_MAPPINGS);
|
|
12
|
-
const keys = Object.keys(mappings);
|
|
13
|
-
Module._load = function (request, parent) {
|
|
14
|
-
if (!parent)
|
|
15
|
-
return originalLoader.apply(this, arguments);
|
|
16
|
-
const match = keys.find((k) => request === k);
|
|
17
|
-
if (match) {
|
|
18
|
-
const newArguments = [...arguments];
|
|
19
|
-
newArguments[0] = mappings[match];
|
|
20
|
-
return originalLoader.apply(this, newArguments);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return originalLoader.apply(this, arguments);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.patchSigint = patchSigint;
|
|
4
|
-
const readline = require('node:readline');
|
|
5
|
-
/**
|
|
6
|
-
* Patches the current process so that Ctrl+C is properly handled.
|
|
7
|
-
* Without this patch, SIGINT or Ctrl+C does not wait for graceful shutdown and exits immediately.
|
|
8
|
-
*/
|
|
9
|
-
function patchSigint() {
|
|
10
|
-
readline.emitKeypressEvents(process.stdin);
|
|
11
|
-
if (process.stdin.isTTY)
|
|
12
|
-
process.stdin.setRawMode(true);
|
|
13
|
-
process.stdin.on('keypress', async (chunk, key) => {
|
|
14
|
-
if (key && key.ctrl && key.name === 'c') {
|
|
15
|
-
process.stdin.setRawMode(false); // To ensure nx terminal is not stuck in raw mode
|
|
16
|
-
const listeners = process.listeners('SIGINT');
|
|
17
|
-
for (const listener of listeners) {
|
|
18
|
-
await listener('SIGINT');
|
|
19
|
-
}
|
|
20
|
-
process.exit(130);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
console.log('To exit the process, press Ctrl+C');
|
|
24
|
-
}
|