@ucdjs/release-scripts 0.1.0-beta.61 → 0.1.0-beta.62
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/dist/index.mjs +44 -18
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1226,6 +1226,23 @@ function isValidSemver(version) {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
function getNextVersion(currentVersion, bump) {
|
|
1228
1228
|
if (bump === "none") return currentVersion;
|
|
1229
|
+
if (!isValidSemver(currentVersion)) throw new Error(`Cannot bump version for invalid semver: ${currentVersion}`);
|
|
1230
|
+
if (semver.prerelease(currentVersion)) {
|
|
1231
|
+
const identifier = getPrereleaseIdentifier(currentVersion);
|
|
1232
|
+
const next = identifier ? semver.inc(currentVersion, "prerelease", identifier) : semver.inc(currentVersion, "prerelease");
|
|
1233
|
+
if (!next) throw new Error(`Failed to bump prerelease version ${currentVersion}`);
|
|
1234
|
+
return next;
|
|
1235
|
+
}
|
|
1236
|
+
const next = semver.inc(currentVersion, bump);
|
|
1237
|
+
if (!next) throw new Error(`Failed to bump version ${currentVersion} with bump ${bump}`);
|
|
1238
|
+
return next;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Like getNextVersion but always produces a stable version, even when
|
|
1242
|
+
* currentVersion is a prerelease. Use this when the caller explicitly wants
|
|
1243
|
+
* to promote to a stable release (e.g. patch/minor/major prompt choices).
|
|
1244
|
+
*/
|
|
1245
|
+
function getNextStableVersion(currentVersion, bump) {
|
|
1229
1246
|
if (!isValidSemver(currentVersion)) throw new Error(`Cannot bump version for invalid semver: ${currentVersion}`);
|
|
1230
1247
|
const next = semver.inc(currentVersion, bump);
|
|
1231
1248
|
if (!next) throw new Error(`Failed to bump version ${currentVersion} with bump ${bump}`);
|
|
@@ -1306,15 +1323,15 @@ async function selectVersionPrompt(workspaceRoot, pkg, currentVersion, suggested
|
|
|
1306
1323
|
}] : [],
|
|
1307
1324
|
{
|
|
1308
1325
|
value: "patch",
|
|
1309
|
-
title: `patch ${farver.bold(
|
|
1326
|
+
title: `patch ${farver.bold(getNextStableVersion(pkg.version, "patch"))}`
|
|
1310
1327
|
},
|
|
1311
1328
|
{
|
|
1312
1329
|
value: "minor",
|
|
1313
|
-
title: `minor ${farver.bold(
|
|
1330
|
+
title: `minor ${farver.bold(getNextStableVersion(pkg.version, "minor"))}`
|
|
1314
1331
|
},
|
|
1315
1332
|
{
|
|
1316
1333
|
value: "major",
|
|
1317
|
-
title: `major ${farver.bold(
|
|
1334
|
+
title: `major ${farver.bold(getNextStableVersion(pkg.version, "major"))}`
|
|
1318
1335
|
},
|
|
1319
1336
|
{
|
|
1320
1337
|
value: "prerelease",
|
|
@@ -1416,7 +1433,8 @@ async function selectVersionPrompt(workspaceRoot, pkg, currentVersion, suggested
|
|
|
1416
1433
|
}
|
|
1417
1434
|
const prereleaseVersion = prereleaseVersionByChoice[answers.version];
|
|
1418
1435
|
if (prereleaseVersion) return prereleaseVersion;
|
|
1419
|
-
|
|
1436
|
+
const stableBump = answers.version;
|
|
1437
|
+
return getNextStableVersion(pkg.version, stableBump);
|
|
1420
1438
|
}
|
|
1421
1439
|
async function confirmOverridePrompt(pkg, overrideVersion) {
|
|
1422
1440
|
const response = await prompts({
|
|
@@ -2637,24 +2655,32 @@ async function publishWorkflow(options) {
|
|
|
2637
2655
|
status.failed.push(packageName);
|
|
2638
2656
|
exitWithError(`Publishing failed for ${packageName}.`, "Check your network connection and NPM registry access", existsResult.error);
|
|
2639
2657
|
}
|
|
2640
|
-
|
|
2641
|
-
|
|
2658
|
+
const npmExists = existsResult.value;
|
|
2659
|
+
let changelogEntryExists = false;
|
|
2660
|
+
const changelogPath = join(pkg.path, "CHANGELOG.md");
|
|
2661
|
+
try {
|
|
2662
|
+
changelogEntryExists = parseChangelog(await readFile(changelogPath, "utf-8")).versions.some((v) => v.version === version);
|
|
2663
|
+
} catch {}
|
|
2664
|
+
if (npmExists && changelogEntryExists) {
|
|
2665
|
+
logger.info(`Version ${farver.cyan(version)} already exists on NPM and in changelog, skipping`);
|
|
2642
2666
|
status.skipped.push(packageName);
|
|
2643
2667
|
continue;
|
|
2644
2668
|
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2669
|
+
if (!npmExists) {
|
|
2670
|
+
logger.step(`Publishing ${farver.cyan(`${packageName}@${version}`)} to NPM...`);
|
|
2671
|
+
const publishResult = await publishPackage(packageName, version, options.workspaceRoot, options);
|
|
2672
|
+
if (!publishResult.ok) {
|
|
2673
|
+
logger.error(`Failed to publish: ${publishResult.error.message}`);
|
|
2674
|
+
status.failed.push(packageName);
|
|
2675
|
+
let hint;
|
|
2676
|
+
if (publishResult.error.code === "E403") hint = "Authentication failed. Ensure your NPM token or OIDC configuration is correct";
|
|
2677
|
+
else if (publishResult.error.code === "EPUBLISHCONFLICT") hint = "Version conflict. The version may have been published recently";
|
|
2678
|
+
else if (publishResult.error.code === "EOTP") hint = "2FA/OTP required. Provide the otp option or use OIDC authentication";
|
|
2679
|
+
exitWithError(`Publishing failed for ${packageName}`, hint, publishResult.error);
|
|
2680
|
+
}
|
|
2681
|
+
logger.success(`Published ${farver.cyan(`${packageName}@${version}`)}`);
|
|
2682
|
+
status.published.push(packageName);
|
|
2655
2683
|
}
|
|
2656
|
-
logger.success(`Published ${farver.cyan(`${packageName}@${version}`)}`);
|
|
2657
|
-
status.published.push(packageName);
|
|
2658
2684
|
logger.step(`Creating git tag ${farver.cyan(`${packageName}@${version}`)}...`);
|
|
2659
2685
|
const tagResult = await createAndPushPackageTag(packageName, version, options.workspaceRoot);
|
|
2660
2686
|
const tagName = `${packageName}@${version}`;
|