@sap-ux/cf-deploy-config-writer 0.3.82 → 0.3.84

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/README.md CHANGED
@@ -45,29 +45,10 @@ await mtaConfig.addMtaExtensionConfig('mynewdestination', 'https://my-service-ur
45
45
  await mtaConfig.save();
46
46
  ```
47
47
 
48
- ## Example: Appending a `Managed` Approuter Configuration to an SAP Fiori UI5 Application
49
-
50
- Calling the `generateAppConfig` function to append Cloud Foundry configuration to a HTML5 application, assumes `manifest.json` and `ui5.yaml` configurations are present otherwise the process will exit with an error;
51
- ```Typescript
52
- import { generateAppConfig, DefaultMTADestination } from '@sap-ux/cf-deploy-config-writer'
53
- import { join } from 'path';
54
-
55
- const exampleWriter = async () => {
56
- const ui5AppPath = join(__dirname, 'testapp');
57
- // Option 1. Append managed approuter configuration, toggle `addManagedAppRouter` to false to ommit the managed approuter configuration being appended to the mta.yaml
58
- const fs = await generateAppConfig({appPath: ui5AppPath, addManagedAppRouter: true, destinationName: 'SAPBTPDestination'});
59
- return new Promise((resolve) => {
60
- fs.commit(resolve); // When using with Yeoman it handle the fs commit.
61
- });
62
- }
63
- // Calling the function
64
- await exampleWriter();
65
- ```
66
-
67
48
  ## Example: Generate or Append a `Managed` Approuter Configuration to a SAP Fiori UI5 Application
68
49
 
69
50
  Calling the `generateAppConfig` function to append Cloud Foundry configuration to a HTML5 application;
70
- - Assumes `manifest.json` and `ui5.yaml` configurations are present in the target folder
51
+ - Assumes `manifest.json` and `ui5.yaml` configurations are present in the target folder, otherwise the process will exit with an error
71
52
  - Supports `CAP` projects where an existing `mta.yaml` is already present and you are adding a SAP Fiori UI5 app to it
72
53
 
73
54
  ```Typescript
@@ -76,12 +57,12 @@ import { join } from 'path';
76
57
 
77
58
  const exampleWriter = async () => {
78
59
  const ui5AppPath = join(__dirname, 'testapp');
79
- // Option 1. Append managed approuter configuration, toggle `addManagedAppRouter` to false to ommit the managed approuter configuration being appended to the mta.yaml
80
- const fs = await generateAppConfig({appPath: ui5AppPath, addManagedAppRouter: true, destinationName: 'SAPBTPDestination'});
60
+ // Option 1. Append managed approuter configuration, toggle `addManagedAppRouter` to false to omit the managed approuter configuration being appended to the mta.yaml
61
+ const fs1 = await generateAppConfig({appPath: ui5AppPath, addManagedAppRouter: true, destinationName: 'SAPBTPDestination'});
81
62
  // Option 2. For CAP flows, set the destination to DefaultMTADestination to create a destination instance between the HTML5 app and CAP Project
82
- const fs = await generateAppConfig({appPath: ui5AppPath, addManagedAppRouter: true, destinationName: DefaultMTADestination});
63
+ const fs2 = await generateAppConfig({appPath: ui5AppPath, addManagedAppRouter: true, destinationName: DefaultMTADestination});
83
64
  return new Promise((resolve) => {
84
- fs.commit(resolve); // When using with Yeoman it handle the fs commit.
65
+ fs2.commit(resolve); // When using with Yeoman it handles the fs commit.
85
66
  });
86
67
  }
87
68
  // Calling the function
@@ -100,12 +81,12 @@ import { join } from 'path';
100
81
 
101
82
  const exampleWriter = async () => {
102
83
  const mtaPath = join(__dirname, 'testproject');
103
- // If your SAPUI5 application will be consuming an SAB BTP OnPremise destination, Connectivity serivce is required; Refer to https://discovery-center.cloud.sap/serviceCatalog/connectivity-service?region=all
84
+ // If your SAPUI5 application will be consuming an SAP BTP OnPremise destination, Connectivity service is required; Refer to https://discovery-center.cloud.sap/serviceCatalog/connectivity-service?region=all
104
85
  const addConnectivityService = true;
105
- // Generate an approuter configuration, with the default being a Managed Approuter, toggle the routerType to genereate RouterModuleType.AppFront or RouterModuleType.Standard configurations
86
+ // Generate an approuter configuration, with the default being a Managed Approuter, toggle the routerType to generate RouterModuleType.AppFront or RouterModuleType.Standard configurations
106
87
  const fs = await generateBaseConfig({ mtaId: 'mymtaproject', routerType: RouterModuleType.Managed, mtaPath, addConnectivityService });
107
88
  return new Promise((resolve) => {
108
- fs.commit(resolve); // When using with Yeoman it handle the fs commit.
89
+ fs.commit(resolve); // When using with Yeoman it handles the fs commit.
109
90
  });
110
91
  }
111
92
  // Calling the function
@@ -124,10 +105,10 @@ import { join } from 'path';
124
105
 
125
106
  const exampleWriter = async () => {
126
107
  const mtaPath = join(__dirname, 'testcapproject');
127
- // Generate an approuter configuration, with the default being a Managed Approuter, toggle the routerType to genereate RouterModuleType.AppFront or RouterModuleType.Standard configurations
108
+ // Generate an approuter configuration, with the default being a Managed Approuter, toggle the routerType to generate RouterModuleType.AppFront or RouterModuleType.Standard configurations
128
109
  const fs = await generateCAPConfig({ mtaId: 'mymtaproject', routerType: RouterModuleType.Managed, mtaPath });
129
110
  return new Promise((resolve) => {
130
- fs.commit(resolve); // When using with Yeoman it handle the fs commit.
111
+ fs.commit(resolve); // When using with Yeoman it handles the fs commit.
131
112
  });
132
113
  }
133
114
  // Calling the function
@@ -152,6 +133,30 @@ For example, the following configuration will be appended to the `xs-app.json` r
152
133
 
153
134
  Replace `<apply-service-segment-path>` with the actual service path you want to use, for example `/sap` or `/myservice`;
154
135
 
136
+ ## Error Handling
137
+
138
+ The package throws errors in the following scenarios:
139
+ - **MTA Binary Not Found**: If the MTA tool is not installed or not in PATH
140
+ - **Invalid MTA ID**: If the MTA ID doesn't meet naming requirements (must start with letter/underscore, max 128 chars, only letters/numbers/dashes/periods/underscores)
141
+ - **Missing Required Files**: If `manifest.json` or `ui5.yaml` are missing for UI5 app configuration
142
+ - **Existing MTA Configuration**: If an `mta.yaml` file already exists when generating base config
143
+ - **Missing ABAP Service Details**: If ABAP service binding is specified without required service details
144
+ - **Invalid CAP Project**: If the target folder doesn't contain a valid Node.js CAP project
145
+
146
+ All error messages support internationalization (i18n) for proper localization.
147
+
148
+ ## CAP Project Considerations
149
+
150
+ When using `generateCAPConfig`, note that CAP projects do not support direct ABAP service binding. The `CAPConfig` interface intentionally excludes `abapServiceProvider` properties to provide type safety and semantic clarity for CAP-specific deployments.
151
+
152
+ ## MTA Module Naming
153
+
154
+ Application names are automatically converted to MTA-compatible module names by:
155
+ - Removing special characters (`` `~!@#$%^&*£()|+=?;:'",.<>`` )
156
+ - Keeping only letters, numbers, dots (.), hyphens (-), and underscores (_)
157
+ - Truncating to maximum allowed length (128 characters for IDs)
158
+
159
+ For example: `sap.ux.app` remains `sap.ux.app`, but `my-app@v1.0` becomes `my-appv1.0`
155
160
 
156
161
  ## Keywords
157
162
  SAP Fiori elements
@@ -4,25 +4,27 @@ import { type CFAppConfig, type CFConfig } from '../types';
4
4
  /**
5
5
  * Add a managed approuter configuration to an existing HTML5 application, any exceptions thrown will be handled by the calling client.
6
6
  *
7
- * @param cfAppConfig writer configuration
8
- * @param fs an optional reference to a mem-fs editor
9
- * @param logger optional logger instance
10
- * @returns file system reference
7
+ * @param cfAppConfig Writer configuration
8
+ * @param fs An optional reference to a mem-fs editor
9
+ * @param logger Optional logger instance
10
+ * @returns File system reference
11
+ * @throws {Error} If MTA binary is not found in the system path
12
+ * @throws {Error} If required files (manifest.json, ui5.yaml) are missing or invalid
11
13
  */
12
14
  export declare function generateAppConfig(cfAppConfig: CFAppConfig, fs?: Editor, logger?: Logger): Promise<Editor>;
13
15
  /**
14
16
  * Creates the MTA configuration file.
15
17
  *
16
- * @param cfConfig writer configuration
17
- * @param fs reference to a mem-fs editor
18
+ * @param cfConfig Writer configuration containing MTA details
19
+ * @param fs Reference to a mem-fs editor
20
+ * @throws {Error} If MTA file creation or CAP MTA generation fails
18
21
  */
19
22
  export declare function generateMTAFile(cfConfig: CFConfig, fs: Editor): Promise<void>;
20
23
  /**
21
24
  * Generate UI5 deploy config.
22
25
  *
23
- * @param cfConfig - the deployment config
24
- * @param fs reference to a mem-fs editor
25
- * @returns the deploy config
26
+ * @param cfConfig The deployment configuration
27
+ * @param fs Reference to a mem-fs editor
26
28
  */
27
29
  export declare function generateUI5DeployConfig(cfConfig: CFConfig, fs: Editor): Promise<void>;
28
30
  //# sourceMappingURL=app-config.d.ts.map
@@ -20,10 +20,12 @@ const i18n_1 = require("../i18n");
20
20
  /**
21
21
  * Add a managed approuter configuration to an existing HTML5 application, any exceptions thrown will be handled by the calling client.
22
22
  *
23
- * @param cfAppConfig writer configuration
24
- * @param fs an optional reference to a mem-fs editor
25
- * @param logger optional logger instance
26
- * @returns file system reference
23
+ * @param cfAppConfig Writer configuration
24
+ * @param fs An optional reference to a mem-fs editor
25
+ * @param logger Optional logger instance
26
+ * @returns File system reference
27
+ * @throws {Error} If MTA binary is not found in the system path
28
+ * @throws {Error} If required files (manifest.json, ui5.yaml) are missing or invalid
27
29
  */
28
30
  async function generateAppConfig(cfAppConfig, fs, logger) {
29
31
  fs ??= (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
@@ -37,9 +39,10 @@ async function generateAppConfig(cfAppConfig, fs, logger) {
37
39
  /**
38
40
  * Returns the updated configuration for the given HTML5 app, after reading all the required files.
39
41
  *
40
- * @param cfAppConfig writer configuration
41
- * @param fs reference to a mem-fs editor
42
- * @returns updated writer configuration
42
+ * @param cfAppConfig Writer configuration
43
+ * @param fs Reference to a mem-fs editor
44
+ * @returns Updated writer configuration
45
+ * @throws {Error} If no SAP Fiori UI5 application is found (missing app ID)
43
46
  */
44
47
  async function getUpdatedConfig(cfAppConfig, fs) {
45
48
  const isLCAP = cfAppConfig.lcapMode ?? false;
@@ -47,7 +50,7 @@ async function getUpdatedConfig(cfAppConfig, fs) {
47
50
  const { serviceHost, destination, firstServicePathSegmentUI5Config } = await processUI5Config(cfAppConfig.appPath, fs);
48
51
  const { servicePath, firstServicePathSegment, appId } = await processManifest(cfAppConfig.appPath, fs);
49
52
  if (!appId) {
50
- throw new Error('No SAP Fiori UI5 application found.');
53
+ throw new Error((0, i18n_1.t)('error.noUI5AppFound'));
51
54
  }
52
55
  const { destinationIsFullUrl, destinationAuthentication } = await (0, utils_1.getDestinationProperties)(cfAppConfig.destinationName ?? destination);
53
56
  (0, utils_1.enforceValidRouterConfig)(cfAppConfig);
@@ -146,8 +149,9 @@ async function processManifest(appPath, fs) {
146
149
  /**
147
150
  * Generates the deployment configuration for the HTML5 application.
148
151
  *
149
- * @param cfAppConfig writer configuration
150
- * @param fs reference to a mem-fs editor
152
+ * @param cfAppConfig Writer configuration
153
+ * @param fs Reference to a mem-fs editor
154
+ * @throws {Error} If MTA generation or configuration update fails
151
155
  */
152
156
  async function generateDeployConfig(cfAppConfig, fs) {
153
157
  logger_helper_1.default?.logger?.debug(`Generate HTML5 app deployment configuration with: \n ${JSON.stringify(cfAppConfig)}`);
@@ -168,8 +172,9 @@ async function generateDeployConfig(cfAppConfig, fs) {
168
172
  /**
169
173
  * Creates the MTA configuration file.
170
174
  *
171
- * @param cfConfig writer configuration
172
- * @param fs reference to a mem-fs editor
175
+ * @param cfConfig Writer configuration containing MTA details
176
+ * @param fs Reference to a mem-fs editor
177
+ * @throws {Error} If MTA file creation or CAP MTA generation fails
173
178
  */
174
179
  async function generateMTAFile(cfConfig, fs) {
175
180
  // Step1. Create mta.yaml
@@ -191,8 +196,9 @@ async function generateMTAFile(cfConfig, fs) {
191
196
  /**
192
197
  * Updates the MTA configuration file with the app router and destination.
193
198
  *
194
- * @param cfConfig writer configuration
195
- * @param fs reference to a mem-fs editor
199
+ * @param cfConfig Writer configuration
200
+ * @param fs Reference to a mem-fs editor
201
+ * @throws {Error} If MTA configuration update or save fails
196
202
  */
197
203
  async function appendAppRouter(cfConfig, fs) {
198
204
  const mtaInstance = await (0, mta_config_1.getMtaConfig)(cfConfig.rootPath);
@@ -225,12 +231,12 @@ async function appendAppRouter(cfConfig, fs) {
225
231
  /**
226
232
  * Cleans up standalone routes in a Cloud Foundry application configuration.
227
233
  *
228
- * @param {object} cfConfig - The Cloud Foundry configuration object
229
- * @param {string} cfConfig.rootPath - The root path of the application
230
- * @param {string} cfConfig.appId - The application identifier
231
- * @param {MtaConfig} mtaInstance - The MTA configuration instance
232
- * @param {Editor} fs - The file system editor for performing cleanup operations
233
- * @returns {void} - This function does not return a value
234
+ * @param cfConfig The Cloud Foundry configuration object
235
+ * @param cfConfig.rootPath The root path of the application
236
+ * @param cfConfig.appId The application identifier
237
+ * @param mtaInstance The MTA configuration instance
238
+ * @param fs The file system editor for performing cleanup operations
239
+ * @throws {Error} If xs-app.json cannot be read or updated
234
240
  */
235
241
  function cleanupStandaloneRoutes({ rootPath, appId }, mtaInstance, fs) {
236
242
  // Cleanup standalone xs-app.json to reflect new application
@@ -252,8 +258,9 @@ function cleanupStandaloneRoutes({ rootPath, appId }, mtaInstance, fs) {
252
258
  /**
253
259
  * Apply changes to mta.yaml, will retry if an exception is thrown.
254
260
  *
255
- * @param cfConfig writer configuration
261
+ * @param cfConfig Writer configuration
256
262
  * @param mtaInstance MTA configuration instance
263
+ * @throws {Error} If MTA extension configuration cannot be added for API Hub Enterprise
257
264
  */
258
265
  async function saveMta(cfConfig, mtaInstance) {
259
266
  try {
@@ -280,8 +287,8 @@ async function saveMta(cfConfig, mtaInstance) {
280
287
  /**
281
288
  * Appends the Cloud Foundry specific configurations to the project.
282
289
  *
283
- * @param cfConfig writer configuration
284
- * @param fs reference to a mem-fs editor
290
+ * @param cfConfig Writer configuration
291
+ * @param fs Reference to a mem-fs editor
285
292
  */
286
293
  async function appendCloudFoundryConfigurations(cfConfig, fs) {
287
294
  // When data source is none in app generator, it is not required to provide destination
@@ -308,8 +315,8 @@ async function appendCloudFoundryConfigurations(cfConfig, fs) {
308
315
  * Updates the manifest.json file with the cloud service name.
309
316
  * Preserves existing sap.cloud properties while updating public and service values.
310
317
  *
311
- * @param cfConfig writer configuration
312
- * @param fs reference to a mem-fs editor
318
+ * @param cfConfig Writer configuration
319
+ * @param fs Reference to a mem-fs editor
313
320
  */
314
321
  async function updateManifest(cfConfig, fs) {
315
322
  const webappPath = await (0, project_access_1.getWebappPath)(cfConfig.appPath, fs);
@@ -329,8 +336,8 @@ async function updateManifest(cfConfig, fs) {
329
336
  /**
330
337
  * Updates the package.json file with the necessary scripts and dependencies.
331
338
  *
332
- * @param cfConfig writer configuration
333
- * @param fs reference to a mem-fs editor
339
+ * @param cfConfig Writer configuration
340
+ * @param fs Reference to a mem-fs editor
334
341
  */
335
342
  async function updateHTML5AppPackage(cfConfig, fs) {
336
343
  let deployArgs = [];
@@ -356,9 +363,8 @@ async function updateHTML5AppPackage(cfConfig, fs) {
356
363
  /**
357
364
  * Generate UI5 deploy config.
358
365
  *
359
- * @param cfConfig - the deployment config
360
- * @param fs reference to a mem-fs editor
361
- * @returns the deploy config
366
+ * @param cfConfig The deployment configuration
367
+ * @param fs Reference to a mem-fs editor
362
368
  */
363
369
  async function generateUI5DeployConfig(cfConfig, fs) {
364
370
  const ui5BaseConfig = await (0, project_access_1.readUi5Yaml)(cfConfig.appPath, project_access_1.FileName.Ui5Yaml, fs);
@@ -4,10 +4,11 @@ import { type CFBaseConfig } from '../types';
4
4
  /**
5
5
  * Add a standalone | managed | frontend app router to an empty target folder.
6
6
  *
7
- * @param config writer configuration
8
- * @param fs an optional reference to a mem-fs editor
9
- * @param logger optional logger instance
10
- * @returns file system reference
7
+ * @param config Writer configuration
8
+ * @param fs An optional reference to a mem-fs editor
9
+ * @param logger Optional logger instance
10
+ * @returns File system reference
11
+ * @throws {Error} If MTA binary is not found, configuration is invalid, or mta.yaml already exists
11
12
  */
12
13
  export declare function generateBaseConfig(config: CFBaseConfig, fs?: Editor, logger?: Logger): Promise<Editor>;
13
14
  //# sourceMappingURL=base-config.d.ts.map
@@ -14,10 +14,11 @@ const i18n_1 = require("../i18n");
14
14
  /**
15
15
  * Add a standalone | managed | frontend app router to an empty target folder.
16
16
  *
17
- * @param config writer configuration
18
- * @param fs an optional reference to a mem-fs editor
19
- * @param logger optional logger instance
20
- * @returns file system reference
17
+ * @param config Writer configuration
18
+ * @param fs An optional reference to a mem-fs editor
19
+ * @param logger Optional logger instance
20
+ * @returns File system reference
21
+ * @throws {Error} If MTA binary is not found, configuration is invalid, or mta.yaml already exists
21
22
  */
22
23
  async function generateBaseConfig(config, fs, logger) {
23
24
  fs ??= (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
@@ -26,8 +27,9 @@ async function generateBaseConfig(config, fs, logger) {
26
27
  }
27
28
  logger?.debug(`Generate base configuration using: \n ${JSON.stringify(config)}`);
28
29
  (0, mta_config_1.validateMtaConfig)(config);
30
+ // Check if mta.yaml already exists in the target directory
29
31
  if ((0, utils_1.fileExists)(fs, (0, node_path_1.join)(config.mtaPath, config.mtaId))) {
30
- throw new Error((0, i18n_1.t)('error.mtaFolderAlreadyExists'));
32
+ throw new Error((0, i18n_1.t)('error.mtaAlreadyExists'));
31
33
  }
32
34
  (0, mta_config_1.createMTA)(config);
33
35
  await (0, mta_config_1.addRoutingConfig)(config, fs);
@@ -4,10 +4,12 @@ import { type CAPConfig } from '../types';
4
4
  /**
5
5
  * Add a standalone | managed approuter to a CAP project.
6
6
  *
7
- * @param config writer configuration
8
- * @param fs an optional reference to a mem-fs editor
9
- * @param logger optional logger instance
10
- * @returns file system reference
7
+ * @param config Writer configuration
8
+ * @param fs An optional reference to a mem-fs editor
9
+ * @param logger Optional logger instance
10
+ * @returns File system reference
11
+ * @throws {Error} If target folder does not contain a Node.js CAP project
12
+ * @throws {Error} If mta.yaml already exists in the target directory
11
13
  */
12
14
  export declare function generateCAPConfig(config: CAPConfig, fs?: Editor, logger?: Logger): Promise<Editor>;
13
15
  //# sourceMappingURL=cap-config.d.ts.map
@@ -15,10 +15,12 @@ const constants_1 = require("../constants");
15
15
  /**
16
16
  * Add a standalone | managed approuter to a CAP project.
17
17
  *
18
- * @param config writer configuration
19
- * @param fs an optional reference to a mem-fs editor
20
- * @param logger optional logger instance
21
- * @returns file system reference
18
+ * @param config Writer configuration
19
+ * @param fs An optional reference to a mem-fs editor
20
+ * @param logger Optional logger instance
21
+ * @returns File system reference
22
+ * @throws {Error} If target folder does not contain a Node.js CAP project
23
+ * @throws {Error} If mta.yaml already exists in the target directory
22
24
  */
23
25
  async function generateCAPConfig(config, fs, logger) {
24
26
  fs ??= (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
@@ -38,7 +40,9 @@ async function generateCAPConfig(config, fs, logger) {
38
40
  /**
39
41
  * Ensure the configuration is valid, target folder exists and is a CAP Node.js app and mta.yaml does not already exist.
40
42
  *
41
- * @param config writer configuration
43
+ * @param config Writer configuration
44
+ * @throws {Error} If target folder does not contain a CAP Node.js project
45
+ * @throws {Error} If mta.yaml already exists in the target directory
42
46
  */
43
47
  async function validateConfig(config) {
44
48
  (0, mta_config_1.validateMtaConfig)(config);
package/dist/i18n.js CHANGED
@@ -25,8 +25,7 @@ async function initI18n() {
25
25
  lng: 'en',
26
26
  fallbackLng: 'en',
27
27
  defaultNS: NS,
28
- ns: [NS],
29
- showSupportNotice: false
28
+ ns: [NS]
30
29
  });
31
30
  }
32
31
  /**
@@ -19,6 +19,7 @@ export declare function getMtaConfig(rootPath: string): Promise<MtaConfig | unde
19
19
  /**
20
20
  * Generate an MTA ID that is suitable for CF deployment.
21
21
  * Removes special characters and restricts length to maximum allowed.
22
+ * Note: This delegates to the utility function and adds length restriction.
22
23
  *
23
24
  * @param appId Name of the app, like `sap.ux.app`
24
25
  * @returns Name that's acceptable for mta.yaml (sanitized and length-restricted)
@@ -43,22 +44,27 @@ export declare function doesCDSBinaryExist(): void;
43
44
  /**
44
45
  * Validate the writer configuration to ensure all required parameters are present.
45
46
  *
46
- * @param config writer configuration
47
- * @throws {Error} If validation fails
47
+ * @param config Writer configuration
48
+ * @throws {Error} If MTA binary is not found in system path
49
+ * @throws {Error} If required MTA parameters (routerType, mtaId, mtaPath) are missing
50
+ * @throws {Error} If MTA ID is invalid (too long, invalid characters, or doesn't start with letter/underscore)
51
+ * @throws {Error} If MTA version is invalid
52
+ * @throws {Error} If ABAP service binding details are incomplete
48
53
  */
49
54
  export declare function validateMtaConfig(config: CFBaseConfig): void;
50
55
  /**
51
56
  * Add standalone | managed | frontend app router to the target folder.
52
57
  *
53
- * @param config writer configuration
54
- * @param fs reference to a mem-fs editor
58
+ * @param config Writer configuration
59
+ * @param fs Reference to a mem-fs editor
55
60
  */
56
61
  export declare function addRoutingConfig(config: CFBaseConfig, fs: Editor): Promise<void>;
57
62
  /**
58
63
  * Create an MTA file in the target folder, needs to be written to disk as subsequent calls are dependent on it being on the file system i.e mta-lib.
59
64
  *
60
- * @param config writer configuration
61
- * @param fs reference to a mem-fs editor
65
+ * @param config Writer configuration
66
+ * @param fs Reference to a mem-fs editor
67
+ * @throws {Error} If CDS command execution fails when generating mta.yaml
62
68
  */
63
69
  export declare function generateCAPMTA(config: CAPConfig, fs: Editor): Promise<void>;
64
70
  export * from './mta';
@@ -76,15 +76,14 @@ async function getMtaConfig(rootPath) {
76
76
  /**
77
77
  * Generate an MTA ID that is suitable for CF deployment.
78
78
  * Removes special characters and restricts length to maximum allowed.
79
+ * Note: This delegates to the utility function and adds length restriction.
79
80
  *
80
81
  * @param appId Name of the app, like `sap.ux.app`
81
82
  * @returns Name that's acceptable for mta.yaml (sanitized and length-restricted)
82
83
  */
83
84
  function toMtaModuleName(appId) {
84
- // Remove special characters not allowed in MTA module names
85
- // MTA IDs must contain only alphanumeric characters, hyphens, underscores, and dots
86
- // Using replaceAll for global replacement (Sonar S7781)
87
- return appId.replaceAll(/[`~!@#$%^&*()_|+\-=?;:'",.<>]/gi, '').slice(0, constants_1.MAX_MTA_ID_LENGTH);
85
+ // Use the canonical implementation from utils and apply length restriction
86
+ return (0, utils_1.toMtaModuleName)(appId).slice(0, constants_1.MAX_MTA_ID_LENGTH);
88
87
  }
89
88
  /**
90
89
  * Create an MTA file in the target folder, needs to be written to disk as subsequent calls are dependent on it being on the file system i.e mta-lib.
@@ -127,8 +126,12 @@ function doesCDSBinaryExist() {
127
126
  /**
128
127
  * Validate the writer configuration to ensure all required parameters are present.
129
128
  *
130
- * @param config writer configuration
131
- * @throws {Error} If validation fails
129
+ * @param config Writer configuration
130
+ * @throws {Error} If MTA binary is not found in system path
131
+ * @throws {Error} If required MTA parameters (routerType, mtaId, mtaPath) are missing
132
+ * @throws {Error} If MTA ID is invalid (too long, invalid characters, or doesn't start with letter/underscore)
133
+ * @throws {Error} If MTA version is invalid
134
+ * @throws {Error} If ABAP service binding details are incomplete
132
135
  */
133
136
  function validateMtaConfig(config) {
134
137
  // We use mta-lib, which in turn relies on the mta executable being installed and available in the path
@@ -151,12 +154,11 @@ function validateMtaConfig(config) {
151
154
  }
152
155
  /**
153
156
  * Create an MTA file in the target folder, needs to be written to disk as subsequent calls are dependent on it being on the file system i.e mta-lib.
154
- *
155
157
  * Note: this function is deprecated and will be removed in future releases since the cds binary currently does not support app frontend services.
156
158
  *
157
- * @param config writer configuration
158
- * @param fs reference to a mem-fs editor
159
- * @deprecated this function is deprecated and will be removed in future releases
159
+ * @param config Writer configuration
160
+ * @param fs Reference to a mem-fs editor
161
+ * @deprecated This function is deprecated and will be removed in future releases
160
162
  */
161
163
  async function createCAPMTAAppFrontend(config, fs) {
162
164
  const mtaTemplate = (0, node_fs_1.readFileSync)((0, utils_1.getTemplatePath)(`frontend/${project_access_1.FileName.MtaYaml}`), 'utf-8');
@@ -172,11 +174,12 @@ async function createCAPMTAAppFrontend(config, fs) {
172
174
  logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaCreated', { mtaPath: config.mtaPath }));
173
175
  }
174
176
  /**
175
- * Add standalone app router to the target folder.
177
+ * Add standalone app router to the target folder.
176
178
  *
177
- * @param cfConfig writer configuration
179
+ * @param cfConfig Writer configuration
178
180
  * @param mtaInstance MTA configuration instance
179
- * @param fs reference to a mem-fs editor
181
+ * @param fs Reference to a mem-fs editor
182
+ * @throws {Error} If service key retrieval fails for ABAP service binding
180
183
  */
181
184
  async function addStandaloneRouter(cfConfig, mtaInstance, fs) {
182
185
  await mtaInstance.addStandaloneRouter(true);
@@ -208,8 +211,8 @@ async function addStandaloneRouter(cfConfig, mtaInstance, fs) {
208
211
  /**
209
212
  * Add standalone | managed | frontend app router to the target folder.
210
213
  *
211
- * @param config writer configuration
212
- * @param fs reference to a mem-fs editor
214
+ * @param config Writer configuration
215
+ * @param fs Reference to a mem-fs editor
213
216
  */
214
217
  async function addRoutingConfig(config, fs) {
215
218
  const mtaConfigInstance = await getMtaConfig(config.mtaPath);
@@ -227,8 +230,9 @@ async function addRoutingConfig(config, fs) {
227
230
  /**
228
231
  * Create an MTA file in the target folder, needs to be written to disk as subsequent calls are dependent on it being on the file system i.e mta-lib.
229
232
  *
230
- * @param config writer configuration
231
- * @param fs reference to a mem-fs editor
233
+ * @param config Writer configuration
234
+ * @param fs Reference to a mem-fs editor
235
+ * @throws {Error} If CDS command execution fails when generating mta.yaml
232
236
  */
233
237
  async function generateCAPMTA(config, fs) {
234
238
  if (config.routerType === types_1.RouterModuleType.AppFront) {
@@ -39,9 +39,9 @@ export declare class MtaConfig {
39
39
  /**
40
40
  * Determines if the MTA configuration contains a known resource or module.
41
41
  *
42
- * @param requires resource to validate
43
- * @param resourceType managed or existing service
44
- * @returns true if the resource exists, false otherwise
42
+ * @param requires Resource requirements array to validate
43
+ * @param resourceType Managed or existing service type identifier
44
+ * @returns True if the resource exists, false otherwise
45
45
  * @private
46
46
  */
47
47
  private targetExists;
@@ -70,21 +70,21 @@ export declare class MtaConfig {
70
70
  /**
71
71
  * Add a destination service to the MTA.
72
72
  *
73
- * @param isManagedApp - If the destination service is for a managed app
73
+ * @param isManagedApp If the destination service is for a managed app (default: false)
74
74
  */
75
75
  private addDestinationResource;
76
76
  /**
77
77
  * Update the destination service in the MTA if not already present.
78
78
  *
79
- * @param isManagedApp - If the destination service is for a managed app, false by default
79
+ * @param isManagedApp If the destination service is for a managed app (default: false)
80
80
  */
81
81
  private updateDestinationResource;
82
82
  /**
83
83
  * Update the server module to include the required dependencies to ensure endpoints are secured.
84
84
  *
85
- * @param moduleType known module type
86
- * @param supportedResource selected resource to be added
87
- * @param appendSrvApi if `srv-api` should be appended, typically used for CAP flows
85
+ * @param moduleType Known module type (e.g., 'nodejs', 'java')
86
+ * @param supportedResource Selected resource to be added (default: ManagedXSUAA)
87
+ * @param appendSrvApi If `srv-api` should be appended, typically used for CAP flows (default: true)
88
88
  */
89
89
  private updateServerModule;
90
90
  /**
@@ -96,66 +96,63 @@ export declare class MtaConfig {
96
96
  /**
97
97
  * Verify if the destination is valid and if WebIDEUsage is set to ODATA_GENERIC or ODATA_ABAP.
98
98
  *
99
- * @param {MTADestinationType} destination - destination object
100
- * @returns {boolean} - true if the destination is valid, false otherwise
99
+ * @param destination Destination object to validate
100
+ * @returns True if the destination is an OData destination (ODATA_GENERIC or ODATA_ABAP), false otherwise
101
101
  */
102
102
  private isODataDestination;
103
103
  /**
104
104
  * Cleanup missing content for Managed | Standalone router types.
105
105
  *
106
106
  * @private
107
- * @returns {Promise<void>} A promise that resolves when the change request has been processed.
108
107
  */
109
108
  private cleanupMissingResources;
110
109
  private cleanupModules;
111
110
  /**
112
111
  * Returns the MTA prefix, read from the MTA ID.
113
112
  *
114
- * @returns {string} the MTA ID
113
+ * @returns The MTA ID prefix
115
114
  */
116
115
  get prefix(): string;
117
116
  /**
118
117
  * Returns the path to the standalone approuter module.
119
118
  *
120
- * @returns {string | undefined} the MTA ID
119
+ * @returns The path to the standalone approuter module, or undefined if not found
121
120
  */
122
121
  get standaloneRouterPath(): string | undefined;
123
122
  /**
124
123
  * Returns the cloud service name, read from the content module which contains destinations.
125
124
  *
126
- * @returns {string | undefined} the cloud service name
125
+ * @returns The cloud service name, or undefined if not found
127
126
  */
128
127
  get cloudServiceName(): string | undefined;
129
128
  /**
130
129
  * Returns true if the MTA contains an approuter module of type App Frontend Service.
131
130
  *
132
- * @returns {boolean} true if the mta contains an App Frontend Service
131
+ * @returns True if the MTA contains an App Frontend Service
133
132
  */
134
133
  hasAppFrontendRouter(): boolean;
135
134
  /**
136
- * Returns the mta parameters.
135
+ * Returns the MTA parameters.
137
136
  *
138
- * @returns {Promise<mta.Parameters>} the MTA parameters
137
+ * @returns The MTA parameters
139
138
  */
140
139
  getParameters(): Promise<mta.Parameters>;
141
140
  /**
142
- * Returns the mta build parameters.
141
+ * Returns the MTA build parameters.
143
142
  *
144
- * @returns {Promise<mta.Parameters>} the MTA build parameters
143
+ * @returns The MTA build parameters
145
144
  */
146
145
  getBuildParameters(): Promise<mta.ProjectBuildParameters>;
147
146
  /**
148
147
  * Update the MTA parameters.
149
148
  *
150
- * @param parameters the MTA parameters being applied
151
- * @returns {Promise<void>} A promise that resolves when the change request has been processed.
149
+ * @param parameters The MTA parameters being applied
152
150
  */
153
151
  updateParameters(parameters: mta.Parameters): Promise<void>;
154
152
  /**
155
153
  * Update the MTA build parameters i.e. build-parameters -> before-all.
156
154
  *
157
- * @param parameters the MTA build parameters being applied
158
- * @returns {Promise<void>} A promise that resolves when the change request has been processed.
155
+ * @param parameters The MTA build parameters being applied
159
156
  */
160
157
  updateBuildParams(parameters: mta.ProjectBuildParameters): Promise<void>;
161
158
  /**
@@ -68,9 +68,9 @@ class MtaConfig {
68
68
  /**
69
69
  * Determines if the MTA configuration contains a known resource or module.
70
70
  *
71
- * @param requires resource to validate
72
- * @param resourceType managed or existing service
73
- * @returns true if the resource exists, false otherwise
71
+ * @param requires Resource requirements array to validate
72
+ * @param resourceType Managed or existing service type identifier
73
+ * @returns True if the resource exists, false otherwise
74
74
  * @private
75
75
  */
76
76
  targetExists(requires, resourceType) {
@@ -251,7 +251,7 @@ class MtaConfig {
251
251
  /**
252
252
  * Add a destination service to the MTA.
253
253
  *
254
- * @param isManagedApp - If the destination service is for a managed app
254
+ * @param isManagedApp If the destination service is for a managed app (default: false)
255
255
  */
256
256
  async addDestinationResource(isManagedApp = false) {
257
257
  const destinationName = `${this.prefix?.slice(0, constants_1.MAX_MTA_PREFIX_LENGTH)}-destination-service`;
@@ -275,7 +275,7 @@ class MtaConfig {
275
275
  /**
276
276
  * Update the destination service in the MTA if not already present.
277
277
  *
278
- * @param isManagedApp - If the destination service is for a managed app, false by default
278
+ * @param isManagedApp If the destination service is for a managed app (default: false)
279
279
  */
280
280
  async updateDestinationResource(isManagedApp = false) {
281
281
  const resource = this.resources.get('destination');
@@ -307,9 +307,9 @@ class MtaConfig {
307
307
  /**
308
308
  * Update the server module to include the required dependencies to ensure endpoints are secured.
309
309
  *
310
- * @param moduleType known module type
311
- * @param supportedResource selected resource to be added
312
- * @param appendSrvApi if `srv-api` should be appended, typically used for CAP flows
310
+ * @param moduleType Known module type (e.g., 'nodejs', 'java')
311
+ * @param supportedResource Selected resource to be added (default: ManagedXSUAA)
312
+ * @param appendSrvApi If `srv-api` should be appended, typically used for CAP flows (default: true)
313
313
  */
314
314
  async updateServerModule(moduleType, supportedResource = constants_1.ManagedXSUAA, appendSrvApi = true) {
315
315
  const mtaResource = this.resources.get(supportedResource);
@@ -358,8 +358,8 @@ class MtaConfig {
358
358
  /**
359
359
  * Verify if the destination is valid and if WebIDEUsage is set to ODATA_GENERIC or ODATA_ABAP.
360
360
  *
361
- * @param {MTADestinationType} destination - destination object
362
- * @returns {boolean} - true if the destination is valid, false otherwise
361
+ * @param destination Destination object to validate
362
+ * @returns True if the destination is an OData destination (ODATA_GENERIC or ODATA_ABAP), false otherwise
363
363
  */
364
364
  isODataDestination(destination) {
365
365
  return (0, btp_utils_1.isGenericODataDestination)(destination) || (0, btp_utils_1.isAbapEnvironmentOnBtp)(destination);
@@ -368,7 +368,6 @@ class MtaConfig {
368
368
  * Cleanup missing content for Managed | Standalone router types.
369
369
  *
370
370
  * @private
371
- * @returns {Promise<void>} A promise that resolves when the change request has been processed.
372
371
  */
373
372
  async cleanupMissingResources() {
374
373
  this.log?.debug((0, i18n_1.t)('debug.addMissingModules'));
@@ -419,7 +418,7 @@ class MtaConfig {
419
418
  /**
420
419
  * Returns the MTA prefix, read from the MTA ID.
421
420
  *
422
- * @returns {string} the MTA ID
421
+ * @returns The MTA ID prefix
423
422
  */
424
423
  get prefix() {
425
424
  return this.mtaId;
@@ -427,7 +426,7 @@ class MtaConfig {
427
426
  /**
428
427
  * Returns the path to the standalone approuter module.
429
428
  *
430
- * @returns {string | undefined} the MTA ID
429
+ * @returns The path to the standalone approuter module, or undefined if not found
431
430
  */
432
431
  get standaloneRouterPath() {
433
432
  return this.modules.get('approuter.nodejs')?.path;
@@ -435,7 +434,7 @@ class MtaConfig {
435
434
  /**
436
435
  * Returns the cloud service name, read from the content module which contains destinations.
437
436
  *
438
- * @returns {string | undefined} the cloud service name
437
+ * @returns The cloud service name, or undefined if not found
439
438
  */
440
439
  get cloudServiceName() {
441
440
  let cloudServiceName;
@@ -454,23 +453,23 @@ class MtaConfig {
454
453
  /**
455
454
  * Returns true if the MTA contains an approuter module of type App Frontend Service.
456
455
  *
457
- * @returns {boolean} true if the mta contains an App Frontend Service
456
+ * @returns True if the MTA contains an App Frontend Service
458
457
  */
459
458
  hasAppFrontendRouter() {
460
459
  return this.modules.has('com.sap.application.content:appfront');
461
460
  }
462
461
  /**
463
- * Returns the mta parameters.
462
+ * Returns the MTA parameters.
464
463
  *
465
- * @returns {Promise<mta.Parameters>} the MTA parameters
464
+ * @returns The MTA parameters
466
465
  */
467
466
  async getParameters() {
468
467
  return this.mta.getParameters();
469
468
  }
470
469
  /**
471
- * Returns the mta build parameters.
470
+ * Returns the MTA build parameters.
472
471
  *
473
- * @returns {Promise<mta.Parameters>} the MTA build parameters
472
+ * @returns The MTA build parameters
474
473
  */
475
474
  async getBuildParameters() {
476
475
  return this.mta.getBuildParameters();
@@ -478,8 +477,7 @@ class MtaConfig {
478
477
  /**
479
478
  * Update the MTA parameters.
480
479
  *
481
- * @param parameters the MTA parameters being applied
482
- * @returns {Promise<void>} A promise that resolves when the change request has been processed.
480
+ * @param parameters The MTA parameters being applied
483
481
  */
484
482
  async updateParameters(parameters) {
485
483
  await this.mta?.updateParameters(parameters);
@@ -488,8 +486,7 @@ class MtaConfig {
488
486
  /**
489
487
  * Update the MTA build parameters i.e. build-parameters -> before-all.
490
488
  *
491
- * @param parameters the MTA build parameters being applied
492
- * @returns {Promise<void>} A promise that resolves when the change request has been processed.
489
+ * @param parameters The MTA build parameters being applied
493
490
  */
494
491
  async updateBuildParams(parameters) {
495
492
  await this.mta?.updateBuildParameters(parameters);
@@ -37,7 +37,8 @@
37
37
  "targetFolderDoesNotExist": "The target folder does not exist: {{targetFolder}}. Check the folder has the correct permissions.",
38
38
  "doesNotContainACapApp": "The target folder does not contain a Node.js CAP project. Please ensure the folder contains a Node.js CAP project.",
39
39
  "errorInstallingNodeModules": "An error occurred when installing node modules. Please check the logs.",
40
- "errorGeneratingMtaYaml": "An error occurred when creating the mta.yaml file. Please check the logs."
40
+ "errorGeneratingMtaYaml": "An error occurred when creating the mta.yaml file. For more information, check the logs.",
41
+ "noUI5AppFound": "No SAPUI5 application found. Please ensure the manifest.json file contains a valid 'sap.app.id'."
41
42
  },
42
43
  "info": {
43
44
  "existingMTAExtensionNotFound": "Cannot find a valid existing MTA extension file. A new one will be created. Error: {{- error}}.",
@@ -54,6 +54,15 @@ export interface CFConfig extends CFAppConfig, CFBaseConfig {
54
54
  firstServicePathSegment?: string;
55
55
  isMtaRoot?: boolean;
56
56
  }
57
+ /**
58
+ * Configuration for CAP (Cloud Application Programming) project deployments.
59
+ * Extends CFBaseConfig but excludes ABAP service provider properties since CAP projects
60
+ * don't support direct ABAP service binding. This interface provides semantic clarity
61
+ * and type safety by explicitly excluding properties that are not applicable to CAP deployments.
62
+ *
63
+ * @remarks This is an intentionally narrow interface that omits ABAP-specific properties
64
+ * while inheriting all standard Cloud Foundry base configuration properties.
65
+ */
57
66
  export interface CAPConfig extends Omit<CFBaseConfig, 'abapServiceProvider'> {
58
67
  }
59
68
  export declare const enum ApiHubType {
package/dist/utils.d.ts CHANGED
@@ -6,21 +6,23 @@ import { type MTABaseConfig, type CFBaseConfig, type CFAppConfig } from './types
6
6
  * Read manifest file for processing.
7
7
  *
8
8
  * @param manifestPath Path to the manifest file
9
- * @param fs reference to a mem-fs editor
9
+ * @param fs Reference to a mem-fs editor
10
10
  * @returns Manifest object
11
+ * @throws {Error} If the manifest file cannot be read or parsed as valid JSON
11
12
  */
12
13
  export declare function readManifest(manifestPath: string, fs: Editor): Manifest;
13
14
  /**
14
15
  * Locates template files relative to the dist folder.
15
16
  * This helps to locate templates when this module is bundled and the dir structure is flattened, maintaining the relative paths.
16
17
  *
17
- * @param relativeTemplatePath - optional, the path of the required template relative to the ./templates folder. If not specified the root templates folder is returned.
18
- * @returns the path of the template specified or templates root folder
18
+ * @param relativeTemplatePath The path of the required template relative to the ./templates folder
19
+ * @returns The path of the template specified or templates root folder
19
20
  */
20
21
  export declare function getTemplatePath(relativeTemplatePath: string): string;
21
22
  /**
22
- * Convert an app name to an MTA ID that is suitable for CF deployment.
23
+ * Convert an app name to an MTA module name that is suitable for CF deployment.
23
24
  * Removes special characters that are not allowed in MTA module names.
25
+ * MTA module names can only contain: letters, numbers, dots (.), hyphens (-), and underscores (_).
24
26
  *
25
27
  * @param id Name of the app, like `sap.ux.app`
26
28
  * @returns Name that's acceptable in an mta.yaml (special characters removed)
@@ -35,9 +37,12 @@ export declare function toMtaModuleName(id: string): string;
35
37
  export declare function toPosixPath(dirPath: string): string;
36
38
  /**
37
39
  * Get the destination properties, based on the destination value.
40
+ * Retrieves destination configuration from SAP BTP when running in Business Application Studio.
38
41
  *
39
- * @param destination destination name
40
- * @returns Destination properties, default properties returned if not found
42
+ * @param destination The destination name to look up in BTP destination service
43
+ * @returns Object containing destination URL format flag and authentication type
44
+ * @returns {boolean} destinationIsFullUrl - True if destination uses full URL format
45
+ * @returns {Authentication | undefined} destinationAuthentication - Authentication type configured for the destination
41
46
  */
42
47
  export declare function getDestinationProperties(destination: string | undefined): Promise<{
43
48
  destinationIsFullUrl: boolean;
@@ -52,68 +57,66 @@ export declare function getBTPDestinations(): Promise<Destinations>;
52
57
  /**
53
58
  * Validates the MTA version passed in the config.
54
59
  *
55
- * @param mtaVersion MTA version
56
- * @returns true if the version is valid
60
+ * @param mtaVersion MTA version to validate
61
+ * @returns True if the version is valid
62
+ * @throws {Error} If the MTA version is invalid or below minimum required version (0.0.1)
57
63
  */
58
64
  export declare function validateVersion(mtaVersion?: string): boolean;
59
65
  /**
60
66
  * Appends xs-security.json to the project folder.
61
67
  *
62
- * @param {MTABaseConfig} config - MTA base configuration
63
- * @param {string} config.mtaPath - Path to the MTA project
64
- * @param {string} config.mtaId - MTA ID
65
- * @param {Editor} fs - Reference to a mem-fs editor
66
- * @param {boolean} [addTenant] - If true, append tenant to the xs-security.json file
67
- * @returns {void}
68
+ * @param config MTA base configuration
69
+ * @param config.mtaPath Path to the MTA project
70
+ * @param config.mtaId MTA ID used for security configuration
71
+ * @param fs Reference to a mem-fs editor
72
+ * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
68
73
  */
69
74
  export declare function addXSSecurityConfig({ mtaPath, mtaId }: MTABaseConfig, fs: Editor, addTenant?: boolean): void;
70
75
  /**
71
- * Append .gitignore to project folder.
76
+ * Appends .gitignore to project folder.
72
77
  *
73
78
  * @param targetPath Path to the project folder
74
- * @param fs reference to a mem-fs editor
79
+ * @param fs Reference to a mem-fs editor
75
80
  */
76
81
  export declare function addGitIgnore(targetPath: string, fs: Editor): void;
77
82
  /**
78
83
  * Appends server package.json to the project folder.
79
84
  *
80
- * @param {MTABaseConfig} config - MTA base configuration
81
- * @param {string} config.mtaPath - Path to the MTA project
82
- * @param {string} config.mtaId - MTA ID
83
- * @param {Editor} fs - Reference to a mem-fs editor
84
- * @returns {void}
85
+ * @param config MTA base configuration
86
+ * @param config.mtaPath Path to the MTA project
87
+ * @param config.mtaId MTA ID used in package.json
88
+ * @param fs Reference to a mem-fs editor
85
89
  */
86
90
  export declare function addRootPackage({ mtaPath, mtaId }: MTABaseConfig, fs: Editor): void;
87
91
  /**
88
92
  * Add common dependencies to the HTML5 app package.json.
89
93
  *
90
94
  * @param targetPath Path to the package.json file
91
- * @param fs reference to a mem-fs editor
95
+ * @param fs Reference to a mem-fs editor
92
96
  */
93
97
  export declare function addCommonPackageDependencies(targetPath: string, fs: Editor): Promise<void>;
94
98
  /**
95
99
  * Generate CF specific configurations to support deployment and undeployment.
96
100
  *
97
- * @param config writer configuration
98
- * @param fs reference to a mem-fs editor
99
- * @param addTenant If true, append tenant to the xs-security.json file
101
+ * @param config Writer configuration
102
+ * @param fs Reference to a mem-fs editor
103
+ * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
100
104
  */
101
105
  export declare function generateSupportingConfig(config: MTABaseConfig, fs: Editor, addTenant?: boolean): Promise<void>;
102
106
  /**
103
107
  * Update the writer configuration with defaults.
104
108
  *
105
- * @param config writer configuration
109
+ * @param config Writer configuration to be updated with default values
106
110
  */
107
111
  export declare function setMtaDefaults(config: CFBaseConfig): void;
108
112
  /**
109
113
  * Update the root package.json with scripts to deploy the MTA.
110
- *
111
114
  * Note: The fs editor is not passed to `addPackageDevDependency` since the package.json could be updated by other third party tools.
112
115
  *
113
- * @param {object} Options Input params
114
- * @param {string} Options.mtaId - MTA ID to be written to package.json
115
- * @param {string} Options.rootPath - MTA project path
116
- * @param fs - optional reference to a mem-fs editor
116
+ * @param options Input parameters
117
+ * @param options.mtaId MTA ID to be written to package.json
118
+ * @param options.rootPath MTA project path
119
+ * @param fs Reference to a mem-fs editor
117
120
  */
118
121
  export declare function updateRootPackage({ mtaId, rootPath }: {
119
122
  mtaId: string;
@@ -129,18 +132,16 @@ export declare function enforceValidRouterConfig(config: CFAppConfig): void;
129
132
  * Append devDependency if missing, required by mta `cds build` step.
130
133
  *
131
134
  * @param rootPath Path to the project folder
132
- * @param fs reference to a mem-fs editor
135
+ * @param fs Reference to a mem-fs editor
133
136
  */
134
137
  export declare function alignCdsVersions(rootPath: string, fs: Editor): Promise<void>;
135
138
  /**
136
139
  * Executes a command in the specified project directory.
137
140
  *
138
- * @async
139
- * @param {string} cwd - Working directory where the command will be executed
140
- * @param {string} cmd - Command to execute
141
- * @param {string[]} args - Arguments to pass to the command
142
- * @param {string} errorMsg - Error message prefix to display if the command fails
143
- * @returns {Promise<void>} - A promise that resolves when the command completes successfully
141
+ * @param cwd Working directory where the command will be executed
142
+ * @param cmd Command to execute
143
+ * @param args Arguments to pass to the command
144
+ * @param errorMsg Error message prefix to display if the command fails
144
145
  * @throws {Error} Throws an error with the provided error message concatenated with the original error if execution fails
145
146
  * @example
146
147
  * // Execute npm install in the project directory
@@ -150,9 +151,9 @@ export declare function runCommand(cwd: string, cmd: string, args: string[], err
150
151
  /**
151
152
  * Check if a file exists in the file system.
152
153
  *
153
- * @param fs reference to a mem-fs editor
154
+ * @param fs Reference to a mem-fs editor
154
155
  * @param filePath Path to the file
155
- * @returns true if the file exists, false otherwise
156
+ * @returns True if the file exists, false otherwise
156
157
  */
157
158
  export declare function fileExists(fs: Editor, filePath: string): boolean;
158
159
  //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js CHANGED
@@ -29,8 +29,9 @@ let cachedDestinationsList = {};
29
29
  * Read manifest file for processing.
30
30
  *
31
31
  * @param manifestPath Path to the manifest file
32
- * @param fs reference to a mem-fs editor
32
+ * @param fs Reference to a mem-fs editor
33
33
  * @returns Manifest object
34
+ * @throws {Error} If the manifest file cannot be read or parsed as valid JSON
34
35
  */
35
36
  function readManifest(manifestPath, fs) {
36
37
  return fs.readJSON(manifestPath);
@@ -39,22 +40,24 @@ function readManifest(manifestPath, fs) {
39
40
  * Locates template files relative to the dist folder.
40
41
  * This helps to locate templates when this module is bundled and the dir structure is flattened, maintaining the relative paths.
41
42
  *
42
- * @param relativeTemplatePath - optional, the path of the required template relative to the ./templates folder. If not specified the root templates folder is returned.
43
- * @returns the path of the template specified or templates root folder
43
+ * @param relativeTemplatePath The path of the required template relative to the ./templates folder
44
+ * @returns The path of the template specified or templates root folder
44
45
  */
45
46
  function getTemplatePath(relativeTemplatePath) {
46
47
  return (0, node_path_1.join)(__dirname, '../templates', relativeTemplatePath);
47
48
  }
48
49
  /**
49
- * Convert an app name to an MTA ID that is suitable for CF deployment.
50
+ * Convert an app name to an MTA module name that is suitable for CF deployment.
50
51
  * Removes special characters that are not allowed in MTA module names.
52
+ * MTA module names can only contain: letters, numbers, dots (.), hyphens (-), and underscores (_).
51
53
  *
52
54
  * @param id Name of the app, like `sap.ux.app`
53
55
  * @returns Name that's acceptable in an mta.yaml (special characters removed)
54
56
  */
55
57
  function toMtaModuleName(id) {
56
58
  // Remove special characters not allowed in MTA module names
57
- // Keep alphanumeric, underscore, hyphen, and dot
59
+ // Keep: alphanumeric, underscore, hyphen, and dot
60
+ // Remove: all other special characters including backticks, currency symbols, brackets, operators, etc.
58
61
  // Using replaceAll for global replacement (Sonar S7781)
59
62
  return id.replaceAll(/[`~!@#$%^&*£()|+=?;:'",.<>]/gi, '');
60
63
  }
@@ -69,9 +72,12 @@ function toPosixPath(dirPath) {
69
72
  }
70
73
  /**
71
74
  * Get the destination properties, based on the destination value.
75
+ * Retrieves destination configuration from SAP BTP when running in Business Application Studio.
72
76
  *
73
- * @param destination destination name
74
- * @returns Destination properties, default properties returned if not found
77
+ * @param destination The destination name to look up in BTP destination service
78
+ * @returns Object containing destination URL format flag and authentication type
79
+ * @returns {boolean} destinationIsFullUrl - True if destination uses full URL format
80
+ * @returns {Authentication | undefined} destinationAuthentication - Authentication type configured for the destination
75
81
  */
76
82
  async function getDestinationProperties(destination) {
77
83
  let destinationIsFullUrl = false;
@@ -99,8 +105,9 @@ async function getBTPDestinations() {
99
105
  /**
100
106
  * Validates the MTA version passed in the config.
101
107
  *
102
- * @param mtaVersion MTA version
103
- * @returns true if the version is valid
108
+ * @param mtaVersion MTA version to validate
109
+ * @returns True if the version is valid
110
+ * @throws {Error} If the MTA version is invalid or below minimum required version (0.0.1)
104
111
  */
105
112
  function validateVersion(mtaVersion) {
106
113
  const version = (0, semver_1.coerce)(mtaVersion);
@@ -112,12 +119,11 @@ function validateVersion(mtaVersion) {
112
119
  /**
113
120
  * Appends xs-security.json to the project folder.
114
121
  *
115
- * @param {MTABaseConfig} config - MTA base configuration
116
- * @param {string} config.mtaPath - Path to the MTA project
117
- * @param {string} config.mtaId - MTA ID
118
- * @param {Editor} fs - Reference to a mem-fs editor
119
- * @param {boolean} [addTenant] - If true, append tenant to the xs-security.json file
120
- * @returns {void}
122
+ * @param config MTA base configuration
123
+ * @param config.mtaPath Path to the MTA project
124
+ * @param config.mtaId MTA ID used for security configuration
125
+ * @param fs Reference to a mem-fs editor
126
+ * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
121
127
  */
122
128
  function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
123
129
  fs.copyTpl(getTemplatePath(`common/${project_access_1.FileName.XSSecurityJson}`), (0, node_path_1.join)(mtaPath, project_access_1.FileName.XSSecurityJson), {
@@ -126,10 +132,10 @@ function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
126
132
  });
127
133
  }
128
134
  /**
129
- * Append .gitignore to project folder.
135
+ * Appends .gitignore to project folder.
130
136
  *
131
137
  * @param targetPath Path to the project folder
132
- * @param fs reference to a mem-fs editor
138
+ * @param fs Reference to a mem-fs editor
133
139
  */
134
140
  function addGitIgnore(targetPath, fs) {
135
141
  fs.copyTpl(getTemplatePath('gitignore.tmpl'), (0, node_path_1.join)(targetPath, project_access_1.FileName.DotGitIgnore), {});
@@ -137,11 +143,10 @@ function addGitIgnore(targetPath, fs) {
137
143
  /**
138
144
  * Appends server package.json to the project folder.
139
145
  *
140
- * @param {MTABaseConfig} config - MTA base configuration
141
- * @param {string} config.mtaPath - Path to the MTA project
142
- * @param {string} config.mtaId - MTA ID
143
- * @param {Editor} fs - Reference to a mem-fs editor
144
- * @returns {void}
146
+ * @param config MTA base configuration
147
+ * @param config.mtaPath Path to the MTA project
148
+ * @param config.mtaId MTA ID used in package.json
149
+ * @param fs Reference to a mem-fs editor
145
150
  */
146
151
  function addRootPackage({ mtaPath, mtaId }, fs) {
147
152
  fs.copyTpl(getTemplatePath(project_access_1.FileName.Package), (0, node_path_1.join)(mtaPath, project_access_1.FileName.Package), {
@@ -152,7 +157,7 @@ function addRootPackage({ mtaPath, mtaId }, fs) {
152
157
  * Add common dependencies to the HTML5 app package.json.
153
158
  *
154
159
  * @param targetPath Path to the package.json file
155
- * @param fs reference to a mem-fs editor
160
+ * @param fs Reference to a mem-fs editor
156
161
  */
157
162
  async function addCommonPackageDependencies(targetPath, fs) {
158
163
  await (0, project_access_1.addPackageDevDependency)(targetPath, constants_1.UI5TaskZipperPackage, constants_1.UI5TaskZipperPackageVersion, fs);
@@ -161,9 +166,9 @@ async function addCommonPackageDependencies(targetPath, fs) {
161
166
  /**
162
167
  * Generate CF specific configurations to support deployment and undeployment.
163
168
  *
164
- * @param config writer configuration
165
- * @param fs reference to a mem-fs editor
166
- * @param addTenant If true, append tenant to the xs-security.json file
169
+ * @param config Writer configuration
170
+ * @param fs Reference to a mem-fs editor
171
+ * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
167
172
  */
168
173
  async function generateSupportingConfig(config, fs, addTenant = true) {
169
174
  if (config.mtaId && !fs.exists((0, node_path_1.join)(config.mtaPath, 'package.json'))) {
@@ -180,7 +185,7 @@ async function generateSupportingConfig(config, fs, addTenant = true) {
180
185
  /**
181
186
  * Update the writer configuration with defaults.
182
187
  *
183
- * @param config writer configuration
188
+ * @param config Writer configuration to be updated with default values
184
189
  */
185
190
  function setMtaDefaults(config) {
186
191
  config.mtaPath = config.mtaPath.replace(/\/$/, '');
@@ -189,13 +194,12 @@ function setMtaDefaults(config) {
189
194
  }
190
195
  /**
191
196
  * Update the root package.json with scripts to deploy the MTA.
192
- *
193
197
  * Note: The fs editor is not passed to `addPackageDevDependency` since the package.json could be updated by other third party tools.
194
198
  *
195
- * @param {object} Options Input params
196
- * @param {string} Options.mtaId - MTA ID to be written to package.json
197
- * @param {string} Options.rootPath - MTA project path
198
- * @param fs - optional reference to a mem-fs editor
199
+ * @param options Input parameters
200
+ * @param options.mtaId MTA ID to be written to package.json
201
+ * @param options.rootPath MTA project path
202
+ * @param fs Reference to a mem-fs editor
199
203
  */
200
204
  async function updateRootPackage({ mtaId, rootPath }, fs) {
201
205
  const packageExists = fileExists(fs, (0, node_path_1.join)(rootPath, project_access_1.FileName.Package));
@@ -241,7 +245,7 @@ function enforceValidRouterConfig(config) {
241
245
  * Append devDependency if missing, required by mta `cds build` step.
242
246
  *
243
247
  * @param rootPath Path to the project folder
244
- * @param fs reference to a mem-fs editor
248
+ * @param fs Reference to a mem-fs editor
245
249
  */
246
250
  async function alignCdsVersions(rootPath, fs) {
247
251
  const filePath = (0, node_path_1.join)(rootPath, project_access_1.FileName.Package);
@@ -255,12 +259,10 @@ async function alignCdsVersions(rootPath, fs) {
255
259
  /**
256
260
  * Executes a command in the specified project directory.
257
261
  *
258
- * @async
259
- * @param {string} cwd - Working directory where the command will be executed
260
- * @param {string} cmd - Command to execute
261
- * @param {string[]} args - Arguments to pass to the command
262
- * @param {string} errorMsg - Error message prefix to display if the command fails
263
- * @returns {Promise<void>} - A promise that resolves when the command completes successfully
262
+ * @param cwd Working directory where the command will be executed
263
+ * @param cmd Command to execute
264
+ * @param args Arguments to pass to the command
265
+ * @param errorMsg Error message prefix to display if the command fails
264
266
  * @throws {Error} Throws an error with the provided error message concatenated with the original error if execution fails
265
267
  * @example
266
268
  * // Execute npm install in the project directory
@@ -279,9 +281,9 @@ async function runCommand(cwd, cmd, args, errorMsg) {
279
281
  /**
280
282
  * Check if a file exists in the file system.
281
283
  *
282
- * @param fs reference to a mem-fs editor
284
+ * @param fs Reference to a mem-fs editor
283
285
  * @param filePath Path to the file
284
- * @returns true if the file exists, false otherwise
286
+ * @returns True if the file exists, false otherwise
285
287
  */
286
288
  function fileExists(fs, filePath) {
287
289
  return fs.exists(filePath);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/cf-deploy-config-writer",
3
3
  "description": "Add or amend Cloud Foundry and ABAP deployment configuration for SAP projects",
4
- "version": "0.3.82",
4
+ "version": "0.3.84",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,11 +29,11 @@
29
29
  "mem-fs": "2.1.0",
30
30
  "mem-fs-editor": "9.4.0",
31
31
  "hasbin": "1.2.3",
32
- "@sap-ux/project-access": "1.35.13",
32
+ "@sap-ux/project-access": "1.35.14",
33
33
  "@sap-ux/yaml": "0.17.5",
34
34
  "@sap-ux/btp-utils": "1.1.10",
35
35
  "@sap-ux/logger": "0.8.2",
36
- "@sap-ux/ui5-config": "0.29.21",
36
+ "@sap-ux/ui5-config": "0.30.0",
37
37
  "@sap-ux/nodejs-utils": "0.2.17"
38
38
  },
39
39
  "devDependencies": {