@ui5/webcomponents-tools 1.3.1 → 1.4.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/CHANGELOG.md +11 -0
- package/components-package/nps.js +5 -1
- package/components-package/wdio.js +1 -1
- package/icons-collection/nps.js +1 -7
- package/lib/copy-and-watch/index.js +0 -1
- package/lib/copy-list/index.js +16 -16
- package/lib/create-icons/index.js +82 -72
- package/lib/create-illustrations/index.js +101 -90
- package/lib/documentation/index.js +119 -116
- package/lib/esm-abs-to-rel/index.js +13 -9
- package/lib/generate-json-imports/i18n.js +38 -31
- package/lib/generate-json-imports/themes.js +28 -21
- package/lib/hbs2lit/src/compiler.js +2 -2
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2ui5/index.js +37 -21
- package/lib/i18n/defaults.js +49 -57
- package/lib/i18n/toJSON.js +12 -11
- package/lib/replace-global-core/index.js +13 -8
- package/package.json +3 -3
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.4.0](https://github.com/SAP/ui5-webcomponents/compare/v1.3.1...v1.4.0) (2022-05-25)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
**Note:** Version bump only for package @ui5/webcomponents-icons-tnt
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
6
17
|
## [1.3.1](https://github.com/SAP/ui5-webcomponents/compare/v1.3.0...v1.3.1) (2022-04-27)
|
7
18
|
|
8
19
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
@@ -18,7 +18,11 @@ const getScripts = (options) => {
|
|
18
18
|
clean: "rimraf dist && rimraf .port",
|
19
19
|
lint: "eslint . --config config/.eslintrc.js",
|
20
20
|
lintfix: "eslint . --config config/.eslintrc.js --fix",
|
21
|
-
prepare:
|
21
|
+
prepare: {
|
22
|
+
default: "nps clean prepare.all",
|
23
|
+
all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.samples" "nps build.illustrations"',
|
24
|
+
styleRelated: "nps build.styles build.jsonImports",
|
25
|
+
},
|
22
26
|
build: {
|
23
27
|
default: "nps lint prepare build.bundle",
|
24
28
|
templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
|
@@ -99,7 +99,7 @@ exports.config = {
|
|
99
99
|
// Services take over a specific job you don't want to take care of. They enhance
|
100
100
|
// your test setup with almost no effort. Unlike plugins, they don't add new
|
101
101
|
// commands. Instead, they hook themselves up into the test process.
|
102
|
-
services: ['chromedriver'],
|
102
|
+
services: ['chromedriver', 'devtools'],
|
103
103
|
// options
|
104
104
|
chromeDriverArgs: ['--port=9515'], // default
|
105
105
|
// Framework you want to run your specs with.
|
package/icons-collection/nps.js
CHANGED
@@ -1,9 +1,4 @@
|
|
1
1
|
const path = require("path");
|
2
|
-
const resolve = require("resolve");
|
3
|
-
|
4
|
-
const generateHash = resolve.sync("@ui5/webcomponents-tools/lib/hash/generate.js");
|
5
|
-
const hashIsUpToDate = resolve.sync("@ui5/webcomponents-tools/lib/hash/upToDate.js");
|
6
|
-
const UP_TO_DATE = `node "${hashIsUpToDate}" dist/ hash.txt && echo "Up to date."`;
|
7
2
|
|
8
3
|
const LIB = path.join(__dirname, `../lib/`);
|
9
4
|
|
@@ -51,7 +46,7 @@ const getScripts = (options) => {
|
|
51
46
|
clean: "rimraf dist",
|
52
47
|
copy: copyAssetsCmd,
|
53
48
|
build: {
|
54
|
-
default:
|
49
|
+
default: `nps clean copy build.i18n build.icons build.jsonImports`,
|
55
50
|
i18n: {
|
56
51
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
57
52
|
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
|
@@ -63,7 +58,6 @@ const getScripts = (options) => {
|
|
63
58
|
},
|
64
59
|
icons: createJSImportsCmd,
|
65
60
|
},
|
66
|
-
hash: `node "${generateHash}" dist/ hash.txt`,
|
67
61
|
};
|
68
62
|
|
69
63
|
return scripts;
|
package/lib/copy-list/index.js
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
const fs = require("fs");
|
1
|
+
const fs = require("fs").promises;
|
2
2
|
const path = require("path");
|
3
|
-
const mkdirp = require("mkdirp");
|
4
3
|
|
5
4
|
const fileList = process.argv[2];
|
6
5
|
const dest = process.argv[3];
|
7
6
|
const src = "../../node_modules/@openui5/sap.ui.core/src/";
|
8
7
|
|
9
|
-
const
|
10
|
-
|
8
|
+
const generate = async () => {
|
9
|
+
const filesToCopy = (await fs.readFile(fileList)).toString();
|
10
|
+
// console.log(filesToCopy);
|
11
11
|
|
12
|
-
// Support full-line comments starting with # in the used-modules.txt file
|
13
|
-
const shouldCopy = file => file.length && !file.startsWith("#");
|
12
|
+
// Support full-line comments starting with # in the used-modules.txt file
|
13
|
+
const shouldCopy = file => file.length && !file.startsWith("#");
|
14
14
|
|
15
|
-
const trimFile = file => file.trim();
|
15
|
+
const trimFile = file => file.trim();
|
16
16
|
|
17
|
-
filesToCopy.split("\n").map(trimFile).filter(shouldCopy).
|
18
|
-
|
19
|
-
|
17
|
+
return filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
|
18
|
+
const srcPath = path.join(src, moduleName);
|
19
|
+
const destPath = path.join(dest, moduleName);
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
if (err) {
|
24
|
-
throw err;
|
25
|
-
}
|
26
|
-
console.log(`${destPath} created.`);
|
21
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
22
|
+
return fs.copyFile(srcPath, destPath);
|
27
23
|
});
|
24
|
+
};
|
25
|
+
|
26
|
+
generate().then(() => {
|
27
|
+
console.log("Files copied.");
|
28
28
|
});
|
@@ -1,72 +1,82 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const path = require("path");
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
const
|
13
|
-
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
const
|
29
|
-
const
|
30
|
-
const
|
31
|
-
const
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
export
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
const collectionTemplate = (name) => `import { isThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
42
|
-
import
|
43
|
-
import
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
};
|
71
|
-
|
72
|
-
|
1
|
+
const fs = require("fs").promises;
|
2
|
+
const path = require("path");
|
3
|
+
|
4
|
+
const collectionName = process.argv[2] || "SAP-icons";
|
5
|
+
const collectionVersion = process.argv[3];
|
6
|
+
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
7
|
+
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
8
|
+
|
9
|
+
const iconTemplate = (name, pathData, ltr, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
10
|
+
|
11
|
+
const name = "${name}";
|
12
|
+
const pathData = "${pathData}";
|
13
|
+
const ltr = ${ltr};
|
14
|
+
const accData = null;
|
15
|
+
const collection = "${collection}";
|
16
|
+
const packageName = "${packageName}";
|
17
|
+
|
18
|
+
registerIcon(name, { pathData, ltr, collection, packageName });
|
19
|
+
|
20
|
+
export default "${name}";
|
21
|
+
export { pathData, ltr, accData };`;
|
22
|
+
|
23
|
+
|
24
|
+
const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
25
|
+
import { ${accData.key} } from "../generated/i18n/i18n-defaults.js";
|
26
|
+
|
27
|
+
const name = "${name}";
|
28
|
+
const pathData = "${pathData}";
|
29
|
+
const ltr = ${ltr};
|
30
|
+
const accData = ${accData.key};
|
31
|
+
const collection = "${collection}";
|
32
|
+
const packageName = "${packageName}";
|
33
|
+
|
34
|
+
registerIcon(name, { pathData, ltr, accData, collection, packageName });
|
35
|
+
|
36
|
+
export default "${name}";
|
37
|
+
export { pathData, ltr, accData };`;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
const collectionTemplate = (name) => `import { isThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
42
|
+
import {pathData as pathDataV5, ltr, accData} from "./v5/${name}.js";
|
43
|
+
import {pathData as pathDataV4} from "./v4/${name}.js";
|
44
|
+
|
45
|
+
const pathData = isThemeFamily("sap_horizon") ? pathDataV5 : pathDataV4;
|
46
|
+
|
47
|
+
export default "${name}";
|
48
|
+
export { pathData, ltr, accData };`;
|
49
|
+
|
50
|
+
|
51
|
+
const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
52
|
+
<path d="${pathData}"/>
|
53
|
+
</svg>`;
|
54
|
+
|
55
|
+
const createIcons = async (file) => {
|
56
|
+
await fs.mkdir(destDir, { recursive: true });
|
57
|
+
|
58
|
+
const json = JSON.parse(await fs.readFile(file));
|
59
|
+
|
60
|
+
const promises = [];
|
61
|
+
for (let name in json.data) {
|
62
|
+
const iconData = json.data[name];
|
63
|
+
const pathData = iconData.path;
|
64
|
+
const ltr = !!iconData.ltr;
|
65
|
+
const acc = iconData.acc;
|
66
|
+
|
67
|
+
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, json.collection, json.packageName) : iconTemplate(name, pathData, ltr, json.collection, json.packageName);
|
68
|
+
|
69
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
|
70
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
|
71
|
+
|
72
|
+
if (json.version) {
|
73
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name)));
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
return Promise.all(promises);
|
78
|
+
};
|
79
|
+
|
80
|
+
createIcons(srcFile).then(() => {
|
81
|
+
console.log("Icons created.");
|
82
|
+
});
|
@@ -1,87 +1,90 @@
|
|
1
|
-
const fs = require("fs");
|
1
|
+
const fs = require("fs").promises;
|
2
2
|
const path = require("path");
|
3
|
-
const mkdirp = require("mkdirp");
|
4
3
|
|
5
4
|
if (process.argv.length < 7) {
|
6
|
-
|
5
|
+
throw new Error("Not enough arguments");
|
7
6
|
}
|
8
7
|
|
9
|
-
const
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
const
|
57
|
-
const
|
58
|
-
const
|
59
|
-
const
|
8
|
+
const generate = async () => {
|
9
|
+
|
10
|
+
const ORIGINAL_TEXTS = {
|
11
|
+
UnableToLoad: "UnableToLoad",
|
12
|
+
UnableToUpload: "UnableToUpload",
|
13
|
+
NoActivities: "NoActivities",
|
14
|
+
BeforeSearch: "BeforeSearch",
|
15
|
+
NoSearchResults: "NoSearchResults",
|
16
|
+
NoEntries: "NoEntries",
|
17
|
+
NoData: "NoData",
|
18
|
+
NoNotifications: "NoNotifications",
|
19
|
+
BalloonSky: "BalloonSky",
|
20
|
+
SuccessScreen: "SuccessScreen",
|
21
|
+
NoMail: "NoMail",
|
22
|
+
NoSavedItems: "NoSavedItems",
|
23
|
+
NoTasks: "NoTasks"
|
24
|
+
};
|
25
|
+
|
26
|
+
const FALLBACK_TEXTS = {
|
27
|
+
ReloadScreen: ORIGINAL_TEXTS.UnableToLoad,
|
28
|
+
Connection: ORIGINAL_TEXTS.UnableToLoad,
|
29
|
+
ErrorScreen: ORIGINAL_TEXTS.UnableToUpload,
|
30
|
+
EmptyCalendar: ORIGINAL_TEXTS.NoActivities,
|
31
|
+
SearchEarth: ORIGINAL_TEXTS.BeforeSearch,
|
32
|
+
SearchFolder: ORIGINAL_TEXTS.NoSearchResults,
|
33
|
+
EmptyList: ORIGINAL_TEXTS.NoEntries,
|
34
|
+
Tent: ORIGINAL_TEXTS.NoData,
|
35
|
+
SleepingBell: ORIGINAL_TEXTS.NoNotifications,
|
36
|
+
SimpleBalloon: ORIGINAL_TEXTS.BalloonSky,
|
37
|
+
SimpleBell: ORIGINAL_TEXTS.NoNotifications,
|
38
|
+
SimpleCalendar: ORIGINAL_TEXTS.NoActivities,
|
39
|
+
SimpleCheckMark: ORIGINAL_TEXTS.SuccessScreen,
|
40
|
+
SimpleConnection: ORIGINAL_TEXTS.UnableToLoad,
|
41
|
+
SimpleEmptyDoc: ORIGINAL_TEXTS.NoData,
|
42
|
+
SimpleEmptyList: ORIGINAL_TEXTS.NoEntries,
|
43
|
+
SimpleError: ORIGINAL_TEXTS.UnableToUpload,
|
44
|
+
SimpleMagnifier: ORIGINAL_TEXTS.BeforeSearch,
|
45
|
+
SimpleMail: ORIGINAL_TEXTS.NoMail,
|
46
|
+
SimpleNoSavedItems: ORIGINAL_TEXTS.NoSavedItems,
|
47
|
+
SimpleNotFoundMagnifier: ORIGINAL_TEXTS.NoSearchResults,
|
48
|
+
SimpleReload: ORIGINAL_TEXTS.UnableToLoad,
|
49
|
+
SimpleTask: ORIGINAL_TEXTS.NoTasks,
|
50
|
+
SuccessBalloon: ORIGINAL_TEXTS.BalloonSky,
|
51
|
+
SuccessCheckMark: ORIGINAL_TEXTS.SuccessScreen,
|
52
|
+
SuccessHighFive: ORIGINAL_TEXTS.BalloonSky
|
53
|
+
};
|
54
|
+
|
55
|
+
const srcPath = process.argv[2];
|
56
|
+
const defaultText = process.argv[3] === "true";
|
57
|
+
const illustrationsPrefix = process.argv[4];
|
58
|
+
const illustrationSet = process.argv[5];
|
59
|
+
const destPath = process.argv[6];
|
60
|
+
const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
|
60
61
|
// collect each illustration name because each one should have Sample.js file
|
61
|
-
const fileNames = new Set();
|
62
|
-
|
63
|
-
const svgImportTemplate = svgContent => {
|
64
|
-
|
65
|
-
|
66
|
-
const
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
62
|
+
const fileNames = new Set();
|
63
|
+
|
64
|
+
const svgImportTemplate = svgContent => {
|
65
|
+
return `export default \`${svgContent}\`;`
|
66
|
+
};
|
67
|
+
const svgToJs = async fileName => {
|
68
|
+
const svg = await fs.readFile(path.join(srcPath, fileName), {encoding: "utf-8"});
|
69
|
+
const fileContent = svgImportTemplate(svg);
|
70
|
+
fileName = fileName.replace(/\.svg$/, ".js");
|
71
|
+
|
72
|
+
return fs.writeFile(path.join(destPath, fileName), fileContent);
|
73
|
+
};
|
74
|
+
const illustrationImportTemplate = illustrationName => {
|
75
|
+
let illustrationNameForTranslation = illustrationName;
|
76
|
+
|
77
|
+
if (defaultText) {
|
78
|
+
if (FALLBACK_TEXTS[illustrationNameForTranslation]) {
|
79
|
+
illustrationNameForTranslation = FALLBACK_TEXTS[illustrationNameForTranslation];
|
80
|
+
} else if (illustrationName.indexOf("_v") !== -1) {
|
81
|
+
illustrationNameForTranslation = illustrationNameForTranslation.substr(0, illustrationNameForTranslation.indexOf('_v'));
|
82
|
+
}
|
79
83
|
}
|
80
|
-
}
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
+
const illustrationNameUpperCase = illustrationNameForTranslation.toUpperCase();
|
86
|
+
|
87
|
+
return defaultText ? `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
85
88
|
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
86
89
|
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
87
90
|
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
@@ -109,7 +112,7 @@ export {
|
|
109
112
|
sceneSvg,
|
110
113
|
spotSvg,
|
111
114
|
};` :
|
112
|
-
`import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
115
|
+
`import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
113
116
|
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
114
117
|
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
115
118
|
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
@@ -129,22 +132,30 @@ export {
|
|
129
132
|
sceneSvg,
|
130
133
|
spotSvg,
|
131
134
|
};`
|
132
|
-
};
|
135
|
+
};
|
136
|
+
|
137
|
+
await fs.mkdir(destPath, { recursive: true });
|
133
138
|
|
134
|
-
|
139
|
+
const illustrationFileNames = await fs.readdir(path.normalize(srcPath));
|
135
140
|
|
136
|
-
|
141
|
+
// convert SVG to JS imports
|
142
|
+
const promises = [];
|
143
|
+
illustrationFileNames.forEach(illustration => {
|
144
|
+
if (fileNamePattern.test(illustration)) {
|
145
|
+
let [fileName, illustrationName] = illustration.match(fileNamePattern);
|
137
146
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
147
|
+
promises.push(svgToJs(fileName));
|
148
|
+
fileNames.add(illustrationName);
|
149
|
+
}
|
150
|
+
});
|
142
151
|
|
143
|
-
|
144
|
-
|
152
|
+
for (let illustrationName of fileNames) {
|
153
|
+
promises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
|
145
154
|
}
|
146
|
-
});
|
147
155
|
|
148
|
-
|
149
|
-
|
150
|
-
|
156
|
+
return Promise.all(promises);
|
157
|
+
};
|
158
|
+
|
159
|
+
generate().then(() => {
|
160
|
+
console.log("Illustrations generated.");
|
161
|
+
});
|