@sap-ux/project-access 1.25.4 → 1.25.6

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.
@@ -116,7 +116,7 @@ export declare const toAbsoluteUri: (projectRoot: string, relativeUri: string) =
116
116
  */
117
117
  export declare const toReferenceUri: (projectRoot: string, relativeUriFrom: string, relativeUriTo: string) => Promise<string>;
118
118
  /**
119
- * Clear cache of path to global cds module.
119
+ * Clear cache of request to load global cds module.
120
120
  */
121
- export declare function clearGlobalCdsPathCache(): void;
121
+ export declare function clearGlobalCdsModulePromiseCache(): void;
122
122
  //# sourceMappingURL=cap.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clearGlobalCdsPathCache = exports.toReferenceUri = exports.toAbsoluteUri = exports.clearCdsModuleCache = exports.getCapEnvironment = exports.readCapServiceMetadataEdmx = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapModelAndServices = exports.getCapCustomPaths = exports.isCapProject = exports.getCapProjectType = exports.isCapJavaProject = exports.isCapNodeJsProject = void 0;
3
+ exports.clearGlobalCdsModulePromiseCache = exports.toReferenceUri = exports.toAbsoluteUri = exports.clearCdsModuleCache = exports.getCapEnvironment = exports.readCapServiceMetadataEdmx = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapModelAndServices = exports.getCapCustomPaths = exports.isCapProject = exports.getCapProjectType = exports.isCapJavaProject = exports.isCapNodeJsProject = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const path_1 = require("path");
6
6
  const constants_1 = require("../constants");
@@ -493,29 +493,35 @@ async function readPackageNameForFolder(baseUri, relativeUri) {
493
493
  }
494
494
  return packageName;
495
495
  }
496
- let globalCdsPathCache;
496
+ // Cache for request to load global cds. Cache the promise to avoid starting multiple identical requests in parallel.
497
+ let globalCdsModulePromise;
497
498
  /**
498
499
  * Try to load global installation of @sap/cds, usually child of @sap/cds-dk.
499
500
  *
500
501
  * @returns - module @sap/cds from global installed @sap/cds-dk
501
502
  */
502
503
  async function loadGlobalCdsModule() {
503
- if (!globalCdsPathCache) {
504
- const versions = await getCdsVersionInfo();
505
- if (!versions.home) {
506
- throw Error('Can not find global installation of module @sap/cds, which should be part of @sap/cds-dk');
507
- }
508
- globalCdsPathCache = versions.home;
509
- }
510
- return (0, module_loader_1.loadModuleFromProject)(globalCdsPathCache, '@sap/cds');
504
+ globalCdsModulePromise =
505
+ globalCdsModulePromise ??
506
+ new Promise((resolve, reject) => {
507
+ return getCdsVersionInfo().then((versions) => {
508
+ if (versions.home) {
509
+ resolve((0, module_loader_1.loadModuleFromProject)(versions.home, '@sap/cds'));
510
+ }
511
+ else {
512
+ reject(new Error('Can not find global installation of module @sap/cds, which should be part of @sap/cds-dk'));
513
+ }
514
+ }, reject);
515
+ });
516
+ return globalCdsModulePromise;
511
517
  }
512
518
  /**
513
- * Clear cache of path to global cds module.
519
+ * Clear cache of request to load global cds module.
514
520
  */
515
- function clearGlobalCdsPathCache() {
516
- globalCdsPathCache = '';
521
+ function clearGlobalCdsModulePromiseCache() {
522
+ globalCdsModulePromise = undefined;
517
523
  }
518
- exports.clearGlobalCdsPathCache = clearGlobalCdsPathCache;
524
+ exports.clearGlobalCdsModulePromiseCache = clearGlobalCdsModulePromiseCache;
519
525
  /**
520
526
  * Get cds information, which includes versions and also the home path of cds module.
521
527
  *
@@ -81,11 +81,13 @@ exports.loadModuleFromProject = loadModuleFromProject;
81
81
  async function getModule(module, version, options) {
82
82
  const logger = options?.logger;
83
83
  const moduleDirectory = (0, path_1.join)(constants_1.moduleCacheRoot, module, version);
84
- if (!(0, fs_1.existsSync)((0, path_1.join)(moduleDirectory, constants_1.FileName.Package))) {
84
+ const modulePackagePath = (0, path_1.join)(moduleDirectory, constants_1.FileName.Package);
85
+ if (!(0, fs_1.existsSync)(modulePackagePath)) {
85
86
  if ((0, fs_1.existsSync)(moduleDirectory)) {
86
87
  await (0, promises_1.rm)(moduleDirectory, { recursive: true });
87
88
  }
88
89
  await (0, promises_1.mkdir)(moduleDirectory, { recursive: true });
90
+ await (0, promises_1.writeFile)(modulePackagePath, '{}');
89
91
  await (0, command_1.execNpmCommand)(['install', `${module}@${version}`], { cwd: moduleDirectory, logger });
90
92
  }
91
93
  return loadModuleFromProject(moduleDirectory, module);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.25.4",
3
+ "version": "1.25.6",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",