@forge/cli
12.9.0-next.1712.9.0-next.18-experimental-f76634b
out/command-line/register-webtrigger-commands.js~
out/command-line/register-webtrigger-commands.jsModified+45−8
Index: package/out/command-line/register-webtrigger-commands.js
===================================================================
--- package/out/command-line/register-webtrigger-commands.js
+++ package/out/command-line/register-webtrigger-commands.js
@@ -38,29 +38,36 @@
const values = [...availableWebTriggers.values()];
return await ui.promptForList(cli_shared_1.Text.webtrigger.promptFuncKey, values);
}
}
-async function webtriggerCreateAction(deps, { functionKey, site, environment, product }) {
- const { ui, configFile, services: { installationsService }, commands: { getWebTriggerURLCommand } } = deps;
- let selectedInstallationId = '';
+async function getInstallation(ui, installationsService, context, textConfig) {
+ const { site, product, environment } = context;
if (site && product) {
- ui.info(cli_shared_1.Text.webtrigger.overviewFuncKey);
+ ui.info(textConfig.providedContextOverview);
const installation = await installationsService.findOnlyMatchingInstallation({
site,
environment,
product
});
- selectedInstallationId = (0, installation_helper_1.validateInstallationId)(installation?.id);
+ return (0, installation_helper_1.validateInstallationId)(installation?.id);
}
else {
const appInstallation = await installationsService.listNonTechnicalAppInstallations({
site,
environment,
product
});
- const installation = await (0, installation_helper_1.selectSingleInstallation)(ui, appInstallation.installations, cli_shared_1.Text.webtrigger.promptInstallationTable, cli_shared_1.Text.webtrigger.overViewInstallationTable);
- selectedInstallationId = (0, installation_helper_1.validateInstallationId)(installation.id);
+ const installation = await (0, installation_helper_1.selectSingleInstallation)(ui, appInstallation.installations, textConfig.interactiveTablePrompt, textConfig.interactiveTableOverview);
+ return (0, installation_helper_1.validateInstallationId)(installation.id);
}
+}
+async function webtriggerCreateAction(deps, { functionKey, site, environment, product }) {
+ const { ui, configFile, services: { installationsService }, commands: { getWebTriggerURLCommand } } = deps;
+ const selectedInstallationId = await getInstallation(ui, installationsService, { site, product, environment }, {
+ interactiveTablePrompt: cli_shared_1.Text.webtrigger.promptInstallationTable,
+ interactiveTableOverview: cli_shared_1.Text.webtrigger.overViewInstallationTable,
+ providedContextOverview: cli_shared_1.Text.webtrigger.overviewFuncKey
+ });
const url = await getWebTriggerURLCommand.execute(selectedInstallationId, await validateWebtriggerKey(ui, configFile, functionKey));
ui.info(cli_shared_1.Text.webtrigger.copy(url));
}
function registerDeprecatedWebtriggerCreateCommand(deps) {
@@ -89,11 +96,41 @@
.action(async (args) => {
await webtriggerCreateAction(deps, args);
});
}
+function registerWebTriggerListCommand({ cmd, configFile, ui, services: { installationsService }, commands: { listWebTriggerURLCommand } }) {
+ cmd
+ .command('list')
+ .requireAppId()
+ .description(cli_shared_1.Text.webtrigger.list.cmd)
+ .option('-f, --functionKey <functionKey>', cli_shared_1.Text.webtrigger.list.optionFuncKey)
+ .contextOption()
+ .environmentOption()
+ .precondition(manifestDefinesTriggers(configFile))
+ .action(async ({ site, environment, product, functionKey }) => {
+ const selectedInstallationId = await getInstallation(ui, installationsService, { site, product, environment }, {
+ interactiveTablePrompt: cli_shared_1.Text.webtrigger.promptInstallationTable,
+ interactiveTableOverview: cli_shared_1.Text.webtrigger.list.overviewInstallationTable,
+ providedContextOverview: cli_shared_1.Text.webtrigger.list.overviewProvidedContext
+ });
+ let urls = await listWebTriggerURLCommand.execute(selectedInstallationId);
+ let tablePreMessage = cli_shared_1.Text.webtrigger.list.tablePreMessage;
+ if (functionKey) {
+ const validatedKey = await validateWebtriggerKey(ui, configFile, functionKey);
+ urls = urls.filter((url) => url.triggerKey === validatedKey);
+ tablePreMessage = cli_shared_1.Text.webtrigger.list.listUrlsForKey(validatedKey);
+ }
+ ui.table([
+ ['id', 'ID'],
+ ['triggerKey', 'Module Key'],
+ ['url', 'URL']
+ ], urls, { preMessage: tablePreMessage, emptyMessage: cli_shared_1.Text.webtrigger.list.noWebtriggerURLs });
+ });
+}
const registerCommands = (deps) => {
const webtrigger = deps.cmd.command('webtrigger').description(cli_shared_1.Text.webtrigger.cmd);
- registerWebtriggerCreateCommand({ ...deps, cmd: webtrigger });
registerDeprecatedWebtriggerCreateCommand({ ...deps, cmd: webtrigger });
+ registerWebtriggerCreateCommand({ ...deps, cmd: webtrigger });
+ registerWebTriggerListCommand({ ...deps, cmd: webtrigger });
};
exports.registerCommands = registerCommands;
//# sourceMappingURL=register-webtrigger-commands.js.map
\ No newline at end of file