pubz 0.2.1 → 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 +237 -109
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
+
// src/colors.ts
|
|
6
|
+
var isColorSupported = process.env.FORCE_COLOR !== "0" && (process.env.FORCE_COLOR !== undefined || process.stdout.isTTY && process.env.TERM !== "dumb");
|
|
7
|
+
var fmt = (open, close) => {
|
|
8
|
+
if (!isColorSupported) {
|
|
9
|
+
return (str) => str;
|
|
10
|
+
}
|
|
11
|
+
return (str) => `\x1B[${open}m${str}\x1B[${close}m`;
|
|
12
|
+
};
|
|
13
|
+
var bold = fmt("1", "22");
|
|
14
|
+
var dim = fmt("2", "22");
|
|
15
|
+
var italic = fmt("3", "23");
|
|
16
|
+
var underline = fmt("4", "24");
|
|
17
|
+
var red = fmt("31", "39");
|
|
18
|
+
var green = fmt("32", "39");
|
|
19
|
+
var yellow = fmt("33", "39");
|
|
20
|
+
var blue = fmt("34", "39");
|
|
21
|
+
var magenta = fmt("35", "39");
|
|
22
|
+
var cyan = fmt("36", "39");
|
|
23
|
+
var white = fmt("37", "39");
|
|
24
|
+
var gray = fmt("90", "39");
|
|
25
|
+
var bgRed = fmt("41", "49");
|
|
26
|
+
var bgGreen = fmt("42", "49");
|
|
27
|
+
var bgYellow = fmt("43", "49");
|
|
28
|
+
var bgBlue = fmt("44", "49");
|
|
29
|
+
var muted = gray;
|
|
30
|
+
|
|
5
31
|
// src/discovery.ts
|
|
6
32
|
import { readFile, readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
7
33
|
import { join as join2, resolve } from "node:path";
|
|
@@ -164,23 +190,24 @@ function prompt(question) {
|
|
|
164
190
|
function closePrompt() {
|
|
165
191
|
rl.close();
|
|
166
192
|
}
|
|
167
|
-
async function confirm(message,
|
|
168
|
-
const hint =
|
|
169
|
-
const answer = await prompt(`${message} ${hint} `);
|
|
193
|
+
async function confirm(message, defaultYes = true) {
|
|
194
|
+
const hint = defaultYes ? `[${bold("Y")}/n]` : `[y/${bold("N")}]`;
|
|
195
|
+
const answer = await prompt(`${cyan("?")} ${message} ${hint} `);
|
|
170
196
|
if (answer === "") {
|
|
171
|
-
return
|
|
197
|
+
return defaultYes;
|
|
172
198
|
}
|
|
173
199
|
return answer.toLowerCase() === "y";
|
|
174
200
|
}
|
|
175
201
|
async function select(message, options, defaultIndex = 0) {
|
|
176
|
-
console.log(message);
|
|
202
|
+
console.log(`${cyan("?")} ${message}`);
|
|
177
203
|
console.log("");
|
|
178
204
|
for (let i = 0;i < options.length; i++) {
|
|
179
|
-
const marker = i === defaultIndex ? ">" : " ";
|
|
180
|
-
|
|
205
|
+
const marker = i === defaultIndex ? cyan(">") : " ";
|
|
206
|
+
const num = dim(`${i + 1})`);
|
|
207
|
+
console.log(` ${marker} ${num} ${options[i].label}`);
|
|
181
208
|
}
|
|
182
209
|
console.log("");
|
|
183
|
-
const answer = await prompt(`Enter choice [1-${options.length}] (default: ${defaultIndex + 1}): `);
|
|
210
|
+
const answer = await prompt(` Enter choice ${dim(`[1-${options.length}]`)} ${muted(`(default: ${defaultIndex + 1})`)}: `);
|
|
184
211
|
if (answer === "") {
|
|
185
212
|
return options[defaultIndex].value;
|
|
186
213
|
}
|
|
@@ -188,55 +215,92 @@ async function select(message, options, defaultIndex = 0) {
|
|
|
188
215
|
if (index >= 0 && index < options.length) {
|
|
189
216
|
return options[index].value;
|
|
190
217
|
}
|
|
191
|
-
console.log(`Invalid choice. Using default: ${options[defaultIndex].label}`);
|
|
218
|
+
console.log(yellow(` Invalid choice. Using default: ${options[defaultIndex].label}`));
|
|
192
219
|
return options[defaultIndex].value;
|
|
193
220
|
}
|
|
194
221
|
async function multiSelect(message, options, allSelectedByDefault = true) {
|
|
195
222
|
const selected = new Set(allSelectedByDefault ? options.map((_, i) => i) : []);
|
|
196
|
-
|
|
197
|
-
|
|
223
|
+
let cursor = 0;
|
|
224
|
+
const clearLines = (count) => {
|
|
225
|
+
for (let i = 0;i < count; i++) {
|
|
226
|
+
process.stdout.write("\x1B[A\x1B[2K");
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
const render = (initial = false) => {
|
|
230
|
+
if (!initial) {
|
|
231
|
+
clearLines(options.length + 3);
|
|
232
|
+
}
|
|
233
|
+
console.log(`${cyan("?")} ${message}`);
|
|
198
234
|
console.log("");
|
|
199
235
|
for (let i = 0;i < options.length; i++) {
|
|
200
|
-
const
|
|
201
|
-
|
|
236
|
+
const isSelected = selected.has(i);
|
|
237
|
+
const isCursor = i === cursor;
|
|
238
|
+
const checkbox = isSelected ? green("[x]") : dim("[ ]");
|
|
239
|
+
const pointer = isCursor ? cyan(">") : " ";
|
|
240
|
+
const label = isCursor ? bold(options[i].label) : options[i].label;
|
|
241
|
+
console.log(` ${pointer} ${checkbox} ${label}`);
|
|
202
242
|
}
|
|
203
243
|
console.log("");
|
|
204
|
-
console.log(
|
|
244
|
+
console.log(dim(" ↑/↓ navigate • space toggle • a all • n none • enter confirm"));
|
|
205
245
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
246
|
+
return new Promise((resolve2) => {
|
|
247
|
+
render(true);
|
|
248
|
+
rl.pause();
|
|
249
|
+
const stdin = process.stdin;
|
|
250
|
+
stdin.setRawMode(true);
|
|
251
|
+
stdin.resume();
|
|
252
|
+
const onKeypress = (key) => {
|
|
253
|
+
const str = key.toString();
|
|
254
|
+
if (str === "\x03") {
|
|
255
|
+
stdin.setRawMode(false);
|
|
256
|
+
stdin.removeListener("data", onKeypress);
|
|
257
|
+
rl.resume();
|
|
258
|
+
console.log("");
|
|
259
|
+
process.exit(0);
|
|
215
260
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
const index = Number.parseInt(answer, 10) - 1;
|
|
227
|
-
if (index >= 0 && index < options.length) {
|
|
228
|
-
if (selected.has(index)) {
|
|
229
|
-
selected.delete(index);
|
|
230
|
-
} else {
|
|
231
|
-
selected.add(index);
|
|
261
|
+
if (str === "\r" || str === `
|
|
262
|
+
`) {
|
|
263
|
+
stdin.setRawMode(false);
|
|
264
|
+
stdin.removeListener("data", onKeypress);
|
|
265
|
+
rl.resume();
|
|
266
|
+
console.log("");
|
|
267
|
+
resolve2(options.filter((_, i) => selected.has(i)).map((o) => o.value));
|
|
268
|
+
return;
|
|
232
269
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
270
|
+
if (str === " ") {
|
|
271
|
+
if (selected.has(cursor)) {
|
|
272
|
+
selected.delete(cursor);
|
|
273
|
+
} else {
|
|
274
|
+
selected.add(cursor);
|
|
275
|
+
}
|
|
276
|
+
render();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (str === "\x1B[A" || str === "k") {
|
|
280
|
+
cursor = cursor > 0 ? cursor - 1 : options.length - 1;
|
|
281
|
+
render();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (str === "\x1B[B" || str === "j") {
|
|
285
|
+
cursor = cursor < options.length - 1 ? cursor + 1 : 0;
|
|
286
|
+
render();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (str === "a") {
|
|
290
|
+
for (let i = 0;i < options.length; i++) {
|
|
291
|
+
selected.add(i);
|
|
292
|
+
}
|
|
293
|
+
render();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (str === "n") {
|
|
297
|
+
selected.clear();
|
|
298
|
+
render();
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
stdin.on("data", onKeypress);
|
|
303
|
+
});
|
|
240
304
|
}
|
|
241
305
|
|
|
242
306
|
// src/publish.ts
|
|
@@ -475,13 +539,17 @@ Options:
|
|
|
475
539
|
--registry <url> Specify npm registry URL (default: public npm)
|
|
476
540
|
--otp <code> One-time password for 2FA
|
|
477
541
|
--skip-build Skip the build step
|
|
478
|
-
--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)
|
|
479
545
|
-h, --help Show this help message
|
|
480
546
|
|
|
481
547
|
Examples:
|
|
482
548
|
pubz # Interactive publish
|
|
483
549
|
pubz --dry-run # Preview what would happen
|
|
484
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
|
|
485
553
|
`);
|
|
486
554
|
}
|
|
487
555
|
function parseArgs(args) {
|
|
@@ -490,7 +558,9 @@ function parseArgs(args) {
|
|
|
490
558
|
registry: "",
|
|
491
559
|
otp: "",
|
|
492
560
|
skipBuild: false,
|
|
493
|
-
|
|
561
|
+
skipConfirms: false,
|
|
562
|
+
ci: false,
|
|
563
|
+
version: "",
|
|
494
564
|
help: false
|
|
495
565
|
};
|
|
496
566
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -510,7 +580,13 @@ function parseArgs(args) {
|
|
|
510
580
|
break;
|
|
511
581
|
case "--yes":
|
|
512
582
|
case "-y":
|
|
513
|
-
options.
|
|
583
|
+
options.skipConfirms = true;
|
|
584
|
+
break;
|
|
585
|
+
case "--ci":
|
|
586
|
+
options.ci = true;
|
|
587
|
+
break;
|
|
588
|
+
case "--version":
|
|
589
|
+
options.version = args[++i] || "";
|
|
514
590
|
break;
|
|
515
591
|
case "-h":
|
|
516
592
|
case "--help":
|
|
@@ -526,57 +602,69 @@ async function main() {
|
|
|
526
602
|
printUsage();
|
|
527
603
|
process.exit(0);
|
|
528
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;
|
|
529
617
|
const cwd = process.cwd();
|
|
530
618
|
if (options.dryRun) {
|
|
531
|
-
console.log("DRY RUN MODE - No actual changes will be made");
|
|
619
|
+
console.log(yellow(bold("DRY RUN MODE")) + dim(" - No actual changes will be made"));
|
|
532
620
|
console.log("");
|
|
533
621
|
}
|
|
534
|
-
console.log("pubz - npm package publisher");
|
|
535
|
-
console.log("
|
|
622
|
+
console.log(bold("pubz") + dim(" - npm package publisher"));
|
|
623
|
+
console.log(dim("═".repeat(30)));
|
|
536
624
|
console.log("");
|
|
537
625
|
const uncommitted = await hasUncommittedChanges(cwd);
|
|
538
626
|
if (uncommitted.hasChanges && !options.dryRun) {
|
|
539
|
-
console.log("Error: You have uncommitted changes:");
|
|
627
|
+
console.log(red(bold("Error:")) + " You have uncommitted changes:");
|
|
540
628
|
console.log("");
|
|
541
629
|
for (const file of uncommitted.files.slice(0, 10)) {
|
|
542
|
-
console.log(` ${file}`);
|
|
630
|
+
console.log(` ${yellow(file)}`);
|
|
543
631
|
}
|
|
544
632
|
if (uncommitted.files.length > 10) {
|
|
545
|
-
console.log(` ... and ${uncommitted.files.length - 10} more`);
|
|
633
|
+
console.log(dim(` ... and ${uncommitted.files.length - 10} more`));
|
|
546
634
|
}
|
|
547
635
|
console.log("");
|
|
548
|
-
console.log("Please commit or stash your changes before publishing.");
|
|
636
|
+
console.log(muted("Please commit or stash your changes before publishing."));
|
|
549
637
|
closePrompt();
|
|
550
638
|
process.exit(1);
|
|
551
639
|
}
|
|
552
|
-
console.log("Discovering packages...");
|
|
640
|
+
console.log(cyan("Discovering packages..."));
|
|
553
641
|
console.log("");
|
|
554
642
|
let packages = await discoverPackages(cwd);
|
|
555
643
|
const publishablePackages = packages.filter((p) => !p.isPrivate);
|
|
556
644
|
if (publishablePackages.length === 0) {
|
|
557
|
-
console.log("No publishable packages found.");
|
|
645
|
+
console.log(yellow("No publishable packages found."));
|
|
558
646
|
console.log("");
|
|
559
|
-
console.log("Make sure your packages:");
|
|
560
|
-
console.log(' - Have a package.json with a "name" field');
|
|
561
|
-
console.log(' - Do not have "private": true');
|
|
647
|
+
console.log(muted("Make sure your packages:"));
|
|
648
|
+
console.log(muted(' - Have a package.json with a "name" field'));
|
|
649
|
+
console.log(muted(' - Do not have "private": true'));
|
|
562
650
|
console.log("");
|
|
563
651
|
process.exit(1);
|
|
564
652
|
}
|
|
565
653
|
packages = sortByDependencyOrder(publishablePackages);
|
|
566
|
-
console.log(`Found ${packages.length} publishable package(s):`);
|
|
654
|
+
console.log(`Found ${green(bold(String(packages.length)))} publishable package(s):`);
|
|
567
655
|
console.log("");
|
|
568
656
|
for (const pkg of packages) {
|
|
569
|
-
const deps = pkg.localDependencies.length > 0 ? ` (depends on: ${pkg.localDependencies.join(", ")})` : "";
|
|
570
|
-
console.log(`
|
|
657
|
+
const deps = pkg.localDependencies.length > 0 ? dim(` (depends on: ${pkg.localDependencies.join(", ")})`) : "";
|
|
658
|
+
console.log(` ${dim("•")} ${cyan(pkg.name)}${dim("@")}${yellow(pkg.version)}${deps}`);
|
|
571
659
|
}
|
|
572
660
|
console.log("");
|
|
573
|
-
if (packages.length > 1 && !
|
|
661
|
+
if (packages.length > 1 && !skipAllPrompts) {
|
|
574
662
|
const selectedPackages = await multiSelect("Select packages to publish:", packages.map((pkg) => ({
|
|
575
663
|
label: `${pkg.name}@${pkg.version}`,
|
|
576
664
|
value: pkg
|
|
577
665
|
})));
|
|
578
666
|
if (selectedPackages.length === 0) {
|
|
579
|
-
console.log("No packages selected. Exiting.");
|
|
667
|
+
console.log(yellow("No packages selected. Exiting."));
|
|
580
668
|
closePrompt();
|
|
581
669
|
process.exit(0);
|
|
582
670
|
}
|
|
@@ -584,14 +672,41 @@ async function main() {
|
|
|
584
672
|
console.log("");
|
|
585
673
|
}
|
|
586
674
|
const currentVersion = packages[0].version;
|
|
587
|
-
console.log("Step 1: Version Management");
|
|
588
|
-
console.log("
|
|
675
|
+
console.log(bold(cyan("Step 1:")) + " Version Management");
|
|
676
|
+
console.log(dim("─".repeat(30)));
|
|
589
677
|
console.log("");
|
|
590
|
-
console.log(`Current version: ${currentVersion}`);
|
|
678
|
+
console.log(`Current version: ${yellow(currentVersion)}`);
|
|
591
679
|
console.log("");
|
|
592
680
|
let newVersion = currentVersion;
|
|
593
|
-
if (
|
|
594
|
-
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?");
|
|
595
710
|
if (shouldBump) {
|
|
596
711
|
const bumpType = await select("Select version bump type:", [
|
|
597
712
|
{
|
|
@@ -609,7 +724,7 @@ async function main() {
|
|
|
609
724
|
]);
|
|
610
725
|
newVersion = bumpVersion(currentVersion, bumpType);
|
|
611
726
|
console.log("");
|
|
612
|
-
console.log(`Updating version to ${newVersion} in all packages...`);
|
|
727
|
+
console.log(`Updating version to ${green(newVersion)} in all packages...`);
|
|
613
728
|
console.log("");
|
|
614
729
|
for (const pkg of packages) {
|
|
615
730
|
await updatePackageVersion(pkg, newVersion, options.dryRun);
|
|
@@ -620,7 +735,7 @@ async function main() {
|
|
|
620
735
|
}
|
|
621
736
|
const commitResult = await commitVersionBump(newVersion, cwd, options.dryRun);
|
|
622
737
|
if (!commitResult.success) {
|
|
623
|
-
console.error(
|
|
738
|
+
console.error(red(bold("Failed to commit version bump:")) + ` ${commitResult.error}`);
|
|
624
739
|
closePrompt();
|
|
625
740
|
process.exit(1);
|
|
626
741
|
}
|
|
@@ -628,7 +743,7 @@ async function main() {
|
|
|
628
743
|
}
|
|
629
744
|
}
|
|
630
745
|
let registry = options.registry;
|
|
631
|
-
if (!registry && !
|
|
746
|
+
if (!registry && !skipAllPrompts) {
|
|
632
747
|
registry = await select("Select publish target:", [
|
|
633
748
|
{
|
|
634
749
|
label: "Public npm registry (https://registry.npmjs.org)",
|
|
@@ -642,109 +757,122 @@ async function main() {
|
|
|
642
757
|
}
|
|
643
758
|
registry = registry || REGISTRIES.npm;
|
|
644
759
|
console.log("");
|
|
645
|
-
console.log(`Publishing to: ${registry}`);
|
|
760
|
+
console.log(`Publishing to: ${cyan(registry)}`);
|
|
646
761
|
console.log("");
|
|
647
762
|
if (!options.skipBuild) {
|
|
648
|
-
console.log("Step 2: Building Packages");
|
|
649
|
-
console.log("
|
|
763
|
+
console.log(bold(cyan("Step 2:")) + " Building Packages");
|
|
764
|
+
console.log(dim("─".repeat(30)));
|
|
650
765
|
console.log("");
|
|
651
766
|
const buildResult = await runBuild(cwd, options.dryRun);
|
|
652
767
|
if (!buildResult.success) {
|
|
653
|
-
console.error(
|
|
768
|
+
console.error(red(bold("Build failed:")) + ` ${buildResult.error}`);
|
|
654
769
|
closePrompt();
|
|
655
770
|
process.exit(1);
|
|
656
771
|
}
|
|
657
772
|
console.log("");
|
|
658
|
-
console.log("Verifying builds...");
|
|
773
|
+
console.log(cyan("Verifying builds..."));
|
|
659
774
|
console.log("");
|
|
660
775
|
let allBuildsVerified = true;
|
|
661
776
|
for (const pkg of packages) {
|
|
662
777
|
const result = await verifyBuild(pkg);
|
|
663
778
|
if (result.success) {
|
|
664
|
-
console.log(` ${pkg.name} build verified`);
|
|
779
|
+
console.log(` ${green("✓")} ${pkg.name} build verified`);
|
|
665
780
|
} else {
|
|
666
|
-
console.error(` ${pkg.name}: ${result.error}`);
|
|
781
|
+
console.error(` ${red("✗")} ${pkg.name}: ${result.error}`);
|
|
667
782
|
allBuildsVerified = false;
|
|
668
783
|
}
|
|
669
784
|
}
|
|
670
785
|
console.log("");
|
|
671
786
|
if (!allBuildsVerified) {
|
|
672
|
-
console.error("Build verification failed. Please fix the issues and try again.");
|
|
787
|
+
console.error(red("Build verification failed.") + muted(" Please fix the issues and try again."));
|
|
673
788
|
closePrompt();
|
|
674
789
|
process.exit(1);
|
|
675
790
|
}
|
|
676
791
|
}
|
|
677
|
-
console.log("Step 3: Publishing to npm");
|
|
678
|
-
console.log("
|
|
792
|
+
console.log(bold(cyan("Step 3:")) + " Publishing to npm");
|
|
793
|
+
console.log(dim("─".repeat(30)));
|
|
679
794
|
console.log("");
|
|
680
795
|
if (options.dryRun) {
|
|
681
|
-
console.log(
|
|
796
|
+
console.log(yellow("[DRY RUN]") + ` Would publish the following packages to ${cyan(registry)}:`);
|
|
682
797
|
console.log("");
|
|
683
798
|
for (const pkg of packages) {
|
|
684
|
-
console.log(` ${pkg.name}
|
|
799
|
+
console.log(` ${dim("•")} ${cyan(pkg.name)}${dim("@")}${yellow(newVersion)}`);
|
|
685
800
|
}
|
|
686
801
|
console.log("");
|
|
687
|
-
console.log("Run without --dry-run to actually publish.");
|
|
802
|
+
console.log(muted("Run without --dry-run to actually publish."));
|
|
688
803
|
} else {
|
|
689
804
|
console.log("About to publish the following packages:");
|
|
690
805
|
console.log("");
|
|
691
806
|
for (const pkg of packages) {
|
|
692
|
-
console.log(` ${pkg.name}
|
|
807
|
+
console.log(` ${dim("•")} ${cyan(pkg.name)}${dim("@")}${yellow(newVersion)}`);
|
|
693
808
|
}
|
|
694
809
|
console.log("");
|
|
695
|
-
console.log(`Registry: ${registry}`);
|
|
810
|
+
console.log(`Registry: ${cyan(registry)}`);
|
|
696
811
|
console.log("");
|
|
697
|
-
if (!
|
|
812
|
+
if (!skipConfirms) {
|
|
698
813
|
const shouldContinue = await confirm("Continue?");
|
|
699
814
|
if (!shouldContinue) {
|
|
700
|
-
console.log("Publish cancelled.");
|
|
815
|
+
console.log(yellow("Publish cancelled."));
|
|
701
816
|
closePrompt();
|
|
702
817
|
process.exit(0);
|
|
703
818
|
}
|
|
704
819
|
}
|
|
705
820
|
console.log("");
|
|
706
|
-
console.log("Publishing packages...");
|
|
821
|
+
console.log(cyan("Publishing packages..."));
|
|
707
822
|
console.log("");
|
|
708
823
|
for (const pkg of packages) {
|
|
709
824
|
const result = await publishPackage(pkg, registry, options.otp, options.dryRun);
|
|
710
825
|
if (!result.success) {
|
|
711
|
-
console.error(
|
|
826
|
+
console.error(red(bold("Failed to publish")) + ` ${cyan(pkg.name)}: ${result.error}`);
|
|
712
827
|
console.log("");
|
|
713
|
-
console.log("Stopping publish process.");
|
|
828
|
+
console.log(red("Stopping publish process."));
|
|
714
829
|
closePrompt();
|
|
715
830
|
process.exit(1);
|
|
716
831
|
}
|
|
717
832
|
}
|
|
718
833
|
}
|
|
719
834
|
console.log("");
|
|
720
|
-
console.log("
|
|
721
|
-
console.log("Publishing complete!");
|
|
835
|
+
console.log(dim("═".repeat(30)));
|
|
836
|
+
console.log(green(bold("Publishing complete!")));
|
|
722
837
|
console.log("");
|
|
723
|
-
console.log(`Published version: ${newVersion}`);
|
|
838
|
+
console.log(`Published version: ${green(bold(newVersion))}`);
|
|
724
839
|
console.log("");
|
|
725
|
-
if (!options.dryRun
|
|
726
|
-
|
|
727
|
-
if (shouldTag) {
|
|
840
|
+
if (!options.dryRun) {
|
|
841
|
+
if (options.ci) {
|
|
728
842
|
console.log("");
|
|
843
|
+
console.log(cyan("Creating git tag..."));
|
|
729
844
|
const tagResult = await createGitTag(newVersion, cwd, options.dryRun);
|
|
730
845
|
if (tagResult.success) {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
await pushGitTag(newVersion, cwd, options.dryRun);
|
|
734
|
-
} else {
|
|
735
|
-
console.log(`Tag created locally. Push manually with: git push origin v${newVersion}`);
|
|
736
|
-
}
|
|
846
|
+
console.log(cyan("Pushing tag to origin..."));
|
|
847
|
+
await pushGitTag(newVersion, cwd, options.dryRun);
|
|
737
848
|
} else {
|
|
738
|
-
console.error(tagResult.error);
|
|
849
|
+
console.error(red(tagResult.error ?? "Failed to create git tag"));
|
|
739
850
|
}
|
|
740
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
|
+
}
|
|
741
869
|
}
|
|
742
870
|
}
|
|
743
|
-
console.log("Done!");
|
|
871
|
+
console.log(green(bold("Done!")));
|
|
744
872
|
closePrompt();
|
|
745
873
|
}
|
|
746
874
|
main().catch((error) => {
|
|
747
|
-
console.error("Error:"
|
|
875
|
+
console.error(red(bold("Error:")) + ` ${error.message}`);
|
|
748
876
|
closePrompt();
|
|
749
877
|
process.exit(1);
|
|
750
878
|
});
|