@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
package/dist/constants.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
exports.CDSDestinationService = 'destination';
|
|
40
|
-
exports.MTAAPIDestination = {
|
|
41
|
-
Name: exports.SRV_API,
|
|
1
|
+
import { UI5_DEFAULT } from '@sap-ux/ui5-config';
|
|
2
|
+
import { t } from './i18n.js';
|
|
3
|
+
export const WelcomeFile = 'welcomeFile';
|
|
4
|
+
export const MTABuildResult = 'build-result';
|
|
5
|
+
export const MTABuildParams = 'build-parameters';
|
|
6
|
+
export const DefaultServiceURL = '${default-url}';
|
|
7
|
+
export const ManagedXSUAA = 'managed:xsuaa';
|
|
8
|
+
export const ManagedAppFront = 'managed:app-front';
|
|
9
|
+
export const ManagedDestination = 'destination';
|
|
10
|
+
export const HTML5RepoHost = 'html5-apps-repo:app-host';
|
|
11
|
+
export const SRV_API = 'srv-api';
|
|
12
|
+
export const DefaultMTADestination = 'fiori-default-srv-api';
|
|
13
|
+
export const EmptyDestination = 'NONE';
|
|
14
|
+
export const MTADescription = 'Generated by Fiori Tools';
|
|
15
|
+
export const RouterModule = 'router';
|
|
16
|
+
export const CloudFoundry = 'cf';
|
|
17
|
+
export const deployMode = 'deploy_mode';
|
|
18
|
+
export const enableParallelDeployments = 'enable-parallel-deployments';
|
|
19
|
+
export const CDSExecutable = 'cds';
|
|
20
|
+
export const CDSDKPackage = '@sap/cds-dk';
|
|
21
|
+
export const CDSPackage = '@sap/cds';
|
|
22
|
+
export const MTAExecutable = 'mta';
|
|
23
|
+
export const MTAPackage = 'mta';
|
|
24
|
+
export const MTAVersion = '0.0.1';
|
|
25
|
+
export const RimrafVersion = '^5.0.5';
|
|
26
|
+
export const Rimraf = 'rimraf';
|
|
27
|
+
export const MbtPackage = 'mbt';
|
|
28
|
+
export const MbtPackageVersion = '^1.2.49';
|
|
29
|
+
export const UI5TaskZipperPackage = 'ui5-task-zipper';
|
|
30
|
+
export const UI5TaskZipperPackageVersion = '^3.4.x';
|
|
31
|
+
export const UI5Package = '@ui5/cli';
|
|
32
|
+
export const UI5PackageVersion = '^4.0.33';
|
|
33
|
+
export const CDSAddMtaParams = ['add', 'mta'];
|
|
34
|
+
export const CDSXSUAAService = 'xsuaa';
|
|
35
|
+
export const CDSHTML5RepoService = 'html5-repo';
|
|
36
|
+
export const CDSDestinationService = 'destination';
|
|
37
|
+
export const MTAAPIDestination = {
|
|
38
|
+
Name: SRV_API,
|
|
42
39
|
Type: 'HTTP',
|
|
43
40
|
URL: `~{srv-api/srv-url}`,
|
|
44
41
|
ProxyType: 'Internet',
|
|
@@ -46,23 +43,23 @@ exports.MTAAPIDestination = {
|
|
|
46
43
|
'HTML5.DynamicDestination': true,
|
|
47
44
|
'HTML5.ForwardAuthToken': true
|
|
48
45
|
};
|
|
49
|
-
|
|
46
|
+
export const UI5Destination = {
|
|
50
47
|
Name: 'ui5',
|
|
51
48
|
Type: 'HTTP',
|
|
52
|
-
URL:
|
|
49
|
+
URL: UI5_DEFAULT.SAPUI5_CDN,
|
|
53
50
|
ProxyType: 'Internet',
|
|
54
51
|
Authentication: 'NoAuthentication'
|
|
55
52
|
};
|
|
56
|
-
|
|
53
|
+
export const UI5AppfrontDestinationParameter = {
|
|
57
54
|
name: 'ui5',
|
|
58
|
-
url:
|
|
55
|
+
url: UI5_DEFAULT.SAPUI5_CDN
|
|
59
56
|
};
|
|
60
|
-
|
|
61
|
-
name:
|
|
57
|
+
export const CAPAppfrontDestination = {
|
|
58
|
+
name: SRV_API,
|
|
62
59
|
url: '~{srv-api/srv-url}',
|
|
63
60
|
forwardAuthToken: true
|
|
64
61
|
};
|
|
65
|
-
|
|
62
|
+
export const UI5ResourceDestination = {
|
|
66
63
|
'init_data': {
|
|
67
64
|
instance: {
|
|
68
65
|
'existing_destinations_policy': 'update',
|
|
@@ -70,7 +67,7 @@ exports.UI5ResourceDestination = {
|
|
|
70
67
|
{
|
|
71
68
|
Name: 'ui5',
|
|
72
69
|
Type: 'HTTP',
|
|
73
|
-
URL:
|
|
70
|
+
URL: UI5_DEFAULT.SAPUI5_CDN,
|
|
74
71
|
ProxyType: 'Internet',
|
|
75
72
|
Authentication: 'NoAuthentication'
|
|
76
73
|
}
|
|
@@ -78,60 +75,57 @@ exports.UI5ResourceDestination = {
|
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
};
|
|
81
|
-
|
|
78
|
+
export const UI5StandaloneModuleDestination = {
|
|
82
79
|
group: 'destinations',
|
|
83
80
|
properties: {
|
|
84
81
|
forwardAuthToken: false,
|
|
85
82
|
name: 'ui5',
|
|
86
|
-
url:
|
|
83
|
+
url: UI5_DEFAULT.SAPUI5_CDN
|
|
87
84
|
}
|
|
88
85
|
};
|
|
89
|
-
|
|
86
|
+
export const DestinationServiceConfig = {
|
|
90
87
|
config: {
|
|
91
88
|
'HTML5Runtime_enabled': true,
|
|
92
89
|
version: '1.0.0',
|
|
93
|
-
...
|
|
90
|
+
...UI5ResourceDestination
|
|
94
91
|
}
|
|
95
92
|
};
|
|
96
|
-
|
|
97
|
-
name:
|
|
93
|
+
export const ServiceAPIRequires = {
|
|
94
|
+
name: SRV_API,
|
|
98
95
|
properties: {
|
|
99
|
-
'srv-url':
|
|
96
|
+
'srv-url': DefaultServiceURL
|
|
100
97
|
}
|
|
101
98
|
};
|
|
102
|
-
|
|
99
|
+
export const HTMLAppBuildParams = {
|
|
103
100
|
builder: 'custom',
|
|
104
101
|
'build-result': 'dist',
|
|
105
102
|
commands: ['npm install', 'npm run build:cf'],
|
|
106
103
|
'supported-platforms': []
|
|
107
104
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const appDeployMTAScript = (args) => {
|
|
105
|
+
export const UI5DeployBuildScriptForCap = 'npm run build:cf';
|
|
106
|
+
export const UI5DeployBuildScript = 'ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateCachebusterInfo';
|
|
107
|
+
export const MTABuildScript = 'rimraf resources mta_archives && mbt build';
|
|
108
|
+
export const appDeployMTAScript = (args) => {
|
|
112
109
|
const mtaArgs = args.length > 0 ? ` ${args.join(' ')}` : '';
|
|
113
110
|
return `fiori cfDeploy${mtaArgs}`;
|
|
114
111
|
};
|
|
115
|
-
|
|
116
|
-
const rootDeployMTAScript = (args) => {
|
|
112
|
+
export const rootDeployMTAScript = (args) => {
|
|
117
113
|
const mtaArgs = args.length > 0 ? `${args.join(' ')} ` : '';
|
|
118
114
|
return `cf deploy mta_archives/archive.mtar ${mtaArgs}--retries 1`;
|
|
119
115
|
};
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
exports.CDSBinNotFound = cannotFindBinary(exports.CDSExecutable, exports.CDSDKPackage);
|
|
125
|
-
exports.MTABinNotFound = cannotFindBinary(exports.MTAExecutable, exports.MTAPackage);
|
|
116
|
+
export const undeployMTAScript = (mtaId) => `cf undeploy ${mtaId} --delete-services --delete-service-keys --delete-service-brokers`;
|
|
117
|
+
const cannotFindBinary = (bin, pkg) => t('error.cannotFindBinary', { bin, pkg });
|
|
118
|
+
export const CDSBinNotFound = cannotFindBinary(CDSExecutable, CDSDKPackage);
|
|
119
|
+
export const MTABinNotFound = cannotFindBinary(MTAExecutable, MTAPackage);
|
|
126
120
|
// MTA ID length limits
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
export const MAX_MTA_ID_LENGTH = 128;
|
|
122
|
+
export const MAX_MTA_PREFIX_LENGTH = 100;
|
|
123
|
+
export const MAX_MTA_PREFIX_SHORT_LENGTH = 94;
|
|
124
|
+
export const MAX_MTA_PREFIX_SHORTER_LENGTH = 96;
|
|
125
|
+
export const MAX_ABAP_SERVICE_PREFIX_LENGTH = 24;
|
|
126
|
+
export const MAX_ABAP_SERVICE_NAME_LENGTH = 20;
|
|
133
127
|
// MTA file operation timing
|
|
134
128
|
// Delay in milliseconds to ensure MTA file operations complete before subsequent reads
|
|
135
129
|
// This is necessary as mta-lib requires files to be fully written to disk before access
|
|
136
|
-
|
|
130
|
+
export const MTA_FILE_OPERATION_DELAY_MS = 1000;
|
|
137
131
|
//# sourceMappingURL=constants.js.map
|
package/dist/i18n.js
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.i18n = void 0;
|
|
7
|
-
exports.initI18n = initI18n;
|
|
8
|
-
exports.t = t;
|
|
9
|
-
const i18next_1 = __importDefault(require("i18next"));
|
|
10
|
-
const cf_deploy_config_writer_i18n_json_1 = __importDefault(require("./translations/cf-deploy-config-writer.i18n.json"));
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import translations from './translations/cf-deploy-config-writer.i18n.json' with { type: 'json' };
|
|
11
3
|
const NS = 'cf-deploy-config-writer';
|
|
12
|
-
|
|
4
|
+
export const i18n = i18next.createInstance();
|
|
13
5
|
/**
|
|
14
6
|
* Initialize i18next with the translations for this module.
|
|
15
7
|
*
|
|
16
8
|
* @returns {Promise<void>} A promise that resolves when i18n is initialized
|
|
17
9
|
*/
|
|
18
|
-
async function initI18n() {
|
|
19
|
-
await
|
|
10
|
+
export async function initI18n() {
|
|
11
|
+
await i18n.init({
|
|
20
12
|
resources: {
|
|
21
13
|
en: {
|
|
22
|
-
[NS]:
|
|
14
|
+
[NS]: translations
|
|
23
15
|
}
|
|
24
16
|
},
|
|
25
17
|
lng: 'en',
|
|
@@ -36,12 +28,10 @@ async function initI18n() {
|
|
|
36
28
|
* @param options additional options
|
|
37
29
|
* @returns {string} localized string stored for the given key
|
|
38
30
|
*/
|
|
39
|
-
function t(key, options) {
|
|
40
|
-
return
|
|
31
|
+
export function t(key, options) {
|
|
32
|
+
return i18n.t(key, options);
|
|
41
33
|
}
|
|
42
34
|
// Initialize i18n on module load
|
|
43
35
|
// Errors are ignored since the writer will still work (fallback strings will be used)
|
|
44
|
-
initI18n().catch(() =>
|
|
45
|
-
// Ignore any errors since the write will still work
|
|
46
|
-
});
|
|
36
|
+
void initI18n().catch(() => undefined);
|
|
47
37
|
//# sourceMappingURL=i18n.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './mta-config';
|
|
2
|
-
export * from './cf-writer';
|
|
3
|
-
export { DefaultMTADestination, MAX_MTA_ID_LENGTH, MAX_MTA_PREFIX_LENGTH, MAX_MTA_PREFIX_SHORT_LENGTH, MAX_MTA_PREFIX_SHORTER_LENGTH, MAX_ABAP_SERVICE_PREFIX_LENGTH, MAX_ABAP_SERVICE_NAME_LENGTH, MTA_FILE_OPERATION_DELAY_MS } from './constants';
|
|
4
|
-
export { CFBaseConfig, CFAppConfig, CAPConfig,
|
|
1
|
+
export * from './mta-config/index.js';
|
|
2
|
+
export * from './cf-writer/index.js';
|
|
3
|
+
export { DefaultMTADestination, MAX_MTA_ID_LENGTH, MAX_MTA_PREFIX_LENGTH, MAX_MTA_PREFIX_SHORT_LENGTH, MAX_MTA_PREFIX_SHORTER_LENGTH, MAX_ABAP_SERVICE_PREFIX_LENGTH, MAX_ABAP_SERVICE_NAME_LENGTH, MTA_FILE_OPERATION_DELAY_MS } from './constants.js';
|
|
4
|
+
export type { CFBaseConfig, CFAppConfig, CAPConfig, ApiHubConfig } from './types/index.js';
|
|
5
|
+
export { RouterModuleType, ApiHubType } from './types/index.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.RouterModuleType = exports.MTA_FILE_OPERATION_DELAY_MS = exports.MAX_ABAP_SERVICE_NAME_LENGTH = exports.MAX_ABAP_SERVICE_PREFIX_LENGTH = exports.MAX_MTA_PREFIX_SHORTER_LENGTH = exports.MAX_MTA_PREFIX_SHORT_LENGTH = exports.MAX_MTA_PREFIX_LENGTH = exports.MAX_MTA_ID_LENGTH = exports.DefaultMTADestination = void 0;
|
|
18
|
-
__exportStar(require("./mta-config"), exports);
|
|
19
|
-
__exportStar(require("./cf-writer"), exports);
|
|
20
|
-
var constants_1 = require("./constants");
|
|
21
|
-
Object.defineProperty(exports, "DefaultMTADestination", { enumerable: true, get: function () { return constants_1.DefaultMTADestination; } });
|
|
22
|
-
Object.defineProperty(exports, "MAX_MTA_ID_LENGTH", { enumerable: true, get: function () { return constants_1.MAX_MTA_ID_LENGTH; } });
|
|
23
|
-
Object.defineProperty(exports, "MAX_MTA_PREFIX_LENGTH", { enumerable: true, get: function () { return constants_1.MAX_MTA_PREFIX_LENGTH; } });
|
|
24
|
-
Object.defineProperty(exports, "MAX_MTA_PREFIX_SHORT_LENGTH", { enumerable: true, get: function () { return constants_1.MAX_MTA_PREFIX_SHORT_LENGTH; } });
|
|
25
|
-
Object.defineProperty(exports, "MAX_MTA_PREFIX_SHORTER_LENGTH", { enumerable: true, get: function () { return constants_1.MAX_MTA_PREFIX_SHORTER_LENGTH; } });
|
|
26
|
-
Object.defineProperty(exports, "MAX_ABAP_SERVICE_PREFIX_LENGTH", { enumerable: true, get: function () { return constants_1.MAX_ABAP_SERVICE_PREFIX_LENGTH; } });
|
|
27
|
-
Object.defineProperty(exports, "MAX_ABAP_SERVICE_NAME_LENGTH", { enumerable: true, get: function () { return constants_1.MAX_ABAP_SERVICE_NAME_LENGTH; } });
|
|
28
|
-
Object.defineProperty(exports, "MTA_FILE_OPERATION_DELAY_MS", { enumerable: true, get: function () { return constants_1.MTA_FILE_OPERATION_DELAY_MS; } });
|
|
29
|
-
var types_1 = require("./types");
|
|
30
|
-
Object.defineProperty(exports, "RouterModuleType", { enumerable: true, get: function () { return types_1.RouterModuleType; } });
|
|
1
|
+
export * from './mta-config/index.js';
|
|
2
|
+
export * from './cf-writer/index.js';
|
|
3
|
+
export { DefaultMTADestination, MAX_MTA_ID_LENGTH, MAX_MTA_PREFIX_LENGTH, MAX_MTA_PREFIX_SHORT_LENGTH, MAX_MTA_PREFIX_SHORTER_LENGTH, MAX_ABAP_SERVICE_PREFIX_LENGTH, MAX_ABAP_SERVICE_NAME_LENGTH, MTA_FILE_OPERATION_DELAY_MS } from './constants.js';
|
|
4
|
+
export { RouterModuleType, ApiHubType } from './types/index.js';
|
|
31
5
|
//# sourceMappingURL=index.js.map
|
package/dist/logger-helper.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const logger_1 = require("@sap-ux/logger");
|
|
1
|
+
import { ToolsLogger } from '@sap-ux/logger';
|
|
4
2
|
/**
|
|
5
3
|
* Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
|
|
6
4
|
*/
|
|
7
|
-
class LoggerHelper {
|
|
8
|
-
static _logger = new
|
|
5
|
+
export default class LoggerHelper {
|
|
6
|
+
static _logger = new ToolsLogger({ logPrefix: '@sap-ux/cf-deploy-config-writer' });
|
|
9
7
|
/**
|
|
10
8
|
* Get the logger.
|
|
11
9
|
*
|
|
@@ -23,5 +21,4 @@ class LoggerHelper {
|
|
|
23
21
|
LoggerHelper._logger = value;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
exports.default = LoggerHelper;
|
|
27
24
|
//# sourceMappingURL=logger-helper.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MtaConfig } from './mta';
|
|
2
|
-
import { type MTABaseConfig, type CFBaseConfig, type CAPConfig } from '../types';
|
|
1
|
+
import { MtaConfig } from './mta.js';
|
|
2
|
+
import { type MTABaseConfig, type CFBaseConfig, type CAPConfig } from '../types/index.js';
|
|
3
3
|
import { type Editor } from 'mem-fs-editor';
|
|
4
4
|
/**
|
|
5
5
|
* Get the MTA ID, read from the root path specified.
|
|
@@ -68,5 +68,5 @@ export declare function addRoutingConfig(config: CFBaseConfig, fs: Editor): Prom
|
|
|
68
68
|
* @throws {Error} If CDS command execution fails when generating mta.yaml
|
|
69
69
|
*/
|
|
70
70
|
export declare function generateCAPMTA(config: CAPConfig, fs: Editor): Promise<void>;
|
|
71
|
-
export * from './mta';
|
|
71
|
+
export * from './mta.js';
|
|
72
72
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mta-config/index.js
CHANGED
|
@@ -1,50 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.getMtaId = getMtaId;
|
|
21
|
-
exports.getMtaConfig = getMtaConfig;
|
|
22
|
-
exports.toMtaModuleName = toMtaModuleName;
|
|
23
|
-
exports.createMTA = createMTA;
|
|
24
|
-
exports.doesMTABinaryExist = doesMTABinaryExist;
|
|
25
|
-
exports.doesCDSBinaryExist = doesCDSBinaryExist;
|
|
26
|
-
exports.validateMtaConfig = validateMtaConfig;
|
|
27
|
-
exports.addRoutingConfig = addRoutingConfig;
|
|
28
|
-
exports.generateCAPMTA = generateCAPMTA;
|
|
29
|
-
const node_path_1 = require("node:path");
|
|
30
|
-
const mta_1 = require("./mta");
|
|
31
|
-
const template_renderer_1 = require("./template-renderer");
|
|
32
|
-
const utils_1 = require("../utils");
|
|
33
|
-
const constants_1 = require("../constants");
|
|
34
|
-
const wait_for_mta_1 = require("./wait-for-mta");
|
|
35
|
-
const types_1 = require("../types");
|
|
36
|
-
const logger_helper_1 = __importDefault(require("../logger-helper"));
|
|
37
|
-
const hasbin_1 = require("hasbin");
|
|
38
|
-
const i18n_1 = require("../i18n");
|
|
39
|
-
const cf_tools_1 = require("@sap/cf-tools");
|
|
40
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { MtaConfig } from './mta.js';
|
|
3
|
+
import { renderTemplateToDisk } from './template-renderer.js';
|
|
4
|
+
import { addXSSecurityConfig, getTemplatePath, setMtaDefaults, validateVersion, runCommand, toMtaModuleName as toMtaModuleNameUtil } from '../utils.js';
|
|
5
|
+
import { MTAVersion, MTADescription, CDSAddMtaParams, CDSBinNotFound, CDSExecutable, MTABinNotFound, MTAExecutable, CDSXSUAAService, CDSDestinationService, CDSHTML5RepoService, RouterModule, MAX_MTA_ID_LENGTH } from '../constants.js';
|
|
6
|
+
import { waitForMtaFile } from './wait-for-mta.js';
|
|
7
|
+
import { RouterModuleType } from '../types/index.js';
|
|
8
|
+
import LoggerHelper from '../logger-helper.js';
|
|
9
|
+
import { sync } from 'hasbin';
|
|
10
|
+
import { t } from '../i18n.js';
|
|
11
|
+
import { apiGetInstanceCredentials } from '@sap/cf-tools';
|
|
12
|
+
import { FileName } from '@sap-ux/project-access';
|
|
41
13
|
/**
|
|
42
14
|
* Get the MTA ID, read from the root path specified.
|
|
43
15
|
*
|
|
44
16
|
* @param rootPath Path to the root folder
|
|
45
17
|
* @returns MTA ID if found
|
|
46
18
|
*/
|
|
47
|
-
async function getMtaId(rootPath) {
|
|
19
|
+
export async function getMtaId(rootPath) {
|
|
48
20
|
return (await getMtaConfig(rootPath))?.prefix;
|
|
49
21
|
}
|
|
50
22
|
/**
|
|
@@ -55,17 +27,17 @@ async function getMtaId(rootPath) {
|
|
|
55
27
|
* @param rootPath Path to the root folder
|
|
56
28
|
* @returns MtaConfig instance if found
|
|
57
29
|
*/
|
|
58
|
-
async function getMtaConfig(rootPath) {
|
|
30
|
+
export async function getMtaConfig(rootPath) {
|
|
59
31
|
try {
|
|
60
|
-
await
|
|
32
|
+
await waitForMtaFile(rootPath);
|
|
61
33
|
}
|
|
62
34
|
catch {
|
|
63
35
|
// File did not become ready — return undefined (same behaviour as before)
|
|
64
|
-
|
|
36
|
+
LoggerHelper.logger?.debug(t('debug.mtaReadWithPrefix', { prefix: undefined }));
|
|
65
37
|
return undefined;
|
|
66
38
|
}
|
|
67
|
-
const mtaConfig = await
|
|
68
|
-
|
|
39
|
+
const mtaConfig = await MtaConfig.newInstance(rootPath, LoggerHelper.logger);
|
|
40
|
+
LoggerHelper.logger?.debug(t('debug.mtaReadWithPrefix', { prefix: mtaConfig?.prefix }));
|
|
69
41
|
return mtaConfig;
|
|
70
42
|
}
|
|
71
43
|
/**
|
|
@@ -76,44 +48,44 @@ async function getMtaConfig(rootPath) {
|
|
|
76
48
|
* @param appId Name of the app, like `sap.ux.app`
|
|
77
49
|
* @returns Name that's acceptable for mta.yaml (sanitized and length-restricted)
|
|
78
50
|
*/
|
|
79
|
-
function toMtaModuleName(appId) {
|
|
51
|
+
export function toMtaModuleName(appId) {
|
|
80
52
|
// Use the canonical implementation from utils and apply length restriction
|
|
81
|
-
return (
|
|
53
|
+
return toMtaModuleNameUtil(appId).slice(0, MAX_MTA_ID_LENGTH);
|
|
82
54
|
}
|
|
83
55
|
/**
|
|
84
56
|
* Create an MTA file in the target folder, needs to be written to disk as subsequent calls are dependent on it being on the file system i.e mta-lib.
|
|
85
57
|
*
|
|
86
58
|
* @param config writer configuration
|
|
87
59
|
*/
|
|
88
|
-
function createMTA(config) {
|
|
89
|
-
const mtaId = `${config.mtaId.slice(0,
|
|
60
|
+
export function createMTA(config) {
|
|
61
|
+
const mtaId = `${config.mtaId.slice(0, MAX_MTA_ID_LENGTH)}`;
|
|
90
62
|
config.mtaId = mtaId;
|
|
91
63
|
// Written to disk immediately! Subsequent calls are dependent on it being on the file system i.e mta-lib.
|
|
92
|
-
|
|
64
|
+
renderTemplateToDisk(`app/${FileName.MtaYaml}`, join(config.mtaPath, FileName.MtaYaml), {
|
|
93
65
|
id: mtaId,
|
|
94
|
-
mtaDescription: config.mtaDescription ??
|
|
95
|
-
mtaVersion: config.mtaVersion ??
|
|
66
|
+
mtaDescription: config.mtaDescription ?? MTADescription,
|
|
67
|
+
mtaVersion: config.mtaVersion ?? MTAVersion
|
|
96
68
|
});
|
|
97
|
-
|
|
69
|
+
LoggerHelper.logger?.debug(t('debug.mtaCreated', { mtaPath: config.mtaPath }));
|
|
98
70
|
}
|
|
99
71
|
/**
|
|
100
72
|
* Validate MTA binary is available.
|
|
101
73
|
*
|
|
102
74
|
*/
|
|
103
|
-
function doesMTABinaryExist() {
|
|
75
|
+
export function doesMTABinaryExist() {
|
|
104
76
|
// CF Writer is dependent on the mta-lib library, which in turn relies on the mta executable being installed and available in the path
|
|
105
|
-
if (!
|
|
106
|
-
throw new Error(
|
|
77
|
+
if (!sync(MTAExecutable)) {
|
|
78
|
+
throw new Error(MTABinNotFound);
|
|
107
79
|
}
|
|
108
80
|
}
|
|
109
81
|
/**
|
|
110
82
|
* Validate CDS binary is available.
|
|
111
83
|
*
|
|
112
84
|
*/
|
|
113
|
-
function doesCDSBinaryExist() {
|
|
85
|
+
export function doesCDSBinaryExist() {
|
|
114
86
|
// CF Writer is dependent on the cds library
|
|
115
|
-
if (!
|
|
116
|
-
throw new Error(
|
|
87
|
+
if (!sync(CDSExecutable)) {
|
|
88
|
+
throw new Error(CDSBinNotFound);
|
|
117
89
|
}
|
|
118
90
|
}
|
|
119
91
|
/**
|
|
@@ -126,24 +98,24 @@ function doesCDSBinaryExist() {
|
|
|
126
98
|
* @throws {Error} If MTA version is invalid
|
|
127
99
|
* @throws {Error} If ABAP service binding details are incomplete
|
|
128
100
|
*/
|
|
129
|
-
function validateMtaConfig(config) {
|
|
101
|
+
export function validateMtaConfig(config) {
|
|
130
102
|
// We use mta-lib, which in turn relies on the mta executable being installed and available in the path
|
|
131
103
|
doesMTABinaryExist();
|
|
132
104
|
if (!config.routerType || !config.mtaId || !config.mtaPath) {
|
|
133
|
-
throw new Error(
|
|
105
|
+
throw new Error(t('error.missingMtaParameters'));
|
|
134
106
|
}
|
|
135
|
-
if (config.mtaId.length >
|
|
136
|
-
throw new Error(
|
|
107
|
+
if (config.mtaId.length > MAX_MTA_ID_LENGTH || !/^[a-zA-Z_]/.test(config.mtaId)) {
|
|
108
|
+
throw new Error(t('error.invalidMtaId'));
|
|
137
109
|
}
|
|
138
110
|
if (!/^[\w\-.]*$/.test(config.mtaId)) {
|
|
139
|
-
throw new Error(
|
|
111
|
+
throw new Error(t('error.invalidMtaIdWithChars'));
|
|
140
112
|
}
|
|
141
|
-
|
|
113
|
+
validateVersion(config.mtaVersion);
|
|
142
114
|
if (config.abapServiceProvider &&
|
|
143
115
|
(!config.abapServiceProvider.abapService || !config.abapServiceProvider.abapServiceName)) {
|
|
144
|
-
throw new Error(
|
|
116
|
+
throw new Error(t('error.missingABAPServiceBindingDetails'));
|
|
145
117
|
}
|
|
146
|
-
|
|
118
|
+
setMtaDefaults(config);
|
|
147
119
|
}
|
|
148
120
|
/**
|
|
149
121
|
* Create an MTA file in the target folder, needs to be written to disk as subsequent calls are dependent on it being on the file system i.e mta-lib.
|
|
@@ -155,14 +127,14 @@ function validateMtaConfig(config) {
|
|
|
155
127
|
*/
|
|
156
128
|
async function createCAPMTAAppFrontend(config, fs) {
|
|
157
129
|
// Written to disk immediately! Subsequent calls are dependent on it being on the file system i.e mta-lib.
|
|
158
|
-
|
|
159
|
-
id: `${config.mtaId.slice(0,
|
|
160
|
-
mtaDescription: config.mtaDescription ??
|
|
161
|
-
mtaVersion: config.mtaVersion ??
|
|
130
|
+
renderTemplateToDisk(`frontend/${FileName.MtaYaml}`, join(config.mtaPath, FileName.MtaYaml), {
|
|
131
|
+
id: `${config.mtaId.slice(0, MAX_MTA_ID_LENGTH)}`,
|
|
132
|
+
mtaDescription: config.mtaDescription ?? MTADescription,
|
|
133
|
+
mtaVersion: config.mtaVersion ?? MTAVersion
|
|
162
134
|
});
|
|
163
135
|
// Add missing configurations
|
|
164
|
-
|
|
165
|
-
|
|
136
|
+
addXSSecurityConfig(config, fs, false);
|
|
137
|
+
LoggerHelper.logger?.debug(t('debug.mtaCreated', { mtaPath: config.mtaPath }));
|
|
166
138
|
}
|
|
167
139
|
/**
|
|
168
140
|
* Add standalone app router to the target folder.
|
|
@@ -181,22 +153,22 @@ async function addStandaloneRouter(cfConfig, mtaInstance, fs) {
|
|
|
181
153
|
if (abapServiceName && abapService) {
|
|
182
154
|
await mtaInstance.addAbapService(abapServiceName, abapService);
|
|
183
155
|
}
|
|
184
|
-
fs.copyTpl(
|
|
156
|
+
fs.copyTpl(getTemplatePath(`router/package.json`), join(cfConfig.mtaPath, `${RouterModule}/${FileName.Package}`));
|
|
185
157
|
if (abapServiceName) {
|
|
186
158
|
let serviceKey;
|
|
187
159
|
try {
|
|
188
|
-
const instanceCredentials = await
|
|
160
|
+
const instanceCredentials = await apiGetInstanceCredentials(abapServiceName);
|
|
189
161
|
serviceKey = instanceCredentials?.credentials;
|
|
190
162
|
}
|
|
191
163
|
catch {
|
|
192
|
-
|
|
164
|
+
LoggerHelper.logger?.error(t('error.serviceKeyFailed'));
|
|
193
165
|
}
|
|
194
166
|
const endpoints = serviceKey?.endpoints ? Object.keys(serviceKey.endpoints) : [''];
|
|
195
167
|
const service = serviceKey ? serviceKey['sap.cloud.service'] : '';
|
|
196
|
-
fs.copyTpl(
|
|
168
|
+
fs.copyTpl(getTemplatePath('router/xs-app-abapservice.json'), join(cfConfig.mtaPath, `${RouterModule}/${FileName.XSAppJson}`), { servicekeyService: service, servicekeyEndpoint: endpoints[0] });
|
|
197
169
|
}
|
|
198
170
|
else {
|
|
199
|
-
fs.copyTpl(
|
|
171
|
+
fs.copyTpl(getTemplatePath('router/xs-app-server.json'), join(cfConfig.mtaPath, `${RouterModule}/${FileName.XSAppJson}`));
|
|
200
172
|
}
|
|
201
173
|
}
|
|
202
174
|
/**
|
|
@@ -205,17 +177,17 @@ async function addStandaloneRouter(cfConfig, mtaInstance, fs) {
|
|
|
205
177
|
* @param config Writer configuration
|
|
206
178
|
* @param fs Reference to a mem-fs editor
|
|
207
179
|
*/
|
|
208
|
-
async function addRoutingConfig(config, fs) {
|
|
180
|
+
export async function addRoutingConfig(config, fs) {
|
|
209
181
|
const mtaConfigInstance = await getMtaConfig(config.mtaPath);
|
|
210
182
|
if (mtaConfigInstance) {
|
|
211
|
-
if (config.routerType ===
|
|
183
|
+
if (config.routerType === RouterModuleType.Standard) {
|
|
212
184
|
await addStandaloneRouter(config, mtaConfigInstance, fs);
|
|
213
185
|
}
|
|
214
186
|
else {
|
|
215
187
|
await mtaConfigInstance.addRouterType({ routerType: config.routerType, addMissingModules: false });
|
|
216
188
|
}
|
|
217
189
|
await mtaConfigInstance.save();
|
|
218
|
-
|
|
190
|
+
LoggerHelper.logger?.debug(t('debug.capMtaUpdated'));
|
|
219
191
|
}
|
|
220
192
|
}
|
|
221
193
|
/**
|
|
@@ -225,21 +197,21 @@ async function addRoutingConfig(config, fs) {
|
|
|
225
197
|
* @param fs Reference to a mem-fs editor
|
|
226
198
|
* @throws {Error} If CDS command execution fails when generating mta.yaml
|
|
227
199
|
*/
|
|
228
|
-
async function generateCAPMTA(config, fs) {
|
|
229
|
-
if (config.routerType ===
|
|
200
|
+
export async function generateCAPMTA(config, fs) {
|
|
201
|
+
if (config.routerType === RouterModuleType.AppFront) {
|
|
230
202
|
await createCAPMTAAppFrontend(config, fs);
|
|
231
203
|
}
|
|
232
204
|
else {
|
|
233
205
|
const defaultOptions = [
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
206
|
+
CDSXSUAAService,
|
|
207
|
+
CDSDestinationService,
|
|
208
|
+
CDSHTML5RepoService
|
|
237
209
|
];
|
|
238
|
-
const cdsParams = [...
|
|
239
|
-
|
|
240
|
-
await
|
|
241
|
-
|
|
210
|
+
const cdsParams = [...CDSAddMtaParams, ...defaultOptions];
|
|
211
|
+
LoggerHelper.logger?.debug(t('debug.creatingMta', { cdsParams: cdsParams.toString() }));
|
|
212
|
+
await runCommand(config.mtaPath, CDSExecutable, cdsParams, t('error.errorGeneratingMtaYaml'));
|
|
213
|
+
LoggerHelper.logger?.debug(t('debug.capMtaCreated'));
|
|
242
214
|
}
|
|
243
215
|
}
|
|
244
|
-
|
|
216
|
+
export * from './mta.js';
|
|
245
217
|
//# sourceMappingURL=index.js.map
|
package/dist/mta-config/mta.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type mta } from '@sap/mta-lib';
|
|
2
2
|
import type { Logger } from '@sap-ux/logger';
|
|
3
|
-
import { RouterModuleType } from '../types';
|
|
3
|
+
import { RouterModuleType } from '../types/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* A class representing interactions with the MTA binary, found at https://sap.github.io/cloud-mta-build-tool/.
|
|
6
6
|
*/
|