@sap-ux/project-access 1.35.1 → 1.35.2

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.
Files changed (2) hide show
  1. package/dist/project/cap.js +17 -13
  2. package/package.json +1 -1
@@ -567,9 +567,12 @@ async function loadGlobalCdsModule() {
567
567
  globalCdsModulePromise =
568
568
  globalCdsModulePromise ??
569
569
  new Promise((resolve, reject) => {
570
- return getCdsVersionInfo().then((versions) => {
571
- if (versions.home) {
572
- resolve((0, module_loader_1.loadModuleFromProject)(versions.home, '@sap/cds'));
570
+ return getCdsEnvData().then((data) => {
571
+ // Handle output of `cds env --json`
572
+ const home = data['_home_cds-dk'];
573
+ if (home) {
574
+ // "@sap/cds" module is inside node_modules of "@sap/cds-dk"
575
+ resolve((0, module_loader_1.loadModuleFromProject)((0, node_path_1.join)(home, 'node_modules', '@sap', 'cds'), '@sap/cds'));
573
576
  }
574
577
  else {
575
578
  reject(new Error('Can not find global installation of module @sap/cds, which should be part of @sap/cds-dk'));
@@ -585,26 +588,27 @@ function clearGlobalCdsModulePromiseCache() {
585
588
  globalCdsModulePromise = undefined;
586
589
  }
587
590
  /**
588
- * Get cds information, which includes versions and also the home path of cds module.
591
+ * Get cds environment information, which includes the home path of cds-dk module.
589
592
  *
590
- * @param [cwd] - optional folder in which cds --version should be executed
591
- * @returns - result of call 'cds --version'
593
+ * @param [cwd] - optional folder in which cds env --json should be executed
594
+ * @returns - result of call 'cds env --json'
592
595
  */
593
- async function getCdsVersionInfo(cwd) {
596
+ async function getCdsEnvData(cwd) {
594
597
  return new Promise((resolve, reject) => {
595
598
  let out = '';
596
- const cdsVersionInfo = (0, node_child_process_1.spawn)('cds', ['--version'], { cwd, shell: true });
599
+ // call 'cds env --json'
600
+ const cdsVersionInfo = (0, node_child_process_1.spawn)('cds', ['env', '--json'], { cwd, shell: true });
597
601
  cdsVersionInfo.stdout.on('data', (data) => {
598
602
  out += data.toString();
599
603
  });
600
604
  cdsVersionInfo.on('close', () => {
601
605
  if (out) {
602
- const versions = {};
603
- for (const line of out.split('\n').filter((v) => v)) {
604
- const [key, value] = line.split(': ');
605
- versions[key] = value;
606
+ try {
607
+ resolve(JSON.parse(out));
608
+ }
609
+ catch (e) {
610
+ reject(new Error(`Unexpected output of "cds env --json": ${e.message}`));
606
611
  }
607
- resolve(versions);
608
612
  }
609
613
  else {
610
614
  reject(new Error('Module path not found'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.35.1",
3
+ "version": "1.35.2",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",