@suitegeezus/suitecloud-cli 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +7 -0
- package/DELTA.md +235 -0
- package/README.md +107 -0
- package/docs/Command.md +299 -0
- package/messages.json +317 -0
- package/package.json +51 -0
- package/postinstall.js +8 -0
- package/resources/FUTC-LICENSE.txt +115 -0
- package/src/ApplicationConstants.js +87 -0
- package/src/CLI.js +202 -0
- package/src/CLIException.js +21 -0
- package/src/ExecutionEnvironmentContext.js +39 -0
- package/src/SdkExecutionContext.js +90 -0
- package/src/SdkExecutor.js +160 -0
- package/src/commands/Command.js +158 -0
- package/src/commands/account/manageauth/ManageAccountAction.js +126 -0
- package/src/commands/account/manageauth/ManageAccountCommand.js +20 -0
- package/src/commands/account/manageauth/ManageAccountInputHandler.js +215 -0
- package/src/commands/account/manageauth/ManageAccountOutputHandler.js +30 -0
- package/src/commands/account/setup/SetupAction.js +39 -0
- package/src/commands/account/setup/SetupCommand.js +21 -0
- package/src/commands/account/setup/SetupInputHandler.js +169 -0
- package/src/commands/account/setup/SetupOutputHandler.js +65 -0
- package/src/commands/account/setupci/AccountSetupCiAction.js +58 -0
- package/src/commands/account/setupci/AccountSetupCiCommand.js +20 -0
- package/src/commands/account/setupci/AccountSetupCiConstants.js +21 -0
- package/src/commands/account/setupci/AccountSetupCiOutputHandler.js +40 -0
- package/src/commands/account/setupci/AccountSetupCiValidation.js +100 -0
- package/src/commands/base/BaseAction.js +37 -0
- package/src/commands/base/BaseInputHandler.js +24 -0
- package/src/commands/base/BaseOutputHandler.js +30 -0
- package/src/commands/custom/hello/Action.js +58 -0
- package/src/commands/custom/hello/Command.js +20 -0
- package/src/commands/custom/hello/Handler.js +26 -0
- package/src/commands/custom/hello/README.md +78 -0
- package/src/commands/custom/hook/Action.js +28 -0
- package/src/commands/custom/hook/Command.js +22 -0
- package/src/commands/custom/hook/InputHandler.js +8 -0
- package/src/commands/custom/hook/OutputHandler.js +8 -0
- package/src/commands/custom/hook/README.md +32 -0
- package/src/commands/file/create/CreateFileAction.js +89 -0
- package/src/commands/file/create/CreateFileCommand.js +20 -0
- package/src/commands/file/create/CreateFileInputHandler.js +175 -0
- package/src/commands/file/create/CreateFileOutputHandler.js +22 -0
- package/src/commands/file/import/ImportFilesAction.js +112 -0
- package/src/commands/file/import/ImportFilesCommand.js +22 -0
- package/src/commands/file/import/ImportFilesInputHandler.js +130 -0
- package/src/commands/file/import/ImportFilesOutputHandler.js +53 -0
- package/src/commands/file/list/ListFilesAction.js +55 -0
- package/src/commands/file/list/ListFilesCommand.js +20 -0
- package/src/commands/file/list/ListFilesInputHandler.js +55 -0
- package/src/commands/file/list/ListFilesOutputHandler.js +24 -0
- package/src/commands/file/upload/UploadFilesAction.js +67 -0
- package/src/commands/file/upload/UploadFilesCommand.js +20 -0
- package/src/commands/file/upload/UploadFilesInputHandler.js +125 -0
- package/src/commands/file/upload/UploadFilesOutputHandler.js +49 -0
- package/src/commands/object/create/CreateObjectAction.js +33 -0
- package/src/commands/object/create/CreateObjectCommand.js +19 -0
- package/src/commands/object/create/CreateObjectInputHandler.js +82 -0
- package/src/commands/object/import/ImportObjectsAction.js +225 -0
- package/src/commands/object/import/ImportObjectsCommand.js +20 -0
- package/src/commands/object/import/ImportObjectsInputHandler.js +310 -0
- package/src/commands/object/import/ImportObjectsOutputHandler.js +114 -0
- package/src/commands/object/list/ListObjectsAction.js +62 -0
- package/src/commands/object/list/ListObjectsCommand.js +20 -0
- package/src/commands/object/list/ListObjectsInputHandler.js +148 -0
- package/src/commands/object/list/ListObjectsOutputHandler.js +29 -0
- package/src/commands/object/update/UpdateAction.js +138 -0
- package/src/commands/object/update/UpdateCommand.js +20 -0
- package/src/commands/object/update/UpdateInputHandler.js +170 -0
- package/src/commands/object/update/UpdateOutputHandler.js +61 -0
- package/src/commands/project/adddependencies/AddDependenciesAction.js +55 -0
- package/src/commands/project/adddependencies/AddDependenciesCommand.js +19 -0
- package/src/commands/project/adddependencies/AddDependenciesOutputHandler.js +114 -0
- package/src/commands/project/create/CreateProjectAction.js +370 -0
- package/src/commands/project/create/CreateProjectCommand.js +20 -0
- package/src/commands/project/create/CreateProjectInputHandler.js +169 -0
- package/src/commands/project/create/CreateProjectOutputHandler.js +36 -0
- package/src/commands/project/deploy/DeployAction.js +161 -0
- package/src/commands/project/deploy/DeployCommand.js +20 -0
- package/src/commands/project/deploy/DeployInputHandler.js +100 -0
- package/src/commands/project/deploy/DeployOutputHandler.js +49 -0
- package/src/commands/project/package/PackageAction.js +59 -0
- package/src/commands/project/package/PackageCommand.js +18 -0
- package/src/commands/project/package/PackageOutputHandler.js +18 -0
- package/src/commands/project/validate/ValidateAction.js +106 -0
- package/src/commands/project/validate/ValidateCommand.js +20 -0
- package/src/commands/project/validate/ValidateInputHandler.js +92 -0
- package/src/commands/project/validate/ValidateOutputHandler.js +74 -0
- package/src/core/CommandActionExecutor.js +347 -0
- package/src/core/CommandAuthentication.js +13 -0
- package/src/core/CommandOptionsValidator.js +42 -0
- package/src/core/CommandRegistrationService.js +130 -0
- package/src/core/CommandsMetadataService.js +104 -0
- package/src/core/extensibility/CLIConfigurationService.js +192 -0
- package/src/core/extensibility/CommandUserExtension.js +64 -0
- package/src/core/sdksetup/SdkDownloadService.js +109 -0
- package/src/core/sdksetup/SdkLicense.js +39 -0
- package/src/core/sdksetup/SdkProperties.js +51 -0
- package/src/loggers/ConsoleLogger.js +32 -0
- package/src/loggers/LoggerFontFormatter.mjs +17 -0
- package/src/loggers/LoggerOsConstants.js +12 -0
- package/src/loggers/NodeConsoleLogger.js +47 -0
- package/src/metadata/CommandGenerators.json +92 -0
- package/src/metadata/NodeCommandsMetadata.json +139 -0
- package/src/metadata/ObjectTypesMetadata.js +615 -0
- package/src/metadata/SdkCommandsMetadata.json +846 -0
- package/src/metadata/SdkCommandsMetadataPatch.json +130 -0
- package/src/metadata/SuiteScriptModulesMetadata.js +152 -0
- package/src/metadata/SuiteScriptTypesMetadata.js +64 -0
- package/src/services/AccountFileCabinetService.js +86 -0
- package/src/services/EnvironmentInformationService.js +31 -0
- package/src/services/ExecutionContextService.js +108 -0
- package/src/services/FileCabinetService.js +65 -0
- package/src/services/FileSystemService.js +245 -0
- package/src/services/NodeTranslationService.js +22 -0
- package/src/services/NpmInstallRunner.js +33 -0
- package/src/services/ProjectInfoService.js +209 -0
- package/src/services/SuiteCloudAuthProxyService.js +469 -0
- package/src/services/TranslationKeys.js +506 -0
- package/src/services/TranslationService.js +30 -0
- package/src/services/actionresult/ActionResult.js +129 -0
- package/src/services/actionresult/AuthenticateActionResult.js +85 -0
- package/src/services/actionresult/CreateProjectActionResult.js +100 -0
- package/src/services/actionresult/DeployActionResult.js +69 -0
- package/src/services/actionresult/HelloActionResult.js +13 -0
- package/src/services/actionresult/ManageAccountActionResult.js +70 -0
- package/src/services/settings/CLISettings.js +46 -0
- package/src/services/settings/CLISettingsService.js +132 -0
- package/src/suitecloud.js +33 -0
- package/src/templates/TemplateKeys.js +25 -0
- package/src/templates/objects/commerceextension.xml +9 -0
- package/src/templates/projectconfigs/default_gitignore.template +47 -0
- package/src/templates/projectconfigs/sdf.config.js +4 -0
- package/src/templates/projectconfigs/suitecloud.config.js +4 -0
- package/src/templates/scripts/blankscript.js +3 -0
- package/src/templates/unittest/jest.config.js.template +7 -0
- package/src/templates/unittest/jsconfig.json.template +5 -0
- package/src/templates/unittest/package.json.template +12 -0
- package/src/templates/unittest/sample-test.js.template +37 -0
- package/src/templates/unittest/suitecloud.config.js.template +15 -0
- package/src/ui/CliSpinner.js +34 -0
- package/src/utils/AccountCredentialsFormatter.js +62 -0
- package/src/utils/AccountSpecificValuesUtils.js +55 -0
- package/src/utils/ActionResultUtils.js +47 -0
- package/src/utils/ApplyInstallationPreferencesUtils.js +41 -0
- package/src/utils/AuthenticationUtils.js +262 -0
- package/src/utils/CommandUtils.js +50 -0
- package/src/utils/CryptoUtils.js +41 -0
- package/src/utils/ExceptionUtils.js +33 -0
- package/src/utils/FileUtils.js +43 -0
- package/src/utils/SdkOperationResult.js +68 -0
- package/src/utils/SdkOperationResultUtils.js +20 -0
- package/src/utils/ValidationErrorsFormatter.js +23 -0
- package/src/utils/http/HttpConstants.js +39 -0
- package/src/utils/http/ProxyAgent.js +110 -0
- package/src/validation/InteractiveAnswersValidator.js +205 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const assert = require('assert');
|
|
8
|
+
const BaseAction = require('../../base/BaseAction');
|
|
9
|
+
const SdkExecutionContext = require('../../../SdkExecutionContext');
|
|
10
|
+
const { executeWithSpinner } = require('../../../ui/CliSpinner');
|
|
11
|
+
const SdkOperationResultUtils = require('../../../utils/SdkOperationResultUtils');
|
|
12
|
+
const CommandUtils = require('../../../utils/CommandUtils');
|
|
13
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
14
|
+
const { ManageAccountActionResult, MANAGE_ACTION } = require('../../../services/actionresult/ManageAccountActionResult');
|
|
15
|
+
const { throwValidationException } = require('../../../utils/ExceptionUtils');
|
|
16
|
+
const {
|
|
17
|
+
COMMAND_MANAGE_ACCOUNT: { MESSAGES, ERRORS },
|
|
18
|
+
} = require('../../../services/TranslationKeys');
|
|
19
|
+
|
|
20
|
+
const COMMAND = {
|
|
21
|
+
OPTIONS: {
|
|
22
|
+
INFO: 'info',
|
|
23
|
+
LIST: 'list',
|
|
24
|
+
REMOVE: 'remove',
|
|
25
|
+
RENAME: 'rename',
|
|
26
|
+
RENAMETO: 'renameto',
|
|
27
|
+
},
|
|
28
|
+
FLAGS: {
|
|
29
|
+
NO_PREVIEW: 'no_preview',
|
|
30
|
+
SKIP_WARNING: 'skip_warning',
|
|
31
|
+
VALIDATE: 'validate',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const DATA_PROPERTIES = {
|
|
36
|
+
INFO: 'info',
|
|
37
|
+
ACCOUNT_INFO: 'accountInfo',
|
|
38
|
+
HOST_INFO: 'hostInfo',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const DOMAIN = 'domain';
|
|
42
|
+
|
|
43
|
+
module.exports = class ManageAccountAction extends BaseAction {
|
|
44
|
+
constructor(options) {
|
|
45
|
+
super(options);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async execute(params) {
|
|
49
|
+
const sdkParams = CommandUtils.extractCommandOptions(params, this._commandMetadata);
|
|
50
|
+
|
|
51
|
+
const flags = [];
|
|
52
|
+
if (params[COMMAND.OPTIONS.LIST]) {
|
|
53
|
+
flags.push(COMMAND.OPTIONS.LIST);
|
|
54
|
+
delete sdkParams[COMMAND.OPTIONS.LIST];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const executionContext = SdkExecutionContext.Builder.forCommand(this._commandMetadata.sdkCommand)
|
|
58
|
+
.integration()
|
|
59
|
+
.addParams(sdkParams)
|
|
60
|
+
.addFlags(flags)
|
|
61
|
+
.build();
|
|
62
|
+
|
|
63
|
+
const selectedOptions = this._extractSelectedOptions(params);
|
|
64
|
+
const message = this._getSpinnerMessage(selectedOptions);
|
|
65
|
+
const operationResult = await executeWithSpinner({
|
|
66
|
+
action: this._sdkExecutor.execute(executionContext),
|
|
67
|
+
message: message,
|
|
68
|
+
});
|
|
69
|
+
return operationResult.status === SdkOperationResultUtils.STATUS.SUCCESS
|
|
70
|
+
? ManageAccountActionResult.Builder.withData(this._prepareData(selectedOptions, operationResult.data))
|
|
71
|
+
.withResultMessage(operationResult.resultMessage)
|
|
72
|
+
.withExecutedAction(selectedOptions.action)
|
|
73
|
+
.withCommandParameters(sdkParams)
|
|
74
|
+
.build()
|
|
75
|
+
: ManageAccountActionResult.Builder.withErrors(operationResult.errorMessages).withCommandParameters(sdkParams).build();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_extractSelectedOptions(answers) {
|
|
79
|
+
let action;
|
|
80
|
+
let authId;
|
|
81
|
+
if (answers.hasOwnProperty(COMMAND.OPTIONS.INFO)) {
|
|
82
|
+
action = MANAGE_ACTION.INFO;
|
|
83
|
+
authId = answers[COMMAND.OPTIONS.INFO];
|
|
84
|
+
} else if (answers.hasOwnProperty(COMMAND.OPTIONS.LIST)) {
|
|
85
|
+
action = MANAGE_ACTION.LIST;
|
|
86
|
+
} else if (answers.hasOwnProperty(COMMAND.OPTIONS.REMOVE)) {
|
|
87
|
+
action = MANAGE_ACTION.REMOVE;
|
|
88
|
+
authId = answers[COMMAND.OPTIONS.REMOVE];
|
|
89
|
+
} else if (answers.hasOwnProperty(COMMAND.OPTIONS.RENAME)) {
|
|
90
|
+
action = MANAGE_ACTION.RENAME;
|
|
91
|
+
authId = answers[COMMAND.OPTIONS.RENAME];
|
|
92
|
+
} else {
|
|
93
|
+
throwValidationException([NodeTranslationService.getMessage(ERRORS.OPTION_NOT_SPECIFIED)], this._runInInteractiveMode, this._commandMetadata);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
action: action,
|
|
97
|
+
...(authId && { authId: authId }),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_getSpinnerMessage(selectedOptions) {
|
|
102
|
+
switch (selectedOptions.action) {
|
|
103
|
+
case MANAGE_ACTION.REMOVE:
|
|
104
|
+
return NodeTranslationService.getMessage(MESSAGES.REMOVING);
|
|
105
|
+
case MANAGE_ACTION.RENAME:
|
|
106
|
+
return NodeTranslationService.getMessage(MESSAGES.RENAMING);
|
|
107
|
+
case MANAGE_ACTION.LIST:
|
|
108
|
+
return NodeTranslationService.getMessage(MESSAGES.LISTING);
|
|
109
|
+
case MANAGE_ACTION.INFO:
|
|
110
|
+
return NodeTranslationService.getMessage(MESSAGES.INFO, selectedOptions.authId);
|
|
111
|
+
}
|
|
112
|
+
assert.fail(NodeTranslationService.getMessage(ERRORS.UNKNOWN_ACTION));
|
|
113
|
+
}
|
|
114
|
+
_prepareData(selectedOptions, data) {
|
|
115
|
+
if (selectedOptions.action !== MANAGE_ACTION.INFO) {
|
|
116
|
+
return data;
|
|
117
|
+
}
|
|
118
|
+
assert(selectedOptions.authId);
|
|
119
|
+
assert(data.hasOwnProperty(DATA_PROPERTIES.ACCOUNT_INFO));
|
|
120
|
+
let actionResultData = { authId: selectedOptions.authId, accountInfo: data.accountInfo };
|
|
121
|
+
if (data.hasOwnProperty(DATA_PROPERTIES.HOST_INFO)) {
|
|
122
|
+
actionResultData[DOMAIN] = data.hostInfo.hostName;
|
|
123
|
+
}
|
|
124
|
+
return actionResultData;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const Command = require('../../Command');
|
|
8
|
+
const ManageAccountAction = require('./ManageAccountAction');
|
|
9
|
+
const ManageAccountInputHandler = require('./ManageAccountInputHandler');
|
|
10
|
+
const ManageAccountOutputHandler = require('./ManageAccountOutputHandler');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
create(options) {
|
|
14
|
+
return Command.Builder.withOptions(options)
|
|
15
|
+
.withAction(ManageAccountAction)
|
|
16
|
+
.withInput(ManageAccountInputHandler)
|
|
17
|
+
.withOutput(ManageAccountOutputHandler)
|
|
18
|
+
.build();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const BaseInputHandler = require('../../base/BaseInputHandler');
|
|
8
|
+
const CommandUtils = require('../../../utils/CommandUtils');
|
|
9
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
10
|
+
const AccountCredentialsFormatter = require('../../../utils/AccountCredentialsFormatter');
|
|
11
|
+
const { getAuthIds } = require('../../../utils/AuthenticationUtils');
|
|
12
|
+
const { MANAGE_ACTION } = require('../../../services/actionresult/ManageAccountActionResult');
|
|
13
|
+
const { DOMAIN } = require('../../../ApplicationConstants');
|
|
14
|
+
const { default : { prompt, Separator } } = require('inquirer');
|
|
15
|
+
const {
|
|
16
|
+
showValidationResults,
|
|
17
|
+
validateAuthIDNotInList,
|
|
18
|
+
validateAlphanumericHyphenUnderscore,
|
|
19
|
+
validateFieldHasNoSpaces,
|
|
20
|
+
validateFieldIsNotEmpty,
|
|
21
|
+
validateMaximumLength,
|
|
22
|
+
validateSameAuthID,
|
|
23
|
+
} = require('../../../validation/InteractiveAnswersValidator');
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
COMMAND_MANAGE_ACCOUNT: { QUESTIONS, QUESTIONS_CHOICES, MESSAGES, ERRORS },
|
|
27
|
+
YES,
|
|
28
|
+
NO,
|
|
29
|
+
} = require('../../../services/TranslationKeys');
|
|
30
|
+
|
|
31
|
+
const COMMAND = {
|
|
32
|
+
OPTIONS: {
|
|
33
|
+
INFO: 'info',
|
|
34
|
+
LIST: 'list',
|
|
35
|
+
REMOVE: 'remove',
|
|
36
|
+
RENAME: 'rename',
|
|
37
|
+
RENAMETO: 'renameto',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ANSWERS_NAMES = {
|
|
42
|
+
SELECTED_AUTH_ID: 'selected_auth_id',
|
|
43
|
+
ACTION: 'action',
|
|
44
|
+
AUTHID: 'authId',
|
|
45
|
+
RENAMETO: 'renameto',
|
|
46
|
+
REMOVE: 'remove',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
module.exports = class ManageAccountInputHandler extends BaseInputHandler {
|
|
50
|
+
constructor(options) {
|
|
51
|
+
super(options);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getParameters(params) {
|
|
55
|
+
if (!this._runInInteractiveMode) {
|
|
56
|
+
return params;
|
|
57
|
+
}
|
|
58
|
+
let answers = await this.getAuthId(params)
|
|
59
|
+
this._log.info(AccountCredentialsFormatter.getInfoString(answers[ANSWERS_NAMES.SELECTED_AUTH_ID]));
|
|
60
|
+
const selectedAuthID = answers[ANSWERS_NAMES.SELECTED_AUTH_ID].authId;
|
|
61
|
+
answers[ANSWERS_NAMES.ACTION] = await this._selectAction(prompt);
|
|
62
|
+
if (answers[ANSWERS_NAMES.ACTION] === MANAGE_ACTION.RENAME) {
|
|
63
|
+
answers[ANSWERS_NAMES.RENAMETO] = await this._introduceNewName(prompt, authIDActionResult.data, selectedAuthID);
|
|
64
|
+
} else if (answers[ANSWERS_NAMES.ACTION] === MANAGE_ACTION.REMOVE) {
|
|
65
|
+
answers[ANSWERS_NAMES.REMOVE] = await this._confirmRemove(prompt);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return this._extractAnswers(answers);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async getAuthId(params){
|
|
72
|
+
if (!this._runInInteractiveMode) {
|
|
73
|
+
return params;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const authIDActionResult = await getAuthIds(this._sdkPath);
|
|
77
|
+
if (!authIDActionResult.isSuccess()) {
|
|
78
|
+
throw authIDActionResult.errorMessages;
|
|
79
|
+
}
|
|
80
|
+
return await this._selectAuthID(authIDActionResult.data, prompt);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_logAccountInfo(selectedAuthId) {
|
|
84
|
+
const accountInfo = selectedAuthId.accountInfo;
|
|
85
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.ACCOUNT_INFO.AUTHID, selectedAuthId.authId));
|
|
86
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.ACCOUNT_INFO.ACCOUNT_NAME, accountInfo.companyName));
|
|
87
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.ACCOUNT_INFO.ACCOUNT_ID, accountInfo.companyId));
|
|
88
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.ACCOUNT_INFO.ROLE, accountInfo.roleName));
|
|
89
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.ACCOUNT_INFO.DOMAIN, accountInfo.roleName));
|
|
90
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.ACCOUNT_INFO.ACCOUNT_TYPE, accountInfo.roleName));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_accountCredentialToString(authID, accountCredential) {
|
|
94
|
+
const urlInfo =
|
|
95
|
+
accountCredential.hostInfo.hostName &&
|
|
96
|
+
!accountCredential.hostInfo.hostName.match(DOMAIN.PRODUCTION.PRODUCTION_DOMAIN_REGEX) &&
|
|
97
|
+
!accountCredential.hostInfo.hostName.match(DOMAIN.PRODUCTION.PRODUCTION_ACCOUNT_SPECIFIC_DOMAIN_REGEX)
|
|
98
|
+
? NodeTranslationService.getMessage(QUESTIONS_CHOICES.SELECT_AUTHID.EXISTING_AUTH_ID_URL_NOT_PRODUCTION, accountCredential.hostInfo.hostName)
|
|
99
|
+
: '';
|
|
100
|
+
const accountInfo = `${accountCredential.accountInfo.roleName} @ ${accountCredential.accountInfo.companyName}`;
|
|
101
|
+
return NodeTranslationService.getMessage(
|
|
102
|
+
QUESTIONS_CHOICES.SELECT_AUTHID.EXISTING_AUTH_ID,
|
|
103
|
+
authID,
|
|
104
|
+
accountInfo,
|
|
105
|
+
urlInfo
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async _selectAuthID(authIDList, prompt) {
|
|
110
|
+
var authIDs = Object.entries(authIDList).sort();
|
|
111
|
+
if (authIDs.length <= 0) {
|
|
112
|
+
throw NodeTranslationService.getMessage(ERRORS.CREDENTIALS_EMPTY);
|
|
113
|
+
}
|
|
114
|
+
const choices = [];
|
|
115
|
+
authIDs.forEach((authIDArray) => {
|
|
116
|
+
const authID = authIDArray[0];
|
|
117
|
+
const accountCredential = authIDArray[1];
|
|
118
|
+
const accountCredentialString = this._accountCredentialToString(authID, accountCredential);
|
|
119
|
+
choices.push({
|
|
120
|
+
name: accountCredentialString,
|
|
121
|
+
value: { authId: authID, accountInfo: accountCredential.accountInfo, domain: accountCredential.hostInfo.hostName },
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
choices.push(new Separator());
|
|
125
|
+
return await prompt([
|
|
126
|
+
{
|
|
127
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
128
|
+
name: ANSWERS_NAMES.SELECTED_AUTH_ID,
|
|
129
|
+
message: NodeTranslationService.getMessage(QUESTIONS.SELECT_CREDENTIALS),
|
|
130
|
+
choices: choices,
|
|
131
|
+
},
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async _selectAction(prompt) {
|
|
136
|
+
let answer = await prompt({
|
|
137
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
138
|
+
name: ANSWERS_NAMES.ACTION,
|
|
139
|
+
message: NodeTranslationService.getMessage(QUESTIONS.SELECT_ACTION),
|
|
140
|
+
choices: [
|
|
141
|
+
{
|
|
142
|
+
name: NodeTranslationService.getMessage(QUESTIONS_CHOICES.ACTIONS.RENAME),
|
|
143
|
+
value: MANAGE_ACTION.RENAME,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: NodeTranslationService.getMessage(QUESTIONS_CHOICES.ACTIONS.REMOVE),
|
|
147
|
+
value: MANAGE_ACTION.REMOVE,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: NodeTranslationService.getMessage(QUESTIONS_CHOICES.ACTIONS.EXIT),
|
|
151
|
+
value: MANAGE_ACTION.EXIT,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (answer[ANSWERS_NAMES.ACTION] === MANAGE_ACTION.EXIT) {
|
|
157
|
+
throw NodeTranslationService.getMessage(MESSAGES.CANCEL);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return answer[ANSWERS_NAMES.ACTION];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async _introduceNewName(prompt, authIDMap, originalAuthId) {
|
|
164
|
+
let answer = await prompt({
|
|
165
|
+
type: CommandUtils.INQUIRER_TYPES.INPUT,
|
|
166
|
+
name: ANSWERS_NAMES.RENAMETO,
|
|
167
|
+
message: NodeTranslationService.getMessage(QUESTIONS.NEW_NAME),
|
|
168
|
+
filter: (fieldValue) => fieldValue.trim(),
|
|
169
|
+
//fieldValue needs the trim because filter is executed AFTER validate
|
|
170
|
+
validate: (fieldValue) =>
|
|
171
|
+
showValidationResults(
|
|
172
|
+
fieldValue.trim(),
|
|
173
|
+
validateFieldIsNotEmpty,
|
|
174
|
+
validateFieldHasNoSpaces,
|
|
175
|
+
(fieldValue) => validateSameAuthID(fieldValue.trim(), originalAuthId),
|
|
176
|
+
(fieldValue) => validateAuthIDNotInList(fieldValue.trim(), Object.keys(authIDMap)),
|
|
177
|
+
validateAlphanumericHyphenUnderscore,
|
|
178
|
+
validateMaximumLength
|
|
179
|
+
),
|
|
180
|
+
});
|
|
181
|
+
return answer[ANSWERS_NAMES.RENAMETO];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async _confirmRemove(prompt) {
|
|
185
|
+
let answer = await prompt([
|
|
186
|
+
{
|
|
187
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
188
|
+
name: ANSWERS_NAMES.REMOVE,
|
|
189
|
+
message: NodeTranslationService.getMessage(QUESTIONS.VERIFY_REMOVE),
|
|
190
|
+
default: false,
|
|
191
|
+
choices: [
|
|
192
|
+
{ name: NodeTranslationService.getMessage(YES), value: true },
|
|
193
|
+
{ name: NodeTranslationService.getMessage(NO), value: false },
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
]);
|
|
197
|
+
if (!answer[ANSWERS_NAMES.REMOVE]) {
|
|
198
|
+
throw NodeTranslationService.getMessage(MESSAGES.CANCEL);
|
|
199
|
+
}
|
|
200
|
+
return answer[ANSWERS_NAMES.REMOVE];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
_extractAnswers(answers) {
|
|
204
|
+
if (answers[ANSWERS_NAMES.ACTION] === MANAGE_ACTION.RENAME) {
|
|
205
|
+
return {
|
|
206
|
+
[COMMAND.OPTIONS.RENAME]: answers[ANSWERS_NAMES.SELECTED_AUTH_ID].authId,
|
|
207
|
+
[COMMAND.OPTIONS.RENAMETO]: answers[ANSWERS_NAMES.RENAMETO],
|
|
208
|
+
};
|
|
209
|
+
} else if (answers[ANSWERS_NAMES.ACTION] === MANAGE_ACTION.REMOVE) {
|
|
210
|
+
return {
|
|
211
|
+
[COMMAND.OPTIONS.REMOVE]: answers[ANSWERS_NAMES.SELECTED_AUTH_ID].authId,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
const BaseOutputHandler = require('../../base/BaseOutputHandler');
|
|
7
|
+
const ActionResultUtils = require('../../../utils/ActionResultUtils');
|
|
8
|
+
const AccountCredentialsFormatter = require('../../../utils/AccountCredentialsFormatter');
|
|
9
|
+
const { MANAGE_ACTION } = require('../../../services/actionresult/ManageAccountActionResult');
|
|
10
|
+
|
|
11
|
+
module.exports = class ManageAccountOutputFormatter extends BaseOutputHandler {
|
|
12
|
+
constructor(consoleLogger) {
|
|
13
|
+
super(consoleLogger);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
parse(actionResult) {
|
|
17
|
+
if (actionResult.resultMessage) {
|
|
18
|
+
ActionResultUtils.logResultMessage(actionResult, this._log);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (actionResult.actionExecuted === MANAGE_ACTION.INFO) {
|
|
22
|
+
this._log.result(AccountCredentialsFormatter.getInfoString(actionResult.data));
|
|
23
|
+
} else if (actionResult.actionExecuted === MANAGE_ACTION.LIST) {
|
|
24
|
+
Object.keys(actionResult.data).forEach((authId) =>
|
|
25
|
+
this._log.result(AccountCredentialsFormatter.getListItemString(authId, actionResult.data[authId]))
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return actionResult;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const BaseAction = require('../../base/BaseAction');
|
|
8
|
+
const AuthenticateActionResult = require('../../../services/actionresult/AuthenticateActionResult');
|
|
9
|
+
const { setDefaultAuthentication, authenticateWithOauth } = require('../../../utils/AuthenticationUtils');
|
|
10
|
+
|
|
11
|
+
const AUTH_MODE = {
|
|
12
|
+
OAUTH: 'OAUTH',
|
|
13
|
+
REUSE: 'REUSE',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = class SetupAction extends BaseAction {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(options);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async execute(params) {
|
|
22
|
+
try {
|
|
23
|
+
if (params.mode === AUTH_MODE.OAUTH) {
|
|
24
|
+
return await authenticateWithOauth(params, this._sdkPath, this._executionPath, this._executionEnvironmentContext);
|
|
25
|
+
} else if (params.mode === AUTH_MODE.REUSE) {
|
|
26
|
+
const authId = params.authentication.authId;
|
|
27
|
+
const accountInfo = params.authentication.accountInfo;
|
|
28
|
+
setDefaultAuthentication(this._executionPath, authId);
|
|
29
|
+
return AuthenticateActionResult.Builder.success()
|
|
30
|
+
.withMode(AUTH_MODE.REUSE)
|
|
31
|
+
.withAuthId(authId)
|
|
32
|
+
.withAccountInfo(accountInfo)
|
|
33
|
+
.build();
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return AuthenticateActionResult.Builder.withErrors([error]).build();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const Command = require('../../Command');
|
|
8
|
+
const SetupAction = require('./SetupAction');
|
|
9
|
+
const SetupInputHandler = require('./SetupInputHandler');
|
|
10
|
+
const SetupOutputHandler = require('./SetupOutputHandler');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
create(options) {
|
|
14
|
+
return Command.Builder.withOptions(options)
|
|
15
|
+
.withAction(SetupAction)
|
|
16
|
+
.withInput(SetupInputHandler)
|
|
17
|
+
.withOutput(SetupOutputHandler)
|
|
18
|
+
.alwaysInteractive()
|
|
19
|
+
.build();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const loadLoggerFontFormatter = async () => {
|
|
8
|
+
const { COLORS, BOLD } = await import('../../../loggers/LoggerFontFormatter.mjs');
|
|
9
|
+
return { COLORS, BOLD };
|
|
10
|
+
};
|
|
11
|
+
const fontFormatterPromise = loadLoggerFontFormatter();
|
|
12
|
+
const { default : { prompt, Separator } } = require('inquirer');
|
|
13
|
+
const BaseInputHandler = require('../../base/BaseInputHandler');
|
|
14
|
+
const CommandUtils = require('../../../utils/CommandUtils');
|
|
15
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
16
|
+
const { getAuthIds } = require('../../../utils/AuthenticationUtils');
|
|
17
|
+
const { validateBrowserBasedAuthIsAllowed } = require('../../../services/ExecutionContextService');
|
|
18
|
+
const {
|
|
19
|
+
DOMAIN
|
|
20
|
+
} = require('../../../ApplicationConstants');
|
|
21
|
+
const ProjectInfoService = require('../../../services/ProjectInfoService');
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
COMMAND_SETUPACCOUNT: { QUESTIONS, QUESTIONS_CHOICES, MESSAGES }
|
|
25
|
+
} = require('../../../services/TranslationKeys');
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
validateFieldHasNoSpaces,
|
|
29
|
+
validateFieldIsNotEmpty,
|
|
30
|
+
validateAuthIDNotInList,
|
|
31
|
+
validateAlphanumericHyphenUnderscore,
|
|
32
|
+
validateMaximumLength,
|
|
33
|
+
showValidationResults,
|
|
34
|
+
} = require('../../../validation/InteractiveAnswersValidator');
|
|
35
|
+
|
|
36
|
+
const ANSWERS = {
|
|
37
|
+
SELECTED_AUTH_ID: 'selected_auth_id',
|
|
38
|
+
AUTH_MODE: 'AUTH_MODE',
|
|
39
|
+
NEW_AUTH_ID: 'NEW_AUTH_ID',
|
|
40
|
+
URL: 'url',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const AUTH_MODE = {
|
|
44
|
+
OAUTH: 'OAUTH',
|
|
45
|
+
REUSE: 'REUSE',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const CREATE_NEW_AUTH = '******CREATE_NEW_AUTH*******!£$%&*';
|
|
49
|
+
|
|
50
|
+
module.exports = class SetupInputHandler extends BaseInputHandler {
|
|
51
|
+
constructor(options) {
|
|
52
|
+
super(options);
|
|
53
|
+
this._projectInfoService = new ProjectInfoService(this._projectFolder);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async getParameters(params) {
|
|
57
|
+
this._projectInfoService.checkWorkingDirectoryContainsValidProject(this._commandMetadata.name);
|
|
58
|
+
validateBrowserBasedAuthIsAllowed();
|
|
59
|
+
const authIDActionResult = await getAuthIds(this._sdkPath);
|
|
60
|
+
if (!authIDActionResult.isSuccess()) {
|
|
61
|
+
throw authIDActionResult.errorMessages;
|
|
62
|
+
}
|
|
63
|
+
const selectedAuth = await this.selectAuthIdOption(authIDActionResult);
|
|
64
|
+
|
|
65
|
+
if (selectedAuth !== CREATE_NEW_AUTH) {
|
|
66
|
+
return {
|
|
67
|
+
createNewAuthentication: false,
|
|
68
|
+
authentication: selectedAuth,
|
|
69
|
+
mode: AUTH_MODE.REUSE,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// creating a new authID
|
|
74
|
+
return await this.getParamsCreateNewAuthId(params, authIDActionResult);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async selectAuthIdOption(authIDActionResult) {
|
|
78
|
+
const choices = [];
|
|
79
|
+
let authIdAnswer;
|
|
80
|
+
let authIDs = Object.keys(authIDActionResult.data);
|
|
81
|
+
if (authIDs.length > 0) {
|
|
82
|
+
choices.push({
|
|
83
|
+
name: (await fontFormatterPromise).BOLD(NodeTranslationService.getMessage(QUESTIONS_CHOICES.SELECT_AUTHID.NEW_AUTH_ID)),
|
|
84
|
+
value: CREATE_NEW_AUTH,
|
|
85
|
+
});
|
|
86
|
+
choices.push(new Separator());
|
|
87
|
+
choices.push(new Separator(NodeTranslationService.getMessage(MESSAGES.SELECT_CONFIGURED_AUTHID)));
|
|
88
|
+
authIDs.forEach((authID) => {
|
|
89
|
+
const accountCredentials = authIDActionResult.data[authID];
|
|
90
|
+
// just fixed the isNotProductionUrl because of new credentials format, but the previous version was always false
|
|
91
|
+
// TODO: review if we want to show non-production urls on the list of selectable authIds
|
|
92
|
+
const isNotProductionUrl =
|
|
93
|
+
accountCredentials.hostInfo &&
|
|
94
|
+
accountCredentials.hostInfo.hostName &&
|
|
95
|
+
!accountCredentials.hostInfo.hostName.match(DOMAIN.PRODUCTION.PRODUCTION_DOMAIN_REGEX) &&
|
|
96
|
+
!accountCredentials.hostInfo.hostName.match(DOMAIN.PRODUCTION.PRODUCTION_ACCOUNT_SPECIFIC_DOMAIN_REGEX);
|
|
97
|
+
const notProductionLabel = isNotProductionUrl
|
|
98
|
+
? NodeTranslationService.getMessage(
|
|
99
|
+
QUESTIONS_CHOICES.SELECT_AUTHID.EXISTING_AUTH_ID_URL_NOT_PRODUCTION,
|
|
100
|
+
accountCredentials.hostInfo.hostName
|
|
101
|
+
)
|
|
102
|
+
: '';
|
|
103
|
+
const accountInfo = `${accountCredentials.accountInfo.companyName} [${accountCredentials.accountInfo.roleName}]`;
|
|
104
|
+
choices.push({
|
|
105
|
+
name: NodeTranslationService.getMessage(
|
|
106
|
+
QUESTIONS_CHOICES.SELECT_AUTHID.EXISTING_AUTH_ID,
|
|
107
|
+
authID,
|
|
108
|
+
accountInfo,
|
|
109
|
+
notProductionLabel
|
|
110
|
+
),
|
|
111
|
+
value: { authId: authID, accountInfo: accountCredentials.accountInfo },
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
choices.push(new Separator());
|
|
115
|
+
authIdAnswer = await prompt([
|
|
116
|
+
{
|
|
117
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
118
|
+
name: ANSWERS.SELECTED_AUTH_ID,
|
|
119
|
+
message: NodeTranslationService.getMessage(QUESTIONS.SELECT_AUTHID),
|
|
120
|
+
choices: choices,
|
|
121
|
+
},
|
|
122
|
+
]);
|
|
123
|
+
} else {
|
|
124
|
+
// There was no previous authIDs
|
|
125
|
+
authIdAnswer = {
|
|
126
|
+
[ANSWERS.SELECTED_AUTH_ID]: CREATE_NEW_AUTH,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return authIdAnswer[ANSWERS.SELECTED_AUTH_ID];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async getParamsCreateNewAuthId(params, authIDActionResult) {
|
|
133
|
+
const newAuthenticationAnswers = await prompt([
|
|
134
|
+
{
|
|
135
|
+
when: params && params.dev !== undefined && params.dev,
|
|
136
|
+
type: CommandUtils.INQUIRER_TYPES.INPUT,
|
|
137
|
+
name: ANSWERS.URL,
|
|
138
|
+
message: NodeTranslationService.getMessage(QUESTIONS.URL),
|
|
139
|
+
filter: (fieldValue) => fieldValue.trim(),
|
|
140
|
+
validate: (fieldValue) => showValidationResults(fieldValue.trim(), validateFieldIsNotEmpty, validateFieldHasNoSpaces),
|
|
141
|
+
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
type: CommandUtils.INQUIRER_TYPES.INPUT,
|
|
145
|
+
name: ANSWERS.NEW_AUTH_ID,
|
|
146
|
+
message: NodeTranslationService.getMessage(QUESTIONS.NEW_AUTH_ID),
|
|
147
|
+
filter: (answer) => answer.trim(),
|
|
148
|
+
validate: (fieldValue) =>
|
|
149
|
+
showValidationResults(
|
|
150
|
+
fieldValue.trim(),
|
|
151
|
+
validateFieldIsNotEmpty,
|
|
152
|
+
validateFieldHasNoSpaces,
|
|
153
|
+
(fieldValue) => validateAuthIDNotInList(fieldValue.trim(), Object.keys(authIDActionResult.data)),
|
|
154
|
+
validateAlphanumericHyphenUnderscore,
|
|
155
|
+
validateMaximumLength
|
|
156
|
+
),
|
|
157
|
+
},
|
|
158
|
+
]);
|
|
159
|
+
|
|
160
|
+
const executeActionContext = {
|
|
161
|
+
createNewAuthentication: true,
|
|
162
|
+
authid: newAuthenticationAnswers[ANSWERS.NEW_AUTH_ID],
|
|
163
|
+
mode: AUTH_MODE.OAUTH,
|
|
164
|
+
...(newAuthenticationAnswers[ANSWERS.URL] && { url: newAuthenticationAnswers[ANSWERS.URL] })
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
return executeActionContext;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
const BaseOutputHandler = require('../../base/BaseOutputHandler');
|
|
7
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
COMMAND_SETUPACCOUNT: { MESSAGES, OUTPUT },
|
|
11
|
+
UTILS: { AUTHENTICATION },
|
|
12
|
+
} = require('../../../services/TranslationKeys');
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
LINKS: {
|
|
16
|
+
ERRORS: {
|
|
17
|
+
AUTHENTICATION_FALLBACK_INFO,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
} = require('../../../ApplicationConstants');
|
|
21
|
+
|
|
22
|
+
const AUTH_MODE = {
|
|
23
|
+
OAUTH: 'OAUTH',
|
|
24
|
+
SAVE_TOKEN: 'SAVE_TOKEN',
|
|
25
|
+
REUSE: 'REUSE',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = class SetupOutputHandler extends BaseOutputHandler {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
super(options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
parse(actionResult) {
|
|
34
|
+
let resultMessage;
|
|
35
|
+
switch (actionResult.mode) {
|
|
36
|
+
case AUTH_MODE.OAUTH:
|
|
37
|
+
resultMessage = NodeTranslationService.getMessage(
|
|
38
|
+
OUTPUT.NEW_OAUTH,
|
|
39
|
+
actionResult.accountInfo.companyName,
|
|
40
|
+
actionResult.accountInfo.roleName,
|
|
41
|
+
actionResult.authId
|
|
42
|
+
);
|
|
43
|
+
break;
|
|
44
|
+
case AUTH_MODE.REUSE:
|
|
45
|
+
resultMessage = NodeTranslationService.getMessage(
|
|
46
|
+
OUTPUT.REUSED_AUTH_ID,
|
|
47
|
+
actionResult.authId,
|
|
48
|
+
actionResult.accountInfo.companyName,
|
|
49
|
+
actionResult.accountInfo.roleName
|
|
50
|
+
);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this._log.result(resultMessage);
|
|
57
|
+
this._log.result(NodeTranslationService.getMessage(AUTHENTICATION.SUCCESS_SETUP));
|
|
58
|
+
|
|
59
|
+
if (actionResult.isSuccess() && process.env.SUITECLOUD_FALLBACK_PASSKEY) {
|
|
60
|
+
this._log.warning(NodeTranslationService.getMessage(MESSAGES.ROTATE_PASSWORD_WARNING, AUTHENTICATION_FALLBACK_INFO));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return actionResult;
|
|
64
|
+
}
|
|
65
|
+
};
|