@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.
- 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,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
|
-
const ejs_1 = require("ejs");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { render } from 'ejs';
|
|
3
|
+
import { getTemplatePath } from '../utils.js';
|
|
7
4
|
/**
|
|
8
5
|
* Render an EJS template directly to disk.
|
|
9
6
|
* Intentionally bypasses mem-fs — mta-lib and other consumers require the file to be
|
|
@@ -13,8 +10,8 @@ const utils_1 = require("../utils");
|
|
|
13
10
|
* @param outputPath Absolute path where the rendered file will be written
|
|
14
11
|
* @param data Template data object passed to EJS
|
|
15
12
|
*/
|
|
16
|
-
function renderTemplateToDisk(templateName, outputPath, data) {
|
|
17
|
-
const template =
|
|
18
|
-
|
|
13
|
+
export function renderTemplateToDisk(templateName, outputPath, data) {
|
|
14
|
+
const template = readFileSync(getTemplatePath(templateName), 'utf-8');
|
|
15
|
+
writeFileSync(outputPath, render(template, data));
|
|
19
16
|
}
|
|
20
17
|
//# sourceMappingURL=template-renderer.js.map
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const mta_lib_1 = require("@sap/mta-lib");
|
|
7
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
8
|
-
const i18n_1 = require("../i18n");
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { Mta } from '@sap/mta-lib';
|
|
4
|
+
import { FileName } from '@sap-ux/project-access';
|
|
5
|
+
import { t } from '../i18n.js';
|
|
9
6
|
/**
|
|
10
7
|
* Waits until mta.yaml exists on disk and is readable by mta-lib.
|
|
11
8
|
* Replaces hardcoded setTimeout delays used to work around mta-lib requiring
|
|
@@ -15,14 +12,14 @@ const i18n_1 = require("../i18n");
|
|
|
15
12
|
* @param options Polling configuration
|
|
16
13
|
* @throws {Error} If the file is not ready within maxWaitMs
|
|
17
14
|
*/
|
|
18
|
-
async function waitForMtaFile(mtaPath, options = {}) {
|
|
15
|
+
export async function waitForMtaFile(mtaPath, options = {}) {
|
|
19
16
|
const { maxWaitMs = 5000, pollIntervalMs = 100 } = options;
|
|
20
|
-
const mtaFilePath =
|
|
17
|
+
const mtaFilePath = join(mtaPath, FileName.MtaYaml);
|
|
21
18
|
const deadline = Date.now() + maxWaitMs;
|
|
22
19
|
while (Date.now() < deadline) {
|
|
23
|
-
if (
|
|
20
|
+
if (existsSync(mtaFilePath)) {
|
|
24
21
|
try {
|
|
25
|
-
const mta = new
|
|
22
|
+
const mta = new Mta(mtaPath, false);
|
|
26
23
|
const id = await mta.getMtaID();
|
|
27
24
|
if (id) {
|
|
28
25
|
return;
|
|
@@ -34,6 +31,6 @@ async function waitForMtaFile(mtaPath, options = {}) {
|
|
|
34
31
|
}
|
|
35
32
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
36
33
|
}
|
|
37
|
-
throw new Error(
|
|
34
|
+
throw new Error(t('error.mtaFileNotReady', { mtaPath }));
|
|
38
35
|
}
|
|
39
36
|
//# sourceMappingURL=wait-for-mta.js.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Destination, Authentication } from '@sap-ux/btp-utils';
|
|
2
|
-
import { type CDSDestinationService, type CDSHTML5RepoService, type HTML5RepoHost, type ManagedAppFront, type ManagedDestination, type ManagedXSUAA, type CDSXSUAAService } from '../constants';
|
|
2
|
+
import { type CDSDestinationService, type CDSHTML5RepoService, type HTML5RepoHost, type ManagedAppFront, type ManagedDestination, type ManagedXSUAA, type CDSXSUAAService } from '../constants.js';
|
|
3
3
|
export type ResourceType = 'xsuaa' | 'destination' | 'portal' | 'connectivity' | 'managed:xsuaa' | 'html5-apps-repo:app-host' | 'html5-apps-repo:app-runtime';
|
|
4
4
|
export type ModuleType = 'hdb' | 'nodejs' | 'java' | 'approuter.nodejs' | 'com.sap.application.content' | 'com.sap.application.content:destination' | 'com.sap.application.content:resource' | 'html5' | 'com.sap.portal.content';
|
|
5
5
|
export declare enum CloudFoundryServiceType {
|
package/dist/types/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouterModuleType = exports.CloudFoundryServiceType = void 0;
|
|
4
|
-
var CloudFoundryServiceType;
|
|
1
|
+
export var CloudFoundryServiceType;
|
|
5
2
|
(function (CloudFoundryServiceType) {
|
|
6
3
|
CloudFoundryServiceType["Existing"] = "org.cloudfoundry.existing-service";
|
|
7
4
|
CloudFoundryServiceType["Managed"] = "org.cloudfoundry.managed-service";
|
|
8
|
-
})(CloudFoundryServiceType || (
|
|
9
|
-
|
|
5
|
+
})(CloudFoundryServiceType || (CloudFoundryServiceType = {}));
|
|
6
|
+
export const RouterModuleType = {
|
|
10
7
|
Standard: 'standard',
|
|
11
8
|
Managed: 'managed',
|
|
12
9
|
AppFront: 'appFront'
|
|
13
10
|
};
|
|
11
|
+
export var ApiHubType;
|
|
12
|
+
(function (ApiHubType) {
|
|
13
|
+
ApiHubType["apiHub"] = "API_HUB";
|
|
14
|
+
ApiHubType["apiHubEnterprise"] = "API_HUB_ENTERPRISE";
|
|
15
|
+
})(ApiHubType || (ApiHubType = {}));
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
2
|
import { type Authentication, type Destinations } from '@sap-ux/btp-utils';
|
|
3
3
|
import { type Manifest } from '@sap-ux/project-access';
|
|
4
|
-
import { type MTABaseConfig, type CFBaseConfig, type CFAppConfig } from './types';
|
|
4
|
+
import { type MTABaseConfig, type CFBaseConfig, type CFAppConfig } from './types/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Read manifest file for processing.
|
|
7
7
|
*
|
package/dist/utils.js
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.getBTPDestinations = getBTPDestinations;
|
|
9
|
-
exports.validateVersion = validateVersion;
|
|
10
|
-
exports.addXSSecurityConfig = addXSSecurityConfig;
|
|
11
|
-
exports.addGitIgnore = addGitIgnore;
|
|
12
|
-
exports.addRootPackage = addRootPackage;
|
|
13
|
-
exports.addCommonPackageDependencies = addCommonPackageDependencies;
|
|
14
|
-
exports.generateSupportingConfig = generateSupportingConfig;
|
|
15
|
-
exports.setMtaDefaults = setMtaDefaults;
|
|
16
|
-
exports.updateRootPackage = updateRootPackage;
|
|
17
|
-
exports.enforceValidRouterConfig = enforceValidRouterConfig;
|
|
18
|
-
exports.alignCdsVersions = alignCdsVersions;
|
|
19
|
-
exports.runCommand = runCommand;
|
|
20
|
-
exports.fileExists = fileExists;
|
|
21
|
-
const node_path_1 = require("node:path");
|
|
22
|
-
const semver_1 = require("semver");
|
|
23
|
-
const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
|
|
24
|
-
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
25
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
26
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import { dirname, join, normalize, posix } from 'node:path';
|
|
2
|
+
import { coerce, satisfies } from 'semver';
|
|
3
|
+
import { CommandRunner } from '@sap-ux/nodejs-utils';
|
|
4
|
+
import { isAppStudio, listDestinations, isFullUrlDestination } from '@sap-ux/btp-utils';
|
|
5
|
+
import { addPackageDevDependency, FileName, updatePackageScript } from '@sap-ux/project-access';
|
|
6
|
+
import { MTAVersion, UI5Package, UI5PackageVersion, UI5TaskZipperPackage, UI5TaskZipperPackageVersion, rootDeployMTAScript, undeployMTAScript, Rimraf, RimrafVersion, MbtPackageVersion, MbtPackage, MTABuildScript, CDSDKPackage, CDSPackage, MAX_MTA_PREFIX_LENGTH } from './constants.js';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
27
8
|
/**
|
|
28
9
|
* Read manifest file for processing.
|
|
29
10
|
*
|
|
@@ -32,7 +13,7 @@ const constants_1 = require("./constants");
|
|
|
32
13
|
* @returns Manifest object
|
|
33
14
|
* @throws {Error} If the manifest file cannot be read or parsed as valid JSON
|
|
34
15
|
*/
|
|
35
|
-
function readManifest(manifestPath, fs) {
|
|
16
|
+
export function readManifest(manifestPath, fs) {
|
|
36
17
|
return fs.readJSON(manifestPath);
|
|
37
18
|
}
|
|
38
19
|
/**
|
|
@@ -42,8 +23,8 @@ function readManifest(manifestPath, fs) {
|
|
|
42
23
|
* @param relativeTemplatePath The path of the required template relative to the ./templates folder
|
|
43
24
|
* @returns The path of the template specified or templates root folder
|
|
44
25
|
*/
|
|
45
|
-
function getTemplatePath(relativeTemplatePath) {
|
|
46
|
-
return (
|
|
26
|
+
export function getTemplatePath(relativeTemplatePath) {
|
|
27
|
+
return join(dirname(fileURLToPath(import.meta.url)), '../templates', relativeTemplatePath);
|
|
47
28
|
}
|
|
48
29
|
/**
|
|
49
30
|
* Convert an app name to an MTA module name that is suitable for CF deployment.
|
|
@@ -53,7 +34,7 @@ function getTemplatePath(relativeTemplatePath) {
|
|
|
53
34
|
* @param id Name of the app, like `sap.ux.app`
|
|
54
35
|
* @returns Name that's acceptable in an mta.yaml (special characters removed)
|
|
55
36
|
*/
|
|
56
|
-
function toMtaModuleName(id) {
|
|
37
|
+
export function toMtaModuleName(id) {
|
|
57
38
|
// Remove special characters not allowed in MTA module names
|
|
58
39
|
// Keep: alphanumeric, underscore, hyphen, and dot
|
|
59
40
|
// Remove: all other special characters including backticks, currency symbols, brackets, operators, etc.
|
|
@@ -66,8 +47,8 @@ function toMtaModuleName(id) {
|
|
|
66
47
|
* @param dirPath Path to the directory
|
|
67
48
|
* @returns Path to the directory with consistent separators
|
|
68
49
|
*/
|
|
69
|
-
function toPosixPath(dirPath) {
|
|
70
|
-
return
|
|
50
|
+
export function toPosixPath(dirPath) {
|
|
51
|
+
return normalize(dirPath).split(/[\\/]/g).join(posix.sep);
|
|
71
52
|
}
|
|
72
53
|
/**
|
|
73
54
|
* Get the destination properties, based on the destination value.
|
|
@@ -80,13 +61,13 @@ function toPosixPath(dirPath) {
|
|
|
80
61
|
* @returns {boolean} destinationIsFullUrl - True if destination uses full URL format
|
|
81
62
|
* @returns {Authentication | undefined} destinationAuthentication - Authentication type configured for the destination
|
|
82
63
|
*/
|
|
83
|
-
async function getDestinationProperties(destination, cache = {}) {
|
|
64
|
+
export async function getDestinationProperties(destination, cache = {}) {
|
|
84
65
|
let destinationIsFullUrl = false;
|
|
85
66
|
let destinationAuthentication;
|
|
86
|
-
if (
|
|
67
|
+
if (isAppStudio() && destination) {
|
|
87
68
|
const destinations = await getBTPDestinations(cache);
|
|
88
69
|
if (destinations[destination]) {
|
|
89
|
-
destinationIsFullUrl =
|
|
70
|
+
destinationIsFullUrl = isFullUrlDestination(destinations[destination]);
|
|
90
71
|
destinationAuthentication = destinations[destination].Authentication;
|
|
91
72
|
}
|
|
92
73
|
}
|
|
@@ -100,8 +81,8 @@ async function getDestinationProperties(destination, cache = {}) {
|
|
|
100
81
|
* @param cache.list
|
|
101
82
|
* @returns Destinations list
|
|
102
83
|
*/
|
|
103
|
-
async function getBTPDestinations(cache = {}) {
|
|
104
|
-
cache.list ??= await
|
|
84
|
+
export async function getBTPDestinations(cache = {}) {
|
|
85
|
+
cache.list ??= await listDestinations({ stripS4HCApiHosts: true });
|
|
105
86
|
return cache.list;
|
|
106
87
|
}
|
|
107
88
|
/**
|
|
@@ -111,9 +92,9 @@ async function getBTPDestinations(cache = {}) {
|
|
|
111
92
|
* @returns True if the version is valid
|
|
112
93
|
* @throws {Error} If the MTA version is invalid or below minimum required version (0.0.1)
|
|
113
94
|
*/
|
|
114
|
-
function validateVersion(mtaVersion) {
|
|
115
|
-
const version =
|
|
116
|
-
if ((mtaVersion && !version) || (version && !
|
|
95
|
+
export function validateVersion(mtaVersion) {
|
|
96
|
+
const version = coerce(mtaVersion);
|
|
97
|
+
if ((mtaVersion && !version) || (version && !satisfies(version, `>=${MTAVersion}`))) {
|
|
117
98
|
throw new Error('Invalid MTA version specified. Please use version 0.0.1 or higher.');
|
|
118
99
|
}
|
|
119
100
|
return true;
|
|
@@ -127,9 +108,9 @@ function validateVersion(mtaVersion) {
|
|
|
127
108
|
* @param fs Reference to a mem-fs editor
|
|
128
109
|
* @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
|
|
129
110
|
*/
|
|
130
|
-
function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
|
|
131
|
-
fs.copyTpl(getTemplatePath(`common/${
|
|
132
|
-
id: mtaId.slice(0,
|
|
111
|
+
export function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
|
|
112
|
+
fs.copyTpl(getTemplatePath(`common/${FileName.XSSecurityJson}`), join(mtaPath, FileName.XSSecurityJson), {
|
|
113
|
+
id: mtaId.slice(0, MAX_MTA_PREFIX_LENGTH),
|
|
133
114
|
addTenant
|
|
134
115
|
});
|
|
135
116
|
}
|
|
@@ -139,8 +120,8 @@ function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
|
|
|
139
120
|
* @param targetPath Path to the project folder
|
|
140
121
|
* @param fs Reference to a mem-fs editor
|
|
141
122
|
*/
|
|
142
|
-
function addGitIgnore(targetPath, fs) {
|
|
143
|
-
fs.copyTpl(getTemplatePath('gitignore.tmpl'),
|
|
123
|
+
export function addGitIgnore(targetPath, fs) {
|
|
124
|
+
fs.copyTpl(getTemplatePath('gitignore.tmpl'), join(targetPath, FileName.DotGitIgnore), {});
|
|
144
125
|
}
|
|
145
126
|
/**
|
|
146
127
|
* Appends server package.json to the project folder.
|
|
@@ -150,8 +131,8 @@ function addGitIgnore(targetPath, fs) {
|
|
|
150
131
|
* @param config.mtaId MTA ID used in package.json
|
|
151
132
|
* @param fs Reference to a mem-fs editor
|
|
152
133
|
*/
|
|
153
|
-
function addRootPackage({ mtaPath, mtaId }, fs) {
|
|
154
|
-
fs.copyTpl(getTemplatePath(
|
|
134
|
+
export function addRootPackage({ mtaPath, mtaId }, fs) {
|
|
135
|
+
fs.copyTpl(getTemplatePath(FileName.Package), join(mtaPath, FileName.Package), {
|
|
155
136
|
mtaId
|
|
156
137
|
});
|
|
157
138
|
}
|
|
@@ -161,9 +142,9 @@ function addRootPackage({ mtaPath, mtaId }, fs) {
|
|
|
161
142
|
* @param targetPath Path to the package.json file
|
|
162
143
|
* @param fs Reference to a mem-fs editor
|
|
163
144
|
*/
|
|
164
|
-
async function addCommonPackageDependencies(targetPath, fs) {
|
|
165
|
-
await
|
|
166
|
-
await
|
|
145
|
+
export async function addCommonPackageDependencies(targetPath, fs) {
|
|
146
|
+
await addPackageDevDependency(targetPath, UI5TaskZipperPackage, UI5TaskZipperPackageVersion, fs);
|
|
147
|
+
await addPackageDevDependency(targetPath, UI5Package, UI5PackageVersion, fs);
|
|
167
148
|
}
|
|
168
149
|
/**
|
|
169
150
|
* Generate CF specific configurations to support deployment and undeployment.
|
|
@@ -172,15 +153,15 @@ async function addCommonPackageDependencies(targetPath, fs) {
|
|
|
172
153
|
* @param fs Reference to a mem-fs editor
|
|
173
154
|
* @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
|
|
174
155
|
*/
|
|
175
|
-
async function generateSupportingConfig(config, fs, addTenant = true) {
|
|
176
|
-
if (config.mtaId && !fs.exists(
|
|
156
|
+
export async function generateSupportingConfig(config, fs, addTenant = true) {
|
|
157
|
+
if (config.mtaId && !fs.exists(join(config.mtaPath, 'package.json'))) {
|
|
177
158
|
addRootPackage(config, fs);
|
|
178
159
|
}
|
|
179
|
-
if (config.mtaId && !fs.exists(
|
|
160
|
+
if (config.mtaId && !fs.exists(join(config.mtaPath, FileName.XSSecurityJson))) {
|
|
180
161
|
addXSSecurityConfig(config, fs, addTenant);
|
|
181
162
|
}
|
|
182
163
|
// Be a good citizen and add a .gitignore if missing from the existing project root
|
|
183
|
-
if (!fs.exists(
|
|
164
|
+
if (!fs.exists(join(config.mtaPath, '.gitignore'))) {
|
|
184
165
|
addGitIgnore(config.mtaPath, fs);
|
|
185
166
|
}
|
|
186
167
|
}
|
|
@@ -189,7 +170,7 @@ async function generateSupportingConfig(config, fs, addTenant = true) {
|
|
|
189
170
|
*
|
|
190
171
|
* @param config Writer configuration to be updated with default values
|
|
191
172
|
*/
|
|
192
|
-
function setMtaDefaults(config) {
|
|
173
|
+
export function setMtaDefaults(config) {
|
|
193
174
|
config.mtaPath = config.mtaPath.replace(/\/$/, '');
|
|
194
175
|
config.addConnectivityService ??= false;
|
|
195
176
|
config.mtaId = toMtaModuleName(config.mtaId);
|
|
@@ -203,24 +184,24 @@ function setMtaDefaults(config) {
|
|
|
203
184
|
* @param options.rootPath MTA project path
|
|
204
185
|
* @param fs Reference to a mem-fs editor
|
|
205
186
|
*/
|
|
206
|
-
async function updateRootPackage({ mtaId, rootPath }, fs) {
|
|
207
|
-
const packageExists = fileExists(fs,
|
|
187
|
+
export async function updateRootPackage({ mtaId, rootPath }, fs) {
|
|
188
|
+
const packageExists = fileExists(fs, join(rootPath, FileName.Package));
|
|
208
189
|
// Append package.json only if mta.yaml is at a different level to the HTML5 app
|
|
209
190
|
if (packageExists) {
|
|
210
191
|
// Align CDS versions if missing otherwise mta.yaml before-all scripts will fail
|
|
211
192
|
await alignCdsVersions(rootPath, fs);
|
|
212
|
-
await
|
|
213
|
-
await
|
|
193
|
+
await addPackageDevDependency(rootPath, Rimraf, RimrafVersion, fs);
|
|
194
|
+
await addPackageDevDependency(rootPath, MbtPackage, MbtPackageVersion, fs);
|
|
214
195
|
let deployArgs = [];
|
|
215
|
-
if (fs?.exists(
|
|
216
|
-
deployArgs = ['-e',
|
|
196
|
+
if (fs?.exists(join(rootPath, FileName.MtaExtYaml))) {
|
|
197
|
+
deployArgs = ['-e', FileName.MtaExtYaml];
|
|
217
198
|
}
|
|
218
199
|
for (const script of [
|
|
219
|
-
{ name: 'undeploy', run:
|
|
220
|
-
{ name: 'build', run: `${
|
|
221
|
-
{ name: 'deploy', run:
|
|
200
|
+
{ name: 'undeploy', run: undeployMTAScript(mtaId) },
|
|
201
|
+
{ name: 'build', run: `${MTABuildScript} --mtar archive` },
|
|
202
|
+
{ name: 'deploy', run: rootDeployMTAScript(deployArgs) }
|
|
222
203
|
]) {
|
|
223
|
-
await
|
|
204
|
+
await updatePackageScript(rootPath, script.name, script.run, fs);
|
|
224
205
|
}
|
|
225
206
|
}
|
|
226
207
|
}
|
|
@@ -229,7 +210,7 @@ async function updateRootPackage({ mtaId, rootPath }, fs) {
|
|
|
229
210
|
*
|
|
230
211
|
* @param config The current router configuration
|
|
231
212
|
*/
|
|
232
|
-
function enforceValidRouterConfig(config) {
|
|
213
|
+
export function enforceValidRouterConfig(config) {
|
|
233
214
|
const { addManagedAppRouter, addAppFrontendRouter } = config;
|
|
234
215
|
if (addManagedAppRouter) {
|
|
235
216
|
config.addAppFrontendRouter = false;
|
|
@@ -249,13 +230,13 @@ function enforceValidRouterConfig(config) {
|
|
|
249
230
|
* @param rootPath Path to the project folder
|
|
250
231
|
* @param fs Reference to a mem-fs editor
|
|
251
232
|
*/
|
|
252
|
-
async function alignCdsVersions(rootPath, fs) {
|
|
253
|
-
const filePath =
|
|
233
|
+
export async function alignCdsVersions(rootPath, fs) {
|
|
234
|
+
const filePath = join(rootPath, FileName.Package);
|
|
254
235
|
const packageJson = (fs.readJSON(filePath) ?? {});
|
|
255
|
-
const cdsDKDevDepVersion =
|
|
256
|
-
const cdsDepVersion = packageJson?.dependencies?.[
|
|
236
|
+
const cdsDKDevDepVersion = coerce(packageJson?.devDependencies?.[CDSDKPackage]);
|
|
237
|
+
const cdsDepVersion = packageJson?.dependencies?.[CDSPackage];
|
|
257
238
|
if (!cdsDKDevDepVersion && cdsDepVersion) {
|
|
258
|
-
await
|
|
239
|
+
await addPackageDevDependency(rootPath, CDSDKPackage, cdsDepVersion, fs);
|
|
259
240
|
}
|
|
260
241
|
}
|
|
261
242
|
/**
|
|
@@ -270,8 +251,8 @@ async function alignCdsVersions(rootPath, fs) {
|
|
|
270
251
|
* // Execute npm install in the project directory
|
|
271
252
|
* await runCommand('/path/to/project', 'npm', ['install'], 'Failed to install dependencies');
|
|
272
253
|
*/
|
|
273
|
-
async function runCommand(cwd, cmd, args, errorMsg) {
|
|
274
|
-
const commandRunner = new
|
|
254
|
+
export async function runCommand(cwd, cmd, args, errorMsg) {
|
|
255
|
+
const commandRunner = new CommandRunner();
|
|
275
256
|
try {
|
|
276
257
|
await commandRunner.run(cmd, args, { cwd });
|
|
277
258
|
}
|
|
@@ -287,7 +268,7 @@ async function runCommand(cwd, cmd, args, errorMsg) {
|
|
|
287
268
|
* @param filePath Path to the file
|
|
288
269
|
* @returns True if the file exists, false otherwise
|
|
289
270
|
*/
|
|
290
|
-
function fileExists(fs, filePath) {
|
|
271
|
+
export function fileExists(fs, filePath) {
|
|
291
272
|
return fs.exists(filePath);
|
|
292
273
|
}
|
|
293
274
|
//# 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.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Acf-deploy-config-writer"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"main": "dist/index.js",
|
|
15
16
|
"author": "@SAP/ux-tools-team",
|
|
@@ -29,14 +30,15 @@
|
|
|
29
30
|
"mem-fs": "2.1.0",
|
|
30
31
|
"mem-fs-editor": "9.4.0",
|
|
31
32
|
"hasbin": "1.2.3",
|
|
32
|
-
"@sap-ux/project-access": "
|
|
33
|
-
"@sap-ux/yaml": "0.
|
|
34
|
-
"@sap-ux/btp-utils": "
|
|
35
|
-
"@sap-ux/logger": "0.
|
|
36
|
-
"@sap-ux/ui5-config": "0.
|
|
37
|
-
"@sap-ux/nodejs-utils": "0.
|
|
33
|
+
"@sap-ux/project-access": "2.0.0",
|
|
34
|
+
"@sap-ux/yaml": "1.0.0",
|
|
35
|
+
"@sap-ux/btp-utils": "2.0.0",
|
|
36
|
+
"@sap-ux/logger": "1.0.0",
|
|
37
|
+
"@sap-ux/ui5-config": "1.0.0",
|
|
38
|
+
"@sap-ux/nodejs-utils": "1.0.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
41
|
+
"@jest/globals": "30.3.0",
|
|
40
42
|
"@types/ejs": "3.1.5",
|
|
41
43
|
"@types/mem-fs": "1.1.2",
|
|
42
44
|
"@types/mem-fs-editor": "7.0.1",
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
"format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",
|
|
62
64
|
"lint": "eslint",
|
|
63
65
|
"lint:fix": "eslint --fix",
|
|
64
|
-
"test": "jest --runInBand --ci --forceExit --detectOpenHandles --colors",
|
|
66
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --runInBand --ci --forceExit --detectOpenHandles --colors",
|
|
65
67
|
"watch": "tsc --watch"
|
|
66
68
|
}
|
|
67
69
|
}
|