@ui5/webcomponents-tools 2.15.0-rc.0 → 2.15.0-rc.3
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 +27 -0
- package/bin/dev.js +3 -2
- package/bin/ui5nps.js +261 -0
- package/components-package/nps.js +93 -82
- package/icons-collection/nps.js +30 -21
- package/lib/amd-to-es6/index.js +15 -10
- package/lib/cem/cem.js +12 -0
- package/lib/cem/validate.js +56 -47
- package/lib/copy-and-watch/index.js +105 -97
- package/lib/copy-list/index.js +16 -10
- package/lib/create-icons/index.js +19 -15
- package/lib/create-illustrations/index.js +28 -24
- package/lib/css-processors/css-processor-components.mjs +71 -61
- package/lib/css-processors/css-processor-themes.mjs +76 -66
- package/lib/generate-js-imports/illustrations.js +53 -54
- package/lib/generate-json-imports/i18n.js +14 -10
- package/lib/generate-json-imports/themes.js +15 -10
- package/lib/i18n/defaults.js +12 -7
- package/lib/i18n/toJSON.js +14 -10
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +34 -24
- package/lib/rimraf/rimraf.js +31 -0
- package/package.json +8 -10
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import ignore from "ignore";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
// -------------------
|
|
10
|
+
// FNV-1a 32-bit hash
|
|
11
|
+
// -------------------
|
|
12
|
+
function fnv1aHash(str) {
|
|
13
|
+
let hash = 0x811c9dc5;
|
|
14
|
+
for (let i = 0; i < str.length; i++) {
|
|
15
|
+
hash ^= str.charCodeAt(i);
|
|
16
|
+
hash = (hash * 0x01000193) >>> 0;
|
|
17
|
+
}
|
|
18
|
+
return hash.toString(16);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function findGitignoreFiles(startDir) {
|
|
22
|
+
const gitignores = [];
|
|
23
|
+
let currentDir = path.resolve(startDir);
|
|
24
|
+
while (true) {
|
|
25
|
+
const candidate = path.join(currentDir, ".gitignore");
|
|
26
|
+
try {
|
|
27
|
+
await fs.access(candidate);
|
|
28
|
+
gitignores.push(candidate);
|
|
29
|
+
} catch { }
|
|
30
|
+
const parentDir = path.dirname(currentDir);
|
|
31
|
+
if (parentDir === currentDir) break;
|
|
32
|
+
currentDir = parentDir;
|
|
33
|
+
}
|
|
34
|
+
return gitignores;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function loadIgnoreRules(dir) {
|
|
38
|
+
const files = await findGitignoreFiles(dir);
|
|
39
|
+
const ig = ignore();
|
|
40
|
+
for (const file of files) {
|
|
41
|
+
const content = await fs.readFile(file, "utf8");
|
|
42
|
+
ig.add(content);
|
|
43
|
+
}
|
|
44
|
+
return ig;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function walkDir(dir, ig, baseDir) {
|
|
48
|
+
const results = [];
|
|
49
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
50
|
+
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
const absPath = path.join(dir, entry.name);
|
|
53
|
+
let relPath = path.relative(baseDir, absPath).replace(/\\/g, "/"); // normalize for .gitignore
|
|
54
|
+
|
|
55
|
+
if (ig.ignores(relPath) || relPath.startsWith("dist/")) continue;
|
|
56
|
+
|
|
57
|
+
if (entry.isDirectory()) {
|
|
58
|
+
results.push(...await walkDir(absPath, ig, baseDir));
|
|
59
|
+
} else {
|
|
60
|
+
results.push(relPath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return results;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Hash file content + mtime
|
|
67
|
+
async function hashFile(filePath) {
|
|
68
|
+
const stat = await fs.stat(filePath);
|
|
69
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
70
|
+
return fnv1aHash(String(stat.mtimeMs) + content);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getRepoName(repoPath) {
|
|
74
|
+
return repoPath.split("/").pop();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function computeHashes(repoPath, ig) {
|
|
78
|
+
const files = await walkDir(repoPath, ig, repoPath);
|
|
79
|
+
const hashEntries = await Promise.all(
|
|
80
|
+
files.map(async (file) => {
|
|
81
|
+
const absPath = path.join(repoPath, file);
|
|
82
|
+
const hash = await hashFile(absPath);
|
|
83
|
+
return [path.relative(process.cwd(), absPath), hash];
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
return Object.fromEntries(hashEntries);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function saveHashes(repoPath, ig) {
|
|
90
|
+
const distPath = path.join(repoPath, "dist");
|
|
91
|
+
await fs.mkdir(distPath, { recursive: true });
|
|
92
|
+
const ui5iconsHashPath = path.join(distPath, ".ui5iconsHash");
|
|
93
|
+
|
|
94
|
+
// Cache the hashes for both the icons and tools packages, since the output depends on the content of both.
|
|
95
|
+
const hashes = {
|
|
96
|
+
...(await computeHashes(repoPath, ig)),
|
|
97
|
+
...(await computeHashes(path.resolve(__dirname, "../../"), ig)),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
await fs.writeFile(ui5iconsHashPath, JSON.stringify(hashes, null, 2), "utf8");
|
|
101
|
+
console.log(`Saved build hashes for the ${getRepoName(repoPath)} package.`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function checkHashes(repoPath, ig) {
|
|
105
|
+
const ui5iconsHashPath = path.join(repoPath, "dist", ".ui5iconsHash");
|
|
106
|
+
let oldHashes = {};
|
|
107
|
+
try {
|
|
108
|
+
const raw = await fs.readFile(ui5iconsHashPath, "utf8");
|
|
109
|
+
oldHashes = JSON.parse(raw);
|
|
110
|
+
} catch {
|
|
111
|
+
console.log(`No build hashes found for the ${getRepoName(repoPath)} package. Building it now.`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Compare the hashes for both the icons and tools packages, since the output depends on the content of both.
|
|
116
|
+
const newHashes = {
|
|
117
|
+
...(await computeHashes(repoPath, ig)),
|
|
118
|
+
...(await computeHashes(path.resolve(__dirname, "../../"), ig)),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
let changed = false;
|
|
122
|
+
for (const file of new Set([...Object.keys(oldHashes), ...Object.keys(newHashes)])) {
|
|
123
|
+
if (oldHashes[file] !== newHashes[file]) {
|
|
124
|
+
changed = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!changed) {
|
|
129
|
+
console.log(`No changes detected in the ${getRepoName(repoPath)} package.`);
|
|
130
|
+
} else {
|
|
131
|
+
console.log(`Changes detected in the ${getRepoName(repoPath)} package. Rebuilding it.`);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function main() {
|
|
137
|
+
const mode = process.argv[2];
|
|
138
|
+
if (!["save", "check"].includes(mode)) {
|
|
139
|
+
throw new Error("Usage: node hashes.js <save|check>");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const repoPath = process.cwd();
|
|
143
|
+
const ig = await loadIgnoreRules(repoPath);
|
|
144
|
+
|
|
145
|
+
if (mode === "save") await saveHashes(repoPath, ig);
|
|
146
|
+
if (mode === "check") await checkHashes(repoPath, ig);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
main().catch(console.error);
|
|
@@ -2,36 +2,46 @@ import { globby } from "globby";
|
|
|
2
2
|
import * as esbuild from 'esbuild'
|
|
3
3
|
import * as fs from "fs";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const generate = async () => {
|
|
6
|
+
let customPlugin = {
|
|
6
7
|
name: 'ui5-tools',
|
|
7
8
|
setup(build) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
9
|
+
build.onLoad({ filter: /UI5Element.ts$/ }, async (args) => {
|
|
10
|
+
let text = await fs.promises.readFile(args.path, 'utf8');
|
|
11
|
+
text = text.replaceAll(/const DEV_MODE = true/g, "");
|
|
12
|
+
text = text.replaceAll(/if \(DEV_MODE\)/g, "if (false)");
|
|
13
|
+
return {
|
|
14
|
+
contents: text,
|
|
15
|
+
loader: 'ts',
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
}
|
|
19
20
|
|
|
20
|
-
const getConfig = async () => {
|
|
21
|
+
const getConfig = async () => {
|
|
21
22
|
const config = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
entryPoints: await globby("src/**/*.ts"),
|
|
24
|
+
bundle: false,
|
|
25
|
+
minify: true,
|
|
26
|
+
sourcemap: true,
|
|
27
|
+
outdir: 'dist/prod',
|
|
28
|
+
outbase: 'src',
|
|
29
|
+
plugins: [
|
|
30
|
+
customPlugin,
|
|
31
|
+
]
|
|
31
32
|
};
|
|
32
33
|
return config;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
const config = await getConfig();
|
|
38
|
+
const result = await esbuild.build(config);
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
42
|
+
generate()
|
|
43
|
+
}
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
export default {
|
|
46
|
+
_ui5mainFn: generate
|
|
47
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const rimraf = dir => {
|
|
5
|
+
if (fs.existsSync(dir)) {
|
|
6
|
+
fs.readdirSync(dir).forEach(entry => {
|
|
7
|
+
const entryPath = path.join(dir, entry);
|
|
8
|
+
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
9
|
+
rimraf(entryPath);
|
|
10
|
+
} else {
|
|
11
|
+
fs.unlinkSync(entryPath);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
fs.rmdirSync(dir);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const main = argv => {
|
|
19
|
+
if (argv.length < 3) {
|
|
20
|
+
console.error("rimraf <dir>");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const dir = argv[2];
|
|
24
|
+
rimraf(dir);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (require.main === module) {
|
|
28
|
+
main(process.argv)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports._ui5mainFn = main;
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
|
3
|
-
"version": "2.15.0-rc.
|
|
3
|
+
"version": "2.15.0-rc.3",
|
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"private": false,
|
|
8
7
|
"keywords": [
|
|
9
8
|
"openui5",
|
|
10
9
|
"sapui5",
|
|
11
10
|
"ui5"
|
|
12
11
|
],
|
|
13
|
-
"scripts": {},
|
|
14
12
|
"bin": {
|
|
15
|
-
"
|
|
16
|
-
"wc-create-ui5-element": "bin/create-ui5-element.js"
|
|
13
|
+
"ui5nps": "bin/ui5nps.js",
|
|
14
|
+
"wc-create-ui5-element": "bin/create-ui5-element.js",
|
|
15
|
+
"wc-dev": "bin/dev.js"
|
|
17
16
|
},
|
|
18
17
|
"repository": {
|
|
19
18
|
"type": "git",
|
|
@@ -21,7 +20,7 @@
|
|
|
21
20
|
"directory": "packages/tools"
|
|
22
21
|
},
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"@custom-elements-manifest/analyzer": "
|
|
23
|
+
"@custom-elements-manifest/analyzer": "patch:@custom-elements-manifest/analyzer@npm%3A0.10.6#~/.yarn/patches/@custom-elements-manifest-analyzer-npm-0.10.6-9b5ff0c50b.patch",
|
|
25
24
|
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
26
25
|
"@typescript-eslint/parser": "^6.9.0",
|
|
27
26
|
"@wdio/cli": "^7.19.7",
|
|
@@ -38,7 +37,6 @@
|
|
|
38
37
|
"chokidar-cli": "^3.0.0",
|
|
39
38
|
"command-line-args": "^5.1.1",
|
|
40
39
|
"comment-parser": "^1.4.0",
|
|
41
|
-
"concurrently": "^6.0.0",
|
|
42
40
|
"cross-env": "^7.0.3",
|
|
43
41
|
"custom-element-jet-brains-integration": "^1.4.4",
|
|
44
42
|
"dotenv": "^16.5.0",
|
|
@@ -53,10 +51,10 @@
|
|
|
53
51
|
"glob-parent": "^6.0.2",
|
|
54
52
|
"globby": "^13.1.1",
|
|
55
53
|
"handlebars": "^4.7.7",
|
|
54
|
+
"ignore": "^7.0.5",
|
|
56
55
|
"is-port-reachable": "^3.1.0",
|
|
57
56
|
"json-beautify": "^1.1.1",
|
|
58
57
|
"mkdirp": "^1.0.4",
|
|
59
|
-
"nps": "^5.10.0",
|
|
60
58
|
"postcss": "^8.4.5",
|
|
61
59
|
"postcss-cli": "^9.1.0",
|
|
62
60
|
"postcss-selector-parser": "^6.0.10",
|
|
@@ -64,8 +62,8 @@
|
|
|
64
62
|
"properties-reader": "^2.2.0",
|
|
65
63
|
"recursive-readdir": "^2.2.2",
|
|
66
64
|
"resolve": "^1.20.0",
|
|
67
|
-
"rimraf": "^3.0.2",
|
|
68
65
|
"slash": "3.0.0",
|
|
66
|
+
"string-argv": "^0.3.2",
|
|
69
67
|
"vite": "^5.4.8",
|
|
70
68
|
"vite-plugin-istanbul": "^6.0.2",
|
|
71
69
|
"wdio-chromedriver-service": "^7.3.2"
|
|
@@ -83,5 +81,5 @@
|
|
|
83
81
|
"esbuild": "^0.25.0",
|
|
84
82
|
"yargs": "^17.5.1"
|
|
85
83
|
},
|
|
86
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "be8dc39a71bc2df6b14528e50a243ce48c9015c5"
|
|
87
85
|
}
|