@sap-ux/create 0.17.6 → 1.0.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/dist/cli/add/adp-cf-config.js +14 -17
- package/dist/cli/add/annotations-to-odata.js +20 -23
- package/dist/cli/add/cards-generator.js +11 -14
- package/dist/cli/add/cds-plugin-ui.js +11 -14
- package/dist/cli/add/component-usages.js +13 -17
- package/dist/cli/add/deploy-config.js +23 -25
- package/dist/cli/add/eslint-config.js +13 -16
- package/dist/cli/add/flp-embedded-config.js +8 -11
- package/dist/cli/add/html.js +18 -21
- package/dist/cli/add/index.js +33 -36
- package/dist/cli/add/mockserver-config.js +19 -21
- package/dist/cli/add/navigation-config.js +38 -41
- package/dist/cli/add/new-model.js +11 -14
- package/dist/cli/add/smartlinks-config.js +10 -13
- package/dist/cli/add/system.js +22 -25
- package/dist/cli/add/variants-config.js +13 -16
- package/dist/cli/change/change-data-source.js +18 -21
- package/dist/cli/change/change-inbound.js +13 -16
- package/dist/cli/change/index.js +9 -12
- package/dist/cli/change/system.js +12 -15
- package/dist/cli/convert/eslint-config.js +15 -18
- package/dist/cli/convert/index.js +7 -10
- package/dist/cli/convert/preview.js +10 -13
- package/dist/cli/generate/adaptation-project.js +14 -20
- package/dist/cli/generate/index.js +5 -8
- package/dist/cli/get/index.js +5 -8
- package/dist/cli/get/system.js +10 -13
- package/dist/cli/index.js +27 -29
- package/dist/cli/list/index.js +5 -8
- package/dist/cli/list/system.js +9 -12
- package/dist/cli/remove/index.js +7 -10
- package/dist/cli/remove/mockserver-config.js +12 -18
- package/dist/cli/remove/system.js +8 -11
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +4 -9
- package/dist/common/prompts.js +7 -15
- package/dist/index.js +2 -4
- package/dist/tracing/compare.js +12 -16
- package/dist/tracing/index.d.ts +2 -2
- package/dist/tracing/index.js +2 -8
- package/dist/tracing/logger.js +9 -15
- package/dist/tracing/trace.js +11 -14
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -8
- package/dist/validation/validation.js +15 -21
- package/package.json +24 -22
package/dist/cli/add/index.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const eslint_config_1 = require("./eslint-config");
|
|
18
|
-
const system_1 = require("./system");
|
|
19
|
-
const flp_embedded_config_1 = require("./flp-embedded-config");
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { addAddMockserverConfigCommand } from './mockserver-config.js';
|
|
3
|
+
import { addAddSmartLinksConfigCommand } from './smartlinks-config.js';
|
|
4
|
+
import { addAddCdsPluginUi5Command } from './cds-plugin-ui.js';
|
|
5
|
+
import { addInboundNavigationConfigCommand } from './navigation-config.js';
|
|
6
|
+
import { addCardsEditorConfigCommand } from './cards-generator.js';
|
|
7
|
+
import { addNewModelCommand } from './new-model.js';
|
|
8
|
+
import { addAnnotationsToOdataCommand } from './annotations-to-odata.js';
|
|
9
|
+
import { addAddHtmlFilesCmd } from './html.js';
|
|
10
|
+
import { addComponentUsagesCommand } from './component-usages.js';
|
|
11
|
+
import { addDeployConfigCommand } from './deploy-config.js';
|
|
12
|
+
import { addAddVariantsConfigCommand } from './variants-config.js';
|
|
13
|
+
import { addAdaptationProjectCFConfigCommand } from './adp-cf-config.js';
|
|
14
|
+
import { addAddEslintConfigCommand } from './eslint-config.js';
|
|
15
|
+
import { addSystemAddCommand } from './system.js';
|
|
16
|
+
import { addFlpEmbeddedConfigCommand } from './flp-embedded-config.js';
|
|
20
17
|
/**
|
|
21
18
|
* Return 'create-fiori add *' commands. Commands include also the handler action.
|
|
22
19
|
*
|
|
23
20
|
* @returns - commander command containing add <feature> commands
|
|
24
21
|
*/
|
|
25
|
-
function getAddCommands() {
|
|
26
|
-
const addCommands = new
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
export function getAddCommands() {
|
|
23
|
+
const addCommands = new Command('add');
|
|
24
|
+
addAddMockserverConfigCommand(addCommands);
|
|
25
|
+
addAddSmartLinksConfigCommand(addCommands);
|
|
26
|
+
addAddEslintConfigCommand(addCommands);
|
|
27
|
+
addAddCdsPluginUi5Command(addCommands);
|
|
28
|
+
addInboundNavigationConfigCommand(addCommands);
|
|
29
|
+
addCardsEditorConfigCommand(addCommands);
|
|
30
|
+
addNewModelCommand(addCommands);
|
|
31
|
+
addAnnotationsToOdataCommand(addCommands);
|
|
32
|
+
addAddHtmlFilesCmd(addCommands);
|
|
33
|
+
addComponentUsagesCommand(addCommands);
|
|
34
|
+
addDeployConfigCommand(addCommands);
|
|
35
|
+
addAddVariantsConfigCommand(addCommands);
|
|
36
|
+
addAdaptationProjectCFConfigCommand(addCommands);
|
|
37
|
+
addSystemAddCommand(addCommands);
|
|
38
|
+
addFlpEmbeddedConfigCommand(addCommands);
|
|
42
39
|
return addCommands;
|
|
43
40
|
}
|
|
44
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const validation_1 = require("../../validation");
|
|
10
|
-
const common_1 = require("../../common");
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import prompts from 'prompts';
|
|
3
|
+
import { getWebappPath } from '@sap-ux/project-access';
|
|
4
|
+
import { generateMockserverConfig, getMockserverConfigQuestions } from '@sap-ux/mockserver-config-writer';
|
|
5
|
+
import { getLogger, traceChanges, setLogLevelVerbose } from '../../tracing/index.js';
|
|
6
|
+
import { validateBasePath } from '../../validation/index.js';
|
|
7
|
+
import { runNpmInstallCommand } from '../../common/index.js';
|
|
8
|
+
const { prompt } = prompts;
|
|
11
9
|
/**
|
|
12
10
|
* Add the "add mockserver config" command to a passed command.
|
|
13
11
|
*
|
|
14
12
|
* @param cmd - commander command for adding mockserver config command
|
|
15
13
|
*/
|
|
16
|
-
function addAddMockserverConfigCommand(cmd) {
|
|
14
|
+
export function addAddMockserverConfigCommand(cmd) {
|
|
17
15
|
cmd.command('mockserver-config [path]')
|
|
18
16
|
.description(`Add the necessary configuration for the \`@sap-ux/ui5-middleware-fe-mockserver\` mockserver module to enable local OData mocking.\n
|
|
19
17
|
Example:
|
|
@@ -24,7 +22,7 @@ Example:
|
|
|
24
22
|
.option('-v, --verbose', 'Show verbose information.')
|
|
25
23
|
.action(async (path, options) => {
|
|
26
24
|
if (options.verbose === true || options.simulate) {
|
|
27
|
-
|
|
25
|
+
setLogLevelVerbose();
|
|
28
26
|
}
|
|
29
27
|
await addMockserverConfig(path || process.cwd(), !!options.simulate, !!options.skipInstall, !!options.interactive);
|
|
30
28
|
});
|
|
@@ -38,25 +36,25 @@ Example:
|
|
|
38
36
|
* @param interactive - if true, prompt user for config options, otherwise use defaults
|
|
39
37
|
*/
|
|
40
38
|
async function addMockserverConfig(basePath, simulate, skipInstall, interactive) {
|
|
41
|
-
const logger =
|
|
39
|
+
const logger = getLogger();
|
|
42
40
|
try {
|
|
43
41
|
logger.debug(`Called add mockserver-config for path '${basePath}', simulate is '${simulate}', skip install is '${skipInstall}'`);
|
|
44
|
-
await
|
|
45
|
-
const webappPath = await
|
|
42
|
+
await validateBasePath(basePath);
|
|
43
|
+
const webappPath = await getWebappPath(basePath);
|
|
46
44
|
const config = { webappPath };
|
|
47
45
|
if (interactive) {
|
|
48
|
-
const questions =
|
|
46
|
+
const questions = getMockserverConfigQuestions({ webappPath, askForOverwrite: true });
|
|
49
47
|
// User responses for webappPath and whether to overwrite existing services in mockserver config
|
|
50
|
-
config.ui5MockYamlConfig = await
|
|
48
|
+
config.ui5MockYamlConfig = await prompt(questions);
|
|
51
49
|
}
|
|
52
|
-
const fs = await
|
|
53
|
-
await
|
|
50
|
+
const fs = await generateMockserverConfig(basePath, config);
|
|
51
|
+
await traceChanges(fs);
|
|
54
52
|
if (!simulate) {
|
|
55
53
|
await new Promise((resolve) => fs.commit(resolve));
|
|
56
54
|
logger.info(`Changes written.`);
|
|
57
55
|
if (skipInstall) {
|
|
58
56
|
logger.warn('To finish mockserver configuration run commands:');
|
|
59
|
-
const relPath =
|
|
57
|
+
const relPath = relative(basePath, process.cwd());
|
|
60
58
|
if (relPath) {
|
|
61
59
|
logger.info(`cd ${relPath}`);
|
|
62
60
|
}
|
|
@@ -64,7 +62,7 @@ async function addMockserverConfig(basePath, simulate, skipInstall, interactive)
|
|
|
64
62
|
}
|
|
65
63
|
else {
|
|
66
64
|
logger.debug('Running npm install command');
|
|
67
|
-
|
|
65
|
+
runNpmInstallCommand(basePath, ['--save-dev', '@sap-ux/ui5-middleware-fe-mockserver']);
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
}
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const validation_1 = require("../../validation");
|
|
14
|
-
const prompts_1 = require("../../common/prompts");
|
|
15
|
-
const tracing_1 = require("../../tracing");
|
|
1
|
+
import { create as createStorage } from 'mem-fs';
|
|
2
|
+
import { create } from 'mem-fs-editor';
|
|
3
|
+
import { generateInboundConfig, getAdpConfig, getInboundsFromManifest, getVariant, getBaseAppInbounds, getCfBaseAppInbounds, isCFEnvironment, loadCfConfig, getAppParamsFromUI5Yaml } from '@sap-ux/adp-tooling';
|
|
4
|
+
import { getPrompts, tileActions } from '@sap-ux/flp-config-inquirer';
|
|
5
|
+
import { FileName, getAppType } from '@sap-ux/project-access';
|
|
6
|
+
import { createAbapServiceProvider } from '@sap-ux/system-access';
|
|
7
|
+
import { generateInboundNavigationConfig, readManifest } from '@sap-ux/app-config-writer';
|
|
8
|
+
import { getAdpFlpConfigPromptOptions, getAdpFlpInboundsWriterConfig, getTileSettingsQuestions } from '@sap-ux/flp-config-inquirer';
|
|
9
|
+
import { promptYUIQuestions } from '../../common/index.js';
|
|
10
|
+
import { validateBasePath } from '../../validation/index.js';
|
|
11
|
+
import { filterLabelTypeQuestions } from '../../common/prompts.js';
|
|
12
|
+
import { getLogger, traceChanges, setLogLevelVerbose } from '../../tracing/index.js';
|
|
16
13
|
/**
|
|
17
14
|
* Add the "add inbound-navigation" command to a passed command.
|
|
18
15
|
*
|
|
19
16
|
* @param cmd - commander command for adding navigation inbounds config command
|
|
20
17
|
*/
|
|
21
|
-
function addInboundNavigationConfigCommand(cmd) {
|
|
18
|
+
export function addInboundNavigationConfigCommand(cmd) {
|
|
22
19
|
cmd.command('inbound-navigation [path]')
|
|
23
20
|
.description(`Add SAP Fiori launchpad inbound navigation configuration to a project.\n
|
|
24
21
|
Example:
|
|
25
22
|
\`npx --yes @sap-ux/create@latest add inbound-navigation\``)
|
|
26
23
|
.option('-s, --simulate', 'Simulate only. Do not write to the config file. Also, sets `--verbose`')
|
|
27
24
|
.option('-v, --verbose', 'Show verbose information.')
|
|
28
|
-
.option('-c, --config <string>', 'Path to the project configuration file in YAML format.',
|
|
25
|
+
.option('-c, --config <string>', 'Path to the project configuration file in YAML format.', FileName.Ui5Yaml)
|
|
29
26
|
.action(async (path, options) => {
|
|
30
27
|
if (options.verbose === true || options.simulate) {
|
|
31
|
-
|
|
28
|
+
setLogLevelVerbose();
|
|
32
29
|
}
|
|
33
30
|
await addInboundNavigationConfig(path || process.cwd(), !!options.simulate, options.config);
|
|
34
31
|
});
|
|
@@ -42,27 +39,27 @@ Example:
|
|
|
42
39
|
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
43
40
|
*/
|
|
44
41
|
async function addInboundNavigationConfig(basePath, simulate, yamlPath) {
|
|
45
|
-
const logger =
|
|
42
|
+
const logger = getLogger();
|
|
46
43
|
try {
|
|
47
44
|
logger.debug(`Called add inbound navigation-config for path '${basePath}', simulate is '${simulate}'`);
|
|
48
|
-
await
|
|
49
|
-
const appType = await
|
|
45
|
+
await validateBasePath(basePath);
|
|
46
|
+
const appType = await getAppType(basePath);
|
|
50
47
|
const isAdp = appType === 'Fiori Adaptation';
|
|
51
|
-
const fs =
|
|
48
|
+
const fs = create(createStorage());
|
|
52
49
|
let variant;
|
|
53
50
|
if (!isAdp) {
|
|
54
51
|
variant = { isAdp: false, content: undefined };
|
|
55
52
|
}
|
|
56
53
|
else {
|
|
57
|
-
variant = { isAdp: true, content: await
|
|
54
|
+
variant = { isAdp: true, content: await getVariant(basePath, fs) };
|
|
58
55
|
}
|
|
59
56
|
const inbounds = await getInbounds(basePath, yamlPath, fs, logger, variant);
|
|
60
57
|
let tileSettingsAnswers;
|
|
61
58
|
if (inbounds && isAdp) {
|
|
62
|
-
tileSettingsAnswers = await
|
|
59
|
+
tileSettingsAnswers = await promptYUIQuestions(getTileSettingsQuestions(inbounds), false);
|
|
63
60
|
}
|
|
64
61
|
const answers = await getUserAnswers(inbounds, isAdp, tileSettingsAnswers);
|
|
65
|
-
if (!answers && tileSettingsAnswers?.tileHandlingAction !==
|
|
62
|
+
if (!answers && tileSettingsAnswers?.tileHandlingAction !== tileActions.REPLACE) {
|
|
66
63
|
logger.info('User chose not to overwrite existing inbound navigation configuration.');
|
|
67
64
|
return;
|
|
68
65
|
}
|
|
@@ -74,7 +71,7 @@ async function addInboundNavigationConfig(basePath, simulate, yamlPath) {
|
|
|
74
71
|
fs.commit(() => logger.info(`Inbound navigation configuration complete.`));
|
|
75
72
|
}
|
|
76
73
|
else {
|
|
77
|
-
await
|
|
74
|
+
await traceChanges(fs);
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
catch (error) {
|
|
@@ -94,15 +91,15 @@ async function addInboundNavigationConfig(basePath, simulate, yamlPath) {
|
|
|
94
91
|
*/
|
|
95
92
|
async function getInbounds(basePath, yamlPath, fs, logger, variant) {
|
|
96
93
|
if (variant.isAdp) {
|
|
97
|
-
if (await
|
|
94
|
+
if (await isCFEnvironment(basePath)) {
|
|
98
95
|
return getCfInbounds(basePath, variant.content, logger);
|
|
99
96
|
}
|
|
100
|
-
const { target, ignoreCertErrors = false } = await
|
|
101
|
-
const provider = await
|
|
102
|
-
return
|
|
97
|
+
const { target, ignoreCertErrors = false } = await getAdpConfig(basePath, yamlPath);
|
|
98
|
+
const provider = await createAbapServiceProvider(target, { ignoreCertErrors }, true, logger);
|
|
99
|
+
return getBaseAppInbounds(variant.content.reference, provider);
|
|
103
100
|
}
|
|
104
101
|
const manifest = await retrieveManifest(basePath, fs);
|
|
105
|
-
return
|
|
102
|
+
return getInboundsFromManifest(manifest);
|
|
106
103
|
}
|
|
107
104
|
/**
|
|
108
105
|
* Retrieves the inbounds for a CF adaptation project using the FDC service.
|
|
@@ -113,15 +110,15 @@ async function getInbounds(basePath, yamlPath, fs, logger, variant) {
|
|
|
113
110
|
* @returns The inbounds from the FDC service.
|
|
114
111
|
*/
|
|
115
112
|
async function getCfInbounds(basePath, variant, logger) {
|
|
116
|
-
const cfConfig =
|
|
113
|
+
const cfConfig = loadCfConfig(logger);
|
|
117
114
|
if (!cfConfig?.token) {
|
|
118
115
|
throw new Error('CF login required. Please run "cf login" and try again.');
|
|
119
116
|
}
|
|
120
|
-
const appParams =
|
|
117
|
+
const appParams = getAppParamsFromUI5Yaml(basePath);
|
|
121
118
|
if (!appParams.appHostId) {
|
|
122
119
|
throw new Error('Could not determine appHostId from project ui5.yaml configuration.');
|
|
123
120
|
}
|
|
124
|
-
return
|
|
121
|
+
return getCfBaseAppInbounds(variant.reference, appParams.appHostId, cfConfig, logger);
|
|
125
122
|
}
|
|
126
123
|
/**
|
|
127
124
|
* Retrieves the manifest for a Fiori project.
|
|
@@ -131,7 +128,7 @@ async function getCfInbounds(basePath, variant, logger) {
|
|
|
131
128
|
* @returns {Promise<Manifest>} The base project manifest.
|
|
132
129
|
*/
|
|
133
130
|
async function retrieveManifest(basePath, fs) {
|
|
134
|
-
const { manifest } = await
|
|
131
|
+
const { manifest } = await readManifest(basePath, fs);
|
|
135
132
|
return manifest;
|
|
136
133
|
}
|
|
137
134
|
/**
|
|
@@ -153,10 +150,10 @@ async function getUserAnswers(inbounds, isAdp, tileSettingsAnswers) {
|
|
|
153
150
|
};
|
|
154
151
|
}
|
|
155
152
|
else {
|
|
156
|
-
promptOptions =
|
|
153
|
+
promptOptions = getAdpFlpConfigPromptOptions(tileSettingsAnswers, inbounds);
|
|
157
154
|
}
|
|
158
|
-
const prompts = await
|
|
159
|
-
const config = await
|
|
155
|
+
const prompts = await filterLabelTypeQuestions(await getPrompts(inbounds, promptOptions));
|
|
156
|
+
const config = await promptYUIQuestions(prompts, false);
|
|
160
157
|
if (config?.subTitle === '') {
|
|
161
158
|
config.subTitle = undefined;
|
|
162
159
|
}
|
|
@@ -177,11 +174,11 @@ async function getUserAnswers(inbounds, isAdp, tileSettingsAnswers) {
|
|
|
177
174
|
async function generateConfig(basePath, answers, variant, fs, inbounds) {
|
|
178
175
|
const { flpConfigAnswers, tileSettingsAnswers } = answers;
|
|
179
176
|
if (variant.isAdp) {
|
|
180
|
-
const config =
|
|
181
|
-
await
|
|
177
|
+
const config = getAdpFlpInboundsWriterConfig(flpConfigAnswers, variant.content.layer, tileSettingsAnswers, inbounds);
|
|
178
|
+
await generateInboundConfig(basePath, config, fs);
|
|
182
179
|
}
|
|
183
180
|
else {
|
|
184
|
-
await
|
|
181
|
+
await generateInboundNavigationConfig(basePath, flpConfigAnswers, true, fs);
|
|
185
182
|
}
|
|
186
183
|
}
|
|
187
184
|
//# sourceMappingURL=navigation-config.js.map
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const common_1 = require("../../common");
|
|
6
|
-
const tracing_1 = require("../../tracing");
|
|
7
|
-
const validation_1 = require("../../validation/validation");
|
|
1
|
+
import { generateChange, ChangeType, getPromptsForNewModel, getVariant, createNewModelData } from '@sap-ux/adp-tooling';
|
|
2
|
+
import { promptYUIQuestions } from '../../common/index.js';
|
|
3
|
+
import { getLogger, traceChanges } from '../../tracing/index.js';
|
|
4
|
+
import { validateAdpAppType } from '../../validation/index.js';
|
|
8
5
|
/**
|
|
9
6
|
* Add a new sub-command to add new odata service and new sapui5 model of an adaptation project to the given command.
|
|
10
7
|
*
|
|
11
8
|
* @param {Command} cmd - The command to add the model sub-command to.
|
|
12
9
|
*/
|
|
13
|
-
function addNewModelCommand(cmd) {
|
|
10
|
+
export function addNewModelCommand(cmd) {
|
|
14
11
|
cmd.command('model [path]')
|
|
15
12
|
.description(`Add a new OData service and SAPUI5 model to an existing adaptation project.\n
|
|
16
13
|
Example:
|
|
@@ -27,20 +24,20 @@ Example:
|
|
|
27
24
|
* @param {boolean} simulate - If set to true, then no files will be written to the filesystem.
|
|
28
25
|
*/
|
|
29
26
|
async function addNewModel(basePath, simulate) {
|
|
30
|
-
const logger =
|
|
27
|
+
const logger = getLogger();
|
|
31
28
|
try {
|
|
32
29
|
if (!basePath) {
|
|
33
30
|
basePath = process.cwd();
|
|
34
31
|
}
|
|
35
|
-
await
|
|
36
|
-
const variant = await
|
|
37
|
-
const answers = await
|
|
38
|
-
const fs = await
|
|
32
|
+
await validateAdpAppType(basePath);
|
|
33
|
+
const variant = await getVariant(basePath);
|
|
34
|
+
const answers = await promptYUIQuestions(await getPromptsForNewModel(basePath, variant.layer, logger), false);
|
|
35
|
+
const fs = await generateChange(basePath, ChangeType.ADD_NEW_MODEL, await createNewModelData(basePath, variant, answers, logger));
|
|
39
36
|
if (!simulate) {
|
|
40
37
|
await new Promise((resolve) => fs.commit(resolve));
|
|
41
38
|
}
|
|
42
39
|
else {
|
|
43
|
-
await
|
|
40
|
+
await traceChanges(fs);
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
catch (error) {
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const app_config_writer_1 = require("@sap-ux/app-config-writer");
|
|
5
|
-
const tracing_1 = require("../../tracing");
|
|
6
|
-
const validation_1 = require("../../validation");
|
|
1
|
+
import { generateSmartLinksConfig, getSmartLinksTargetFromPrompt } from '@sap-ux/app-config-writer';
|
|
2
|
+
import { getLogger, traceChanges, setLogLevelVerbose } from '../../tracing/index.js';
|
|
3
|
+
import { validateBasePath } from '../../validation/index.js';
|
|
7
4
|
/**
|
|
8
5
|
* Add the "add smartlinks config" command to a passed command.
|
|
9
6
|
*
|
|
10
7
|
* @param cmd - commander command for adding smartlinks config command
|
|
11
8
|
*/
|
|
12
|
-
function addAddSmartLinksConfigCommand(cmd) {
|
|
9
|
+
export function addAddSmartLinksConfigCommand(cmd) {
|
|
13
10
|
cmd.command('smartlinks-config [path]')
|
|
14
11
|
.description(`Add a \`smartLinks\` configuration to a project for cross-app navigation.\n
|
|
15
12
|
Example:
|
|
@@ -18,7 +15,7 @@ Example:
|
|
|
18
15
|
.option('-v, --verbose', 'Show verbose information.')
|
|
19
16
|
.action(async (path, options) => {
|
|
20
17
|
if (options.verbose === true || options.simulate) {
|
|
21
|
-
|
|
18
|
+
setLogLevelVerbose();
|
|
22
19
|
}
|
|
23
20
|
await addSmartLinksConfig(path || process.cwd(), !!options.simulate);
|
|
24
21
|
});
|
|
@@ -30,13 +27,13 @@ Example:
|
|
|
30
27
|
* @param simulate - if true, do not write but just show what would be changed; otherwise write
|
|
31
28
|
*/
|
|
32
29
|
async function addSmartLinksConfig(basePath, simulate) {
|
|
33
|
-
const logger =
|
|
30
|
+
const logger = getLogger();
|
|
34
31
|
try {
|
|
35
32
|
logger.debug(`Called add smartlinks-config for path '${basePath}', simulate is '${simulate}'`);
|
|
36
|
-
await
|
|
37
|
-
const config = await
|
|
38
|
-
const fs = await
|
|
39
|
-
await
|
|
33
|
+
await validateBasePath(basePath);
|
|
34
|
+
const config = await getSmartLinksTargetFromPrompt(basePath, logger);
|
|
35
|
+
const fs = await generateSmartLinksConfig(basePath, config, logger);
|
|
36
|
+
await traceChanges(fs);
|
|
40
37
|
if (!simulate) {
|
|
41
38
|
fs.commit(() => logger.info(`SmartLinks configuration written.`));
|
|
42
39
|
}
|
package/dist/cli/add/system.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
7
|
-
const dotenv_1 = require("dotenv");
|
|
8
|
-
const tracing_1 = require("../../tracing");
|
|
1
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
2
|
+
import { getService, BackendSystem, BackendSystemKey, SystemType, AuthenticationType, ConnectionType } from '@sap-ux/store';
|
|
3
|
+
import { replaceEnvVariables } from '@sap-ux/ui5-config';
|
|
4
|
+
import { config as loadEnvConfig } from 'dotenv';
|
|
5
|
+
import { getLogger } from '../../tracing/index.js';
|
|
9
6
|
/**
|
|
10
7
|
* Add the "add system" subcommand to a passed command.
|
|
11
8
|
* Adds a new backend system to the saved systems store (~/.fioritools).
|
|
@@ -13,25 +10,25 @@ const tracing_1 = require("../../tracing");
|
|
|
13
10
|
*
|
|
14
11
|
* @param cmd - commander command to attach the system subcommand to
|
|
15
12
|
*/
|
|
16
|
-
function addSystemAddCommand(cmd) {
|
|
13
|
+
export function addSystemAddCommand(cmd) {
|
|
17
14
|
cmd.command('system')
|
|
18
15
|
.description(`Add a new back-end system to the saved systems store (\`~/.fioritools\`). Credentials are stored securely in the OS keychain.\n
|
|
19
|
-
System types: \`${Object.values(
|
|
20
|
-
Auth types: \`${Object.values(
|
|
21
|
-
Connection types: \`${Object.values(
|
|
16
|
+
System types: \`${Object.values(SystemType).join('`, `')}\`
|
|
17
|
+
Auth types: \`${Object.values(AuthenticationType).join('`, `')}\`
|
|
18
|
+
Connection types: \`${Object.values(ConnectionType).join('`, `')}\`\n
|
|
22
19
|
Example:
|
|
23
20
|
\`npx --yes @sap-ux/create@latest add system --name "My System" --url https://my-sap.example.com\`
|
|
24
21
|
\`npx --yes @sap-ux/create@latest add system --name "My System" --url https://my-sap.example.com --client 100 --username myuser\``)
|
|
25
22
|
.requiredOption('--name <string>', 'Display name for the system')
|
|
26
23
|
.requiredOption('--url <string>', 'URL of the backend system')
|
|
27
24
|
.option('--client <string>', 'SAP client number (optional)')
|
|
28
|
-
.option('--type <string>', `System type (${Object.values(
|
|
29
|
-
.option('--auth <string>', `Authentication type (${Object.values(
|
|
30
|
-
.option('--connection-type <string>', `Connection type (${Object.values(
|
|
25
|
+
.option('--type <string>', `System type (${Object.values(SystemType).join(' | ')})`, SystemType.AbapOnPrem)
|
|
26
|
+
.option('--auth <string>', `Authentication type (${Object.values(AuthenticationType).join(' | ')})`, AuthenticationType.Basic)
|
|
27
|
+
.option('--connection-type <string>', `Connection type (${Object.values(ConnectionType).join(' | ')})`, ConnectionType.AbapCatalog)
|
|
31
28
|
.option('--username <string>', 'Username for basic authentication')
|
|
32
29
|
.option('--password <string>', "To avoid plain-text credentials in the shell's history, pass an env reference: --password env:MY_VAR")
|
|
33
30
|
.action(async (options) => {
|
|
34
|
-
(
|
|
31
|
+
loadEnvConfig();
|
|
35
32
|
await addSystem({
|
|
36
33
|
name: options.name,
|
|
37
34
|
url: options.url,
|
|
@@ -58,9 +55,9 @@ Example:
|
|
|
58
55
|
* @param params.password - optional password for basic auth
|
|
59
56
|
*/
|
|
60
57
|
async function addSystem(params) {
|
|
61
|
-
const logger =
|
|
58
|
+
const logger = getLogger();
|
|
62
59
|
try {
|
|
63
|
-
if (
|
|
60
|
+
if (isAppStudio()) {
|
|
64
61
|
logger.error('System management using the CLI is not supported in SAP Business Application Studio. Use the built-in system management instead.');
|
|
65
62
|
return;
|
|
66
63
|
}
|
|
@@ -71,30 +68,30 @@ async function addSystem(params) {
|
|
|
71
68
|
logger.error(`Invalid URL: '${params.url}'`);
|
|
72
69
|
return;
|
|
73
70
|
}
|
|
74
|
-
const validSystemTypes = Object.values(
|
|
71
|
+
const validSystemTypes = Object.values(SystemType);
|
|
75
72
|
if (!validSystemTypes.includes(params.systemType)) {
|
|
76
73
|
logger.error(`Invalid system type '${params.systemType}'. Valid values: ${validSystemTypes.join(', ')}`);
|
|
77
74
|
return;
|
|
78
75
|
}
|
|
79
|
-
const validAuthTypes = Object.values(
|
|
76
|
+
const validAuthTypes = Object.values(AuthenticationType);
|
|
80
77
|
if (!validAuthTypes.includes(params.authenticationType)) {
|
|
81
78
|
logger.error(`Invalid auth type '${params.authenticationType}'. Valid values: ${validAuthTypes.join(', ')}`);
|
|
82
79
|
return;
|
|
83
80
|
}
|
|
84
|
-
const validConnectionTypes = Object.values(
|
|
81
|
+
const validConnectionTypes = Object.values(ConnectionType);
|
|
85
82
|
if (!validConnectionTypes.includes(params.connectionType)) {
|
|
86
83
|
logger.error(`Invalid connection type '${params.connectionType}'. Valid values: ${validConnectionTypes.join(', ')}`);
|
|
87
84
|
return;
|
|
88
85
|
}
|
|
89
|
-
const service = await
|
|
90
|
-
const existingSystem = await service.read(new
|
|
86
|
+
const service = await getService({ entityName: 'system' });
|
|
87
|
+
const existingSystem = await service.read(new BackendSystemKey({ url: params.url, client: params.client }));
|
|
91
88
|
if (existingSystem) {
|
|
92
89
|
const clientSuffix = params.client ? ` (client ${params.client})` : '';
|
|
93
90
|
logger.error(`System '${params.url}'${clientSuffix} already exists. Use 'change system' to update it.`);
|
|
94
91
|
return;
|
|
95
92
|
}
|
|
96
|
-
|
|
97
|
-
const system = new
|
|
93
|
+
replaceEnvVariables(params);
|
|
94
|
+
const system = new BackendSystem({
|
|
98
95
|
name: params.name,
|
|
99
96
|
url: params.url,
|
|
100
97
|
client: params.client,
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const app_config_writer_1 = require("@sap-ux/app-config-writer");
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
1
|
+
import { getLogger, traceChanges, setLogLevelVerbose } from '../../tracing/index.js';
|
|
2
|
+
import { validateBasePath } from '../../validation/index.js';
|
|
3
|
+
import { generateVariantsConfig } from '@sap-ux/app-config-writer';
|
|
4
|
+
import { isAbsolute, join } from 'node:path';
|
|
5
|
+
import { FileName } from '@sap-ux/project-access';
|
|
9
6
|
/**
|
|
10
7
|
* Add the "add variants config" command to a passed command.
|
|
11
8
|
*
|
|
12
9
|
* @param cmd - commander command for adding variants config command
|
|
13
10
|
*/
|
|
14
|
-
function addAddVariantsConfigCommand(cmd) {
|
|
11
|
+
export function addAddVariantsConfigCommand(cmd) {
|
|
15
12
|
cmd.command('variants-config [path]')
|
|
16
13
|
.description(`Add the necessary configuration to an existing YAML file and the script to the \`package.json\` file for variants creation. It uses the configuration from the YAML file passed by the CLI or default to \`ui5.yaml\`, as provided by the \`fiori-tools-preview\` or \`preview-middleware\`.\n
|
|
17
14
|
Example:
|
|
18
15
|
\`npx --yes @sap-ux/create@latest add variants-config\``)
|
|
19
|
-
.option('-c, --config <string>', 'Path to the project configuration file in YAML format.',
|
|
16
|
+
.option('-c, --config <string>', 'Path to the project configuration file in YAML format.', FileName.Ui5Yaml)
|
|
20
17
|
.option('-s, --simulate', 'Simulate only. Do not write to the config file. Also, sets `--verbose`')
|
|
21
18
|
.option('-v, --verbose', 'Show verbose information.')
|
|
22
19
|
.action(async (path, options) => {
|
|
23
20
|
if (options.verbose === true || options.simulate) {
|
|
24
|
-
|
|
21
|
+
setLogLevelVerbose();
|
|
25
22
|
}
|
|
26
23
|
await addVariantsConfig(path || process.cwd(), !!options.simulate, options.config);
|
|
27
24
|
});
|
|
@@ -35,17 +32,17 @@ Example:
|
|
|
35
32
|
* @param yamlPath - path to the ui5*.yaml file passed by cli
|
|
36
33
|
*/
|
|
37
34
|
async function addVariantsConfig(basePath, simulate, yamlPath) {
|
|
38
|
-
const logger =
|
|
35
|
+
const logger = getLogger();
|
|
39
36
|
try {
|
|
40
37
|
logger.debug(`Called add variants-config for path '${basePath}', simulate is '${simulate}'`);
|
|
41
|
-
const ui5ConfigPath =
|
|
42
|
-
await
|
|
43
|
-
const fs = await
|
|
38
|
+
const ui5ConfigPath = isAbsolute(yamlPath) ? yamlPath : join(basePath, yamlPath);
|
|
39
|
+
await validateBasePath(basePath, ui5ConfigPath);
|
|
40
|
+
const fs = await generateVariantsConfig(basePath, ui5ConfigPath, logger);
|
|
44
41
|
if (!simulate) {
|
|
45
42
|
fs.commit(() => logger.info(`Variants configuration written.`));
|
|
46
43
|
}
|
|
47
44
|
else {
|
|
48
|
-
await
|
|
45
|
+
await traceChanges(fs);
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
catch (error) {
|