@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,58 @@
|
|
|
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 { authenticateCi, selectAuthenticationCI } = require('../../../utils/AuthenticationUtils');
|
|
9
|
+
const { DOMAIN: { PRODUCTION: { GENERIC_NETSUITE_DOMAIN } } } = require('../../../ApplicationConstants');
|
|
10
|
+
const { ACCOUNT_SETUP_CI: { COMMAND: { OPTIONS } } } = require('./AccountSetupCiConstants');
|
|
11
|
+
const ProjectInfoService = require('../../../services/ProjectInfoService');
|
|
12
|
+
const { validateMachineToMachineAuthIsAllowed } = require('../../../services/ExecutionContextService');
|
|
13
|
+
const AccountSetupCiValidation = require('./AccountSetupCiValidation');
|
|
14
|
+
|
|
15
|
+
module.exports = class AccountSetupCiAction extends BaseAction {
|
|
16
|
+
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(options);
|
|
19
|
+
this._projectInfoService = new ProjectInfoService(this._projectFolder);
|
|
20
|
+
this._validator = new AccountSetupCiValidation(this._commandMetadata, this._runInInteractiveMode);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
preExecute(params) {
|
|
24
|
+
this._projectInfoService.checkWorkingDirectoryContainsValidProject(this._commandMetadata.name);
|
|
25
|
+
|
|
26
|
+
if (params[OPTIONS.ACCOUNT]) {
|
|
27
|
+
params[OPTIONS.ACCOUNT] = params[OPTIONS.ACCOUNT].toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return params;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async execute(params) {
|
|
34
|
+
if (params[OPTIONS.DOMAIN] === GENERIC_NETSUITE_DOMAIN) {
|
|
35
|
+
delete params[OPTIONS.DOMAIN];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
validateMachineToMachineAuthIsAllowed();
|
|
39
|
+
|
|
40
|
+
const isSetupMode = this._isSetupMode(params);
|
|
41
|
+
this._validator.validateActionParametersByMode(params, isSetupMode);
|
|
42
|
+
this._validator.validateAuthIDFormat(this._getAuthId(params), isSetupMode);
|
|
43
|
+
|
|
44
|
+
if (isSetupMode) {
|
|
45
|
+
return await authenticateCi(params, this._sdkPath, this._executionPath, this._executionEnvironmentContext);
|
|
46
|
+
} else {
|
|
47
|
+
return await selectAuthenticationCI(this._getAuthId(params), this._sdkPath, this._executionPath);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_isSetupMode(params) {
|
|
52
|
+
return (!params[OPTIONS.SELECT]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_getAuthId(params) {
|
|
56
|
+
return this._isSetupMode(params) ? params[OPTIONS.AUTHID] : params[OPTIONS.SELECT];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -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 AccountSetupCiAction = require('./AccountSetupCiAction');
|
|
9
|
+
const AccountSetupCiOutputHandler = require('./AccountSetupCiOutputHandler');
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
create(options) {
|
|
13
|
+
return Command.Builder
|
|
14
|
+
.withOptions(options)
|
|
15
|
+
.withAction(AccountSetupCiAction)
|
|
16
|
+
.withOutput(AccountSetupCiOutputHandler)
|
|
17
|
+
.neverInteractive()
|
|
18
|
+
.build();
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** Copyright (c) 2025 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
|
+
module.exports = {
|
|
7
|
+
ACCOUNT_SETUP_CI: {
|
|
8
|
+
COMMAND: {
|
|
9
|
+
OPTIONS: {
|
|
10
|
+
ACCOUNT: 'account',
|
|
11
|
+
AUTHID: 'authid',
|
|
12
|
+
CERTIFCATEID: 'certificateid',
|
|
13
|
+
PRIVATEKEYPATH: 'privatekeypath',
|
|
14
|
+
DOMAIN: 'domain',
|
|
15
|
+
SELECT: 'select'
|
|
16
|
+
},
|
|
17
|
+
SDK_COMMAND: 'authenticateci',
|
|
18
|
+
MANDATORY_PARAMS_FOR_SETUP_MODE: ['account', 'authid', 'certificateid', 'privatekeypath']
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 {
|
|
9
|
+
COMMAND_SETUPACCOUNTCI: { OUTPUT: { SELECT_DEFAULT_ACCOUNT, NEW_OAUTH } },
|
|
10
|
+
UTILS,
|
|
11
|
+
} = require('../../../services/TranslationKeys');
|
|
12
|
+
|
|
13
|
+
const { COMMANDS: { AUTHENTICATE: { MODES: { REUSE } } } } = require('../../../utils/AuthenticationUtils');
|
|
14
|
+
|
|
15
|
+
module.exports = class AccountSetupCiOutputHandler extends BaseOutputHandler {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
parse(actionResult) {
|
|
21
|
+
|
|
22
|
+
if (actionResult.mode === REUSE) {
|
|
23
|
+
//SELECT mode
|
|
24
|
+
this._log.result(NodeTranslationService.getMessage(
|
|
25
|
+
SELECT_DEFAULT_ACCOUNT,
|
|
26
|
+
actionResult.authId,
|
|
27
|
+
));
|
|
28
|
+
} else {
|
|
29
|
+
//SETUP mode
|
|
30
|
+
this._log.result(NodeTranslationService.getMessage(
|
|
31
|
+
NEW_OAUTH,
|
|
32
|
+
actionResult.accountInfo.companyName,
|
|
33
|
+
actionResult.accountInfo.roleName,
|
|
34
|
+
actionResult.authId,
|
|
35
|
+
));
|
|
36
|
+
this._log.result(NodeTranslationService.getMessage(UTILS.AUTHENTICATION.SUCCESS_SETUP));
|
|
37
|
+
}
|
|
38
|
+
return actionResult;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const {
|
|
2
|
+
showValidationResults,
|
|
3
|
+
validateFieldIsNotEmpty,
|
|
4
|
+
validateFieldHasNoSpaces,
|
|
5
|
+
validateAlphanumericHyphenUnderscore,
|
|
6
|
+
validateMaximumLength,
|
|
7
|
+
} = require('../../../validation/InteractiveAnswersValidator');
|
|
8
|
+
const assert = require('assert');
|
|
9
|
+
const { throwValidationException } = require('../../../utils/ExceptionUtils');
|
|
10
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
11
|
+
const TRANSLATION_KEYS = require('../../../services/TranslationKeys');
|
|
12
|
+
const {
|
|
13
|
+
ACCOUNT_SETUP_CI: {
|
|
14
|
+
COMMAND: {
|
|
15
|
+
OPTIONS,
|
|
16
|
+
MANDATORY_PARAMS_FOR_SETUP_MODE,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
} = require('./AccountSetupCiConstants');
|
|
20
|
+
const { COMMAND_SETUPACCOUNTCI: { ERRORS } } = require('../../../services/TranslationKeys');
|
|
21
|
+
|
|
22
|
+
class AccountSetupCiValidation {
|
|
23
|
+
constructor(commandMetadata, runInInteractiveMode) {
|
|
24
|
+
this._commandMetadata = commandMetadata;
|
|
25
|
+
this._runInInteractiveMode = runInInteractiveMode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
validateAuthIDFormat(authId, isSetupMode) {
|
|
29
|
+
const validateResult = showValidationResults(
|
|
30
|
+
authId,
|
|
31
|
+
validateFieldIsNotEmpty,
|
|
32
|
+
validateFieldHasNoSpaces,
|
|
33
|
+
validateAlphanumericHyphenUnderscore,
|
|
34
|
+
validateMaximumLength,
|
|
35
|
+
);
|
|
36
|
+
if (validateResult !== true) {
|
|
37
|
+
throwValidationException(
|
|
38
|
+
[NodeTranslationService.getMessage(TRANSLATION_KEYS.COMMAND_OPTIONS.VALIDATION_SHOW_ERROR_MESSAGE,
|
|
39
|
+
isSetupMode ? OPTIONS.AUTHID : OPTIONS.SELECT, validateResult
|
|
40
|
+
)],
|
|
41
|
+
false,
|
|
42
|
+
this._commandMetadata
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* There are 2 options, select mode --select <authI> and nothing else allowed.
|
|
49
|
+
* and the setup mode --authid <authI> --certificateid <certId>--privatekeypath <privatekeypath> -account <account> -domain <domain>
|
|
50
|
+
* all mandatory except domain which is optional.
|
|
51
|
+
* @param params
|
|
52
|
+
* @param isSetupMode
|
|
53
|
+
*/
|
|
54
|
+
validateActionParametersByMode(params, isSetupMode) {
|
|
55
|
+
assert(this._commandMetadata);
|
|
56
|
+
assert(this._commandMetadata.options);
|
|
57
|
+
const validationErrors = isSetupMode ?
|
|
58
|
+
this._validateActionParametersSetupMode(params) :
|
|
59
|
+
this._validateActionParametersSelectMode(params);
|
|
60
|
+
|
|
61
|
+
if (validationErrors.length > 0) {
|
|
62
|
+
throwValidationException(validationErrors, this._runInInteractiveMode, this._commandMetadata);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Since account:setup:ci in standard setup mode and account:setup:ci --select are handled by the same default
|
|
68
|
+
* parameter validations, all the parameters are configured as not mandatory.
|
|
69
|
+
* The validation of the mandatory parameters for account:setup:ci standard setup mode is done here.
|
|
70
|
+
* This method makes sure all the mandatory params for the standard mode are present
|
|
71
|
+
* @param params input parameters
|
|
72
|
+
* @returns empty list if the validation is correct, otherwise it returns the list of errors with the missing mandatory
|
|
73
|
+
* fields
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
_validateActionParametersSetupMode(params) {
|
|
77
|
+
return MANDATORY_PARAMS_FOR_SETUP_MODE
|
|
78
|
+
.filter(mandatoryOption => !params[mandatoryOption])
|
|
79
|
+
.map(missingParam => NodeTranslationService.getMessage(ERRORS.IS_MANDATORY_SETUP_MODE, missingParam));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Since account:setup:ci in standard setup mode and account:setup:ci --select are handled by the same default
|
|
84
|
+
* parameter validations, all the parameters are configured as not mandatory.
|
|
85
|
+
* The validation of the not allowed parameters for account:setup:ci select mode is done here.
|
|
86
|
+
* This method makes sure none the not allowed params for the setup mode is present
|
|
87
|
+
* @param params input parameters
|
|
88
|
+
* @returns empty list if the validation is correct, otherwise it returns the list of errors with the not allowed
|
|
89
|
+
* fields
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
_validateActionParametersSelectMode(params) {
|
|
93
|
+
return Object.keys(params)
|
|
94
|
+
.filter(paramKey => paramKey !== OPTIONS.SELECT)
|
|
95
|
+
.map(notAllowedParam => NodeTranslationService.getMessage(ERRORS.IS_NOT_ALLOWED_SELECT_MODE, notAllowedParam));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = AccountSetupCiValidation;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { ActionResult } = require('../../services/actionresult/ActionResult');
|
|
8
|
+
const SdkExecutor = require('../../SdkExecutor');
|
|
9
|
+
const { getProjectDefaultAuthId } = require('../../utils/AuthenticationUtils');
|
|
10
|
+
|
|
11
|
+
module.exports = class BaseAction {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this._projectFolder = options.projectFolder;
|
|
14
|
+
// an optional opportunity to override;
|
|
15
|
+
this._authId = options.authId || getProjectDefaultAuthId();
|
|
16
|
+
this._commandMetadata = options.commandMetadata;
|
|
17
|
+
this._executionPath = options.executionPath;
|
|
18
|
+
this._runInInteractiveMode = options.runInInteractiveMode;
|
|
19
|
+
this._log = options.log;
|
|
20
|
+
this._sdkPath = options.sdkPath;
|
|
21
|
+
|
|
22
|
+
this._executionEnvironmentContext = options.executionEnvironmentContext;
|
|
23
|
+
this._sdkExecutor = new SdkExecutor(this._sdkPath, this._executionEnvironmentContext);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async preExecute(params) {
|
|
27
|
+
return params;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async execute(params) {
|
|
31
|
+
return ActionResult.Builder.withErrors(['BaseAction execute should never be called']);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async postExecute(actionResult) {
|
|
35
|
+
return actionResult;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { getProjectDefaultAuthId } = require('../../utils/AuthenticationUtils');
|
|
8
|
+
module.exports = class BaseInputHandler {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this._projectFolder = options.projectFolder;
|
|
11
|
+
this._commandMetadata = options.commandMetadata;
|
|
12
|
+
this._executionPath = options.executionPath;
|
|
13
|
+
this._configPath = options.configPath;
|
|
14
|
+
this._log = options.log;
|
|
15
|
+
this._authId = options.authId || getProjectDefaultAuthId();
|
|
16
|
+
this._runInInteractiveMode = options.runInInteractiveMode;
|
|
17
|
+
this._executionEnvironmentContext = options.executionEnvironmentContext;
|
|
18
|
+
this._sdkPath = options.sdkPath;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getParameters(params) {
|
|
22
|
+
return params;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -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
|
+
|
|
7
|
+
|
|
8
|
+
const { getProjectDefaultAuthId } = require('../../utils/AuthenticationUtils');
|
|
9
|
+
module.exports = class BaseOutputHandler {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this._log = options.log;
|
|
12
|
+
this._projectFolder = options.projectFolder;
|
|
13
|
+
this._authId = options.authId || getProjectDefaultAuthId();
|
|
14
|
+
|
|
15
|
+
this._log.info(`[${options.authId || 'N/A'}]: ${options.projectFolder}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
parse(actionResult) {
|
|
19
|
+
return actionResult;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
parseError(actionResult) {
|
|
23
|
+
if (actionResult.errorMessages && actionResult.errorMessages.length > 0) {
|
|
24
|
+
for (let i =0; i<actionResult.errorMessages.length; i++) {
|
|
25
|
+
this._log.error(actionResult.errorMessages[i]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return actionResult;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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 { HelloActionResult } = require('../../../services/actionresult/HelloActionResult');
|
|
9
|
+
const {ENV_VARS} = require('../../../ApplicationConstants');
|
|
10
|
+
|
|
11
|
+
const COMMAND = {
|
|
12
|
+
OPTIONS: {
|
|
13
|
+
PHRASE: 'phrase'
|
|
14
|
+
},
|
|
15
|
+
SDK_COMMAND: 'null',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports = class HelloAction extends BaseAction {
|
|
19
|
+
|
|
20
|
+
constructor(options) {
|
|
21
|
+
super(options);
|
|
22
|
+
this._options = options;
|
|
23
|
+
// this._projectInfoService = new ProjectInfoService(this._projectFolder);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @An opportunity to:
|
|
28
|
+
* - modify the params. e.g. use a command argument to override the project folder?
|
|
29
|
+
* - check the environment
|
|
30
|
+
* - prompt the user, etc
|
|
31
|
+
* @param params
|
|
32
|
+
* @returns {any}
|
|
33
|
+
*/
|
|
34
|
+
preExecute(params) {
|
|
35
|
+
|
|
36
|
+
if( params.debug) console.log('preExecute', params, this._options);
|
|
37
|
+
return params;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description - do whatever you want in here
|
|
42
|
+
* @param params
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
async execute(params) {
|
|
46
|
+
if(params.debug) {
|
|
47
|
+
console.log('execute', params, this._options);
|
|
48
|
+
Object.values(ENV_VARS).forEach((envKey)=>{
|
|
49
|
+
console.log(envKey,process.env[envKey]);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return new HelloActionResult({
|
|
53
|
+
status: 'SUCCESS',
|
|
54
|
+
data: {},
|
|
55
|
+
commandParameters: params
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
@@ -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 Action = require('./Action');
|
|
9
|
+
const Handler = require('./Handler');
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
create(options) {
|
|
13
|
+
return Command.Builder
|
|
14
|
+
.withOptions(options)
|
|
15
|
+
.withAction(Action)
|
|
16
|
+
.withOutput(Handler)
|
|
17
|
+
.neverInteractive()
|
|
18
|
+
.build();
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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 tranKeys = require('../../../services/TranslationKeys');
|
|
10
|
+
|
|
11
|
+
module.exports = class HelloOutputHandler extends BaseOutputHandler {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
parse(actionResult) {
|
|
17
|
+
const resultMessage = NodeTranslationService.getMessage(
|
|
18
|
+
tranKeys.COMMAND_HELLO.TEST,
|
|
19
|
+
actionResult.commandParameters.phrase
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
this._log.result(resultMessage);
|
|
23
|
+
this._log.result(NodeTranslationService.getMessage(tranKeys.COMMAND_HELLO.TEST2));
|
|
24
|
+
return actionResult;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Experimenting with creating a custom command inside the cli
|
|
2
|
+
|
|
3
|
+
this is a hello world example
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# TODO
|
|
7
|
+
- copying from another command to see what i can do
|
|
8
|
+
|
|
9
|
+
# Discoveries
|
|
10
|
+
Internally "SDK" refers to the java application that will run commands against Netsuite. The node cli is a wrapper to this SDK.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
- A command such as `custom:hello` can be setup in the [SdkCommandsMetadata.json](../../../metadata/SdkCommandsMetadata.json) file.
|
|
14
|
+
- You don't need an entry in [SdkCommandMetadataPath.json](../../../metadata/SdkCommandsMetadataPatch.json)
|
|
15
|
+
- A generator needs to be setup in [CommandGenerators.json](../../../metadata/CommandGenerators.json)
|
|
16
|
+
-
|
|
17
|
+
- If configured with `isSetupRequired` property then the `authId will be injected
|
|
18
|
+
- In `beforeExecuting` hooks only changes to the `options.arguments` are kept. Changes to `projectFolder` are
|
|
19
|
+
|
|
20
|
+
## Command.run
|
|
21
|
+
After you "build" the Command (in your Command.js) the instance object that you have has a method `run` on it. This could be overridden to not call the SDK (i.e. the java application)
|
|
22
|
+
|
|
23
|
+
## SKIP_AUHTORIZATION_CHECK and reauth
|
|
24
|
+
- There is a concept of reauthorization that is provided via (hidden?) properties on the command.
|
|
25
|
+
|
|
26
|
+
## `projectFolder` and `defaultProjectFolder` can override
|
|
27
|
+
`defaultProjectFolder` can be set as a relative path to the location of the suitecloud.config.js file.
|
|
28
|
+
This folder should be the containing directory of the `FileCabinet` directory. But either way it is going to be the expected
|
|
29
|
+
location of the deploy and manifest files. And other paths are going to be relative to that. Such as `~/FileCabinet` and `~/Objects` folders
|
|
30
|
+
|
|
31
|
+
You can override this with `projectFolder` on any command hook.
|
|
32
|
+
|
|
33
|
+
Example use-case:
|
|
34
|
+
You are doing a file:upload
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## current working directory
|
|
38
|
+
|
|
39
|
+
THis is by default uses as the `_executionPath` internally and is `node:path.join` with the projectFolder above in order to location the FileCabinet.
|
|
40
|
+
it is expected that the suitecloud.config.js file reside there as well.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Features Todo
|
|
44
|
+
|
|
45
|
+
## Look for the closest suitecloud.config file instead of requiring it be in the working directory
|
|
46
|
+
|
|
47
|
+
## expand on the config that is accepted for a command
|
|
48
|
+
currently authid is available to `beforeExecuting` hooks BUT any chances you make to it are not respective.
|
|
49
|
+
Instead it is already forced from a read of the project.json file.
|
|
50
|
+
So we could extend the modification of options to include options.authid
|
|
51
|
+
|
|
52
|
+
- `authid` could be modifiedy-orprovided-by `beforeExecuting`
|
|
53
|
+
- e.g. you could provide a prompt
|
|
54
|
+
- `beforeExecuting` could be provided additional object to do things such as provide an interactive experience for the user.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const customCommandHandler = {
|
|
58
|
+
beforeExecuting: (options: any, helpers: {
|
|
59
|
+
promptUser: any; // function,
|
|
60
|
+
displayMesage: any; // function
|
|
61
|
+
})=>{
|
|
62
|
+
return options;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- additionally: be able to know whether setup is required for a command. As this should be determined immediately, you shouldn't be able to change it, but you should be able to know via a property in the options. `options.setupRequired: boolean` ?
|
|
68
|
+
- additionally: know whether the command will fire the SDK. Any custom commands will not fire it.
|
|
69
|
+
- `options.isSDK : boolean`
|
|
70
|
+
- There are some commands where not both are true
|
|
71
|
+
|
|
72
|
+
## Make `beforeExecuting` more powerful
|
|
73
|
+
- carry-over changes to `options.projectFolder` property (see CommandActionExecutor#executeAction)
|
|
74
|
+
- Continue to not allow a change to options.CommandName
|
|
75
|
+
|
|
76
|
+
## Type definitions for the commands and arguments
|
|
77
|
+
|
|
78
|
+
adding some slowly
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { ActionResult, STATUS } = require('../../../services/actionresult/ActionResult');
|
|
9
|
+
|
|
10
|
+
module.exports = class AcsExtraAction extends BaseAction {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param params
|
|
18
|
+
* @returns {Promise<ActionResult>}
|
|
19
|
+
*/
|
|
20
|
+
async execute(params) {
|
|
21
|
+
return new ActionResult({
|
|
22
|
+
status: STATUS.SUCCESS,
|
|
23
|
+
data: {},
|
|
24
|
+
commandParameters: params
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 Action = require('./Action');
|
|
9
|
+
const InputHandler = require('./InputHandler');
|
|
10
|
+
const OutputHandler = require('./OutputHandler')
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
create(options) {
|
|
14
|
+
return Command.Builder
|
|
15
|
+
.withOptions(options)
|
|
16
|
+
.withAction(Action)
|
|
17
|
+
.withInput(InputHandler)
|
|
18
|
+
.withOutput(OutputHandler)
|
|
19
|
+
.neverInteractive()
|
|
20
|
+
.build();
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
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 BaseInputHandler = require('../../base/BaseInputHandler');
|
|
7
|
+
|
|
8
|
+
module.exports = BaseInputHandler;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
|
|
8
|
+
module.exports = BaseOutputHandler
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
For commands that will be completely reliant on hooks.
|
|
2
|
+
|
|
3
|
+
Good for temporary commands.
|
|
4
|
+
|
|
5
|
+
there are no additional command parameters supported. You will need to provide this support in your own way as any attempt to use command line arguments wil result in an error.
|
|
6
|
+
|
|
7
|
+
Some options for you are:
|
|
8
|
+
1. Use different configuration files and point to them with the `--config` option
|
|
9
|
+
2. Build your own interaction
|
|
10
|
+
3. Make a feature request to the author
|
|
11
|
+
|
|
12
|
+
# Usage: Example
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
// in your sdf.config.js file you could have
|
|
16
|
+
module.exports = {
|
|
17
|
+
defaultProjectFolder: 'src',
|
|
18
|
+
commands: {
|
|
19
|
+
'custom:hook': {
|
|
20
|
+
beforeExecuting(options) {
|
|
21
|
+
// do stuff
|
|
22
|
+
if (options.arguments.option1 === 'words') console.log(options.arguments.mulit1.join(' '));
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
sdf custom:hook --option1 words --multi1 hi there guy --flag1
|
|
32
|
+
```
|