@forge/cli
12.22.0-experimental-04cc2b912.23.0-next.7-experimental-44b7a12
out/command-line/controller/module-controller.js~
out/command-line/controller/module-controller.jsModified+20−15
Index: package/out/command-line/controller/module-controller.js
===================================================================
--- package/out/command-line/controller/module-controller.js
+++ package/out/command-line/controller/module-controller.js
@@ -5,9 +5,13 @@
const path_1 = tslib_1.__importDefault(require("path"));
const dependencies_merger_1 = require("../../module-add/dependencies-merger");
const cli_shared_1 = require("@forge/cli-shared");
const register_app_commands_1 = require("../register-app-commands");
-const MODULE_PRODUCTS = [register_app_commands_1.TemplateContext.JIRA, register_app_commands_1.TemplateContext.CONFLUENCE];
+const MODULE_PRODUCTS = [
+ register_app_commands_1.TemplateContext.JIRA,
+ register_app_commands_1.TemplateContext.JIRA_SERVICE_MANAGEMENT,
+ register_app_commands_1.TemplateContext.CONFLUENCE
+];
class ModuleController {
moduleView;
moduleService;
fileService;
@@ -24,12 +28,11 @@
this.moduleService.cleanup();
}
}
async runModuleAdd(options) {
- const product = await this.resolveProduct(options);
- const moduleMap = await this.moduleService.getAvailableModules(product);
- const moduleChoiceMap = this.moduleService.getModuleChoice(moduleMap);
- const selectedTemplate = await this.resolveSelectedTemplate(options, moduleMap, moduleChoiceMap);
+ const selectedTemplate = options.moduleType
+ ? await this.resolveTemplateByModuleType(options.moduleType)
+ : await this.resolveSelectedTemplate(await this.resolveProduct(options));
const uiType = options.uiType ?? (await this.resolveUIFramework(selectedTemplate));
const downloadedTemplate = await this.moduleService.prepareModuleMetadata(selectedTemplate, uiType);
if (!downloadedTemplate) {
throw new Error(cli_shared_1.Text.module.add.errorFailedToDownloadTemplate(selectedTemplate.moduleKey));
@@ -54,25 +57,27 @@
});
this.renderRunResult(result, depChanges, hasConflicts, options);
}
async resolveProduct(options) {
- const inferredProduct = options.moduleType?.split(':')[0];
- const product = options.product ??
- inferredProduct ??
- (await this.moduleView.promptForList(cli_shared_1.Text.module.add.promptSelectProduct, MODULE_PRODUCTS));
+ const product = options.product ?? (await this.moduleView.promptForList(cli_shared_1.Text.module.add.promptSelectProduct, MODULE_PRODUCTS));
if (!MODULE_PRODUCTS.includes(product)) {
throw new Error(cli_shared_1.Text.module.add.errorInvalidProduct(product));
}
return product;
}
- async resolveSelectedTemplate(options, moduleMap, moduleChoiceMap) {
- if (options.moduleType) {
- const template = moduleMap.get(options.moduleType);
- if (!template) {
- throw new Error(cli_shared_1.Text.module.add.errorFailedToResolveChoice(options.moduleType));
+ async resolveTemplateByModuleType(moduleType) {
+ for (const product of MODULE_PRODUCTS) {
+ const moduleMap = await this.moduleService.getAvailableModules(product);
+ const template = moduleMap.get(moduleType);
+ if (template) {
+ return template;
}
- return template;
}
+ throw new Error(cli_shared_1.Text.module.add.errorFailedToResolveChoice(moduleType));
+ }
+ async resolveSelectedTemplate(product) {
+ const moduleMap = await this.moduleService.getAvailableModules(product);
+ const moduleChoiceMap = this.moduleService.getModuleChoice(moduleMap);
const selectedChoice = await this.moduleView.promptForList(cli_shared_1.Text.module.add.promptSelectModule, Array.from(moduleChoiceMap.keys()));
const template = moduleChoiceMap.get(selectedChoice);
if (!template) {
throw new Error(cli_shared_1.Text.module.add.errorFailedToResolveChoice(selectedChoice));