@nx/js 17.2.0-beta.5 → 17.2.0-beta.8
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "17.2.0-beta.
|
|
3
|
+
"version": "17.2.0-beta.8",
|
|
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": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"semver": "7.5.3",
|
|
58
58
|
"source-map-support": "0.5.19",
|
|
59
59
|
"tslib": "^2.3.0",
|
|
60
|
-
"@nx/devkit": "17.2.0-beta.
|
|
61
|
-
"@nx/workspace": "17.2.0-beta.
|
|
62
|
-
"@nrwl/js": "17.2.0-beta.
|
|
60
|
+
"@nx/devkit": "17.2.0-beta.8",
|
|
61
|
+
"@nx/workspace": "17.2.0-beta.8",
|
|
62
|
+
"@nrwl/js": "17.2.0-beta.8"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"verdaccio": "^5.0.4"
|
|
@@ -27,14 +27,18 @@ async function runExecutor(options, context) {
|
|
|
27
27
|
? `package "${packageName}"`
|
|
28
28
|
: `package "${packageName}" from project "${context.projectName}"`;
|
|
29
29
|
if (projectPackageJson.private === true) {
|
|
30
|
-
console.warn(`
|
|
30
|
+
console.warn(`Skipped ${packageTxt}, because it has \`"private": true\` in ${packageJsonPath}`);
|
|
31
31
|
return {
|
|
32
32
|
success: true,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
const npmPublishCommandSegments = [`npm publish --json`];
|
|
36
|
+
const npmViewCommandSegments = [
|
|
37
|
+
`npm view ${packageName} versions dist-tags --json`,
|
|
38
|
+
];
|
|
36
39
|
if (options.registry) {
|
|
37
40
|
npmPublishCommandSegments.push(`--registry=${options.registry}`);
|
|
41
|
+
npmViewCommandSegments.push(`--registry=${options.registry}`);
|
|
38
42
|
}
|
|
39
43
|
if (options.tag) {
|
|
40
44
|
npmPublishCommandSegments.push(`--tag=${options.tag}`);
|
|
@@ -48,6 +52,76 @@ async function runExecutor(options, context) {
|
|
|
48
52
|
// Resolve values using the `npm config` command so that things like environment variables and `publishConfig`s are accounted for
|
|
49
53
|
const registry = options.registry ?? (0, child_process_1.execSync)(`npm config get registry`).toString().trim();
|
|
50
54
|
const tag = options.tag ?? (0, child_process_1.execSync)(`npm config get tag`).toString().trim();
|
|
55
|
+
const currentVersion = projectPackageJson.version;
|
|
56
|
+
try {
|
|
57
|
+
const result = (0, child_process_1.execSync)(npmViewCommandSegments.join(' '), {
|
|
58
|
+
env: processEnv(true),
|
|
59
|
+
cwd: packageRoot,
|
|
60
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
61
|
+
});
|
|
62
|
+
const resultJson = JSON.parse(result.toString());
|
|
63
|
+
const distTags = resultJson['dist-tags'] || {};
|
|
64
|
+
if (distTags[tag] === currentVersion) {
|
|
65
|
+
console.warn(`Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`);
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (resultJson.versions.includes(currentVersion)) {
|
|
71
|
+
try {
|
|
72
|
+
if (!options.dryRun) {
|
|
73
|
+
(0, child_process_1.execSync)(`npm dist-tag add ${packageName}@${currentVersion} ${tag} --registry=${registry}`, {
|
|
74
|
+
env: processEnv(true),
|
|
75
|
+
cwd: packageRoot,
|
|
76
|
+
stdio: 'ignore',
|
|
77
|
+
});
|
|
78
|
+
console.log(`Added the dist-tag ${tag} to v${currentVersion} for registry ${registry}.\n`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.log(`Would add the dist-tag ${tag} to v${currentVersion} for registry ${registry}, but ${chalk.keyword('orange')('[dry-run]')} was set.\n`);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
try {
|
|
89
|
+
const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
|
|
90
|
+
console.error('npm dist-tag add error:');
|
|
91
|
+
if (stdoutData.error.summary) {
|
|
92
|
+
console.error(stdoutData.error.summary);
|
|
93
|
+
}
|
|
94
|
+
if (stdoutData.error.detail) {
|
|
95
|
+
console.error(stdoutData.error.detail);
|
|
96
|
+
}
|
|
97
|
+
if (context.isVerbose) {
|
|
98
|
+
console.error('npm dist-tag add stdout:');
|
|
99
|
+
console.error(JSON.stringify(stdoutData, null, 2));
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
console.error('Something unexpected went wrong when processing the npm dist-tag add output\n', err);
|
|
107
|
+
return {
|
|
108
|
+
success: false,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
|
|
116
|
+
// If the error is that the package doesn't exist, then we can ignore it because we will be publishing it for the first time in the next step
|
|
117
|
+
if (!(stdoutData.error?.code?.includes('E404') &&
|
|
118
|
+
stdoutData.error?.summary?.includes('no such package available'))) {
|
|
119
|
+
console.error(`Something unexpected went wrong when checking for existing dist-tags.\n`, err);
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
51
125
|
try {
|
|
52
126
|
const output = (0, child_process_1.execSync)(npmPublishCommandSegments.join(' '), {
|
|
53
127
|
maxBuffer: LARGE_BUFFER,
|
|
@@ -71,22 +145,7 @@ async function runExecutor(options, context) {
|
|
|
71
145
|
}
|
|
72
146
|
catch (err) {
|
|
73
147
|
try {
|
|
74
|
-
const currentVersion = projectPackageJson.version;
|
|
75
148
|
const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
|
|
76
|
-
if (
|
|
77
|
-
// handle npm conflict error
|
|
78
|
-
stdoutData.error?.code === 'EPUBLISHCONFLICT' ||
|
|
79
|
-
// handle npm conflict error when the package has a scope
|
|
80
|
-
(stdoutData.error?.code === 'E403' &&
|
|
81
|
-
stdoutData.error?.summary?.includes('You cannot publish over the previously published versions')) ||
|
|
82
|
-
// handle verdaccio conflict error
|
|
83
|
-
(stdoutData.error?.code === 'E409' &&
|
|
84
|
-
stdoutData.error?.summary?.includes('this package is already present'))) {
|
|
85
|
-
console.warn(`Skipping ${packageTxt}, as v${currentVersion} has already been published to ${registry} with tag "${tag}"`);
|
|
86
|
-
return {
|
|
87
|
-
success: true,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
149
|
console.error('npm publish error:');
|
|
91
150
|
if (stdoutData.error.summary) {
|
|
92
151
|
console.error(stdoutData.error.summary);
|
|
@@ -103,8 +162,6 @@ async function runExecutor(options, context) {
|
|
|
103
162
|
};
|
|
104
163
|
}
|
|
105
164
|
catch (err) {
|
|
106
|
-
// npm v9 onwards seems to guarantee stdout will be well formed JSON when --json is used, so maybe we need to
|
|
107
|
-
// specify that as minimum supported version? (comes with node 18 and 20 by default)
|
|
108
165
|
console.error('Something unexpected went wrong when processing the npm publish output\n', err);
|
|
109
166
|
return {
|
|
110
167
|
success: false,
|
|
@@ -162,9 +162,6 @@ function addProject(tree, options) {
|
|
|
162
162
|
}
|
|
163
163
|
async function addLint(tree, options) {
|
|
164
164
|
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
|
|
165
|
-
const { mapLintPattern } =
|
|
166
|
-
// nx-ignore-next-line
|
|
167
|
-
require('@nx/eslint/src/generators/lint-project/lint-project');
|
|
168
165
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.name);
|
|
169
166
|
const task = lintProjectGenerator(tree, {
|
|
170
167
|
project: options.name,
|
|
@@ -174,9 +171,6 @@ async function addLint(tree, options) {
|
|
|
174
171
|
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
175
172
|
],
|
|
176
173
|
unitTestRunner: options.unitTestRunner,
|
|
177
|
-
eslintFilePatterns: [
|
|
178
|
-
mapLintPattern(options.projectRoot, options.js ? 'js' : 'ts', options.rootProject),
|
|
179
|
-
],
|
|
180
174
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
181
175
|
rootProject: options.rootProject,
|
|
182
176
|
});
|
|
@@ -186,25 +186,31 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
186
186
|
throw new Error(`Invalid specifierSource "${specifierSource}" provided. Must be one of "prompt" or "conventional-commits"`);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
+
// Resolve any local package dependencies for this project (before applying the new version or updating the versionData)
|
|
190
|
+
const localPackageDependencies = (0, resolve_local_package_dependencies_1.resolveLocalPackageDependencies)(tree, options.projectGraph, projects, projectNameToPackageRootMap, resolvePackageRoot,
|
|
191
|
+
// includeAll when the release group is independent, as we may be filtering to a specific subset of projects, but we still want to update their dependents
|
|
192
|
+
options.releaseGroup.projectsRelationship === 'independent');
|
|
193
|
+
const dependentProjects = Object.values(localPackageDependencies)
|
|
194
|
+
.flat()
|
|
195
|
+
.filter((localPackageDependency) => {
|
|
196
|
+
return localPackageDependency.target === project.name;
|
|
197
|
+
});
|
|
198
|
+
versionData[projectName] = {
|
|
199
|
+
currentVersion,
|
|
200
|
+
dependentProjects,
|
|
201
|
+
newVersion: null, // will stay as null in the final result the case that no changes are detected
|
|
202
|
+
};
|
|
189
203
|
if (!specifier) {
|
|
190
204
|
log(`🚫 Skipping versioning "${projectPackageJson.name}" as no changes were detected.`);
|
|
191
205
|
continue;
|
|
192
206
|
}
|
|
193
|
-
// Resolve any local package dependencies for this project (before applying the new version)
|
|
194
|
-
const localPackageDependencies = (0, resolve_local_package_dependencies_1.resolveLocalPackageDependencies)(tree, options.projectGraph, projects, projectNameToPackageRootMap, resolvePackageRoot,
|
|
195
|
-
// includeAll when the release group is independent, as we may be filtering to a specific subset of projects, but we still want to update their dependents
|
|
196
|
-
options.releaseGroup.projectsRelationship === 'independent');
|
|
197
207
|
const newVersion = (0, version_1.deriveNewSemverVersion)(currentVersion, specifier, options.preid);
|
|
208
|
+
versionData[projectName].newVersion = newVersion;
|
|
198
209
|
(0, devkit_1.writeJson)(tree, packageJsonPath, {
|
|
199
210
|
...projectPackageJson,
|
|
200
211
|
version: newVersion,
|
|
201
212
|
});
|
|
202
213
|
log(`✍️ New version ${newVersion} written to ${workspaceRelativePackageJsonPath}`);
|
|
203
|
-
const dependentProjects = Object.values(localPackageDependencies)
|
|
204
|
-
.flat()
|
|
205
|
-
.filter((localPackageDependency) => {
|
|
206
|
-
return localPackageDependency.target === project.name;
|
|
207
|
-
});
|
|
208
214
|
if (dependentProjects.length > 0) {
|
|
209
215
|
log(`✍️ Applying new version ${newVersion} to ${dependentProjects.length} ${dependentProjects.length > 1
|
|
210
216
|
? 'packages which depend'
|
|
@@ -217,11 +223,6 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
217
223
|
return json;
|
|
218
224
|
});
|
|
219
225
|
}
|
|
220
|
-
versionData[projectName] = {
|
|
221
|
-
currentVersion,
|
|
222
|
-
newVersion,
|
|
223
|
-
dependentProjects,
|
|
224
|
-
};
|
|
225
226
|
}
|
|
226
227
|
/**
|
|
227
228
|
* Ensure that formatting is applied so that version bump diffs are as mimimal as possible
|