pubz 0.7.4 → 0.7.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/dist/cli.js +49 -21
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -549,6 +549,10 @@ function isOtpError(output) {
|
|
|
549
549
|
return output.includes("EOTP") || output.includes("one-time password");
|
|
550
550
|
}
|
|
551
551
|
var NPM_COMMAND = process.env.PUBZ_NPM_COMMAND ?? "npm";
|
|
552
|
+
async function isVersionPublished(packageName, version, registry) {
|
|
553
|
+
const result = await runStdout(NPM_COMMAND, ["view", `${packageName}@${version}`, "version", "--registry", registry], homedir2());
|
|
554
|
+
return result.trim() === version;
|
|
555
|
+
}
|
|
552
556
|
async function publishPackage(pkg, registry, context, dryRun) {
|
|
553
557
|
if (dryRun) {
|
|
554
558
|
return { success: true };
|
|
@@ -613,11 +617,15 @@ async function createGitTag(version, cwd, dryRun) {
|
|
|
613
617
|
if (dryRun) {
|
|
614
618
|
return { success: true };
|
|
615
619
|
}
|
|
620
|
+
const existing = await runStdout("git", ["tag", "-l", tagName], cwd);
|
|
621
|
+
if (existing.trim() === tagName) {
|
|
622
|
+
return { success: true };
|
|
623
|
+
}
|
|
616
624
|
const tagResult = await run("git", ["tag", tagName], cwd);
|
|
617
625
|
if (tagResult.code !== 0) {
|
|
618
626
|
return {
|
|
619
627
|
success: false,
|
|
620
|
-
error: `Failed to create tag ${tagName}
|
|
628
|
+
error: `Failed to create tag ${tagName}`
|
|
621
629
|
};
|
|
622
630
|
}
|
|
623
631
|
return { success: true };
|
|
@@ -864,6 +872,12 @@ async function createGitHubRelease(version, body, cwd, dryRun) {
|
|
|
864
872
|
console.log(`[DRY RUN] Would create GitHub release for ${tagName}`);
|
|
865
873
|
return { success: true };
|
|
866
874
|
}
|
|
875
|
+
const existing = await runSilent(GH_COMMAND, ["release", "view", tagName], cwd);
|
|
876
|
+
if (existing.code === 0) {
|
|
877
|
+
const url2 = existing.output.trim().split(`
|
|
878
|
+
`).find((l) => l.startsWith("https://"))?.trim();
|
|
879
|
+
return { success: true, url: url2 };
|
|
880
|
+
}
|
|
867
881
|
const result = await runSilent(GH_COMMAND, ["release", "create", tagName, "--title", tagName, "--notes", body], cwd);
|
|
868
882
|
if (result.code !== 0) {
|
|
869
883
|
return {
|
|
@@ -1259,29 +1273,38 @@ async function main() {
|
|
|
1259
1273
|
console.log("");
|
|
1260
1274
|
}
|
|
1261
1275
|
if (didBump) {
|
|
1262
|
-
|
|
1263
|
-
if (
|
|
1264
|
-
|
|
1276
|
+
const onDiskVersion = JSON.parse(readFileSync2(packages[0].packageJsonPath, "utf-8")).version;
|
|
1277
|
+
if (onDiskVersion === newVersion) {
|
|
1278
|
+
console.log(dim(`⏭ Version already set to ${newVersion}, skipping bump`));
|
|
1279
|
+
console.log("");
|
|
1280
|
+
for (const pkg of packages) {
|
|
1281
|
+
pkg.version = newVersion;
|
|
1282
|
+
}
|
|
1265
1283
|
} else {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1284
|
+
frameHeader("\uD83D\uDD16 Version");
|
|
1285
|
+
if (options.version && ["patch", "minor", "major"].includes(options.version)) {
|
|
1286
|
+
frameLine(`Bumping (${options.version}): ${yellow(currentVersion)} → ${green(newVersion)}`);
|
|
1287
|
+
} else {
|
|
1288
|
+
frameLine(`${yellow(currentVersion)} → ${green(newVersion)}`);
|
|
1289
|
+
}
|
|
1290
|
+
frameLine(dim("Updating all packages..."));
|
|
1291
|
+
for (const pkg of packages) {
|
|
1292
|
+
await updatePackageVersion(pkg, newVersion, options.dryRun);
|
|
1293
|
+
}
|
|
1294
|
+
await updateLocalDependencyVersions(packages, newVersion, options.dryRun);
|
|
1295
|
+
for (const pkg of packages) {
|
|
1296
|
+
pkg.version = newVersion;
|
|
1297
|
+
}
|
|
1298
|
+
const commitResult = await commitVersionBump(newVersion, cwd, options.dryRun);
|
|
1299
|
+
if (!commitResult.success) {
|
|
1300
|
+
frameFooter();
|
|
1301
|
+
console.error(red(bold("Failed to commit version bump:")) + ` ${commitResult.error}`);
|
|
1302
|
+
closePrompt();
|
|
1303
|
+
process.exit(1);
|
|
1304
|
+
}
|
|
1278
1305
|
frameFooter();
|
|
1279
|
-
console.
|
|
1280
|
-
closePrompt();
|
|
1281
|
-
process.exit(1);
|
|
1306
|
+
console.log("");
|
|
1282
1307
|
}
|
|
1283
|
-
frameFooter();
|
|
1284
|
-
console.log("");
|
|
1285
1308
|
}
|
|
1286
1309
|
if (!options.skipBuild) {
|
|
1287
1310
|
frameHeader("\uD83C\uDFD7️ Build");
|
|
@@ -1403,6 +1426,11 @@ async function main() {
|
|
|
1403
1426
|
if (options.dryRun) {
|
|
1404
1427
|
frameLine(` ${dim("[dry run]")} ${cyan(pkg.name)}${dim("@")}${yellow(newVersion)}`);
|
|
1405
1428
|
} else {
|
|
1429
|
+
const alreadyPublished = await isVersionPublished(pkg.name, newVersion, registry);
|
|
1430
|
+
if (alreadyPublished) {
|
|
1431
|
+
frameLine(` ${dim("⏭")} ${cyan(pkg.name)}${dim("@")}${yellow(newVersion)} ${dim("already published, skipping")}`);
|
|
1432
|
+
continue;
|
|
1433
|
+
}
|
|
1406
1434
|
frameLine(dim(` Publishing ${pkg.name}...`));
|
|
1407
1435
|
}
|
|
1408
1436
|
const result = await publishPackage(pkg, registry, publishContext, options.dryRun);
|