@sap-ux/cf-deploy-config-writer 0.4.3 → 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.
- package/dist/cf-writer/app-config.d.ts +1 -1
- package/dist/cf-writer/app-config.js +72 -79
- package/dist/cf-writer/base-config.d.ts +1 -1
- package/dist/cf-writer/base-config.js +17 -23
- package/dist/cf-writer/cap-config.d.ts +1 -1
- package/dist/cf-writer/cap-config.js +21 -27
- package/dist/cf-writer/index.d.ts +3 -3
- package/dist/cf-writer/index.js +3 -9
- package/dist/constants.d.ts +5 -6
- package/dist/constants.js +70 -76
- package/dist/i18n.js +9 -19
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -30
- package/dist/logger-helper.js +3 -6
- package/dist/mta-config/index.d.ts +3 -3
- package/dist/mta-config/index.js +64 -92
- package/dist/mta-config/mta.d.ts +1 -1
- package/dist/mta-config/mta.js +135 -141
- package/dist/mta-config/template-renderer.js +6 -9
- package/dist/mta-config/wait-for-mta.js +10 -13
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +8 -6
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +55 -74
- package/package.json +10 -8
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 ??=
|
|
23
|
+
export async function generateAppConfig(cfAppConfig, fs, logger) {
|
|
24
|
+
fs ??= create(createStorage());
|
|
32
25
|
if (logger) {
|
|
33
|
-
|
|
26
|
+
LoggerHelper.logger = logger;
|
|
34
27
|
}
|
|
35
|
-
|
|
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(
|
|
46
|
+
throw new Error(t('error.noUI5AppFound'));
|
|
54
47
|
}
|
|
55
|
-
const { destinationIsFullUrl, destinationAuthentication } = await
|
|
56
|
-
|
|
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
|
|
85
|
+
const foundMtaPath = await getMtaPath(config.appPath);
|
|
93
86
|
if (foundMtaPath) {
|
|
94
|
-
mtaPath =
|
|
95
|
-
mtaId = await
|
|
87
|
+
mtaPath = dirname(foundMtaPath.mtaPath);
|
|
88
|
+
mtaId = await getMtaId(mtaPath);
|
|
96
89
|
}
|
|
97
90
|
const hasRoot = foundMtaPath?.hasRoot ?? false;
|
|
98
|
-
const capRoot = (await
|
|
91
|
+
const capRoot = (await findCapProjectRoot(config.appPath)) ?? undefined;
|
|
99
92
|
if (capRoot) {
|
|
100
|
-
|
|
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
|
|
122
|
-
const toolsConfig = ui5YamlConfig.findCustomMiddleware(
|
|
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
|
-
|
|
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
|
|
143
|
-
const manifest =
|
|
144
|
-
const appId = manifest?.['sap.app']?.id ?
|
|
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
|
-
|
|
150
|
+
LoggerHelper?.logger?.debug(`Generate HTML5 app deployment configuration with: \n ${JSON.stringify(cfAppConfig)}`);
|
|
158
151
|
const config = await getUpdatedConfig(cfAppConfig, fs);
|
|
159
|
-
|
|
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
|
|
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
|
|
176
|
+
await generateCAPMTA({ ...cfConfig, mtaPath: cfConfig.rootPath }, fs);
|
|
184
177
|
}
|
|
185
178
|
else {
|
|
186
|
-
|
|
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
|
|
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
|
|
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 =
|
|
205
|
+
const appRelativePath = toPosixPath(relative(cfConfig.rootPath, cfConfig.appPath));
|
|
213
206
|
await mtaInstance.addApp(appModule, appRelativePath ?? '.');
|
|
214
|
-
if ((cfConfig.addMtaDestination && cfConfig.isCap) || cfConfig.destinationName ===
|
|
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 ===
|
|
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 =
|
|
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 =
|
|
247
|
-
const appRouterXsAppObj = fs.readJSON(
|
|
248
|
-
if ((appRouterXsAppObj && !appRouterXsAppObj?.[
|
|
249
|
-
appRouterXsAppObj[
|
|
250
|
-
fs.writeJSON(
|
|
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
|
-
|
|
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
|
-
|
|
262
|
+
LoggerHelper.logger?.debug(t('debug.mtaSaved'));
|
|
270
263
|
}
|
|
271
264
|
catch (error) {
|
|
272
|
-
|
|
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 ===
|
|
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
|
-
|
|
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 !==
|
|
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 ===
|
|
298
|
+
authentication: cfConfig.destinationAuthentication === Authentication.NO_AUTHENTICATION
|
|
306
299
|
? 'none'
|
|
307
300
|
: authenticationType
|
|
308
301
|
}
|
|
309
302
|
: {})
|
|
310
303
|
};
|
|
311
|
-
fs.copyTpl(
|
|
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
|
|
323
|
-
const manifest =
|
|
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(
|
|
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 (
|
|
345
|
-
deployArgs = ['-e',
|
|
337
|
+
if (fileExists(fs, join(cfConfig.appPath, FileName.MtaExtYaml))) {
|
|
338
|
+
deployArgs = ['-e', FileName.MtaExtYaml];
|
|
346
339
|
}
|
|
347
340
|
// Added for all flows
|
|
348
|
-
await
|
|
349
|
-
await
|
|
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
|
|
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
|
|
357
|
-
await
|
|
358
|
-
await
|
|
359
|
-
await
|
|
360
|
-
await
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 ??=
|
|
17
|
+
export async function generateBaseConfig(config, fs, logger) {
|
|
18
|
+
fs ??= create(createStorage());
|
|
25
19
|
if (logger) {
|
|
26
|
-
|
|
20
|
+
LoggerHelper.logger = logger;
|
|
27
21
|
}
|
|
28
22
|
logger?.debug(`Generate base configuration using: \n ${JSON.stringify(config)}`);
|
|
29
|
-
|
|
23
|
+
validateMtaConfig(config);
|
|
30
24
|
// Check if mta.yaml already exists in the target directory
|
|
31
|
-
if (
|
|
32
|
-
throw new Error(
|
|
25
|
+
if (fileExists(fs, join(config.mtaPath, config.mtaId))) {
|
|
26
|
+
throw new Error(t('error.mtaAlreadyExists'));
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
await
|
|
36
|
-
await
|
|
37
|
-
|
|
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,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 ??=
|
|
19
|
+
export async function generateCAPConfig(config, fs, logger) {
|
|
20
|
+
fs ??= create(createStorage());
|
|
27
21
|
if (logger) {
|
|
28
|
-
|
|
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
|
|
26
|
+
await generateCAPMTA(config, fs);
|
|
33
27
|
// Wait until mta.yaml is readable by mta-lib before proceeding
|
|
34
|
-
await
|
|
35
|
-
await
|
|
36
|
-
await
|
|
37
|
-
|
|
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
|
-
|
|
42
|
+
validateMtaConfig(config);
|
|
49
43
|
// Check if the target directory contains a CAP Node.js project or exists!
|
|
50
|
-
if ((await
|
|
51
|
-
throw new Error(
|
|
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 (
|
|
55
|
-
throw new Error(
|
|
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
|
package/dist/cf-writer/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
package/dist/constants.d.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
90
|
+
URL: "https://ui5.sap.com";
|
|
92
91
|
ProxyType: string;
|
|
93
92
|
Authentication: string;
|
|
94
93
|
}[];
|