@sap-ux/cf-deploy-config-writer 0.1.10 → 0.1.12

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.
@@ -160,7 +160,9 @@ async function generateDeployConfig(cfAppConfig, fs) {
160
160
  await appendCloudFoundryConfigurations(config, fs);
161
161
  await updateManifest(config, fs);
162
162
  await updateHTML5AppPackage(config, fs);
163
- await updateRootPackage(config, fs);
163
+ if (config.isMtaRoot) {
164
+ await (0, utils_1.updateRootPackage)({ mtaId: config.mtaId ?? config.appId, rootPath: config.rootPath }, fs);
165
+ }
164
166
  }
165
167
  /**
166
168
  * Creates the MTA configuration file.
@@ -329,31 +331,6 @@ async function updateHTML5AppPackage(cfConfig, fs) {
329
331
  await (0, project_access_1.addPackageDevDependency)(cfConfig.appPath, constants_1.MbtPackage, constants_1.MbtPackageVersion, fs);
330
332
  }
331
333
  }
332
- /**
333
- * Update the root package.json with scripts to deploy the MTA.
334
- *
335
- * @param cfConfig writer configuration
336
- * @param fs reference to a mem-fs editor
337
- */
338
- async function updateRootPackage(cfConfig, fs) {
339
- const packageExists = fs.exists((0, path_1.join)(cfConfig.rootPath, project_access_1.FileName.Package));
340
- // Append mta scripts only if mta.yaml is at a different level to the HTML5 app
341
- if (cfConfig.isMtaRoot && packageExists) {
342
- await (0, project_access_1.addPackageDevDependency)(cfConfig.rootPath, constants_1.Rimraf, constants_1.RimrafVersion, fs);
343
- await (0, project_access_1.addPackageDevDependency)(cfConfig.rootPath, constants_1.MbtPackage, constants_1.MbtPackageVersion, fs);
344
- let deployArgs = [];
345
- if (fs.exists((0, path_1.join)(cfConfig.rootPath, constants_1.MTAFileExtension))) {
346
- deployArgs = ['-e', constants_1.MTAFileExtension];
347
- }
348
- for (const script of [
349
- { name: 'undeploy', run: (0, constants_1.undeployMTAScript)(cfConfig.mtaId ?? cfConfig.appId) },
350
- { name: 'build', run: `${constants_1.MTABuildScript} --mtar archive` },
351
- { name: 'deploy', run: (0, constants_1.rootDeployMTAScript)(deployArgs) }
352
- ]) {
353
- await (0, project_access_1.updatePackageScript)(cfConfig.rootPath, script.name, script.run, fs);
354
- }
355
- }
356
- }
357
334
  /**
358
335
  * Generate UI5 deploy config.
359
336
  *
@@ -32,8 +32,7 @@ async function generateCAPConfig(config, fs, logger) {
32
32
  const cdsOptionalParams = [constants_1.CDSXSUAAService, constants_1.CDSDestinationService, constants_1.CDSHTML5RepoService];
33
33
  (0, mta_config_1.createCAPMTA)(config.mtaPath, cdsOptionalParams);
34
34
  await (0, utils_1.addRoutingConfig)(config, fs);
35
- (0, utils_1.addSupportingConfig)(config, fs);
36
- logger_helper_1.default.logger?.debug(`CF CAP Config ${JSON.stringify(config, null, 2)}`);
35
+ await (0, utils_1.updateRootPackage)({ mtaId: config.mtaId, rootPath: config.mtaPath }, fs);
37
36
  return fs;
38
37
  }
39
38
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './mta-config';
2
2
  export * from './cf-writer';
3
3
  export { DefaultMTADestination } from './constants';
4
- export { CFBaseConfig, CFAppConfig, RouterModuleType, ApiHubConfig, ApiHubType } from './types';
4
+ export { CFBaseConfig, CFAppConfig, CAPConfig, RouterModuleType, ApiHubConfig, ApiHubType } from './types';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -155,6 +155,7 @@ function createCAPMTA(cwd, options) {
155
155
  if (result?.error) {
156
156
  throw new Error(`Something went wrong installing node modules! ${result.error}`);
157
157
  }
158
+ logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.capMtaCreated'));
158
159
  }
159
160
  /**
160
161
  * Validate the writer configuration to ensure all required parameters are present.
@@ -3,12 +3,13 @@
3
3
  "logError": "{{method}} error found {{ error }}",
4
4
  "mtaLoaded": "MTA {{ type }} loaded",
5
5
  "ui5YamlDoesNotExist": "File ui5.yaml does not exist in the project",
6
+ "capMtaCreated": "CAP MTA Configuration created",
6
7
  "mtaCreated": "MTA Configuration created {{mtaPath}}.",
7
8
  "mtaSaved": "MTA Configuration has been saved.",
8
9
  "mtaSavedFailed": "MTA saved failed with error {{- error }}"
9
10
  },
10
11
  "error": {
11
- "unableToLoadMTA": "Unable to load mta.yaml configuration {{ mtaDir }}, error thrown {{ error }}.",
12
+ "unableToLoadMTA": "Unable to load mta.yaml configuration {{- mtaDir }}, error thrown {{- error }}.",
12
13
  "updatingMTAExtensionFailed": "Unable to add mta extension configuration to file: {{mtaExtFilePath}}.",
13
14
  "cannotFindBinary": "Cannot find the \"{{bin}}\" executable. Please add it to the path or use \"npm i -g {{- pkg}}\" to install it.",
14
15
  "mtaExtensionFailed": "Unable to create or update the mta extension file for Api Hub Enterprise destination configuration: {{error}}.",
@@ -10,10 +10,11 @@ export type MTADestinationType = Destination & {
10
10
  ServiceKeyName: string;
11
11
  'sap.cloud.service': string;
12
12
  };
13
- export declare enum RouterModuleType {
14
- Standard = "standard",
15
- Managed = "managed"
16
- }
13
+ export declare const RouterModuleType: {
14
+ readonly Standard: "standard";
15
+ readonly Managed: "managed";
16
+ };
17
+ export type RouterModuleType = (typeof RouterModuleType)[keyof typeof RouterModuleType];
17
18
  export interface MTABaseConfig {
18
19
  mtaId: string;
19
20
  mtaPath: string;
@@ -6,9 +6,8 @@ var CloudFoundryServiceType;
6
6
  CloudFoundryServiceType["Existing"] = "org.cloudfoundry.existing-service";
7
7
  CloudFoundryServiceType["Managed"] = "org.cloudfoundry.managed-service";
8
8
  })(CloudFoundryServiceType || (exports.CloudFoundryServiceType = CloudFoundryServiceType = {}));
9
- var RouterModuleType;
10
- (function (RouterModuleType) {
11
- RouterModuleType["Standard"] = "standard";
12
- RouterModuleType["Managed"] = "managed";
13
- })(RouterModuleType || (exports.RouterModuleType = RouterModuleType = {}));
9
+ exports.RouterModuleType = {
10
+ Standard: 'standard',
11
+ Managed: 'managed'
12
+ };
14
13
  //# sourceMappingURL=index.js.map
package/dist/utils.d.ts CHANGED
@@ -114,4 +114,16 @@ export declare function addRoutingConfig(config: CFBaseConfig, fs: Editor): Prom
114
114
  * @param config writer configuration
115
115
  */
116
116
  export declare function setMtaDefaults(config: CFBaseConfig): void;
117
+ /**
118
+ * Update the root package.json with scripts to deploy the MTA.
119
+ *
120
+ * @param {object} Options
121
+ * @param {string} Options.mtaId - MTA ID to be written to package.json
122
+ * @param {string} Options.rootPath - MTA project path
123
+ * @param fs
124
+ */
125
+ export declare function updateRootPackage({ mtaId, rootPath }: {
126
+ mtaId: string;
127
+ rootPath: string;
128
+ }, fs: Editor): Promise<void>;
117
129
  //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js CHANGED
@@ -18,6 +18,7 @@ exports.generateSupportingConfig = generateSupportingConfig;
18
18
  exports.addSupportingConfig = addSupportingConfig;
19
19
  exports.addRoutingConfig = addRoutingConfig;
20
20
  exports.setMtaDefaults = setMtaDefaults;
21
+ exports.updateRootPackage = updateRootPackage;
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");
@@ -248,4 +249,31 @@ function setMtaDefaults(config) {
248
249
  config.addConnectivityService ||= false;
249
250
  config.mtaId = toMtaModuleName(config.mtaId);
250
251
  }
252
+ /**
253
+ * Update the root package.json with scripts to deploy the MTA.
254
+ *
255
+ * @param {object} Options
256
+ * @param {string} Options.mtaId - MTA ID to be written to package.json
257
+ * @param {string} Options.rootPath - MTA project path
258
+ * @param fs
259
+ */
260
+ async function updateRootPackage({ mtaId, rootPath }, fs) {
261
+ const packageExists = fs.exists((0, path_1.join)(rootPath, project_access_1.FileName.Package));
262
+ // Append mta scripts only if mta.yaml is at a different level to the HTML5 app
263
+ if (packageExists) {
264
+ await (0, project_access_1.addPackageDevDependency)(rootPath, constants_1.Rimraf, constants_1.RimrafVersion, fs);
265
+ await (0, project_access_1.addPackageDevDependency)(rootPath, constants_1.MbtPackage, constants_1.MbtPackageVersion, fs);
266
+ let deployArgs = [];
267
+ if (fs.exists((0, path_1.join)(rootPath, constants_1.MTAFileExtension))) {
268
+ deployArgs = ['-e', constants_1.MTAFileExtension];
269
+ }
270
+ for (const script of [
271
+ { name: 'undeploy', run: (0, constants_1.undeployMTAScript)(mtaId) },
272
+ { name: 'build', run: `${constants_1.MTABuildScript} --mtar archive` },
273
+ { name: 'deploy', run: (0, constants_1.rootDeployMTAScript)(deployArgs) }
274
+ ]) {
275
+ await (0, project_access_1.updatePackageScript)(rootPath, script.name, script.run, fs);
276
+ }
277
+ }
278
+ }
251
279
  //# 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.1.10",
4
+ "version": "0.1.12",
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.7",
32
+ "@sap-ux/project-access": "1.29.8",
33
33
  "@sap-ux/yaml": "0.16.0",
34
34
  "@sap-ux/btp-utils": "1.0.1",
35
- "@sap-ux/ui5-config": "0.26.2",
36
- "@sap-ux/logger": "0.6.0"
35
+ "@sap-ux/logger": "0.6.0",
36
+ "@sap-ux/ui5-config": "0.26.2"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/ejs": "3.1.2",