@sap-ux/project-access 1.22.4 → 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.
- package/dist/file/file-access.js +42 -65
- package/dist/file/file-search.js +19 -34
- package/dist/library/helpers.js +51 -72
- package/dist/project/access.js +30 -43
- package/dist/project/cap.js +273 -322
- package/dist/project/dependencies.js +9 -21
- package/dist/project/i18n/i18n.js +16 -29
- package/dist/project/i18n/read.js +30 -43
- package/dist/project/i18n/write.js +46 -58
- package/dist/project/info.js +109 -134
- package/dist/project/module-loader.js +12 -23
- package/dist/project/mta.js +12 -23
- package/dist/project/script.js +8 -19
- package/dist/project/search.js +223 -261
- package/dist/project/service.js +17 -31
- package/dist/project/ui5-config.js +18 -32
- package/package.json +4 -4
package/dist/file/file-access.js
CHANGED
|
@@ -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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
90
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
package/dist/file/file-search.js
CHANGED
|
@@ -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
|
-
|
|
97
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
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/library/helpers.js
CHANGED
|
@@ -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) =>
|
|
31
|
-
var _a, _b, _c;
|
|
21
|
+
const getLibraryFromManifest = async (manifest, manifestPath, reuseLibs, projectRoot) => {
|
|
32
22
|
let reuseLib;
|
|
33
|
-
const manifestType =
|
|
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 =
|
|
38
|
-
const libIndex = reuseLibs.findIndex((reuseLib) => reuseLib.name ===
|
|
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:
|
|
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) =>
|
|
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 (
|
|
66
|
-
const manifestType =
|
|
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 =
|
|
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:
|
|
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) =>
|
|
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 =
|
|
114
|
-
const libraryPaths =
|
|
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(
|
|
118
|
-
const library =
|
|
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 = (
|
|
126
|
-
const libFile =
|
|
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
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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 (
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
package/dist/project/access.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
|
|
270
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|