@forge/cli

13.0.013.1.0-next.4-experimental-9423de1
out/command-line/controller/install-controller.js
~out/command-line/controller/install-controller.jsModified
+25−20
Index: package/out/command-line/controller/install-controller.js
===================================================================
--- package/out/command-line/controller/install-controller.js
+++ package/out/command-line/controller/install-controller.js
@@ -61,9 +61,10 @@
                     product,
                     licenseOverride: license,
                     overrides,
                     majorVersionId,
-                    environmentType
+                    environmentType,
+                    appIdOverride: appId
                 });
                 return { operation: 'install', alreadyUpdated: false, installResult };
             }
         }, text.cmd.start(environment, environmentType, (0, cli_shared_1.productDisplayName)(product)), ({ alreadyUpdated }) => {
@@ -104,18 +105,18 @@
             throw new cli_shared_1.ValidationError(invalidText);
         }
         return this.supportedProductsService.validateSite(trySite, products[0] && (0, cli_shared_1.productDisplayName)(products[0]));
     }
-    async getAppInstallations(siteOption, productOption, environmentOption) {
+    async getAppInstallations(siteOption, productOption, environmentOption, appIdOverride) {
         const { installations } = await this.installationService.listNonTechnicalAppInstallations({
             site: siteOption,
             product: productOption,
             environment: environmentOption
-        });
+        }, appIdOverride);
         return installations;
     }
-    async getInstallationToUpgrade(siteOption, productOption, environmentOption, isCodeUpgrade, targetVersion, isLatest) {
-        const matchingInstallations = await this.getAppInstallations(siteOption, productOption, environmentOption);
+    async getInstallationToUpgrade(siteOption, productOption, environmentOption, isCodeUpgrade, targetVersion, isLatest, appIdOverride) {
+        const matchingInstallations = await this.getAppInstallations(siteOption, productOption, environmentOption, appIdOverride);
         let selectedInstallationToUpgrade;
         if (siteOption && productOption?.length) {
             if (!matchingInstallations.length) {
                 throw new cli_shared_1.ValidationError(cli_shared_1.Text.error.invalidInstallationContext);
@@ -203,10 +204,10 @@
             throw new cli_shared_1.UserError(cli_shared_1.Text.install.error.majorVersionNotFound);
         }
         return result;
     }
-    async run({ environment, site, products, upgrade, confirmScopes, license, licenseModes, usersWithAccess, nonInteractive, majorVersion }) {
-        const { id } = await this.appConfigProvider();
+    async run({ environment, site, products, upgrade, confirmScopes, license, licenseModes, usersWithAccess, nonInteractive, majorVersion, appIdOverride }) {
+        const id = appIdOverride ?? (await this.appConfigProvider()).id;
         await this.devSpaceService.displayEnforcementWarningsIfNeeded(this.ui, id, 'install');
         const { isUpgrade, isCodeUpgrade } = this.validateUpgradeTarget(upgrade);
         const text = isUpgrade ? cli_shared_1.Text.upgrade : cli_shared_1.Text.install;
         const validLicense = this.validateLicenseOption(license, environment);
@@ -230,9 +231,9 @@
         let scopesFromLastInstallation = new Set();
         let egressFromLastInstallation = new Set();
         let currentVersion;
         if (isUpgrade) {
-            const upgradeResult = await this.getInstallationToUpgrade(site, products?.[0], environment, isCodeUpgrade, environmentPermissions?.version, environmentPermissions?.isLatest);
+            const upgradeResult = await this.getInstallationToUpgrade(site, products?.[0], environment, isCodeUpgrade, environmentPermissions?.version, environmentPermissions?.isLatest, appIdOverride);
             environment = upgradeResult.environment;
             site = upgradeResult.site;
             products = [upgradeResult.product];
             scopesFromLastInstallation = new Set(upgradeResult.scopes);
@@ -245,9 +246,9 @@
             site = site ? site : await this.promptForSite(products);
             this.ui.info(this.supportedProductsService.isWorkspaceProduct(products[0]) ? text.bannerWorkspace : text.bannerSite);
         }
         else {
-            const result = await this.getXPAProductsAndSite(requiredProducts.map(cli_shared_1.productDisplayName), products, site, environment);
+            const result = await this.getXPAProductsAndSite(requiredProducts.map(cli_shared_1.productDisplayName), products, site, environment, appIdOverride);
             site = result.site;
             products = result.products;
             this.ui.info(cli_shared_1.Text.install.installConfirmation(products.join(', '), site.host));
         }
@@ -258,14 +259,18 @@
             this.ui.error(new NoDeploymentError(environment), { pad: false });
             return;
         }
         const { scopes: environmentScopes, egressAddresses: environmentEgressAddresses, environmentType } = environmentPermissions;
-        const [{ permissions, modules }, manifestEgressEntries] = await Promise.all([
-            this.configFile.readConfig(),
-            this.configFile.getEgressPermissions()
-        ]);
-        this.checkForUIKit1Modules(modules);
-        const { manifestEgressAddresses, manifestScopes } = this.extractManifestData(manifestEgressEntries, permissions);
+        let manifestScopes = new Set(environmentScopes);
+        let manifestEgressAddresses = [...environmentEgressAddresses];
+        if (!appIdOverride) {
+            const [{ permissions, modules }, manifestEgressEntries] = await Promise.all([
+                this.configFile.readConfig(),
+                this.configFile.getEgressPermissions()
+            ]);
+            this.checkForUIKit1Modules(modules);
+            ({ manifestEgressAddresses, manifestScopes } = this.extractManifestData(manifestEgressEntries, permissions));
+        }
         const differenceInScopes = environmentScopes.filter((x) => !scopesFromLastInstallation.has(x));
         const listScopes = await this.convertListScope(differenceInScopes);
         const differenceInEgress = environmentEgressAddresses.filter((x) => !egressFromLastInstallation.has(x));
         const listEgress = this.convertListEgress(differenceInEgress);
@@ -298,9 +303,9 @@
                 this.ui.clearSpinner();
                 this.ui.error(error);
                 failedProducts.push(product);
             }
-            await this.checkForMultiProductScopes(environmentScopes, site, environment);
+            await this.checkForMultiProductScopes(environmentScopes, site, environment, appIdOverride);
         }
         if (successfulProducts.length) {
             if (isUpgrade) {
                 this.ui.info(text.success.banner(environment, environmentType, (0, cli_shared_1.productDisplayName)(successfulProducts.join(', ')), site.host, environmentPermissions?.isLatest, environmentPermissions?.version, isCodeUpgrade));
@@ -354,15 +359,15 @@
         const manifestEgressAddresses = (0, cli_shared_1.flatMap)(manifestEgressEntries, ({ domains }) => domains ?? []);
         const manifestScopes = new Set(this.getAllScopeKeys(permissions?.scopes ?? []));
         return { manifestEgressAddresses, manifestScopes };
     };
-    getXPAProductsAndSite = async (requiredProducts, products, site, environmentKey) => {
+    getXPAProductsAndSite = async (requiredProducts, products, site, environmentKey, appIdOverride) => {
         site = site ? site : await this.promptForSite([]);
         const { installations = [] } = await this.installationService.listAppInstallations({
             site,
             ...(environmentKey && { environment: environmentKey }),
             ...(requiredProducts.length > 0 && { product: requiredProducts[0] })
-        });
+        }, appIdOverride);
         if (!products?.length) {
             const hasRequiredInstallations = this.checkRequiredInstallationExists(installations, site.host, requiredProducts);
             if (hasRequiredInstallations) {
                 this.ui.info(cli_shared_1.Text.install.alreadyInstalledInRequiredProduct(requiredProducts[0]));
@@ -386,16 +391,16 @@
             }
         }
         return { site, products };
     };
-    checkForMultiProductScopes = async (environmentScopes, site, environment) => {
+    checkForMultiProductScopes = async (environmentScopes, site, environment, appIdOverride) => {
         const uniqueProductsFromScopes = this.getUniqueInstallationProductsFromScopes(environmentScopes);
         if (!uniqueProductsFromScopes || uniqueProductsFromScopes.length <= 1)
             return;
         const { installations: nonTechnicalInstallations } = await this.installationService.listNonTechnicalAppInstallations({
             site,
             environment
-        });
+        }, appIdOverride);
         const productsToUpgrade = nonTechnicalInstallations
             .filter((installation) => !installation.version.isLatest)
             .map((installation) => installation.product);
         const allInstalledProducts = nonTechnicalInstallations