npm package diff

Package: @forge/cli

Versions: 11.3.1 - 11.4.0-next.1-experimental-01f8230

File: package/out/command-line/controller/version-controller.js

Index: package/out/command-line/controller/version-controller.js
===================================================================
--- package/out/command-line/controller/version-controller.js
+++ package/out/command-line/controller/version-controller.js
@@ -3,8 +3,9 @@
 exports.VersionController = void 0;
 const tslib_1 = require("tslib");
 const fs_1 = require("fs");
 const diff = tslib_1.__importStar(require("diff"));
+const cli_shared_1 = require("@forge/cli-shared");
 const defaultProperties = ['appVersion', 'deploymentDateTime', 'environmentType'];
 function filterObjectProperties(source, filteredProperties, defaultProperties) {
     const result = {};
     for (const prop of [...filteredProperties, ...defaultProperties]) {
@@ -113,6 +114,51 @@
         else {
             this.view.displayVersionList(versionList);
         }
     }
+    async createVersionUpgrade({ environment, json, outFile, nonInteractive, fromMajorVersion, toMajorVersion }) {
+        let appVersionUpgradeRolloutId;
+        if (nonInteractive) {
+            appVersionUpgradeRolloutId = await this.versionService.createAppVersionUpgradeRolloutNonInteractively(environment, fromMajorVersion, toMajorVersion);
+        }
+        else {
+            const sourceVersions = await this.versionService.getAppUpgradeVersionsList(environment);
+            const selectedSourceVersion = await this.getSelectedVersion(['Major version', 'Deployment date', 'Installations'], sourceVersions.map(({ version, deploymentDateTime, installations, id }) => ({
+                names: [version, deploymentDateTime, installations],
+                value: id,
+                primary: version
+            })), sourceVersions, cli_shared_1.Text.version.upgrade.promptVersionTable, cli_shared_1.Text.version.upgrade.overViewVersionTable(sourceVersions.length, environment));
+            const upgradableToVersions = await this.versionService.getUpgradableVersions(environment, selectedSourceVersion.id);
+            if (upgradableToVersions.length == 0) {
+                this.view.displayInfo(cli_shared_1.Text.version.upgrade.error.noTargetVersionAvailable);
+                return;
+            }
+            const selectedTargetVersion = await this.getSelectedVersion(['Major version', 'Deployment date'], upgradableToVersions.map(({ version, deploymentDateTime, id }) => ({
+                names: [version, deploymentDateTime],
+                value: id,
+                primary: version
+            })), upgradableToVersions, cli_shared_1.Text.version.upgrade.selectTargetVersionToUpgrade(selectedSourceVersion.installations));
+            const confirmCreate = await this.view.confirmAppVersionRolloutCreation(selectedSourceVersion.id, selectedTargetVersion.id, selectedSourceVersion.installations);
+            if (confirmCreate) {
+                appVersionUpgradeRolloutId = await this.versionService.createAppVersionUpgradeRollout(environment, selectedSourceVersion.id, selectedTargetVersion.id);
+            }
+            else {
+                return;
+            }
+        }
+        if (outFile) {
+            this.writeToFile(cli_shared_1.Text.version.upgrade.appVersionRolloutSuccess(appVersionUpgradeRolloutId), outFile);
+        }
+        else if (json) {
+            this.displayInJson(cli_shared_1.Text.version.upgrade.appVersionRolloutSuccess(appVersionUpgradeRolloutId));
+        }
+        else {
+            this.view.displayAppVersionRolloutCreationSuccess(appVersionUpgradeRolloutId);
+        }
+    }
+    async getSelectedVersion(columns, tableData, versions, versionTablePrompt, versionTableOverview) {
+        const index = await this.view.displaySingleSelectVersion(columns, tableData, versionTablePrompt, versionTableOverview);
+        return versions[index];
+    }
 }
 exports.VersionController = VersionController;
+//# sourceMappingURL=version-controller.js.map
\ No newline at end of file