@sap-ux/ui5-library-reference-writer 0.3.2 → 1.0.1
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/constants.js +4 -7
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.js +14 -18
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -9
- package/dist/types.js +1 -2
- package/package.json +6 -5
package/dist/constants.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
5
|
-
exports.yamlFiles = [project_access_1.FileName.Ui5Yaml, project_access_1.FileName.Ui5LocalYaml, project_access_1.FileName.Ui5MockYaml];
|
|
6
|
-
var ManifestReuseType;
|
|
1
|
+
import { FileName } from '@sap-ux/project-access';
|
|
2
|
+
export const yamlFiles = [FileName.Ui5Yaml, FileName.Ui5LocalYaml, FileName.Ui5MockYaml];
|
|
3
|
+
export var ManifestReuseType;
|
|
7
4
|
(function (ManifestReuseType) {
|
|
8
5
|
ManifestReuseType["Library"] = "libs";
|
|
9
6
|
ManifestReuseType["Component"] = "components";
|
|
10
|
-
})(ManifestReuseType || (
|
|
7
|
+
})(ManifestReuseType || (ManifestReuseType = {}));
|
|
11
8
|
//# sourceMappingURL=constants.js.map
|
package/dist/helpers.d.ts
CHANGED
package/dist/helpers.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
6
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import { UI5Config } from '@sap-ux/ui5-config';
|
|
2
|
+
import { getWebappPath } from '@sap-ux/project-access';
|
|
3
|
+
import { join, relative } from 'node:path';
|
|
4
|
+
import { yamlFiles, ManifestReuseType } from './constants.js';
|
|
9
5
|
/**
|
|
10
6
|
* Updates manifest with references for the chosen reuse libs.
|
|
11
7
|
*
|
|
@@ -13,12 +9,12 @@ const constants_1 = require("./constants");
|
|
|
13
9
|
* @param reuseLibs reuse libraries for referencing
|
|
14
10
|
* @param fs mem-fs editor instance
|
|
15
11
|
*/
|
|
16
|
-
async function updateManifest(projectPath, reuseLibs, fs) {
|
|
17
|
-
const webapp = await
|
|
18
|
-
const manifestPath =
|
|
12
|
+
export async function updateManifest(projectPath, reuseLibs, fs) {
|
|
13
|
+
const webapp = await getWebappPath(projectPath);
|
|
14
|
+
const manifestPath = join(webapp, 'manifest.json');
|
|
19
15
|
const manifest = fs.readJSON(manifestPath);
|
|
20
16
|
reuseLibs.forEach((lib) => {
|
|
21
|
-
const reuseType = lib.type === 'library' ?
|
|
17
|
+
const reuseType = lib.type === 'library' ? ManifestReuseType.Library : ManifestReuseType.Component;
|
|
22
18
|
if (manifest['sap.ui5']?.dependencies && !manifest['sap.ui5']?.dependencies?.[reuseType]) {
|
|
23
19
|
manifest['sap.ui5'].dependencies[reuseType] = {};
|
|
24
20
|
}
|
|
@@ -35,11 +31,11 @@ async function updateManifest(projectPath, reuseLibs, fs) {
|
|
|
35
31
|
* @param reuseLibs reuse libraries for referencing
|
|
36
32
|
* @param fs mem-fs editor instance
|
|
37
33
|
*/
|
|
38
|
-
function updateYaml(projectPath, reuseLibs, fs) {
|
|
39
|
-
|
|
40
|
-
const yamlPath =
|
|
34
|
+
export function updateYaml(projectPath, reuseLibs, fs) {
|
|
35
|
+
yamlFiles.forEach(async (yaml) => {
|
|
36
|
+
const yamlPath = join(projectPath, yaml);
|
|
41
37
|
if (fs.exists(yamlPath)) {
|
|
42
|
-
const ui5Config = await
|
|
38
|
+
const ui5Config = await UI5Config.newInstance(fs.read(yamlPath));
|
|
43
39
|
const serveStaticPaths = getServeStaticPaths(reuseLibs, projectPath);
|
|
44
40
|
ui5Config.addServeStaticConfig(serveStaticPaths);
|
|
45
41
|
fs.write(yamlPath, ui5Config.toString());
|
|
@@ -59,14 +55,14 @@ function getServeStaticPaths(reuseLibs, projectPath) {
|
|
|
59
55
|
const reuseLibRefs = [
|
|
60
56
|
{
|
|
61
57
|
path: `/resources/${lib.name.replace(/\./g, '/')}`,
|
|
62
|
-
src:
|
|
58
|
+
src: relative(projectPath, lib.path),
|
|
63
59
|
fallthrough: false
|
|
64
60
|
}
|
|
65
61
|
];
|
|
66
62
|
if (lib.uri) {
|
|
67
63
|
reuseLibRefs.push({
|
|
68
64
|
path: `${lib.uri.replace(/\/bsp\//g, '/ui5_ui5/')}`,
|
|
69
|
-
src:
|
|
65
|
+
src: relative(projectPath, lib.path),
|
|
70
66
|
fallthrough: false
|
|
71
67
|
});
|
|
72
68
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const mem_fs_1 = require("mem-fs");
|
|
5
|
-
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
6
|
-
const helpers_1 = require("./helpers");
|
|
1
|
+
import { create as createStorage } from 'mem-fs';
|
|
2
|
+
import { create } from 'mem-fs-editor';
|
|
3
|
+
import { updateManifest, updateYaml } from './helpers.js';
|
|
7
4
|
/**
|
|
8
5
|
* Writes the file updates to the memfs editor instance.
|
|
9
6
|
*
|
|
@@ -14,10 +11,11 @@ const helpers_1 = require("./helpers");
|
|
|
14
11
|
*/
|
|
15
12
|
async function generate(basePath, referenceLibraries, fs) {
|
|
16
13
|
if (!fs) {
|
|
17
|
-
fs =
|
|
14
|
+
fs = create(createStorage());
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
await
|
|
16
|
+
updateYaml(basePath, referenceLibraries, fs);
|
|
17
|
+
await updateManifest(basePath, referenceLibraries, fs);
|
|
21
18
|
return fs;
|
|
22
19
|
}
|
|
20
|
+
export { generate };
|
|
23
21
|
//# sourceMappingURL=index.js.map
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-library-reference-writer",
|
|
3
3
|
"description": "Writer module to add library/component references to an existing Fiori application",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
7
8
|
"directory": "packages/ui5-library-reference-writer"
|
|
8
9
|
},
|
|
9
|
-
"version": "0.
|
|
10
|
+
"version": "1.0.1",
|
|
10
11
|
"license": "Apache-2.0",
|
|
11
12
|
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
@@ -21,8 +22,8 @@
|
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"mem-fs": "2.1.0",
|
|
23
24
|
"mem-fs-editor": "9.4.0",
|
|
24
|
-
"@sap-ux/project-access": "
|
|
25
|
-
"@sap-ux/ui5-config": "0.
|
|
25
|
+
"@sap-ux/project-access": "2.0.1",
|
|
26
|
+
"@sap-ux/ui5-config": "1.0.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/fs-extra": "11.0.4",
|
|
@@ -37,8 +38,8 @@
|
|
|
37
38
|
"format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",
|
|
38
39
|
"lint": "eslint",
|
|
39
40
|
"lint:fix": "eslint --fix",
|
|
40
|
-
"test": "jest --ci --forceExit --detectOpenHandles --colors",
|
|
41
|
-
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
41
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
|
|
42
|
+
"test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
42
43
|
"link": "pnpm link --global",
|
|
43
44
|
"unlink": "pnpm unlink --global"
|
|
44
45
|
}
|