@nx/js 17.3.0-beta.4 → 17.3.0-beta.6
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 +5 -5
- package/src/executors/verdaccio/verdaccio.impl.js +1 -1
- package/src/generators/init/init.js +2 -2
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/init/schema.json +6 -0
- package/src/generators/release-version/release-version.js +55 -18
- package/src/generators/setup-build/generator.js +3 -0
- package/src/utils/assets/copy-assets-handler.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "17.3.0-beta.
|
|
3
|
+
"version": "17.3.0-beta.6",
|
|
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": {
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"tsconfig-paths": "^4.1.2",
|
|
53
53
|
"ignore": "^5.0.4",
|
|
54
54
|
"js-tokens": "^4.0.0",
|
|
55
|
-
"minimatch": "
|
|
55
|
+
"minimatch": "9.0.3",
|
|
56
56
|
"ora": "5.3.0",
|
|
57
57
|
"semver": "7.5.3",
|
|
58
58
|
"source-map-support": "0.5.19",
|
|
59
59
|
"tslib": "^2.3.0",
|
|
60
|
-
"@nx/devkit": "17.3.0-beta.
|
|
61
|
-
"@nx/workspace": "17.3.0-beta.
|
|
62
|
-
"@nrwl/js": "17.3.0-beta.
|
|
60
|
+
"@nx/devkit": "17.3.0-beta.6",
|
|
61
|
+
"@nx/workspace": "17.3.0-beta.6",
|
|
62
|
+
"@nrwl/js": "17.3.0-beta.6"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"verdaccio": "^5.0.4"
|
|
@@ -149,7 +149,7 @@ function getYarnUnsafeHttpWhitelist(isYarnV1) {
|
|
|
149
149
|
: null;
|
|
150
150
|
}
|
|
151
151
|
function setYarnUnsafeHttpWhitelist(currentWhitelist, options) {
|
|
152
|
-
if (currentWhitelist.size >
|
|
152
|
+
if (currentWhitelist.size > 0) {
|
|
153
153
|
(0, child_process_1.execSync)(`yarn config set unsafeHttpWhitelist --json '${JSON.stringify(Array.from(currentWhitelist))}'` + (options.location === 'user' ? ' --home' : ''));
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
@@ -50,7 +50,7 @@ async function initGenerator(tree, schema) {
|
|
|
50
50
|
'@swc-node/register': versions_1.swcNodeVersion,
|
|
51
51
|
'@swc/core': versions_1.swcCoreVersion,
|
|
52
52
|
};
|
|
53
|
-
if (!schema.js) {
|
|
53
|
+
if (!schema.js && !schema.keepExistingVersions) {
|
|
54
54
|
const installedTsVersion = await getInstalledTypescriptVersion(tree);
|
|
55
55
|
if (!installedTsVersion ||
|
|
56
56
|
!(0, semver_2.satisfies)(installedTsVersion, versions_1.supportedTypescriptVersions, {
|
|
@@ -96,7 +96,7 @@ async function initGenerator(tree, schema) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
const installTask = !schema.skipPackageJson
|
|
99
|
-
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies)
|
|
99
|
+
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions)
|
|
100
100
|
: () => { };
|
|
101
101
|
tasks.push(installTask);
|
|
102
102
|
(0, devkit_1.ensurePackage)('prettier', versions_1.prettierVersion);
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
"description": "Skip adding package.json dependencies",
|
|
22
22
|
"x-priority": "internal"
|
|
23
23
|
},
|
|
24
|
+
"keepExistingVersions": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"x-priority": "internal",
|
|
27
|
+
"description": "Keep existing dependencies versions",
|
|
28
|
+
"default": false
|
|
29
|
+
},
|
|
24
30
|
"tsConfigName": {
|
|
25
31
|
"type": "string",
|
|
26
32
|
"description": "Customize the generated tsconfig file name.",
|
|
@@ -25,6 +25,10 @@ async function releaseVersionGenerator(tree, options) {
|
|
|
25
25
|
// The node semver library classes a leading `v` as valid, but we want to ensure it is not present in the final version
|
|
26
26
|
options.specifier = options.specifier.replace(/^v/, '');
|
|
27
27
|
}
|
|
28
|
+
if (options.firstRelease) {
|
|
29
|
+
// always use disk as a fallback for the first release
|
|
30
|
+
options.fallbackCurrentVersionResolver = 'disk';
|
|
31
|
+
}
|
|
28
32
|
const projects = options.projects;
|
|
29
33
|
const createResolvePackageRoot = (customPackageRoot) => (projectNode) => {
|
|
30
34
|
// Default to the project root if no custom packageRoot
|
|
@@ -44,6 +48,7 @@ async function releaseVersionGenerator(tree, options) {
|
|
|
44
48
|
projectNameToPackageRootMap.set(project.name, resolvePackageRoot(project));
|
|
45
49
|
}
|
|
46
50
|
let currentVersion;
|
|
51
|
+
let currentVersionResolvedFromFallback = false;
|
|
47
52
|
// only used for options.currentVersionResolver === 'git-tag', but
|
|
48
53
|
// must be declared here in order to reuse it for additional projects
|
|
49
54
|
let latestMatchingGitTag;
|
|
@@ -85,23 +90,41 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
85
90
|
spinner.color =
|
|
86
91
|
color.spinnerColor;
|
|
87
92
|
spinner.start();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
try {
|
|
94
|
+
// Must be non-blocking async to allow spinner to render
|
|
95
|
+
currentVersion = await new Promise((resolve, reject) => {
|
|
96
|
+
(0, child_process_1.exec)(`npm view ${packageName} version --registry=${registry} --tag=${tag}`, (error, stdout, stderr) => {
|
|
97
|
+
if (error) {
|
|
98
|
+
return reject(error);
|
|
99
|
+
}
|
|
100
|
+
if (stderr) {
|
|
101
|
+
return reject(stderr);
|
|
102
|
+
}
|
|
103
|
+
return resolve(stdout.trim());
|
|
104
|
+
});
|
|
98
105
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
spinner.stop();
|
|
107
|
+
log(`📄 Resolved the current version as ${currentVersion} for tag "${tag}" from registry ${registry}`);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
spinner.stop();
|
|
111
|
+
if (options.fallbackCurrentVersionResolver === 'disk') {
|
|
112
|
+
log(`📄 Unable to resolve the current version from the registry ${registry}. Falling back to the version on disk of ${currentVersionFromDisk}`);
|
|
113
|
+
currentVersion = currentVersionFromDisk;
|
|
114
|
+
currentVersionResolvedFromFallback = true;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new Error(`Unable to resolve the current version from the registry ${registry}. Please ensure that the package exists in the registry in order to use the "registry" currentVersionResolver. Alternatively, you can set the "version.generatorOptions.fallbackCurrentVersionResolver" to "disk" in order to fallback to the version on disk when the registry lookup fails.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
102
120
|
}
|
|
103
121
|
else {
|
|
104
|
-
|
|
122
|
+
if (currentVersionResolvedFromFallback) {
|
|
123
|
+
log(`📄 Using the current version ${currentVersion} already resolved from disk fallback.`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
log(`📄 Using the current version ${currentVersion} already resolved from the registry ${registry}`);
|
|
127
|
+
}
|
|
105
128
|
}
|
|
106
129
|
break;
|
|
107
130
|
}
|
|
@@ -118,13 +141,27 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
118
141
|
projectName: project.name,
|
|
119
142
|
});
|
|
120
143
|
if (!latestMatchingGitTag) {
|
|
121
|
-
|
|
144
|
+
if (options.fallbackCurrentVersionResolver === 'disk') {
|
|
145
|
+
log(`📄 Unable to resolve the current version from git tag using pattern "${releaseTagPattern}". Falling back to the version on disk of ${currentVersionFromDisk}`);
|
|
146
|
+
currentVersion = currentVersionFromDisk;
|
|
147
|
+
currentVersionResolvedFromFallback = true;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw new Error(`No git tags matching pattern "${releaseTagPattern}" for project "${project.name}" were found. You will need to create an initial matching tag to use as a base for determining the next version. Alternatively, you can set the "version.generatorOptions.fallbackCurrentVersionResolver" to "disk" in order to fallback to the version on disk when no matching git tags are found.`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
currentVersion = latestMatchingGitTag.extractedVersion;
|
|
155
|
+
log(`📄 Resolved the current version as ${currentVersion} from git tag "${latestMatchingGitTag.tag}".`);
|
|
122
156
|
}
|
|
123
|
-
currentVersion = latestMatchingGitTag.extractedVersion;
|
|
124
|
-
log(`📄 Resolved the current version as ${currentVersion} from git tag "${latestMatchingGitTag.tag}".`);
|
|
125
157
|
}
|
|
126
158
|
else {
|
|
127
|
-
|
|
159
|
+
if (currentVersionResolvedFromFallback) {
|
|
160
|
+
log(`📄 Using the current version ${currentVersion} already resolved from disk fallback.`);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
log(`📄 Using the current version ${currentVersion} already resolved from git tag "${latestMatchingGitTag.tag}".`);
|
|
164
|
+
}
|
|
128
165
|
}
|
|
129
166
|
break;
|
|
130
167
|
}
|
|
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const add_swc_config_1 = require("../../utils/swc/add-swc-config");
|
|
6
6
|
const add_swc_dependencies_1 = require("../../utils/swc/add-swc-dependencies");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
|
+
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
8
9
|
async function setupBuildGenerator(tree, options) {
|
|
9
10
|
const tasks = [];
|
|
10
11
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
@@ -101,6 +102,7 @@ async function setupBuildGenerator(tree, options) {
|
|
|
101
102
|
break;
|
|
102
103
|
}
|
|
103
104
|
case 'tsc': {
|
|
105
|
+
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, '@nx/js:tsc');
|
|
104
106
|
const outputPath = (0, devkit_1.joinPathFragments)('dist', project.root);
|
|
105
107
|
project.targets[buildTarget] = {
|
|
106
108
|
executor: `@nx/js:tsc`,
|
|
@@ -116,6 +118,7 @@ async function setupBuildGenerator(tree, options) {
|
|
|
116
118
|
break;
|
|
117
119
|
}
|
|
118
120
|
case 'swc': {
|
|
121
|
+
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, '@nx/js:swc');
|
|
119
122
|
const outputPath = (0, devkit_1.joinPathFragments)('dist', project.root);
|
|
120
123
|
project.targets[buildTarget] = {
|
|
121
124
|
executor: `@nx/js:swc`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CopyAssetsHandler = exports.defaultFileEventHandler = void 0;
|
|
4
|
-
const
|
|
4
|
+
const minimatch_1 = require("minimatch");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fse = require("fs-extra");
|
|
7
7
|
const ignore_1 = require("ignore");
|
|
@@ -114,8 +114,8 @@ class CopyAssetsHandler {
|
|
|
114
114
|
for (const event of events) {
|
|
115
115
|
const pathFromRoot = path.relative(this.rootDir, event.path);
|
|
116
116
|
for (const ag of this.assetGlobs) {
|
|
117
|
-
if (minimatch(pathFromRoot, ag.pattern) &&
|
|
118
|
-
!ag.ignore?.some((ig) => minimatch(pathFromRoot, ig)) &&
|
|
117
|
+
if ((0, minimatch_1.minimatch)(pathFromRoot, ag.pattern) &&
|
|
118
|
+
!ag.ignore?.some((ig) => (0, minimatch_1.minimatch)(pathFromRoot, ig)) &&
|
|
119
119
|
!this.ignore.ignores(pathFromRoot)) {
|
|
120
120
|
const relPath = path.relative(ag.input, pathFromRoot);
|
|
121
121
|
const destPath = relPath.startsWith('..') ? pathFromRoot : relPath;
|
|
@@ -134,7 +134,7 @@ class CopyAssetsHandler {
|
|
|
134
134
|
}
|
|
135
135
|
filesToEvent(files, assetGlob) {
|
|
136
136
|
return files.reduce((acc, src) => {
|
|
137
|
-
if (!assetGlob.ignore?.some((ig) => minimatch(src, ig)) &&
|
|
137
|
+
if (!assetGlob.ignore?.some((ig) => (0, minimatch_1.minimatch)(src, ig)) &&
|
|
138
138
|
!this.ignore.ignores(src)) {
|
|
139
139
|
const relPath = path.relative(assetGlob.input, src);
|
|
140
140
|
const dest = relPath.startsWith('..') ? src : relPath;
|