@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,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 ListFilesAction = require('./ListFilesAction');
|
|
9
|
+
const ListFilesInputHandler = require('./ListFilesInputHandler');
|
|
10
|
+
const ListFilesOutputHandler = require('./ListFilesOutputHandler');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
create(options) {
|
|
14
|
+
return Command.Builder.withOptions(options)
|
|
15
|
+
.withAction(ListFilesAction)
|
|
16
|
+
.withInput(ListFilesInputHandler)
|
|
17
|
+
.withOutput(ListFilesOutputHandler)
|
|
18
|
+
.build();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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: { prompt} } = require('inquirer');
|
|
8
|
+
const CommandUtils = require('../../../utils/CommandUtils');
|
|
9
|
+
const AccountFileCabinetService = require('../../../services/AccountFileCabinetService');
|
|
10
|
+
const { getProjectDefaultAuthId } = require('../../../utils/AuthenticationUtils');
|
|
11
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
12
|
+
const BaseInputHandler = require('../../base/BaseInputHandler');
|
|
13
|
+
const SdkExecutor = require('../../../SdkExecutor');
|
|
14
|
+
const {
|
|
15
|
+
COMMAND_LISTFILES: { ERRORS, SELECT_FOLDER },
|
|
16
|
+
} = require('../../../services/TranslationKeys');
|
|
17
|
+
|
|
18
|
+
const SUITE_SCRIPTS_FOLDER = '/SuiteScripts';
|
|
19
|
+
|
|
20
|
+
module.exports = class ListFilesInputHandler extends BaseInputHandler {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
super(options);
|
|
23
|
+
|
|
24
|
+
// TODO input handlers shouldn't execute actions. rework this
|
|
25
|
+
this._sdkExecutor = new SdkExecutor(this._sdkPath, this._executionEnvironmentContext);
|
|
26
|
+
this._accountFileCabinetService = new AccountFileCabinetService(
|
|
27
|
+
this._sdkPath,
|
|
28
|
+
this._executionEnvironmentContext,
|
|
29
|
+
this._authId
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async getParameters(params) {
|
|
34
|
+
const accountFileCabinetFolders = await this._accountFileCabinetService.getAccountFileCabinetFolders();
|
|
35
|
+
if (accountFileCabinetFolders.length === 0) {
|
|
36
|
+
throw NodeTranslationService.getMessage(ERRORS.NO_FOLDERS_FOUND);
|
|
37
|
+
}
|
|
38
|
+
const fileCabinetFolders = accountFileCabinetFolders.map((folderPath) => {
|
|
39
|
+
return {
|
|
40
|
+
name: folderPath,
|
|
41
|
+
value: folderPath,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return prompt([
|
|
46
|
+
{
|
|
47
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
48
|
+
name: this._commandMetadata.options.folder.name,
|
|
49
|
+
message: NodeTranslationService.getMessage(SELECT_FOLDER),
|
|
50
|
+
default: SUITE_SCRIPTS_FOLDER,
|
|
51
|
+
choices: fileCabinetFolders,
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -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
|
+
const BaseOutputHandler = require('../../base/BaseOutputHandler');
|
|
7
|
+
const ActionResultUtils = require('../../../utils/ActionResultUtils');
|
|
8
|
+
|
|
9
|
+
module.exports = class ListFilesOutputHandler extends BaseOutputHandler {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super(options);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
parse(actionResult) {
|
|
15
|
+
ActionResultUtils.logResultMessage(actionResult, this._log);
|
|
16
|
+
|
|
17
|
+
if (Array.isArray(actionResult.data)) {
|
|
18
|
+
actionResult.data.forEach((fileName) => {
|
|
19
|
+
this._log.result(fileName);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return actionResult;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
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 CommandUtils = require('../../../utils/CommandUtils');
|
|
9
|
+
const { executeWithSpinner } = require('../../../ui/CliSpinner');
|
|
10
|
+
const SdkOperationResultUtils = require('../../../utils/SdkOperationResultUtils');
|
|
11
|
+
const SdkExecutionContext = require('../../../SdkExecutionContext');
|
|
12
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
13
|
+
const { ActionResult } = require('../../../services/actionresult/ActionResult');
|
|
14
|
+
const { getProjectDefaultAuthId } = require('../../../utils/AuthenticationUtils');
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
COMMAND_UPLOADFILES: { MESSAGES },
|
|
18
|
+
} = require('../../../services/TranslationKeys');
|
|
19
|
+
|
|
20
|
+
const COMMAND_OPTIONS = {
|
|
21
|
+
PATHS: 'paths',
|
|
22
|
+
PROJECT: 'project',
|
|
23
|
+
AUTH_ID: 'authid',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = class UploadFilesAction extends BaseAction {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
super(options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
preExecute(params) {
|
|
32
|
+
const { PATHS } = COMMAND_OPTIONS;
|
|
33
|
+
|
|
34
|
+
if (params.hasOwnProperty(PATHS)) {
|
|
35
|
+
if (Array.isArray(params[PATHS])) {
|
|
36
|
+
params[PATHS] = params[PATHS].map(CommandUtils.quoteString).join(' ');
|
|
37
|
+
} else {
|
|
38
|
+
params[PATHS] = CommandUtils.quoteString(params[PATHS]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
params[COMMAND_OPTIONS.PROJECT] = CommandUtils.quoteString(this._projectFolder);
|
|
42
|
+
return params;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async execute(params) {
|
|
46
|
+
try {
|
|
47
|
+
const executionContextUploadFiles = SdkExecutionContext.Builder.forCommand(this._commandMetadata.sdkCommand)
|
|
48
|
+
.integration()
|
|
49
|
+
.addParams(params)
|
|
50
|
+
.build();
|
|
51
|
+
|
|
52
|
+
const operationResult = await executeWithSpinner({
|
|
53
|
+
action: this._sdkExecutor.execute(executionContextUploadFiles),
|
|
54
|
+
message: NodeTranslationService.getMessage(MESSAGES.UPLOADING_FILES),
|
|
55
|
+
});
|
|
56
|
+
return operationResult.status === SdkOperationResultUtils.STATUS.SUCCESS
|
|
57
|
+
? ActionResult.Builder.withData(operationResult.data)
|
|
58
|
+
.withResultMessage(operationResult.resultMessage)
|
|
59
|
+
.withProjectFolder(this._projectFolder)
|
|
60
|
+
.withCommandParameters(params)
|
|
61
|
+
.build()
|
|
62
|
+
: ActionResult.Builder.withErrors(operationResult.errorMessages).withCommandParameters(params).build();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return ActionResult.Builder.withErrors([error]).build();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
@@ -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 UploadFilesAction = require('./UploadFilesAction');
|
|
9
|
+
const UploadFilesInputHandler = require('./UploadFilesInputHandler');
|
|
10
|
+
const UploadFilesOutputHandler = require('./UploadFilesOutputHandler');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
create(options) {
|
|
14
|
+
return Command.Builder.withOptions(options)
|
|
15
|
+
.withAction(UploadFilesAction)
|
|
16
|
+
.withInput(UploadFilesInputHandler)
|
|
17
|
+
.withOutput(UploadFilesOutputHandler)
|
|
18
|
+
.build();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
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: { prompt } } = require('inquirer');
|
|
8
|
+
const BaseInputHandler = require('../../base/BaseInputHandler');
|
|
9
|
+
const CommandUtils = require('../../../utils/CommandUtils');
|
|
10
|
+
const FileCabinetService = require('../../../services/FileCabinetService');
|
|
11
|
+
const FileSystemService = require('../../../services/FileSystemService');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
COMMAND_UPLOADFILES: { QUESTIONS, MESSAGES, ERRORS },
|
|
17
|
+
NO,
|
|
18
|
+
YES,
|
|
19
|
+
} = require('../../../services/TranslationKeys');
|
|
20
|
+
|
|
21
|
+
const { FILE_CABINET } = require('../../../ApplicationConstants').FOLDERS;
|
|
22
|
+
const { validateArrayIsNotEmpty, showValidationResults } = require('../../../validation/InteractiveAnswersValidator');
|
|
23
|
+
|
|
24
|
+
const COMMAND_OPTIONS = {
|
|
25
|
+
PATHS: 'paths',
|
|
26
|
+
PROJECT: 'project',
|
|
27
|
+
AUTH_ID: 'authid',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const COMMAND_ANSWERS = {
|
|
31
|
+
SELECTED_FOLDER: 'selectedFolder',
|
|
32
|
+
OVERWRITE_FILES: 'overwrite',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
module.exports = class UploadFilesInputHandler extends BaseInputHandler {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
super(options);
|
|
38
|
+
this._fileSystemService = new FileSystemService();
|
|
39
|
+
this._fileCabinetService = new FileCabinetService(path.join(this._projectFolder, FILE_CABINET));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async getParameters(params) {
|
|
43
|
+
const selectFolderQuestion = this._generateSelectFolderQuestion();
|
|
44
|
+
const selectFolderAnswer = await prompt(selectFolderQuestion);
|
|
45
|
+
|
|
46
|
+
const selectFilesQuestion = this._generateSelectFilesQuestion(selectFolderAnswer.selectedFolder);
|
|
47
|
+
const selectFilesAnswer = await prompt(selectFilesQuestion);
|
|
48
|
+
|
|
49
|
+
const overwriteAnswer = await prompt([this._generateOverwriteQuestion()]);
|
|
50
|
+
if (overwriteAnswer[COMMAND_ANSWERS.OVERWRITE_FILES] === false) {
|
|
51
|
+
throw NodeTranslationService.getMessage(MESSAGES.CANCEL_UPLOAD);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return selectFilesAnswer;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
_generateSelectFolderQuestion() {
|
|
58
|
+
const localFileCabinetSubFolders = this._fileCabinetService.getFileCabinetFolders();
|
|
59
|
+
|
|
60
|
+
const transformFoldersToChoicesFunc = (folder) => {
|
|
61
|
+
const name = this._fileCabinetService.getFileCabinetRelativePath(folder);
|
|
62
|
+
|
|
63
|
+
let disabledMessage = '';
|
|
64
|
+
if (!this._fileCabinetService.isUnrestrictedPath(name)) {
|
|
65
|
+
disabledMessage = NodeTranslationService.getMessage(MESSAGES.RESTRICTED_FOLDER);
|
|
66
|
+
} else if (!this._fileSystemService.getFilesFromDirectory(folder).length) {
|
|
67
|
+
disabledMessage = NodeTranslationService.getMessage(MESSAGES.EMPTY_FOLDER);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
name: name,
|
|
72
|
+
value: folder,
|
|
73
|
+
disabled: disabledMessage,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const localFileCabinetFoldersChoices = localFileCabinetSubFolders.map(transformFoldersToChoicesFunc);
|
|
78
|
+
|
|
79
|
+
if (!localFileCabinetFoldersChoices.some((choice) => !choice.disabled)) {
|
|
80
|
+
throw NodeTranslationService.getMessage(MESSAGES.NOTHING_TO_UPLOAD);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
message: NodeTranslationService.getMessage(QUESTIONS.SELECT_FOLDER),
|
|
86
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
87
|
+
name: COMMAND_ANSWERS.SELECTED_FOLDER,
|
|
88
|
+
choices: localFileCabinetFoldersChoices,
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_generateSelectFilesQuestion(selectedFolder) {
|
|
94
|
+
const files = this._fileSystemService.getFilesFromDirectory(selectedFolder);
|
|
95
|
+
|
|
96
|
+
const transformFilesToChoicesFunc = (file) => {
|
|
97
|
+
const path = this._fileCabinetService.getFileCabinetRelativePath(file);
|
|
98
|
+
return { name: path, value: path };
|
|
99
|
+
};
|
|
100
|
+
const filesChoices = files.map(transformFilesToChoicesFunc);
|
|
101
|
+
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
message: NodeTranslationService.getMessage(QUESTIONS.SELECT_FILES),
|
|
105
|
+
type: CommandUtils.INQUIRER_TYPES.CHECKBOX,
|
|
106
|
+
name: COMMAND_OPTIONS.PATHS,
|
|
107
|
+
choices: filesChoices,
|
|
108
|
+
validate: (fieldValue) => showValidationResults(fieldValue, validateArrayIsNotEmpty),
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_generateOverwriteQuestion() {
|
|
114
|
+
return {
|
|
115
|
+
type: CommandUtils.INQUIRER_TYPES.LIST,
|
|
116
|
+
name: COMMAND_ANSWERS.OVERWRITE_FILES,
|
|
117
|
+
message: NodeTranslationService.getMessage(QUESTIONS.OVERWRITE_FILES),
|
|
118
|
+
default: true,
|
|
119
|
+
choices: [
|
|
120
|
+
{ name: NodeTranslationService.getMessage(YES), value: true },
|
|
121
|
+
{ name: NodeTranslationService.getMessage(NO), value: false },
|
|
122
|
+
],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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 FileCabinetService = require('../../../services/FileCabinetService');
|
|
8
|
+
const NodeTranslationService = require('../../../services/NodeTranslationService');
|
|
9
|
+
const { FILE_CABINET } = require('../../../ApplicationConstants').FOLDERS;
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
COMMAND_UPLOADFILES: { OUTPUT },
|
|
14
|
+
} = require('../../../services/TranslationKeys');
|
|
15
|
+
|
|
16
|
+
const UPLOAD_FILE_RESULT_STATUS = {
|
|
17
|
+
SUCCESS: 'SUCCESS',
|
|
18
|
+
ERROR: 'ERROR',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = class UploadFilesOutputHandler extends BaseOutputHandler {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
super(options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
parse(actionResult) {
|
|
27
|
+
const { data } = actionResult;
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(data)) {
|
|
30
|
+
const successfulUploads = data.filter((result) => result.type === UPLOAD_FILE_RESULT_STATUS.SUCCESS);
|
|
31
|
+
const unsuccessfulUploads = data.filter((result) => result.type === UPLOAD_FILE_RESULT_STATUS.ERROR);
|
|
32
|
+
const localFileCabinetFolder = path.join(actionResult.projectFolder, FILE_CABINET);
|
|
33
|
+
this._fileCabinetService = new FileCabinetService(localFileCabinetFolder);
|
|
34
|
+
if (successfulUploads && successfulUploads.length) {
|
|
35
|
+
this._log.result(NodeTranslationService.getMessage(OUTPUT.FILES_UPLOADED));
|
|
36
|
+
successfulUploads.forEach((result) => {
|
|
37
|
+
this._log.result(this._fileCabinetService.getFileCabinetRelativePath(result.file.path));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (unsuccessfulUploads && unsuccessfulUploads.length) {
|
|
41
|
+
this._log.warning(NodeTranslationService.getMessage(OUTPUT.FILES_NOT_UPLOADED));
|
|
42
|
+
unsuccessfulUploads.forEach((result) => {
|
|
43
|
+
this._log.warning(`${this._fileCabinetService.getFileCabinetRelativePath(result.file.path)}: ${result.errorMessage}`);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return actionResult;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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 TemplateKeys = require('../../../templates/TemplateKeys');
|
|
8
|
+
const BaseAction = require('../../base/BaseAction');
|
|
9
|
+
const FileSystemService = require('../../../services/FileSystemService');
|
|
10
|
+
|
|
11
|
+
module.exports = class CreateObjectAction extends BaseAction {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options);
|
|
14
|
+
this._fileSystemService = new FileSystemService();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async execute(params) {
|
|
18
|
+
const createFilePromise = this._fileSystemService.createFileFromTemplate({
|
|
19
|
+
template: TemplateKeys.SCRIPTS['blankscript'],
|
|
20
|
+
destinationFolder: params.relatedfiledestinationfolder,
|
|
21
|
+
fileName: params.relatedfilename,
|
|
22
|
+
fileExtension: 'js',
|
|
23
|
+
});
|
|
24
|
+
const createObjectPromise = this._fileSystemService.createFileFromTemplate({
|
|
25
|
+
template: TemplateKeys.OBJECTS['commerceextension'],
|
|
26
|
+
destinationFolder: params.folder,
|
|
27
|
+
fileName: params.objectfilename,
|
|
28
|
+
fileExtension: 'xml',
|
|
29
|
+
bindings: [{ id: 'scriptid', value: params.type.prefix + params.objectfilename }],
|
|
30
|
+
});
|
|
31
|
+
await Promise.all([createFilePromise, createObjectPromise]);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 CreateObjectAction = require('./CreateObjectAction');
|
|
9
|
+
const CreateObjectInputHandler = require('./CreateObjectInputHandler');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
create(options) {
|
|
14
|
+
return Command.Builder.withOptions(options)
|
|
15
|
+
.withAction(CreateObjectAction)
|
|
16
|
+
.withInput(CreateObjectInputHandler)
|
|
17
|
+
.build();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
* The create:object command is no longer in use; as a result, this class is now deprecated. If there is a need to use this class in the future,
|
|
8
|
+
* the imports and implementation related to chalk and inquirer will need to be updated accordingly.
|
|
9
|
+
*/
|
|
10
|
+
const OBJECT_TYPES = require('../../../metadata/ObjectTypesMetadata');
|
|
11
|
+
// const { prompt } = require('inquirer');
|
|
12
|
+
// const chalk = require('chalk');
|
|
13
|
+
const { join } = require('path');
|
|
14
|
+
const { FOLDERS } = require('../../../ApplicationConstants');
|
|
15
|
+
const BaseInputHandler = require('../../base/BaseInputHandler');
|
|
16
|
+
const FileSystemService = require('../../../services/FileSystemService');
|
|
17
|
+
|
|
18
|
+
module.exports = class CreateObjectInputHandler extends BaseInputHandler {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(options);
|
|
21
|
+
|
|
22
|
+
this._fileSystemService = new FileSystemService();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async getParameters(params) {
|
|
26
|
+
const transformFoldersToChoicesFunc = (folder) => {
|
|
27
|
+
return { name: folder.replace(this._projectFolder, ''), value: folder };
|
|
28
|
+
};
|
|
29
|
+
const objectDirectoryChoices = this._fileSystemService
|
|
30
|
+
.getFoldersFromDirectory(join(this._projectFolder, FOLDERS.OBJECTS))
|
|
31
|
+
.map(transformFoldersToChoicesFunc);
|
|
32
|
+
|
|
33
|
+
// const mainAnswers = await prompt([
|
|
34
|
+
// {
|
|
35
|
+
// type: 'list',
|
|
36
|
+
// name: 'type',
|
|
37
|
+
// message: 'What object type would you like to create?',
|
|
38
|
+
// choices: OBJECT_TYPES,
|
|
39
|
+
// },
|
|
40
|
+
// {
|
|
41
|
+
// type: 'input',
|
|
42
|
+
// name: 'objectfilename',
|
|
43
|
+
// message: (answers_1) => `Please specify the filename for the ${chalk.green.bold(answers_1.type.name)} object`,
|
|
44
|
+
// transformer: (input_1, answers_2, flags) => `${answers_2.type.prefix}${input_1}.xml`,
|
|
45
|
+
// },
|
|
46
|
+
// {
|
|
47
|
+
// type: 'list',
|
|
48
|
+
// name: 'folder',
|
|
49
|
+
// message: (answers_4) =>
|
|
50
|
+
// `Where would you like to store the ${chalk.green.bold(answers_4.type.prefix + answers_4.objectfilename + '.xml')} file?`,
|
|
51
|
+
// choices: objectDirectoryChoices,
|
|
52
|
+
// },
|
|
53
|
+
// {
|
|
54
|
+
// type: 'confirm',
|
|
55
|
+
// name: 'createrelatedfiles',
|
|
56
|
+
// message: 'Would you like to also create associated files with this object?',
|
|
57
|
+
// when: (answers_6) => answers_6.type.hasRelatedFiles,
|
|
58
|
+
// },
|
|
59
|
+
// ]);
|
|
60
|
+
// if (mainAnswers.createrelatedfiles) {
|
|
61
|
+
// const fileCabinetDirectoryChoices = this._fileSystemService
|
|
62
|
+
// .getFoldersFromDirectory(join(this._projectFolder, FOLDERS.FILE_CABINET))
|
|
63
|
+
// .map(transformFoldersToChoicesFunc);
|
|
64
|
+
// const answers_10 = await prompt([
|
|
65
|
+
// {
|
|
66
|
+
// type: 'input',
|
|
67
|
+
// name: 'relatedfilename',
|
|
68
|
+
// message: 'Please specify the script filename',
|
|
69
|
+
// transformer: (input_3, answers_7, flags) => `${input_3}.js`,
|
|
70
|
+
// },
|
|
71
|
+
// {
|
|
72
|
+
// type: 'list',
|
|
73
|
+
// name: 'relatedfiledestinationfolder',
|
|
74
|
+
// message: (answers_9) => `Where would you like to store the ${chalk.green.bold(answers_9.relatedfilename)}.js file?`,
|
|
75
|
+
// choices: fileCabinetDirectoryChoices,
|
|
76
|
+
// },
|
|
77
|
+
// ]);
|
|
78
|
+
// return { ...answers_10, ...mainAnswers };
|
|
79
|
+
// }
|
|
80
|
+
// return mainAnswers;
|
|
81
|
+
}
|
|
82
|
+
};
|