@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,85 @@
|
|
|
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 assert = require('assert');
|
|
7
|
+
const { ActionResult, ActionResultBuilder, STATUS } = require('./ActionResult');
|
|
8
|
+
|
|
9
|
+
class AuthenticateActionResult extends ActionResult {
|
|
10
|
+
constructor(parameters) {
|
|
11
|
+
super(parameters);
|
|
12
|
+
this._mode = parameters.mode;
|
|
13
|
+
this._authId = parameters.authId;
|
|
14
|
+
this._accountInfo = parameters.accountInfo;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
validateParameters(parameters) {
|
|
18
|
+
assert(parameters);
|
|
19
|
+
assert(parameters.status, 'status is required when creating an ActionResult object.');
|
|
20
|
+
if (parameters.status === STATUS.SUCCESS) {
|
|
21
|
+
assert(parameters.mode, 'mode is required when ActionResult is a success.');
|
|
22
|
+
assert(parameters.authId, 'authId is required when ActionResult is a success.');
|
|
23
|
+
assert(parameters.accountInfo, 'accountInfo is required when ActionResult is a success.');
|
|
24
|
+
} else {
|
|
25
|
+
assert(parameters.errorMessages, 'errorMessages is required when ActionResult is an error.');
|
|
26
|
+
assert(Array.isArray(parameters.errorMessages), 'errorMessages argument must be an array');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get mode() {
|
|
31
|
+
return this._mode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get authId() {
|
|
35
|
+
return this._authId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get accountInfo() {
|
|
39
|
+
return this._accountInfo;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static get Builder() {
|
|
43
|
+
return new AuthenticateActionResultBuilder();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class AuthenticateActionResultBuilder extends ActionResultBuilder {
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
success() {
|
|
53
|
+
this.status = STATUS.SUCCESS;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
withMode(mode) {
|
|
58
|
+
this.mode = mode;
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
withAuthId(authId) {
|
|
63
|
+
this.authId = authId;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
withAccountInfo(accountInfo) {
|
|
68
|
+
this.accountInfo = accountInfo;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
build() {
|
|
73
|
+
return new AuthenticateActionResult({
|
|
74
|
+
status: this.status,
|
|
75
|
+
...(this.errorMessages && { errorMessages: this.errorMessages }),
|
|
76
|
+
...(this.mode && { mode: this.mode }),
|
|
77
|
+
...(this.authId && { authId: this.authId }),
|
|
78
|
+
...(this.accountInfo && { accountInfo: this.accountInfo }),
|
|
79
|
+
...(this.projectFolder && { projectFolder: this.projectFolder }),
|
|
80
|
+
...(this.commandParameters && { commandParameters: this.commandParameters }),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = AuthenticateActionResult;
|
|
@@ -0,0 +1,100 @@
|
|
|
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 assert = require('assert');
|
|
7
|
+
const { ActionResult, ActionResultBuilder } = require('./ActionResult');
|
|
8
|
+
|
|
9
|
+
class CreateProjectActionResult extends ActionResult {
|
|
10
|
+
constructor(parameters) {
|
|
11
|
+
super(parameters);
|
|
12
|
+
this._projectType = parameters.projectType;
|
|
13
|
+
this._projectName = parameters.projectName;
|
|
14
|
+
this._projectDirectory = parameters.projectDirectory;
|
|
15
|
+
this._includeUnitTesting = parameters.includeUnitTesting;
|
|
16
|
+
this._npmPackageInitialized = parameters.npmPackageInitialized;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
validateParameters(parameters) {
|
|
20
|
+
super.validateParameters(parameters);
|
|
21
|
+
if (this.isSuccess()) {
|
|
22
|
+
assert(parameters.projectDirectory, 'projectDirectory is required when ActionResult is a success.');
|
|
23
|
+
assert(parameters.projectType, 'projectType is required when ActionResult is a success.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get projectType() {
|
|
28
|
+
return this._projectType;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get projectName() {
|
|
32
|
+
return this._projectName;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get projectDirectory() {
|
|
36
|
+
return this._projectDirectory;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get includeUnitTesting() {
|
|
40
|
+
return this._includeUnitTesting;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get npmPackageInitialized() {
|
|
44
|
+
return this._npmPackageInitialized;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static get Builder() {
|
|
48
|
+
return new CreateProjectActionResultBuilder();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class CreateProjectActionResultBuilder extends ActionResultBuilder {
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
withProjectType(projectType) {
|
|
58
|
+
this.projectType = projectType;
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
withProjectName(projectName) {
|
|
63
|
+
this.projectName = projectName;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
withProjectDirectory(projectDirectory) {
|
|
68
|
+
this.projectDirectory = projectDirectory;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
withUnitTesting(includeUnitTesting) {
|
|
73
|
+
this.includeUnitTesting = includeUnitTesting;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
withNpmPackageInitialized(npmPackageInitialized) {
|
|
78
|
+
this.npmPackageInitialized = npmPackageInitialized;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
build() {
|
|
83
|
+
return new CreateProjectActionResult({
|
|
84
|
+
status: this.status,
|
|
85
|
+
...(this.data && { data: this.data }),
|
|
86
|
+
...(this.resultMessage && { resultMessage: this.resultMessage }),
|
|
87
|
+
...(this.errorMessages && { errorMessages: this.errorMessages }),
|
|
88
|
+
...(this.projectType && { projectType: this.projectType }),
|
|
89
|
+
...(this.projectName && { projectName: this.projectName }),
|
|
90
|
+
...(this.projectDirectory && { projectDirectory: this.projectDirectory }),
|
|
91
|
+
...(this.includeUnitTesting && { includeUnitTesting: this.includeUnitTesting }),
|
|
92
|
+
...(this.npmPackageInitialized && { npmPackageInitialized: this.npmPackageInitialized }),
|
|
93
|
+
...(this.projectFolder && { projectFolder: this.projectFolder }),
|
|
94
|
+
...(this.commandParameters && { commandParameters: this.commandParameters }),
|
|
95
|
+
...(this.commandFlags && { commandFlags: this.commandFlags }),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = CreateProjectActionResult;
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { ActionResult, ActionResultBuilder } = require('./ActionResult');
|
|
7
|
+
|
|
8
|
+
class DeployActionResult extends ActionResult {
|
|
9
|
+
constructor(parameters) {
|
|
10
|
+
super(parameters);
|
|
11
|
+
this._isServerValidation = !!parameters.isServerValidation;
|
|
12
|
+
this._appliedInstallationPreferences = !!parameters.appliedInstallationPreferences;
|
|
13
|
+
this._projectType = parameters.projectType;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get isServerValidation() {
|
|
17
|
+
return this._isServerValidation;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get appliedInstallationPreferences() {
|
|
21
|
+
return this._appliedInstallationPreferences;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get projectType() {
|
|
25
|
+
return this._projectType;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static get Builder() {
|
|
29
|
+
return new DeployActionResultBuilder();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class DeployActionResultBuilder extends ActionResultBuilder {
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
withServerValidation(isServerValidation) {
|
|
39
|
+
this.isServerValidation = isServerValidation;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
withAppliedInstallationPreferences(appliedInstallationPreferences) {
|
|
44
|
+
this.appliedInstallationPreferences = appliedInstallationPreferences;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
withProjectType(projectType) {
|
|
49
|
+
this.projectType = projectType;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
build() {
|
|
54
|
+
return new DeployActionResult({
|
|
55
|
+
status: this.status,
|
|
56
|
+
...(this.data && { data: this.data }),
|
|
57
|
+
...(this.resultMessage && { resultMessage: this.resultMessage }),
|
|
58
|
+
...(this.errorMessages && { errorMessages: this.errorMessages }),
|
|
59
|
+
...(this.isServerValidation && { isServerValidation: this.isServerValidation }),
|
|
60
|
+
...(this.appliedInstallationPreferences && { appliedInstallationPreferences: this.appliedInstallationPreferences }),
|
|
61
|
+
...(this.projectType && { projectType: this.projectType }),
|
|
62
|
+
...(this.projectFolder && { projectFolder: this.projectFolder }),
|
|
63
|
+
...(this.commandParameters && { commandParameters: this.commandParameters }),
|
|
64
|
+
...(this.commandFlags && { commandFlags: this.commandFlags }),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = DeployActionResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
const { ActionResult,
|
|
3
|
+
ActionResultBuilder,
|
|
4
|
+
STATUS
|
|
5
|
+
} = require('./ActionResult');
|
|
6
|
+
|
|
7
|
+
class HelloActionResult extends ActionResult {
|
|
8
|
+
constructor(parameters) {
|
|
9
|
+
super(parameters);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports.HelloActionResult = HelloActionResult;
|
|
@@ -0,0 +1,70 @@
|
|
|
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 assert = require('assert');
|
|
7
|
+
const { ActionResult, ActionResultBuilder, STATUS } = require('./ActionResult');
|
|
8
|
+
|
|
9
|
+
const MANAGE_ACTION = {
|
|
10
|
+
LIST: 'list',
|
|
11
|
+
EXIT: 'exit',
|
|
12
|
+
INFO: 'info',
|
|
13
|
+
RENAME: 'rename',
|
|
14
|
+
REMOVE: 'remove',
|
|
15
|
+
REVOKE: 'revoke',
|
|
16
|
+
UNKNOWN: 'unknown',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
class ManageAccountActionResult extends ActionResult {
|
|
20
|
+
constructor(parameters) {
|
|
21
|
+
super(parameters);
|
|
22
|
+
this._actionExecuted = parameters.actionExecuted;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
validateParameters(parameters) {
|
|
26
|
+
assert(parameters);
|
|
27
|
+
assert(parameters.status, 'status is required when creating an ActionResult object.');
|
|
28
|
+
if (parameters.status === STATUS.SUCCESS) {
|
|
29
|
+
assert(parameters.actionExecuted);
|
|
30
|
+
}
|
|
31
|
+
if (parameters.status === STATUS.ERROR) {
|
|
32
|
+
assert(parameters.errorMessages, 'errorMessages is required when ActionResult is an error.');
|
|
33
|
+
assert(Array.isArray(parameters.errorMessages), 'errorMessages argument must be an array');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get actionExecuted() {
|
|
38
|
+
return this._actionExecuted;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get Builder() {
|
|
42
|
+
return new ManageAccountActionResultBuilder();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class ManageAccountActionResultBuilder extends ActionResultBuilder {
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
withExecutedAction(actionExecuted) {
|
|
52
|
+
this.actionExecuted = actionExecuted;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
build() {
|
|
57
|
+
return new ManageAccountActionResult({
|
|
58
|
+
status: this.status,
|
|
59
|
+
...(this.data && { data: this.data }),
|
|
60
|
+
...(this.resultMessage && { resultMessage: this.resultMessage }),
|
|
61
|
+
...(this.errorMessages && { errorMessages: this.errorMessages }),
|
|
62
|
+
...(this.actionExecuted && { actionExecuted: this.actionExecuted }),
|
|
63
|
+
...(this.commandParameters && { commandParameters: this.commandParameters }),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports.ManageAccountActionResult = ManageAccountActionResult;
|
|
69
|
+
module.exports.ManageAccountActionResultBuilder = ManageAccountActionResultBuilder;
|
|
70
|
+
module.exports.MANAGE_ACTION = MANAGE_ACTION;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 DEFAULT_CLI_SETTINGS = {
|
|
8
|
+
isJavaVersionValid: false,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = class CLISettings {
|
|
12
|
+
// should not be directly used, use static fromJson(json) method
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this._isJavaVersionValid = options.isJavaVersionValid ? options.isJavaVersionValid : DEFAULT_CLI_SETTINGS.isJavaVersionValid;
|
|
15
|
+
// we only accept an object as a value for vmOptions
|
|
16
|
+
if (options.hasOwnProperty("vmOptions")) {
|
|
17
|
+
if (options.vmOptions !== null && typeof options.vmOptions === 'object') {
|
|
18
|
+
this._vmOptions = options.vmOptions;
|
|
19
|
+
} else {
|
|
20
|
+
this._vmOptions = {};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get isJavaVersionValid() {
|
|
26
|
+
return this._isJavaVersionValid;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get vmOptions() {
|
|
30
|
+
return this._vmOptions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
toJSON() {
|
|
34
|
+
return {
|
|
35
|
+
isJavaVersionValid: this._isJavaVersionValid,
|
|
36
|
+
...(this._vmOptions && { vmOptions: this._vmOptions }),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static fromJson(json) {
|
|
41
|
+
return new CLISettings({
|
|
42
|
+
isJavaVersionValid: json.isJavaVersionValid,
|
|
43
|
+
...(json.hasOwnProperty("vmOptions") && { vmOptions: json.vmOptions })
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
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 FileSystemService = require('../FileSystemService');
|
|
8
|
+
const FileUtils = require('../../utils/FileUtils');
|
|
9
|
+
const CLISettings = require('./CLISettings');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const NodeTranslationService = require('../NodeTranslationService');
|
|
12
|
+
const {
|
|
13
|
+
ERRORS: { SDK_SETTINGS_FILE },
|
|
14
|
+
} = require('../TranslationKeys');
|
|
15
|
+
|
|
16
|
+
const HOME_PATH = require('os').homedir();
|
|
17
|
+
const { FILES, FOLDERS } = require('../../ApplicationConstants');
|
|
18
|
+
|
|
19
|
+
const SDK_SETTINGS_FILEPATH = path.join(HOME_PATH, FOLDERS.SUITECLOUD_SDK, FILES.SDK_SETTINGS);
|
|
20
|
+
|
|
21
|
+
const CLI_SETTINGS_PROPERTIES_KEYS = ['isJavaVersionValid'];
|
|
22
|
+
const DEFAULT_CLI_SETTINGS = CLISettings.fromJson({
|
|
23
|
+
isJavaVersionValid: false,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const VM_OPTION_VALIDATION_ERROR_NAME = 'VmOptionValidationError';
|
|
27
|
+
const SYNTAX_ERROR_NAME = 'SyntaxError';
|
|
28
|
+
class VmOptionValidationError extends Error {
|
|
29
|
+
constructor(message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = VM_OPTION_VALIDATION_ERROR_NAME;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let CACHED_CLI_SETTINGS;
|
|
36
|
+
|
|
37
|
+
module.exports = class CLISettingsService {
|
|
38
|
+
constructor() {
|
|
39
|
+
this._fileSystemService = new FileSystemService();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_saveSettings(cliSettings) {
|
|
43
|
+
this._fileSystemService.createFolder(HOME_PATH, FOLDERS.SUITECLOUD_SDK);
|
|
44
|
+
FileUtils.create(SDK_SETTINGS_FILEPATH, cliSettings);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_getSettings() {
|
|
48
|
+
if (CACHED_CLI_SETTINGS) {
|
|
49
|
+
return CACHED_CLI_SETTINGS;
|
|
50
|
+
}
|
|
51
|
+
if (FileUtils.exists(SDK_SETTINGS_FILEPATH)) {
|
|
52
|
+
try {
|
|
53
|
+
const cliSettingsJson = FileUtils.readAsJson(SDK_SETTINGS_FILEPATH);
|
|
54
|
+
CACHED_CLI_SETTINGS = CLISettings.fromJson(cliSettingsJson);
|
|
55
|
+
|
|
56
|
+
// check if the settings file has the expected properties
|
|
57
|
+
if (!this._settingsFileHasExpectedProperties(cliSettingsJson) || this._settingsFileHasVmOptionsNotObjectType(cliSettingsJson)) {
|
|
58
|
+
// regenerate the file with the missing properties default values
|
|
59
|
+
this._saveSettings(CACHED_CLI_SETTINGS);
|
|
60
|
+
}
|
|
61
|
+
this._validateVmOptions(CACHED_CLI_SETTINGS.vmOptions);
|
|
62
|
+
return CACHED_CLI_SETTINGS;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (error && error.constructor && error.constructor.name) {
|
|
65
|
+
if (error.constructor.name === SYNTAX_ERROR_NAME) {
|
|
66
|
+
throw NodeTranslationService.getMessage(SDK_SETTINGS_FILE.WRONG_JSON_SYNTAX, SDK_SETTINGS_FILEPATH, error);
|
|
67
|
+
}
|
|
68
|
+
if (error.constructor.name === VM_OPTION_VALIDATION_ERROR_NAME) {
|
|
69
|
+
throw NodeTranslationService.getMessage(SDK_SETTINGS_FILE.INVALID_CUSTOM_VM_OPTION, SDK_SETTINGS_FILEPATH, error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw NodeTranslationService.getMessage(
|
|
73
|
+
SDK_SETTINGS_FILE.GENERIC_PROBLEM,
|
|
74
|
+
SDK_SETTINGS_FILEPATH,
|
|
75
|
+
error
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
CACHED_CLI_SETTINGS = DEFAULT_CLI_SETTINGS;
|
|
80
|
+
return DEFAULT_CLI_SETTINGS;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
isJavaVersionValid() {
|
|
84
|
+
return this._getSettings().isJavaVersionValid === true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setJavaVersionValid(value) {
|
|
88
|
+
const newSettings = this._getSettings().toJSON();
|
|
89
|
+
if (newSettings.isJavaVersionValid === value) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
newSettings.isJavaVersionValid = value;
|
|
93
|
+
CACHED_CLI_SETTINGS = CLISettings.fromJson(newSettings);
|
|
94
|
+
this._saveSettings(CACHED_CLI_SETTINGS);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getCustomVmOptions() {
|
|
98
|
+
return this._getSettings().vmOptions;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_settingsFileHasExpectedProperties(settingsFromFile) {
|
|
102
|
+
return CLI_SETTINGS_PROPERTIES_KEYS.every((key) => settingsFromFile.hasOwnProperty(key));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_settingsFileHasVmOptionsNotObjectType(settingsFromFile) {
|
|
106
|
+
if (!settingsFromFile.hasOwnProperty('vmOptions')) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (settingsFromFile.vmOptions !== null && typeof settingsFromFile.vmOptions === 'object') {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
_validateVmOptions(vmOptions) {
|
|
118
|
+
if (vmOptions === null || vmOptions === undefined) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (const [key, value] of Object.entries(vmOptions)) {
|
|
123
|
+
// All vmOptions should be named '-Dx' and have at least another character
|
|
124
|
+
if (!key.startsWith('-D') || key.lenght < 3) {
|
|
125
|
+
throw new VmOptionValidationError(`vmOptions keys must start with '-D', and contain at least three characters.`);
|
|
126
|
+
}
|
|
127
|
+
if (typeof value !== 'string') {
|
|
128
|
+
throw new VmOptionValidationError(`vmOptions keys only support string values.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
** Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
|
|
4
|
+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const CLI = require('./CLI');
|
|
9
|
+
const CommandsMetadataService = require('./core/CommandsMetadataService');
|
|
10
|
+
const CommandActionExecutor = require('./core/CommandActionExecutor');
|
|
11
|
+
const CommandRegistrationService = require('./core/CommandRegistrationService');
|
|
12
|
+
const CommandOptionsValidator = require('./core/CommandOptionsValidator');
|
|
13
|
+
const CLIConfigurationService = require('./core/extensibility/CLIConfigurationService');
|
|
14
|
+
const sdkPath = require('./core/sdksetup/SdkProperties').getSdkPath();
|
|
15
|
+
const NodeConsoleLogger = require('./loggers/NodeConsoleLogger');
|
|
16
|
+
|
|
17
|
+
const executionPath = process.cwd();
|
|
18
|
+
const commandsMetadataServiceSingleton = new CommandsMetadataService();
|
|
19
|
+
|
|
20
|
+
const cliInstance = new CLI({
|
|
21
|
+
commandsMetadataService: commandsMetadataServiceSingleton,
|
|
22
|
+
commandRegistrationService: new CommandRegistrationService(),
|
|
23
|
+
commandActionExecutor: new CommandActionExecutor({
|
|
24
|
+
executionPath,
|
|
25
|
+
commandOptionsValidator: new CommandOptionsValidator(),
|
|
26
|
+
cliConfigurationService: new CLIConfigurationService(),
|
|
27
|
+
commandsMetadataService: commandsMetadataServiceSingleton,
|
|
28
|
+
log: NodeConsoleLogger,
|
|
29
|
+
sdkPath: sdkPath
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
cliInstance.start(process);
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
module.exports = {
|
|
8
|
+
SCRIPTS: {
|
|
9
|
+
blankscript: require.resolve('./scripts/blankscript.js'),
|
|
10
|
+
},
|
|
11
|
+
OBJECTS: {
|
|
12
|
+
commerceextension: require.resolve('./objects/commerceextension.xml'),
|
|
13
|
+
},
|
|
14
|
+
PROJECTCONFIGS: {
|
|
15
|
+
cliconfig: require.resolve('./projectconfigs/suitecloud.config.js'),
|
|
16
|
+
gitignore: require.resolve('./projectconfigs/default_gitignore.template')
|
|
17
|
+
},
|
|
18
|
+
UNIT_TEST: {
|
|
19
|
+
cliconfig: require.resolve('./unittest/suitecloud.config.js.template'),
|
|
20
|
+
jestconfig: require.resolve('./unittest/jest.config.js.template'),
|
|
21
|
+
packagejson: require.resolve('./unittest/package.json.template'),
|
|
22
|
+
sampletest: require.resolve('./unittest/sample-test.js.template'),
|
|
23
|
+
jsconfig: require.resolve('./unittest/jsconfig.json.template')
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# IDEs and editors
|
|
2
|
+
.idea
|
|
3
|
+
*.iml
|
|
4
|
+
*.iws
|
|
5
|
+
.project
|
|
6
|
+
.classpath
|
|
7
|
+
*.launch
|
|
8
|
+
.settings
|
|
9
|
+
*.sublime-workspace
|
|
10
|
+
.vscode
|
|
11
|
+
|
|
12
|
+
# Dependency directories
|
|
13
|
+
node_modules
|
|
14
|
+
|
|
15
|
+
# TypeScript cache
|
|
16
|
+
*.tsbuildinfo
|
|
17
|
+
|
|
18
|
+
# Logs
|
|
19
|
+
logs
|
|
20
|
+
*.log
|
|
21
|
+
npm-debug.log*
|
|
22
|
+
|
|
23
|
+
# Packaged SuiteCloud projects
|
|
24
|
+
build
|
|
25
|
+
|
|
26
|
+
# misc
|
|
27
|
+
.sass-cache
|
|
28
|
+
|
|
29
|
+
# Optional npm cache directory
|
|
30
|
+
.npm
|
|
31
|
+
|
|
32
|
+
# System Files
|
|
33
|
+
.DS_Store
|
|
34
|
+
Thumbs.db
|
|
35
|
+
|
|
36
|
+
# Output of 'npm pack'
|
|
37
|
+
*.tgz
|
|
38
|
+
|
|
39
|
+
# Project config
|
|
40
|
+
project.json
|
|
41
|
+
|
|
42
|
+
# temp files
|
|
43
|
+
sdftemp*
|
|
44
|
+
|
|
45
|
+
# default deploy and manifest file
|
|
46
|
+
deploy.xml
|
|
47
|
+
manifest.xml
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const SuiteCloudJestConfiguration = require("@oracle/suitecloud-unit-testing/jest-configuration/SuiteCloudJestConfiguration");
|
|
2
|
+
const cliConfig = require("./suitecloud.config");
|
|
3
|
+
|
|
4
|
+
module.exports = SuiteCloudJestConfiguration.build({
|
|
5
|
+
projectFolder: cliConfig.defaultProjectFolder,
|
|
6
|
+
projectType: {{projectType}},
|
|
7
|
+
});
|