pubz 0.2.2 → 0.2.3
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 +81 -17
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -539,13 +539,17 @@ Options:
|
|
|
539
539
|
--registry <url> Specify npm registry URL (default: public npm)
|
|
540
540
|
--otp <code> One-time password for 2FA
|
|
541
541
|
--skip-build Skip the build step
|
|
542
|
-
--yes, -y Skip confirmation prompts (
|
|
542
|
+
--yes, -y Skip yes/no confirmation prompts (still asks for choices)
|
|
543
|
+
--ci CI mode: skip all prompts, auto-accept everything
|
|
544
|
+
--version <value> Version bump type (patch|minor|major) or explicit version (required with --ci)
|
|
543
545
|
-h, --help Show this help message
|
|
544
546
|
|
|
545
547
|
Examples:
|
|
546
548
|
pubz # Interactive publish
|
|
547
549
|
pubz --dry-run # Preview what would happen
|
|
548
550
|
pubz --registry https://npm.pkg.github.com # Publish to GitHub Packages
|
|
551
|
+
pubz --ci --version patch # CI mode with patch bump
|
|
552
|
+
pubz --ci --version 1.2.3 # CI mode with explicit version
|
|
549
553
|
`);
|
|
550
554
|
}
|
|
551
555
|
function parseArgs(args) {
|
|
@@ -554,7 +558,9 @@ function parseArgs(args) {
|
|
|
554
558
|
registry: "",
|
|
555
559
|
otp: "",
|
|
556
560
|
skipBuild: false,
|
|
557
|
-
|
|
561
|
+
skipConfirms: false,
|
|
562
|
+
ci: false,
|
|
563
|
+
version: "",
|
|
558
564
|
help: false
|
|
559
565
|
};
|
|
560
566
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -574,7 +580,13 @@ function parseArgs(args) {
|
|
|
574
580
|
break;
|
|
575
581
|
case "--yes":
|
|
576
582
|
case "-y":
|
|
577
|
-
options.
|
|
583
|
+
options.skipConfirms = true;
|
|
584
|
+
break;
|
|
585
|
+
case "--ci":
|
|
586
|
+
options.ci = true;
|
|
587
|
+
break;
|
|
588
|
+
case "--version":
|
|
589
|
+
options.version = args[++i] || "";
|
|
578
590
|
break;
|
|
579
591
|
case "-h":
|
|
580
592
|
case "--help":
|
|
@@ -590,6 +602,18 @@ async function main() {
|
|
|
590
602
|
printUsage();
|
|
591
603
|
process.exit(0);
|
|
592
604
|
}
|
|
605
|
+
if (options.ci && !options.version) {
|
|
606
|
+
console.error(red(bold("Error:")) + " --ci requires --version to be specified");
|
|
607
|
+
console.log("");
|
|
608
|
+
console.log(muted("Examples:"));
|
|
609
|
+
console.log(muted(" pubz --ci --version patch"));
|
|
610
|
+
console.log(muted(" pubz --ci --version minor"));
|
|
611
|
+
console.log(muted(" pubz --ci --version major"));
|
|
612
|
+
console.log(muted(" pubz --ci --version 1.2.3"));
|
|
613
|
+
process.exit(1);
|
|
614
|
+
}
|
|
615
|
+
const skipConfirms = options.skipConfirms || options.ci;
|
|
616
|
+
const skipAllPrompts = options.ci;
|
|
593
617
|
const cwd = process.cwd();
|
|
594
618
|
if (options.dryRun) {
|
|
595
619
|
console.log(yellow(bold("DRY RUN MODE")) + dim(" - No actual changes will be made"));
|
|
@@ -634,7 +658,7 @@ async function main() {
|
|
|
634
658
|
console.log(` ${dim("•")} ${cyan(pkg.name)}${dim("@")}${yellow(pkg.version)}${deps}`);
|
|
635
659
|
}
|
|
636
660
|
console.log("");
|
|
637
|
-
if (packages.length > 1 && !
|
|
661
|
+
if (packages.length > 1 && !skipAllPrompts) {
|
|
638
662
|
const selectedPackages = await multiSelect("Select packages to publish:", packages.map((pkg) => ({
|
|
639
663
|
label: `${pkg.name}@${pkg.version}`,
|
|
640
664
|
value: pkg
|
|
@@ -654,8 +678,35 @@ async function main() {
|
|
|
654
678
|
console.log(`Current version: ${yellow(currentVersion)}`);
|
|
655
679
|
console.log("");
|
|
656
680
|
let newVersion = currentVersion;
|
|
657
|
-
if (
|
|
658
|
-
const
|
|
681
|
+
if (options.version) {
|
|
682
|
+
const bumpTypes = ["patch", "minor", "major"];
|
|
683
|
+
const isBumpType = bumpTypes.includes(options.version);
|
|
684
|
+
if (isBumpType) {
|
|
685
|
+
newVersion = bumpVersion(currentVersion, options.version);
|
|
686
|
+
console.log(`Bumping version (${options.version}): ${yellow(currentVersion)} → ${green(newVersion)}`);
|
|
687
|
+
} else {
|
|
688
|
+
newVersion = options.version;
|
|
689
|
+
console.log(`Using explicit version: ${green(newVersion)}`);
|
|
690
|
+
}
|
|
691
|
+
console.log("");
|
|
692
|
+
console.log(`Updating version to ${green(newVersion)} in all packages...`);
|
|
693
|
+
console.log("");
|
|
694
|
+
for (const pkg of packages) {
|
|
695
|
+
await updatePackageVersion(pkg, newVersion, options.dryRun);
|
|
696
|
+
}
|
|
697
|
+
await updateLocalDependencyVersions(packages, newVersion, options.dryRun);
|
|
698
|
+
for (const pkg of packages) {
|
|
699
|
+
pkg.version = newVersion;
|
|
700
|
+
}
|
|
701
|
+
const commitResult = await commitVersionBump(newVersion, cwd, options.dryRun);
|
|
702
|
+
if (!commitResult.success) {
|
|
703
|
+
console.error(red(bold("Failed to commit version bump:")) + ` ${commitResult.error}`);
|
|
704
|
+
closePrompt();
|
|
705
|
+
process.exit(1);
|
|
706
|
+
}
|
|
707
|
+
console.log("");
|
|
708
|
+
} else if (!skipAllPrompts) {
|
|
709
|
+
const shouldBump = skipConfirms || await confirm("Bump version before publishing?");
|
|
659
710
|
if (shouldBump) {
|
|
660
711
|
const bumpType = await select("Select version bump type:", [
|
|
661
712
|
{
|
|
@@ -692,7 +743,7 @@ async function main() {
|
|
|
692
743
|
}
|
|
693
744
|
}
|
|
694
745
|
let registry = options.registry;
|
|
695
|
-
if (!registry && !
|
|
746
|
+
if (!registry && !skipAllPrompts) {
|
|
696
747
|
registry = await select("Select publish target:", [
|
|
697
748
|
{
|
|
698
749
|
label: "Public npm registry (https://registry.npmjs.org)",
|
|
@@ -758,7 +809,7 @@ async function main() {
|
|
|
758
809
|
console.log("");
|
|
759
810
|
console.log(`Registry: ${cyan(registry)}`);
|
|
760
811
|
console.log("");
|
|
761
|
-
if (!
|
|
812
|
+
if (!skipConfirms) {
|
|
762
813
|
const shouldContinue = await confirm("Continue?");
|
|
763
814
|
if (!shouldContinue) {
|
|
764
815
|
console.log(yellow("Publish cancelled."));
|
|
@@ -786,22 +837,35 @@ async function main() {
|
|
|
786
837
|
console.log("");
|
|
787
838
|
console.log(`Published version: ${green(bold(newVersion))}`);
|
|
788
839
|
console.log("");
|
|
789
|
-
if (!options.dryRun
|
|
790
|
-
|
|
791
|
-
if (shouldTag) {
|
|
840
|
+
if (!options.dryRun) {
|
|
841
|
+
if (options.ci) {
|
|
792
842
|
console.log("");
|
|
843
|
+
console.log(cyan("Creating git tag..."));
|
|
793
844
|
const tagResult = await createGitTag(newVersion, cwd, options.dryRun);
|
|
794
845
|
if (tagResult.success) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
await pushGitTag(newVersion, cwd, options.dryRun);
|
|
798
|
-
} else {
|
|
799
|
-
console.log(`Tag created locally. Push manually with: ${dim(`git push origin v${newVersion}`)}`);
|
|
800
|
-
}
|
|
846
|
+
console.log(cyan("Pushing tag to origin..."));
|
|
847
|
+
await pushGitTag(newVersion, cwd, options.dryRun);
|
|
801
848
|
} else {
|
|
802
849
|
console.error(red(tagResult.error ?? "Failed to create git tag"));
|
|
803
850
|
}
|
|
804
851
|
console.log("");
|
|
852
|
+
} else if (!skipConfirms) {
|
|
853
|
+
const shouldTag = await confirm(`Create a git tag for ${cyan(`v${newVersion}`)}?`);
|
|
854
|
+
if (shouldTag) {
|
|
855
|
+
console.log("");
|
|
856
|
+
const tagResult = await createGitTag(newVersion, cwd, options.dryRun);
|
|
857
|
+
if (tagResult.success) {
|
|
858
|
+
const shouldPush = await confirm("Push tag to origin?");
|
|
859
|
+
if (shouldPush) {
|
|
860
|
+
await pushGitTag(newVersion, cwd, options.dryRun);
|
|
861
|
+
} else {
|
|
862
|
+
console.log(`Tag created locally. Push manually with: ${dim(`git push origin v${newVersion}`)}`);
|
|
863
|
+
}
|
|
864
|
+
} else {
|
|
865
|
+
console.error(red(tagResult.error ?? "Failed to create git tag"));
|
|
866
|
+
}
|
|
867
|
+
console.log("");
|
|
868
|
+
}
|
|
805
869
|
}
|
|
806
870
|
}
|
|
807
871
|
console.log(green(bold("Done!")));
|