Skip to content

Commit e59dd66

Browse files
authored
Added --non-interactive and --force options to ext:dev:unpublish (#3846)
1 parent b5864cd commit e59dd66

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/commands/ext-dev-unpublish.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import { checkMinRequiredVersion } from "../checkMinRequiredVersion";
1111

1212
module.exports = new Command("ext:dev:unpublish <extensionRef>")
1313
.description("unpublish an extension")
14+
.withForce()
1415
.help(
1516
"use this command to unpublish an extension, and make it unavailable for developers to install or reconfigure. " +
1617
"Specify the extension you want to unpublish using the format '<publisherId>/<extensionId>."
1718
)
1819
.before(requireAuth)
1920
.before(checkMinRequiredVersion, "extDevMinVersion")
20-
.action(async (extensionRef: string) => {
21+
.action(async (extensionRef: string, options: any) => {
2122
const { publisherId, extensionId, version } = refs.parse(extensionRef);
2223
utils.logLabeledWarning(
2324
logPrefix,
@@ -35,15 +36,25 @@ module.exports = new Command("ext:dev:unpublish <extensionRef>")
3536
);
3637
}
3738
await getExtension(extensionRef);
38-
const consent = await comfirmUnpublish(publisherId, extensionId);
39+
const consent = await comfirmUnpublish(publisherId, extensionId, options);
3940
if (!consent) {
4041
throw new FirebaseError("unpublishing cancelled.");
4142
}
4243
await unpublishExtension(extensionRef);
4344
utils.logLabeledSuccess(logPrefix, "successfully unpublished all versions of this extension.");
4445
});
4546

46-
async function comfirmUnpublish(publisherId: string, extensionId: string): Promise<boolean> {
47+
async function comfirmUnpublish(
48+
publisherId: string,
49+
extensionId: string,
50+
options: any
51+
): Promise<boolean> {
52+
if (options.nonInteractive && !options.force) {
53+
throw new FirebaseError("Pass the --force flag to use this command in non-interactive mode");
54+
}
55+
if (options.nonInteractive && options.force) {
56+
return true;
57+
}
4758
const message = `You are about to unpublish ALL versions of ${clc.green(
4859
`${publisherId}/${extensionId}`
4960
)}.\nDo you wish to continue? `;

0 commit comments

Comments
 (0)