@sap-ux/adp-tooling 0.18.4 → 0.18.6

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/types.d.ts CHANGED
@@ -389,6 +389,11 @@ export declare const enum HttpStatusCodes {
389
389
  NOT_IMPLEMETED = 501,
390
390
  SERVICE_UNAVAILABLE = 503
391
391
  }
392
+ export type NetworkError = {
393
+ message?: string;
394
+ name?: string;
395
+ code?: string;
396
+ };
392
397
  export type OperationType = 'read' | 'write' | 'delete';
393
398
  /**
394
399
  * Represents a constructor type that creates an instance of IWriter.
@@ -40,28 +40,20 @@ export declare function removeBracketsFromVersion(version: string): string;
40
40
  */
41
41
  export declare function removeMicroPart(version: string): string;
42
42
  /**
43
- * Removes the timestamp part from a version string, typically used to clean up snapshot versions that include a timestamp.
44
- * Converts a version string like '1.95.0.34566363464' to '1.95.0'.
43
+ * Removes the timestamp and '-snapshot' suffix from a version string.
44
+ * Converts a version string like '1.95.0.123456789' or '1.95.0-snapshot' to '1.95.0'.
45
45
  *
46
- * @param {string} version - The version string that may include a timestamp as part of a snapshot version.
47
- * @returns {string} The version string without the timestamp, including only the major, minor, and micro version numbers.
48
- */
49
- export declare function removeTimestampFromVersion(version: string): string;
50
- /**
51
- * Removes the '-snapshot' suffix from a version string's patch number.
52
- * Converts version strings like '1.96.0-snapshot' to '1.96.0' by cleaning
53
- * the patch part of any snapshot designation.
54
- *
55
- * @param {string} version - The version string that may include '-snapshot' in the patch number.
56
- * @returns {string} The version string with the snapshot suffix removed from the patch number.
46
+ * @param {string} version - The version string that may include a timestamp and '-snapshot' suffix.
47
+ * @returns {string} The cleaned version string without the timestamp and snapshot designation.
57
48
  * @example
58
49
  * ```typescript
59
- * removeSnapshotFromVersion('1.96.0-snapshot'); // Returns '1.96.0'
60
- * removeSnapshotFromVersion('1.87.3-SNAPSHOT'); // Returns '1.87.3' (case-insensitive)
61
- * removeSnapshotFromVersion('1.120.1'); // Returns '1.120.1' (no change)
50
+ * formatUi5Version('1.95.0.123456789'); // returns '1.95.0'
51
+ * formatUi5Version('1.95.0-snapshot'); // returns '1.95.0'
52
+ * formatUi5Version('1.95.0-SNAPSHOT'); // returns '1.95.0'
53
+ * formatUi5Version('1.95.0'); // returns '1.95.0'
62
54
  * ```
63
55
  */
64
- export declare function removeSnapshotFromVersion(version: string): string;
56
+ export declare function formatUi5Version(version: string): string;
65
57
  /**
66
58
  * Conditionally appends a '-snapshot' suffix to a version string if certain criteria are met.
67
59
  * The suffix is added only if the version string includes an unreleased snapshot version.
@@ -5,8 +5,7 @@ exports.getFormattedVersion = getFormattedVersion;
5
5
  exports.buildSystemVersionLabel = buildSystemVersionLabel;
6
6
  exports.removeBracketsFromVersion = removeBracketsFromVersion;
7
7
  exports.removeMicroPart = removeMicroPart;
8
- exports.removeTimestampFromVersion = removeTimestampFromVersion;
9
- exports.removeSnapshotFromVersion = removeSnapshotFromVersion;
8
+ exports.formatUi5Version = formatUi5Version;
10
9
  exports.addSnapshot = addSnapshot;
11
10
  exports.parseUI5Version = parseUI5Version;
12
11
  exports.isFeatureSupportedVersion = isFeatureSupportedVersion;
@@ -73,34 +72,22 @@ function removeMicroPart(version) {
73
72
  return `${versionParts[0]}.${versionParts[1]}`;
74
73
  }
75
74
  /**
76
- * Removes the timestamp part from a version string, typically used to clean up snapshot versions that include a timestamp.
77
- * Converts a version string like '1.95.0.34566363464' to '1.95.0'.
75
+ * Removes the timestamp and '-snapshot' suffix from a version string.
76
+ * Converts a version string like '1.95.0.123456789' or '1.95.0-snapshot' to '1.95.0'.
78
77
  *
79
- * @param {string} version - The version string that may include a timestamp as part of a snapshot version.
80
- * @returns {string} The version string without the timestamp, including only the major, minor, and micro version numbers.
81
- */
82
- function removeTimestampFromVersion(version) {
83
- const versionParts = version.split('.');
84
- return `${versionParts[0]}.${versionParts[1]}.${versionParts[2]}`;
85
- }
86
- /**
87
- * Removes the '-snapshot' suffix from a version string's patch number.
88
- * Converts version strings like '1.96.0-snapshot' to '1.96.0' by cleaning
89
- * the patch part of any snapshot designation.
90
- *
91
- * @param {string} version - The version string that may include '-snapshot' in the patch number.
92
- * @returns {string} The version string with the snapshot suffix removed from the patch number.
78
+ * @param {string} version - The version string that may include a timestamp and '-snapshot' suffix.
79
+ * @returns {string} The cleaned version string without the timestamp and snapshot designation.
93
80
  * @example
94
81
  * ```typescript
95
- * removeSnapshotFromVersion('1.96.0-snapshot'); // Returns '1.96.0'
96
- * removeSnapshotFromVersion('1.87.3-SNAPSHOT'); // Returns '1.87.3' (case-insensitive)
97
- * removeSnapshotFromVersion('1.120.1'); // Returns '1.120.1' (no change)
82
+ * formatUi5Version('1.95.0.123456789'); // returns '1.95.0'
83
+ * formatUi5Version('1.95.0-snapshot'); // returns '1.95.0'
84
+ * formatUi5Version('1.95.0-SNAPSHOT'); // returns '1.95.0'
85
+ * formatUi5Version('1.95.0'); // returns '1.95.0'
98
86
  * ```
99
87
  */
100
- function removeSnapshotFromVersion(version) {
88
+ function formatUi5Version(version) {
101
89
  const versionParts = version.split('.');
102
- const patchNumber = versionParts[2].toLowerCase().replace('-snapshot', '');
103
- return `${versionParts[0]}.${versionParts[1]}.${patchNumber}`;
90
+ return `${versionParts[0]}.${versionParts[1]}.${versionParts[2].toLowerCase().replace('-snapshot', '')}`;
104
91
  }
105
92
  /**
106
93
  * Conditionally appends a '-snapshot' suffix to a version string if certain criteria are met.
@@ -113,7 +100,10 @@ function removeSnapshotFromVersion(version) {
113
100
  */
114
101
  function addSnapshot(version, latestVersion) {
115
102
  const versionParts = version.split('.');
116
- return versionParts[2] && removeTimestampFromVersion(version) != latestVersion ? '-snapshot' : '';
103
+ return (versionParts[3] || version.toLowerCase().includes('-snapshot')) &&
104
+ formatUi5Version(version) !== latestVersion
105
+ ? '-snapshot'
106
+ : '';
117
107
  }
118
108
  /**
119
109
  * Function that parse the UI5 version. Returns NaN for snapshot or snapshot-untested. eturns x.xx for snapshot-x.xx.xx.
@@ -1,10 +1,14 @@
1
+ import type { NetworkError } from '../types';
1
2
  /**
2
3
  * Checks if the current environment is offline or has network connectivity issues.
3
4
  * This function is designed for VS Code's Yeoman UI environment where network
4
5
  * errors may differ from browser environments.
5
6
  *
6
- * @param {Error} error - The error object from a failed fetch request.
7
+ * @param {object} error - The error object from a failed fetch request.
8
+ * @param {string} [error.message] - The error message string.
9
+ * @param {string} [error.name] - The error name string.
10
+ * @param {string} [error.code] - The error code string.
7
11
  * @returns {boolean} True if the error indicates offline/network issues.
8
12
  */
9
- export declare function isOfflineError(error: Error): boolean;
13
+ export declare function isOfflineError(error: NetworkError): boolean;
10
14
  //# sourceMappingURL=network.d.ts.map
@@ -22,10 +22,13 @@ const networkErrorMessages = [
22
22
  * This function is designed for VS Code's Yeoman UI environment where network
23
23
  * errors may differ from browser environments.
24
24
  *
25
- * @param {Error} error - The error object from a failed fetch request.
25
+ * @param {object} error - The error object from a failed fetch request.
26
+ * @param {string} [error.message] - The error message string.
27
+ * @param {string} [error.name] - The error name string.
28
+ * @param {string} [error.code] - The error code string.
26
29
  * @returns {boolean} True if the error indicates offline/network issues.
27
30
  */
28
31
  function isOfflineError(error) {
29
- return networkErrorMessages.some((msg) => error.message?.includes(msg) || error.name?.includes(msg));
32
+ return networkErrorMessages.some((msg) => error.message?.includes(msg) || error.name?.includes(msg) || error.code?.includes(msg));
30
33
  }
31
34
  //# sourceMappingURL=network.js.map
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.validateUI5VersionExists = validateUI5VersionExists;
4
7
  const project_input_validator_1 = require("@sap-ux/project-input-validator");
8
+ const axios_1 = __importDefault(require("axios"));
5
9
  const i18n_1 = require("../i18n");
6
10
  const format_1 = require("./format");
7
11
  const network_1 = require("./network");
@@ -19,7 +23,7 @@ async function validateUI5VersionExists(version) {
19
23
  const selectedVersionURL = (0, format_1.getOfficialBaseUI5VersionUrl)(version);
20
24
  const resource = version.includes('snapshot') ? 'neo-app.json' : (0, format_1.getFormattedVersion)(version);
21
25
  try {
22
- await fetch(`${selectedVersionURL}/${resource}`);
26
+ await axios_1.default.get(`${selectedVersionURL}/${resource}`);
23
27
  return true;
24
28
  }
25
29
  catch (e) {
@@ -82,7 +82,7 @@ function getVersionLabels(version, publicVersions) {
82
82
  let systemLatestLabel = '';
83
83
  if (version) {
84
84
  const latestVersion = getLatestVersion(publicVersions);
85
- formattedVersion = (0, format_1.removeTimestampFromVersion)(version);
85
+ formattedVersion = (0, format_1.formatUi5Version)(version);
86
86
  systemSnapshotLabel = (0, format_1.addSnapshot)(version, latestVersion);
87
87
  systemLatestLabel = formattedVersion === latestVersion ? constants_1.LATEST_VERSION : '';
88
88
  }
@@ -99,9 +99,7 @@ function checkSystemVersionPattern(version) {
99
99
  if (!version || !pattern.test(version)) {
100
100
  return undefined;
101
101
  }
102
- let normalizedVersion = (0, format_1.removeTimestampFromVersion)(version);
103
- normalizedVersion = (0, format_1.removeSnapshotFromVersion)(normalizedVersion);
104
- return normalizedVersion;
102
+ return (0, format_1.formatUi5Version)(version);
105
103
  }
106
104
  /**
107
105
  * Retrieves and filters internal UI5 versions.
@@ -151,21 +149,27 @@ async function getHigherVersions(version, publicVersions) {
151
149
  * @returns {Promise<string[]>} A promise that resolves to an array of relevant version strings.
152
150
  */
153
151
  async function getRelevantVersions(systemVersion, isCustomerBase, publicVersions) {
154
- const version = checkSystemVersionPattern(systemVersion);
152
+ let formattedVersion = '', systemSnapshotLabel = '', systemLatestLabel = '';
155
153
  const latestPublicVersion = publicVersions?.latest?.version;
156
154
  let versions = [];
157
- const { formattedVersion, systemSnapshotLabel, systemLatestLabel } = getVersionLabels(version, publicVersions);
155
+ if (systemVersion) {
156
+ ({ formattedVersion, systemSnapshotLabel, systemLatestLabel } = getVersionLabels(systemVersion, publicVersions));
157
+ }
158
158
  if (!isCustomerBase) {
159
159
  versions = await getInternalVersions(latestPublicVersion);
160
- if (version) {
160
+ if (formattedVersion) {
161
161
  const regex = new RegExp(`${formattedVersion} `, 'g');
162
162
  versions = versions.map((v) => v.replace(regex, `${formattedVersion}${systemSnapshotLabel} ${constants_1.CURRENT_SYSTEM_VERSION}`));
163
163
  versions.unshift((0, format_1.buildSystemVersionLabel)(formattedVersion, systemSnapshotLabel, systemLatestLabel));
164
164
  }
165
165
  versions.unshift(constants_1.SNAPSHOT_VERSION, constants_1.SNAPSHOT_UNTESTED_VERSION);
166
166
  }
167
- else if (version && systemSnapshotLabel === '') {
167
+ else if (formattedVersion && systemSnapshotLabel === '') {
168
168
  versions = await getHigherVersions(formattedVersion, publicVersions);
169
+ if (!versions.length && formattedVersion !== latestPublicVersion) {
170
+ versions = [`${formattedVersion} ${constants_1.CURRENT_SYSTEM_VERSION}`, `${latestPublicVersion} ${constants_1.LATEST_VERSION}`];
171
+ return [...new Set(versions)];
172
+ }
169
173
  versions.unshift((0, format_1.buildSystemVersionLabel)(formattedVersion, systemSnapshotLabel, systemLatestLabel));
170
174
  }
171
175
  else {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.18.4",
12
+ "version": "0.18.6",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "ejs": "3.1.10",
31
31
  "i18next": "25.3.0",
32
32
  "inquirer": "8.2.7",
33
- "js-yaml": "4.1.0",
33
+ "js-yaml": "4.1.1",
34
34
  "mem-fs": "2.1.0",
35
35
  "mem-fs-editor": "9.4.0",
36
36
  "prompts": "2.4.2",
@@ -39,12 +39,12 @@
39
39
  "@sap-ux/axios-extension": "1.24.2",
40
40
  "@sap-ux/btp-utils": "1.1.5",
41
41
  "@sap-ux/i18n": "0.3.5",
42
- "@sap-ux/inquirer-common": "0.9.3",
42
+ "@sap-ux/inquirer-common": "0.9.4",
43
43
  "@sap-ux/logger": "0.7.1",
44
44
  "@sap-ux/nodejs-utils": "0.2.8",
45
- "@sap-ux/odata-service-writer": "0.27.29",
46
- "@sap-ux/project-access": "1.32.8",
47
- "@sap-ux/project-input-validator": "0.6.30",
45
+ "@sap-ux/odata-service-writer": "0.27.30",
46
+ "@sap-ux/project-access": "1.32.9",
47
+ "@sap-ux/project-input-validator": "0.6.31",
48
48
  "@sap-ux/store": "1.3.3",
49
49
  "@sap-ux/system-access": "0.6.28",
50
50
  "@sap-ux/ui5-config": "0.29.9",