From 6732d9501f9f430e431ba03b1c630d8d7f2c2818 Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Mon, 4 Jul 2022 14:31:44 +0100 Subject: [PATCH] fix: log pubsub beta usage warnings consistently (#1401) This fix makes sure the pubsub beta warnings are logged consistently, once per help menu, through the hierarchy of its command tree. This fix makes sure the pubsub beta warnings are logged consistently, once per help menu, through the hierarchy of its command tree. Fixes https://github.com/cloudflare/wrangler2/issues/1370 --- .changeset/lovely-bulldogs-repeat.md | 9 + .../wrangler/src/__tests__/pubsub.test.ts | 91 ++ .../wrangler/src/pubsub/pubsub-commands.tsx | 789 +++++++++--------- 3 files changed, 486 insertions(+), 403 deletions(-) create mode 100644 .changeset/lovely-bulldogs-repeat.md diff --git a/.changeset/lovely-bulldogs-repeat.md b/.changeset/lovely-bulldogs-repeat.md new file mode 100644 index 000000000000..b2e2f882ffe7 --- /dev/null +++ b/.changeset/lovely-bulldogs-repeat.md @@ -0,0 +1,9 @@ +--- +"wrangler": patch +--- + +fix: log pubsub beta usage warnings consistently + +This fix makes sure the pubsub beta warnings are logged consistently, once per help menu, through the hierarchy of its command tree. + +Fixes https://github.com/cloudflare/wrangler2/issues/1370 diff --git a/packages/wrangler/src/__tests__/pubsub.test.ts b/packages/wrangler/src/__tests__/pubsub.test.ts index ab372fe234b1..56f4c850bc6b 100644 --- a/packages/wrangler/src/__tests__/pubsub.test.ts +++ b/packages/wrangler/src/__tests__/pubsub.test.ts @@ -21,7 +21,63 @@ describe("wrangler", () => { }); describe("pubsub", () => { + describe("help menu", () => { + it("shows usage details", async () => { + await runWrangler("pubsub --help"); + expect(std).toMatchInlineSnapshot(` + Object { + "debug": "", + "err": "", + "out": "wrangler pubsub + + 📮 Interact and manage Pub/Sub Brokers + + Commands: + wrangler pubsub namespace Manage your Pub/Sub Namespaces + wrangler pubsub broker Interact with your Pub/Sub Brokers + + Flags: + -c, --config Path to .toml configuration file [string] + -h, --help Show help [boolean] + -v, --version Show version number [boolean] + + 👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/", + "warn": "", + } + `); + }); + }); + describe("namespaces", () => { + describe("help menu", () => { + it("shows usage details", async () => { + await runWrangler("pubsub namespace --help"); + expect(std).toMatchInlineSnapshot(` + Object { + "debug": "", + "err": "", + "out": "wrangler pubsub namespace + + Manage your Pub/Sub Namespaces + + Commands: + wrangler pubsub namespace create Create a new Pub/Sub Namespace + wrangler pubsub namespace list List your existing Pub/Sub Namespaces + wrangler pubsub namespace delete Delete a Pub/Sub Namespace + wrangler pubsub namespace describe Describe a Pub/Sub Namespace + + Flags: + -c, --config Path to .toml configuration file [string] + -h, --help Show help [boolean] + -v, --version Show version number [boolean] + + 👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/", + "warn": "", + } + `); + }); + }); + describe("create", () => { function mockCreateRequest(expectedNamespaceName: string) { const requests = { count: 0 }; @@ -77,6 +133,41 @@ describe("wrangler", () => { }); describe("brokers", () => { + describe("help menu", () => { + it("shows usage details", async () => { + await runWrangler("pubsub broker --help"); + expect(std).toMatchInlineSnapshot(` + Object { + "debug": "", + "err": "", + "out": "wrangler pubsub broker + + Interact with your Pub/Sub Brokers + + Commands: + wrangler pubsub broker create Create a new Pub/Sub Broker + wrangler pubsub broker update Update an existing Pub/Sub Broker's configuration. + wrangler pubsub broker list List the Pub/Sub Brokers within a Namespace + wrangler pubsub broker delete Delete an existing Pub/Sub Broker + wrangler pubsub broker describe Describe an existing Pub/Sub Broker. + wrangler pubsub broker issue Issue new client credentials for a specific Pub/Sub Broker. + wrangler pubsub broker revoke Revoke a set of active client credentials associated with the given Broker + wrangler pubsub broker unrevoke Restore access to a set of previously revoked client credentials. + wrangler pubsub broker show-revocations Show all previously revoked client credentials. + wrangler pubsub broker public-keys Show the public keys used for verifying on-publish hooks and credentials for a Broker. + + Flags: + -c, --config Path to .toml configuration file [string] + -h, --help Show help [boolean] + -v, --version Show version number [boolean] + + 👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/", + "warn": "", + } + `); + }); + }); + describe("create", () => { function mockCreateRequest(expectedBrokerName: string) { const requests = { count: 0 }; diff --git a/packages/wrangler/src/pubsub/pubsub-commands.tsx b/packages/wrangler/src/pubsub/pubsub-commands.tsx index b63a92f877c5..b2c1b98a321f 100644 --- a/packages/wrangler/src/pubsub/pubsub-commands.tsx +++ b/packages/wrangler/src/pubsub/pubsub-commands.tsx @@ -18,7 +18,7 @@ export function pubSubCommands( "namespace", "Manage your Pub/Sub Namespaces", (pubsubNamespaceYargs) => { - pubsubNamespaceYargs + return pubsubNamespaceYargs .command( "create ", "Create a new Pub/Sub Namespace", @@ -33,7 +33,8 @@ export function pubSubCommands( .option("description", { describe: "Textual description of Namespace", type: "string", - }); + }) + .epilogue(pubsub.pubSubBetaWarning); }, async (args) => { const config = readConfig(args.config as ConfigPath, args); @@ -51,13 +52,12 @@ export function pubSubCommands( logger.log(`Success! Created Pub/Sub Namespace ${args.name}`); } ) - .epilogue(pubsub.pubSubBetaWarning); - - pubsubNamespaceYargs .command( "list", "List your existing Pub/Sub Namespaces", - {}, + (yargs) => { + return yargs.epilogue(pubsub.pubSubBetaWarning); + }, async (args) => { const config = readConfig(args.config as ConfigPath, args); const accountId = await requireAuth(config); @@ -65,18 +65,17 @@ export function pubSubCommands( logger.log(await pubsub.listPubSubNamespaces(accountId)); } ) - .epilogue(pubsub.pubSubBetaWarning); - - pubsubNamespaceYargs .command( "delete ", "Delete a Pub/Sub Namespace", (yargs) => { - return yargs.positional("name", { - describe: "The name of the namespace to delete", - type: "string", - demandOption: true, - }); + return yargs + .positional("name", { + describe: "The name of the namespace to delete", + type: "string", + demandOption: true, + }) + .epilogue(pubsub.pubSubBetaWarning); }, async (args) => { const config = readConfig(args.config as ConfigPath, args); @@ -93,18 +92,17 @@ export function pubSubCommands( } } ) - .epilogue(pubsub.pubSubBetaWarning); - - pubsubNamespaceYargs .command( "describe ", "Describe a Pub/Sub Namespace", (yargs) => { - return yargs.positional("name", { - describe: "The name of the namespace to describe.", - type: "string", - demandOption: true, - }); + return yargs + .positional("name", { + describe: "The name of the namespace to describe.", + type: "string", + demandOption: true, + }) + .epilogue(pubsub.pubSubBetaWarning); }, async (args) => { const config = readConfig(args.config as ConfigPath, args); @@ -116,168 +114,162 @@ export function pubSubCommands( } ) .epilogue(pubsub.pubSubBetaWarning); - - return pubsubNamespaceYargs; } ) .command("broker", "Interact with your Pub/Sub Brokers", (brokersYargs) => { - brokersYargs - .command( - "create ", - "Create a new Pub/Sub Broker", - (yargs) => - yargs - .positional("name", { - describe: - "The name of the Pub/Sub Broker. This name will form part of the public endpoint, in the form ..cloudflarepubsub.com", - type: "string", - demandOption: true, - }) - .option("namespace", { - describe: - "An existing Namespace to associate the Broker with. This name will form part of the public endpoint, in the form ..cloudflarepubsub.com", - type: "string", - alias: "ns", - demandOption: true, - }) - .option("description", { - describe: "Longer description for the broker", - type: "string", - }) - .option("expiration", { - describe: - "Time to allow token validity (can use seconds, hours, months, weeks, years)", - type: "string", - }) - .option("on-publish-url", { - describe: - "A (HTTPS) Cloudflare Worker (or webhook) URL that messages will be sent to on-publish.", - type: "string", - }), - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); - - const broker: pubsub.PubSubBroker = { - name: args.name, - }; - if (args.description) { - broker.description = args.description; - } - if (args.expiration) { - const expiration = parseHumanDuration(args.expiration); - if (isNaN(expiration)) { - throw new CommandLineArgsError( - `${args.expiration} is not a time duration. (Example of valid values are: 1y, 6 days)` - ); - } - broker.expiration = expiration; - } - if (args["on-publish-url"]) { - broker.on_publish = { - url: args["on-publish-url"], - }; + brokersYargs.command( + "create ", + "Create a new Pub/Sub Broker", + (yargs) => + yargs + .positional("name", { + describe: + "The name of the Pub/Sub Broker. This name will form part of the public endpoint, in the form ..cloudflarepubsub.com", + type: "string", + demandOption: true, + }) + .option("namespace", { + describe: + "An existing Namespace to associate the Broker with. This name will form part of the public endpoint, in the form ..cloudflarepubsub.com", + type: "string", + alias: "ns", + demandOption: true, + }) + .option("description", { + describe: "Longer description for the broker", + type: "string", + }) + .option("expiration", { + describe: + "Time to allow token validity (can use seconds, hours, months, weeks, years)", + type: "string", + }) + .option("on-publish-url", { + describe: + "A (HTTPS) Cloudflare Worker (or webhook) URL that messages will be sent to on-publish.", + type: "string", + }) + .epilogue(pubsub.pubSubBetaWarning), + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); + + const broker: pubsub.PubSubBroker = { + name: args.name, + }; + if (args.description) { + broker.description = args.description; + } + if (args.expiration) { + const expiration = parseHumanDuration(args.expiration); + if (isNaN(expiration)) { + throw new CommandLineArgsError( + `${args.expiration} is not a time duration. (Example of valid values are: 1y, 6 days)` + ); } - - logger.log( - await pubsub.createPubSubBroker(accountId, args.namespace, broker) - ); + broker.expiration = expiration; + } + if (args["on-publish-url"]) { + broker.on_publish = { + url: args["on-publish-url"], + }; } - ) - .epilogue(pubsub.pubSubBetaWarning); - - brokersYargs - .command( - "update ", - "Update an existing Pub/Sub Broker's configuration.", - (yargs) => - yargs - .positional("name", { - describe: "The name of an existing Pub/Sub Broker", - type: "string", - demandOption: true, - }) - .option("namespace", { - describe: "The Namespace the Broker is associated with", - type: "string", - alias: "ns", - demandOption: true, - }) - .option("description", { - describe: "A optional description of the Broker.", - type: "string", - }) - .option("expiration", { - describe: - "The expiration date for all client credentials issued by the Broker (can use seconds, hours, months, weeks, years)", - type: "string", - }) - .option("on-publish-url", { - describe: - "A (HTTPS) Cloudflare Worker (or webhook) URL that messages will be sent to on-publish.", - type: "string", - }), - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); - const broker: pubsub.PubSubBrokerUpdate = {}; + logger.log( + await pubsub.createPubSubBroker(accountId, args.namespace, broker) + ); + } + ); + + brokersYargs.command( + "update ", + "Update an existing Pub/Sub Broker's configuration.", + (yargs) => + yargs + .positional("name", { + describe: "The name of an existing Pub/Sub Broker", + type: "string", + demandOption: true, + }) + .option("namespace", { + describe: "The Namespace the Broker is associated with", + type: "string", + alias: "ns", + demandOption: true, + }) + .option("description", { + describe: "A optional description of the Broker.", + type: "string", + }) + .option("expiration", { + describe: + "The expiration date for all client credentials issued by the Broker (can use seconds, hours, months, weeks, years)", + type: "string", + }) + .option("on-publish-url", { + describe: + "A (HTTPS) Cloudflare Worker (or webhook) URL that messages will be sent to on-publish.", + type: "string", + }) + .epilogue(pubsub.pubSubBetaWarning), + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); - if (args.description) { - broker.description = args.description; - } + const broker: pubsub.PubSubBrokerUpdate = {}; - if (args.expiration) { - const expiration = parseHumanDuration(args.expiration); - if (isNaN(expiration)) { - throw new CommandLineArgsError( - `${args.expiration} is not a time duration. Examples of valid values include: '1y', '24h', or '6 days'.` - ); - } - broker.expiration = expiration; - } + if (args.description) { + broker.description = args.description; + } - if (args["on-publish-url"]) { - broker.on_publish = { - url: args["on-publish-url"], - }; + if (args.expiration) { + const expiration = parseHumanDuration(args.expiration); + if (isNaN(expiration)) { + throw new CommandLineArgsError( + `${args.expiration} is not a time duration. Examples of valid values include: '1y', '24h', or '6 days'.` + ); } + broker.expiration = expiration; + } - logger.log( - await pubsub.updatePubSubBroker( - accountId, - args.namespace, - args.name, - broker - ) - ); - logger.log(`Successfully updated Pub/Sub Broker ${args.name}`); + if (args["on-publish-url"]) { + broker.on_publish = { + url: args["on-publish-url"], + }; } - ) - .epilogue(pubsub.pubSubBetaWarning); - brokersYargs - .command( - "list", - "List the Pub/Sub Brokers within a Namespace", - (yargs) => { - return yargs.option("namespace", { + logger.log( + await pubsub.updatePubSubBroker( + accountId, + args.namespace, + args.name, + broker + ) + ); + logger.log(`Successfully updated Pub/Sub Broker ${args.name}`); + } + ); + + brokersYargs.command( + "list", + "List the Pub/Sub Brokers within a Namespace", + (yargs) => { + return yargs + .option("namespace", { describe: "The Namespace the Brokers are associated with.", type: "string", alias: "ns", demandOption: true, - }); - }, - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); + }) + .epilogue(pubsub.pubSubBetaWarning); + }, + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); - logger.log( - await pubsub.listPubSubBrokers(accountId, args.namespace) - ); - } - ) - .epilogue(pubsub.pubSubBetaWarning); + logger.log(await pubsub.listPubSubBrokers(accountId, args.namespace)); + } + ); brokersYargs .command( @@ -295,7 +287,8 @@ export function pubSubCommands( type: "string", alias: "ns", demandOption: true, - }); + }) + .epilogue(pubsub.pubSubBetaWarning); }, async (args) => { const config = readConfig(args.config as ConfigPath, args); @@ -316,9 +309,6 @@ export function pubSubCommands( } } ) - .epilogue(pubsub.pubSubBetaWarning); - - brokersYargs .command( "describe ", "Describe an existing Pub/Sub Broker.", @@ -334,7 +324,8 @@ export function pubSubCommands( type: "string", alias: "ns", demandOption: true, - }); + }) + .epilogue(pubsub.pubSubBetaWarning); }, async (args) => { const config = readConfig(args.config as ConfigPath, args); @@ -348,247 +339,239 @@ export function pubSubCommands( ) ); } - ) - .epilogue(pubsub.pubSubBetaWarning); - - brokersYargs - .command( - "issue ", - "Issue new client credentials for a specific Pub/Sub Broker.", - (yargs) => { - return yargs - .positional("name", { - describe: "The name of the Broker to issue credentials for.", - type: "string", - demandOption: true, - }) - .option("namespace", { - describe: "The Namespace the Broker is associated with.", - type: "string", - alias: "ns", - demandOption: true, - }) - .option("number", { - describe: "The number of credentials to generate.", - type: "number", - alias: "n", - default: 1, - }) - .option("type", { - describe: "The type of credential to generate.", - type: "string", - default: "TOKEN", - }) - .option("expiration", { - describe: - "The expiration to set on the issued credentials. This overrides any Broker-level expiration that is set.", - type: "string", - alias: "exp", - }) - .option("client-id", { - describe: - "A list of existing clientIds to generate tokens for. By default, clientIds are randomly generated.", - type: "string", - alias: "jti", - array: true, - }); - }, - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); - - let parsedExpiration: number | undefined; - if (args.expiration) { - const expiration = parseHumanDuration(args.expiration); - if (isNaN(expiration)) { - throw new CommandLineArgsError( - `${args.expiration} is not a time duration. Example of valid values are: 1y, 6 days.` - ); - } - parsedExpiration = expiration; + ); + + brokersYargs.command( + "issue ", + "Issue new client credentials for a specific Pub/Sub Broker.", + (yargs) => { + return yargs + .positional("name", { + describe: "The name of the Broker to issue credentials for.", + type: "string", + demandOption: true, + }) + .option("namespace", { + describe: "The Namespace the Broker is associated with.", + type: "string", + alias: "ns", + demandOption: true, + }) + .option("number", { + describe: "The number of credentials to generate.", + type: "number", + alias: "n", + default: 1, + }) + .option("type", { + describe: "The type of credential to generate.", + type: "string", + default: "TOKEN", + }) + .option("expiration", { + describe: + "The expiration to set on the issued credentials. This overrides any Broker-level expiration that is set.", + type: "string", + alias: "exp", + }) + .option("client-id", { + describe: + "A list of existing clientIds to generate tokens for. By default, clientIds are randomly generated.", + type: "string", + alias: "jti", + array: true, + }) + .epilogue(pubsub.pubSubBetaWarning); + }, + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); + + let parsedExpiration: number | undefined; + if (args.expiration) { + const expiration = parseHumanDuration(args.expiration); + if (isNaN(expiration)) { + throw new CommandLineArgsError( + `${args.expiration} is not a time duration. Example of valid values are: 1y, 6 days.` + ); } - - logger.log( - `🔑 Issuing credential(s) for ${args.name}.${args.namespace}...` - ); - - logger.log( - await pubsub.issuePubSubBrokerTokens( - accountId, - args.namespace, - args.name, - args.number, - args.type, - args["client-id"], - parsedExpiration - ) - ); + parsedExpiration = expiration; } - ) - .epilogue(pubsub.pubSubBetaWarning); - - brokersYargs - .command( - "revoke ", - "Revoke a set of active client credentials associated with the given Broker", - (yargs) => { - return yargs - .positional("name", { - describe: - "The name of the Broker to revoke credentials against.", - type: "string", - demandOption: true, - }) - .option("namespace", { - describe: "The Namespace the Broker is associated with.", - type: "string", - alias: "ns", - demandOption: true, - }) - .option("jti", { - describe: "Tokens to revoke", - type: "string", - demandOption: true, - array: true, - }); - }, - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); - - const numTokens = args.jti.length; - logger.log( - `🔴 Revoking access to ${args.name} for ${numTokens} credential(s)...` - ); + logger.log( + `🔑 Issuing credential(s) for ${args.name}.${args.namespace}...` + ); - await pubsub.revokePubSubBrokerTokens( + logger.log( + await pubsub.issuePubSubBrokerTokens( accountId, args.namespace, args.name, - args.jti - ); - - logger.log(`Revoked ${args.jti.length} credential(s).`); - } - ) - .epilogue(pubsub.pubSubBetaWarning); - - brokersYargs - .command( - "unrevoke ", - "Restore access to a set of previously revoked client credentials.", - (yargs) => { - return yargs - .positional("name", { - describe: - "The name of the Broker to revoke credentials against.", - type: "string", - demandOption: true, - }) - .option("namespace", { - describe: "The Namespace the Broker is associated with.", - type: "string", - alias: "ns", - demandOption: true, - }) - .option("jti", { - describe: "Tokens to revoke", - type: "string", - demandOption: true, - array: true, - }); - }, - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); - - const numTokens = args.jti.length; - logger.log( - `🟢 Restoring access to ${args.broker} for ${numTokens} credential(s)...` - ); - - await pubsub.unrevokePubSubBrokerTokens( + args.number, + args.type, + args["client-id"], + parsedExpiration + ) + ); + } + ); + + brokersYargs.command( + "revoke ", + "Revoke a set of active client credentials associated with the given Broker", + (yargs) => { + return yargs + .positional("name", { + describe: "The name of the Broker to revoke credentials against.", + type: "string", + demandOption: true, + }) + .option("namespace", { + describe: "The Namespace the Broker is associated with.", + type: "string", + alias: "ns", + demandOption: true, + }) + .option("jti", { + describe: "Tokens to revoke", + type: "string", + demandOption: true, + array: true, + }) + .epilogue(pubsub.pubSubBetaWarning); + }, + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); + + const numTokens = args.jti.length; + + logger.log( + `🔴 Revoking access to ${args.name} for ${numTokens} credential(s)...` + ); + + await pubsub.revokePubSubBrokerTokens( + accountId, + args.namespace, + args.name, + args.jti + ); + + logger.log(`Revoked ${args.jti.length} credential(s).`); + } + ); + + brokersYargs.command( + "unrevoke ", + "Restore access to a set of previously revoked client credentials.", + (yargs) => { + return yargs + .positional("name", { + describe: "The name of the Broker to revoke credentials against.", + type: "string", + demandOption: true, + }) + .option("namespace", { + describe: "The Namespace the Broker is associated with.", + type: "string", + alias: "ns", + demandOption: true, + }) + .option("jti", { + describe: "Tokens to revoke", + type: "string", + demandOption: true, + array: true, + }) + .epilogue(pubsub.pubSubBetaWarning); + }, + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); + + const numTokens = args.jti.length; + logger.log( + `🟢 Restoring access to ${args.broker} for ${numTokens} credential(s)...` + ); + + await pubsub.unrevokePubSubBrokerTokens( + accountId, + args.namespace, + args.name, + args.jti + ); + + logger.log(`Unrevoked ${numTokens} credential(s)`); + } + ); + + brokersYargs.command( + "show-revocations ", + "Show all previously revoked client credentials.", + (yargs) => { + return yargs + .positional("name", { + describe: "The name of the Broker to revoke credentials against.", + type: "string", + demandOption: true, + }) + .option("namespace", { + describe: "The Namespace the Broker is associated with.", + type: "string", + alias: "ns", + demandOption: true, + }) + .epilogue(pubsub.pubSubBetaWarning); + }, + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); + + logger.log(`Listing previously revoked tokens for ${args.name}...`); + logger.log( + await pubsub.listRevokedPubSubBrokerTokens( accountId, args.namespace, - args.name, - args.jti - ); - - logger.log(`Unrevoked ${numTokens} credential(s)`); - } - ) - .epilogue(pubsub.pubSubBetaWarning); - - brokersYargs - .command( - "show-revocations ", - "Show all previously revoked client credentials.", - (yargs) => { - return yargs - .positional("name", { - describe: - "The name of the Broker to revoke credentials against.", - type: "string", - demandOption: true, - }) - .option("namespace", { - describe: "The Namespace the Broker is associated with.", - type: "string", - alias: "ns", - demandOption: true, - }); - }, - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); - - logger.log(`Listing previously revoked tokens for ${args.name}...`); - logger.log( - await pubsub.listRevokedPubSubBrokerTokens( - accountId, - args.namespace, - args.name - ) - ); - } - ) - .epilogue(pubsub.pubSubBetaWarning); - - brokersYargs - .command( - "public-keys ", - "Show the public keys used for verifying on-publish hooks and credentials for a Broker.", - (yargs) => { - return yargs - .positional("name", { - describe: - "The name of the Broker to revoke credentials against.", - type: "string", - demandOption: true, - }) - .option("namespace", { - describe: "The Namespace the Broker is associated with.", - type: "string", - alias: "ns", - demandOption: true, - }); - }, - async (args) => { - const config = readConfig(args.config as ConfigPath, args); - const accountId = await requireAuth(config); - - logger.log( - await pubsub.getPubSubBrokerPublicKeys( - accountId, - args.namespace, - args.name - ) - ); - } - ) - .epilogue(pubsub.pubSubBetaWarning); + args.name + ) + ); + } + ); + + brokersYargs.command( + "public-keys ", + "Show the public keys used for verifying on-publish hooks and credentials for a Broker.", + (yargs) => { + return yargs + .positional("name", { + describe: "The name of the Broker to revoke credentials against.", + type: "string", + demandOption: true, + }) + .option("namespace", { + describe: "The Namespace the Broker is associated with.", + type: "string", + alias: "ns", + demandOption: true, + }) + .epilogue(pubsub.pubSubBetaWarning); + }, + async (args) => { + const config = readConfig(args.config as ConfigPath, args); + const accountId = await requireAuth(config); + + logger.log( + await pubsub.getPubSubBrokerPublicKeys( + accountId, + args.namespace, + args.name + ) + ); + } + ); + brokersYargs.epilogue(pubsub.pubSubBetaWarning); return brokersYargs; - }); + }) + .epilogue(pubsub.pubSubBetaWarning); }