@sap-ux/create 0.7.67 → 0.8.1
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/README.md +9 -0
- package/dist/cli/add/deploy-config.d.ts +8 -0
- package/dist/cli/add/deploy-config.js +109 -0
- package/dist/cli/add/index.js +3 -0
- package/dist/common/prompts.d.ts +8 -1
- package/dist/common/prompts.js +32 -12
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -31,6 +31,15 @@ Calling `sap-ux add annotations` allows adding an annotation to the OData Source
|
|
|
31
31
|
```sh
|
|
32
32
|
sap-ux add annotations /path/to/adaptation-project
|
|
33
33
|
```
|
|
34
|
+
### deploy-config
|
|
35
|
+
Calling `sap-ux add deploy-config` will prompt for ABAP deployment configuration details and add/update the project files accordingly
|
|
36
|
+
```sh
|
|
37
|
+
sap-ux add deploy-config /path/to/project
|
|
38
|
+
```
|
|
39
|
+
#### deploy-config options:
|
|
40
|
+
`--target` abap | cf (cf deploy config inquirer not yet implemented)\
|
|
41
|
+
`--base-file` e.g ui5.yaml\
|
|
42
|
+
`--deploy-file` e.g. ui5-deploy.yaml
|
|
34
43
|
|
|
35
44
|
### model
|
|
36
45
|
Calling `sap-ux add model` allows to add new OData Service and SAPUI5 Model to an existing adaptation project.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Add the "add deploy config" command to a passed command.
|
|
4
|
+
*
|
|
5
|
+
* @param cmd - commander command for adding deploy config command
|
|
6
|
+
*/
|
|
7
|
+
export declare function addDeployConfigCommand(cmd: Command): void;
|
|
8
|
+
//# sourceMappingURL=deploy-config.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDeployConfigCommand = void 0;
|
|
4
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
5
|
+
const abap_deploy_config_writer_1 = require("@sap-ux/abap-deploy-config-writer");
|
|
6
|
+
const tracing_1 = require("../../tracing");
|
|
7
|
+
const validation_1 = require("../../validation");
|
|
8
|
+
const abap_deploy_config_inquirer_1 = require("@sap-ux/abap-deploy-config-inquirer");
|
|
9
|
+
const prompts_1 = require("prompts");
|
|
10
|
+
const common_1 = require("../../common");
|
|
11
|
+
/**
|
|
12
|
+
* Add the "add deploy config" command to a passed command.
|
|
13
|
+
*
|
|
14
|
+
* @param cmd - commander command for adding deploy config command
|
|
15
|
+
*/
|
|
16
|
+
function addDeployConfigCommand(cmd) {
|
|
17
|
+
cmd.command('deploy-config [path]')
|
|
18
|
+
.option('-t, --target <string>', 'target for deployment; ABAP or Cloud Foundry (not yet implemented)')
|
|
19
|
+
.option('-s, --simulate', 'simulate only do not write; sets also --verbose')
|
|
20
|
+
.option('-v, --verbose', 'show verbose information')
|
|
21
|
+
.option('-b, --base-file <string>', 'the base file config file of the project; default : ui5.yaml')
|
|
22
|
+
.option('-d, --deploy-file <string>', 'the name of the deploy config file to be written; default : ui5-deploy.yaml')
|
|
23
|
+
.action(async (path, options) => {
|
|
24
|
+
if (options.verbose === true || options.simulate) {
|
|
25
|
+
(0, tracing_1.setLogLevelVerbose)();
|
|
26
|
+
}
|
|
27
|
+
await addDeployConfig(path || process.cwd(), options.target, options.simulate, options.baseFile ?? project_access_1.FileName.Ui5Yaml, options.deployFile ?? project_access_1.FileName.UI5DeployYaml);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.addDeployConfigCommand = addDeployConfigCommand;
|
|
31
|
+
/**
|
|
32
|
+
* Prompts the user to select the target for deployment.
|
|
33
|
+
*
|
|
34
|
+
* @param target - target for deployment
|
|
35
|
+
* @returns target
|
|
36
|
+
*/
|
|
37
|
+
async function getTarget(target) {
|
|
38
|
+
if (!target || (target !== 'abap' && target !== 'cf')) {
|
|
39
|
+
const question = {
|
|
40
|
+
name: 'target',
|
|
41
|
+
type: 'select',
|
|
42
|
+
message: 'Select the target for deployment',
|
|
43
|
+
choices: [
|
|
44
|
+
{ title: 'ABAP', value: 'abap' }
|
|
45
|
+
// { title: 'Cloud Foundry', value: 'cf' }
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
return (await (0, prompts_1.prompt)(question)).target;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Adds a deploy config to an app or project.
|
|
56
|
+
*
|
|
57
|
+
* @param basePath - path to application root
|
|
58
|
+
* @param target - target for deployment (ABAP or Cloud Foundry)
|
|
59
|
+
* @param simulate - simulate only do not write
|
|
60
|
+
* @param baseFile - base file name
|
|
61
|
+
* @param deployFile - deploy file name
|
|
62
|
+
*/
|
|
63
|
+
async function addDeployConfig(basePath, target, simulate = false, baseFile, deployFile) {
|
|
64
|
+
const logger = (0, tracing_1.getLogger)();
|
|
65
|
+
try {
|
|
66
|
+
target = await getTarget(target);
|
|
67
|
+
if (target === 'cf') {
|
|
68
|
+
logger.info('Cloud Foundry deployment is not yet implemented.');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
else if (target === 'abap') {
|
|
72
|
+
logger.debug(`Called add deploy-config for path '${basePath}', simulate is '${simulate}'`);
|
|
73
|
+
await (0, validation_1.validateBasePath)(basePath);
|
|
74
|
+
const { prompts: abapPrompts, answers: abapAnswers } = await (0, abap_deploy_config_inquirer_1.getPrompts)({ useAutocomplete: true }, logger, false);
|
|
75
|
+
const answers = (0, abap_deploy_config_inquirer_1.reconcileAnswers)(await (0, common_1.promptYUIQuestions)(abapPrompts, false), abapAnswers);
|
|
76
|
+
const config = {
|
|
77
|
+
target: {
|
|
78
|
+
url: answers.url,
|
|
79
|
+
client: answers.client,
|
|
80
|
+
scp: answers.scp,
|
|
81
|
+
destination: answers.destination
|
|
82
|
+
},
|
|
83
|
+
app: {
|
|
84
|
+
name: answers.ui5AbapRepo,
|
|
85
|
+
package: answers.package,
|
|
86
|
+
description: answers.description,
|
|
87
|
+
transport: answers.transport
|
|
88
|
+
},
|
|
89
|
+
index: answers.index
|
|
90
|
+
};
|
|
91
|
+
logger.debug(`Adding deployment configuration : ${JSON.stringify(config, null, 2)}`);
|
|
92
|
+
const fs = await (0, abap_deploy_config_writer_1.generate)(basePath, config, {
|
|
93
|
+
baseFile,
|
|
94
|
+
deployFile
|
|
95
|
+
});
|
|
96
|
+
await (0, tracing_1.traceChanges)(fs);
|
|
97
|
+
if (!simulate) {
|
|
98
|
+
fs.commit(() => {
|
|
99
|
+
logger.info(`Changes written.`);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
logger.error(`Error while executing add deploy-config '${error.message}'`);
|
|
106
|
+
logger.debug(error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=deploy-config.js.map
|
package/dist/cli/add/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const new_model_1 = require("./new-model");
|
|
|
11
11
|
const annotations_to_odata_1 = require("./annotations-to-odata");
|
|
12
12
|
const html_1 = require("./html");
|
|
13
13
|
const component_usages_1 = require("./component-usages");
|
|
14
|
+
const deploy_config_1 = require("./deploy-config");
|
|
14
15
|
/**
|
|
15
16
|
* Return 'create-fiori add *' commands. Commands include also the handler action.
|
|
16
17
|
*
|
|
@@ -36,6 +37,8 @@ function getAddCommands() {
|
|
|
36
37
|
(0, html_1.addAddHtmlFilesCmd)(addCommands);
|
|
37
38
|
// create-fiori add component-usages
|
|
38
39
|
(0, component_usages_1.addComponentUsagesCommand)(addCommands);
|
|
40
|
+
// create-fiori add deploy-config
|
|
41
|
+
(0, deploy_config_1.addDeployConfigCommand)(addCommands);
|
|
39
42
|
return addCommands;
|
|
40
43
|
}
|
|
41
44
|
exports.getAddCommands = getAddCommands;
|
package/dist/common/prompts.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { PromptObject } from 'prompts';
|
|
2
2
|
import type { YUIQuestion } from '@sap-ux/inquirer-common';
|
|
3
3
|
import type { Answers } from 'inquirer';
|
|
4
|
+
type AutoCompleteCallbackFn = (answers: Answers, input: string) => Promise<Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
value: unknown;
|
|
7
|
+
}>>;
|
|
4
8
|
/**
|
|
5
9
|
* Converts a YUI question to a simple prompts question.
|
|
6
10
|
*
|
|
@@ -10,13 +14,16 @@ import type { Answers } from 'inquirer';
|
|
|
10
14
|
*/
|
|
11
15
|
export declare function convertQuestion<T extends Answers>(question: YUIQuestion<T> & {
|
|
12
16
|
choices?: unknown;
|
|
17
|
+
source?: AutoCompleteCallbackFn;
|
|
13
18
|
}, answers: T): Promise<PromptObject>;
|
|
14
19
|
/**
|
|
15
20
|
* Prompt a list of YeomanUI questions with the simple prompts module.
|
|
16
21
|
*
|
|
17
22
|
* @param questions list of questions
|
|
18
23
|
* @param useDefaults - if true, the default values are used for all prompts
|
|
24
|
+
* @param answers - previously given answers
|
|
19
25
|
* @returns the answers to the questions
|
|
20
26
|
*/
|
|
21
|
-
export declare function promptYUIQuestions<T extends Answers>(questions: YUIQuestion<T>[], useDefaults: boolean): Promise<T>;
|
|
27
|
+
export declare function promptYUIQuestions<T extends Answers>(questions: YUIQuestion<T>[], useDefaults: boolean, answers?: T): Promise<T>;
|
|
28
|
+
export {};
|
|
22
29
|
//# sourceMappingURL=prompts.d.ts.map
|
package/dist/common/prompts.js
CHANGED
|
@@ -22,23 +22,42 @@ const QUESTION_TYPE_MAP = {
|
|
|
22
22
|
checkbox: 'multiselect'
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Map choices from inquirer format to prompts format.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @
|
|
29
|
-
* @param answers previously given answers
|
|
27
|
+
* @param choices choices to be mapped
|
|
28
|
+
* @returns mapped choices
|
|
30
29
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const mapppedChoices = choices.map((choice) => ({
|
|
30
|
+
function mapChoices(choices) {
|
|
31
|
+
return choices.map((choice) => ({
|
|
34
32
|
title: typeof choice === 'object' ? choice.name : `${choice}`,
|
|
35
33
|
value: typeof choice === 'object' ? choice.value : choice
|
|
36
34
|
}));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Enhances the new prompt with the choices from the original list question.
|
|
38
|
+
*
|
|
39
|
+
* @param origChoices choices of the original list/autocomplete question
|
|
40
|
+
* @param prompt converted prompt
|
|
41
|
+
* @param answers previously given answers
|
|
42
|
+
* @param autoCompleteCb callback for autocomplete
|
|
43
|
+
*/
|
|
44
|
+
async function enhanceListQuestion(origChoices, prompt, answers, autoCompleteCb) {
|
|
45
|
+
const choices = (isFunction(origChoices) ? await origChoices(answers) : origChoices);
|
|
46
|
+
const mapppedChoices = mapChoices(choices);
|
|
37
47
|
const initialValue = prompt.initial();
|
|
38
48
|
prompt.choices = mapppedChoices;
|
|
39
49
|
prompt.initial = () => mapppedChoices[initialValue]
|
|
40
50
|
? initialValue
|
|
41
51
|
: mapppedChoices.findIndex((choice) => choice.value === initialValue);
|
|
52
|
+
if (autoCompleteCb) {
|
|
53
|
+
prompt.suggest = async (input, choices) => {
|
|
54
|
+
if (input) {
|
|
55
|
+
const newChoices = await autoCompleteCb(answers, input);
|
|
56
|
+
return mapChoices(newChoices);
|
|
57
|
+
}
|
|
58
|
+
return choices;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
42
61
|
}
|
|
43
62
|
/**
|
|
44
63
|
* Indicates if the question is optional.
|
|
@@ -71,8 +90,8 @@ async function convertQuestion(question, answers) {
|
|
|
71
90
|
validate: async (value) => isFunction(question.validate) ? await question.validate(value, answers) : question.validate ?? true,
|
|
72
91
|
initial: () => (isFunction(question.default) ? question.default(answers) : question.default)
|
|
73
92
|
};
|
|
74
|
-
if (question.choices) {
|
|
75
|
-
await enhanceListQuestion(question, prompt, answers);
|
|
93
|
+
if (question.choices || question.source) {
|
|
94
|
+
await enhanceListQuestion(question.choices ?? question.source, prompt, answers, question.source);
|
|
76
95
|
}
|
|
77
96
|
return prompt;
|
|
78
97
|
}
|
|
@@ -82,12 +101,13 @@ exports.convertQuestion = convertQuestion;
|
|
|
82
101
|
*
|
|
83
102
|
* @param questions list of questions
|
|
84
103
|
* @param useDefaults - if true, the default values are used for all prompts
|
|
104
|
+
* @param answers - previously given answers
|
|
85
105
|
* @returns the answers to the questions
|
|
86
106
|
*/
|
|
87
|
-
async function promptYUIQuestions(questions, useDefaults) {
|
|
88
|
-
|
|
107
|
+
async function promptYUIQuestions(questions, useDefaults, answers) {
|
|
108
|
+
answers ??= {};
|
|
89
109
|
for (const question of questions) {
|
|
90
|
-
if (isFunction(question.when) ? question.when(answers) : question.when !== false) {
|
|
110
|
+
if (isFunction(question.when) ? await question.when(answers) : question.when !== false) {
|
|
91
111
|
if (useDefaults) {
|
|
92
112
|
answers[question.name] = isFunction(question.default) ? question.default(answers) : question.default;
|
|
93
113
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/create",
|
|
3
3
|
"description": "SAP Fiori tools module to add or remove features",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -30,9 +30,11 @@
|
|
|
30
30
|
"mem-fs": "2.1.0",
|
|
31
31
|
"mem-fs-editor": "9.4.0",
|
|
32
32
|
"prompts": "2.4.2",
|
|
33
|
+
"@sap-ux/abap-deploy-config-inquirer": "0.0.9",
|
|
34
|
+
"@sap-ux/abap-deploy-config-writer": "0.0.39",
|
|
33
35
|
"@sap-ux/adp-tooling": "0.12.44",
|
|
34
36
|
"@sap-ux/app-config-writer": "0.4.30",
|
|
35
|
-
"@sap-ux/cap-config-writer": "0.7.
|
|
37
|
+
"@sap-ux/cap-config-writer": "0.7.35",
|
|
36
38
|
"@sap-ux/cards-editor-config-writer": "0.4.4",
|
|
37
39
|
"@sap-ux/inquirer-common": "0.4.6",
|
|
38
40
|
"@sap-ux/logger": "0.6.0",
|