@sap-ux/project-access 1.1.1 → 1.2.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.
@@ -1,6 +1,7 @@
1
1
  export declare const FileName: {
2
2
  readonly Manifest: "manifest.json";
3
3
  readonly Package: "package.json";
4
+ readonly Tsconfig: "tsconfig.json";
4
5
  readonly Ui5Yaml: "ui5.yaml";
5
6
  readonly Ui5LocalYaml: "ui5-local.yaml";
6
7
  readonly Ui5MockYaml: "ui5-mock.yaml";
package/dist/constants.js CHANGED
@@ -4,6 +4,7 @@ exports.FileName = void 0;
4
4
  exports.FileName = {
5
5
  Manifest: 'manifest.json',
6
6
  Package: 'package.json',
7
+ Tsconfig: 'tsconfig.json',
7
8
  Ui5Yaml: 'ui5.yaml',
8
9
  Ui5LocalYaml: 'ui5-local.yaml',
9
10
  Ui5MockYaml: 'ui5-mock.yaml'
@@ -5,10 +5,20 @@ import type { Editor } from 'mem-fs-editor';
5
5
  * @param filename - filename to search
6
6
  * @param root - root folder to start search
7
7
  * @param excludeFolders - list of folder names to exclude (search doesn't traverse into these folders)
8
- * @param fs - optional mem-fs-editor instance
8
+ * @param [memFs] - optional mem-fs-editor instance
9
9
  * @returns - array of paths that contain the filename
10
10
  */
11
- export declare function findFiles(filename: string, root: string, excludeFolders: string[], fs?: Editor): Promise<string[]>;
11
+ export declare function findFiles(filename: string, root: string, excludeFolders: string[], memFs?: Editor): Promise<string[]>;
12
+ /**
13
+ * Search for 'filename' starting from 'root'. Returns array of paths that contain the file.
14
+ *
15
+ * @param extension - file extension to search for including '.', e.g. '.ts'
16
+ * @param root - root folder to start search
17
+ * @param excludeFolders - list of folder names to exclude (search doesn't traverse into these folders)
18
+ * @param [memFs] - optional mem-fs-editor instance
19
+ * @returns - array of file paths that have the extension
20
+ */
21
+ export declare function findFilesByExtension(extension: string, root: string, excludeFolders: string[], memFs?: Editor): Promise<string[]>;
12
22
  /**
13
23
  * Find a file by name in parent folders starting from 'startPath'.
14
24
  *
@@ -12,76 +12,102 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.findFileUp = exports.findFiles = void 0;
15
+ exports.findFileUp = exports.findFilesByExtension = exports.findFiles = void 0;
16
16
  const path_1 = require("path");
17
17
  const findit2_1 = __importDefault(require("findit2"));
18
18
  const file_access_1 = require("./file-access");
19
19
  /**
20
- * Creates a filter function that removes files that have been deleted in an instance of a mem-fs-editor.
20
+ * Get deleted and modified files from mem-fs editor filtered by query and 'by' (name|extension).
21
21
  *
22
- * @param changes - changes recorded in an instance of a mem-fs-editor
23
- * @param filename - relevant filename
24
- * @returns a filter function for string arrays
22
+ * @param changes - memfs editor changes, usually retrieved by fs.dump()
23
+ * @param query - search string, file name or file extension
24
+ * @param by - search by file 'name' or file 'extension'
25
+ * @returns - array of deleted and modified files filtered by query
25
26
  */
26
- function getMemFsFilter(changes, filename) {
27
- const deleted = Object.entries(changes)
28
- .filter(([, info]) => info.state === 'deleted')
29
- .map(([file]) => path_1.join(path_1.basename(path_1.join(file)) === filename ? path_1.dirname(file) : file));
30
- return (path) => !deleted.find((entry) => path.startsWith(entry));
31
- }
32
- /**
33
- * Concatanates the given list of files with additional files that have been created using a mem-fs-editor and matching the filename.
34
- *
35
- * @param folders - existing list of folders
36
- * @param changes - changes recorded in an instance of a mem-fs-editor
37
- * @param filename - relevant filename
38
- * @returns Concatanated and deduped list of folders containing the given filename
39
- */
40
- function concatNewFoldersFromMemFs(folders, changes, filename) {
41
- const modified = Object.entries(changes)
42
- .filter(([file, info]) => info.state === 'modified' && path_1.basename(path_1.join(file)) === filename)
43
- .map(([file]) => path_1.dirname(path_1.join(file)));
44
- return [...new Set([...folders, ...modified])];
27
+ function getMemFsChanges(changes, query, by) {
28
+ const deleted = [];
29
+ const modified = [];
30
+ const getFilePartToCompare = by === 'extension' ? path_1.extname : path_1.basename;
31
+ for (const file of Object.keys(changes).filter((f) => getFilePartToCompare(f) === query)) {
32
+ if (changes[file].state === 'deleted') {
33
+ deleted.push((0, path_1.join)(file));
34
+ }
35
+ if (changes[file].state === 'modified') {
36
+ modified.push((0, path_1.join)(file));
37
+ }
38
+ }
39
+ return { deleted, modified };
45
40
  }
46
41
  /**
47
- * Search for 'filename' starting from 'root'. Returns array of paths that contain the file.
42
+ * Find function to search for files.
48
43
  *
49
- * @param filename - filename to search
50
- * @param root - root folder to start search
51
- * @param excludeFolders - list of folder names to exclude (search doesn't traverse into these folders)
52
- * @param fs - optional mem-fs-editor instance
53
- * @returns - array of paths that contain the filename
44
+ * @param options - find options
45
+ * @param options.query - search string
46
+ * @param options.by - search by file 'name' or file 'extension'
47
+ * @param options.root - folder to start recursive search
48
+ * @param options.excludeFolders - folder names to exclude
49
+ * @param [options.memFs] - optional memfs editor instance
50
+ * @returns - array of paths that contain the file if searched for name; array of full file paths in case of search by extension
54
51
  */
55
- function findFiles(filename, root, excludeFolders, fs) {
52
+ function findBy(options) {
53
+ const getFilePartToCompare = options.by === 'extension' ? path_1.extname : path_1.basename;
56
54
  return new Promise((resolve, reject) => {
57
55
  const results = [];
58
- const finder = findit2_1.default(root);
56
+ const finder = (0, findit2_1.default)(options.root);
59
57
  finder.on('directory', (dir, _stat, stop) => {
60
- const base = path_1.basename(dir);
61
- if (excludeFolders.includes(base)) {
58
+ const base = (0, path_1.basename)(dir);
59
+ if (options.excludeFolders.includes(base)) {
62
60
  stop();
63
61
  }
64
62
  });
65
63
  finder.on('file', (file) => {
66
- if (file.endsWith(path_1.sep + filename)) {
67
- results.push(path_1.dirname(file));
64
+ if (getFilePartToCompare(file) === options.query) {
65
+ results.push(file);
68
66
  }
69
67
  });
70
68
  finder.on('end', () => {
71
- if (fs) {
72
- const changes = fs.dump('');
73
- resolve(concatNewFoldersFromMemFs(results, changes, filename).filter(getMemFsFilter(changes, filename)));
69
+ let searchResult = results;
70
+ if (options.memFs) {
71
+ const { modified, deleted } = getMemFsChanges(options.memFs.dump(''), options.query, options.by);
72
+ const merged = Array.from(new Set([...results, ...modified]));
73
+ searchResult = merged.filter((f) => !deleted.includes(f));
74
74
  }
75
- else {
76
- resolve(results);
75
+ if (options.by === 'name') {
76
+ searchResult = searchResult.map((f) => (0, path_1.dirname)(f));
77
77
  }
78
+ resolve(searchResult);
78
79
  });
79
80
  finder.on('error', (error) => {
80
81
  reject(error);
81
82
  });
82
83
  });
83
84
  }
85
+ /**
86
+ * Search for 'filename' starting from 'root'. Returns array of paths that contain the file.
87
+ *
88
+ * @param filename - filename to search
89
+ * @param root - root folder to start search
90
+ * @param excludeFolders - list of folder names to exclude (search doesn't traverse into these folders)
91
+ * @param [memFs] - optional mem-fs-editor instance
92
+ * @returns - array of paths that contain the filename
93
+ */
94
+ function findFiles(filename, root, excludeFolders, memFs) {
95
+ return findBy({ query: filename, by: 'name', root, excludeFolders, memFs });
96
+ }
84
97
  exports.findFiles = findFiles;
98
+ /**
99
+ * Search for 'filename' starting from 'root'. Returns array of paths that contain the file.
100
+ *
101
+ * @param extension - file extension to search for including '.', e.g. '.ts'
102
+ * @param root - root folder to start search
103
+ * @param excludeFolders - list of folder names to exclude (search doesn't traverse into these folders)
104
+ * @param [memFs] - optional mem-fs-editor instance
105
+ * @returns - array of file paths that have the extension
106
+ */
107
+ function findFilesByExtension(extension, root, excludeFolders, memFs) {
108
+ return findBy({ query: extension, by: 'extension', root, excludeFolders, memFs });
109
+ }
110
+ exports.findFilesByExtension = findFilesByExtension;
85
111
  /**
86
112
  * Find a file by name in parent folders starting from 'startPath'.
87
113
  *
@@ -92,12 +118,12 @@ exports.findFiles = findFiles;
92
118
  */
93
119
  function findFileUp(fileName, startPath, fs) {
94
120
  return __awaiter(this, void 0, void 0, function* () {
95
- const filePath = path_1.join(startPath, fileName);
96
- if (yield file_access_1.fileExists(filePath, fs)) {
121
+ const filePath = (0, path_1.join)(startPath, fileName);
122
+ if (yield (0, file_access_1.fileExists)(filePath, fs)) {
97
123
  return filePath;
98
124
  }
99
125
  else {
100
- return path_1.dirname(startPath) !== startPath ? findFileUp(fileName, path_1.dirname(startPath), fs) : undefined;
126
+ return (0, path_1.dirname)(startPath) !== startPath ? findFileUp(fileName, (0, path_1.dirname)(startPath), fs) : undefined;
101
127
  }
102
128
  });
103
129
  }
@@ -1,3 +1,3 @@
1
1
  export { fileExists, readFile, readJSON } from './file-access';
2
- export { findFiles, findFileUp } from './file-search';
2
+ export { findFiles, findFilesByExtension, findFileUp } from './file-search';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findFileUp = exports.findFiles = exports.readJSON = exports.readFile = exports.fileExists = void 0;
3
+ exports.findFileUp = exports.findFilesByExtension = exports.findFiles = exports.readJSON = exports.readFile = exports.fileExists = void 0;
4
4
  var file_access_1 = require("./file-access");
5
5
  Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return file_access_1.fileExists; } });
6
6
  Object.defineProperty(exports, "readFile", { enumerable: true, get: function () { return file_access_1.readFile; } });
7
7
  Object.defineProperty(exports, "readJSON", { enumerable: true, get: function () { return file_access_1.readJSON; } });
8
8
  var file_search_1 = require("./file-search");
9
9
  Object.defineProperty(exports, "findFiles", { enumerable: true, get: function () { return file_search_1.findFiles; } });
10
+ Object.defineProperty(exports, "findFilesByExtension", { enumerable: true, get: function () { return file_search_1.findFilesByExtension; } });
10
11
  Object.defineProperty(exports, "findFileUp", { enumerable: true, get: function () { return file_search_1.findFileUp; } });
11
12
  //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { FileName } from './constants';
2
- export { findAllApps, findProjectRoot, getAppRootFromWebappPath, getCapModelAndServices, getCapProjectType, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject } from './project';
2
+ export { findAllApps, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getCapModelAndServices, getCapProjectType, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject } from './project';
3
3
  export * from './types';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,13 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getCapProjectType = exports.getCapModelAndServices = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findAllApps = exports.FileName = void 0;
17
+ exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getCapProjectType = exports.getCapModelAndServices = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findAllApps = exports.FileName = void 0;
14
18
  var constants_1 = require("./constants");
15
19
  Object.defineProperty(exports, "FileName", { enumerable: true, get: function () { return constants_1.FileName; } });
16
20
  var project_1 = require("./project");
17
21
  Object.defineProperty(exports, "findAllApps", { enumerable: true, get: function () { return project_1.findAllApps; } });
18
22
  Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return project_1.findProjectRoot; } });
19
23
  Object.defineProperty(exports, "getAppRootFromWebappPath", { enumerable: true, get: function () { return project_1.getAppRootFromWebappPath; } });
24
+ Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return project_1.getAppProgrammingLanguage; } });
20
25
  Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return project_1.getCapModelAndServices; } });
21
26
  Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: function () { return project_1.getCapProjectType; } });
22
27
  Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: function () { return project_1.getWebappPath; } });
@@ -34,7 +34,7 @@ exports.isCapNodeJsProject = isCapNodeJsProject;
34
34
  function isCapJavaProject(projectRoot) {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
36
  const { srv } = yield getCapCustomPaths(projectRoot);
37
- return file_1.fileExists(path_1.join(projectRoot, srv, 'src', 'main', 'resources', 'application.yaml'));
37
+ return (0, file_1.fileExists)((0, path_1.join)(projectRoot, srv, 'src', 'main', 'resources', 'application.yaml'));
38
38
  });
39
39
  }
40
40
  exports.isCapJavaProject = isCapJavaProject;
@@ -51,7 +51,7 @@ function getCapProjectType(projectRoot) {
51
51
  }
52
52
  let packageJson;
53
53
  try {
54
- packageJson = yield file_1.readJSON(path_1.join(projectRoot, constants_1.FileName.Package));
54
+ packageJson = yield (0, file_1.readJSON)((0, path_1.join)(projectRoot, constants_1.FileName.Package));
55
55
  }
56
56
  catch (_a) {
57
57
  // Ignore errors while reading the package.json file
@@ -77,7 +77,7 @@ function getCapCustomPaths(capProjectPath) {
77
77
  srv: 'srv/'
78
78
  };
79
79
  try {
80
- const cds = yield module_loader_1.loadModuleFromProject(capProjectPath, '@sap/cds');
80
+ const cds = yield (0, module_loader_1.loadModuleFromProject)(capProjectPath, '@sap/cds');
81
81
  const cdsCustomPaths = cds.env.for('cds', capProjectPath);
82
82
  if (cdsCustomPaths.folders) {
83
83
  result.app = cdsCustomPaths.folders.app;
@@ -99,12 +99,12 @@ exports.getCapCustomPaths = getCapCustomPaths;
99
99
  */
100
100
  function getCapModelAndServices(projectRoot) {
101
101
  return __awaiter(this, void 0, void 0, function* () {
102
- const cds = yield module_loader_1.loadModuleFromProject(projectRoot, '@sap/cds');
102
+ const cds = yield (0, module_loader_1.loadModuleFromProject)(projectRoot, '@sap/cds');
103
103
  const capProjectPaths = yield getCapCustomPaths(projectRoot);
104
104
  const modelPaths = [
105
- path_1.join(projectRoot, capProjectPaths.app),
106
- path_1.join(projectRoot, capProjectPaths.srv),
107
- path_1.join(projectRoot, capProjectPaths.db)
105
+ (0, path_1.join)(projectRoot, capProjectPaths.app),
106
+ (0, path_1.join)(projectRoot, capProjectPaths.srv),
107
+ (0, path_1.join)(projectRoot, capProjectPaths.db)
108
108
  ];
109
109
  const model = yield cds.load(modelPaths);
110
110
  const services = cds.compile.to['serviceinfo'](model, { root: projectRoot });
@@ -1,4 +1,5 @@
1
1
  export { getCapModelAndServices, getCapProjectType, isCapJavaProject, isCapNodeJsProject } from './cap';
2
+ export { getAppProgrammingLanguage } from './info';
2
3
  export { loadModuleFromProject } from './module-loader';
3
4
  export { findAllApps, findProjectRoot, getAppRootFromWebappPath } from './search';
4
5
  export { getWebappPath } from './ui5-config';
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findAllApps = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCapProjectType = exports.getCapModelAndServices = void 0;
3
+ exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findAllApps = exports.loadModuleFromProject = exports.getAppProgrammingLanguage = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCapProjectType = exports.getCapModelAndServices = void 0;
4
4
  var cap_1 = require("./cap");
5
5
  Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return cap_1.getCapModelAndServices; } });
6
6
  Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: function () { return cap_1.getCapProjectType; } });
7
7
  Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return cap_1.isCapJavaProject; } });
8
8
  Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return cap_1.isCapNodeJsProject; } });
9
+ var info_1 = require("./info");
10
+ Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return info_1.getAppProgrammingLanguage; } });
9
11
  var module_loader_1 = require("./module-loader");
10
12
  Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get: function () { return module_loader_1.loadModuleFromProject; } });
11
13
  var search_1 = require("./search");
@@ -0,0 +1,11 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { AppProgrammingLanguage } from '../types';
3
+ /**
4
+ * Get the used programming language of an application.
5
+ *
6
+ * @param appRoot - root folder of the application
7
+ * @param [memFs] - optional mem-fs editor instance
8
+ * @returns - used language, JavaScript or TypeScript
9
+ */
10
+ export declare function getAppProgrammingLanguage(appRoot: string, memFs?: Editor): Promise<AppProgrammingLanguage>;
11
+ //# sourceMappingURL=info.d.ts.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getAppProgrammingLanguage = void 0;
13
+ const path_1 = require("path");
14
+ const constants_1 = require("../constants");
15
+ const file_1 = require("../file");
16
+ const ui5_config_1 = require("./ui5-config");
17
+ /**
18
+ * Get the used programming language of an application.
19
+ *
20
+ * @param appRoot - root folder of the application
21
+ * @param [memFs] - optional mem-fs editor instance
22
+ * @returns - used language, JavaScript or TypeScript
23
+ */
24
+ function getAppProgrammingLanguage(appRoot, memFs) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const ignoreFolders = ['node_modules', '.git'];
27
+ let appLanguage = '';
28
+ try {
29
+ const webappPath = yield (0, ui5_config_1.getWebappPath)(appRoot, memFs);
30
+ if (yield (0, file_1.fileExists)(webappPath, memFs)) {
31
+ if ((yield (0, file_1.fileExists)((0, path_1.join)(appRoot, constants_1.FileName.Tsconfig), memFs)) &&
32
+ (yield (0, file_1.findFilesByExtension)('.ts', webappPath, ignoreFolders, memFs)).length > 0) {
33
+ appLanguage = 'TypeScript';
34
+ }
35
+ else if ((yield (0, file_1.findFilesByExtension)('.js', webappPath, ignoreFolders, memFs)).length > 0) {
36
+ appLanguage = 'JavaScript';
37
+ }
38
+ }
39
+ }
40
+ catch (_a) {
41
+ // could not detect app language
42
+ }
43
+ return appLanguage;
44
+ });
45
+ }
46
+ exports.getAppProgrammingLanguage = getAppProgrammingLanguage;
47
+ //# sourceMappingURL=info.js.map
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -38,10 +42,11 @@ exports.loadModuleFromProject = void 0;
38
42
  */
39
43
  function loadModuleFromProject(projectRoot, moduleName) {
40
44
  return __awaiter(this, void 0, void 0, function* () {
45
+ var _a;
41
46
  let module;
42
47
  try {
43
48
  const modulePath = require.resolve(moduleName, { paths: [projectRoot] });
44
- module = (yield Promise.resolve().then(() => __importStar(require(modulePath))));
49
+ module = (yield (_a = modulePath, Promise.resolve().then(() => __importStar(require(_a)))));
45
50
  }
46
51
  catch (error) {
47
52
  throw Error(`Module '${moduleName}' not installed in project '${projectRoot}'`);
@@ -51,7 +51,7 @@ function findAllManifest(wsFolders) {
51
51
  const manifests = [];
52
52
  for (const root of wsRoots) {
53
53
  try {
54
- manifests.push(...(yield file_1.findFiles(constants_1.FileName.Manifest, root, ['.git', 'node_modules', 'dist'])));
54
+ manifests.push(...(yield (0, file_1.findFiles)(constants_1.FileName.Manifest, root, ['.git', 'node_modules', 'dist'])));
55
55
  }
56
56
  catch (_a) {
57
57
  // ignore exceptions during find
@@ -69,18 +69,18 @@ function findAllManifest(wsFolders) {
69
69
  */
70
70
  function findProjectRoot(path, sapuxRequired = true, silent = false) {
71
71
  return __awaiter(this, void 0, void 0, function* () {
72
- const packageJson = yield file_1.findFileUp(constants_1.FileName.Package, path);
72
+ const packageJson = yield (0, file_1.findFileUp)(constants_1.FileName.Package, path);
73
73
  if (!packageJson) {
74
74
  if (silent) {
75
75
  return '';
76
76
  }
77
77
  throw new Error(`Could not find any project root for '${path}'. Search was done for ${sapuxRequired ? 'Fiori elements' : 'All'} projects.`);
78
78
  }
79
- let root = path_1.dirname(packageJson);
79
+ let root = (0, path_1.dirname)(packageJson);
80
80
  if (sapuxRequired) {
81
- const sapux = (yield file_1.readJSON(packageJson)).sapux;
81
+ const sapux = (yield (0, file_1.readJSON)(packageJson)).sapux;
82
82
  if (!sapux) {
83
- root = yield findProjectRoot(path_1.dirname(root), sapuxRequired);
83
+ root = yield findProjectRoot((0, path_1.dirname)(root), sapuxRequired, silent);
84
84
  }
85
85
  }
86
86
  return root;
@@ -107,11 +107,11 @@ function findRootsWithSapux(sapux, path, root) {
107
107
  // Backward compatibility for FE apps in CAP projects that have no app package.json,
108
108
  // but are listed in CAP root sapux array
109
109
  const pathWithSep = path.endsWith(path_1.sep) ? path : path + path_1.sep;
110
- const relAppPaths = sapux.map((a) => path_1.join(...a.split(/[\\/]/)));
111
- const relApp = relAppPaths.find((app) => pathWithSep.startsWith(path_1.join(root, app) + path_1.sep));
110
+ const relAppPaths = sapux.map((a) => (0, path_1.join)(...a.split(/[\\/]/)));
111
+ const relApp = relAppPaths.find((app) => pathWithSep.startsWith((0, path_1.join)(root, app) + path_1.sep));
112
112
  if (relApp) {
113
113
  return {
114
- appRoot: path_1.join(root, relApp),
114
+ appRoot: (0, path_1.join)(root, relApp),
115
115
  projectRoot: root
116
116
  };
117
117
  }
@@ -127,11 +127,11 @@ function findRootsWithSapux(sapux, path, root) {
127
127
  */
128
128
  function getAppRootFromWebappPath(webappPath) {
129
129
  return __awaiter(this, void 0, void 0, function* () {
130
- const ui5YamlPath = yield file_1.findFileUp(constants_1.FileName.Ui5Yaml, webappPath);
131
- let appRoot = path_1.dirname(webappPath);
130
+ const ui5YamlPath = yield (0, file_1.findFileUp)(constants_1.FileName.Ui5Yaml, webappPath);
131
+ let appRoot = (0, path_1.dirname)(webappPath);
132
132
  if (ui5YamlPath) {
133
- const candidate = path_1.dirname(ui5YamlPath);
134
- const webapp = yield ui5_config_1.getWebappPath(candidate);
133
+ const candidate = (0, path_1.dirname)(ui5YamlPath);
134
+ const webapp = yield (0, ui5_config_1.getWebappPath)(candidate);
135
135
  if (webapp === webappPath) {
136
136
  appRoot = candidate;
137
137
  }
@@ -163,19 +163,19 @@ function findRootsForPath(path) {
163
163
  if (!appRoot) {
164
164
  return null;
165
165
  }
166
- const appPckJson = yield file_1.readJSON(path_1.join(appRoot, constants_1.FileName.Package));
166
+ const appPckJson = yield (0, file_1.readJSON)((0, path_1.join)(appRoot, constants_1.FileName.Package));
167
167
  // Check for most common app, Fiori elements with sapux=true in package.json
168
168
  if (appPckJson.sapux) {
169
169
  return findRootsWithSapux(appPckJson.sapux, path, appRoot);
170
170
  }
171
- if (cap_1.isCapNodeJsProject(appPckJson) || (yield cap_1.isCapJavaProject(appRoot))) {
171
+ if ((0, cap_1.isCapNodeJsProject)(appPckJson) || (yield (0, cap_1.isCapJavaProject)(appRoot))) {
172
172
  // App is part of a CAP project, but doesn't have own package.json and is not mentioned in sapux array
173
173
  // in root -> not supported
174
174
  return null;
175
175
  }
176
176
  // Now we have the app root folder. Check for freestyle non CAP
177
- if ((yield file_1.fileExists(path_1.join(appRoot, constants_1.FileName.Ui5LocalYaml))) &&
178
- dependencies_1.hasDependency(appPckJson, '@sap/ux-ui5-tooling')) {
177
+ if ((yield (0, file_1.fileExists)((0, path_1.join)(appRoot, constants_1.FileName.Ui5LocalYaml))) &&
178
+ (0, dependencies_1.hasDependency)(appPckJson, '@sap/ux-ui5-tooling')) {
179
179
  return {
180
180
  appRoot,
181
181
  projectRoot: appRoot
@@ -183,20 +183,20 @@ function findRootsForPath(path) {
183
183
  }
184
184
  // Project must be CAP, find project root
185
185
  try {
186
- const { root } = path_1.parse(appRoot);
187
- let projectRoot = path_1.dirname(appRoot);
186
+ const { root } = (0, path_1.parse)(appRoot);
187
+ let projectRoot = (0, path_1.dirname)(appRoot);
188
188
  while (projectRoot !== root) {
189
- if (yield cap_1.getCapProjectType(projectRoot)) {
189
+ if (yield (0, cap_1.getCapProjectType)(projectRoot)) {
190
190
  // We have found a CAP project as root. Check if the found app is not directly in CAP's 'app/' folder.
191
191
  // Sometime there is a <CAP_ROOT>/app/package.json file that is used for app router (not an app)
192
- if (path_1.join(projectRoot, 'app') !== appRoot) {
192
+ if ((0, path_1.join)(projectRoot, 'app') !== appRoot) {
193
193
  return {
194
194
  appRoot,
195
195
  projectRoot
196
196
  };
197
197
  }
198
198
  }
199
- projectRoot = path_1.dirname(projectRoot);
199
+ projectRoot = (0, path_1.dirname)(projectRoot);
200
200
  }
201
201
  }
202
202
  catch (_a) {
@@ -222,7 +222,7 @@ function findAllApps(wsFolders) {
222
222
  for (const manifestPath of manifestPaths) {
223
223
  try {
224
224
  // All UI5 apps have at least sap.app: { id: <ID>, type: "application" } in manifest.json
225
- const manifest = yield file_1.readJSON(path_1.join(manifestPath, constants_1.FileName.Manifest));
225
+ const manifest = yield (0, file_1.readJSON)((0, path_1.join)(manifestPath, constants_1.FileName.Manifest));
226
226
  if (!manifest['sap.app'] || !manifest['sap.app'].id || manifest['sap.app'].type !== 'application') {
227
227
  continue;
228
228
  }
@@ -1,8 +1,10 @@
1
+ import type { Editor } from 'mem-fs-editor';
1
2
  /**
2
3
  * Get path to webapp.
3
4
  *
4
5
  * @param projectRoot - root path, where package.json or ui5.yaml is
6
+ * @param [memFs] - optional mem-fs editor instance
5
7
  * @returns - path to webapp folder
6
8
  */
7
- export declare function getWebappPath(projectRoot: string): Promise<string>;
9
+ export declare function getWebappPath(projectRoot: string, memFs?: Editor): Promise<string>;
8
10
  //# sourceMappingURL=ui5-config.d.ts.map
@@ -18,19 +18,20 @@ const file_1 = require("../file");
18
18
  * Get path to webapp.
19
19
  *
20
20
  * @param projectRoot - root path, where package.json or ui5.yaml is
21
+ * @param [memFs] - optional mem-fs editor instance
21
22
  * @returns - path to webapp folder
22
23
  */
23
- function getWebappPath(projectRoot) {
24
+ function getWebappPath(projectRoot, memFs) {
24
25
  var _a, _b;
25
26
  return __awaiter(this, void 0, void 0, function* () {
26
- let webappPath = path_1.join(projectRoot, 'webapp');
27
- const ui5YamlPath = path_1.join(projectRoot, constants_1.FileName.Ui5Yaml);
28
- if (yield file_1.fileExists(ui5YamlPath)) {
29
- const yamlString = yield file_1.readFile(ui5YamlPath);
27
+ let webappPath = (0, path_1.join)(projectRoot, 'webapp');
28
+ const ui5YamlPath = (0, path_1.join)(projectRoot, constants_1.FileName.Ui5Yaml);
29
+ if (yield (0, file_1.fileExists)(ui5YamlPath, memFs)) {
30
+ const yamlString = yield (0, file_1.readFile)(ui5YamlPath, memFs);
30
31
  const ui5Config = yield ui5_config_1.UI5Config.newInstance(yamlString);
31
32
  const relativeWebappPath = (_b = (_a = ui5Config.getConfiguration()) === null || _a === void 0 ? void 0 : _a.paths) === null || _b === void 0 ? void 0 : _b.webapp;
32
33
  if (relativeWebappPath) {
33
- webappPath = path_1.join(projectRoot, relativeWebappPath);
34
+ webappPath = (0, path_1.join)(projectRoot, relativeWebappPath);
34
35
  }
35
36
  }
36
37
  return webappPath;
@@ -1,10 +1,10 @@
1
- export declare type CapProjectType = 'CAPJava' | 'CAPNodejs';
1
+ export type CapProjectType = 'CAPJava' | 'CAPNodejs';
2
2
  export interface CapCustomPaths {
3
3
  app: string;
4
4
  db: string;
5
5
  srv: string;
6
6
  }
7
- declare type SELECT = {
7
+ type SELECT = {
8
8
  SELECT: {
9
9
  distinct?: true;
10
10
  one?: boolean;
@@ -21,41 +21,41 @@ declare type SELECT = {
21
21
  };
22
22
  };
23
23
  };
24
- declare type source = (ref | SELECT) & {
24
+ type source = (ref | SELECT) & {
25
25
  as?: name;
26
26
  join?: name;
27
27
  on?: xpr;
28
28
  };
29
- declare type name = string;
30
- declare type operator = string;
31
- declare type predicate = _xpr;
32
- declare type _xpr = (expr | operator)[];
33
- declare type expr = ref | val | xpr | SELECT;
34
- declare type ref = {
29
+ type name = string;
30
+ type operator = string;
31
+ type predicate = _xpr;
32
+ type _xpr = (expr | operator)[];
33
+ type expr = ref | val | xpr | SELECT;
34
+ type ref = {
35
35
  ref: (name & {
36
36
  id?: string;
37
37
  where?: expr;
38
38
  args?: expr[];
39
39
  })[];
40
40
  };
41
- declare type val = {
41
+ type val = {
42
42
  val: any;
43
43
  };
44
- declare type xpr = {
44
+ type xpr = {
45
45
  xpr: _xpr;
46
46
  };
47
- declare type ordering_term = expr & {
47
+ type ordering_term = expr & {
48
48
  asc?: true;
49
49
  desc?: true;
50
50
  };
51
- declare type column_expr = expr & {
51
+ type column_expr = expr & {
52
52
  as?: name;
53
53
  cast?: any;
54
54
  expand?: column_expr[];
55
55
  inline?: column_expr[];
56
56
  };
57
57
  /** A parsed model. */
58
- export declare type csn = CSN;
58
+ export type csn = CSN;
59
59
  export interface CSN {
60
60
  /** The assigned namespace. If parsed from multiple sources, this is the topmost model's namespace, if any, not the ones of imported models. */
61
61
  namespace?: string;
@@ -77,12 +77,12 @@ interface DefinitionRegistry {
77
77
  entity: Entity;
78
78
  Association: Association;
79
79
  }
80
- declare type Definition = DefinitionRegistry[keyof DefinitionRegistry];
80
+ type Definition = DefinitionRegistry[keyof DefinitionRegistry];
81
81
  interface Definitions {
82
82
  [name: string]: Definition;
83
83
  }
84
- declare type kind = 'context' | 'service' | 'type' | 'entity' | 'element' | 'const' | 'annotation';
85
- declare type Element = Type & Struct & Association & {
84
+ type kind = 'context' | 'service' | 'type' | 'entity' | 'element' | 'const' | 'annotation';
85
+ type Element = Type & Struct & Association & {
86
86
  kind: 'element' | undefined;
87
87
  };
88
88
  interface Type {
@@ -1,6 +1,7 @@
1
1
  export * from './cap';
2
- export * from './package';
3
2
  export * from './find';
3
+ export * from './info';
4
+ export * from './package';
4
5
  export * from './vscode';
5
6
  export * from './webapp';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,8 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./cap"), exports);
14
- __exportStar(require("./package"), exports);
15
18
  __exportStar(require("./find"), exports);
19
+ __exportStar(require("./info"), exports);
20
+ __exportStar(require("./package"), exports);
16
21
  __exportStar(require("./vscode"), exports);
17
22
  __exportStar(require("./webapp"), exports);
18
23
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export type AppProgrammingLanguage = 'JavaScript' | 'TypeScript' | '';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -3,7 +3,7 @@ Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe
3
3
 
4
4
  @category Class
5
5
  */
6
- export declare type Class<T, Arguments extends unknown[] = any[]> = Constructor<T, Arguments> & {
6
+ export type Class<T, Arguments extends unknown[] = any[]> = Constructor<T, Arguments> & {
7
7
  prototype: T;
8
8
  };
9
9
  /**
@@ -11,7 +11,7 @@ Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/Jav
11
11
 
12
12
  @category Class
13
13
  */
14
- export declare type Constructor<T, Arguments extends unknown[] = any[]> = new (...arguments_: Arguments) => T;
14
+ export type Constructor<T, Arguments extends unknown[] = any[]> = new (...arguments_: Arguments) => T;
15
15
  /**
16
16
  Matches a JSON object.
17
17
 
@@ -19,7 +19,7 @@ This type can be useful to enforce some input to be JSON-compatible or as a supe
19
19
 
20
20
  @category JSON
21
21
  */
22
- export declare type JsonObject = {
22
+ export type JsonObject = {
23
23
  [Key in string]: JsonValue;
24
24
  } & {
25
25
  [Key in string]?: JsonValue | undefined;
@@ -29,13 +29,13 @@ Matches a JSON array.
29
29
 
30
30
  @category JSON
31
31
  */
32
- export declare type JsonArray = JsonValue[];
32
+ export type JsonArray = JsonValue[];
33
33
  /**
34
34
  Matches any valid JSON primitive value.
35
35
 
36
36
  @category JSON
37
37
  */
38
- export declare type JsonPrimitive = string | number | boolean | null;
38
+ export type JsonPrimitive = string | number | boolean | null;
39
39
  /**
40
40
  Matches any valid JSON value.
41
41
 
@@ -43,5 +43,5 @@ Matches any valid JSON value.
43
43
 
44
44
  @category JSON
45
45
  */
46
- export declare type JsonValue = JsonPrimitive | JsonObject | JsonArray;
46
+ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
47
47
  //# sourceMappingURL=basic.d.ts.map
@@ -8,7 +8,7 @@ interface SapUxPackage {
8
8
  };
9
9
  remarkConfig?: object;
10
10
  }
11
- export declare type UI5FlexLayer = 'VENDOR' | 'CUSTOMER_BASE';
12
- export declare type Package = PackageJson & SapUxPackage;
11
+ export type UI5FlexLayer = 'VENDOR' | 'CUSTOMER_BASE';
12
+ export type Package = PackageJson & SapUxPackage;
13
13
  export {};
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -28,5 +28,5 @@ const pet: Pet2 = '';
28
28
 
29
29
  @category Type
30
30
  */
31
- export declare type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
31
+ export type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
32
32
  //# sourceMappingURL=literal-union.d.ts.map
@@ -505,6 +505,6 @@ Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-j
505
505
 
506
506
  @category File
507
507
  */
508
- export declare type PackageJson = JsonObject & PackageJson.NodeJsStandard & PackageJson.PackageJsonStandard & PackageJson.NonStandardEntryPoints & PackageJson.TypeScriptConfiguration & PackageJson.YarnConfiguration & PackageJson.JSPMConfiguration;
508
+ export type PackageJson = JsonObject & PackageJson.NodeJsStandard & PackageJson.PackageJsonStandard & PackageJson.NonStandardEntryPoints & PackageJson.TypeScriptConfiguration & PackageJson.YarnConfiguration & PackageJson.JSPMConfiguration;
509
509
  export {};
510
510
  //# sourceMappingURL=package-json.d.ts.map
@@ -3,5 +3,5 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
3
3
 
4
4
  @category Type
5
5
  */
6
- export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
6
+ export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
7
7
  //# sourceMappingURL=primitive.d.ts.map
@@ -1,4 +1,4 @@
1
1
  import type * as ManifestNamespace from '@ui5/manifest/types/manifest';
2
2
  export { ManifestNamespace };
3
- export declare type Manifest = ManifestNamespace.SAPJSONSchemaForWebApplicationManifestFile;
3
+ export type Manifest = ManifestNamespace.SAPJSONSchemaForWebApplicationManifestFile;
4
4
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "node": ">= 14.16.0 < 15.0.0 || >=16.1.0 < 17.0.0 || >=18.0.0 < 19.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@sap-ux/ui5-config": "0.16.3",
27
+ "@sap-ux/ui5-config": "0.16.4",
28
28
  "findit2": "2.2.3",
29
29
  "mem-fs": "2.1.0",
30
30
  "mem-fs-editor": "9.4.0"