@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,106 @@
|
|
|
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
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const BaseAction = require('../../base/BaseAction');
|
|
9
|
+
const DeployActionResult = require('../../../services/actionresult/DeployActionResult');
|
|
10
|
+
const SdkExecutionContext = require('../../../SdkExecutionContext');
|
|
11
|
+
const SdkOperationResultUtils = require('../../../utils/SdkOperationResultUtils');
|
|
12
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
13
|
+
const CommandUtils = require('../../../utils/CommandUtils');
|
|
14
|
+
const ProjectInfoService = require('../../../services/ProjectInfoService');
|
|
15
|
+
const AccountSpecificValuesUtils = require('../../../utils/AccountSpecificValuesUtils');
|
|
16
|
+
const ApplyInstallationPreferencesUtils = require('../../../utils/ApplyInstallationPreferencesUtils');
|
|
17
|
+
const { executeWithSpinner } = require('../../../ui/CliSpinner');
|
|
18
|
+
const { getProjectDefaultAuthId } = require('../../../utils/AuthenticationUtils');
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
COMMAND_VALIDATE: { MESSAGES },
|
|
22
|
+
} = require('../../../services/TranslationKeys');
|
|
23
|
+
|
|
24
|
+
const COMMAND_OPTIONS = {
|
|
25
|
+
SERVER: 'server',
|
|
26
|
+
ACCOUNT_SPECIFIC_VALUES: 'accountspecificvalues',
|
|
27
|
+
APPLY_INSTALLATION_PREFERENCES: 'applyinstallprefs',
|
|
28
|
+
PROJECT: 'project',
|
|
29
|
+
AUTH_ID: 'authid',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = class ValidateAction extends BaseAction {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
super(options);
|
|
35
|
+
const projectInfoService = new ProjectInfoService(this._projectFolder);
|
|
36
|
+
this._projectType = projectInfoService.getProjectType()
|
|
37
|
+
this._projectName = projectInfoService.getProjectName()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
preExecute(params) {
|
|
41
|
+
params[COMMAND_OPTIONS.PROJECT] = CommandUtils.quoteString(this._projectFolder);
|
|
42
|
+
|
|
43
|
+
AccountSpecificValuesUtils.validate(params, this._projectFolder);
|
|
44
|
+
ApplyInstallationPreferencesUtils.validate(params, this._projectFolder, this._commandMetadata.name, this._log);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...params,
|
|
48
|
+
...AccountSpecificValuesUtils.transformArgument(params),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async execute(params) {
|
|
53
|
+
try {
|
|
54
|
+
let isServerValidation = false;
|
|
55
|
+
let installationPreferencesApplied = false;
|
|
56
|
+
const flags = [];
|
|
57
|
+
|
|
58
|
+
if (params[COMMAND_OPTIONS.SERVER]) {
|
|
59
|
+
flags.push(COMMAND_OPTIONS.SERVER);
|
|
60
|
+
isServerValidation = true;
|
|
61
|
+
delete params[COMMAND_OPTIONS.SERVER];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (params[COMMAND_OPTIONS.APPLY_INSTALLATION_PREFERENCES]) {
|
|
65
|
+
delete params[COMMAND_OPTIONS.APPLY_INSTALLATION_PREFERENCES];
|
|
66
|
+
flags.push(COMMAND_OPTIONS.APPLY_INSTALLATION_PREFERENCES);
|
|
67
|
+
installationPreferencesApplied = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const sdkParams = CommandUtils.extractCommandOptions(params, this._commandMetadata);
|
|
71
|
+
|
|
72
|
+
const executionContext = SdkExecutionContext.Builder.forCommand(this._commandMetadata.sdkCommand)
|
|
73
|
+
.integration()
|
|
74
|
+
.addParams(sdkParams)
|
|
75
|
+
.addFlags(flags)
|
|
76
|
+
.build();
|
|
77
|
+
|
|
78
|
+
const operationResult = await executeWithSpinner({
|
|
79
|
+
action: this._sdkExecutor.execute(executionContext),
|
|
80
|
+
message: NodeTranslationService.getMessage(
|
|
81
|
+
MESSAGES.VALIDATING,
|
|
82
|
+
this._projectName,
|
|
83
|
+
this._authId
|
|
84
|
+
)
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return operationResult.status === SdkOperationResultUtils.STATUS.SUCCESS
|
|
88
|
+
? DeployActionResult.Builder.withData(operationResult.data)
|
|
89
|
+
.withResultMessage(operationResult.resultMessage)
|
|
90
|
+
.withServerValidation(isServerValidation)
|
|
91
|
+
.withAppliedInstallationPreferences(installationPreferencesApplied)
|
|
92
|
+
.withProjectType(this._projectType)
|
|
93
|
+
.withProjectFolder(this._projectFolder)
|
|
94
|
+
.withCommandParameters(sdkParams)
|
|
95
|
+
.withCommandFlags(flags)
|
|
96
|
+
.build()
|
|
97
|
+
: DeployActionResult.Builder.withErrors(operationResult.errorMessages)
|
|
98
|
+
.withServerValidation(isServerValidation)
|
|
99
|
+
.withCommandParameters(sdkParams)
|
|
100
|
+
.withCommandFlags(flags)
|
|
101
|
+
.build();
|
|
102
|
+
} catch (error) {
|
|
103
|
+
return DeployActionResult.Builder.withErrors([error]).build();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
@@ -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 ValidateAction = require('./ValidateAction');
|
|
9
|
+
const ValidateInputHandler = require('./ValidateInputHandler');
|
|
10
|
+
const ValidateOutputHandler = require('./ValidateOutputHandler');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
create(options) {
|
|
14
|
+
return Command.Builder.withOptions(options)
|
|
15
|
+
.withAction(ValidateAction)
|
|
16
|
+
.withInput(ValidateInputHandler)
|
|
17
|
+
.withOutput(ValidateOutputHandler)
|
|
18
|
+
.build();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const { default: { prompt } } = require('inquirer');
|
|
9
|
+
const BaseInputHandler = require('../../base/BaseInputHandler');
|
|
10
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
11
|
+
const CommandUtils = require('../../../utils/CommandUtils');
|
|
12
|
+
const ProjectInfoService = require('../../../services/ProjectInfoService');
|
|
13
|
+
const { ACCOUNT_SPECIFIC_VALUES_OPTIONS } = require('../../../utils/AccountSpecificValuesUtils');
|
|
14
|
+
const { PROJECT_ACP, PROJECT_SUITEAPP } = require('../../../ApplicationConstants');
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
COMMAND_VALIDATE: { QUESTIONS, QUESTIONS_CHOICES },
|
|
18
|
+
YES,
|
|
19
|
+
NO,
|
|
20
|
+
} = require('../../../services/TranslationKeys');
|
|
21
|
+
|
|
22
|
+
const COMMAND_OPTIONS = {
|
|
23
|
+
SERVER: 'server',
|
|
24
|
+
ACCOUNT_SPECIFIC_VALUES: 'accountspecificvalues',
|
|
25
|
+
APPLY_INSTALLATION_PREFERENCES: 'applyinstallprefs',
|
|
26
|
+
PROJECT: 'project',
|
|
27
|
+
AUTH_ID: 'authid',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = class ValidateInputHandler extends BaseInputHandler {
|
|
31
|
+
constructor(options) {
|
|
32
|
+
super(options);
|
|
33
|
+
this._projectInfoService = new ProjectInfoService(this._projectFolder);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getParameters(params) {
|
|
37
|
+
|
|
38
|
+
const answers = await prompt([
|
|
39
|
+
{
|
|
40
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
41
|
+
name: COMMAND_OPTIONS.SERVER,
|
|
42
|
+
message: NodeTranslationService.getMessage(QUESTIONS.SERVER_SIDE),
|
|
43
|
+
default: true,
|
|
44
|
+
choices: [
|
|
45
|
+
{
|
|
46
|
+
name: NodeTranslationService.getMessage(QUESTIONS_CHOICES.ACCOUNT_OR_LOCAL.ACCOUNT),
|
|
47
|
+
value: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: NodeTranslationService.getMessage(QUESTIONS_CHOICES.ACCOUNT_OR_LOCAL.LOCAL),
|
|
51
|
+
value: false,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
when: this._projectInfoService.getProjectType() === PROJECT_ACP,
|
|
57
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
58
|
+
name: COMMAND_OPTIONS.ACCOUNT_SPECIFIC_VALUES,
|
|
59
|
+
message: NodeTranslationService.getMessage(QUESTIONS.ACCOUNT_SPECIFIC_VALUES),
|
|
60
|
+
default: ACCOUNT_SPECIFIC_VALUES_OPTIONS.ERROR,
|
|
61
|
+
choices: [
|
|
62
|
+
{
|
|
63
|
+
name: NodeTranslationService.getMessage(QUESTIONS_CHOICES.ACCOUNT_SPECIFIC_VALUES.WARNING),
|
|
64
|
+
value: ACCOUNT_SPECIFIC_VALUES_OPTIONS.WARNING,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: NodeTranslationService.getMessage(QUESTIONS_CHOICES.ACCOUNT_SPECIFIC_VALUES.CANCEL),
|
|
68
|
+
value: ACCOUNT_SPECIFIC_VALUES_OPTIONS.ERROR,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
when: this._projectInfoService.getProjectType() === PROJECT_SUITEAPP && this._projectInfoService.hasLockAndHideFiles(),
|
|
74
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
75
|
+
name: COMMAND_OPTIONS.APPLY_INSTALLATION_PREFERENCES,
|
|
76
|
+
message: NodeTranslationService.getMessage(QUESTIONS.APPLY_INSTALLATION_PREFERENCES),
|
|
77
|
+
default: false,
|
|
78
|
+
choices: [
|
|
79
|
+
{
|
|
80
|
+
name: NodeTranslationService.getMessage(NO),
|
|
81
|
+
value: false,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: NodeTranslationService.getMessage(YES),
|
|
85
|
+
value: true,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
return { ...params, ...answers };
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
const ActionResultUtils = require('../../../utils/ActionResultUtils');
|
|
9
|
+
|
|
10
|
+
const { PROJECT_SUITEAPP } = require('../../../ApplicationConstants');
|
|
11
|
+
const {
|
|
12
|
+
COMMAND_VALIDATE: { MESSAGES, OUTPUT },
|
|
13
|
+
} = require('../../../services/TranslationKeys');
|
|
14
|
+
|
|
15
|
+
module.exports = class ValidateOutputHandler extends BaseOutputHandler {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
parse(actionResult) {
|
|
21
|
+
if (actionResult.isServerValidation && Array.isArray(actionResult.data)) {
|
|
22
|
+
actionResult.data.forEach((resultLine) => {
|
|
23
|
+
this._log.result(resultLine);
|
|
24
|
+
});
|
|
25
|
+
} else if (!actionResult.isServerValidation) {
|
|
26
|
+
this._showApplyInstallationPreferencesOptionMessage(
|
|
27
|
+
actionResult.appliedInstallationPreferences,
|
|
28
|
+
actionResult.projectType,
|
|
29
|
+
actionResult.projectFolder
|
|
30
|
+
);
|
|
31
|
+
this._showLocalValidationResultData(actionResult.data);
|
|
32
|
+
}
|
|
33
|
+
ActionResultUtils.logResultMessage(actionResult, this._log);
|
|
34
|
+
return actionResult;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_showApplyInstallationPreferencesOptionMessage(isAppliedInstallationPreferences, projectType, projectFolder) {
|
|
38
|
+
if (projectType === PROJECT_SUITEAPP) {
|
|
39
|
+
if (isAppliedInstallationPreferences) {
|
|
40
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.APPLYING_INSTALLATION_PREFERENCES, projectFolder));
|
|
41
|
+
} else {
|
|
42
|
+
this._log.info(NodeTranslationService.getMessage(MESSAGES.NOT_APPLYING_INSTALLATION_PREFERENCES, projectFolder));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_showLocalValidationResultData(data) {
|
|
48
|
+
this._logValidationEntries(data.warnings, NodeTranslationService.getMessage(OUTPUT.HEADING_LABEL_WARNING), this._log.warning.bind(this._log));
|
|
49
|
+
this._logValidationEntries(data.errors, NodeTranslationService.getMessage(OUTPUT.HEADING_LABEL_ERROR), this._log.error.bind(this._log));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_logValidationEntries(entries, headingLabel, log) {
|
|
53
|
+
const files = [];
|
|
54
|
+
entries.forEach((entry) => {
|
|
55
|
+
if (!files.includes(entry.filePath)) {
|
|
56
|
+
files.push(entry.filePath);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (entries.length > 0) {
|
|
61
|
+
log(`${headingLabel}:`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
files.forEach((file) => {
|
|
65
|
+
const fileString = ` ${file}`;
|
|
66
|
+
log(fileString);
|
|
67
|
+
entries
|
|
68
|
+
.filter((entry) => entry.filePath === file)
|
|
69
|
+
.forEach((entry) => {
|
|
70
|
+
log(NodeTranslationService.getMessage(OUTPUT.VALIDATION_OUTPUT_MESSAGE, entry.lineNumber, entry.message));
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
@@ -0,0 +1,347 @@
|
|
|
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 fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const NodeTranslationService = require('./../services/NodeTranslationService');
|
|
11
|
+
const { ERRORS, CLI, COMMAND_REFRESH_AUTHORIZATION } = require('../services/TranslationKeys');
|
|
12
|
+
const { ActionResult } = require('../services/actionresult/ActionResult');
|
|
13
|
+
const { lineBreak } = require('../loggers/LoggerOsConstants');
|
|
14
|
+
const ActionResultUtils = require('../utils/ActionResultUtils');
|
|
15
|
+
const { unwrapExceptionMessage, unwrapInformationMessage } = require('../utils/ExceptionUtils');
|
|
16
|
+
const { getProjectDefaultAuthId } = require('../utils/AuthenticationUtils');
|
|
17
|
+
const ExecutionEnvironmentContext = require('../ExecutionEnvironmentContext');
|
|
18
|
+
const { checkIfReauthorizationIsNeeded, refreshAuthorization } = require('../utils/AuthenticationUtils');
|
|
19
|
+
const { AUTHORIZATION_PROPERTIES_KEYS, AUTHORIZATION_FORCE_PROMPTS, ENV_VARS } = require('../ApplicationConstants');
|
|
20
|
+
const ManageAccountInputHandler = require('../commands/account/manageauth/ManageAccountInputHandler');
|
|
21
|
+
|
|
22
|
+
/** @type {CommandActionExecutor} */
|
|
23
|
+
module.exports = class CommandActionExecutor {
|
|
24
|
+
constructor(dependencies) {
|
|
25
|
+
assert(dependencies);
|
|
26
|
+
assert(dependencies.cliConfigurationService);
|
|
27
|
+
assert(dependencies.commandsMetadataService);
|
|
28
|
+
assert(dependencies.log);
|
|
29
|
+
assert(dependencies.sdkPath);
|
|
30
|
+
|
|
31
|
+
this._cliConfigurationService = dependencies.cliConfigurationService;
|
|
32
|
+
this._commandsMetadataService = dependencies.commandsMetadataService;
|
|
33
|
+
this._log = dependencies.log;
|
|
34
|
+
this._sdkPath = dependencies.sdkPath;
|
|
35
|
+
|
|
36
|
+
if (!dependencies.executionEnvironmentContext) {
|
|
37
|
+
this._executionEnvironmentContext = new ExecutionEnvironmentContext();
|
|
38
|
+
} else {
|
|
39
|
+
this._executionEnvironmentContext = dependencies.executionEnvironmentContext;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
get _executionPath(){
|
|
43
|
+
return this._cliConfigurationService?._executionPath ?? process.cwd();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async executeAction(context) {
|
|
47
|
+
assert(context);
|
|
48
|
+
assert(context.arguments);
|
|
49
|
+
assert(context.commandName);
|
|
50
|
+
assert(typeof context.runInInteractiveMode === 'boolean');
|
|
51
|
+
|
|
52
|
+
let commandUserExtension;
|
|
53
|
+
const commandName = context.commandName;
|
|
54
|
+
const debugFilePath = this._getDebugFilePath(context.arguments.debug, commandName);
|
|
55
|
+
try {
|
|
56
|
+
const commandMetadata = this._commandsMetadataService.getCommandMetadataByName(commandName);
|
|
57
|
+
if (context.arguments.config) {
|
|
58
|
+
this._cliConfigurationService.initialize(context.arguments.config, true);
|
|
59
|
+
} else if (context.arguments.noconfig) {
|
|
60
|
+
//do nothing;
|
|
61
|
+
this._cliConfigurationService.initialize(undefined, true);
|
|
62
|
+
} else {
|
|
63
|
+
// location of suitecloud.config
|
|
64
|
+
this._cliConfigurationService.initialize(process.cwd());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
commandUserExtension = this._cliConfigurationService.getCommandUserExtension(commandName);
|
|
68
|
+
const runInInteractiveMode = context.runInInteractiveMode;
|
|
69
|
+
const commandArguments = this._extractOptionValuesFromArguments(commandMetadata.options, context.arguments);
|
|
70
|
+
|
|
71
|
+
// need the
|
|
72
|
+
const projectFolder = this._cliConfigurationService.getProjectFolder(commandName, commandArguments?.project);
|
|
73
|
+
const projectPath = this._cliConfigurationService.getProjectPath(projectFolder);
|
|
74
|
+
let authId;
|
|
75
|
+
// allow an override via --authid
|
|
76
|
+
if (commandArguments?.authid) {
|
|
77
|
+
if (!runInInteractiveMode) {
|
|
78
|
+
// this might throw -- it could also be semi-interactive
|
|
79
|
+
try{
|
|
80
|
+
authId = this._cliConfigurationService.getAuthId(commandName, projectPath, commandArguments?.authid);
|
|
81
|
+
}catch(e){
|
|
82
|
+
if( commandMetadata.isSetupRequired ) throw e;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
} else {
|
|
86
|
+
[authId] = [commandArguments?.authid, ...AUTHORIZATION_FORCE_PROMPTS].filter(Boolean);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const promptForInteractive = runInInteractiveMode &&
|
|
90
|
+
!commandMetadata.name.startsWith('account') &&
|
|
91
|
+
!authId
|
|
92
|
+
|
|
93
|
+
// in interactive mode we can prompt for the authid
|
|
94
|
+
if (promptForInteractive || AUTHORIZATION_FORCE_PROMPTS.includes(authId) ) {
|
|
95
|
+
const interactiveAuthIdHandler = new ManageAccountInputHandler({
|
|
96
|
+
projectFolder: projectPath,
|
|
97
|
+
commandMetadata,
|
|
98
|
+
log: this._log,
|
|
99
|
+
// force it
|
|
100
|
+
runInInteractiveMode: true,
|
|
101
|
+
executionEnvironmentContext: this._executionEnvironmentContext,
|
|
102
|
+
sdkPath: this._sdkPath,
|
|
103
|
+
});
|
|
104
|
+
const { selected_auth_id: chosenAuth } = await interactiveAuthIdHandler.getAuthId(authId);
|
|
105
|
+
if (chosenAuth?.authId) authId = chosenAuth.authId;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this._checkCanExecuteCommand({ runInInteractiveMode, commandMetadata, defaultAuthId: authId });
|
|
109
|
+
|
|
110
|
+
const commandArgumentsWithDefaultContext = this._applyDefaultContextParams(
|
|
111
|
+
commandArguments,
|
|
112
|
+
{
|
|
113
|
+
project: projectPath,
|
|
114
|
+
authid: authId,
|
|
115
|
+
},
|
|
116
|
+
commandMetadata,
|
|
117
|
+
);
|
|
118
|
+
const beforeExecutingOptions = {
|
|
119
|
+
commandName: commandName,
|
|
120
|
+
// the path of the config for teh service
|
|
121
|
+
projectFolder: projectFolder, // this._cliConfigurationService._executionPath,
|
|
122
|
+
projectPath: projectPath,
|
|
123
|
+
// probably cwd
|
|
124
|
+
executionPath: this._executionPath,
|
|
125
|
+
// do not pass reference
|
|
126
|
+
arguments: { ...commandArgumentsWithDefaultContext },
|
|
127
|
+
};
|
|
128
|
+
if (commandMetadata.isSetupRequired) {
|
|
129
|
+
// run beforeExecute(args) from suitecloud.config.js
|
|
130
|
+
beforeExecutingOptions.authId = authId;
|
|
131
|
+
beforeExecutingOptions.arguments = {
|
|
132
|
+
...commandArgumentsWithDefaultContext,
|
|
133
|
+
authid: authId,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (context.runInInteractiveMode){
|
|
138
|
+
beforeExecutingOptions.arguments.interactive = true
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// establish these prior to calling the hooks so they have the available in their environment as well
|
|
142
|
+
process.env[ENV_VARS.SUITECLOUD_PROJECT_FOLDER] = projectFolder;
|
|
143
|
+
process.env[ENV_VARS.SUITECLOUD_PROJECT_PATH] = projectPath;
|
|
144
|
+
process.env[ENV_VARS.SUITECLOUD_PROJECT_ROOT] = this._executionPath;
|
|
145
|
+
// this might modified but we need the user's hooks to take advantage of their current values
|
|
146
|
+
process.env[ENV_VARS.SUITECLOUD_AUTHID] = authId;
|
|
147
|
+
this._dumpDebugFile(debugFilePath, undefined, 'FIRST');
|
|
148
|
+
this._dumpDebugFile(debugFilePath, 'beforeExecuting', beforeExecutingOptions, runInInteractiveMode);
|
|
149
|
+
const beforeExecutingOutput = await commandUserExtension.beforeExecuting(beforeExecutingOptions);
|
|
150
|
+
const overriddenArguments = beforeExecutingOutput.arguments;
|
|
151
|
+
|
|
152
|
+
// do not allow this argument to be overwritten (i.e. change it back)
|
|
153
|
+
if (Reflect.has(commandArgumentsWithDefaultContext, 'project'))
|
|
154
|
+
overriddenArguments.project = commandArgumentsWithDefaultContext.project;
|
|
155
|
+
|
|
156
|
+
// update the authid as well (not recommended but possible) -- should this be in the isSetupRequired check?
|
|
157
|
+
// EXPERIMENTAL: ALLOW UPDATE OF THE AUTHID AT THIS TIME
|
|
158
|
+
if (commandMetadata.isSetupRequired)
|
|
159
|
+
authId = beforeExecutingOutput?.arguments?.authid || authId;
|
|
160
|
+
|
|
161
|
+
if (commandMetadata.isSetupRequired && !context.arguments[AUTHORIZATION_PROPERTIES_KEYS.SKIP_AUHTORIZATION_CHECK]) {
|
|
162
|
+
// check if reauthz is needed to show proper message before continuing with the execution
|
|
163
|
+
// check after the beforeExecute() has been performed because for instance some unit-test failed and we won't continue the execution
|
|
164
|
+
await this._refreshAuthorizationIfNeeded(authId);
|
|
165
|
+
}
|
|
166
|
+
// AT THIS POINT THE AUTHID IS NOW LOCKED IN SO WE CAN UPDATE THE (TEMP) ENVIRONMENT AGAIN
|
|
167
|
+
process.env[ENV_VARS.SUITECLOUD_AUTHID] = authId;
|
|
168
|
+
|
|
169
|
+
// command creation
|
|
170
|
+
// src/commands/{noun}/{verb}/{verb}{noun}Command.js => specific implementation creation for a given command
|
|
171
|
+
const command = this._getCommand(runInInteractiveMode, projectPath, commandMetadata, authId);
|
|
172
|
+
|
|
173
|
+
// command execution
|
|
174
|
+
// src/commands/Command.js, run(inputParams) => execution flow for all commands
|
|
175
|
+
const actionResult = await command.run(overriddenArguments);
|
|
176
|
+
|
|
177
|
+
if (context.runInInteractiveMode) {
|
|
178
|
+
// generate non-interactive equivalent
|
|
179
|
+
const notInteractiveCommand = ActionResultUtils.extractNotInteractiveCommand(commandName, commandMetadata, actionResult);
|
|
180
|
+
this._log.info(NodeTranslationService.getMessage(CLI.SHOW_NOT_INTERACTIVE_COMMAND_MESSAGE, notInteractiveCommand));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (actionResult.isSuccess() && commandUserExtension.onCompleted) {
|
|
184
|
+
// run onCompleted(output) from suitecloud.config.js
|
|
185
|
+
this._dumpDebugFile(debugFilePath, 'onCompleted', actionResult, runInInteractiveMode);
|
|
186
|
+
commandUserExtension.onCompleted(actionResult);
|
|
187
|
+
} else if (!actionResult.isSuccess() && commandUserExtension.onError) {
|
|
188
|
+
// run onError(error) from suitecloud.config.js
|
|
189
|
+
const errorData = ActionResultUtils.getErrorMessagesString(actionResult);
|
|
190
|
+
this._dumpDebugFile(debugFilePath, 'onError', errorData, runInInteractiveMode);
|
|
191
|
+
commandUserExtension.onError(errorData);
|
|
192
|
+
}
|
|
193
|
+
return actionResult;
|
|
194
|
+
|
|
195
|
+
} catch (error) {
|
|
196
|
+
let errorMessage = this._logGenericError(error);
|
|
197
|
+
if (commandUserExtension && commandUserExtension.onError) {
|
|
198
|
+
// run onError(error) from suitecloud.config.js
|
|
199
|
+
this._dumpDebugFile(debugFilePath, 'onError', error, context.runInInteractiveMode);
|
|
200
|
+
commandUserExtension.onError(error);
|
|
201
|
+
}
|
|
202
|
+
return ActionResult.Builder.withErrors(Array.isArray(errorMessage) ? errorMessage : [errorMessage]).build();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async _refreshAuthorizationIfNeeded(defaultAuthId) {
|
|
207
|
+
const inspectAuthzOperationResult = await checkIfReauthorizationIsNeeded(defaultAuthId, this._sdkPath, this._executionEnvironmentContext);
|
|
208
|
+
|
|
209
|
+
if (!inspectAuthzOperationResult.isSuccess()) {
|
|
210
|
+
throw inspectAuthzOperationResult.errorMessages;
|
|
211
|
+
}
|
|
212
|
+
const inspectAuthzData = inspectAuthzOperationResult.data;
|
|
213
|
+
if (inspectAuthzData[AUTHORIZATION_PROPERTIES_KEYS.NEEDS_REAUTHORIZATION]) {
|
|
214
|
+
await this._log.info(NodeTranslationService.getMessage(COMMAND_REFRESH_AUTHORIZATION.MESSAGES.CREDENTIALS_NEED_TO_BE_REFRESHED, defaultAuthId));
|
|
215
|
+
const refreshAuthzOperationResult = await refreshAuthorization(defaultAuthId, this._sdkPath, this._executionEnvironmentContext);
|
|
216
|
+
|
|
217
|
+
if (!refreshAuthzOperationResult.isSuccess()) {
|
|
218
|
+
throw refreshAuthzOperationResult.errorMessages;
|
|
219
|
+
}
|
|
220
|
+
await this._log.info(NodeTranslationService.getMessage(COMMAND_REFRESH_AUTHORIZATION.MESSAGES.AUTHORIZATION_REFRESH_COMPLETED));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
_logGenericError(error) {
|
|
225
|
+
let errorMessage = unwrapExceptionMessage(error);
|
|
226
|
+
this._log.error(errorMessage);
|
|
227
|
+
const informativeMessage = unwrapInformationMessage(error);
|
|
228
|
+
|
|
229
|
+
if (informativeMessage) {
|
|
230
|
+
this._log.info(`${lineBreak}${informativeMessage}`);
|
|
231
|
+
errorMessage += lineBreak + informativeMessage;
|
|
232
|
+
}
|
|
233
|
+
return errorMessage;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
_checkCanExecuteCommand({ commandMetadata, defaultAuthId, runInInteractiveMode }) {
|
|
237
|
+
if (commandMetadata.isSetupRequired && !defaultAuthId) {
|
|
238
|
+
throw NodeTranslationService.getMessage(ERRORS.SETUP_REQUIRED);
|
|
239
|
+
}
|
|
240
|
+
if (runInInteractiveMode && !commandMetadata.supportsInteractiveMode) {
|
|
241
|
+
throw NodeTranslationService.getMessage(ERRORS.COMMAND_DOES_NOT_SUPPORT_INTERACTIVE_MODE, commandMetadata.name);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
_extractOptionValuesFromArguments(options, args) {
|
|
246
|
+
const optionValues = {};
|
|
247
|
+
for (const optionId in options) {
|
|
248
|
+
if (options.hasOwnProperty(optionId) && args.hasOwnProperty(optionId)) {
|
|
249
|
+
optionValues[optionId] = args[optionId];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return optionValues;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
*
|
|
258
|
+
* @param runInInteractiveMode
|
|
259
|
+
* @param projectFolder
|
|
260
|
+
* @param commandMetadata
|
|
261
|
+
* @param {string} authId
|
|
262
|
+
* @returns {import('../commands/Command')}
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
_getCommand(runInInteractiveMode, projectFolder, commandMetadata, authId) {
|
|
266
|
+
const commandPath = commandMetadata.generator;
|
|
267
|
+
const commandGenerator = require(commandPath);
|
|
268
|
+
if (!commandGenerator) {
|
|
269
|
+
throw `Path ${commandPath} doesn't contain any command`;
|
|
270
|
+
}
|
|
271
|
+
return commandGenerator.create({
|
|
272
|
+
authId: authId,
|
|
273
|
+
commandMetadata: commandMetadata,
|
|
274
|
+
projectFolder: projectFolder,
|
|
275
|
+
executionPath: this._executionPath,
|
|
276
|
+
runInInteractiveMode: runInInteractiveMode,
|
|
277
|
+
log: this._log,
|
|
278
|
+
sdkPath: this._sdkPath,
|
|
279
|
+
executionEnvironmentContext: this._executionEnvironmentContext,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Assign default context params IF they apply
|
|
285
|
+
*/
|
|
286
|
+
_applyDefaultContextParams(args, any, meta) {
|
|
287
|
+
return Object.keys(any)
|
|
288
|
+
.filter((k1) => Object.keys(meta).includes(k1))
|
|
289
|
+
.reduce((args, filteredKey) => {
|
|
290
|
+
return {
|
|
291
|
+
...args,
|
|
292
|
+
[filteredKey]: any[filteredKey],
|
|
293
|
+
};
|
|
294
|
+
}, args);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
_getDebugFilePath(debugDir, commandName) {
|
|
298
|
+
if (!debugDir) return null;
|
|
299
|
+
const sanitizedCommandName = commandName.replace(/:/g, '-');
|
|
300
|
+
const datetime = new Date().toISOString().replace(/[:.]/g, '-');
|
|
301
|
+
const filename = `${sanitizedCommandName}.${datetime}.json`;
|
|
302
|
+
return path.join(debugDir, filename);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
* @param debugFilePath
|
|
308
|
+
* @param hookName
|
|
309
|
+
* @param {'FIRST'|'LAST'|*} data
|
|
310
|
+
* @param {boolean} runInInteractiveMode
|
|
311
|
+
* @private
|
|
312
|
+
*/
|
|
313
|
+
_dumpDebugFile(debugFilePath, hookName, data, runInInteractiveMode = false) {
|
|
314
|
+
if (!debugFilePath || !data ) return;
|
|
315
|
+
if (data === 'FIRST') {
|
|
316
|
+
fs.writeFileSync(debugFilePath, '[]');
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const envVars = {};
|
|
321
|
+
Object.keys(process.env)
|
|
322
|
+
.filter(key => key.startsWith('SUITECLOUD_'))
|
|
323
|
+
.forEach(key => { envVars[key] = process.env[key]; });
|
|
324
|
+
const entry = {
|
|
325
|
+
hook: hookName,
|
|
326
|
+
timestamp: new Date().toISOString(),
|
|
327
|
+
env: envVars,
|
|
328
|
+
data: data
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// Print to console in interactive mode
|
|
332
|
+
if (runInInteractiveMode) {
|
|
333
|
+
this._log.info(`\n--- DEBUG [${hookName}] ---`);
|
|
334
|
+
this._log.info(JSON.stringify(entry, null, 2));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let entries = [];
|
|
338
|
+
try {
|
|
339
|
+
const contents = fs.readFileSync(debugFilePath, 'utf8');
|
|
340
|
+
entries = JSON.parse(contents);
|
|
341
|
+
} catch (e) {
|
|
342
|
+
// If file doesn't exist or can't be parsed, start with empty array
|
|
343
|
+
}
|
|
344
|
+
entries.push(entry);
|
|
345
|
+
fs.writeFileSync(debugFilePath, JSON.stringify(entries, null, 2));
|
|
346
|
+
}
|
|
347
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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 NodeTranslationService = require('../services/NodeTranslationService');
|
|
8
|
+
const TRANSLATION_KEYS = require('../services/TranslationKeys');
|
|
9
|
+
const assert = require('assert');
|
|
10
|
+
|
|
11
|
+
module.exports = class CommandAuthentication {
|
|
12
|
+
|
|
13
|
+
};
|