npm package diff
Package: @forge/cli
Versions: 11.0.0 - 11.0.1-next.14
File: package/out/command-line/register-installation-commands.js
Index: package/out/command-line/register-installation-commands.js
===================================================================
--- package/out/command-line/register-installation-commands.js
+++ package/out/command-line/register-installation-commands.js
@@ -1,10 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.registerCommands = exports.performMultipleUninstalls = exports.performSingleUninstall = exports.registerListInstallationsCommand = void 0;
+exports.registerCommands = exports.registerListInstallationsCommand = void 0;
const cli_shared_1 = require("@forge/cli-shared");
const shared_1 = require("../installations/shared");
-const errors_1 = require("./errors");
+const uninstall_command_helpers_1 = require("./uninstall-command-helpers");
const semver_1 = require("semver");
const COMMAND_NAME = 'install';
const registerInstallAppCommand = async ({ cmd, controllers: { installController }, services: { supportedProductsService } }) => {
const supportedProducts = await supportedProductsService.getSupportedProducts();
@@ -22,9 +22,9 @@
.action(async ({ environment, site, product, upgrade, confirmScopes, license, licenseModes, usersWithAccess, nonInteractive }) => {
await installController.run({
environment,
site,
- product,
+ products: product ? [product] : [],
upgrade,
confirmScopes,
license,
licenseModes,
@@ -64,54 +64,8 @@
});
});
};
exports.registerListInstallationsCommand = registerListInstallationsCommand;
-const performSingleUninstall = async (installId, { ui, commands: { uninstallAppCommand } }) => {
- const installation = await ui.displayProgress(() => uninstallAppCommand.execute(installId), cli_shared_1.Text.uninstall.cmd.start, (result) => ({
- successful: !!result.successful,
- message: cli_shared_1.Text.uninstall.cmd.success(false)
- }));
- const uninstallMessageFormat = installation.successful ? cli_shared_1.Text.uninstall.done : cli_shared_1.Text.uninstall.failed;
- const uninstallMessage = uninstallMessageFormat((0, cli_shared_1.productDisplayName)(installation.product), installation.site, installation.environmentKey, false);
- if (installation.successful) {
- ui.info(uninstallMessage);
- }
- else {
- ui.error(new shared_1.UninstallAppError(uninstallMessage));
- }
-};
-exports.performSingleUninstall = performSingleUninstall;
-const performMultipleUninstalls = async (appsToUninstall, { ui, commands: { uninstallAppCommand } }) => {
- const filteredInstallations = appsToUninstall.filter(({ product }) => product !== 'identity');
- const hasMultipleNonIdentityApps = filteredInstallations.length > 1;
- const uninstalledApps = await ui.displayProgress(() => uninstallAppCommand.batchExecute([], appsToUninstall), cli_shared_1.Text.uninstall.cmd.start, (result) => {
- const isSuccessful = !result.some(({ successful }) => successful === false);
- return {
- successful: isSuccessful,
- message: cli_shared_1.Text.uninstall.cmd.success(hasMultipleNonIdentityApps)
- };
- });
- const deferredErrors = [];
- uninstalledApps.forEach((uninstall) => {
- const uninstallMessageFormat = uninstall.successful ? cli_shared_1.Text.uninstall.done : cli_shared_1.Text.uninstall.failed;
- const formattedMessage = uninstallMessageFormat((0, cli_shared_1.productDisplayName)(uninstall.product), uninstall.site, uninstall.environmentKey, hasMultipleNonIdentityApps);
- if (uninstall.successful && uninstall.product !== 'identity') {
- ui.info(formattedMessage);
- }
- else if (!uninstall.successful) {
- const uninstallError = new shared_1.UninstallAppError(formattedMessage);
- ui.error(uninstallError);
- deferredErrors.push(uninstallError);
- }
- });
- if (uninstalledApps.some(({ successful }) => successful === false)) {
- throw new errors_1.DeferredErrors(deferredErrors);
- }
- if (hasMultipleNonIdentityApps) {
- ui.info(cli_shared_1.Text.uninstall.interactive.done);
- }
-};
-exports.performMultipleUninstalls = performMultipleUninstalls;
const registerUninstallCommand = async (deps) => {
const { cmd, ui, services: { installationsService, supportedProductsService } } = deps;
const supportedProducts = await supportedProductsService.getSupportedProducts();
cmd
@@ -134,25 +88,25 @@
});
ui.info(cli_shared_1.Text.uninstall.info);
ui.info(cli_shared_1.Text.ctrlC);
ui.emptyLine();
- await (0, exports.performSingleUninstall)(installation.id, deps);
+ await (0, uninstall_command_helpers_1.performSingleUninstall)(installation.id, deps);
}
else {
const filteredInstallations = installations.filter((install) => install.product !== 'identity' && install.product !== 'jira-servicedesk');
- const selectedSitesIndexes = await ui.promptForTable(cli_shared_1.Text.uninstall.interactive.desc, cli_shared_1.Text.uninstall.interactive.progressInfo, ['Environment', 'Site', 'Product'], filteredInstallations.map(({ id, environmentKey, product, site }) => ({
- names: [(0, cli_shared_1.environmentToOption)(environmentKey), site, (0, cli_shared_1.productDisplayName)(product)],
- value: id
- })));
- const appsToUninstall = filteredInstallations.filter((_, index) => selectedSitesIndexes.includes(index));
- const selectedSites = new Set(appsToUninstall.map(({ site }) => site));
- const remainingApps = filteredInstallations.filter((_, index) => !selectedSitesIndexes.includes(index));
- appsToUninstall.push(...(0, shared_1.getHangingIdentityInstallationsFromSite)(installations, remainingApps, selectedSites));
- if (appsToUninstall.length > 1) {
- await (0, exports.performMultipleUninstalls)(appsToUninstall, deps);
+ const options = (0, uninstall_command_helpers_1.getMultiChoiceOptionsForUninstall)(filteredInstallations);
+ const selectedSitesIndexes = await ui.promptForTable(cli_shared_1.Text.uninstall.interactive.desc, cli_shared_1.Text.uninstall.interactive.progressInfo, ['Environment', 'Site', 'Product'], options);
+ const [firstUninstall, secondUninstall] = (0, uninstall_command_helpers_1.getInstallationsFromSelection)(options, selectedSitesIndexes, filteredInstallations);
+ const selectedSites = new Set(firstUninstall.map(({ site }) => site).concat(secondUninstall.map(({ site }) => site)));
+ const remainingApps = options
+ .filter((_, index) => !selectedSitesIndexes.includes(index))
+ .map(({ extra }) => filteredInstallations[extra.installationIdx]);
+ firstUninstall.push(...(0, shared_1.getHangingIdentityInstallationsFromSite)(installations, remainingApps, selectedSites));
+ if (firstUninstall.length > 1 || secondUninstall.length > 0) {
+ await (0, uninstall_command_helpers_1.performMultipleUninstalls)(firstUninstall, secondUninstall, deps);
}
- else {
- await (0, exports.performSingleUninstall)(appsToUninstall[0].id, deps);
+ else if (firstUninstall.length === 1) {
+ await (0, uninstall_command_helpers_1.performSingleUninstall)(firstUninstall[0].id, deps);
}
}
});
};