@sap-ux/app-config-writer 0.7.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.
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,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readUi5DeployConfigTarget = readUi5DeployConfigTarget;
4
- exports.addUi5YamlServeStaticMiddleware = addUi5YamlServeStaticMiddleware;
5
- const node_path_1 = require("node:path");
6
- const project_access_1 = require("@sap-ux/project-access");
7
- const i18n_1 = require("../i18n");
8
- const types_1 = require("../types");
1
+ import { join } from 'node:path';
2
+ import { FileName, readUi5Yaml } from '@sap-ux/project-access';
3
+ import { t } from '../i18n.js';
4
+ import { DeployConfig } from '../types/index.js';
9
5
  /**
10
6
  * Reads and returns target information from ui5-deploy.yaml, if existing.
11
7
  *
12
8
  * @param basePath - path to project root, where ui5-deploy.yaml is
13
9
  * @returns {TargetConfig} target definition for deploy configuration
14
10
  */
15
- async function readUi5DeployConfigTarget(basePath) {
16
- const ui5DeployYaml = await (0, project_access_1.readUi5Yaml)(basePath, project_access_1.FileName.UI5DeployYaml);
17
- const customTask = ui5DeployYaml.findCustomTask(types_1.DeployConfig.DeployToAbap);
11
+ export async function readUi5DeployConfigTarget(basePath) {
12
+ const ui5DeployYaml = await readUi5Yaml(basePath, FileName.UI5DeployYaml);
13
+ const customTask = ui5DeployYaml.findCustomTask(DeployConfig.DeployToAbap);
18
14
  if (!customTask?.configuration?.target) {
19
- throw Error((0, i18n_1.t)('error.noTarget', { file: `${project_access_1.FileName.UI5DeployYaml}` }));
15
+ throw Error(t('error.noTarget', { file: `${FileName.UI5DeployYaml}` }));
20
16
  }
21
17
  const { target, ignoreCertError } = customTask?.configuration || {};
22
18
  return { target, ignoreCertErrors: ignoreCertError };
@@ -50,24 +46,24 @@ const getFioriToolsServeStaticMiddlewareConfig = (existingPaths, existingFioriTo
50
46
  * @param fs - mem-fs reference to be used for file access
51
47
  * @param logger - logger
52
48
  */
53
- async function addUi5YamlServeStaticMiddleware(basePath, fs, logger) {
54
- const ui5Yamls = [project_access_1.FileName.Ui5Yaml, project_access_1.FileName.Ui5MockYaml, project_access_1.FileName.Ui5LocalYaml];
49
+ export async function addUi5YamlServeStaticMiddleware(basePath, fs, logger) {
50
+ const ui5Yamls = [FileName.Ui5Yaml, FileName.Ui5MockYaml, FileName.Ui5LocalYaml];
55
51
  for (const ui5Yaml of ui5Yamls) {
56
52
  let ui5YamlConfig;
57
53
  try {
58
- ui5YamlConfig = await (0, project_access_1.readUi5Yaml)(basePath, ui5Yaml);
54
+ ui5YamlConfig = await readUi5Yaml(basePath, ui5Yaml);
59
55
  }
60
56
  catch (error) {
61
57
  logger?.debug(`File ${ui5Yaml} not existing`);
62
58
  continue;
63
59
  }
64
- const existingFioriToolsProxy = !!ui5YamlConfig.findCustomMiddleware(types_1.DeployConfig.FioriToolsProxy);
65
- const appServeStaticMiddleware = ui5YamlConfig.findCustomMiddleware(types_1.DeployConfig.FioriToolsServestatic);
60
+ const existingFioriToolsProxy = !!ui5YamlConfig.findCustomMiddleware(DeployConfig.FioriToolsProxy);
61
+ const appServeStaticMiddleware = ui5YamlConfig.findCustomMiddleware(DeployConfig.FioriToolsServestatic);
66
62
  const middleware = getFioriToolsServeStaticMiddlewareConfig(appServeStaticMiddleware?.configuration.paths || [], existingFioriToolsProxy);
67
63
  if (middleware) {
68
64
  const yamlConfig = ui5YamlConfig.updateCustomMiddleware(middleware);
69
65
  const yaml = yamlConfig.toString();
70
- fs.write((0, node_path_1.join)(basePath, ui5Yaml), yaml);
66
+ fs.write(join(basePath, ui5Yaml), yaml);
71
67
  }
72
68
  }
73
69
  }
@@ -1,7 +1,7 @@
1
1
  import type { AxiosBasicCredentials } from 'axios';
2
2
  import type { Editor } from 'mem-fs-editor';
3
3
  import type { ToolsLogger } from '@sap-ux/logger';
4
- import type { InboundTargetsConfig, SystemDetailsResponse, TargetConfig } from '../types';
4
+ import type { InboundTargetsConfig, SystemDetailsResponse, TargetConfig } from '../types/index.js';
5
5
  /**
6
6
  * Check the secure storage if it has credentials for the entered url.
7
7
  *
@@ -1,20 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLocalStoredCredentials = getLocalStoredCredentials;
4
- exports.sendRequest = sendRequest;
5
- exports.getTargetDefinition = getTargetDefinition;
6
- exports.getTargetMappingsConfig = getTargetMappingsConfig;
7
- exports.writeSmartLinksConfig = writeSmartLinksConfig;
8
- const chalk_1 = require("chalk");
9
- const ejs_1 = require("ejs");
10
- const node_path_1 = require("node:path");
11
- const axios_extension_1 = require("@sap-ux/axios-extension");
12
- const btp_utils_1 = require("@sap-ux/btp-utils");
13
- const project_access_1 = require("@sap-ux/project-access");
14
- const store_1 = require("@sap-ux/store");
15
- const i18n_1 = require("../i18n");
16
- const templates_1 = require("../templates");
17
- const ui5_yaml_1 = require("./ui5-yaml");
1
+ import chalk from 'chalk';
2
+ import { render } from 'ejs';
3
+ import { join } from 'node:path';
4
+ import { createForAbap, createForDestination } from '@sap-ux/axios-extension';
5
+ import { isAppStudio } from '@sap-ux/btp-utils';
6
+ import { FileName } from '@sap-ux/project-access';
7
+ import { BackendSystemKey, getService } from '@sap-ux/store';
8
+ import { t } from '../i18n.js';
9
+ import { getTemplatePath } from '../templates.js';
10
+ import { addUi5YamlServeStaticMiddleware, readUi5DeployConfigTarget } from './ui5-yaml.js';
18
11
  /**
19
12
  * URL parameters for call to backend
20
13
  */
@@ -34,15 +27,15 @@ const UrlParameters = {
34
27
  * @param logger Logger for user output
35
28
  * @returns credentials or undefined
36
29
  */
37
- async function getLocalStoredCredentials(url, client, logger) {
30
+ export async function getLocalStoredCredentials(url, client, logger) {
38
31
  // check if system credentials are stored in the store
39
32
  try {
40
- const systemStore = await (0, store_1.getService)({ logger, entityName: 'system' });
41
- const system = await systemStore.read(new store_1.BackendSystemKey({ url, client }));
33
+ const systemStore = await getService({ logger, entityName: 'system' });
34
+ const system = await systemStore.read(new BackendSystemKey({ url, client }));
42
35
  return system?.username ? { username: system.username, password: system.password || '' } : undefined;
43
36
  }
44
37
  catch (error) {
45
- logger?.warn((0, i18n_1.t)('warnings.useCredentialsFailed'));
38
+ logger?.warn(t('warnings.useCredentialsFailed'));
46
39
  logger?.debug(error);
47
40
  }
48
41
  return undefined;
@@ -56,12 +49,12 @@ async function getLocalStoredCredentials(url, client, logger) {
56
49
  function createSmartLinksProvider(config) {
57
50
  const { target, auth, ignoreCertErrors } = config;
58
51
  let provider;
59
- if ((0, btp_utils_1.isAppStudio)() && target.destination) {
60
- provider = (0, axios_extension_1.createForDestination)({ auth }, { Name: target.destination });
52
+ if (isAppStudio() && target.destination) {
53
+ provider = createForDestination({ auth }, { Name: target.destination });
61
54
  delete provider.defaults.params['saml2'];
62
55
  }
63
56
  else {
64
- provider = (0, axios_extension_1.createForAbap)({
57
+ provider = createForAbap({
65
58
  baseURL: target.url,
66
59
  auth,
67
60
  ignoreCertErrors,
@@ -77,16 +70,16 @@ function createSmartLinksProvider(config) {
77
70
  * @param logger logger to report info to the user
78
71
  * @returns response from service provider
79
72
  */
80
- async function sendRequest(config, logger) {
81
- const target = (0, btp_utils_1.isAppStudio)() && config.target.destination ? config.target.destination : config.target.url;
73
+ export async function sendRequest(config, logger) {
74
+ const target = isAppStudio() && config.target.destination ? config.target.destination : config.target.url;
82
75
  if (!target) {
83
- throw new Error((0, i18n_1.t)('error.target'));
76
+ throw new Error(t('error.target'));
84
77
  }
85
78
  try {
86
79
  const provider = createSmartLinksProvider(config);
87
- logger?.info(`${(0, chalk_1.cyan)((0, i18n_1.t)('info.connectTo'))} ${target}`);
80
+ logger?.info(`${chalk.cyan(t('info.connectTo'))} ${target}`);
88
81
  const response = (await provider.get('/sap/bc/ui2/start_up', { params: UrlParameters }));
89
- logger?.info((0, chalk_1.cyan)((0, i18n_1.t)('info.connectSuccess')));
82
+ logger?.info(chalk.cyan(t('info.connectSuccess')));
90
83
  if (response.status !== 200 || !response.data) {
91
84
  throw new Error(`Invalid response from ${config.target.url ?? config.target.destination}: status: ${response.status}. data: '${response.data}'.`);
92
85
  }
@@ -104,11 +97,11 @@ async function sendRequest(config, logger) {
104
97
  * @param logger - logger
105
98
  * @returns target definition
106
99
  */
107
- async function getTargetDefinition(basePath, logger) {
108
- logger?.info((0, i18n_1.t)('info.searchTarget', { file: project_access_1.FileName.UI5DeployYaml }));
100
+ export async function getTargetDefinition(basePath, logger) {
101
+ logger?.info(t('info.searchTarget', { file: FileName.UI5DeployYaml }));
109
102
  try {
110
- const target = await (0, ui5_yaml_1.readUi5DeployConfigTarget)(basePath);
111
- logger?.info((0, chalk_1.cyan)((0, i18n_1.t)('info.targetFound', { file: project_access_1.FileName.UI5DeployYaml })));
103
+ const target = await readUi5DeployConfigTarget(basePath);
104
+ logger?.info(chalk.cyan(t('info.targetFound', { file: FileName.UI5DeployYaml })));
112
105
  return target;
113
106
  }
114
107
  catch (error) {
@@ -127,7 +120,7 @@ async function getTargetDefinition(basePath, logger) {
127
120
  async function getTargetMappings(config, logger) {
128
121
  const response = await sendRequest(config, logger);
129
122
  if (!response?.targetMappings) {
130
- throw new Error((0, i18n_1.t)('error.noTarget', { file: `${config.target.destination ?? config.target.url}` }));
123
+ throw new Error(t('error.noTarget', { file: `${config.target.destination ?? config.target.url}` }));
131
124
  }
132
125
  return response.targetMappings;
133
126
  }
@@ -138,7 +131,7 @@ async function getTargetMappings(config, logger) {
138
131
  * @param logger logger
139
132
  * @returns config with targets to be used for template mapping
140
133
  */
141
- async function getTargetMappingsConfig(config, logger) {
134
+ export async function getTargetMappingsConfig(config, logger) {
142
135
  const targetMappings = await getTargetMappings(config, logger);
143
136
  const inboundConfig = {};
144
137
  for (const targetName in targetMappings) {
@@ -184,18 +177,18 @@ function mergeTargetMappings(appConfigPath, inboundTargets, fs) {
184
177
  * @param fs - the memfs editor instance
185
178
  * @param logger - logger
186
179
  */
187
- async function writeSmartLinksConfig(basePath, config, fs, logger) {
180
+ export async function writeSmartLinksConfig(basePath, config, fs, logger) {
188
181
  let inboundTargets = await getTargetMappingsConfig(config, logger);
189
- const templatePath = (0, templates_1.getTemplatePath)('smartlinks-config/fioriSandboxConfig.json');
190
- const appConfigPath = (0, node_path_1.join)(basePath, 'appconfig', 'fioriSandboxConfig.json');
182
+ const templatePath = getTemplatePath('smartlinks-config/fioriSandboxConfig.json');
183
+ const appConfigPath = join(basePath, 'appconfig', 'fioriSandboxConfig.json');
191
184
  if (!fs.exists(appConfigPath)) {
192
185
  fs.copyTpl(templatePath, appConfigPath, { inboundTargets });
193
186
  }
194
187
  else {
195
188
  inboundTargets = mergeTargetMappings(appConfigPath, inboundTargets, fs);
196
- const filledTemplate = (0, ejs_1.render)(fs.read(templatePath), { inboundTargets }, {});
189
+ const filledTemplate = render(fs.read(templatePath), { inboundTargets }, {});
197
190
  fs.extendJSON(appConfigPath, JSON.parse(filledTemplate));
198
191
  }
199
- await (0, ui5_yaml_1.addUi5YamlServeStaticMiddleware)(basePath, fs, logger);
192
+ await addUi5YamlServeStaticMiddleware(basePath, fs, logger);
200
193
  }
201
194
  //# sourceMappingURL=utils.js.map
package/dist/templates.js CHANGED
@@ -1,7 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTemplatePath = getTemplatePath;
4
- const node_path_1 = require("node:path");
1
+ import { dirname, join } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ const __dirname = dirname(fileURLToPath(import.meta.url));
5
4
  /**
6
5
  * Locates template files relative to the dist folder.
7
6
  * This helps to locate templates when this module is bundled and the dir structure is flattened, maintaining the relative paths.
@@ -9,7 +8,7 @@ const node_path_1 = require("node:path");
9
8
  * @param relativeTemplatePath - optional, the path of the required template relative to the ./templates folder. If not specified the root templates folder is returned.
10
9
  * @returns the path of the template specified or templates root folder
11
10
  */
12
- function getTemplatePath(relativeTemplatePath = '') {
13
- return (0, node_path_1.join)(__dirname, '../templates', relativeTemplatePath);
11
+ export function getTemplatePath(relativeTemplatePath = '') {
12
+ return join(__dirname, '../templates', relativeTemplatePath);
14
13
  }
15
14
  //# sourceMappingURL=templates.js.map
@@ -1,4 +1,4 @@
1
- export * from './smartLinks';
2
- export * from './variantsConfig';
3
- export * from './navigation';
1
+ export * from './smartLinks.js';
2
+ export * from './variantsConfig.js';
3
+ export * from './navigation.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,20 +1,4 @@
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
- __exportStar(require("./smartLinks"), exports);
18
- __exportStar(require("./variantsConfig"), exports);
19
- __exportStar(require("./navigation"), exports);
1
+ export * from './smartLinks.js';
2
+ export * from './variantsConfig.js';
3
+ export * from './navigation.js';
20
4
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=navigation.js.map
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TargetType = exports.DeployConfig = void 0;
4
- var DeployConfig;
1
+ export var DeployConfig;
5
2
  (function (DeployConfig) {
6
3
  DeployConfig["DeployToAbap"] = "deploy-to-abap";
7
4
  DeployConfig["FioriToolsProxy"] = "fiori-tools-proxy";
8
5
  DeployConfig["FioriToolsServestatic"] = "fiori-tools-servestatic";
9
- })(DeployConfig || (exports.DeployConfig = DeployConfig = {}));
10
- var TargetType;
6
+ })(DeployConfig || (DeployConfig = {}));
7
+ export var TargetType;
11
8
  (function (TargetType) {
12
9
  TargetType["destination"] = "destination";
13
10
  TargetType["url"] = "url";
14
- })(TargetType || (exports.TargetType = TargetType = {}));
11
+ })(TargetType || (TargetType = {}));
15
12
  //# sourceMappingURL=smartLinks.js.map
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MiddlewareConfigs = void 0;
4
- var MiddlewareConfigs;
1
+ export var MiddlewareConfigs;
5
2
  (function (MiddlewareConfigs) {
6
3
  MiddlewareConfigs["FioriToolsPreview"] = "fiori-tools-preview";
7
4
  MiddlewareConfigs["PreviewMiddleware"] = "preview-middleware";
8
5
  MiddlewareConfigs["ReloadMiddleware"] = "reload-middleware";
9
6
  MiddlewareConfigs["FioriToolsAppreload"] = "fiori-tools-appreload";
10
- })(MiddlewareConfigs || (exports.MiddlewareConfigs = MiddlewareConfigs = {}));
7
+ })(MiddlewareConfigs || (MiddlewareConfigs = {}));
11
8
  //# sourceMappingURL=variantsConfig.js.map
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateVariantsConfig = generateVariantsConfig;
4
- const mem_fs_editor_1 = require("mem-fs-editor");
5
- const mem_fs_1 = require("mem-fs");
6
- const ui5_yaml_1 = require("../common/ui5-yaml");
7
- const package_json_1 = require("./package-json");
1
+ import { create } from 'mem-fs-editor';
2
+ import { create as createStorage } from 'mem-fs';
3
+ import { updateMiddlewaresForPreview } from '../common/ui5-yaml.js';
4
+ import { addVariantsManagementScript } from './package-json.js';
8
5
  /**
9
6
  * Add variants configuration to an app or project.
10
7
  *
@@ -14,12 +11,12 @@ const package_json_1 = require("./package-json");
14
11
  * @param fs - the memfs editor instance
15
12
  * @returns Promise<Editor> - memfs editor instance with updated files
16
13
  */
17
- async function generateVariantsConfig(basePath, yamlPath, logger, fs) {
14
+ export async function generateVariantsConfig(basePath, yamlPath, logger, fs) {
18
15
  if (!fs) {
19
- fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
16
+ fs = create(createStorage());
20
17
  }
21
- await (0, ui5_yaml_1.updateMiddlewaresForPreview)(fs, basePath, yamlPath, logger);
22
- await (0, package_json_1.addVariantsManagementScript)(fs, basePath, yamlPath, logger);
18
+ await updateMiddlewaresForPreview(fs, basePath, yamlPath, logger);
19
+ await addVariantsManagementScript(fs, basePath, yamlPath, logger);
23
20
  return fs;
24
21
  }
25
22
  //# sourceMappingURL=generateVariantsConfig.js.map
@@ -1,2 +1,2 @@
1
- export * from './generateVariantsConfig';
1
+ export * from './generateVariantsConfig.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,18 +1,2 @@
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
- __exportStar(require("./generateVariantsConfig"), exports);
1
+ export * from './generateVariantsConfig.js';
18
2
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addVariantsManagementScript = addVariantsManagementScript;
4
- const node_path_1 = require("node:path");
5
- const utils_1 = require("./utils");
6
- const utils_2 = require("../common/utils");
7
- const project_access_1 = require("@sap-ux/project-access");
1
+ import { basename, join } from 'node:path';
2
+ import { getRTAUrlParameters, getRTAUrl } from './utils.js';
3
+ import { getCLIForPreview } from '../common/utils.js';
4
+ import { FileName } from '@sap-ux/project-access';
8
5
  const ERROR_MSG = `Script 'start-variants-management' cannot be written to package.json.`;
9
6
  /**
10
7
  * Add the start-variants-management script to the package.json.
@@ -15,10 +12,10 @@ const ERROR_MSG = `Script 'start-variants-management' cannot be written to packa
15
12
  * @param logger - logger
16
13
  * @returns Promise<void> - rejects in case variants management script can't be added to package.json
17
14
  */
18
- async function addVariantsManagementScript(fs, basePath, yamlPath, logger) {
19
- const packageJsonPath = (0, node_path_1.join)(basePath, 'package.json');
15
+ export async function addVariantsManagementScript(fs, basePath, yamlPath, logger) {
16
+ const packageJsonPath = join(basePath, 'package.json');
20
17
  const packageJson = fs.readJSON(packageJsonPath);
21
- const ui5YamlFileName = yamlPath ? (0, node_path_1.basename)(yamlPath) : project_access_1.FileName.Ui5Yaml;
18
+ const ui5YamlFileName = yamlPath ? basename(yamlPath) : FileName.Ui5Yaml;
22
19
  if (!packageJson) {
23
20
  throw new Error(`${ERROR_MSG} File 'package.json' not found at ${basePath}`);
24
21
  }
@@ -26,13 +23,13 @@ async function addVariantsManagementScript(fs, basePath, yamlPath, logger) {
26
23
  logger?.warn(`File 'package.json' does not contain a script section. Script section added.`);
27
24
  packageJson.scripts = {};
28
25
  }
29
- const url = await (0, utils_1.getRTAUrl)(basePath, (0, utils_1.getRTAUrlParameters)(packageJson), ui5YamlFileName, fs);
30
- const serveCommand = await (0, utils_2.getCLIForPreview)(basePath, ui5YamlFileName, fs);
26
+ const url = await getRTAUrl(basePath, getRTAUrlParameters(packageJson), ui5YamlFileName, fs);
27
+ const serveCommand = await getCLIForPreview(basePath, ui5YamlFileName, fs);
31
28
  if (!url) {
32
29
  throw new Error(`${ERROR_MSG} No RTA editor specified in ui5.yaml.`);
33
30
  }
34
31
  // set --config flag if default ui5.yaml is not used
35
- const yamlConfigFile = ui5YamlFileName !== project_access_1.FileName.Ui5Yaml ? ` --config ./${(0, node_path_1.basename)(ui5YamlFileName)}` : '';
32
+ const yamlConfigFile = ui5YamlFileName !== FileName.Ui5Yaml ? ` --config ./${basename(ui5YamlFileName)}` : '';
36
33
  const startVariantsManagementScriptOld = packageJson.scripts['start-variants-management'] ?? undefined;
37
34
  const startVariantsManagementScriptNew = `${serveCommand}${yamlConfigFile} --open "${url}"`;
38
35
  if (!startVariantsManagementScriptOld) {
@@ -1,33 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRTAUrlParameters = getRTAUrlParameters;
4
- exports.getRTAUrl = getRTAUrl;
5
- const types_1 = require("../types");
6
- const node_querystring_1 = require("node:querystring");
7
- const semver_1 = require("semver");
8
- const utils_1 = require("../common/utils");
1
+ import { MiddlewareConfigs } from '../types/index.js';
2
+ import { stringify } from 'node:querystring';
3
+ import { satisfies } from 'semver';
4
+ import { getPreviewMiddleware, getIntentFromPreviewConfig, isFioriToolsDeprecatedPreviewConfig } from '../common/utils.js';
9
5
  /**
10
6
  * Get the url parameters needed for the UI5 run time adaptation.
11
7
  *
12
8
  @param packageJson - package.json file
13
9
  * @returns enhanced url parameters
14
10
  */
15
- function getRTAUrlParameters(packageJson) {
11
+ export function getRTAUrlParameters(packageJson) {
16
12
  const getDependencyVersion = (packageJson, dependencyName) => {
17
13
  return packageJson?.devDependencies?.[dependencyName] ?? packageJson?.dependencies?.[dependencyName];
18
14
  };
19
15
  const parameters = {};
20
16
  const previewMiddlewareVersion = getDependencyVersion(packageJson, '@sap-ux/preview-middleware');
21
17
  const uxUi5ToolingVersion = getDependencyVersion(packageJson, '@sap/ux-ui5-tooling');
22
- if ((previewMiddlewareVersion && (0, semver_1.satisfies)(previewMiddlewareVersion, '<0.16.89')) ??
23
- (uxUi5ToolingVersion && (0, semver_1.satisfies)(uxUi5ToolingVersion, '<1.15.4')) ??
18
+ if ((previewMiddlewareVersion && satisfies(previewMiddlewareVersion, '<0.16.89')) ??
19
+ (uxUi5ToolingVersion && satisfies(uxUi5ToolingVersion, '<1.15.4')) ??
24
20
  (!previewMiddlewareVersion && !uxUi5ToolingVersion)) {
25
21
  parameters['fiori-tools-rta-mode'] = 'true';
26
22
  parameters['sap-ui-rta-skip-flex-validation'] = 'true';
27
23
  parameters['sap-ui-xx-condense-changes'] = 'true';
28
24
  parameters['sap-ui-xx-viewCache'] = 'false';
29
25
  }
30
- return (0, node_querystring_1.stringify)(parameters);
26
+ return stringify(parameters);
31
27
  }
32
28
  /**
33
29
  * Returns the RTA mount point of the preview middleware configuration from the ui5.yaml file, if given.
@@ -60,22 +56,22 @@ function getRTAMountPoint(previewMiddlewareConfig) {
60
56
  * @param fs - the memfs editor instance
61
57
  * @returns - review url parameters
62
58
  */
63
- async function getRTAUrl(basePath, query, yamlFileName, fs) {
59
+ export async function getRTAUrl(basePath, query, yamlFileName, fs) {
64
60
  let previewMiddleware;
65
61
  try {
66
- previewMiddleware = await (0, utils_1.getPreviewMiddleware)(undefined, basePath, yamlFileName, fs);
62
+ previewMiddleware = await getPreviewMiddleware(undefined, basePath, yamlFileName, fs);
67
63
  }
68
64
  catch (error) {
69
65
  throw new Error(`No ${yamlFileName} file found. ${error}`);
70
66
  }
71
- if (previewMiddleware?.name === types_1.MiddlewareConfigs.PreviewMiddleware &&
67
+ if (previewMiddleware?.name === MiddlewareConfigs.PreviewMiddleware &&
72
68
  !getRTAMountPoint(previewMiddleware?.configuration)) {
73
69
  return undefined;
74
70
  }
75
71
  const mountPoint = getRTAMountPoint(previewMiddleware?.configuration) ?? '/preview.html';
76
- const intent = (0, utils_1.getIntentFromPreviewConfig)(previewMiddleware?.configuration) ?? '#app-preview';
72
+ const intent = getIntentFromPreviewConfig(previewMiddleware?.configuration) ?? '#app-preview';
77
73
  const queryString = query ? '?' + query : '';
78
- return (0, utils_1.isFioriToolsDeprecatedPreviewConfig)(previewMiddleware?.configuration)
74
+ return isFioriToolsDeprecatedPreviewConfig(previewMiddleware?.configuration)
79
75
  ? `${mountPoint}${queryString}#preview-app`
80
76
  : `${mountPoint}${queryString}${intent}`;
81
77
  }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@sap-ux/app-config-writer",
3
3
  "description": "Add or update configuration for SAP Fiori tools application",
4
- "version": "0.7.6",
4
+ "version": "1.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
8
8
  "directory": "packages/app-config-writer"
9
9
  },
10
+ "type": "module",
10
11
  "bugs": {
11
12
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%app-config-writer"
12
13
  },
@@ -20,7 +21,7 @@
20
21
  "!dist/**/*.map"
21
22
  ],
22
23
  "dependencies": {
23
- "chalk": "4.1.2",
24
+ "chalk": "5.3.0",
24
25
  "ejs": "3.1.10",
25
26
  "i18next": "25.10.10",
26
27
  "mem-fs": "2.1.0",
@@ -28,15 +29,16 @@
28
29
  "prompts": "2.4.2",
29
30
  "semver": "7.7.4",
30
31
  "cross-spawn": "7.0.6",
31
- "@sap-ux/axios-extension": "1.26.1",
32
- "@sap-ux/ui5-application-writer": "1.9.2",
33
- "@sap-ux/btp-utils": "1.2.1",
34
- "@sap-ux/logger": "0.9.0",
35
- "@sap-ux/project-access": "1.38.1",
36
- "@sap-ux/store": "1.6.1",
37
- "@sap-ux/ui5-config": "0.31.1"
32
+ "@sap-ux/axios-extension": "2.0.0",
33
+ "@sap-ux/ui5-application-writer": "2.0.0",
34
+ "@sap-ux/btp-utils": "2.0.0",
35
+ "@sap-ux/logger": "1.0.0",
36
+ "@sap-ux/project-access": "2.0.1",
37
+ "@sap-ux/store": "2.0.0",
38
+ "@sap-ux/ui5-config": "1.0.0"
38
39
  },
39
40
  "devDependencies": {
41
+ "@jest/globals": "30.3.0",
40
42
  "@types/ejs": "3.1.5",
41
43
  "@types/mem-fs": "1.1.2",
42
44
  "@types/mem-fs-editor": "7.0.1",
@@ -45,7 +47,7 @@
45
47
  "@types/cross-spawn": "6.0.6",
46
48
  "axios": "1.16.0",
47
49
  "nock": "14.0.11",
48
- "@sap-ux/preview-middleware": "0.26.10"
50
+ "@sap-ux/preview-middleware": "1.0.1"
49
51
  },
50
52
  "engines": {
51
53
  "node": ">=22.x"
@@ -57,6 +59,6 @@
57
59
  "format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",
58
60
  "lint": "eslint",
59
61
  "lint:fix": "eslint --fix",
60
- "test": "jest --ci --forceExit --detectOpenHandles --colors"
62
+ "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors"
61
63
  }
62
64
  }