@sap-ux/adp-tooling 0.15.0 → 0.15.2

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.
@@ -1,6 +1,7 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import { type ManifestNamespace } from '@sap-ux/project-access';
2
+ import type { UI5Config } from '@sap-ux/ui5-config';
3
3
  import type { Inbound } from '@sap-ux/axios-extension';
4
+ import { type ManifestNamespace } from '@sap-ux/project-access';
4
5
  import type { DescriptorVariant, AdpPreviewConfig } from '../types';
5
6
  /**
6
7
  * Get the app descriptor variant.
@@ -37,11 +38,27 @@ export declare function flpConfigurationExists(variant: DescriptorVariant): bool
37
38
  */
38
39
  export declare function isTypescriptSupported(basePath: string, fs?: Editor): boolean;
39
40
  /**
40
- * Returns the adaptation project configuration, throws an error if not found.
41
+ * Reads the UI5 YAML configuration and returns the parsed `UI5Config` instance.
41
42
  *
42
- * @param {string} basePath - The path to the adaptation project.
43
- * @param {string} yamlPath - The path to yaml configuration file.
44
- * @returns {Promise<AdpPreviewConfig>} the adp configuration
43
+ * @param {string} basePath - Adaptation project root
44
+ * @param {string} yamlPath - Relative or absolute path to the ui5.yaml file
45
+ * @returns {Promise<UI5Config>} The `UI5Config` object.
46
+ */
47
+ export declare function readUi5Config(basePath: string, yamlPath: string): Promise<UI5Config>;
48
+ /**
49
+ * Extracts the `adp` preview configuration from a UI5 YAML config (if present).
50
+ *
51
+ * @param {UI5Config} ui5Conf Parsed UI5 configuration
52
+ * @returns The `AdpPreviewConfig` object if found, otherwise `undefined`.
53
+ */
54
+ export declare function extractAdpConfig(ui5Conf: UI5Config): AdpPreviewConfig | undefined;
55
+ /**
56
+ * Convenience wrapper that reads the ui5.yaml and directly returns the ADP preview configuration.
57
+ * Throws if the configuration cannot be found.
58
+ *
59
+ * @param basePath Adaptation project root
60
+ * @param yamlPath Relative or absolute path to the ui5.yaml file
61
+ * @returns The `AdpPreviewConfig` object if found, otherwise throws an error.
45
62
  */
46
63
  export declare function getAdpConfig(basePath: string, yamlPath: string): Promise<AdpPreviewConfig>;
47
64
  /**
@@ -4,6 +4,8 @@ exports.getVariant = getVariant;
4
4
  exports.updateVariant = updateVariant;
5
5
  exports.flpConfigurationExists = flpConfigurationExists;
6
6
  exports.isTypescriptSupported = isTypescriptSupported;
7
+ exports.readUi5Config = readUi5Config;
8
+ exports.extractAdpConfig = extractAdpConfig;
7
9
  exports.getAdpConfig = getAdpConfig;
8
10
  exports.getWebappFiles = getWebappFiles;
9
11
  exports.filterAndMapInboundsToManifest = filterAndMapInboundsToManifest;
@@ -58,29 +60,48 @@ function isTypescriptSupported(basePath, fs) {
58
60
  return fs ? fs.exists(path) : (0, fs_1.existsSync)(path);
59
61
  }
60
62
  /**
61
- * Returns the adaptation project configuration, throws an error if not found.
63
+ * Reads the UI5 YAML configuration and returns the parsed `UI5Config` instance.
62
64
  *
63
- * @param {string} basePath - The path to the adaptation project.
64
- * @param {string} yamlPath - The path to yaml configuration file.
65
- * @returns {Promise<AdpPreviewConfig>} the adp configuration
65
+ * @param {string} basePath - Adaptation project root
66
+ * @param {string} yamlPath - Relative or absolute path to the ui5.yaml file
67
+ * @returns {Promise<UI5Config>} The `UI5Config` object.
66
68
  */
67
- async function getAdpConfig(basePath, yamlPath) {
69
+ async function readUi5Config(basePath, yamlPath) {
68
70
  const ui5ConfigPath = (0, path_1.isAbsolute)(yamlPath) ? yamlPath : (0, path_1.join)(basePath, yamlPath);
69
- let ui5Conf;
70
- let adp;
71
+ return (0, project_access_1.readUi5Yaml)((0, path_1.dirname)(ui5ConfigPath), (0, path_1.basename)(ui5ConfigPath));
72
+ }
73
+ /**
74
+ * Extracts the `adp` preview configuration from a UI5 YAML config (if present).
75
+ *
76
+ * @param {UI5Config} ui5Conf Parsed UI5 configuration
77
+ * @returns The `AdpPreviewConfig` object if found, otherwise `undefined`.
78
+ */
79
+ function extractAdpConfig(ui5Conf) {
80
+ const customMiddleware = ui5Conf.findCustomMiddleware('fiori-tools-preview') ??
81
+ ui5Conf.findCustomMiddleware('preview-middleware');
82
+ return customMiddleware?.configuration?.adp;
83
+ }
84
+ /**
85
+ * Convenience wrapper that reads the ui5.yaml and directly returns the ADP preview configuration.
86
+ * Throws if the configuration cannot be found.
87
+ *
88
+ * @param basePath Adaptation project root
89
+ * @param yamlPath Relative or absolute path to the ui5.yaml file
90
+ * @returns The `AdpPreviewConfig` object if found, otherwise throws an error.
91
+ */
92
+ async function getAdpConfig(basePath, yamlPath) {
71
93
  try {
72
- ui5Conf = await (0, project_access_1.readUi5Yaml)((0, path_1.dirname)(ui5ConfigPath), (0, path_1.basename)(ui5ConfigPath));
73
- const customMiddleware = ui5Conf.findCustomMiddleware('fiori-tools-preview') ??
74
- ui5Conf.findCustomMiddleware('preview-middleware');
75
- adp = customMiddleware?.configuration?.adp;
94
+ const ui5Conf = await readUi5Config(basePath, yamlPath);
95
+ const adp = extractAdpConfig(ui5Conf);
96
+ if (!adp) {
97
+ throw new Error('Could not extract ADP configuration from ui5.yaml');
98
+ }
99
+ return adp;
76
100
  }
77
101
  catch (error) {
78
- // do nothing here
79
- }
80
- if (!adp) {
102
+ const ui5ConfigPath = (0, path_1.isAbsolute)(yamlPath) ? yamlPath : (0, path_1.join)(basePath, yamlPath);
81
103
  throw new Error(`No system configuration found in ${(0, path_1.basename)(ui5ConfigPath)}`);
82
104
  }
83
- return adp;
84
105
  }
85
106
  /**
86
107
  * Get all files in the webapp folder.
@@ -64,7 +64,8 @@ function getPrompts(basePath, dataSources) {
64
64
  if (!(0, fs_1.existsSync)(filePath)) {
65
65
  return (0, i18n_1.t)('validators.fileDoesNotExist');
66
66
  }
67
- if ((0, fs_1.existsSync)((0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), project_access_1.DirName.Changes, project_access_1.DirName.Annotations, (0, path_1.basename)(filePath)))) {
67
+ const annotationFilePath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), project_access_1.DirName.Changes, project_access_1.DirName.Annotations, (0, path_1.basename)(filePath));
68
+ if ((0, fs_1.existsSync)(annotationFilePath)) {
68
69
  return (0, i18n_1.t)('validators.annotationFileAlreadyExists');
69
70
  }
70
71
  return true;
@@ -100,7 +100,7 @@ function getPrompts(basePath, layer) {
100
100
  return [
101
101
  {
102
102
  type: 'input',
103
- name: `usageId`,
103
+ name: 'usageId',
104
104
  message: (0, i18n_1.t)('prompts.component.usageIdLabel'),
105
105
  validate: (value) => validatePromptId(value, componentUsageChangeFiles, isCustomerBase),
106
106
  default: isCustomerBase ? "customer." /* NamespacePrefix.CUSTOMER */ : "" /* NamespacePrefix.EMPTY */,
@@ -135,7 +135,7 @@ function getPrompts(basePath, layer) {
135
135
  },
136
136
  {
137
137
  type: 'editor',
138
- name: `settings`,
138
+ name: 'settings',
139
139
  message: (0, i18n_1.t)('prompts.component.settingsLabel'),
140
140
  validate: validatePromptJSON,
141
141
  store: false,
@@ -176,7 +176,7 @@ function getPrompts(basePath, layer) {
176
176
  },
177
177
  {
178
178
  type: 'list',
179
- name: `libraryIsLazy`,
179
+ name: 'libraryIsLazy',
180
180
  message: (0, i18n_1.t)('prompts.component.libraryIsLazyLabel'),
181
181
  choices: isLazyDropDownOptions,
182
182
  default: isLazyDropDownOptions[1].value,
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.15.0",
12
+ "version": "0.15.2",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "@sap-ux/ui5-config": "0.29.0",
44
44
  "@sap-ux/ui5-info": "0.12.0",
45
45
  "@sap-ux/odata-service-writer": "0.27.12",
46
- "@sap-ux/nodejs-utils": "0.2.1",
46
+ "@sap-ux/nodejs-utils": "0.2.2",
47
47
  "@sap-ux/i18n": "0.3.1",
48
48
  "@sap-ux/store": "1.1.2"
49
49
  },