@sap-ux/app-config-writer 0.5.23 → 0.5.25

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { getSmartLinksTargetFromPrompt } from './prompt';
1
+ export { getSmartLinksTargetFromPrompt, simulatePrompt, includeTestRunnersPrompt } from './prompt';
2
2
  export { generateSmartLinksConfig } from './smartlinks-config';
3
3
  export { generateInboundNavigationConfig, readManifest } from './navigation-config';
4
4
  export { generateVariantsConfig } from './variants-config';
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToVirtualPreview = exports.generateVariantsConfig = exports.readManifest = exports.generateInboundNavigationConfig = exports.generateSmartLinksConfig = exports.getSmartLinksTargetFromPrompt = void 0;
3
+ exports.convertToVirtualPreview = exports.generateVariantsConfig = exports.readManifest = exports.generateInboundNavigationConfig = exports.generateSmartLinksConfig = exports.includeTestRunnersPrompt = exports.simulatePrompt = exports.getSmartLinksTargetFromPrompt = void 0;
4
4
  var prompt_1 = require("./prompt");
5
5
  Object.defineProperty(exports, "getSmartLinksTargetFromPrompt", { enumerable: true, get: function () { return prompt_1.getSmartLinksTargetFromPrompt; } });
6
+ Object.defineProperty(exports, "simulatePrompt", { enumerable: true, get: function () { return prompt_1.simulatePrompt; } });
7
+ Object.defineProperty(exports, "includeTestRunnersPrompt", { enumerable: true, get: function () { return prompt_1.includeTestRunnersPrompt; } });
6
8
  var smartlinks_config_1 = require("./smartlinks-config");
7
9
  Object.defineProperty(exports, "generateSmartLinksConfig", { enumerable: true, get: function () { return smartlinks_config_1.generateSmartLinksConfig; } });
8
10
  var navigation_config_1 = require("./navigation-config");
@@ -28,10 +28,6 @@ async function convertToVirtualPreview(basePath, options) {
28
28
  if (!(await (0, prerequisites_1.checkPrerequisites)(basePath, fs, convertTests, logger))) {
29
29
  throw Error('The prerequisites are not met. For more information, see the log messages above.');
30
30
  }
31
- if (!(await (0, prerequisites_1.getExplicitApprovalToAdjustFiles)())) {
32
- logger?.error('You have not approved the conversion. The conversion has been aborted.');
33
- return fs;
34
- }
35
31
  await (0, ui5_yaml_1.updatePreviewMiddlewareConfigs)(fs, basePath, convertTests, logger);
36
32
  await (0, preview_files_1.renameDefaultSandboxes)(fs, basePath, logger);
37
33
  if (convertTests) {
@@ -13,10 +13,4 @@ import type { ToolsLogger } from '@sap-ux/logger';
13
13
  * @returns indicator if the prerequisites are met
14
14
  */
15
15
  export declare function checkPrerequisites(basePath: string, fs: Editor, convertTests?: boolean, logger?: ToolsLogger): Promise<boolean>;
16
- /**
17
- * Get the explicit approval form the user to do the conversion.
18
- *
19
- * @returns Explicit user approval to do the conversion.
20
- */
21
- export declare function getExplicitApprovalToAdjustFiles(): Promise<boolean>;
22
16
  //# sourceMappingURL=prerequisites.d.ts.map
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkPrerequisites = checkPrerequisites;
4
- exports.getExplicitApprovalToAdjustFiles = getExplicitApprovalToAdjustFiles;
5
4
  const path_1 = require("path");
6
- const prompts_1 = require("prompts");
7
5
  const semver_1 = require("semver");
8
6
  /**
9
7
  * Check if the version of the given package is lower than the minimal version.
@@ -75,18 +73,4 @@ async function checkPrerequisites(basePath, fs, convertTests = false, logger) {
75
73
  }
76
74
  return prerequisitesMet;
77
75
  }
78
- /**
79
- * Get the explicit approval form the user to do the conversion.
80
- *
81
- * @returns Explicit user approval to do the conversion.
82
- */
83
- async function getExplicitApprovalToAdjustFiles() {
84
- const question = {
85
- type: 'confirm',
86
- name: 'approval',
87
- initial: false,
88
- message: 'The converter will rename the HTML files and delete the JS and TS files used for the existing preview functionality and configure virtual endpoints instead. Do you want to proceed with the conversion?'
89
- };
90
- return Boolean((await (0, prompts_1.prompt)([question])).approval);
91
- }
92
76
  //# sourceMappingURL=prerequisites.js.map
@@ -1,2 +1,3 @@
1
1
  export { getSmartLinksTargetFromPrompt, promptUserPass } from './smartlinks-config';
2
+ export * from './preview-config';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,22 @@
1
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
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.promptUserPass = exports.getSmartLinksTargetFromPrompt = void 0;
4
18
  var smartlinks_config_1 = require("./smartlinks-config");
5
19
  Object.defineProperty(exports, "getSmartLinksTargetFromPrompt", { enumerable: true, get: function () { return smartlinks_config_1.getSmartLinksTargetFromPrompt; } });
6
20
  Object.defineProperty(exports, "promptUserPass", { enumerable: true, get: function () { return smartlinks_config_1.promptUserPass; } });
21
+ __exportStar(require("./preview-config"), exports);
7
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Prompt if the conversion should be done in simulation.
3
+ *
4
+ * @returns Indicator if the conversion should be simulated.
5
+ */
6
+ export declare function simulatePrompt(): Promise<boolean>;
7
+ /**
8
+ * Prompt if the conversion should include the test runners.
9
+ *
10
+ * @returns Indicator if the conversion should include test runners.
11
+ */
12
+ export declare function includeTestRunnersPrompt(): Promise<boolean>;
13
+ //# sourceMappingURL=preview-config.d.ts.map
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.simulatePrompt = simulatePrompt;
4
+ exports.includeTestRunnersPrompt = includeTestRunnersPrompt;
5
+ const prompts_1 = require("prompts");
6
+ /**
7
+ * Prompt if the conversion should be done in simulation.
8
+ *
9
+ * @returns Indicator if the conversion should be simulated.
10
+ */
11
+ async function simulatePrompt() {
12
+ const PROMPT_NAME = 'simulate';
13
+ const question = {
14
+ type: 'confirm',
15
+ name: PROMPT_NAME,
16
+ initial: true,
17
+ 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
+ Do you want to simulate the conversion?`
19
+ };
20
+ const answer = (await (0, prompts_1.prompt)([question]));
21
+ return (answer.simulate ?? (await Promise.reject(new Error('An error has occurred. The conversion has been canceled.')))); //in case of doubt, reject
22
+ }
23
+ /**
24
+ * Prompt if the conversion should include the test runners.
25
+ *
26
+ * @returns Indicator if the conversion should include test runners.
27
+ */
28
+ async function includeTestRunnersPrompt() {
29
+ const PROMPT_NAME = 'includeTests';
30
+ const question = {
31
+ type: 'confirm',
32
+ name: PROMPT_NAME,
33
+ initial: false,
34
+ message: 'Do you want to convert the test runners?'
35
+ };
36
+ const answer = (await (0, prompts_1.prompt)([question]));
37
+ return (answer.includeTests ??
38
+ (await Promise.reject(new Error('An error has occurred. The conversion has been canceled.')))); //in case of doubt, reject
39
+ }
40
+ //# sourceMappingURL=preview-config.js.map
@@ -25,12 +25,7 @@ async function addVariantsManagementScript(fs, basePath, yamlPath, logger) {
25
25
  logger?.warn(`File 'package.json' does not contain a script section. Script section added.`);
26
26
  packageJson.scripts = {};
27
27
  }
28
- const urlParameters = {};
29
- const sapClient = (0, utils_1.getSapClientFromPackageJson)(packageJson.scripts);
30
- if (sapClient) {
31
- urlParameters['sap-client'] = sapClient;
32
- }
33
- const url = await (0, utils_1.getRTAUrl)(basePath, (0, utils_1.enhanceUrlParametersWithRta)(packageJson, urlParameters), ui5YamlFileName, fs);
28
+ const url = await (0, utils_1.getRTAUrl)(basePath, (0, utils_1.getRtaUrlParameters)(packageJson), ui5YamlFileName, fs);
34
29
  const serveCommand = await (0, utils_1.getRTAServe)(basePath, ui5YamlFileName, fs);
35
30
  if (!url) {
36
31
  throw new Error(`${ERROR_MSG} No RTA editor specified in ui5.yaml.`);
@@ -22,28 +22,12 @@ export declare function getPreviewMiddleware(yamlConfig?: UI5Config, basePath?:
22
22
  */
23
23
  export declare function isFioriToolsDeprecatedPreviewConfig(configuration: PreviewConfigOptions | undefined): configuration is FioriToolsDeprecatedPreviewConfig;
24
24
  /**
25
- * Extracts sap client string from existing scripts in package.json.
26
- *
27
- * @param scripts - script section of the package.json
28
- * @returns sap client
29
- */
30
- export declare function getSapClientFromPackageJson(scripts: Package['scripts']): string | undefined;
31
- /**
32
- * Extracts the version of the given dependency from the given package.json file.
33
- *
34
- * @param packageJson - package.json file
35
- * @param dependencyName - name of the (dev-)dependency
36
- * @returns version of the dependency as an array of numbers
37
- */
38
- export declare function getDependencyVersion(packageJson: Package, dependencyName: string): number[] | undefined;
39
- /**
40
- * Enhances the given url parameters with the ones needed for the UI5 run time adaptation.
25
+ * Get the url parameters needed for the UI5 run time adaptation.
41
26
  *
42
27
  @param packageJson - package.json file
43
- * @param existingParams - parameters to be enhanced
44
28
  * @returns enhanced url parameters
45
29
  */
46
- export declare function enhanceUrlParametersWithRta(packageJson: Package, existingParams?: Record<string, string>): string;
30
+ export declare function getRtaUrlParameters(packageJson: Package): string;
47
31
  /**
48
32
  * Returns the serve command for the preview middleware configuration of the ui5.yaml file, if given.
49
33
  * If the fiori-tools-preview middleware is used, then the serve command will be 'fiori run'.
@@ -2,14 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPreviewMiddleware = getPreviewMiddleware;
4
4
  exports.isFioriToolsDeprecatedPreviewConfig = isFioriToolsDeprecatedPreviewConfig;
5
- exports.getSapClientFromPackageJson = getSapClientFromPackageJson;
6
- exports.getDependencyVersion = getDependencyVersion;
7
- exports.enhanceUrlParametersWithRta = enhanceUrlParametersWithRta;
5
+ exports.getRtaUrlParameters = getRtaUrlParameters;
8
6
  exports.getRTAServe = getRTAServe;
9
7
  exports.getRTAUrl = getRTAUrl;
10
8
  const project_access_1 = require("@sap-ux/project-access");
11
9
  const types_1 = require("../types");
12
10
  const querystring_1 = require("querystring");
11
+ const semver_1 = require("semver");
13
12
  /**
14
13
  * Gets the preview middleware form the yamlConfig or provided path.
15
14
  * The middleware can either be named 'fiori-tools-preview' or 'preview-middleware'.
@@ -39,68 +38,27 @@ function isFioriToolsDeprecatedPreviewConfig(configuration) {
39
38
  return configuration?.component !== undefined;
40
39
  }
41
40
  /**
42
- * Extracts sap client string from existing scripts in package.json.
43
- *
44
- * @param scripts - script section of the package.json
45
- * @returns sap client
46
- */
47
- function getSapClientFromPackageJson(scripts) {
48
- for (const value of Object.values(scripts)) {
49
- const match = value?.match(/sap-client=(\d{3})/);
50
- if (match) {
51
- return match[1];
52
- }
53
- }
54
- return undefined;
55
- }
56
- /**
57
- * Extracts the version of the given dependency from the given package.json file.
58
- *
59
- * @param packageJson - package.json file
60
- * @param dependencyName - name of the (dev-)dependency
61
- * @returns version of the dependency as an array of numbers
62
- */
63
- function getDependencyVersion(packageJson, dependencyName) {
64
- return (packageJson?.devDependencies?.[dependencyName] ?? packageJson?.dependencies?.[dependencyName])
65
- ?.split('.')
66
- .map((versionPart) => parseInt(versionPart, 10));
67
- }
68
- /**
69
- * Checks if the given version is less than the given major, minor and patch version.
70
- *
71
- * @param version - version to be checked
72
- * @param major - major version to be compared with
73
- * @param minor - minor version to be compared with
74
- * @param patch - patch version to be compared with
75
- * @returns true, if the given version is less than the given major, minor and patch version
76
- */
77
- function isVersionLessThan(version, major, minor, patch) {
78
- if (!version) {
79
- return undefined;
80
- }
81
- const [vMajor, vMinor, vPatch] = version;
82
- return vMajor < major || (vMajor === major && (vMinor < minor || (vMinor === minor && vPatch < patch)));
83
- }
84
- /**
85
- * Enhances the given url parameters with the ones needed for the UI5 run time adaptation.
41
+ * Get the url parameters needed for the UI5 run time adaptation.
86
42
  *
87
43
  @param packageJson - package.json file
88
- * @param existingParams - parameters to be enhanced
89
44
  * @returns enhanced url parameters
90
45
  */
91
- function enhanceUrlParametersWithRta(packageJson, existingParams = {}) {
46
+ function getRtaUrlParameters(packageJson) {
47
+ const getDependencyVersion = (packageJson, dependencyName) => {
48
+ return packageJson?.devDependencies?.[dependencyName] ?? packageJson?.dependencies?.[dependencyName];
49
+ };
92
50
  const parameters = {};
93
51
  const previewMiddlewareVersion = getDependencyVersion(packageJson, '@sap-ux/preview-middleware');
94
52
  const uxUi5ToolingVersion = getDependencyVersion(packageJson, '@sap/ux-ui5-tooling');
95
- if (isVersionLessThan(previewMiddlewareVersion, 0, 16, 89) ??
96
- isVersionLessThan(uxUi5ToolingVersion, 1, 15, 4) ??
97
- true) {
53
+ if ((previewMiddlewareVersion && (0, semver_1.satisfies)(previewMiddlewareVersion, '<0.16.89')) ??
54
+ (uxUi5ToolingVersion && (0, semver_1.satisfies)(uxUi5ToolingVersion, '<1.15.4')) ??
55
+ (!previewMiddlewareVersion && !uxUi5ToolingVersion)) {
98
56
  parameters['fiori-tools-rta-mode'] = 'true';
99
57
  parameters['sap-ui-rta-skip-flex-validation'] = 'true';
100
58
  parameters['sap-ui-xx-condense-changes'] = 'true';
101
59
  parameters['sap-ui-xx-viewCache'] = 'false';
102
60
  }
103
- return (0, querystring_1.stringify)(Object.assign(parameters, existingParams));
61
+ return (0, querystring_1.stringify)(parameters);
104
62
  }
105
63
  /**
106
64
  * Returns the RTA mount point of the preview middleware configuration from the ui5.yaml file, if given.
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.5.23",
4
+ "version": "0.5.25",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -42,7 +42,7 @@
42
42
  "@types/semver": "7.5.8",
43
43
  "axios": "1.7.4",
44
44
  "nock": "13.4.0",
45
- "@sap-ux/preview-middleware": "0.17.14"
45
+ "@sap-ux/preview-middleware": "0.17.16"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=18.x"