@ui5/webcomponents-tools 1.2.6 → 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 +17 -3
- package/components-package/nps.js +10 -21
- package/components-package/postcss.themes.js +1 -1
- package/components-package/rollup.js +9 -98
- package/components-package/wdio.js +1 -1
- package/icons-collection/nps.js +1 -7
- package/lib/copy-and-watch/index.js +24 -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 +12 -3
- 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/postcss-combine-duplicated-selectors/index.js +178 -0
- package/lib/postcss-p/postcss-p.mjs +11 -0
- package/lib/replace-global-core/index.js +13 -8
- package/package.json +6 -12
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
- package/lib/polyfill-placeholder/index.js +0 -5
package/CHANGELOG.md
CHANGED
@@ -3,15 +3,18 @@
|
|
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
|
-
|
6
|
+
# [1.4.0](https://github.com/SAP/ui5-webcomponents/compare/v1.3.1...v1.4.0) (2022-05-25)
|
7
7
|
|
8
|
-
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
**Note:** Version bump only for package @ui5/webcomponents-icons-tnt
|
9
12
|
|
10
13
|
|
11
14
|
|
12
15
|
|
13
16
|
|
14
|
-
## [1.
|
17
|
+
## [1.3.1](https://github.com/SAP/ui5-webcomponents/compare/v1.3.0...v1.3.1) (2022-04-27)
|
15
18
|
|
16
19
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
17
20
|
|
@@ -19,6 +22,17 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
19
22
|
|
20
23
|
|
21
24
|
|
25
|
+
# [1.3.0](https://github.com/SAP/ui5-webcomponents/compare/v1.2.4...v1.3.0) (2022-04-19)
|
26
|
+
|
27
|
+
|
28
|
+
### Bug Fixes
|
29
|
+
|
30
|
+
* **localization:** fix js error if "sh" locale set ([#4905](https://github.com/SAP/ui5-webcomponents/issues/4905)) ([979bca2](https://github.com/SAP/ui5-webcomponents/commit/979bca2)), closes [#4904](https://github.com/SAP/ui5-webcomponents/issues/4904)
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
22
36
|
## [1.2.4](https://github.com/SAP/ui5-webcomponents/compare/v1.2.3...v1.2.4) (2022-03-30)
|
23
37
|
|
24
38
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
@@ -2,8 +2,6 @@ const path = require("path");
|
|
2
2
|
const fs = require("fs");
|
3
3
|
|
4
4
|
const LIB = path.join(__dirname, `../lib/`);
|
5
|
-
const polyfillDir = path.dirname(require.resolve("@webcomponents/webcomponentsjs"));
|
6
|
-
const polyfillPath = path.join(polyfillDir, "{*.js,*.map,*.md,bundles/**/*.*}");
|
7
5
|
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
8
6
|
|
9
7
|
const getScripts = (options) => {
|
@@ -21,15 +19,16 @@ const getScripts = (options) => {
|
|
21
19
|
lint: "eslint . --config config/.eslintrc.js",
|
22
20
|
lintfix: "eslint . --config config/.eslintrc.js --fix",
|
23
21
|
prepare: {
|
24
|
-
default: "nps clean
|
25
|
-
|
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",
|
26
25
|
},
|
27
26
|
build: {
|
28
|
-
default: "nps lint prepare
|
27
|
+
default: "nps lint prepare build.bundle",
|
29
28
|
templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
|
30
29
|
styles: {
|
31
30
|
default: "nps build.styles.themes build.styles.components",
|
32
|
-
themes: "postcss
|
31
|
+
themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
|
33
32
|
components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
|
34
33
|
},
|
35
34
|
i18n: {
|
@@ -42,7 +41,7 @@ const getScripts = (options) => {
|
|
42
41
|
themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
|
43
42
|
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
|
44
43
|
},
|
45
|
-
bundle: "rollup --config config/rollup.config.js
|
44
|
+
bundle: "rollup --config config/rollup.config.js",
|
46
45
|
samples: {
|
47
46
|
default: "nps build.samples.api build.samples.docs",
|
48
47
|
api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
|
@@ -51,24 +50,17 @@ const getScripts = (options) => {
|
|
51
50
|
illustrations: illustrationsScript
|
52
51
|
},
|
53
52
|
copy: {
|
54
|
-
default: "nps copy.src copy.props copy.test
|
55
|
-
es5: "nps copy.src copy.props copy.test copy.webcomponents-polyfill",
|
53
|
+
default: "nps copy.src copy.props copy.test",
|
56
54
|
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
57
55
|
props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
|
58
56
|
test: `node "${LIB}/copy-and-watch/index.js" --silent "test/**/*.*" dist/test-resources`,
|
59
|
-
"webcomponents-polyfill": `node "${LIB}/copy-and-watch/index.js" --silent "${polyfillPath}" dist/webcomponentsjs/`,
|
60
|
-
"webcomponents-polyfill-placeholder": `node "${LIB}/polyfill-placeholder/index.js"`
|
61
57
|
},
|
62
58
|
watch: {
|
63
59
|
default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles" "nps watch.i18n"',
|
64
|
-
es5: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle.es5" "nps watch.styles" "nps watch.i18n"',
|
65
60
|
src: 'nps "copy.src --watch --safe --skip-initial-copy"',
|
66
61
|
props: 'nps "copy.props --watch --safe --skip-initial-copy"',
|
67
62
|
test: 'nps "copy.test --watch --safe --skip-initial-copy"',
|
68
|
-
bundle:
|
69
|
-
default: 'rollup --config config/rollup.config.js -w --environment DEV,DEPLOY_PUBLIC_PATH:/resources/',
|
70
|
-
es5: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,DEPLOY_PUBLIC_PATH:/resources/'
|
71
|
-
},
|
63
|
+
bundle: 'rollup --config config/rollup.config.js -w --environment DEV',
|
72
64
|
styles: {
|
73
65
|
default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
|
74
66
|
themes: 'nps "build.styles.themes -w"',
|
@@ -82,10 +74,7 @@ const getScripts = (options) => {
|
|
82
74
|
samples: 'chokidar "test/**/*.sample.html" -c "nps build.samples"',
|
83
75
|
i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
|
84
76
|
},
|
85
|
-
dev:
|
86
|
-
default: 'concurrently "nps serve" "nps watch"',
|
87
|
-
es5: 'concurrently "nps serve" "nps watch.es5"'
|
88
|
-
},
|
77
|
+
dev: 'concurrently "nps serve" "nps watch"',
|
89
78
|
start: "nps prepare dev",
|
90
79
|
serve: `node "${LIB}/serve/index.js" --dir="dist/" --port=${port} --portStep=${portStep} --packageName="${packageName}"`,
|
91
80
|
test: {
|
@@ -106,7 +95,7 @@ const getScripts = (options) => {
|
|
106
95
|
},
|
107
96
|
dev: 'concurrently "nps serve" "nps scope.watch"',
|
108
97
|
watch: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.props" "nps scope.bundle" "nps watch.styles"',
|
109
|
-
bundle: 'rollup --config config/rollup.config.js -w --environment
|
98
|
+
bundle: 'rollup --config config/rollup.config.js -w --environment DEV,SCOPE'
|
110
99
|
}
|
111
100
|
};
|
112
101
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
const postcssImport = require('postcss-import');
|
2
|
-
const combineSelectors = require('postcss-combine-duplicated-selectors');
|
2
|
+
const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
|
3
3
|
const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
|
4
4
|
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
5
5
|
const cssnano = require('cssnano');
|
@@ -1,21 +1,16 @@
|
|
1
1
|
const process = require("process");
|
2
2
|
const fs = require("fs");
|
3
3
|
const os = require("os");
|
4
|
-
const { babel } = require("@rollup/plugin-babel");
|
5
4
|
const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
6
|
-
const url = require("@rollup/plugin-url");
|
7
5
|
const { terser } = require("rollup-plugin-terser");
|
8
6
|
const json = require("@rollup/plugin-json");
|
9
7
|
const replace = require("@rollup/plugin-replace");
|
10
|
-
const commonjs = require("@rollup/plugin-commonjs");
|
11
8
|
const colors = require("cli-color");
|
12
|
-
const filesize = require("rollup-plugin-filesize");
|
13
9
|
const livereload = require("rollup-plugin-livereload");
|
14
10
|
const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
|
15
11
|
|
16
12
|
const packageFile = JSON.parse(fs.readFileSync("./package.json"));
|
17
13
|
const packageName = packageFile.name;
|
18
|
-
const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
|
19
14
|
|
20
15
|
const warningsToSkip = [{
|
21
16
|
warningCode: "THIS_IS_UNDEFINED",
|
@@ -72,7 +67,7 @@ function ui5DevReadyMessagePlugin() {
|
|
72
67
|
};
|
73
68
|
}
|
74
69
|
|
75
|
-
const getPlugins = (
|
70
|
+
const getPlugins = () => {
|
76
71
|
const plugins = [];
|
77
72
|
|
78
73
|
if (process.env.DEV) {
|
@@ -93,59 +88,14 @@ const getPlugins = ({ transpile }) => {
|
|
93
88
|
}));
|
94
89
|
}
|
95
90
|
|
96
|
-
if (!process.env.DEV) {
|
97
|
-
plugins.push(filesize(
|
98
|
-
{
|
99
|
-
reporter(options, bundle, {
|
100
|
-
minSize, gzipSize, brotliSize, bundleSize,
|
101
|
-
fileName,
|
102
|
-
// "showBeforeSizes: release"
|
103
|
-
lastVersion,
|
104
|
-
// "showBeforeSizes: "release" or "showBeforeSizes": "build"
|
105
|
-
bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
|
106
|
-
}) {
|
107
|
-
// If a promise is returned, it will be awaited before rendering.
|
108
|
-
return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
|
109
|
-
},
|
110
|
-
},
|
111
|
-
|
112
|
-
));
|
113
|
-
}
|
114
|
-
|
115
|
-
const publicPath = DEPLOY_PUBLIC_PATH;
|
116
|
-
|
117
91
|
plugins.push(ui5DevImportCheckerPlugin());
|
118
92
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}));
|
126
|
-
}
|
127
|
-
|
128
|
-
if (transpile) {
|
129
|
-
plugins.push(url({
|
130
|
-
limit: 0,
|
131
|
-
include: [
|
132
|
-
/.*assets\/.*\.json/,
|
133
|
-
],
|
134
|
-
emitFiles: true,
|
135
|
-
fileName: "[name].[hash][extname]",
|
136
|
-
publicPath,
|
137
|
-
}));
|
138
|
-
}
|
139
|
-
|
140
|
-
if (transpile) {
|
141
|
-
plugins.push(commonjs());
|
142
|
-
plugins.push(babel({
|
143
|
-
presets: ["@babel/preset-env"],
|
144
|
-
exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
|
145
|
-
sourcemap: false,
|
146
|
-
babelHelpers: "bundled",
|
147
|
-
}));
|
148
|
-
}
|
93
|
+
plugins.push(json({
|
94
|
+
include: [
|
95
|
+
/.*assets\/.*\.json/,
|
96
|
+
],
|
97
|
+
namedExports: false,
|
98
|
+
}));
|
149
99
|
|
150
100
|
plugins.push(nodeResolve());
|
151
101
|
|
@@ -155,7 +105,7 @@ const getPlugins = ({ transpile }) => {
|
|
155
105
|
}));
|
156
106
|
}
|
157
107
|
|
158
|
-
const es6DevMain = process.env.DEV &&
|
108
|
+
const es6DevMain = process.env.DEV && packageName === "@ui5/webcomponents";
|
159
109
|
if (es6DevMain && os.platform() !== "win32") {
|
160
110
|
plugins.push(livereload({
|
161
111
|
watch: [
|
@@ -181,58 +131,19 @@ const getES6Config = (input = "bundle.esm.js") => {
|
|
181
131
|
format: "esm",
|
182
132
|
sourcemap: true,
|
183
133
|
},
|
184
|
-
moduleContext: id => {
|
185
|
-
if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
|
186
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
187
|
-
return "window";
|
188
|
-
}
|
189
|
-
},
|
190
|
-
watch: {
|
191
|
-
clearScreen: false,
|
192
|
-
},
|
193
|
-
plugins: getPlugins({ transpile: false }),
|
194
|
-
onwarn: onwarn,
|
195
|
-
}];
|
196
|
-
};
|
197
|
-
|
198
|
-
const getES5Config = (input = "bundle.es5.js") => {
|
199
|
-
return [{
|
200
|
-
input,
|
201
|
-
output: {
|
202
|
-
dir: "dist/resources",
|
203
|
-
format: "iife",
|
204
|
-
inlineDynamicImports: true,
|
205
|
-
name: "sap-ui-webcomponents-bundle",
|
206
|
-
extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
|
207
|
-
sourcemap: true,
|
208
|
-
},
|
209
|
-
moduleContext: id => {
|
210
|
-
if (id.includes("url-search-params-polyfill")) {
|
211
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
212
|
-
return "window";
|
213
|
-
}
|
214
|
-
},
|
215
134
|
watch: {
|
216
135
|
clearScreen: false,
|
217
136
|
},
|
218
|
-
plugins: getPlugins(
|
137
|
+
plugins: getPlugins(),
|
219
138
|
onwarn: onwarn,
|
220
139
|
}];
|
221
140
|
};
|
222
141
|
|
223
142
|
let config = getES6Config();
|
224
143
|
|
225
|
-
if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
|
226
|
-
config = config.concat(getES5Config());
|
227
|
-
}
|
228
|
-
|
229
144
|
if (process.env.SCOPE) {
|
230
145
|
if (fs.existsSync("bundle.scoped.esm.js")) {
|
231
146
|
config = config.concat(getES6Config("bundle.scoped.esm.js"));
|
232
|
-
|
233
|
-
if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
|
234
|
-
config = config.concat(getES5Config("bundle.scoped.es5.js"));
|
235
|
-
}
|
236
147
|
}
|
237
148
|
}
|
238
149
|
|
@@ -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;
|
@@ -1,9 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Copyright (c) 2017
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
1
25
|
const fs = require('fs');
|
2
26
|
const path = require('path');
|
3
27
|
const chokidar = require('chokidar');
|
4
28
|
const glob = require('glob');
|
5
29
|
const globParent = require('glob-parent');
|
6
|
-
require('colors');
|
7
30
|
|
8
31
|
/* CODE */
|
9
32
|
|
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
|
+
});
|