@nx/js 19.6.0-beta.0 → 19.6.0-beta.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "19.6.0-beta.
|
|
3
|
+
"version": "19.6.0-beta.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": {
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"semver": "^7.5.3",
|
|
59
59
|
"source-map-support": "0.5.19",
|
|
60
60
|
"tslib": "^2.3.0",
|
|
61
|
-
"@nx/devkit": "19.6.0-beta.
|
|
62
|
-
"@nx/workspace": "19.6.0-beta.
|
|
63
|
-
"@nrwl/js": "19.6.0-beta.
|
|
61
|
+
"@nx/devkit": "19.6.0-beta.1",
|
|
62
|
+
"@nx/workspace": "19.6.0-beta.1",
|
|
63
|
+
"@nrwl/js": "19.6.0-beta.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"verdaccio": "^5.0.4"
|
|
@@ -19,6 +19,7 @@ const resolve_local_package_dependencies_1 = require("./utils/resolve-local-pack
|
|
|
19
19
|
const sort_projects_topologically_1 = require("./utils/sort-projects-topologically");
|
|
20
20
|
const update_lock_file_1 = require("./utils/update-lock-file");
|
|
21
21
|
async function releaseVersionGenerator(tree, options) {
|
|
22
|
+
let logger;
|
|
22
23
|
try {
|
|
23
24
|
const versionData = {};
|
|
24
25
|
// If the user provided a specifier, validate that it is valid semver or a relative semver keyword
|
|
@@ -67,6 +68,8 @@ Valid values are: ${version_1.validReleaseVersionPrefixes
|
|
|
67
68
|
? options.specifier
|
|
68
69
|
: undefined;
|
|
69
70
|
const deleteVersionPlanCallbacks = [];
|
|
71
|
+
// If the user has set the logUnchangedProjects option to false, we will not print any logs for projects that have no changes.
|
|
72
|
+
const logUnchangedProjects = options.logUnchangedProjects ?? true;
|
|
70
73
|
for (const project of projects) {
|
|
71
74
|
const projectName = project.name;
|
|
72
75
|
const packageRoot = projectNameToPackageRootMap.get(projectName);
|
|
@@ -74,18 +77,15 @@ Valid values are: ${version_1.validReleaseVersionPrefixes
|
|
|
74
77
|
throw new Error(`The project "${projectName}" does not have a packageRoot available. Please report this issue on https://github.com/nrwl/nx`);
|
|
75
78
|
}
|
|
76
79
|
const packageJsonPath = (0, node_path_1.join)(packageRoot, 'package.json');
|
|
77
|
-
const color = getColor(projectName);
|
|
78
|
-
const log = (msg) => {
|
|
79
|
-
console.log(color.instance.bold(projectName) + ' ' + msg);
|
|
80
|
-
};
|
|
81
80
|
if (!tree.exists(packageJsonPath)) {
|
|
82
81
|
throw new Error(`The project "${projectName}" does not have a package.json available at ${packageJsonPath}.
|
|
83
82
|
|
|
84
83
|
To fix this you will either need to add a package.json file at that location, or configure "release" within your nx.json to exclude "${projectName}" from the current release group, or amend the packageRoot configuration to point to where the package.json should be.`);
|
|
85
84
|
}
|
|
86
|
-
|
|
85
|
+
const color = getColor(projectName);
|
|
86
|
+
logger = new ProjectLogger(projectName, color);
|
|
87
87
|
const packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
|
|
88
|
-
|
|
88
|
+
logger.buffer(`🔍 Reading data for package "${packageJson.name}" from ${packageJsonPath}`);
|
|
89
89
|
const { name: packageName, version: currentVersionFromDisk } = packageJson;
|
|
90
90
|
switch (options.currentVersionResolver) {
|
|
91
91
|
case 'registry': {
|
|
@@ -128,12 +128,12 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
128
128
|
});
|
|
129
129
|
});
|
|
130
130
|
spinner.stop();
|
|
131
|
-
|
|
131
|
+
logger.buffer(`📄 Resolved the current version as ${currentVersion} for tag "${tag}" from registry ${registry}`);
|
|
132
132
|
}
|
|
133
133
|
catch (e) {
|
|
134
134
|
spinner.stop();
|
|
135
135
|
if (options.fallbackCurrentVersionResolver === 'disk') {
|
|
136
|
-
|
|
136
|
+
logger.buffer(`📄 Unable to resolve the current version from the registry ${registry}. Falling back to the version on disk of ${currentVersionFromDisk}`);
|
|
137
137
|
currentVersion = currentVersionFromDisk;
|
|
138
138
|
currentVersionResolvedFromFallback = true;
|
|
139
139
|
}
|
|
@@ -144,10 +144,10 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
146
|
if (currentVersionResolvedFromFallback) {
|
|
147
|
-
|
|
147
|
+
logger.buffer(`📄 Using the current version ${currentVersion} already resolved from disk fallback.`);
|
|
148
148
|
}
|
|
149
149
|
else {
|
|
150
|
-
|
|
150
|
+
logger.buffer(`📄 Using the current version ${currentVersion} already resolved from the registry ${registry}`);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
break;
|
|
@@ -157,7 +157,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
157
157
|
if (!currentVersion) {
|
|
158
158
|
throw new Error(`Unable to determine the current version for project "${project.name}" from ${packageJsonPath}`);
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
logger.buffer(`📄 Resolved the current version as ${currentVersion} from ${packageJsonPath}`);
|
|
161
161
|
break;
|
|
162
162
|
case 'git-tag': {
|
|
163
163
|
if (!currentVersion ||
|
|
@@ -169,7 +169,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
169
169
|
});
|
|
170
170
|
if (!latestMatchingGitTag) {
|
|
171
171
|
if (options.fallbackCurrentVersionResolver === 'disk') {
|
|
172
|
-
|
|
172
|
+
logger.buffer(`📄 Unable to resolve the current version from git tag using pattern "${releaseTagPattern}". Falling back to the version on disk of ${currentVersionFromDisk}`);
|
|
173
173
|
currentVersion = currentVersionFromDisk;
|
|
174
174
|
currentVersionResolvedFromFallback = true;
|
|
175
175
|
}
|
|
@@ -179,15 +179,15 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
181
181
|
currentVersion = latestMatchingGitTag.extractedVersion;
|
|
182
|
-
|
|
182
|
+
logger.buffer(`📄 Resolved the current version as ${currentVersion} from git tag "${latestMatchingGitTag.tag}".`);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
else {
|
|
186
186
|
if (currentVersionResolvedFromFallback) {
|
|
187
|
-
|
|
187
|
+
logger.buffer(`📄 Using the current version ${currentVersion} already resolved from disk fallback.`);
|
|
188
188
|
}
|
|
189
189
|
else {
|
|
190
|
-
|
|
190
|
+
logger.buffer(
|
|
191
191
|
// In this code path we know that latestMatchingGitTag is defined, because we are not relying on the fallbackCurrentVersionResolver, so we can safely use the non-null assertion operator
|
|
192
192
|
`📄 Using the current version ${currentVersion} already resolved from git tag "${latestMatchingGitTag.tag}".`);
|
|
193
193
|
}
|
|
@@ -198,7 +198,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
198
198
|
throw new Error(`Invalid value for options.currentVersionResolver: ${options.currentVersionResolver}`);
|
|
199
199
|
}
|
|
200
200
|
if (options.specifier) {
|
|
201
|
-
|
|
201
|
+
logger.buffer(`📄 Using the provided version specifier "${options.specifier}".`);
|
|
202
202
|
// The user is forcibly overriding whatever specifierSource they had otherwise set by imperatively providing a specifier
|
|
203
203
|
options.specifierSource = 'prompt';
|
|
204
204
|
}
|
|
@@ -240,10 +240,10 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
240
240
|
if (projectToDependencyBumps.has(projectName)) {
|
|
241
241
|
// No applicable changes to the project directly by the user, but one or more dependencies have been bumped and updateDependents is enabled
|
|
242
242
|
specifier = updateDependentsBump;
|
|
243
|
-
|
|
243
|
+
logger.buffer(`📄 Resolved the specifier as "${specifier}" because "release.version.generatorOptions.updateDependents" is enabled`);
|
|
244
244
|
break;
|
|
245
245
|
}
|
|
246
|
-
|
|
246
|
+
logger.buffer(`🚫 No changes were detected using git history and the conventional commits standard.`);
|
|
247
247
|
break;
|
|
248
248
|
}
|
|
249
249
|
// TODO: reevaluate this prerelease logic/workflow for independent projects
|
|
@@ -252,7 +252,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
252
252
|
// Users must manually graduate from a prerelease to a release by providing an explicit specifier.
|
|
253
253
|
if ((0, semver_2.prerelease)(currentVersion ?? '')) {
|
|
254
254
|
specifier = 'prerelease';
|
|
255
|
-
|
|
255
|
+
logger.buffer(`📄 Resolved the specifier as "${specifier}" since the current version is a prerelease.`);
|
|
256
256
|
}
|
|
257
257
|
else {
|
|
258
258
|
let extraText = '';
|
|
@@ -260,7 +260,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
260
260
|
specifier = `pre${specifier}`;
|
|
261
261
|
extraText = `, combined with your given preid "${options.preid}"`;
|
|
262
262
|
}
|
|
263
|
-
|
|
263
|
+
logger.buffer(`📄 Resolved the specifier as "${specifier}" using git history and the conventional commits standard${extraText}.`);
|
|
264
264
|
}
|
|
265
265
|
break;
|
|
266
266
|
}
|
|
@@ -321,15 +321,15 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
321
321
|
projectToDependencyBumps.has(projectName)) {
|
|
322
322
|
// No applicable changes to the project directly by the user, but one or more dependencies have been bumped and updateDependents is enabled
|
|
323
323
|
specifier = updateDependentsBump;
|
|
324
|
-
|
|
324
|
+
logger.buffer(`📄 Resolved the specifier as "${specifier}" because "release.version.generatorOptions.updateDependents" is enabled`);
|
|
325
325
|
}
|
|
326
326
|
else {
|
|
327
327
|
specifier = null;
|
|
328
|
-
|
|
328
|
+
logger.buffer(`🚫 No changes were detected within version plans.`);
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
else {
|
|
332
|
-
|
|
332
|
+
logger.buffer(`📄 Resolved the specifier as "${specifier}" using version plans.`);
|
|
333
333
|
}
|
|
334
334
|
if (options.deleteVersionPlans) {
|
|
335
335
|
options.releaseGroup.versionPlans.forEach((p) => {
|
|
@@ -420,7 +420,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
420
420
|
.map((dependentProject) => `${indent}- ${dependentProject.source}`)
|
|
421
421
|
.join('\n')}`;
|
|
422
422
|
logMsg += `\n${indent}=> You can adjust this behavior by setting \`version.generatorOptions.updateDependents\` to "auto"`;
|
|
423
|
-
|
|
423
|
+
logger.buffer(logMsg);
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
if (!currentVersion) {
|
|
@@ -434,7 +434,11 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
434
434
|
: dependentProjectsInCurrentBatch,
|
|
435
435
|
};
|
|
436
436
|
if (!specifier) {
|
|
437
|
-
|
|
437
|
+
logger.buffer(`🚫 Skipping versioning "${packageJson.name}" as no changes were detected.`);
|
|
438
|
+
// Print the buffered logs for this unchanged project, as long as the user has not explicitly disabled this behavior
|
|
439
|
+
if (logUnchangedProjects) {
|
|
440
|
+
logger.flush();
|
|
441
|
+
}
|
|
438
442
|
continue;
|
|
439
443
|
}
|
|
440
444
|
const newVersion = (0, version_1.deriveNewSemverVersion)(currentVersion, specifier, options.preid);
|
|
@@ -443,7 +447,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
443
447
|
...packageJson,
|
|
444
448
|
version: newVersion,
|
|
445
449
|
});
|
|
446
|
-
|
|
450
|
+
logger.buffer(`✍️ New version ${newVersion} written to ${packageJsonPath}`);
|
|
447
451
|
if (allDependentProjects.length > 0) {
|
|
448
452
|
const totalProjectsToUpdate = updateDependents === 'auto'
|
|
449
453
|
? allDependentProjects.length +
|
|
@@ -452,7 +456,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
452
456
|
circularDependencies.size / 2
|
|
453
457
|
: dependentProjectsInCurrentBatch.length;
|
|
454
458
|
if (totalProjectsToUpdate > 0) {
|
|
455
|
-
|
|
459
|
+
logger.buffer(`✍️ Applying new version ${newVersion} to ${totalProjectsToUpdate} ${totalProjectsToUpdate > 1
|
|
456
460
|
? 'packages which depend'
|
|
457
461
|
: 'package which depends'} on ${project.name}`);
|
|
458
462
|
}
|
|
@@ -555,6 +559,8 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
555
559
|
: updateDependentsBump,
|
|
556
560
|
});
|
|
557
561
|
}
|
|
562
|
+
// Print the logs that have been buffered for this project
|
|
563
|
+
logger.flush();
|
|
558
564
|
}
|
|
559
565
|
/**
|
|
560
566
|
* Ensure that formatting is applied so that version bump diffs are as minimal as possible
|
|
@@ -577,6 +583,8 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
577
583
|
};
|
|
578
584
|
}
|
|
579
585
|
catch (e) {
|
|
586
|
+
// Flush any pending logs before printing the error to make troubleshooting easier
|
|
587
|
+
logger?.flush();
|
|
580
588
|
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
581
589
|
devkit_1.output.error({
|
|
582
590
|
title: e.message,
|
|
@@ -630,3 +638,19 @@ function getColor(projectName) {
|
|
|
630
638
|
const colorIndex = code % colors.length;
|
|
631
639
|
return colors[colorIndex];
|
|
632
640
|
}
|
|
641
|
+
class ProjectLogger {
|
|
642
|
+
constructor(projectName, color) {
|
|
643
|
+
this.projectName = projectName;
|
|
644
|
+
this.color = color;
|
|
645
|
+
this.logs = [];
|
|
646
|
+
}
|
|
647
|
+
buffer(msg) {
|
|
648
|
+
this.logs.push(msg);
|
|
649
|
+
}
|
|
650
|
+
flush() {
|
|
651
|
+
devkit_1.output.logSingleLine(`Running release version for project: ${this.color.instance.bold(this.projectName)}`);
|
|
652
|
+
this.logs.forEach((msg) => {
|
|
653
|
+
console.log(this.color.instance.bold(this.projectName) + ' ' + msg);
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
}
|