@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/constants.js CHANGED
@@ -1,44 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CDSBinNotFound = exports.undeployMTAScript = exports.rootDeployMTAScript = exports.appDeployMTAScript = exports.MTABuildScript = exports.UI5DeployBuildScript = exports.UI5DeployBuildScriptForCap = 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.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.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.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.MTABinNotFound = void 0;
5
- const i18n_1 = require("./i18n");
6
- exports.WelcomeFile = 'welcomeFile';
7
- exports.MTABuildResult = 'build-result';
8
- exports.MTABuildParams = 'build-parameters';
9
- exports.DefaultServiceURL = '${default-url}';
10
- exports.ManagedXSUAA = 'managed:xsuaa';
11
- exports.ManagedAppFront = 'managed:app-front';
12
- exports.ManagedDestination = 'destination';
13
- exports.HTML5RepoHost = 'html5-apps-repo:app-host';
14
- exports.SRV_API = 'srv-api';
15
- exports.DefaultMTADestination = 'fiori-default-srv-api';
16
- exports.EmptyDestination = 'NONE';
17
- exports.MTADescription = 'Generated by Fiori Tools';
18
- exports.RouterModule = 'router';
19
- exports.CloudFoundry = 'cf';
20
- exports.deployMode = 'deploy_mode';
21
- exports.enableParallelDeployments = 'enable-parallel-deployments';
22
- exports.CDSExecutable = 'cds';
23
- exports.CDSDKPackage = '@sap/cds-dk';
24
- exports.CDSPackage = '@sap/cds';
25
- exports.MTAExecutable = 'mta';
26
- exports.MTAPackage = 'mta';
27
- exports.MTAVersion = '0.0.1';
28
- exports.RimrafVersion = '^5.0.5';
29
- exports.Rimraf = 'rimraf';
30
- exports.MbtPackage = 'mbt';
31
- exports.MbtPackageVersion = '^1.2.49';
32
- exports.UI5TaskZipperPackage = 'ui5-task-zipper';
33
- exports.UI5TaskZipperPackageVersion = '^3.4.x';
34
- exports.UI5Package = '@ui5/cli';
35
- exports.UI5PackageVersion = '^4.0.33';
36
- exports.CDSAddMtaParams = ['add', 'mta'];
37
- exports.CDSXSUAAService = 'xsuaa';
38
- exports.CDSHTML5RepoService = 'html5-repo';
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
- exports.UI5Destination = {
46
+ export const UI5Destination = {
50
47
  Name: 'ui5',
51
48
  Type: 'HTTP',
52
- URL: "https://ui5.sap.com" /* UI5_DEFAULT.SAPUI5_CDN */,
49
+ URL: UI5_DEFAULT.SAPUI5_CDN,
53
50
  ProxyType: 'Internet',
54
51
  Authentication: 'NoAuthentication'
55
52
  };
56
- exports.UI5AppfrontDestinationParameter = {
53
+ export const UI5AppfrontDestinationParameter = {
57
54
  name: 'ui5',
58
- url: "https://ui5.sap.com" /* UI5_DEFAULT.SAPUI5_CDN */
55
+ url: UI5_DEFAULT.SAPUI5_CDN
59
56
  };
60
- exports.CAPAppfrontDestination = {
61
- name: exports.SRV_API,
57
+ export const CAPAppfrontDestination = {
58
+ name: SRV_API,
62
59
  url: '~{srv-api/srv-url}',
63
60
  forwardAuthToken: true
64
61
  };
65
- exports.UI5ResourceDestination = {
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: "https://ui5.sap.com" /* UI5_DEFAULT.SAPUI5_CDN */,
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
- exports.UI5StandaloneModuleDestination = {
78
+ export const UI5StandaloneModuleDestination = {
82
79
  group: 'destinations',
83
80
  properties: {
84
81
  forwardAuthToken: false,
85
82
  name: 'ui5',
86
- url: "https://ui5.sap.com" /* UI5_DEFAULT.SAPUI5_CDN */
83
+ url: UI5_DEFAULT.SAPUI5_CDN
87
84
  }
88
85
  };
89
- exports.DestinationServiceConfig = {
86
+ export const DestinationServiceConfig = {
90
87
  config: {
91
88
  'HTML5Runtime_enabled': true,
92
89
  version: '1.0.0',
93
- ...exports.UI5ResourceDestination
90
+ ...UI5ResourceDestination
94
91
  }
95
92
  };
96
- exports.ServiceAPIRequires = {
97
- name: exports.SRV_API,
93
+ export const ServiceAPIRequires = {
94
+ name: SRV_API,
98
95
  properties: {
99
- 'srv-url': exports.DefaultServiceURL
96
+ 'srv-url': DefaultServiceURL
100
97
  }
101
98
  };
102
- exports.HTMLAppBuildParams = {
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
- exports.UI5DeployBuildScriptForCap = 'npm run build:cf';
109
- exports.UI5DeployBuildScript = 'ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateCachebusterInfo';
110
- exports.MTABuildScript = 'rimraf resources mta_archives && mbt build';
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
- exports.appDeployMTAScript = appDeployMTAScript;
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
- exports.rootDeployMTAScript = rootDeployMTAScript;
121
- const undeployMTAScript = (mtaId) => `cf undeploy ${mtaId} --delete-services --delete-service-keys --delete-service-brokers`;
122
- exports.undeployMTAScript = undeployMTAScript;
123
- const cannotFindBinary = (bin, pkg) => (0, i18n_1.t)('error.cannotFindBinary', { bin, pkg });
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
- exports.MAX_MTA_ID_LENGTH = 128;
128
- exports.MAX_MTA_PREFIX_LENGTH = 100;
129
- exports.MAX_MTA_PREFIX_SHORT_LENGTH = 94;
130
- exports.MAX_MTA_PREFIX_SHORTER_LENGTH = 96;
131
- exports.MAX_ABAP_SERVICE_PREFIX_LENGTH = 24;
132
- exports.MAX_ABAP_SERVICE_NAME_LENGTH = 20;
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
- exports.MTA_FILE_OPERATION_DELAY_MS = 1000;
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
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.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
- exports.i18n = i18next_1.default.createInstance();
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 exports.i18n.init({
10
+ export async function initI18n() {
11
+ await i18n.init({
20
12
  resources: {
21
13
  en: {
22
- [NS]: cf_deploy_config_writer_i18n_json_1.default
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 exports.i18n.t(key, options);
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, RouterModuleType, ApiHubConfig, ApiHubType } from './types';
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
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
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
@@ -1,11 +1,9 @@
1
- "use strict";
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 logger_1.ToolsLogger({ logPrefix: '@sap-ux/cf-deploy-config-writer' });
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
@@ -1,50 +1,22 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
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
- 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 (0, wait_for_mta_1.waitForMtaFile)(rootPath);
32
+ await waitForMtaFile(rootPath);
61
33
  }
62
34
  catch {
63
35
  // File did not become ready — return undefined (same behaviour as before)
64
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaReadWithPrefix', { prefix: undefined }));
36
+ LoggerHelper.logger?.debug(t('debug.mtaReadWithPrefix', { prefix: undefined }));
65
37
  return undefined;
66
38
  }
67
- const mtaConfig = await mta_1.MtaConfig.newInstance(rootPath, logger_helper_1.default.logger);
68
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaReadWithPrefix', { prefix: mtaConfig?.prefix }));
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 (0, utils_1.toMtaModuleName)(appId).slice(0, constants_1.MAX_MTA_ID_LENGTH);
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, constants_1.MAX_MTA_ID_LENGTH)}`;
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
- (0, template_renderer_1.renderTemplateToDisk)(`app/${project_access_1.FileName.MtaYaml}`, (0, node_path_1.join)(config.mtaPath, project_access_1.FileName.MtaYaml), {
64
+ renderTemplateToDisk(`app/${FileName.MtaYaml}`, join(config.mtaPath, FileName.MtaYaml), {
93
65
  id: mtaId,
94
- mtaDescription: config.mtaDescription ?? constants_1.MTADescription,
95
- mtaVersion: config.mtaVersion ?? constants_1.MTAVersion
66
+ mtaDescription: config.mtaDescription ?? MTADescription,
67
+ mtaVersion: config.mtaVersion ?? MTAVersion
96
68
  });
97
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaCreated', { mtaPath: config.mtaPath }));
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 (!(0, hasbin_1.sync)(constants_1.MTAExecutable)) {
106
- throw new Error(constants_1.MTABinNotFound);
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 (!(0, hasbin_1.sync)(constants_1.CDSExecutable)) {
116
- throw new Error(constants_1.CDSBinNotFound);
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((0, i18n_1.t)('error.missingMtaParameters'));
105
+ throw new Error(t('error.missingMtaParameters'));
134
106
  }
135
- if (config.mtaId.length > constants_1.MAX_MTA_ID_LENGTH || !/^[a-zA-Z_]/.test(config.mtaId)) {
136
- throw new Error((0, i18n_1.t)('error.invalidMtaId'));
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((0, i18n_1.t)('error.invalidMtaIdWithChars'));
111
+ throw new Error(t('error.invalidMtaIdWithChars'));
140
112
  }
141
- (0, utils_1.validateVersion)(config.mtaVersion);
113
+ validateVersion(config.mtaVersion);
142
114
  if (config.abapServiceProvider &&
143
115
  (!config.abapServiceProvider.abapService || !config.abapServiceProvider.abapServiceName)) {
144
- throw new Error((0, i18n_1.t)('error.missingABAPServiceBindingDetails'));
116
+ throw new Error(t('error.missingABAPServiceBindingDetails'));
145
117
  }
146
- (0, utils_1.setMtaDefaults)(config);
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
- (0, template_renderer_1.renderTemplateToDisk)(`frontend/${project_access_1.FileName.MtaYaml}`, (0, node_path_1.join)(config.mtaPath, project_access_1.FileName.MtaYaml), {
159
- id: `${config.mtaId.slice(0, constants_1.MAX_MTA_ID_LENGTH)}`,
160
- mtaDescription: config.mtaDescription ?? constants_1.MTADescription,
161
- mtaVersion: config.mtaVersion ?? constants_1.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
- (0, utils_1.addXSSecurityConfig)(config, fs, false);
165
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaCreated', { mtaPath: config.mtaPath }));
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((0, utils_1.getTemplatePath)(`router/package.json`), (0, node_path_1.join)(cfConfig.mtaPath, `${constants_1.RouterModule}/${project_access_1.FileName.Package}`));
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 (0, cf_tools_1.apiGetInstanceCredentials)(abapServiceName);
160
+ const instanceCredentials = await apiGetInstanceCredentials(abapServiceName);
189
161
  serviceKey = instanceCredentials?.credentials;
190
162
  }
191
163
  catch {
192
- logger_helper_1.default.logger?.error((0, i18n_1.t)('error.serviceKeyFailed'));
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((0, utils_1.getTemplatePath)('router/xs-app-abapservice.json'), (0, node_path_1.join)(cfConfig.mtaPath, `${constants_1.RouterModule}/${project_access_1.FileName.XSAppJson}`), { servicekeyService: service, servicekeyEndpoint: endpoints[0] });
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((0, utils_1.getTemplatePath)('router/xs-app-server.json'), (0, node_path_1.join)(cfConfig.mtaPath, `${constants_1.RouterModule}/${project_access_1.FileName.XSAppJson}`));
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 === types_1.RouterModuleType.Standard) {
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
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.capMtaUpdated'));
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 === types_1.RouterModuleType.AppFront) {
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
- constants_1.CDSXSUAAService,
235
- constants_1.CDSDestinationService,
236
- constants_1.CDSHTML5RepoService
206
+ CDSXSUAAService,
207
+ CDSDestinationService,
208
+ CDSHTML5RepoService
237
209
  ];
238
- const cdsParams = [...constants_1.CDSAddMtaParams, ...defaultOptions];
239
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.creatingMta', { cdsParams: cdsParams.toString() }));
240
- await (0, utils_1.runCommand)(config.mtaPath, constants_1.CDSExecutable, cdsParams, (0, i18n_1.t)('error.errorGeneratingMtaYaml'));
241
- logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.capMtaCreated'));
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
- __exportStar(require("./mta"), exports);
216
+ export * from './mta.js';
245
217
  //# sourceMappingURL=index.js.map
@@ -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
  */