@forge/cli

10.13.611.0.0-next.18
out/command-line/register-webtrigger-commands.js
out/command-line/register-webtrigger-commands.js
+13−5
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
@@ -25,9 +25,9 @@
     return async () => {
         await getValidWebtriggers(configFile);
     };
 }
-const registerCommands = ({ cmd, ui, graphqlGateway, configFile, services: { installationsService }, commands: { getWebTriggerURLCommand } }) => {
+const registerCommands = async ({ cmd, ui, configFile, services: { installationsService, supportedProductsService }, commands: { getWebTriggerURLCommand } }) => {
     const validateWebtriggerKey = async (functionKey) => {
         const availableWebTriggers = await getValidWebtriggers(configFile);
         if (functionKey) {
             if (!availableWebTriggers.has(functionKey)) {
@@ -39,19 +39,27 @@
             const options = [...availableWebTriggers.keys()];
             return await ui.promptForList(cli_shared_1.Text.webtrigger.promptFuncKey, options);
         }
     };
+    const supportedProducts = await supportedProductsService.getSupportedProducts();
     cmd
-        .command('webtrigger [installationId]')
+        .command('webtrigger')
         .requireAppId()
         .description(cli_shared_1.Text.webtrigger.cmd)
         .option('-f, --functionKey [function]', cli_shared_1.Text.webtrigger.optionFuncKey)
+        .contextOption(supportedProducts)
+        .environmentOption()
         .precondition(manifestDefinesTriggers(configFile))
-        .action(async (argInstallationId, { functionKey }) => {
+        .action(async ({ functionKey, site, environment, product }) => {
         let selectedInstallationId = '';
-        if (argInstallationId) {
+        if (site && product) {
             ui.info(cli_shared_1.Text.webtrigger.overviewFuncKey);
-            selectedInstallationId = (0, installation_helper_1.validateInstallationId)(argInstallationId);
+            const installation = await installationsService.findOnlyMatchingInstallation({
+                site,
+                environment,
+                product
+            });
+            selectedInstallationId = (0, installation_helper_1.validateInstallationId)(installation?.id);
         }
         else {
             const appInstallation = await installationsService.listNonTechnicalAppInstallations();
             const installation = await (0, installation_helper_1.selectSingleInstallation)(ui, appInstallation.installations, cli_shared_1.Text.webtrigger.promptInstallationTable, cli_shared_1.Text.webtrigger.overViewInstallationTable);