@sap-ux/cf-deploy-config-writer 0.4.4 → 1.0.0

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,6 @@
1
1
  import { type Editor } from 'mem-fs-editor';
2
2
  import { type Logger } from '@sap-ux/logger';
3
- import { type CFAppConfig, type CFConfig } from '../types';
3
+ import { type CFAppConfig, type CFConfig } from '../types/index.js';
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
  *
@@ -1,22 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateAppConfig = generateAppConfig;
7
- exports.generateMTAFile = generateMTAFile;
8
- exports.generateUI5DeployConfig = generateUI5DeployConfig;
9
- const node_path_1 = require("node:path");
10
- const mem_fs_1 = require("mem-fs");
11
- const mem_fs_editor_1 = require("mem-fs-editor");
12
- const ui5_config_1 = require("@sap-ux/ui5-config");
13
- const project_access_1 = require("@sap-ux/project-access");
14
- const btp_utils_1 = require("@sap-ux/btp-utils");
15
- const constants_1 = require("../constants");
16
- const utils_1 = require("../utils");
17
- const mta_config_1 = require("../mta-config");
18
- const logger_helper_1 = __importDefault(require("../logger-helper"));
19
- const i18n_1 = require("../i18n");
1
+ import { dirname, join, relative } from 'node:path';
2
+ import { create as createStorage } from 'mem-fs';
3
+ import { create } from 'mem-fs-editor';
4
+ import { UI5Config as UI5ConfigInstance, fioriToolsProxy } from '@sap-ux/ui5-config';
5
+ import { addPackageDevDependency, FileName, findCapProjectRoot, getMtaPath, readUi5Yaml, updatePackageScript, getWebappPath } from '@sap-ux/project-access';
6
+ import { Authentication } from '@sap-ux/btp-utils';
7
+ import { appDeployMTAScript, DefaultMTADestination, EmptyDestination, MbtPackage, MbtPackageVersion, MTABuildScript, SRV_API, Rimraf, RimrafVersion, UI5DeployBuildScript, UI5DeployBuildScriptForCap, undeployMTAScript, WelcomeFile } from '../constants.js';
8
+ import { addCommonPackageDependencies, enforceValidRouterConfig, fileExists, generateSupportingConfig, getDestinationProperties, getTemplatePath, readManifest, toPosixPath, updateRootPackage } from '../utils.js';
9
+ import { createMTA, doesCDSBinaryExist, doesMTABinaryExist, generateCAPMTA, getMtaConfig, getMtaId, toMtaModuleName } from '../mta-config/index.js';
10
+ import LoggerHelper from '../logger-helper.js';
11
+ import { t } from '../i18n.js';
12
+ import { ApiHubType } from '../types/index.js';
20
13
  /**
21
14
  * Add a managed approuter configuration to an existing HTML5 application, any exceptions thrown will be handled by the calling client.
22
15
  *
@@ -27,12 +20,12 @@ const i18n_1 = require("../i18n");
27
20
  * @throws {Error} If MTA binary is not found in the system path
28
21
  * @throws {Error} If required files (manifest.json, ui5.yaml) are missing or invalid
29
22
  */
30
- async function generateAppConfig(cfAppConfig, fs, logger) {
31
- fs ??= (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
23
+ export async function generateAppConfig(cfAppConfig, fs, logger) {
24
+ fs ??= create(createStorage());
32
25
  if (logger) {
33
- logger_helper_1.default.logger = logger;
26
+ LoggerHelper.logger = logger;
34
27
  }
35
- (0, mta_config_1.doesMTABinaryExist)();
28
+ doesMTABinaryExist();
36
29
  await generateDeployConfig(cfAppConfig, fs);
37
30
  return fs;
38
31
  }
@@ -50,10 +43,10 @@ async function getUpdatedConfig(cfAppConfig, fs) {
50
43
  const { serviceHost, destination, firstServicePathSegmentUI5Config } = await processUI5Config(cfAppConfig.appPath, fs);
51
44
  const { servicePath, firstServicePathSegment, appId } = await processManifest(cfAppConfig.appPath, fs);
52
45
  if (!appId) {
53
- throw new Error((0, i18n_1.t)('error.noUI5AppFound'));
46
+ throw new Error(t('error.noUI5AppFound'));
54
47
  }
55
- const { destinationIsFullUrl, destinationAuthentication } = await (0, utils_1.getDestinationProperties)(cfAppConfig.destinationName ?? destination);
56
- (0, utils_1.enforceValidRouterConfig)(cfAppConfig);
48
+ const { destinationIsFullUrl, destinationAuthentication } = await getDestinationProperties(cfAppConfig.destinationName ?? destination);
49
+ enforceValidRouterConfig(cfAppConfig);
57
50
  const config = {
58
51
  appPath: cfAppConfig.appPath.replace(/\/$/, ''),
59
52
  destinationName: cfAppConfig.destinationName ?? destination,
@@ -89,15 +82,15 @@ async function getProjectProperties(config) {
89
82
  let rootPath;
90
83
  let mtaPath;
91
84
  let mtaId;
92
- const foundMtaPath = await (0, project_access_1.getMtaPath)(config.appPath);
85
+ const foundMtaPath = await getMtaPath(config.appPath);
93
86
  if (foundMtaPath) {
94
- mtaPath = (0, node_path_1.dirname)(foundMtaPath.mtaPath);
95
- mtaId = await (0, mta_config_1.getMtaId)(mtaPath);
87
+ mtaPath = dirname(foundMtaPath.mtaPath);
88
+ mtaId = await getMtaId(mtaPath);
96
89
  }
97
90
  const hasRoot = foundMtaPath?.hasRoot ?? false;
98
- const capRoot = (await (0, project_access_1.findCapProjectRoot)(config.appPath)) ?? undefined;
91
+ const capRoot = (await findCapProjectRoot(config.appPath)) ?? undefined;
99
92
  if (capRoot) {
100
- (0, mta_config_1.doesCDSBinaryExist)();
93
+ doesCDSBinaryExist();
101
94
  isCap = true;
102
95
  rootPath = capRoot;
103
96
  }
@@ -118,8 +111,8 @@ async function processUI5Config(appPath, fs) {
118
111
  let serviceHost;
119
112
  let firstServicePathSegmentUI5Config;
120
113
  try {
121
- const ui5YamlConfig = await (0, project_access_1.readUi5Yaml)(appPath, project_access_1.FileName.Ui5Yaml, fs);
122
- const toolsConfig = ui5YamlConfig.findCustomMiddleware(ui5_config_1.fioriToolsProxy);
114
+ const ui5YamlConfig = await readUi5Yaml(appPath, FileName.Ui5Yaml, fs);
115
+ const toolsConfig = ui5YamlConfig.findCustomMiddleware(fioriToolsProxy);
123
116
  if (toolsConfig?.configuration?.backend?.length === 1) {
124
117
  destination = toolsConfig?.configuration?.backend[0].destination;
125
118
  serviceHost = toolsConfig?.configuration?.backend[0].url;
@@ -127,7 +120,7 @@ async function processUI5Config(appPath, fs) {
127
120
  }
128
121
  }
129
122
  catch (error) {
130
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.ui5YamlDoesNotExist', { error: error.message }));
123
+ LoggerHelper.logger?.debug(t('debug.ui5YamlDoesNotExist', { error: error.message }));
131
124
  }
132
125
  return { destination, serviceHost, firstServicePathSegmentUI5Config };
133
126
  }
@@ -139,9 +132,9 @@ async function processUI5Config(appPath, fs) {
139
132
  * @returns servicePath, firstServicePathSegment and appId properties
140
133
  */
141
134
  async function processManifest(appPath, fs) {
142
- const webappPath = await (0, project_access_1.getWebappPath)(appPath);
143
- const manifest = (0, utils_1.readManifest)((0, node_path_1.join)(webappPath, project_access_1.FileName.Manifest), fs);
144
- const appId = manifest?.['sap.app']?.id ? (0, mta_config_1.toMtaModuleName)(manifest['sap.app'].id) : undefined;
135
+ const webappPath = await getWebappPath(appPath);
136
+ const manifest = readManifest(join(webappPath, FileName.Manifest), fs);
137
+ const appId = manifest?.['sap.app']?.id ? toMtaModuleName(manifest['sap.app'].id) : undefined;
145
138
  const servicePath = manifest?.['sap.app']?.dataSources?.mainService?.uri;
146
139
  const firstServicePathSegment = servicePath?.substring(0, servicePath.indexOf('/', 1));
147
140
  return { servicePath, firstServicePathSegment, appId };
@@ -154,9 +147,9 @@ async function processManifest(appPath, fs) {
154
147
  * @throws {Error} If MTA generation or configuration update fails
155
148
  */
156
149
  async function generateDeployConfig(cfAppConfig, fs) {
157
- logger_helper_1.default?.logger?.debug(`Generate HTML5 app deployment configuration with: \n ${JSON.stringify(cfAppConfig)}`);
150
+ LoggerHelper?.logger?.debug(`Generate HTML5 app deployment configuration with: \n ${JSON.stringify(cfAppConfig)}`);
158
151
  const config = await getUpdatedConfig(cfAppConfig, fs);
159
- logger_helper_1.default?.logger?.debug(`Deployment configuration updated: \n ${JSON.stringify(config)}`);
152
+ LoggerHelper?.logger?.debug(`Deployment configuration updated: \n ${JSON.stringify(config)}`);
160
153
  // Generate MTA Config, LCAP will generate the mta.yaml on the fly so we don't care about it!
161
154
  if (!config.lcapMode) {
162
155
  await generateMTAFile(config, fs);
@@ -166,7 +159,7 @@ async function generateDeployConfig(cfAppConfig, fs) {
166
159
  await updateManifest(config, fs);
167
160
  await updateHTML5AppPackage(config, fs);
168
161
  if (config.isMtaRoot) {
169
- await (0, utils_1.updateRootPackage)({ mtaId: config.mtaId ?? config.appId, rootPath: config.rootPath }, fs);
162
+ await updateRootPackage({ mtaId: config.mtaId ?? config.appId, rootPath: config.rootPath }, fs);
170
163
  }
171
164
  }
172
165
  /**
@@ -176,14 +169,14 @@ async function generateDeployConfig(cfAppConfig, fs) {
176
169
  * @param fs Reference to a mem-fs editor
177
170
  * @throws {Error} If MTA file creation or CAP MTA generation fails
178
171
  */
179
- async function generateMTAFile(cfConfig, fs) {
172
+ export async function generateMTAFile(cfConfig, fs) {
180
173
  // Step1. Create mta.yaml
181
174
  if (!cfConfig.mtaId) {
182
175
  if (cfConfig.isCap) {
183
- await (0, mta_config_1.generateCAPMTA)({ ...cfConfig, mtaPath: cfConfig.rootPath }, fs);
176
+ await generateCAPMTA({ ...cfConfig, mtaPath: cfConfig.rootPath }, fs);
184
177
  }
185
178
  else {
186
- (0, mta_config_1.createMTA)({ mtaId: cfConfig.appId, mtaPath: cfConfig.mtaPath ?? cfConfig.rootPath });
179
+ createMTA({ mtaId: cfConfig.appId, mtaPath: cfConfig.mtaPath ?? cfConfig.rootPath });
187
180
  }
188
181
  cfConfig.mtaId = cfConfig.appId;
189
182
  cfConfig.mtaPath = cfConfig.rootPath;
@@ -191,7 +184,7 @@ async function generateMTAFile(cfConfig, fs) {
191
184
  // Step2. Append the approuter and destination to mta.yaml
192
185
  await appendAppRouter(cfConfig, fs);
193
186
  // Step3. Create any missing resources like package.json / xs-security.json / .gitignore
194
- await (0, utils_1.generateSupportingConfig)(cfConfig, fs);
187
+ await generateSupportingConfig(cfConfig, fs);
195
188
  }
196
189
  /**
197
190
  * Updates the MTA configuration file with the app router and destination.
@@ -201,7 +194,7 @@ async function generateMTAFile(cfConfig, fs) {
201
194
  * @throws {Error} If MTA configuration update or save fails
202
195
  */
203
196
  async function appendAppRouter(cfConfig, fs) {
204
- const mtaInstance = await (0, mta_config_1.getMtaConfig)(cfConfig.rootPath);
197
+ const mtaInstance = await getMtaConfig(cfConfig.rootPath);
205
198
  if (mtaInstance) {
206
199
  await mtaInstance.addRoutingModules({
207
200
  isManagedApp: cfConfig.addManagedAppRouter,
@@ -209,16 +202,16 @@ async function appendAppRouter(cfConfig, fs) {
209
202
  addMissingModules: !cfConfig.addAppFrontendRouter
210
203
  });
211
204
  const appModule = cfConfig.appId;
212
- const appRelativePath = (0, utils_1.toPosixPath)((0, node_path_1.relative)(cfConfig.rootPath, cfConfig.appPath));
205
+ const appRelativePath = toPosixPath(relative(cfConfig.rootPath, cfConfig.appPath));
213
206
  await mtaInstance.addApp(appModule, appRelativePath ?? '.');
214
- if ((cfConfig.addMtaDestination && cfConfig.isCap) || cfConfig.destinationName === constants_1.DefaultMTADestination) {
207
+ if ((cfConfig.addMtaDestination && cfConfig.isCap) || cfConfig.destinationName === DefaultMTADestination) {
215
208
  // If the destination instance identifier is passed, create a destination instance
216
209
  cfConfig.destinationName =
217
- cfConfig.destinationName === constants_1.DefaultMTADestination ? constants_1.SRV_API : cfConfig.destinationName;
210
+ cfConfig.destinationName === DefaultMTADestination ? SRV_API : cfConfig.destinationName;
218
211
  await mtaInstance.addDestinationToAppRouter(cfConfig.destinationName);
219
212
  // This is required where a managed or standalone router hasn't been added yet to mta.yaml
220
213
  if (!mtaInstance.hasManagedXsuaaResource()) {
221
- cfConfig.destinationAuthentication = btp_utils_1.Authentication.NO_AUTHENTICATION;
214
+ cfConfig.destinationAuthentication = Authentication.NO_AUTHENTICATION;
222
215
  }
223
216
  }
224
217
  cleanupStandaloneRoutes(cfConfig, mtaInstance, fs);
@@ -243,15 +236,15 @@ function cleanupStandaloneRoutes({ rootPath, appId }, mtaInstance, fs) {
243
236
  const appRouterPath = mtaInstance.standaloneRouterPath;
244
237
  if (appRouterPath) {
245
238
  try {
246
- const xsAppPath = (0, node_path_1.join)(appRouterPath, project_access_1.FileName.XSAppJson);
247
- const appRouterXsAppObj = fs.readJSON((0, node_path_1.join)(rootPath, xsAppPath));
248
- if ((appRouterXsAppObj && !appRouterXsAppObj?.[constants_1.WelcomeFile]) || appRouterXsAppObj?.[constants_1.WelcomeFile] === '/') {
249
- appRouterXsAppObj[constants_1.WelcomeFile] = `/${appId}`;
250
- fs.writeJSON((0, node_path_1.join)(rootPath, xsAppPath), appRouterXsAppObj);
239
+ const xsAppPath = join(appRouterPath, FileName.XSAppJson);
240
+ const appRouterXsAppObj = fs.readJSON(join(rootPath, xsAppPath));
241
+ if ((appRouterXsAppObj && !appRouterXsAppObj?.[WelcomeFile]) || appRouterXsAppObj?.[WelcomeFile] === '/') {
242
+ appRouterXsAppObj[WelcomeFile] = `/${appId}`;
243
+ fs.writeJSON(join(rootPath, xsAppPath), appRouterXsAppObj);
251
244
  }
252
245
  }
253
246
  catch (error) {
254
- logger_helper_1.default.logger?.error((0, i18n_1.t)('error.cannotUpdateRouterXSApp', { error }));
247
+ LoggerHelper.logger?.error(t('error.cannotUpdateRouterXSApp', { error }));
255
248
  }
256
249
  }
257
250
  }
@@ -266,13 +259,13 @@ async function saveMta(cfConfig, mtaInstance) {
266
259
  try {
267
260
  // Cleanup any temp files, not required to handle the exception as the mta.yaml will have been appended already with required changes.
268
261
  await mtaInstance.save();
269
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaSaved'));
262
+ LoggerHelper.logger?.debug(t('debug.mtaSaved'));
270
263
  }
271
264
  catch (error) {
272
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaSavedFailed', { error }));
265
+ LoggerHelper.logger?.debug(t('debug.mtaSavedFailed', { error }));
273
266
  }
274
267
  // Add mtaext if required for API Hub Enterprise connectivity
275
- if (cfConfig.apiHubConfig?.apiHubType === "API_HUB_ENTERPRISE" /* ApiHubType.apiHubEnterprise */) {
268
+ if (cfConfig.apiHubConfig?.apiHubType === ApiHubType.apiHubEnterprise) {
276
269
  try {
277
270
  await mtaInstance.addMtaExtensionConfig(cfConfig.destinationName, cfConfig.serviceHost, {
278
271
  key: 'ApiKey',
@@ -280,7 +273,7 @@ async function saveMta(cfConfig, mtaInstance) {
280
273
  });
281
274
  }
282
275
  catch (error) {
283
- logger_helper_1.default.logger?.error((0, i18n_1.t)('error.mtaExtensionFailed', { error }));
276
+ LoggerHelper.logger?.error(t('error.mtaExtensionFailed', { error }));
284
277
  }
285
278
  }
286
279
  }
@@ -297,18 +290,18 @@ async function appendCloudFoundryConfigurations(cfConfig, fs) {
297
290
  service: cfConfig.addAppFrontendRouter ? 'app-front' : 'html5-apps-repo-rt',
298
291
  authenticationType,
299
292
  addAppFrontendRoutes: cfConfig.addAppFrontendRouter ?? false,
300
- ...(cfConfig.destinationName && cfConfig.destinationName !== constants_1.EmptyDestination
293
+ ...(cfConfig.destinationName && cfConfig.destinationName !== EmptyDestination
301
294
  ? {
302
295
  destination: cfConfig.destinationName,
303
296
  servicePathSegment: `${cfConfig.firstServicePathSegment}${cfConfig.isDestinationFullUrl ? '/.*' : ''}`, // For service URL's, pull out everything after the last slash
304
297
  targetPath: `${cfConfig.isDestinationFullUrl ? '' : cfConfig.firstServicePathSegment}/$1`, // Pull group 1 from the regex
305
- authentication: cfConfig.destinationAuthentication === btp_utils_1.Authentication.NO_AUTHENTICATION
298
+ authentication: cfConfig.destinationAuthentication === Authentication.NO_AUTHENTICATION
306
299
  ? 'none'
307
300
  : authenticationType
308
301
  }
309
302
  : {})
310
303
  };
311
- fs.copyTpl((0, utils_1.getTemplatePath)('app/xs-app-destination.json'), (0, node_path_1.join)(cfConfig.appPath, project_access_1.FileName.XSAppJson), defaultProperties);
304
+ fs.copyTpl(getTemplatePath('app/xs-app-destination.json'), join(cfConfig.appPath, FileName.XSAppJson), defaultProperties);
312
305
  await generateUI5DeployConfig(cfConfig, fs);
313
306
  }
314
307
  /**
@@ -319,8 +312,8 @@ async function appendCloudFoundryConfigurations(cfConfig, fs) {
319
312
  * @param fs Reference to a mem-fs editor
320
313
  */
321
314
  async function updateManifest(cfConfig, fs) {
322
- const webappPath = await (0, project_access_1.getWebappPath)(cfConfig.appPath, fs);
323
- const manifest = (0, utils_1.readManifest)((0, node_path_1.join)(webappPath, project_access_1.FileName.Manifest), fs);
315
+ const webappPath = await getWebappPath(cfConfig.appPath, fs);
316
+ const manifest = readManifest(join(webappPath, FileName.Manifest), fs);
324
317
  if (manifest && cfConfig.cloudServiceName) {
325
318
  // Preserve existing sap.cloud properties while updating required values (Sonar S7744 fix)
326
319
  const sapCloud = {
@@ -328,7 +321,7 @@ async function updateManifest(cfConfig, fs) {
328
321
  public: true,
329
322
  service: cfConfig.cloudServiceName
330
323
  };
331
- fs.extendJSON((0, node_path_1.join)(webappPath, project_access_1.FileName.Manifest), {
324
+ fs.extendJSON(join(webappPath, FileName.Manifest), {
332
325
  'sap.cloud': sapCloud
333
326
  });
334
327
  }
@@ -341,23 +334,23 @@ async function updateManifest(cfConfig, fs) {
341
334
  */
342
335
  async function updateHTML5AppPackage(cfConfig, fs) {
343
336
  let deployArgs = [];
344
- if ((0, utils_1.fileExists)(fs, (0, node_path_1.join)(cfConfig.appPath, project_access_1.FileName.MtaExtYaml))) {
345
- deployArgs = ['-e', project_access_1.FileName.MtaExtYaml];
337
+ if (fileExists(fs, join(cfConfig.appPath, FileName.MtaExtYaml))) {
338
+ deployArgs = ['-e', FileName.MtaExtYaml];
346
339
  }
347
340
  // Added for all flows
348
- await (0, project_access_1.updatePackageScript)(cfConfig.appPath, 'build:cf', constants_1.UI5DeployBuildScript, fs);
349
- await (0, utils_1.addCommonPackageDependencies)(cfConfig.appPath, fs);
341
+ await updatePackageScript(cfConfig.appPath, 'build:cf', UI5DeployBuildScript, fs);
342
+ await addCommonPackageDependencies(cfConfig.appPath, fs);
350
343
  // Add support for CDS compatible applications which rely on `build` as the default script
351
344
  if (cfConfig.isCap) {
352
- await (0, project_access_1.updatePackageScript)(cfConfig.appPath, 'build', constants_1.UI5DeployBuildScriptForCap, fs);
345
+ await updatePackageScript(cfConfig.appPath, 'build', UI5DeployBuildScriptForCap, fs);
353
346
  }
354
347
  // Scripts should only be added if mta and UI5 app is at the same level
355
348
  if (cfConfig.mtaPath && !cfConfig.isMtaRoot) {
356
- await (0, project_access_1.updatePackageScript)(cfConfig.appPath, 'build:mta', constants_1.MTABuildScript, fs);
357
- await (0, project_access_1.updatePackageScript)(cfConfig.appPath, 'deploy', (0, constants_1.appDeployMTAScript)(deployArgs), fs);
358
- await (0, project_access_1.updatePackageScript)(cfConfig.appPath, 'undeploy', (0, constants_1.undeployMTAScript)(cfConfig.mtaId ?? cfConfig.appId), fs);
359
- await (0, project_access_1.addPackageDevDependency)(cfConfig.appPath, constants_1.Rimraf, constants_1.RimrafVersion, fs);
360
- await (0, project_access_1.addPackageDevDependency)(cfConfig.appPath, constants_1.MbtPackage, constants_1.MbtPackageVersion, fs);
349
+ await updatePackageScript(cfConfig.appPath, 'build:mta', MTABuildScript, fs);
350
+ await updatePackageScript(cfConfig.appPath, 'deploy', appDeployMTAScript(deployArgs), fs);
351
+ await updatePackageScript(cfConfig.appPath, 'undeploy', undeployMTAScript(cfConfig.mtaId ?? cfConfig.appId), fs);
352
+ await addPackageDevDependency(cfConfig.appPath, Rimraf, RimrafVersion, fs);
353
+ await addPackageDevDependency(cfConfig.appPath, MbtPackage, MbtPackageVersion, fs);
361
354
  }
362
355
  }
363
356
  /**
@@ -366,18 +359,18 @@ async function updateHTML5AppPackage(cfConfig, fs) {
366
359
  * @param cfConfig The deployment configuration
367
360
  * @param fs Reference to a mem-fs editor
368
361
  */
369
- async function generateUI5DeployConfig(cfConfig, fs) {
370
- const ui5BaseConfig = await (0, project_access_1.readUi5Yaml)(cfConfig.appPath, project_access_1.FileName.Ui5Yaml, fs);
362
+ export async function generateUI5DeployConfig(cfConfig, fs) {
363
+ const ui5BaseConfig = await readUi5Yaml(cfConfig.appPath, FileName.Ui5Yaml, fs);
371
364
  const addTranspileTask = !!ui5BaseConfig.findCustomMiddleware('ui5-tooling-transpile-task');
372
365
  const addModulesTask = !!ui5BaseConfig.findCustomMiddleware('ui5-tooling-modules-task');
373
366
  const baseUi5Doc = ui5BaseConfig.removeConfig('server');
374
- const ui5DeployConfig = await ui5_config_1.UI5Config.newInstance(baseUi5Doc.toString());
367
+ const ui5DeployConfig = await UI5ConfigInstance.newInstance(baseUi5Doc.toString());
375
368
  ui5DeployConfig.addComment({
376
369
  comment: ' yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json',
377
370
  location: 'beginning'
378
371
  });
379
372
  ui5DeployConfig.setConfiguration({ propertiesFileSourceEncoding: 'UTF-8' });
380
373
  ui5DeployConfig.addCloudFoundryDeployTask(cfConfig.appId, addModulesTask, addTranspileTask);
381
- fs.write((0, node_path_1.join)(cfConfig.appPath, project_access_1.FileName.UI5DeployYaml), ui5DeployConfig.toString());
374
+ fs.write(join(cfConfig.appPath, FileName.UI5DeployYaml), ui5DeployConfig.toString());
382
375
  }
383
376
  //# sourceMappingURL=app-config.js.map
@@ -1,6 +1,6 @@
1
1
  import { type Editor } from 'mem-fs-editor';
2
2
  import { type Logger } from '@sap-ux/logger';
3
- import { type CFBaseConfig } from '../types';
3
+ import { type CFBaseConfig } from '../types/index.js';
4
4
  /**
5
5
  * Add a standalone | managed | frontend app router to an empty target folder.
6
6
  *
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateBaseConfig = generateBaseConfig;
7
- const node_path_1 = require("node:path");
8
- const mem_fs_1 = require("mem-fs");
9
- const mem_fs_editor_1 = require("mem-fs-editor");
10
- const utils_1 = require("../utils");
11
- const logger_helper_1 = __importDefault(require("../logger-helper"));
12
- const mta_config_1 = require("../mta-config");
13
- const i18n_1 = require("../i18n");
1
+ import { join } from 'node:path';
2
+ import { create as createStorage } from 'mem-fs';
3
+ import { create } from 'mem-fs-editor';
4
+ import { generateSupportingConfig, fileExists } from '../utils.js';
5
+ import LoggerHelper from '../logger-helper.js';
6
+ import { createMTA, validateMtaConfig, addRoutingConfig } from '../mta-config/index.js';
7
+ import { t } from '../i18n.js';
14
8
  /**
15
9
  * Add a standalone | managed | frontend app router to an empty target folder.
16
10
  *
@@ -20,21 +14,21 @@ const i18n_1 = require("../i18n");
20
14
  * @returns File system reference
21
15
  * @throws {Error} If MTA binary is not found, configuration is invalid, or mta.yaml already exists
22
16
  */
23
- async function generateBaseConfig(config, fs, logger) {
24
- fs ??= (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
17
+ export async function generateBaseConfig(config, fs, logger) {
18
+ fs ??= create(createStorage());
25
19
  if (logger) {
26
- logger_helper_1.default.logger = logger;
20
+ LoggerHelper.logger = logger;
27
21
  }
28
22
  logger?.debug(`Generate base configuration using: \n ${JSON.stringify(config)}`);
29
- (0, mta_config_1.validateMtaConfig)(config);
23
+ validateMtaConfig(config);
30
24
  // Check if mta.yaml already exists in the target directory
31
- if ((0, utils_1.fileExists)(fs, (0, node_path_1.join)(config.mtaPath, config.mtaId))) {
32
- throw new Error((0, i18n_1.t)('error.mtaAlreadyExists'));
25
+ if (fileExists(fs, join(config.mtaPath, config.mtaId))) {
26
+ throw new Error(t('error.mtaAlreadyExists'));
33
27
  }
34
- (0, mta_config_1.createMTA)(config);
35
- await (0, mta_config_1.addRoutingConfig)(config, fs);
36
- await (0, utils_1.generateSupportingConfig)(config, fs);
37
- logger_helper_1.default.logger?.debug(`CF Config ${JSON.stringify(config, null, 2)}`);
28
+ createMTA(config);
29
+ await addRoutingConfig(config, fs);
30
+ await generateSupportingConfig(config, fs);
31
+ LoggerHelper.logger?.debug(`CF Config ${JSON.stringify(config, null, 2)}`);
38
32
  return fs;
39
33
  }
40
34
  //# sourceMappingURL=base-config.js.map
@@ -1,6 +1,6 @@
1
1
  import { type Editor } from 'mem-fs-editor';
2
2
  import type { Logger } from '@sap-ux/logger';
3
- import { type CAPConfig } from '../types';
3
+ import { type CAPConfig } from '../types/index.js';
4
4
  /**
5
5
  * Add a standalone | managed approuter to a CAP project.
6
6
  *
@@ -1,17 +1,11 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateCAPConfig = generateCAPConfig;
7
- const mem_fs_1 = require("mem-fs");
8
- const mem_fs_editor_1 = require("mem-fs-editor");
9
- const utils_1 = require("../utils");
10
- const mta_config_1 = require("../mta-config");
11
- const wait_for_mta_1 = require("../mta-config/wait-for-mta");
12
- const logger_helper_1 = __importDefault(require("../logger-helper"));
13
- const i18n_1 = require("../i18n");
14
- const project_access_1 = require("@sap-ux/project-access");
1
+ import { create as createStorage } from 'mem-fs';
2
+ import { create } from 'mem-fs-editor';
3
+ import { updateRootPackage } from '../utils.js';
4
+ import { validateMtaConfig, isMTAFound, addRoutingConfig, generateCAPMTA } from '../mta-config/index.js';
5
+ import { waitForMtaFile } from '../mta-config/wait-for-mta.js';
6
+ import LoggerHelper from '../logger-helper.js';
7
+ import { t } from '../i18n.js';
8
+ import { getCapProjectType } from '@sap-ux/project-access';
15
9
  /**
16
10
  * Add a standalone | managed approuter to a CAP project.
17
11
  *
@@ -22,19 +16,19 @@ const project_access_1 = require("@sap-ux/project-access");
22
16
  * @throws {Error} If target folder does not contain a Node.js CAP project
23
17
  * @throws {Error} If mta.yaml already exists in the target directory
24
18
  */
25
- async function generateCAPConfig(config, fs, logger) {
26
- fs ??= (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
19
+ export async function generateCAPConfig(config, fs, logger) {
20
+ fs ??= create(createStorage());
27
21
  if (logger) {
28
- logger_helper_1.default.logger = logger;
22
+ LoggerHelper.logger = logger;
29
23
  }
30
24
  logger?.debug(`Generate CAP configuration using: \n ${JSON.stringify(config)}`);
31
25
  await validateConfig(config);
32
- await (0, mta_config_1.generateCAPMTA)(config, fs);
26
+ await generateCAPMTA(config, fs);
33
27
  // Wait until mta.yaml is readable by mta-lib before proceeding
34
- await (0, wait_for_mta_1.waitForMtaFile)(config.mtaPath);
35
- await (0, mta_config_1.addRoutingConfig)(config, fs);
36
- await (0, utils_1.updateRootPackage)({ mtaId: config.mtaId, rootPath: config.mtaPath }, fs);
37
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.capGenerationCompleted'));
28
+ await waitForMtaFile(config.mtaPath);
29
+ await addRoutingConfig(config, fs);
30
+ await updateRootPackage({ mtaId: config.mtaId, rootPath: config.mtaPath }, fs);
31
+ LoggerHelper.logger?.debug(t('debug.capGenerationCompleted'));
38
32
  return fs;
39
33
  }
40
34
  /**
@@ -45,14 +39,14 @@ async function generateCAPConfig(config, fs, logger) {
45
39
  * @throws {Error} If mta.yaml already exists in the target directory
46
40
  */
47
41
  async function validateConfig(config) {
48
- (0, mta_config_1.validateMtaConfig)(config);
42
+ validateMtaConfig(config);
49
43
  // Check if the target directory contains a CAP Node.js project or exists!
50
- if ((await (0, project_access_1.getCapProjectType)(config.mtaPath)) !== 'CAPNodejs') {
51
- throw new Error((0, i18n_1.t)('error.doesNotContainACapApp'));
44
+ if ((await getCapProjectType(config.mtaPath)) !== 'CAPNodejs') {
45
+ throw new Error(t('error.doesNotContainACapApp'));
52
46
  }
53
47
  // Check if the target directory contains an existing mta.yaml
54
- if ((0, mta_config_1.isMTAFound)(config.mtaPath)) {
55
- throw new Error((0, i18n_1.t)('error.mtaAlreadyExists'));
48
+ if (isMTAFound(config.mtaPath)) {
49
+ throw new Error(t('error.mtaAlreadyExists'));
56
50
  }
57
51
  }
58
52
  //# sourceMappingURL=cap-config.js.map
@@ -1,4 +1,4 @@
1
- export { generateAppConfig } from './app-config';
2
- export { generateBaseConfig } from './base-config';
3
- export { generateCAPConfig } from './cap-config';
1
+ export { generateAppConfig } from './app-config.js';
2
+ export { generateBaseConfig } from './base-config.js';
3
+ export { generateCAPConfig } from './cap-config.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateCAPConfig = exports.generateBaseConfig = exports.generateAppConfig = void 0;
4
- var app_config_1 = require("./app-config");
5
- Object.defineProperty(exports, "generateAppConfig", { enumerable: true, get: function () { return app_config_1.generateAppConfig; } });
6
- var base_config_1 = require("./base-config");
7
- Object.defineProperty(exports, "generateBaseConfig", { enumerable: true, get: function () { return base_config_1.generateBaseConfig; } });
8
- var cap_config_1 = require("./cap-config");
9
- Object.defineProperty(exports, "generateCAPConfig", { enumerable: true, get: function () { return cap_config_1.generateCAPConfig; } });
1
+ export { generateAppConfig } from './app-config.js';
2
+ export { generateBaseConfig } from './base-config.js';
3
+ export { generateCAPConfig } from './cap-config.js';
10
4
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,3 @@
1
- import { UI5_DEFAULT } from '@sap-ux/ui5-config';
2
1
  export declare const WelcomeFile = "welcomeFile";
3
2
  export declare const MTABuildResult = "build-result";
4
3
  export declare const MTABuildParams = "build-parameters";
@@ -45,13 +44,13 @@ export declare const MTAAPIDestination: {
45
44
  export declare const UI5Destination: {
46
45
  Name: string;
47
46
  Type: string;
48
- URL: UI5_DEFAULT;
47
+ URL: "https://ui5.sap.com";
49
48
  ProxyType: string;
50
49
  Authentication: string;
51
50
  };
52
51
  export declare const UI5AppfrontDestinationParameter: {
53
52
  name: string;
54
- url: UI5_DEFAULT;
53
+ url: "https://ui5.sap.com";
55
54
  };
56
55
  export declare const CAPAppfrontDestination: {
57
56
  name: string;
@@ -65,7 +64,7 @@ export declare const UI5ResourceDestination: {
65
64
  destinations: {
66
65
  Name: string;
67
66
  Type: string;
68
- URL: UI5_DEFAULT;
67
+ URL: "https://ui5.sap.com";
69
68
  ProxyType: string;
70
69
  Authentication: string;
71
70
  }[];
@@ -77,7 +76,7 @@ export declare const UI5StandaloneModuleDestination: {
77
76
  properties: {
78
77
  forwardAuthToken: boolean;
79
78
  name: string;
80
- url: UI5_DEFAULT;
79
+ url: "https://ui5.sap.com";
81
80
  };
82
81
  };
83
82
  export declare const DestinationServiceConfig: {
@@ -88,7 +87,7 @@ export declare const DestinationServiceConfig: {
88
87
  destinations: {
89
88
  Name: string;
90
89
  Type: string;
91
- URL: UI5_DEFAULT;
90
+ URL: "https://ui5.sap.com";
92
91
  ProxyType: string;
93
92
  Authentication: string;
94
93
  }[];