@sap-ux/project-access 1.22.3 → 1.23.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,13 +1,4 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -22,15 +13,13 @@ const json_parse_even_better_errors_1 = __importDefault(require("json-parse-even
22
13
  * @param memFs - optional mem-fs-editor instance
23
14
  * @returns - file content as string
24
15
  */
25
- function readFile(path, memFs) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- if (memFs) {
28
- return memFs.read(path);
29
- }
30
- else {
31
- return fs_1.promises.readFile(path, { encoding: 'utf8' });
32
- }
33
- });
16
+ async function readFile(path, memFs) {
17
+ if (memFs) {
18
+ return memFs.read(path);
19
+ }
20
+ else {
21
+ return fs_1.promises.readFile(path, { encoding: 'utf8' });
22
+ }
34
23
  }
35
24
  exports.readFile = readFile;
36
25
  /**
@@ -40,15 +29,13 @@ exports.readFile = readFile;
40
29
  * @param memFs - optional mem-fs-editor instance
41
30
  * @returns - file content as object of type T
42
31
  */
43
- function readJSON(path, memFs) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- if (memFs) {
46
- return memFs.readJSON(path);
47
- }
48
- else {
49
- return JSON.parse(yield readFile(path));
50
- }
51
- });
32
+ async function readJSON(path, memFs) {
33
+ if (memFs) {
34
+ return memFs.readJSON(path);
35
+ }
36
+ else {
37
+ return JSON.parse(await readFile(path));
38
+ }
52
39
  }
53
40
  exports.readJSON = readJSON;
54
41
  /**
@@ -59,13 +46,11 @@ exports.readJSON = readJSON;
59
46
  * @param memFs - optional mem-fs-editor instance
60
47
  * @returns - file content as string
61
48
  */
62
- function writeFile(path, content, memFs) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- if (memFs) {
65
- return memFs.write(path, content);
66
- }
67
- return fs_1.promises.writeFile(path, content, { encoding: 'utf8' });
68
- });
49
+ async function writeFile(path, content, memFs) {
50
+ if (memFs) {
51
+ return memFs.write(path, content);
52
+ }
53
+ return fs_1.promises.writeFile(path, content, { encoding: 'utf8' });
69
54
  }
70
55
  exports.writeFile = writeFile;
71
56
  /**
@@ -75,21 +60,19 @@ exports.writeFile = writeFile;
75
60
  * @param memFs - optional mem-fs-editor instance
76
61
  * @returns - true if the file exists; false otherwise.
77
62
  */
78
- function fileExists(path, memFs) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- try {
81
- if (memFs) {
82
- return memFs.exists(path);
83
- }
84
- else {
85
- yield fs_1.promises.access(path);
86
- return true;
87
- }
63
+ async function fileExists(path, memFs) {
64
+ try {
65
+ if (memFs) {
66
+ return memFs.exists(path);
88
67
  }
89
- catch (_a) {
90
- return false;
68
+ else {
69
+ await fs_1.promises.access(path);
70
+ return true;
91
71
  }
92
- });
72
+ }
73
+ catch {
74
+ return false;
75
+ }
93
76
  }
94
77
  exports.fileExists = fileExists;
95
78
  /**
@@ -99,10 +82,8 @@ exports.fileExists = fileExists;
99
82
  * @param packageJson - updated package.json file content
100
83
  * @param memFs - optional mem-fs-editor instance
101
84
  */
102
- function updatePackageJSON(path, packageJson, memFs) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- yield updateJSON(path, packageJson, memFs);
105
- });
85
+ async function updatePackageJSON(path, packageJson, memFs) {
86
+ await updateJSON(path, packageJson, memFs);
106
87
  }
107
88
  exports.updatePackageJSON = updatePackageJSON;
108
89
  /**
@@ -112,10 +93,8 @@ exports.updatePackageJSON = updatePackageJSON;
112
93
  * @param manifest - updated manifest.json file content
113
94
  * @param memFs - optional mem-fs-editor instance
114
95
  */
115
- function updateManifestJSON(path, manifest, memFs) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- yield updateJSON(path, manifest, memFs);
118
- });
96
+ async function updateManifestJSON(path, manifest, memFs) {
97
+ await updateJSON(path, manifest, memFs);
119
98
  }
120
99
  exports.updateManifestJSON = updateManifestJSON;
121
100
  /**
@@ -125,15 +104,13 @@ exports.updateManifestJSON = updateManifestJSON;
125
104
  * @param content - updated JSON file content
126
105
  * @param memFs - optional mem-fs-editor instance
127
106
  */
128
- function updateJSON(path, content, memFs) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- // read old contents and indentation of the JSON file
131
- const oldContentText = yield readFile(path, memFs);
132
- const oldContentJson = (0, json_parse_even_better_errors_1.default)(oldContentText);
133
- const indent = Symbol.for('indent');
134
- // prepare new JSON file content with previous indentation
135
- const result = JSON.stringify(content, null, oldContentJson[indent]) + '\n';
136
- yield writeFile(path, result, memFs);
137
- });
107
+ async function updateJSON(path, content, memFs) {
108
+ // read old contents and indentation of the JSON file
109
+ const oldContentText = await readFile(path, memFs);
110
+ const oldContentJson = (0, json_parse_even_better_errors_1.default)(oldContentText);
111
+ const indent = Symbol.for('indent');
112
+ // prepare new JSON file content with previous indentation
113
+ const result = JSON.stringify(content, null, oldContentJson[indent]) + '\n';
114
+ await writeFile(path, result, memFs);
138
115
  }
139
116
  //# sourceMappingURL=file-access.js.map
@@ -1,13 +1,4 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -92,11 +83,9 @@ exports.findBy = findBy;
92
83
  * @param [memFs] - optional mem-fs-editor instance
93
84
  * @returns - array of paths that contain the filename
94
85
  */
95
- function findFiles(filename, root, excludeFolders, memFs) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const results = yield findBy({ fileNames: [filename], root, excludeFolders, memFs });
98
- return results.map((f) => (0, path_1.dirname)(f));
99
- });
86
+ async function findFiles(filename, root, excludeFolders, memFs) {
87
+ const results = await findBy({ fileNames: [filename], root, excludeFolders, memFs });
88
+ return results.map((f) => (0, path_1.dirname)(f));
100
89
  }
101
90
  exports.findFiles = findFiles;
102
91
  /**
@@ -120,16 +109,14 @@ exports.findFilesByExtension = findFilesByExtension;
120
109
  * @param fs - optional mem-fs-editor instance
121
110
  * @returns - path to file name if found, otherwise undefined
122
111
  */
123
- function findFileUp(fileName, startPath, fs) {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- const filePath = (0, path_1.join)(startPath, fileName);
126
- if (yield (0, file_access_1.fileExists)(filePath, fs)) {
127
- return filePath;
128
- }
129
- else {
130
- return (0, path_1.dirname)(startPath) !== startPath ? findFileUp(fileName, (0, path_1.dirname)(startPath), fs) : undefined;
131
- }
132
- });
112
+ async function findFileUp(fileName, startPath, fs) {
113
+ const filePath = (0, path_1.join)(startPath, fileName);
114
+ if (await (0, file_access_1.fileExists)(filePath, fs)) {
115
+ return filePath;
116
+ }
117
+ else {
118
+ return (0, path_1.dirname)(startPath) !== startPath ? findFileUp(fileName, (0, path_1.dirname)(startPath), fs) : undefined;
119
+ }
133
120
  }
134
121
  exports.findFileUp = findFileUp;
135
122
  /**
@@ -139,17 +126,15 @@ exports.findFileUp = findFileUp;
139
126
  * @returns {string[]} - array of file path strings
140
127
  * @throws if an error occurs reading a file path
141
128
  */
142
- function getFilePaths(dir) {
143
- return __awaiter(this, void 0, void 0, function* () {
144
- const entries = yield fs_1.promises.readdir(dir);
145
- const filePathsPromises = entries.map((entry) => __awaiter(this, void 0, void 0, function* () {
146
- const entryPath = (0, path_1.join)(dir, entry);
147
- const isDirectory = (yield fs_1.promises.stat(entryPath)).isDirectory();
148
- return isDirectory ? getFilePaths(entryPath) : entryPath;
149
- }));
150
- const filePaths = yield Promise.all(filePathsPromises);
151
- return [].concat(...filePaths);
129
+ async function getFilePaths(dir) {
130
+ const entries = await fs_1.promises.readdir(dir);
131
+ const filePathsPromises = entries.map(async (entry) => {
132
+ const entryPath = (0, path_1.join)(dir, entry);
133
+ const isDirectory = (await fs_1.promises.stat(entryPath)).isDirectory();
134
+ return isDirectory ? getFilePaths(entryPath) : entryPath;
152
135
  });
136
+ const filePaths = await Promise.all(filePathsPromises);
137
+ return [].concat(...filePaths);
153
138
  }
154
139
  exports.getFilePaths = getFilePaths;
155
140
  //# sourceMappingURL=file-search.js.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FileName, DirName, FioriToolsSettings } from './constants';
2
2
  export { getFilePaths } from './file';
3
- export { addPackageDevDependency, createApplicationAccess, createProjectAccess, findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getI18nPropertiesPaths, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, toReferenceUri, clearCdsModuleCache, updatePackageScript } from './project';
3
+ export { addPackageDevDependency, createApplicationAccess, createProjectAccess, findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getI18nPropertiesPaths, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, toReferenceUri, filterDataSourcesByType, clearCdsModuleCache, updatePackageScript } from './project';
4
4
  export * from './types';
5
5
  export * from './library';
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.updatePackageScript = exports.clearCdsModuleCache = exports.toReferenceUri = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMtaPath = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.createProjectAccess = exports.createApplicationAccess = exports.addPackageDevDependency = exports.getFilePaths = exports.FioriToolsSettings = exports.DirName = exports.FileName = void 0;
17
+ exports.updatePackageScript = exports.clearCdsModuleCache = exports.filterDataSourcesByType = exports.toReferenceUri = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMtaPath = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.createProjectAccess = exports.createApplicationAccess = exports.addPackageDevDependency = exports.getFilePaths = exports.FioriToolsSettings = exports.DirName = exports.FileName = void 0;
18
18
  var constants_1 = require("./constants");
19
19
  Object.defineProperty(exports, "FileName", { enumerable: true, get: function () { return constants_1.FileName; } });
20
20
  Object.defineProperty(exports, "DirName", { enumerable: true, get: function () { return constants_1.DirName; } });
@@ -56,6 +56,7 @@ Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get:
56
56
  Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return project_1.readCapServiceMetadataEdmx; } });
57
57
  Object.defineProperty(exports, "readUi5Yaml", { enumerable: true, get: function () { return project_1.readUi5Yaml; } });
58
58
  Object.defineProperty(exports, "toReferenceUri", { enumerable: true, get: function () { return project_1.toReferenceUri; } });
59
+ Object.defineProperty(exports, "filterDataSourcesByType", { enumerable: true, get: function () { return project_1.filterDataSourcesByType; } });
59
60
  Object.defineProperty(exports, "clearCdsModuleCache", { enumerable: true, get: function () { return project_1.clearCdsModuleCache; } });
60
61
  Object.defineProperty(exports, "updatePackageScript", { enumerable: true, get: function () { return project_1.updatePackageScript; } });
61
62
  __exportStar(require("./types"), exports);
@@ -1,13 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getManifestDependencies = exports.getManifestDesc = exports.getLibraryDependencies = exports.getLibraryDesc = exports.checkDependencies = exports.getReuseLibs = void 0;
13
4
  const path_1 = require("path");
@@ -27,21 +18,20 @@ const i18n_2 = require("@sap-ux/i18n");
27
18
  * @param projectRoot - root of the project
28
19
  * @returns reuse library or undefined
29
20
  */
30
- const getLibraryFromManifest = (manifest, manifestPath, reuseLibs, projectRoot) => __awaiter(void 0, void 0, void 0, function* () {
31
- var _a, _b, _c;
21
+ const getLibraryFromManifest = async (manifest, manifestPath, reuseLibs, projectRoot) => {
32
22
  let reuseLib;
33
- const manifestType = (_a = manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.type;
23
+ const manifestType = manifest['sap.app']?.type;
34
24
  if ((manifestType === 'component' || manifestType === 'library') && manifestPath) {
35
25
  const reuseType = getReuseType(manifestPath);
36
26
  const libDeps = getManifestDependencies(manifest);
37
- const description = yield getManifestDesc(manifest, manifestPath);
38
- const libIndex = reuseLibs.findIndex((reuseLib) => reuseLib.name === (manifest === null || manifest === void 0 ? void 0 : manifest['sap.app'].id));
27
+ const description = await getManifestDesc(manifest, manifestPath);
28
+ const libIndex = reuseLibs.findIndex((reuseLib) => reuseLib.name === manifest?.['sap.app'].id);
39
29
  if (libIndex === -1) {
40
30
  reuseLib = {
41
31
  name: `${manifest['sap.app'].id}`,
42
32
  path: (0, path_1.dirname)(manifestPath),
43
33
  type: reuseType,
44
- uri: (_c = (_b = manifest['sap.platform.abap']) === null || _b === void 0 ? void 0 : _b.uri) !== null && _c !== void 0 ? _c : '',
34
+ uri: manifest['sap.platform.abap']?.uri ?? '',
45
35
  dependencies: libDeps,
46
36
  libRoot: projectRoot,
47
37
  description
@@ -49,7 +39,7 @@ const getLibraryFromManifest = (manifest, manifestPath, reuseLibs, projectRoot)
49
39
  }
50
40
  }
51
41
  return reuseLib;
52
- });
42
+ };
53
43
  /**
54
44
  * Reads library file and returns a reuse lib object.
55
45
  *
@@ -58,21 +48,20 @@ const getLibraryFromManifest = (manifest, manifestPath, reuseLibs, projectRoot)
58
48
  * @param projectRoot - root of the project
59
49
  * @returns reuse library or undefined
60
50
  */
61
- const getLibraryFromLibraryFile = (library, libraryPath, projectRoot) => __awaiter(void 0, void 0, void 0, function* () {
62
- var _d, _e, _f, _g, _h;
51
+ const getLibraryFromLibraryFile = async (library, libraryPath, projectRoot) => {
63
52
  let libEntry;
64
53
  const parsedFile = new fast_xml_parser_1.XMLParser({ removeNSPrefix: true }).parse(library, false);
65
- if ((_d = parsedFile === null || parsedFile === void 0 ? void 0 : parsedFile.library) === null || _d === void 0 ? void 0 : _d.name) {
66
- const manifestType = (parsedFile === null || parsedFile === void 0 ? void 0 : parsedFile.library) ? 'library' : 'component';
54
+ if (parsedFile?.library?.name) {
55
+ const manifestType = parsedFile?.library ? 'library' : 'component';
67
56
  if (manifestType === 'component' || manifestType === 'library') {
68
57
  const reuseType = getReuseType(libraryPath);
69
58
  const libDeps = getLibraryDependencies(parsedFile);
70
- const description = yield getLibraryDesc(parsedFile, libraryPath);
59
+ const description = await getLibraryDesc(parsedFile, libraryPath);
71
60
  libEntry = {
72
61
  name: `${parsedFile.library.name}`,
73
62
  path: (0, path_1.dirname)(libraryPath),
74
63
  type: reuseType,
75
- uri: ((_h = (_g = (_f = (_e = parsedFile.library) === null || _e === void 0 ? void 0 : _e.appData) === null || _f === void 0 ? void 0 : _f.manifest) === null || _g === void 0 ? void 0 : _g['sap.platform.abap']) === null || _h === void 0 ? void 0 : _h.uri) || '',
64
+ uri: parsedFile.library?.appData?.manifest?.['sap.platform.abap']?.uri || '',
76
65
  dependencies: libDeps,
77
66
  libRoot: projectRoot,
78
67
  description
@@ -80,7 +69,7 @@ const getLibraryFromLibraryFile = (library, libraryPath, projectRoot) => __await
80
69
  }
81
70
  }
82
71
  return libEntry;
83
- });
72
+ };
84
73
  /**
85
74
  * Updates the library options with the new library.
86
75
  *
@@ -105,31 +94,31 @@ const updateLibOptions = (reuseLibs, reuseLib) => {
105
94
  * @param libs - array of libraries found in the workspace folders.
106
95
  * @returns list of reuse library
107
96
  */
108
- const getReuseLibs = (libs) => __awaiter(void 0, void 0, void 0, function* () {
97
+ const getReuseLibs = async (libs) => {
109
98
  const reuseLibs = [];
110
99
  if (libs) {
111
100
  for (const lib of libs) {
112
101
  const excludeFolders = ['.git', 'node_modules', 'dist'];
113
- const manifestPaths = yield (0, file_1.findFiles)('manifest.json', lib.projectRoot, excludeFolders);
114
- const libraryPaths = yield (0, file_1.findFiles)('library.js', lib.projectRoot, excludeFolders);
102
+ const manifestPaths = await (0, file_1.findFiles)('manifest.json', lib.projectRoot, excludeFolders);
103
+ const libraryPaths = await (0, file_1.findFiles)('library.js', lib.projectRoot, excludeFolders);
115
104
  for (const manifestPath of manifestPaths) {
116
105
  const manifestFilePath = (0, path_1.join)(manifestPath, constants_2.FileName.Manifest);
117
- const manifest = JSON.parse(yield fs_1.promises.readFile(manifestFilePath, { encoding: 'utf8' }));
118
- const library = yield getLibraryFromManifest(manifest, manifestFilePath, reuseLibs, lib.projectRoot);
106
+ const manifest = JSON.parse(await fs_1.promises.readFile(manifestFilePath, { encoding: 'utf8' }));
107
+ const library = await getLibraryFromManifest(manifest, manifestFilePath, reuseLibs, lib.projectRoot);
119
108
  if (library) {
120
109
  reuseLibs.push(library);
121
110
  }
122
111
  }
123
112
  for (const libraryPath of libraryPaths) {
124
113
  const libraryFilePath = (0, path_1.join)(libraryPath, constants_2.FileName.Library);
125
- const library = (yield fs_1.promises.readFile(libraryFilePath, { encoding: 'utf8' })).toString();
126
- const libFile = yield getLibraryFromLibraryFile(library, libraryFilePath, lib.projectRoot);
114
+ const library = (await fs_1.promises.readFile(libraryFilePath, { encoding: 'utf8' })).toString();
115
+ const libFile = await getLibraryFromLibraryFile(library, libraryFilePath, lib.projectRoot);
127
116
  updateLibOptions(reuseLibs, libFile);
128
117
  }
129
118
  }
130
119
  }
131
120
  return reuseLibs;
132
- });
121
+ };
133
122
  exports.getReuseLibs = getReuseLibs;
134
123
  /**
135
124
  * Gets the type of reuse library.
@@ -154,7 +143,7 @@ function checkDependencies(answers, reuseLibs) {
154
143
  const missingDeps = [];
155
144
  answers.forEach((answer) => {
156
145
  const dependencies = answer.dependencies;
157
- if (dependencies === null || dependencies === void 0 ? void 0 : dependencies.length) {
146
+ if (dependencies?.length) {
158
147
  dependencies.forEach((dependency) => {
159
148
  if (!reuseLibs.some((lib) => {
160
149
  return dependency === lib.name;
@@ -174,16 +163,13 @@ exports.checkDependencies = checkDependencies;
174
163
  * @param libraryPath - library path
175
164
  * @returns library description
176
165
  */
177
- function getLibraryDesc(library, libraryPath) {
178
- var _a, _b, _c, _d, _e;
179
- return __awaiter(this, void 0, void 0, function* () {
180
- let libraryDesc = (_a = library === null || library === void 0 ? void 0 : library.library) === null || _a === void 0 ? void 0 : _a.documentation;
181
- if (typeof libraryDesc === 'string' && libraryDesc.startsWith('{{')) {
182
- const key = libraryDesc.substring(2, libraryDesc.length - 2);
183
- libraryDesc = yield geti18nPropertyValue((0, path_1.join)((0, path_1.dirname)(libraryPath), (_e = (_d = (_c = (_b = library.library) === null || _b === void 0 ? void 0 : _b.appData) === null || _c === void 0 ? void 0 : _c.manifest) === null || _d === void 0 ? void 0 : _d.i18n) === null || _e === void 0 ? void 0 : _e.toString()), key);
184
- }
185
- return libraryDesc.toString();
186
- });
166
+ async function getLibraryDesc(library, libraryPath) {
167
+ let libraryDesc = library?.library?.documentation;
168
+ if (typeof libraryDesc === 'string' && libraryDesc.startsWith('{{')) {
169
+ const key = libraryDesc.substring(2, libraryDesc.length - 2);
170
+ libraryDesc = await geti18nPropertyValue((0, path_1.join)((0, path_1.dirname)(libraryPath), library.library?.appData?.manifest?.i18n?.toString()), key);
171
+ }
172
+ return libraryDesc.toString();
187
173
  }
188
174
  exports.getLibraryDesc = getLibraryDesc;
189
175
  /**
@@ -193,9 +179,8 @@ exports.getLibraryDesc = getLibraryDesc;
193
179
  * @returns array of dependencies
194
180
  */
195
181
  function getLibraryDependencies(library) {
196
- var _a, _b;
197
182
  const result = [];
198
- if ((_b = (_a = library === null || library === void 0 ? void 0 : library.library) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b.dependency) {
183
+ if (library?.library?.dependencies?.dependency) {
199
184
  let deps = library.library.dependencies.dependency;
200
185
  if (!Array.isArray(deps)) {
201
186
  deps = [deps];
@@ -219,21 +204,19 @@ exports.getLibraryDependencies = getLibraryDependencies;
219
204
  * @param key - property key
220
205
  * @returns i18n property value
221
206
  */
222
- function geti18nPropertyValue(i18nPath, key) {
223
- return __awaiter(this, void 0, void 0, function* () {
224
- let value = '';
225
- try {
226
- const bundle = yield (0, i18n_2.getPropertiesI18nBundle)(i18nPath);
227
- const node = bundle[key].find((i) => i.key.value === key);
228
- if (node) {
229
- value = node.value.value;
230
- }
231
- }
232
- catch (e) {
233
- // ignore exception
207
+ async function geti18nPropertyValue(i18nPath, key) {
208
+ let value = '';
209
+ try {
210
+ const bundle = await (0, i18n_2.getPropertiesI18nBundle)(i18nPath);
211
+ const node = bundle[key].find((i) => i.key.value === key);
212
+ if (node) {
213
+ value = node.value.value;
234
214
  }
235
- return value;
236
- });
215
+ }
216
+ catch (e) {
217
+ // ignore exception
218
+ }
219
+ return value;
237
220
  }
238
221
  /**
239
222
  * Returns the manifest description.
@@ -242,17 +225,14 @@ function geti18nPropertyValue(i18nPath, key) {
242
225
  * @param manifestPath - manifestPath path
243
226
  * @returns manifest description
244
227
  */
245
- function getManifestDesc(manifest, manifestPath) {
246
- var _a;
247
- return __awaiter(this, void 0, void 0, function* () {
248
- let manifestDesc = (_a = manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.description;
249
- if (typeof manifestDesc === 'string' && manifestDesc.startsWith('{{')) {
250
- const key = manifestDesc.substring(2, manifestDesc.length - 2);
251
- const { 'sap.app': i18nPath } = yield (0, i18n_1.getI18nPropertiesPaths)(manifestPath, manifest);
252
- manifestDesc = yield geti18nPropertyValue(i18nPath, key);
253
- }
254
- return (manifestDesc !== null && manifestDesc !== void 0 ? manifestDesc : '').toString();
255
- });
228
+ async function getManifestDesc(manifest, manifestPath) {
229
+ let manifestDesc = manifest['sap.app']?.description;
230
+ if (typeof manifestDesc === 'string' && manifestDesc.startsWith('{{')) {
231
+ const key = manifestDesc.substring(2, manifestDesc.length - 2);
232
+ const { 'sap.app': i18nPath } = await (0, i18n_1.getI18nPropertiesPaths)(manifestPath, manifest);
233
+ manifestDesc = await geti18nPropertyValue(i18nPath, key);
234
+ }
235
+ return (manifestDesc ?? '').toString();
256
236
  }
257
237
  exports.getManifestDesc = getManifestDesc;
258
238
  /**
@@ -264,10 +244,9 @@ exports.getManifestDesc = getManifestDesc;
264
244
  function getManifestDependencies(manifest) {
265
245
  const result = [];
266
246
  Object.values(['libs', 'components']).forEach((reuseType) => {
267
- var _a, _b, _c, _d;
268
- const dependencies = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b[reuseType];
247
+ const dependencies = manifest['sap.ui5']?.dependencies?.[reuseType];
269
248
  if (dependencies) {
270
- const libs = (_d = (_c = manifest === null || manifest === void 0 ? void 0 : manifest['sap.ui5']) === null || _c === void 0 ? void 0 : _c.dependencies) === null || _d === void 0 ? void 0 : _d.libs;
249
+ const libs = manifest?.['sap.ui5']?.dependencies?.libs;
271
250
  if (libs) {
272
251
  Object.keys(libs).forEach((manifestLibKey) => {
273
252
  // ignore libs that start with SAPUI5 delivered namespaces
@@ -1,13 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.createProjectAccess = exports.createApplicationAccess = void 0;
13
4
  const path_1 = require("path");
@@ -20,6 +11,9 @@ const constants_1 = require("../constants");
20
11
  *
21
12
  */
22
13
  class ApplicationAccessImp {
14
+ _project;
15
+ appId;
16
+ fs;
23
17
  /**
24
18
  * Constructor for ApplicationAccess.
25
19
  *
@@ -146,10 +140,8 @@ class ApplicationAccessImp {
146
140
  * @param packageJson - updated package.json file content
147
141
  * @param memFs - optional mem-fs-editor instance
148
142
  */
149
- updatePackageJSON(packageJson, memFs) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- yield (0, file_1.updatePackageJSON)((0, path_1.join)(this.app.appRoot, constants_1.FileName.Package), packageJson, memFs);
152
- });
143
+ async updatePackageJSON(packageJson, memFs) {
144
+ await (0, file_1.updatePackageJSON)((0, path_1.join)(this.app.appRoot, constants_1.FileName.Package), packageJson, memFs);
153
145
  }
154
146
  /**
155
147
  * Updates manifest.json file asynchronously by keeping the previous indentation.
@@ -157,10 +149,8 @@ class ApplicationAccessImp {
157
149
  * @param manifest - updated manifest.json file content
158
150
  * @param memFs - optional mem-fs-editor instance
159
151
  */
160
- updateManifestJSON(manifest, memFs) {
161
- return __awaiter(this, void 0, void 0, function* () {
162
- yield (0, file_1.updateManifestJSON)(this.app.manifest, manifest, memFs);
163
- });
152
+ async updateManifestJSON(manifest, memFs) {
153
+ await (0, file_1.updateManifestJSON)(this.app.manifest, manifest, memFs);
164
154
  }
165
155
  /**
166
156
  * Project structure.
@@ -192,6 +182,7 @@ class ApplicationAccessImp {
192
182
  * It can be used to retrieve information about the project, like applications, paths, services.
193
183
  */
194
184
  class ProjectAccessImp {
185
+ _project;
195
186
  /**
196
187
  * Constructor for ProjectAccess.
197
188
  *
@@ -254,22 +245,20 @@ class ProjectAccessImp {
254
245
  * When calling this function, adding or removing a CDS file in memory or changing CDS configuration will not be considered until present on real file system.
255
246
  * @returns - Instance of ApplicationAccess that contains information about the application, like paths and services
256
247
  */
257
- function createApplicationAccess(appRoot, fs) {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- try {
260
- const apps = yield (0, search_1.findAllApps)([appRoot]);
261
- const app = apps.find((app) => app.appRoot === appRoot);
262
- if (!app) {
263
- throw new Error(`Could not find app with root ${appRoot}`);
264
- }
265
- const project = yield (0, info_1.getProject)(app.projectRoot);
266
- const appId = (0, path_1.relative)(project.root, appRoot);
267
- return new ApplicationAccessImp(project, appId, fs);
248
+ async function createApplicationAccess(appRoot, fs) {
249
+ try {
250
+ const apps = await (0, search_1.findAllApps)([appRoot]);
251
+ const app = apps.find((app) => app.appRoot === appRoot);
252
+ if (!app) {
253
+ throw new Error(`Could not find app with root ${appRoot}`);
268
254
  }
269
- catch (error) {
270
- throw Error(`Error when creating application access for ${appRoot}: ${error}`);
271
- }
272
- });
255
+ const project = await (0, info_1.getProject)(app.projectRoot);
256
+ const appId = (0, path_1.relative)(project.root, appRoot);
257
+ return new ApplicationAccessImp(project, appId, fs);
258
+ }
259
+ catch (error) {
260
+ throw Error(`Error when creating application access for ${appRoot}: ${error}`);
261
+ }
273
262
  }
274
263
  exports.createApplicationAccess = createApplicationAccess;
275
264
  /**
@@ -278,17 +267,15 @@ exports.createApplicationAccess = createApplicationAccess;
278
267
  * @param root - Project root path
279
268
  * @returns - Instance of ProjectAccess that contains information about the project
280
269
  */
281
- function createProjectAccess(root) {
282
- return __awaiter(this, void 0, void 0, function* () {
283
- try {
284
- const project = yield (0, info_1.getProject)(root);
285
- const projectAccess = new ProjectAccessImp(project);
286
- return projectAccess;
287
- }
288
- catch (error) {
289
- throw Error(`Error when creating project access for ${root}: ${error}`);
290
- }
291
- });
270
+ async function createProjectAccess(root) {
271
+ try {
272
+ const project = await (0, info_1.getProject)(root);
273
+ const projectAccess = new ProjectAccessImp(project);
274
+ return projectAccess;
275
+ }
276
+ catch (error) {
277
+ throw Error(`Error when creating project access for ${root}: ${error}`);
278
+ }
292
279
  }
293
280
  exports.createProjectAccess = createProjectAccess;
294
281
  //# sourceMappingURL=access.js.map