@sap-ux/project-access 1.16.1 → 1.16.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.
@@ -1,4 +1,5 @@
1
1
  import type { CapCustomPaths, CapProjectType, CdsEnvironment, csn, Package, ServiceDefinitions } from '../types';
2
+ import type { Logger } from '@sap-ux/logger';
2
3
  interface ServiceInfo {
3
4
  name: string;
4
5
  urlPath: string;
@@ -34,12 +35,15 @@ export declare function getCapProjectType(projectRoot: string): Promise<CapProje
34
35
  */
35
36
  export declare function getCapCustomPaths(capProjectPath: string): Promise<CapCustomPaths>;
36
37
  /**
37
- * Return the CAP model and all services.
38
+ * Return the CAP model and all services. The cds.root will be set to the provided project root path.
38
39
  *
39
- * @param projectRoot - CAP project root where package.json resides
40
+ * @param projectRoot - CAP project root where package.json resides or object specifying project root and optional logger to log additonal info
40
41
  * @returns {*} {Promise<{ model: csn; services: ServiceInfo[] }>} - CAP Model and Services
41
42
  */
42
- export declare function getCapModelAndServices(projectRoot: string): Promise<{
43
+ export declare function getCapModelAndServices(projectRoot: string | {
44
+ projectRoot: string;
45
+ logger?: Logger;
46
+ }): Promise<{
43
47
  model: csn;
44
48
  services: ServiceInfo[];
45
49
  }>;
@@ -99,23 +99,35 @@ function getCapCustomPaths(capProjectPath) {
99
99
  }
100
100
  exports.getCapCustomPaths = getCapCustomPaths;
101
101
  /**
102
- * Return the CAP model and all services.
102
+ * Return the CAP model and all services. The cds.root will be set to the provided project root path.
103
103
  *
104
- * @param projectRoot - CAP project root where package.json resides
104
+ * @param projectRoot - CAP project root where package.json resides or object specifying project root and optional logger to log additonal info
105
105
  * @returns {*} {Promise<{ model: csn; services: ServiceInfo[] }>} - CAP Model and Services
106
106
  */
107
107
  function getCapModelAndServices(projectRoot) {
108
108
  var _a;
109
109
  return __awaiter(this, void 0, void 0, function* () {
110
- const cds = yield loadCdsModuleFromProject(projectRoot);
111
- const capProjectPaths = yield getCapCustomPaths(projectRoot);
110
+ let _projectRoot;
111
+ let _logger;
112
+ if (typeof projectRoot === 'object') {
113
+ _projectRoot = projectRoot.projectRoot;
114
+ _logger = projectRoot.logger;
115
+ }
116
+ else {
117
+ _projectRoot = projectRoot;
118
+ }
119
+ const cds = yield loadCdsModuleFromProject(_projectRoot);
120
+ _logger === null || _logger === void 0 ? void 0 : _logger.info(`@sap-ux/project-access:getCapModelAndServices - Using 'cds.home': ${cds.home}`);
121
+ _logger === null || _logger === void 0 ? void 0 : _logger.info(`@sap-ux/project-access:getCapModelAndServices - Using 'cds.version': ${cds.version}`);
122
+ _logger === null || _logger === void 0 ? void 0 : _logger.info(`@sap-ux/project-access:getCapModelAndServices - Using 'cds.root': ${cds.root}`);
123
+ const capProjectPaths = yield getCapCustomPaths(_projectRoot);
112
124
  const modelPaths = [
113
- (0, path_1.join)(projectRoot, capProjectPaths.app),
114
- (0, path_1.join)(projectRoot, capProjectPaths.srv),
115
- (0, path_1.join)(projectRoot, capProjectPaths.db)
125
+ (0, path_1.join)(_projectRoot, capProjectPaths.app),
126
+ (0, path_1.join)(_projectRoot, capProjectPaths.srv),
127
+ (0, path_1.join)(_projectRoot, capProjectPaths.db)
116
128
  ];
117
129
  const model = yield cds.load(modelPaths);
118
- let services = (_a = cds.compile.to.serviceinfo(model, { root: projectRoot })) !== null && _a !== void 0 ? _a : [];
130
+ let services = (_a = cds.compile.to.serviceinfo(model, { root: _projectRoot })) !== null && _a !== void 0 ? _a : [];
119
131
  if (services.map) {
120
132
  services = services.map((value) => {
121
133
  return {
@@ -359,6 +371,8 @@ function loadCdsModuleFromProject(capProjectPath) {
359
371
  if (global) {
360
372
  global.cds = cds;
361
373
  }
374
+ // Ensure we use a known root path, otherwise `cwd` is used which varies between invocations.
375
+ cds.root = capProjectPath;
362
376
  return cds;
363
377
  });
364
378
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.16.1",
3
+ "version": "1.16.2",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,8 @@
33
33
  "@types/mem-fs": "1.1.2",
34
34
  "@types/mem-fs-editor": "7.0.1",
35
35
  "@ui5/manifest": "1.61.0",
36
- "vscode-uri": "3.0.7"
36
+ "vscode-uri": "3.0.7",
37
+ "@sap-ux/logger": "0.4.0"
37
38
  },
38
39
  "scripts": {
39
40
  "build": "tsc --build",