@sap-ux/cf-deploy-config-writer 0.2.6 → 0.2.8
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 +10 -9
- package/dist/cf-writer/base-config.js +1 -1
- package/dist/constants.d.ts +0 -6
- package/dist/constants.js +2 -8
- package/dist/mta-config/index.js +6 -6
- package/dist/mta-config/mta.js +5 -5
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +20 -9
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { type Editor } from 'mem-fs-editor';
|
|
|
2
2
|
import { type Logger } from '@sap-ux/logger';
|
|
3
3
|
import { type CFAppConfig, type CFConfig } from '../types';
|
|
4
4
|
/**
|
|
5
|
-
* Add a managed approuter configuration to an existing HTML5 application.
|
|
5
|
+
* Add a managed approuter configuration to an existing HTML5 application, any exceptions thrown will be handled by the calling client.
|
|
6
6
|
*
|
|
7
7
|
* @param cfAppConfig writer configuration
|
|
8
8
|
* @param fs an optional reference to a mem-fs editor
|
|
@@ -18,7 +18,7 @@ const mta_config_1 = require("../mta-config");
|
|
|
18
18
|
const logger_helper_1 = __importDefault(require("../logger-helper"));
|
|
19
19
|
const i18n_1 = require("../i18n");
|
|
20
20
|
/**
|
|
21
|
-
* Add a managed approuter configuration to an existing HTML5 application.
|
|
21
|
+
* Add a managed approuter configuration to an existing HTML5 application, any exceptions thrown will be handled by the calling client.
|
|
22
22
|
*
|
|
23
23
|
* @param cfAppConfig writer configuration
|
|
24
24
|
* @param fs an optional reference to a mem-fs editor
|
|
@@ -118,7 +118,7 @@ async function processUI5Config(appPath, fs) {
|
|
|
118
118
|
let firstServicePathSegmentUI5Config;
|
|
119
119
|
try {
|
|
120
120
|
const ui5YamlConfig = await (0, project_access_1.readUi5Yaml)(appPath, project_access_1.FileName.Ui5Yaml, fs);
|
|
121
|
-
const toolsConfig = ui5YamlConfig.findCustomMiddleware(
|
|
121
|
+
const toolsConfig = ui5YamlConfig.findCustomMiddleware(ui5_config_1.fioriToolsProxy);
|
|
122
122
|
if (toolsConfig?.configuration?.backend?.length === 1) {
|
|
123
123
|
destination = toolsConfig?.configuration?.backend[0].destination;
|
|
124
124
|
serviceHost = toolsConfig?.configuration?.backend[0].url;
|
|
@@ -138,7 +138,7 @@ async function processUI5Config(appPath, fs) {
|
|
|
138
138
|
* @returns servicePath, firstServicePathSegment and appId properties
|
|
139
139
|
*/
|
|
140
140
|
async function processManifest(appPath, fs) {
|
|
141
|
-
const manifest = await (0, utils_1.readManifest)((0, path_1.join)(appPath,
|
|
141
|
+
const manifest = await (0, utils_1.readManifest)((0, path_1.join)(await (0, project_access_1.getWebappPath)(appPath), project_access_1.FileName.Manifest), fs);
|
|
142
142
|
const appId = manifest?.['sap.app']?.id ? (0, mta_config_1.toMtaModuleName)(manifest?.['sap.app']?.id) : undefined;
|
|
143
143
|
const servicePath = manifest?.['sap.app']?.dataSources?.mainService?.uri;
|
|
144
144
|
const firstServicePathSegment = servicePath?.substring(0, servicePath?.indexOf('/', 1));
|
|
@@ -245,7 +245,7 @@ function cleanupStandaloneRoutes({ rootPath, appId }, mtaInstance, fs) {
|
|
|
245
245
|
const appRouterPath = mtaInstance.standaloneRouterPath;
|
|
246
246
|
if (appRouterPath) {
|
|
247
247
|
try {
|
|
248
|
-
const xsAppPath = (0, path_1.join)(appRouterPath,
|
|
248
|
+
const xsAppPath = (0, path_1.join)(appRouterPath, project_access_1.FileName.XSAppJson);
|
|
249
249
|
const appRouterXsAppObj = fs.readJSON((0, path_1.join)(rootPath, xsAppPath));
|
|
250
250
|
if ((appRouterXsAppObj && !appRouterXsAppObj?.[constants_1.WelcomeFile]) || appRouterXsAppObj?.[constants_1.WelcomeFile] === '/') {
|
|
251
251
|
appRouterXsAppObj[constants_1.WelcomeFile] = `/${appId}`;
|
|
@@ -309,7 +309,7 @@ async function appendCloudFoundryConfigurations(cfConfig, fs) {
|
|
|
309
309
|
}
|
|
310
310
|
: {})
|
|
311
311
|
};
|
|
312
|
-
fs.copyTpl((0, utils_1.getTemplatePath)('app/xs-app-destination.json'), (0, path_1.join)(cfConfig.appPath,
|
|
312
|
+
fs.copyTpl((0, utils_1.getTemplatePath)('app/xs-app-destination.json'), (0, path_1.join)(cfConfig.appPath, project_access_1.FileName.XSAppJson), defaultProperties);
|
|
313
313
|
await generateUI5DeployConfig(cfConfig, fs);
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
@@ -319,14 +319,15 @@ async function appendCloudFoundryConfigurations(cfConfig, fs) {
|
|
|
319
319
|
* @param fs reference to a mem-fs editor
|
|
320
320
|
*/
|
|
321
321
|
async function updateManifest(cfConfig, fs) {
|
|
322
|
-
const
|
|
322
|
+
const webappPath = await (0, project_access_1.getWebappPath)(cfConfig.appPath, fs);
|
|
323
|
+
const manifest = await (0, utils_1.readManifest)((0, path_1.join)(webappPath, project_access_1.FileName.Manifest), fs);
|
|
323
324
|
if (manifest && cfConfig.cloudServiceName) {
|
|
324
325
|
const sapCloud = {
|
|
325
326
|
...(manifest['sap.cloud'] || {}),
|
|
326
327
|
public: true,
|
|
327
328
|
service: cfConfig.cloudServiceName
|
|
328
329
|
};
|
|
329
|
-
fs.extendJSON((0, path_1.join)(
|
|
330
|
+
fs.extendJSON((0, path_1.join)(webappPath, project_access_1.FileName.Manifest), {
|
|
330
331
|
'sap.cloud': sapCloud
|
|
331
332
|
});
|
|
332
333
|
}
|
|
@@ -339,8 +340,8 @@ async function updateManifest(cfConfig, fs) {
|
|
|
339
340
|
*/
|
|
340
341
|
async function updateHTML5AppPackage(cfConfig, fs) {
|
|
341
342
|
let deployArgs = [];
|
|
342
|
-
if (
|
|
343
|
-
deployArgs = ['-e',
|
|
343
|
+
if ((0, utils_1.fileExists)(fs, (0, path_1.join)(cfConfig.appPath, project_access_1.FileName.MtaExtYaml))) {
|
|
344
|
+
deployArgs = ['-e', project_access_1.FileName.MtaExtYaml];
|
|
344
345
|
}
|
|
345
346
|
// Added for all flows
|
|
346
347
|
await (0, project_access_1.updatePackageScript)(cfConfig.appPath, 'build:cf', constants_1.UI5DeployBuildScript, fs);
|
|
@@ -28,7 +28,7 @@ async function generateBaseConfig(config, fs, logger) {
|
|
|
28
28
|
}
|
|
29
29
|
logger?.debug(`Generate base configuration using: \n ${JSON.stringify(config)}`);
|
|
30
30
|
(0, mta_config_1.validateMtaConfig)(config);
|
|
31
|
-
if (
|
|
31
|
+
if ((0, utils_1.fileExists)(fs, (0, path_1.join)(config.mtaPath, config.mtaId))) {
|
|
32
32
|
throw new Error((0, i18n_1.t)('error.mtaFolderAlreadyExists'));
|
|
33
33
|
}
|
|
34
34
|
(0, mta_config_1.createMTA)(config);
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { UI5_DEFAULT } from '@sap-ux/ui5-config';
|
|
2
2
|
export declare const WelcomeFile = "welcomeFile";
|
|
3
|
-
export declare const XSAppFile = "xs-app.json";
|
|
4
|
-
export declare const XSSecurityFile = "xs-security.json";
|
|
5
3
|
export declare const MTABuildResult = "build-result";
|
|
6
4
|
export declare const MTABuildParams = "build-parameters";
|
|
7
|
-
export declare const MTAFileExtension = "mta-ext.mtaext";
|
|
8
5
|
export declare const DefaultServiceURL = "${default-url}";
|
|
9
6
|
export declare const ManagedXSUAA = "managed:xsuaa";
|
|
10
7
|
export declare const ManagedAppFront = "managed:app-front";
|
|
@@ -14,7 +11,6 @@ export declare const SRV_API = "srv-api";
|
|
|
14
11
|
export declare const DefaultMTADestination = "fiori-default-srv-api";
|
|
15
12
|
export declare const EmptyDestination = "NONE";
|
|
16
13
|
export declare const ResourceMTADestination = "%s-srv-api";
|
|
17
|
-
export declare const MTAYamlFile = "mta.yaml";
|
|
18
14
|
export declare const MTADescription = "Generated by Fiori Tools";
|
|
19
15
|
export declare const RouterModule = "router";
|
|
20
16
|
export declare const CloudFoundry = "cf";
|
|
@@ -25,7 +21,6 @@ export declare const CDSDKPackage = "@sap/cds-dk";
|
|
|
25
21
|
export declare const CDSPackage = "@sap/cds";
|
|
26
22
|
export declare const MTAExecutable = "mta";
|
|
27
23
|
export declare const MTAPackage = "mta";
|
|
28
|
-
export declare const MTAPackageVersion = "^1.2.27";
|
|
29
24
|
export declare const MTAVersion = "0.0.1";
|
|
30
25
|
export declare const RimrafVersion = "^5.0.5";
|
|
31
26
|
export declare const Rimraf = "rimraf";
|
|
@@ -40,7 +35,6 @@ export declare const UI5PackageVersion = "^3.9.2";
|
|
|
40
35
|
export declare const CDSAddMtaParams: string[];
|
|
41
36
|
export declare const CDSXSUAAService = "xsuaa";
|
|
42
37
|
export declare const CDSHTML5RepoService = "html5-repo";
|
|
43
|
-
export declare const CDSConnectivityService = "connectivity";
|
|
44
38
|
export declare const CDSDestinationService = "destination";
|
|
45
39
|
export declare const MTAAPIDestination: {
|
|
46
40
|
Name: string;
|
package/dist/constants.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DestinationServiceConfig = exports.UI5StandaloneModuleDestination = exports.UI5ResourceDestination = exports.CAPAppfrontDestination = exports.UI5AppfrontDestinationParameter = exports.UI5Destination = exports.MTAAPIDestination = exports.CDSDestinationService = exports.
|
|
4
|
-
exports.MTABinNotFound = exports.CDSBinNotFound = exports.undeployMTAScript =
|
|
3
|
+
exports.rootDeployMTAScript = exports.appDeployMTAScript = exports.MTABuildScript = exports.UI5DeployBuildScript = exports.HTMLAppBuildParams = exports.ServiceAPIRequires = exports.DestinationServiceConfig = exports.UI5StandaloneModuleDestination = exports.UI5ResourceDestination = exports.CAPAppfrontDestination = exports.UI5AppfrontDestinationParameter = exports.UI5Destination = exports.MTAAPIDestination = exports.CDSDestinationService = exports.CDSHTML5RepoService = exports.CDSXSUAAService = exports.CDSAddMtaParams = exports.UI5PackageVersion = exports.UI5Package = exports.UI5TaskZipperPackageVersion = exports.UI5TaskZipperPackage = exports.UI5BuilderWebIdePackageVersion = exports.UI5BuilderWebIdePackage = exports.MbtPackageVersion = exports.MbtPackage = exports.Rimraf = exports.RimrafVersion = exports.MTAVersion = exports.MTAPackage = exports.MTAExecutable = exports.CDSPackage = exports.CDSDKPackage = exports.CDSExecutable = exports.enableParallelDeployments = exports.deployMode = exports.CloudFoundry = exports.RouterModule = exports.MTADescription = exports.ResourceMTADestination = exports.EmptyDestination = exports.DefaultMTADestination = exports.SRV_API = exports.HTML5RepoHost = exports.ManagedDestination = exports.ManagedAppFront = exports.ManagedXSUAA = exports.DefaultServiceURL = exports.MTABuildParams = exports.MTABuildResult = exports.WelcomeFile = void 0;
|
|
4
|
+
exports.MTABinNotFound = exports.CDSBinNotFound = exports.undeployMTAScript = void 0;
|
|
5
5
|
const i18n_1 = require("./i18n");
|
|
6
6
|
exports.WelcomeFile = 'welcomeFile';
|
|
7
|
-
exports.XSAppFile = 'xs-app.json';
|
|
8
|
-
exports.XSSecurityFile = 'xs-security.json';
|
|
9
7
|
exports.MTABuildResult = 'build-result';
|
|
10
8
|
exports.MTABuildParams = 'build-parameters';
|
|
11
|
-
exports.MTAFileExtension = 'mta-ext.mtaext';
|
|
12
9
|
exports.DefaultServiceURL = '${default-url}';
|
|
13
10
|
exports.ManagedXSUAA = 'managed:xsuaa';
|
|
14
11
|
exports.ManagedAppFront = 'managed:app-front';
|
|
@@ -18,7 +15,6 @@ exports.SRV_API = 'srv-api';
|
|
|
18
15
|
exports.DefaultMTADestination = 'fiori-default-srv-api';
|
|
19
16
|
exports.EmptyDestination = 'NONE';
|
|
20
17
|
exports.ResourceMTADestination = '%s-srv-api';
|
|
21
|
-
exports.MTAYamlFile = 'mta.yaml';
|
|
22
18
|
exports.MTADescription = 'Generated by Fiori Tools';
|
|
23
19
|
exports.RouterModule = 'router';
|
|
24
20
|
exports.CloudFoundry = 'cf';
|
|
@@ -29,7 +25,6 @@ exports.CDSDKPackage = '@sap/cds-dk';
|
|
|
29
25
|
exports.CDSPackage = '@sap/cds';
|
|
30
26
|
exports.MTAExecutable = 'mta';
|
|
31
27
|
exports.MTAPackage = 'mta';
|
|
32
|
-
exports.MTAPackageVersion = '^1.2.27';
|
|
33
28
|
exports.MTAVersion = '0.0.1';
|
|
34
29
|
exports.RimrafVersion = '^5.0.5';
|
|
35
30
|
exports.Rimraf = 'rimraf';
|
|
@@ -44,7 +39,6 @@ exports.UI5PackageVersion = '^3.9.2';
|
|
|
44
39
|
exports.CDSAddMtaParams = ['add', 'mta'];
|
|
45
40
|
exports.CDSXSUAAService = 'xsuaa';
|
|
46
41
|
exports.CDSHTML5RepoService = 'html5-repo';
|
|
47
|
-
exports.CDSConnectivityService = 'connectivity';
|
|
48
42
|
exports.CDSDestinationService = 'destination';
|
|
49
43
|
exports.MTAAPIDestination = {
|
|
50
44
|
Name: exports.ResourceMTADestination,
|
package/dist/mta-config/index.js
CHANGED
|
@@ -87,14 +87,14 @@ function toMtaModuleName(appId) {
|
|
|
87
87
|
* @param config writer configuration
|
|
88
88
|
*/
|
|
89
89
|
function createMTA(config) {
|
|
90
|
-
const mtaTemplate = (0, fs_1.readFileSync)((0, utils_1.getTemplatePath)(`app/${
|
|
90
|
+
const mtaTemplate = (0, fs_1.readFileSync)((0, utils_1.getTemplatePath)(`app/${project_access_1.FileName.MtaYaml}`), 'utf-8');
|
|
91
91
|
const mtaContents = (0, ejs_1.render)(mtaTemplate, {
|
|
92
92
|
id: `${config.mtaId.slice(0, 128)}`,
|
|
93
93
|
mtaDescription: config.mtaDescription ?? constants_1.MTADescription,
|
|
94
94
|
mtaVersion: config.mtaVersion ?? constants_1.MTAVersion
|
|
95
95
|
});
|
|
96
96
|
// Written to disk immediately! Subsequent calls are dependent on it being on the file system i.e mta-lib.
|
|
97
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(config.mtaPath,
|
|
97
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(config.mtaPath, project_access_1.FileName.MtaYaml), mtaContents);
|
|
98
98
|
logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaCreated', { mtaPath: config.mtaPath }));
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -176,14 +176,14 @@ function validateMtaConfig(config) {
|
|
|
176
176
|
* @deprecated this function is deprecated and will be removed in future releases
|
|
177
177
|
*/
|
|
178
178
|
async function createCAPMTAAppFrontend(config, fs) {
|
|
179
|
-
const mtaTemplate = (0, fs_1.readFileSync)((0, utils_1.getTemplatePath)(`frontend/${
|
|
179
|
+
const mtaTemplate = (0, fs_1.readFileSync)((0, utils_1.getTemplatePath)(`frontend/${project_access_1.FileName.MtaYaml}`), 'utf-8');
|
|
180
180
|
const mtaContents = (0, ejs_1.render)(mtaTemplate, {
|
|
181
181
|
id: `${config.mtaId.slice(0, 128)}`,
|
|
182
182
|
mtaDescription: config.mtaDescription ?? constants_1.MTADescription,
|
|
183
183
|
mtaVersion: config.mtaVersion ?? constants_1.MTAVersion
|
|
184
184
|
});
|
|
185
185
|
// Written to disk immediately! Subsequent calls are dependent on it being on the file system i.e mta-lib.
|
|
186
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(config.mtaPath,
|
|
186
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(config.mtaPath, project_access_1.FileName.MtaYaml), mtaContents);
|
|
187
187
|
// Add missing configurations
|
|
188
188
|
(0, utils_1.addXSSecurityConfig)(config, fs, false);
|
|
189
189
|
logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaCreated', { mtaPath: config.mtaPath }));
|
|
@@ -216,10 +216,10 @@ async function addStandaloneRouter(cfConfig, mtaInstance, fs) {
|
|
|
216
216
|
}
|
|
217
217
|
const endpoints = serviceKey?.endpoints ? Object.keys(serviceKey.endpoints) : [''];
|
|
218
218
|
const service = serviceKey ? serviceKey['sap.cloud.service'] : '';
|
|
219
|
-
fs.copyTpl((0, utils_1.getTemplatePath)('router/xs-app-abapservice.json'), (0, path_1.join)(cfConfig.mtaPath, `${constants_1.RouterModule}/${
|
|
219
|
+
fs.copyTpl((0, utils_1.getTemplatePath)('router/xs-app-abapservice.json'), (0, path_1.join)(cfConfig.mtaPath, `${constants_1.RouterModule}/${project_access_1.FileName.XSAppJson}`), { servicekeyService: service, servicekeyEndpoint: endpoints[0] });
|
|
220
220
|
}
|
|
221
221
|
else {
|
|
222
|
-
fs.copyTpl((0, utils_1.getTemplatePath)('router/xs-app-server.json'), (0, path_1.join)(cfConfig.mtaPath, `${constants_1.RouterModule}/${
|
|
222
|
+
fs.copyTpl((0, utils_1.getTemplatePath)('router/xs-app-server.json'), (0, path_1.join)(cfConfig.mtaPath, `${constants_1.RouterModule}/${project_access_1.FileName.XSAppJson}`));
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
/**
|
package/dist/mta-config/mta.js
CHANGED
|
@@ -748,7 +748,7 @@ class MtaConfig {
|
|
|
748
748
|
destinationServiceName = `${this.prefix.slice(0, 100)}-destination-service`;
|
|
749
749
|
}
|
|
750
750
|
const appMtaId = this.mtaId;
|
|
751
|
-
const mtaExtFilePath = (0, path_1.join)(this.mta.mtaDirPath,
|
|
751
|
+
const mtaExtFilePath = (0, path_1.join)(this.mta.mtaDirPath, project_access_1.FileName.MtaExtYaml);
|
|
752
752
|
let mtaExtensionYamlFile;
|
|
753
753
|
try {
|
|
754
754
|
const mtaExtContents = (0, fs_1.readFileSync)(mtaExtFilePath, 'utf-8');
|
|
@@ -770,9 +770,9 @@ class MtaConfig {
|
|
|
770
770
|
destinationServiceName: destinationServiceName,
|
|
771
771
|
mtaVersion: '1.0.0'
|
|
772
772
|
};
|
|
773
|
-
const mtaExtTemplate = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, `../../templates/app/${
|
|
773
|
+
const mtaExtTemplate = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, `../../templates/app/${project_access_1.FileName.MtaExtYaml}`), 'utf-8');
|
|
774
774
|
(0, fs_1.writeFileSync)(mtaExtFilePath, (0, ejs_1.render)(mtaExtTemplate, mtaExt));
|
|
775
|
-
this.log?.info((0, i18n_1.t)('info.mtaExtensionCreated', { appMtaId, mtaExtFile:
|
|
775
|
+
this.log?.info((0, i18n_1.t)('info.mtaExtensionCreated', { appMtaId, mtaExtFile: project_access_1.FileName.MtaExtYaml }));
|
|
776
776
|
}
|
|
777
777
|
else {
|
|
778
778
|
// Create an entry in an existing mta extension file
|
|
@@ -794,7 +794,7 @@ class MtaConfig {
|
|
|
794
794
|
value: nodeToInsert
|
|
795
795
|
});
|
|
796
796
|
(0, fs_1.writeFileSync)(mtaExtFilePath, mtaExtensionYamlFile.toString());
|
|
797
|
-
this.log?.info((0, i18n_1.t)('info.mtaExtensionUpdated', { mtaExtFile:
|
|
797
|
+
this.log?.info((0, i18n_1.t)('info.mtaExtensionUpdated', { mtaExtFile: project_access_1.FileName.MtaExtYaml }));
|
|
798
798
|
}
|
|
799
799
|
else {
|
|
800
800
|
this.log?.error((0, i18n_1.t)('error.updatingMTAExtensionFailed', { mtaExtFilePath }));
|
|
@@ -1057,7 +1057,7 @@ exports.MtaConfig = MtaConfig;
|
|
|
1057
1057
|
* @returns {boolean} true | false if MTA configuration file is found
|
|
1058
1058
|
*/
|
|
1059
1059
|
function isMTAFound(dir) {
|
|
1060
|
-
return (0, fs_1.existsSync)((0, path_1.join)(dir,
|
|
1060
|
+
return (0, fs_1.existsSync)((0, path_1.join)(dir, project_access_1.FileName.MtaYaml));
|
|
1061
1061
|
}
|
|
1062
1062
|
/**
|
|
1063
1063
|
* Returns true if there's an MTA configuration file in the supplied directory and contains an ABAP service binding.
|
package/dist/utils.d.ts
CHANGED
|
@@ -150,4 +150,12 @@ export declare function alignCdsVersions(rootPath: string, fs: Editor): Promise<
|
|
|
150
150
|
* await runCommand('/path/to/project', 'npm', ['install'], 'Failed to install dependencies:');
|
|
151
151
|
*/
|
|
152
152
|
export declare function runCommand(cwd: string, cmd: string, args: string[], errorMsg: string): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Check if a file exists in the file system.
|
|
155
|
+
*
|
|
156
|
+
* @param fs reference to a mem-fs editor
|
|
157
|
+
* @param filePath Path to the file
|
|
158
|
+
* @returns true if the file exists, false otherwise
|
|
159
|
+
*/
|
|
160
|
+
export declare function fileExists(fs: Editor, filePath: string): boolean;
|
|
153
161
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.updateRootPackage = updateRootPackage;
|
|
|
18
18
|
exports.enforceValidRouterConfig = enforceValidRouterConfig;
|
|
19
19
|
exports.alignCdsVersions = alignCdsVersions;
|
|
20
20
|
exports.runCommand = runCommand;
|
|
21
|
+
exports.fileExists = fileExists;
|
|
21
22
|
const path_1 = require("path");
|
|
22
23
|
const semver_1 = require("semver");
|
|
23
24
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
@@ -115,7 +116,7 @@ function validateVersion(mtaVersion) {
|
|
|
115
116
|
* @param addTenant If true, append tenant to the xs-security.json file
|
|
116
117
|
*/
|
|
117
118
|
function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
|
|
118
|
-
fs.copyTpl(getTemplatePath(`common/${
|
|
119
|
+
fs.copyTpl(getTemplatePath(`common/${project_access_1.FileName.XSSecurityJson}`), (0, path_1.join)(mtaPath, project_access_1.FileName.XSSecurityJson), {
|
|
119
120
|
id: mtaId.slice(0, 100),
|
|
120
121
|
addTenant
|
|
121
122
|
});
|
|
@@ -127,7 +128,7 @@ function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
|
|
|
127
128
|
* @param fs reference to a mem-fs editor
|
|
128
129
|
*/
|
|
129
130
|
function addGitIgnore(targetPath, fs) {
|
|
130
|
-
fs.copyTpl(getTemplatePath('gitignore.tmpl'), (0, path_1.join)(targetPath,
|
|
131
|
+
fs.copyTpl(getTemplatePath('gitignore.tmpl'), (0, path_1.join)(targetPath, project_access_1.FileName.DotGitIgnore), {});
|
|
131
132
|
}
|
|
132
133
|
/**
|
|
133
134
|
* Append server package.json to project folder.
|
|
@@ -138,7 +139,7 @@ function addGitIgnore(targetPath, fs) {
|
|
|
138
139
|
* @param fs reference to a mem-fs editor
|
|
139
140
|
*/
|
|
140
141
|
function addRootPackage({ mtaPath, mtaId }, fs) {
|
|
141
|
-
fs.copyTpl(getTemplatePath(
|
|
142
|
+
fs.copyTpl(getTemplatePath(project_access_1.FileName.Package), (0, path_1.join)(mtaPath, project_access_1.FileName.Package), {
|
|
142
143
|
mtaId: mtaId
|
|
143
144
|
});
|
|
144
145
|
}
|
|
@@ -161,16 +162,16 @@ async function addCommonPackageDependencies(targetPath, fs) {
|
|
|
161
162
|
*/
|
|
162
163
|
async function generateSupportingConfig(config, fs) {
|
|
163
164
|
const mtaConfig = { mtaId: config.mtaId, mtaPath: config.rootPath };
|
|
164
|
-
if (mtaConfig.mtaId && !fs
|
|
165
|
+
if (mtaConfig.mtaId && !fileExists(fs, (0, path_1.join)(config.rootPath, project_access_1.FileName.Package))) {
|
|
165
166
|
addRootPackage(mtaConfig, fs);
|
|
166
167
|
}
|
|
167
168
|
if ((config.addManagedAppRouter || config.addAppFrontendRouter) &&
|
|
168
169
|
mtaConfig.mtaId &&
|
|
169
|
-
!fs
|
|
170
|
+
!fileExists(fs, (0, path_1.join)(config.rootPath, project_access_1.FileName.XSSecurityJson))) {
|
|
170
171
|
addXSSecurityConfig(mtaConfig, fs, true);
|
|
171
172
|
}
|
|
172
173
|
// Be a good citizen and add a .gitignore if missing from the existing project root
|
|
173
|
-
if (!fs
|
|
174
|
+
if (!fileExists(fs, (0, path_1.join)(config.rootPath, project_access_1.FileName.DotGitIgnore))) {
|
|
174
175
|
addGitIgnore(config.rootPath, fs);
|
|
175
176
|
}
|
|
176
177
|
}
|
|
@@ -206,7 +207,7 @@ function setMtaDefaults(config) {
|
|
|
206
207
|
* @param fs - optional reference to a mem-fs editor
|
|
207
208
|
*/
|
|
208
209
|
async function updateRootPackage({ mtaId, rootPath }, fs) {
|
|
209
|
-
const packageExists = fs
|
|
210
|
+
const packageExists = fileExists(fs, (0, path_1.join)(rootPath, project_access_1.FileName.Package));
|
|
210
211
|
// Append package.json only if mta.yaml is at a different level to the HTML5 app
|
|
211
212
|
if (packageExists) {
|
|
212
213
|
// Align CDS versions if missing otherwise mta.yaml before-all scripts will fail
|
|
@@ -214,8 +215,8 @@ async function updateRootPackage({ mtaId, rootPath }, fs) {
|
|
|
214
215
|
await (0, project_access_1.addPackageDevDependency)(rootPath, constants_1.Rimraf, constants_1.RimrafVersion, fs);
|
|
215
216
|
await (0, project_access_1.addPackageDevDependency)(rootPath, constants_1.MbtPackage, constants_1.MbtPackageVersion, fs);
|
|
216
217
|
let deployArgs = [];
|
|
217
|
-
if (fs?.exists((0, path_1.join)(rootPath,
|
|
218
|
-
deployArgs = ['-e',
|
|
218
|
+
if (fs?.exists((0, path_1.join)(rootPath, project_access_1.FileName.MtaExtYaml))) {
|
|
219
|
+
deployArgs = ['-e', project_access_1.FileName.MtaExtYaml];
|
|
219
220
|
}
|
|
220
221
|
for (const script of [
|
|
221
222
|
{ name: 'undeploy', run: (0, constants_1.undeployMTAScript)(mtaId) },
|
|
@@ -283,4 +284,14 @@ async function runCommand(cwd, cmd, args, errorMsg) {
|
|
|
283
284
|
throw new Error(`${errorMsg} ${e.message}`);
|
|
284
285
|
}
|
|
285
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Check if a file exists in the file system.
|
|
289
|
+
*
|
|
290
|
+
* @param fs reference to a mem-fs editor
|
|
291
|
+
* @param filePath Path to the file
|
|
292
|
+
* @returns true if the file exists, false otherwise
|
|
293
|
+
*/
|
|
294
|
+
function fileExists(fs, filePath) {
|
|
295
|
+
return fs.exists(filePath);
|
|
296
|
+
}
|
|
286
297
|
//# sourceMappingURL=utils.js.map
|
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.2.
|
|
4
|
+
"version": "0.2.8",
|
|
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.29.
|
|
32
|
+
"@sap-ux/project-access": "1.29.20",
|
|
33
33
|
"@sap-ux/yaml": "0.16.0",
|
|
34
34
|
"@sap-ux/btp-utils": "1.0.3",
|
|
35
35
|
"@sap-ux/logger": "0.6.0",
|
|
36
|
-
"@sap-ux/ui5-config": "0.
|
|
36
|
+
"@sap-ux/ui5-config": "0.27.1",
|
|
37
37
|
"@sap-ux/nodejs-utils": "0.1.9"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|