@sap-ux/app-config-writer 0.7.6 → 1.0.0

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.
Files changed (46) hide show
  1. package/dist/cards-config/index.js +19 -22
  2. package/dist/common/package-json.js +19 -30
  3. package/dist/common/ui5-yaml.d.ts +2 -2
  4. package/dist/common/ui5-yaml.js +37 -48
  5. package/dist/common/utils.d.ts +1 -1
  6. package/dist/common/utils.js +13 -20
  7. package/dist/eslint-config/add.js +13 -16
  8. package/dist/eslint-config/convert.js +29 -35
  9. package/dist/eslint-config/index.d.ts +2 -2
  10. package/dist/eslint-config/index.js +2 -7
  11. package/dist/flp-embedded-config/index.js +11 -15
  12. package/dist/i18n.js +15 -25
  13. package/dist/index.d.ts +8 -8
  14. package/dist/index.js +8 -24
  15. package/dist/navigation-config/index.js +14 -18
  16. package/dist/preview-config/index.js +15 -18
  17. package/dist/preview-config/package-json.js +12 -16
  18. package/dist/preview-config/prerequisites.js +14 -17
  19. package/dist/preview-config/preview-files.js +28 -34
  20. package/dist/preview-config/ui5-yaml.d.ts +1 -1
  21. package/dist/preview-config/ui5-yaml.js +35 -40
  22. package/dist/prompt/index.d.ts +2 -2
  23. package/dist/prompt/index.js +2 -21
  24. package/dist/prompt/preview-config.js +6 -9
  25. package/dist/prompt/smartlinks-config.d.ts +1 -1
  26. package/dist/prompt/smartlinks-config.js +46 -49
  27. package/dist/smartlinks-config/generateSmartLinks.d.ts +1 -1
  28. package/dist/smartlinks-config/generateSmartLinks.js +6 -9
  29. package/dist/smartlinks-config/index.d.ts +2 -2
  30. package/dist/smartlinks-config/index.js +2 -21
  31. package/dist/smartlinks-config/ui5-yaml.d.ts +1 -1
  32. package/dist/smartlinks-config/ui5-yaml.js +14 -18
  33. package/dist/smartlinks-config/utils.d.ts +1 -1
  34. package/dist/smartlinks-config/utils.js +33 -40
  35. package/dist/templates.js +5 -6
  36. package/dist/types/index.d.ts +3 -3
  37. package/dist/types/index.js +3 -19
  38. package/dist/types/navigation.js +1 -2
  39. package/dist/types/smartLinks.js +4 -7
  40. package/dist/types/variantsConfig.js +2 -5
  41. package/dist/variants-config/generateVariantsConfig.js +8 -11
  42. package/dist/variants-config/index.d.ts +1 -1
  43. package/dist/variants-config/index.js +1 -17
  44. package/dist/variants-config/package-json.js +10 -13
  45. package/dist/variants-config/utils.js +13 -17
  46. package/package.json +13 -11
@@ -1,13 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameSandbox = renameSandbox;
4
- exports.renameDefaultSandboxes = renameDefaultSandboxes;
5
- exports.renameDefaultTestFiles = renameDefaultTestFiles;
6
- exports.deleteNoLongerUsedFiles = deleteNoLongerUsedFiles;
7
- const node_path_1 = require("node:path");
8
- const project_access_1 = require("@sap-ux/project-access");
9
- const ui5_yaml_1 = require("../common/ui5-yaml");
10
- const utils_1 = require("../common/utils");
1
+ import { join } from 'node:path';
2
+ import { getWebappPath } from '@sap-ux/project-access';
3
+ import { TEST_CONFIG_DEFAULTS } from '../common/ui5-yaml.js';
4
+ import { deleteFiles } from '../common/utils.js';
11
5
  const renameMessage = (filePath) => `Renamed '${filePath}' to '${filePath.slice(0, -5)}_old.html'. This file is no longer needed for the virtual endpoints. If you have not modified this file, you can delete it. If you have modified this file, move the modified content to a custom init script for the preview middleware. For more information, see https://github.com/SAP/open-ux-tools/tree/main/packages/preview-middleware#migration.`;
12
6
  /**
13
7
  * Renames the sandbox file which is used in a given script.
@@ -19,8 +13,8 @@ const renameMessage = (filePath) => `Renamed '${filePath}' to '${filePath.slice(
19
13
  * @param path - file path to be used for the renaming
20
14
  * @param logger logger to report info to the user
21
15
  */
22
- async function renameSandbox(fs, basePath, path, logger) {
23
- const filePath = (0, node_path_1.join)(await (0, project_access_1.getWebappPath)(basePath), path);
16
+ export async function renameSandbox(fs, basePath, path, logger) {
17
+ const filePath = join(await getWebappPath(basePath), path);
24
18
  if (fs.exists(filePath)) {
25
19
  if (path.endsWith('unitTests.qunit.html')) {
26
20
  logger?.warn(`Unit test files will be discovered automatically using the default pattern '/test/**/*Test.{js,ts}'. If your unit test files do not match this pattern, add a 'pattern' property to the QUnit test entry in your UI5 YAML configuration (e.g. pattern: '/test/unit/controller/*.{js,ts}'). For more details see https://github.com/SAP/open-ux-tools/blob/main/packages/preview-middleware/README.md#configuration-option-test`);
@@ -49,8 +43,8 @@ async function renameSandbox(fs, basePath, path, logger) {
49
43
  * @param basePath - base path to be used for the conversion
50
44
  * @param logger logger to report info to the user
51
45
  */
52
- async function renameDefaultSandboxes(fs, basePath, logger) {
53
- const defaultSandboxPaths = [(0, node_path_1.join)('test', 'flpSandbox.html'), (0, node_path_1.join)('test', 'flpSandboxMockserver.html')];
46
+ export async function renameDefaultSandboxes(fs, basePath, logger) {
47
+ const defaultSandboxPaths = [join('test', 'flpSandbox.html'), join('test', 'flpSandboxMockserver.html')];
54
48
  for (const path of defaultSandboxPaths) {
55
49
  await renameSandbox(fs, basePath, path, logger);
56
50
  }
@@ -64,8 +58,8 @@ async function renameDefaultSandboxes(fs, basePath, logger) {
64
58
  * @param basePath - base path to be used for the conversion
65
59
  * @param logger logger to report info to the user
66
60
  */
67
- async function renameDefaultTestFiles(fs, basePath, logger) {
68
- for (const path of Object.values(ui5_yaml_1.TEST_CONFIG_DEFAULTS).map((config) => config.path)) {
61
+ export async function renameDefaultTestFiles(fs, basePath, logger) {
62
+ for (const path of Object.values(TEST_CONFIG_DEFAULTS).map((config) => config.path)) {
69
63
  await renameSandbox(fs, basePath, path, logger);
70
64
  }
71
65
  }
@@ -77,27 +71,27 @@ async function renameDefaultTestFiles(fs, basePath, logger) {
77
71
  * @param convertTests - indicator if test suite and test runner should be included in the conversion
78
72
  * @param logger logger to report info to the user
79
73
  */
80
- async function deleteNoLongerUsedFiles(fs, basePath, convertTests, logger) {
81
- const webappTestPath = (0, node_path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), 'test');
74
+ export async function deleteNoLongerUsedFiles(fs, basePath, convertTests, logger) {
75
+ const webappTestPath = join(await getWebappPath(basePath, fs), 'test');
82
76
  const files = [
83
- (0, node_path_1.join)(webappTestPath, 'locate-reuse-libs.js'),
84
- (0, node_path_1.join)(webappTestPath, 'changes_loader.js'),
85
- (0, node_path_1.join)(webappTestPath, 'changes_loader.ts'),
86
- (0, node_path_1.join)(webappTestPath, 'changes_preview.js'),
87
- (0, node_path_1.join)(webappTestPath, 'changes_preview.ts'),
88
- (0, node_path_1.join)(webappTestPath, 'flpSandbox.js'),
89
- (0, node_path_1.join)(webappTestPath, 'flpSandbox.ts'),
90
- (0, node_path_1.join)(webappTestPath, 'initFlpSandbox.js'),
91
- (0, node_path_1.join)(webappTestPath, 'initFlpSandbox.ts')
77
+ join(webappTestPath, 'locate-reuse-libs.js'),
78
+ join(webappTestPath, 'changes_loader.js'),
79
+ join(webappTestPath, 'changes_loader.ts'),
80
+ join(webappTestPath, 'changes_preview.js'),
81
+ join(webappTestPath, 'changes_preview.ts'),
82
+ join(webappTestPath, 'flpSandbox.js'),
83
+ join(webappTestPath, 'flpSandbox.ts'),
84
+ join(webappTestPath, 'initFlpSandbox.js'),
85
+ join(webappTestPath, 'initFlpSandbox.ts')
92
86
  ];
93
87
  if (convertTests) {
94
- files.push((0, node_path_1.join)(webappTestPath, 'testsuite.qunit.js'));
95
- files.push((0, node_path_1.join)(webappTestPath, 'testsuite.qunit.ts'));
96
- files.push((0, node_path_1.join)(webappTestPath, 'integration', 'opaTests.qunit.js'));
97
- files.push((0, node_path_1.join)(webappTestPath, 'integration', 'opaTests.qunit.ts'));
98
- files.push((0, node_path_1.join)(webappTestPath, 'unit', 'unitTests.qunit.js'));
99
- files.push((0, node_path_1.join)(webappTestPath, 'unit', 'unitTests.qunit.ts'));
88
+ files.push(join(webappTestPath, 'testsuite.qunit.js'));
89
+ files.push(join(webappTestPath, 'testsuite.qunit.ts'));
90
+ files.push(join(webappTestPath, 'integration', 'opaTests.qunit.js'));
91
+ files.push(join(webappTestPath, 'integration', 'opaTests.qunit.ts'));
92
+ files.push(join(webappTestPath, 'unit', 'unitTests.qunit.js'));
93
+ files.push(join(webappTestPath, 'unit', 'unitTests.qunit.ts'));
100
94
  }
101
- await (0, utils_1.deleteFiles)(fs, files, logger);
95
+ await deleteFiles(fs, files, logger);
102
96
  }
103
97
  //# sourceMappingURL=preview-files.js.map
@@ -1,4 +1,4 @@
1
- import { type Script } from '../common/package-json';
1
+ import { type Script } from '../common/package-json.js';
2
2
  import type { Editor } from 'mem-fs-editor';
3
3
  import type { ToolsLogger } from '@sap-ux/logger';
4
4
  /**
@@ -1,15 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processUi5YamlConfig = processUi5YamlConfig;
4
- exports.updateDefaultTestConfig = updateDefaultTestConfig;
5
- exports.updatePreviewMiddlewareConfigs = updatePreviewMiddlewareConfigs;
6
- const node_path_1 = require("node:path");
7
- const ui5_yaml_1 = require("../common/ui5-yaml");
8
- const package_json_1 = require("./package-json");
9
- const project_access_1 = require("@sap-ux/project-access");
10
- const utils_1 = require("../common/utils");
11
- const package_json_2 = require("../common/package-json");
12
- const preview_files_1 = require("./preview-files");
1
+ import { basename, join } from 'node:path';
2
+ import { createPreviewMiddlewareConfig, updatePreviewMiddlewareConfig, updateTestConfig, DEFAULT_FLP_PATH, TEST_CONFIG_DEFAULTS } from '../common/ui5-yaml.js';
3
+ import { ensurePreviewMiddlewareDependency } from './package-json.js';
4
+ import { FileName, getAllUi5YamlFileNames, readUi5Yaml } from '@sap-ux/project-access';
5
+ import { getPreviewMiddleware } from '../common/utils.js';
6
+ import { extractUrlDetails, isValidPreviewScript, extractYamlConfigFileName, isTestPath, getScriptsFromPackageJson } from '../common/package-json.js';
7
+ import { renameSandbox } from './preview-files.js';
13
8
  /**
14
9
  * Checks if a script can be converted based on the used UI5 yaml configuration file.
15
10
  *
@@ -45,11 +40,11 @@ async function isUi5YamlFlpPathAlreadyConverted(fs, basePath, ui5Yaml, script, c
45
40
  const yamlConfigAlreadyAdjusted = Object.keys(fs.dump(basePath, (file) => {
46
41
  return file.basename === ui5Yaml && file.state === 'modified';
47
42
  })).length > 0;
48
- const flpPath = (await (0, utils_1.getPreviewMiddleware)(undefined, basePath, ui5Yaml, fs))
43
+ const flpPath = (await getPreviewMiddleware(undefined, basePath, ui5Yaml, fs))
49
44
  ?.configuration?.flp?.path;
50
- const { path: scriptPath } = (0, package_json_2.extractUrlDetails)(script.value);
51
- if (yamlConfigAlreadyAdjusted && flpPath != scriptPath && (convertTests ? !(0, package_json_2.isTestPath)(script) : true)) {
52
- logger?.warn(`Skipping script '${script.name}', because another script also refers to UI5 YAML configuration file, '${ui5Yaml}'. Adjust the 'flp.path' property in the UI5 YAML configuration file to the correct endpoint or create a separate UI5 YAML configuration file for script '${script.name}'. ${ui5Yaml} currently uses ${flpPath ?? ui5_yaml_1.DEFAULT_FLP_PATH} whereas script '${script.name}' uses '${scriptPath}'.`);
45
+ const { path: scriptPath } = extractUrlDetails(script.value);
46
+ if (yamlConfigAlreadyAdjusted && flpPath != scriptPath && (convertTests ? !isTestPath(script) : true)) {
47
+ logger?.warn(`Skipping script '${script.name}', because another script also refers to UI5 YAML configuration file, '${ui5Yaml}'. Adjust the 'flp.path' property in the UI5 YAML configuration file to the correct endpoint or create a separate UI5 YAML configuration file for script '${script.name}'. ${ui5Yaml} currently uses ${flpPath ?? DEFAULT_FLP_PATH} whereas script '${script.name}' uses '${scriptPath}'.`);
53
48
  return true;
54
49
  }
55
50
  return false;
@@ -67,24 +62,24 @@ async function isUi5YamlFlpPathAlreadyConverted(fs, basePath, ui5Yaml, script, c
67
62
  * @param logger logger to report info to the user
68
63
  * @param skipPreviewMiddlewareCreation - (default: false) indicator if the preview middleware creation should be skipped if no preview middleware is configured.
69
64
  */
70
- async function processUi5YamlConfig(fs, basePath, ui5Yaml, script, logger, skipPreviewMiddlewareCreation = false) {
65
+ export async function processUi5YamlConfig(fs, basePath, ui5Yaml, script, logger, skipPreviewMiddlewareCreation = false) {
71
66
  let ui5YamlConfig;
72
67
  try {
73
- ui5YamlConfig = await (0, project_access_1.readUi5Yaml)(basePath, ui5Yaml, fs, { validateSchema: true });
68
+ ui5YamlConfig = await readUi5Yaml(basePath, ui5Yaml, fs, { validateSchema: true });
74
69
  }
75
70
  catch (error) {
76
71
  throw new Error(`An error occurred when reading '${ui5Yaml}': ${error.message}`);
77
72
  }
78
- let previewMiddleware = await (0, utils_1.getPreviewMiddleware)(ui5YamlConfig);
73
+ let previewMiddleware = await getPreviewMiddleware(ui5YamlConfig);
79
74
  if (skipPreviewMiddlewareCreation && !previewMiddleware) {
80
75
  return;
81
76
  }
82
77
  if (!previewMiddleware) {
83
- previewMiddleware = (0, ui5_yaml_1.createPreviewMiddlewareConfig)(fs, basePath);
78
+ previewMiddleware = createPreviewMiddlewareConfig(fs, basePath);
84
79
  }
85
- previewMiddleware = await (0, ui5_yaml_1.updatePreviewMiddlewareConfig)(previewMiddleware, script, basePath, fs, logger);
80
+ previewMiddleware = await updatePreviewMiddlewareConfig(previewMiddleware, script, basePath, fs, logger);
86
81
  ui5YamlConfig.updateCustomMiddleware(previewMiddleware);
87
- const yamlPath = (0, node_path_1.join)(basePath, ui5Yaml);
82
+ const yamlPath = join(basePath, ui5Yaml);
88
83
  fs.write(yamlPath, ui5YamlConfig.toString());
89
84
  }
90
85
  /**
@@ -94,34 +89,34 @@ async function processUi5YamlConfig(fs, basePath, ui5Yaml, script, logger, skipP
94
89
  * @param basePath - base path to be used for the conversion
95
90
  * @param logger logger to report info to the user
96
91
  */
97
- async function updateDefaultTestConfig(fs, basePath, logger) {
98
- const ui5YamlFileNames = await (0, project_access_1.getAllUi5YamlFileNames)(basePath, fs);
99
- for (const ui5Yaml of ui5YamlFileNames.filter((ui5Yaml) => ui5Yaml !== project_access_1.FileName.Ui5Yaml)) {
100
- const ui5YamlConfig = await (0, project_access_1.readUi5Yaml)(basePath, ui5Yaml, fs);
101
- const previewMiddleware = (await (0, utils_1.getPreviewMiddleware)(ui5YamlConfig));
92
+ export async function updateDefaultTestConfig(fs, basePath, logger) {
93
+ const ui5YamlFileNames = await getAllUi5YamlFileNames(basePath, fs);
94
+ for (const ui5Yaml of ui5YamlFileNames.filter((ui5Yaml) => ui5Yaml !== FileName.Ui5Yaml)) {
95
+ const ui5YamlConfig = await readUi5Yaml(basePath, ui5Yaml, fs);
96
+ const previewMiddleware = (await getPreviewMiddleware(ui5YamlConfig));
102
97
  if (previewMiddleware?.configuration?.test) {
103
98
  return;
104
99
  }
105
100
  }
106
101
  let ui5YamlConfig;
107
102
  try {
108
- ui5YamlConfig = await (0, project_access_1.readUi5Yaml)(basePath, project_access_1.FileName.Ui5Yaml, fs);
103
+ ui5YamlConfig = await readUi5Yaml(basePath, FileName.Ui5Yaml, fs);
109
104
  }
110
105
  catch (error) {
111
106
  logger?.warn(`The UI5 YAML configuration file 'ui5.yaml', can't be updated to support test frameworks: '${error}'. Please manually add the test configuration to the UI5 YAML configuration file used for testing according to https://github.com/SAP/open-ux-tools/tree/main/packages/preview-middleware#configuration-option-test.`);
112
107
  return;
113
108
  }
114
- const previewMiddleware = (await (0, utils_1.getPreviewMiddleware)(ui5YamlConfig));
115
- for (const defaultConfig of Object.values(ui5_yaml_1.TEST_CONFIG_DEFAULTS)) {
109
+ const previewMiddleware = (await getPreviewMiddleware(ui5YamlConfig));
110
+ for (const defaultConfig of Object.values(TEST_CONFIG_DEFAULTS)) {
116
111
  if (previewMiddleware.configuration?.test?.some((testConfig) => testConfig.framework.toLowerCase() === defaultConfig.framework.toLowerCase())) {
117
112
  //do not touch existing test config
118
113
  break;
119
114
  }
120
- previewMiddleware.configuration.test = await (0, ui5_yaml_1.updateTestConfig)(previewMiddleware.configuration.test, defaultConfig.path, basePath, fs, logger);
115
+ previewMiddleware.configuration.test = await updateTestConfig(previewMiddleware.configuration.test, defaultConfig.path, basePath, fs, logger);
121
116
  logger?.info(`The UI5 YAML configuration file 'ui5.yaml', has been updated to support the test framework '${defaultConfig.framework}'. Please consider transferring the test configuration to the UI5 YAML configuration file used for testing.`);
122
117
  }
123
118
  ui5YamlConfig.updateCustomMiddleware(previewMiddleware);
124
- const yamlPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Ui5Yaml);
119
+ const yamlPath = join(basePath, FileName.Ui5Yaml);
125
120
  fs.write(yamlPath, ui5YamlConfig.toString());
126
121
  }
127
122
  /**
@@ -136,15 +131,15 @@ async function updateDefaultTestConfig(fs, basePath, logger) {
136
131
  * @param convertTests - indicator if test suite and test runner should be included in the conversion
137
132
  * @param logger logger to report info to the user
138
133
  */
139
- async function updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger) {
140
- const ui5YamlFileNames = await (0, project_access_1.getAllUi5YamlFileNames)(basePath, fs);
134
+ export async function updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger) {
135
+ const ui5YamlFileNames = await getAllUi5YamlFileNames(basePath, fs);
141
136
  const unprocessedUi5YamlFileNames = [...ui5YamlFileNames];
142
- for (const [scriptName, scriptValue] of (0, package_json_2.getScriptsFromPackageJson)(fs, basePath)) {
137
+ for (const [scriptName, scriptValue] of getScriptsFromPackageJson(fs, basePath)) {
143
138
  const script = { name: scriptName, value: scriptValue };
144
- if (!scriptValue || !(0, package_json_2.isValidPreviewScript)(script, convertTests)) {
139
+ if (!scriptValue || !isValidPreviewScript(script, convertTests)) {
145
140
  continue;
146
141
  }
147
- const ui5Yaml = (0, node_path_1.basename)((0, package_json_2.extractYamlConfigFileName)(scriptValue));
142
+ const ui5Yaml = basename(extractYamlConfigFileName(scriptValue));
148
143
  unprocessedUi5YamlFileNames.splice(unprocessedUi5YamlFileNames.indexOf(ui5Yaml), 1);
149
144
  if (!isUi5YamlToBeConverted(ui5Yaml, scriptName, ui5YamlFileNames, logger) ||
150
145
  (await isUi5YamlFlpPathAlreadyConverted(fs, basePath, ui5Yaml, script, convertTests, logger))) {
@@ -157,11 +152,11 @@ async function updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger
157
152
  logger?.warn(`Skipping script '${scriptName}', which refers to the UI5 YAML configuration file '${ui5Yaml}'. ${error.message}`);
158
153
  continue;
159
154
  }
160
- const { path } = (0, package_json_2.extractUrlDetails)(scriptValue);
155
+ const { path } = extractUrlDetails(scriptValue);
161
156
  if (path) {
162
- await (0, preview_files_1.renameSandbox)(fs, basePath, path, logger);
157
+ await renameSandbox(fs, basePath, path, logger);
163
158
  }
164
- (0, package_json_1.ensurePreviewMiddlewareDependency)(fs, basePath);
159
+ ensurePreviewMiddlewareDependency(fs, basePath);
165
160
  logger?.info(`The UI5 YAML configuration file '${ui5Yaml}', has been updated according to script, '${scriptName}'.`);
166
161
  }
167
162
  for (const ui5Yaml of unprocessedUi5YamlFileNames) {
@@ -1,3 +1,3 @@
1
- export { getSmartLinksTargetFromPrompt, promptUserPass } from './smartlinks-config';
2
- export * from './preview-config';
1
+ export { getSmartLinksTargetFromPrompt, promptUserPass } from './smartlinks-config.js';
2
+ export * from './preview-config.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,22 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.promptUserPass = exports.getSmartLinksTargetFromPrompt = void 0;
18
- var smartlinks_config_1 = require("./smartlinks-config");
19
- Object.defineProperty(exports, "getSmartLinksTargetFromPrompt", { enumerable: true, get: function () { return smartlinks_config_1.getSmartLinksTargetFromPrompt; } });
20
- Object.defineProperty(exports, "promptUserPass", { enumerable: true, get: function () { return smartlinks_config_1.promptUserPass; } });
21
- __exportStar(require("./preview-config"), exports);
1
+ export { getSmartLinksTargetFromPrompt, promptUserPass } from './smartlinks-config.js';
2
+ export * from './preview-config.js';
22
3
  //# sourceMappingURL=index.js.map
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.simulatePrompt = simulatePrompt;
4
- exports.includeTestRunnersPrompt = includeTestRunnersPrompt;
5
- const prompts_1 = require("prompts");
1
+ import prompts from 'prompts';
2
+ const { prompt } = prompts;
6
3
  /**
7
4
  * Prompt if the conversion should be done in simulation.
8
5
  *
9
6
  * @returns Indicator if the conversion should be simulated.
10
7
  */
11
- async function simulatePrompt() {
8
+ export async function simulatePrompt() {
12
9
  const PROMPT_NAME = 'simulate';
13
10
  const question = {
14
11
  type: 'confirm',
@@ -17,7 +14,7 @@ async function simulatePrompt() {
17
14
  message: `The converter renames the local HTML files, deletes the JavaScript and TypeScript files used for the existing preview functionality, and configures virtual endpoints instead.
18
15
  Do you want to simulate the conversion?`
19
16
  };
20
- const answer = (await (0, prompts_1.prompt)([question]));
17
+ const answer = (await prompt([question]));
21
18
  return (answer.simulate ?? (await Promise.reject(new Error('An error has occurred. The conversion has been canceled.')))); //in case of doubt, reject
22
19
  }
23
20
  /**
@@ -25,7 +22,7 @@ Do you want to simulate the conversion?`
25
22
  *
26
23
  * @returns Indicator if the conversion should include test runners.
27
24
  */
28
- async function includeTestRunnersPrompt() {
25
+ export async function includeTestRunnersPrompt() {
29
26
  const PROMPT_NAME = 'includeTests';
30
27
  const question = {
31
28
  type: 'confirm',
@@ -33,7 +30,7 @@ async function includeTestRunnersPrompt() {
33
30
  initial: false,
34
31
  message: 'Do you want to convert the test runners?'
35
32
  };
36
- const answer = (await (0, prompts_1.prompt)([question]));
33
+ const answer = (await prompt([question]));
37
34
  return (answer.includeTests ??
38
35
  (await Promise.reject(new Error('An error has occurred. The conversion has been canceled.')))); //in case of doubt, reject
39
36
  }
@@ -1,6 +1,6 @@
1
1
  import type { AxiosBasicCredentials } from 'axios';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
- import type { TargetConfig } from '../types';
3
+ import type { TargetConfig } from '../types/index.js';
4
4
  /**
5
5
  * Prompts the user for credentials.
6
6
  *
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptUserPass = promptUserPass;
4
- exports.getSmartLinksTargetFromPrompt = getSmartLinksTargetFromPrompt;
5
- const chalk_1 = require("chalk");
6
- const prompts_1 = require("prompts");
7
- const btp_utils_1 = require("@sap-ux/btp-utils");
8
- const project_access_1 = require("@sap-ux/project-access");
9
- const i18n_1 = require("../i18n");
10
- const smartlinks_config_1 = require("../smartlinks-config");
11
- const types_1 = require("../types");
1
+ import chalk from 'chalk';
2
+ import prompts from 'prompts';
3
+ import { isAppStudio, listDestinations } from '@sap-ux/btp-utils';
4
+ import { FileName } from '@sap-ux/project-access';
5
+ import { t } from '../i18n.js';
6
+ import { getLocalStoredCredentials, getTargetDefinition } from '../smartlinks-config/index.js';
7
+ const { prompt } = prompts;
8
+ import { TargetType } from '../types/index.js';
12
9
  /**
13
10
  * Validator helper function for prompts.
14
11
  *
@@ -18,7 +15,7 @@ const types_1 = require("../types");
18
15
  */
19
16
  const validator = (value, error) => {
20
17
  if (!value?.trim()) {
21
- return (0, i18n_1.t)(error);
18
+ return t(error);
22
19
  }
23
20
  else {
24
21
  return true;
@@ -34,8 +31,8 @@ const addAppStudioQuestions = (questions, target) => {
34
31
  // Offer existing configuration
35
32
  if (target?.destination || target?.url) {
36
33
  questions.push({
37
- name: target?.destination ? types_1.TargetType.destination : types_1.TargetType.url,
38
- message: (0, i18n_1.t)('questions.useTarget', { target: target.destination || target.url }),
34
+ name: target?.destination ? TargetType.destination : TargetType.url,
35
+ message: t('questions.useTarget', { target: target.destination || target.url }),
39
36
  type: 'confirm',
40
37
  initial: true,
41
38
  format: (confirm) => (confirm ? target.destination || target.url : confirm)
@@ -45,20 +42,20 @@ const addAppStudioQuestions = (questions, target) => {
45
42
  questions.push({
46
43
  name: 'select',
47
44
  type: (prev) => (!prev ? 'select' : null),
48
- message: (0, i18n_1.t)('questions.target', { type: '', file: '' }),
45
+ message: t('questions.target', { type: '', file: '' }),
49
46
  choices: [
50
- { title: (0, i18n_1.t)('questions.enter', { type: types_1.TargetType.destination }), value: types_1.TargetType.destination },
51
- { title: (0, i18n_1.t)('questions.enter', { type: types_1.TargetType.url }), value: types_1.TargetType.url }
47
+ { title: t('questions.enter', { type: TargetType.destination }), value: TargetType.destination },
48
+ { title: t('questions.enter', { type: TargetType.url }), value: TargetType.url }
52
49
  ]
53
50
  });
54
51
  // destination
55
52
  questions.push({
56
- type: (prev) => (prev === types_1.TargetType.destination ? 'text' : null),
57
- name: types_1.TargetType.destination,
53
+ type: (prev) => (prev === TargetType.destination ? 'text' : null),
54
+ name: TargetType.destination,
58
55
  initial: target?.destination,
59
- message: (0, i18n_1.t)('questions.target', {
60
- type: types_1.TargetType.destination,
61
- file: target?.destination ? `(${project_access_1.FileName.UI5DeployYaml})` : ''
56
+ message: t('questions.target', {
57
+ type: TargetType.destination,
58
+ file: target?.destination ? `(${FileName.UI5DeployYaml})` : ''
62
59
  }),
63
60
  validate: (value) => validator(value, 'error.target')
64
61
  });
@@ -71,25 +68,25 @@ const addAppStudioQuestions = (questions, target) => {
71
68
  */
72
69
  const getTargetPromptQuestions = (target) => {
73
70
  const questions = [];
74
- if ((0, btp_utils_1.isAppStudio)()) {
71
+ if (isAppStudio()) {
75
72
  addAppStudioQuestions(questions, target);
76
73
  }
77
74
  // Offer url configuration for VSCode and BAS instance
78
75
  questions.push({
79
- type: (prev) => (!prev || prev === types_1.TargetType.url ? 'text' : null),
80
- name: types_1.TargetType.url,
76
+ type: (prev) => (!prev || prev === TargetType.url ? 'text' : null),
77
+ name: TargetType.url,
81
78
  initial: target?.url,
82
- message: (0, i18n_1.t)('questions.target', {
83
- type: types_1.TargetType.url,
84
- file: target?.url ? `(${project_access_1.FileName.UI5DeployYaml})` : ''
79
+ message: t('questions.target', {
80
+ type: TargetType.url,
81
+ file: target?.url ? `(${FileName.UI5DeployYaml})` : ''
85
82
  }),
86
83
  validate: (value) => validator(value, 'error.target')
87
84
  }, {
88
85
  name: 'client',
89
86
  type: (_prev, values) => (values?.url ? 'text' : null),
90
87
  initial: target?.client,
91
- message: (0, i18n_1.t)('questions.client', {
92
- file: target?.client ? `(${project_access_1.FileName.UI5DeployYaml})` : ''
88
+ message: t('questions.client', {
89
+ file: target?.client ? `(${FileName.UI5DeployYaml})` : ''
93
90
  }),
94
91
  format: (val) => (typeof val === 'number' ? val.toString() : val)
95
92
  });
@@ -105,12 +102,12 @@ const getTargetPromptQuestions = (target) => {
105
102
  const getTargetPrompt = async (config, logger) => {
106
103
  const cancel = {
107
104
  onCancel: () => {
108
- logger?.info((0, chalk_1.yellow)((0, i18n_1.t)('info.operationAborted')));
105
+ logger?.info(chalk.yellow(t('info.operationAborted')));
109
106
  return process.exit(1);
110
107
  }
111
108
  };
112
109
  const questions = getTargetPromptQuestions(config?.target);
113
- const { url, client, destination } = await (0, prompts_1.prompt)(questions, cancel);
110
+ const { url, client, destination } = await prompt(questions, cancel);
114
111
  return { url, client, destination };
115
112
  };
116
113
  /**
@@ -119,15 +116,15 @@ const getTargetPrompt = async (config, logger) => {
119
116
  * @param log logger to report info to the user
120
117
  * @returns prompted user and password serialized for a basic auth header
121
118
  */
122
- async function promptUserPass(log) {
123
- const { username, password } = await (0, prompts_1.prompt)([
119
+ export async function promptUserPass(log) {
120
+ const { username, password } = await prompt([
124
121
  {
125
122
  type: 'text',
126
123
  name: 'username',
127
- message: `${(0, chalk_1.cyan)((0, i18n_1.t)('info.username'))}`,
124
+ message: `${chalk.cyan(t('info.username'))}`,
128
125
  validate: (value) => {
129
126
  if (!value?.trim()) {
130
- return `${(0, i18n_1.t)('error.emptyUsername')}`;
127
+ return `${t('error.emptyUsername')}`;
131
128
  }
132
129
  else {
133
130
  return true;
@@ -137,10 +134,10 @@ async function promptUserPass(log) {
137
134
  {
138
135
  type: 'invisible',
139
136
  name: 'password',
140
- message: `${(0, chalk_1.cyan)((0, i18n_1.t)('info.password'))}`,
137
+ message: `${chalk.cyan(t('info.password'))}`,
141
138
  validate: (value) => {
142
139
  if (!value?.trim()) {
143
- return `${(0, i18n_1.t)('error.emptyPassword')}`;
140
+ return `${t('error.emptyPassword')}`;
144
141
  }
145
142
  else {
146
143
  return true;
@@ -149,7 +146,7 @@ async function promptUserPass(log) {
149
146
  }
150
147
  ], {
151
148
  onCancel: () => {
152
- log?.info((0, chalk_1.yellow)((0, i18n_1.t)('info.operationAborted')));
149
+ log?.info(chalk.yellow(t('info.operationAborted')));
153
150
  return process.exit(1);
154
151
  }
155
152
  });
@@ -163,27 +160,27 @@ async function promptUserPass(log) {
163
160
  * @returns credentials for target definition
164
161
  */
165
162
  async function getCredentialsPrompt(target, logger) {
166
- if ((0, btp_utils_1.isAppStudio)() && target.destination) {
167
- const destinations = await (0, btp_utils_1.listDestinations)();
163
+ if (isAppStudio() && target.destination) {
164
+ const destinations = await listDestinations();
168
165
  const destination = destinations?.[target.destination];
169
166
  if (destination?.Authentication === 'NoAuthentication') {
170
- logger?.info((0, i18n_1.t)('info.credentialsRequired'));
167
+ logger?.info(t('info.credentialsRequired'));
171
168
  return await promptUserPass(logger);
172
169
  }
173
170
  else if (destination) {
174
- logger?.info((0, i18n_1.t)('info.credentialsAvailable'));
171
+ logger?.info(t('info.credentialsAvailable'));
175
172
  return undefined;
176
173
  }
177
174
  }
178
175
  else if (target.url) {
179
- const auth = await (0, smartlinks_config_1.getLocalStoredCredentials)(target.url, target.client, logger);
176
+ const auth = await getLocalStoredCredentials(target.url, target.client, logger);
180
177
  if (auth?.username) {
181
178
  const choices = [
182
179
  { title: `Use ${auth.username}`, value: auth },
183
- { title: (0, i18n_1.t)('questions.credentialsDescription'), value: false }
180
+ { title: t('questions.credentialsDescription'), value: false }
184
181
  ];
185
- const { credentials } = await (0, prompts_1.prompt)([
186
- { name: 'credentials', type: 'select', message: (0, i18n_1.t)('questions.credentials'), choices, initial: 0 }
182
+ const { credentials } = await prompt([
183
+ { name: 'credentials', type: 'select', message: t('questions.credentials'), choices, initial: 0 }
187
184
  ]);
188
185
  if (credentials) {
189
186
  return credentials;
@@ -199,8 +196,8 @@ async function getCredentialsPrompt(target, logger) {
199
196
  * @param logger logger to report info to the user
200
197
  * @returns - array of questions that serves as input for prompt module
201
198
  */
202
- async function getSmartLinksTargetFromPrompt(basePath, logger) {
203
- const definition = await (0, smartlinks_config_1.getTargetDefinition)(basePath, logger);
199
+ export async function getSmartLinksTargetFromPrompt(basePath, logger) {
200
+ const definition = await getTargetDefinition(basePath, logger);
204
201
  const target = await getTargetPrompt(definition, logger);
205
202
  const auth = await getCredentialsPrompt(target, logger);
206
203
  return { target, auth, ignoreCertErrors: definition?.ignoreCertErrors };
@@ -1,6 +1,6 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
- import type { TargetConfig } from '../types';
3
+ import type { TargetConfig } from '../types/index.js';
4
4
  /**
5
5
  * Add smartlinks configuration to a UI5 application.
6
6
  *
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSmartLinksConfig = generateSmartLinksConfig;
4
- const mem_fs_1 = require("mem-fs");
5
- const mem_fs_editor_1 = require("mem-fs-editor");
6
- const utils_1 = require("./utils");
1
+ import { create as createStorage } from 'mem-fs';
2
+ import { create } from 'mem-fs-editor';
3
+ import { writeSmartLinksConfig } from './utils.js';
7
4
  /**
8
5
  * Add smartlinks configuration to a UI5 application.
9
6
  *
@@ -13,11 +10,11 @@ const utils_1 = require("./utils");
13
10
  * @param fs - the memfs editor instance
14
11
  * @returns Promise<Editor> - memfs editor instance with updated files
15
12
  */
16
- async function generateSmartLinksConfig(basePath, config, logger, fs) {
13
+ export async function generateSmartLinksConfig(basePath, config, logger, fs) {
17
14
  if (!fs) {
18
- fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
15
+ fs = create(createStorage());
19
16
  }
20
- await (0, utils_1.writeSmartLinksConfig)(basePath, config, fs, logger);
17
+ await writeSmartLinksConfig(basePath, config, fs, logger);
21
18
  return fs;
22
19
  }
23
20
  //# sourceMappingURL=generateSmartLinks.js.map
@@ -1,3 +1,3 @@
1
- export * from './generateSmartLinks';
2
- export { getTargetDefinition, getLocalStoredCredentials } from './utils';
1
+ export * from './generateSmartLinks.js';
2
+ export { getTargetDefinition, getLocalStoredCredentials } from './utils.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,22 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getLocalStoredCredentials = exports.getTargetDefinition = void 0;
18
- __exportStar(require("./generateSmartLinks"), exports);
19
- var utils_1 = require("./utils");
20
- Object.defineProperty(exports, "getTargetDefinition", { enumerable: true, get: function () { return utils_1.getTargetDefinition; } });
21
- Object.defineProperty(exports, "getLocalStoredCredentials", { enumerable: true, get: function () { return utils_1.getLocalStoredCredentials; } });
1
+ export * from './generateSmartLinks.js';
2
+ export { getTargetDefinition, getLocalStoredCredentials } from './utils.js';
22
3
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
- import type { TargetConfig } from '../types';
3
+ import type { TargetConfig } from '../types/index.js';
4
4
  /**
5
5
  * Reads and returns target information from ui5-deploy.yaml, if existing.
6
6
  *