pubz 0.2.8 → 0.2.9
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 +13 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -346,10 +346,9 @@ async function npmLogin(registry) {
|
|
|
346
346
|
});
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
|
-
async function
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return code.trim();
|
|
349
|
+
async function reauthenticate(registry) {
|
|
350
|
+
const loginResult = await npmLogin(registry);
|
|
351
|
+
return loginResult.success;
|
|
353
352
|
}
|
|
354
353
|
|
|
355
354
|
// src/publish.ts
|
|
@@ -439,11 +438,14 @@ async function publishPackage(pkg, registry, context, dryRun) {
|
|
|
439
438
|
args.push("--otp", context.otp);
|
|
440
439
|
}
|
|
441
440
|
let result = await run("npm", args, pkg.path);
|
|
442
|
-
if (result.code !== 0 && isOtpError(result.output) && context.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
441
|
+
if (result.code !== 0 && isOtpError(result.output) && context.onAuthRequired) {
|
|
442
|
+
console.log("");
|
|
443
|
+
console.log("2FA verification required. Opening browser for authentication...");
|
|
444
|
+
const authSuccess = await context.onAuthRequired(registry);
|
|
445
|
+
if (authSuccess) {
|
|
446
|
+
console.log("");
|
|
447
|
+
console.log(`Retrying publish...`);
|
|
448
|
+
const retryArgs = ["publish", "--registry", registry, "--access", "public"];
|
|
447
449
|
result = await run("npm", retryArgs, pkg.path);
|
|
448
450
|
}
|
|
449
451
|
}
|
|
@@ -451,7 +453,7 @@ async function publishPackage(pkg, registry, context, dryRun) {
|
|
|
451
453
|
if (isOtpError(result.output)) {
|
|
452
454
|
return {
|
|
453
455
|
success: false,
|
|
454
|
-
error: `2FA
|
|
456
|
+
error: `2FA required. Use --otp flag for TOTP, or run interactively for security key auth.`
|
|
455
457
|
};
|
|
456
458
|
}
|
|
457
459
|
return { success: false, error: `Failed to publish ${pkg.name}` };
|
|
@@ -937,7 +939,7 @@ async function main() {
|
|
|
937
939
|
console.log("");
|
|
938
940
|
const publishContext = {
|
|
939
941
|
otp: options.otp,
|
|
940
|
-
|
|
942
|
+
onAuthRequired: options.ci ? undefined : reauthenticate
|
|
941
943
|
};
|
|
942
944
|
for (const pkg of packages) {
|
|
943
945
|
const result = await publishPackage(pkg, registry, publishContext, options.dryRun);
|