@ui5/webcomponents-tools 0.0.0-deac3098a → 0.0.0-df5b4199a
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 +2155 -0
- package/LICENSE.txt +201 -0
- package/README.md +7 -10
- package/assets-meta.js +12 -11
- package/bin/dev.js +3 -6
- package/bin/ui5nps.js +265 -0
- package/components-package/eslint.js +66 -2
- package/components-package/nps.js +140 -80
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -26
- package/components-package/vite.config.js +9 -0
- package/components-package/wdio.js +69 -17
- package/icons-collection/nps.js +32 -24
- package/lib/amd-to-es6/index.js +107 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/cem.js +12 -0
- package/lib/cem/custom-elements-manifest.config.mjs +546 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
- package/lib/cem/schema-internal.json +1422 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +808 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +423 -0
- package/lib/cem/validate.js +76 -0
- package/lib/chokidar/chokidar.js +29 -0
- package/lib/copy-and-watch/index.js +128 -97
- package/lib/copy-list/index.js +26 -20
- package/lib/create-icons/index.js +131 -72
- package/lib/create-illustrations/index.js +169 -114
- package/lib/create-new-component/Component.js +74 -0
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +62 -101
- package/lib/css-processors/css-processor-components.mjs +92 -0
- package/lib/css-processors/css-processor-themes.mjs +118 -0
- package/lib/css-processors/scope-variables.mjs +57 -0
- package/lib/css-processors/shared.mjs +46 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.mjs +78 -0
- package/lib/dev-server/virtual-index-html-plugin.js +56 -0
- package/lib/eslint/eslint.js +42 -0
- package/lib/generate-js-imports/illustrations.js +85 -0
- package/lib/generate-json-imports/i18n.js +70 -70
- package/lib/generate-json-imports/themes.js +47 -49
- package/lib/hbs2lit/src/compiler.js +17 -6
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +85 -22
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +39 -6
- package/lib/hbs2ui5/index.js +57 -24
- package/lib/i18n/defaults.js +74 -60
- package/lib/i18n/toJSON.js +22 -18
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
- package/lib/rimraf/rimraf.js +31 -0
- package/lib/scoping/get-all-tags.js +11 -11
- package/lib/scoping/lint-src.js +8 -7
- package/lib/scoping/scope-test-pages.js +2 -1
- package/lib/test-runner/test-runner.js +79 -0
- package/package.json +47 -44
- package/tsconfig.json +18 -0
- package/components-package/rollup-plugins/empty-module.js +0 -15
- package/components-package/rollup.js +0 -239
- package/components-package/wdio.sync.js +0 -360
- package/lib/documentation/index.js +0 -165
- package/lib/documentation/templates/api-component-since.js +0 -3
- package/lib/documentation/templates/api-css-variables-section.js +0 -24
- package/lib/documentation/templates/api-events-section.js +0 -35
- package/lib/documentation/templates/api-methods-section.js +0 -26
- package/lib/documentation/templates/api-properties-section.js +0 -42
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -39
- package/lib/esm-abs-to-rel/index.js +0 -54
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2436
- package/lib/jsdoc/template/publish.js +0 -4112
- package/lib/polyfill-placeholder/index.js +0 -5
- package/lib/postcss-css-to-esm/index.js +0 -45
- package/lib/postcss-css-to-json/index.js +0 -36
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/postcss-p/postcss-p.mjs +0 -11
- package/lib/replace-global-core/index.js +0 -20
- package/lib/serve/index.js +0 -46
- package/lib/serve/serve.json +0 -3
- package/package-lock.json +0 -48
|
@@ -1,122 +1,153 @@
|
|
|
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
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
33
|
+
const copyAndWatchFn = async (argv) => {
|
|
34
|
+
const args = argv.slice(2);
|
|
35
|
+
const options = {};
|
|
12
36
|
|
|
13
|
-
['watch', 'clean', 'skip-initial-copy', 'safe',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
|
|
38
|
+
const index = args.indexOf(`--${key}`);
|
|
39
|
+
if (index >= 0) {
|
|
40
|
+
options[key] = true;
|
|
41
|
+
args.splice(index, 1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (args.length < 2) {
|
|
46
|
+
console.error('Not enough arguments: copy-and-watch [options] <sources> <target>');
|
|
47
|
+
process.exit(1);
|
|
18
48
|
}
|
|
19
|
-
});
|
|
20
49
|
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
50
|
+
if (options['skip-initial-copy'] && !options['watch']) {
|
|
51
|
+
console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
25
54
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
55
|
+
const target = args.pop();
|
|
56
|
+
const sources = args;
|
|
57
|
+
const parents = [...new Set(sources.map(globParent))];
|
|
30
58
|
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return path.join(target, path.relative(parent, from));
|
|
41
|
-
};
|
|
42
|
-
const createDirIfNotExist = to => {
|
|
43
|
-
'use strict';
|
|
44
|
-
|
|
45
|
-
const dirs = [];
|
|
46
|
-
let dir = path.dirname(to);
|
|
47
|
-
|
|
48
|
-
while (dir !== path.dirname(dir)) {
|
|
49
|
-
dirs.unshift(dir);
|
|
50
|
-
dir = path.dirname(dir);
|
|
51
|
-
}
|
|
59
|
+
const findTarget = from => {
|
|
60
|
+
const parent = parents
|
|
61
|
+
.filter(p => from.indexOf(p) >= 0)
|
|
62
|
+
.sort()
|
|
63
|
+
.reverse()[0];
|
|
64
|
+
return path.join(target, path.relative(parent, from));
|
|
65
|
+
};
|
|
66
|
+
const createDirIfNotExist = to => {
|
|
67
|
+
'use strict';
|
|
52
68
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
69
|
+
const dirs = [];
|
|
70
|
+
let dir = path.dirname(to);
|
|
71
|
+
|
|
72
|
+
while (dir !== path.dirname(dir)) {
|
|
73
|
+
dirs.unshift(dir);
|
|
74
|
+
dir = path.dirname(dir);
|
|
56
75
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
createDirIfNotExist(to);
|
|
62
|
-
const stats = fs.statSync(from);
|
|
63
|
-
if (stats.isDirectory()) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
fs.writeFileSync(to, fs.readFileSync(from));
|
|
67
|
-
options.silent || console.log('[COPY]'.yellow, from, 'to'.yellow, to);
|
|
68
|
-
};
|
|
69
|
-
const remove = from => {
|
|
70
|
-
const to = findTarget(from);
|
|
71
|
-
fs.unlinkSync(to);
|
|
72
|
-
options.silent || console.log('[DELETE]'.yellow, to);
|
|
73
|
-
};
|
|
74
|
-
const rimraf = dir => {
|
|
75
|
-
if (fs.existsSync(dir)) {
|
|
76
|
-
fs.readdirSync(dir).forEach(entry => {
|
|
77
|
-
const entryPath = path.join(dir, entry);
|
|
78
|
-
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
79
|
-
rimraf(entryPath);
|
|
80
|
-
} else {
|
|
81
|
-
fs.unlinkSync(entryPath);
|
|
76
|
+
|
|
77
|
+
dirs.forEach(dir => {
|
|
78
|
+
if (!fs.existsSync(dir)) {
|
|
79
|
+
fs.mkdirSync(dir);
|
|
82
80
|
}
|
|
83
81
|
});
|
|
84
|
-
|
|
82
|
+
};
|
|
83
|
+
const copy = from => {
|
|
84
|
+
const to = findTarget(from);
|
|
85
|
+
createDirIfNotExist(to);
|
|
86
|
+
const stats = fs.statSync(from);
|
|
87
|
+
if (stats.isDirectory()) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
fs.writeFileSync(to, fs.readFileSync(from));
|
|
91
|
+
options.silent || console.log('[COPY]', from, 'to', to);
|
|
92
|
+
};
|
|
93
|
+
const remove = from => {
|
|
94
|
+
const to = findTarget(from);
|
|
95
|
+
fs.unlinkSync(to);
|
|
96
|
+
options.silent || console.log('[DELETE]', to);
|
|
97
|
+
};
|
|
98
|
+
const rimraf = dir => {
|
|
99
|
+
if (fs.existsSync(dir)) {
|
|
100
|
+
fs.readdirSync(dir).forEach(entry => {
|
|
101
|
+
const entryPath = path.join(dir, entry);
|
|
102
|
+
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
103
|
+
rimraf(entryPath);
|
|
104
|
+
} else {
|
|
105
|
+
fs.unlinkSync(entryPath);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
fs.rmdirSync(dir);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// clean
|
|
113
|
+
if (options.clean) {
|
|
114
|
+
rimraf(target);
|
|
85
115
|
}
|
|
86
|
-
};
|
|
87
116
|
|
|
88
|
-
//
|
|
89
|
-
if (options
|
|
90
|
-
|
|
91
|
-
}
|
|
117
|
+
// initial copy
|
|
118
|
+
if (!options['skip-initial-copy']) {
|
|
119
|
+
sources.forEach(s => glob.sync(s).forEach(copy));
|
|
120
|
+
}
|
|
92
121
|
|
|
93
|
-
//
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
122
|
+
// watch
|
|
123
|
+
if (options.watch) {
|
|
124
|
+
const chokidarOptions = {
|
|
125
|
+
ignoreInitial: true
|
|
126
|
+
};
|
|
97
127
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
128
|
+
if (options.safe) {
|
|
129
|
+
chokidarOptions.awaitWriteFinish = {
|
|
130
|
+
stabilityThreshold: 500,
|
|
131
|
+
pollInterval: 100
|
|
132
|
+
};
|
|
133
|
+
}
|
|
103
134
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
135
|
+
chokidar
|
|
136
|
+
.watch(sources, chokidarOptions)
|
|
137
|
+
.on('ready', () => sources.forEach(s => {
|
|
138
|
+
options.silent || console.log('[WATCH]', s);
|
|
139
|
+
}))
|
|
140
|
+
.on('add', copy)
|
|
141
|
+
.on('addDir', copy)
|
|
142
|
+
.on('change', copy)
|
|
143
|
+
.on('unlink', remove)
|
|
144
|
+
.on('unlinkDir', remove)
|
|
145
|
+
.on('error', e => console.log('[ERROR]', e));
|
|
109
146
|
}
|
|
147
|
+
}
|
|
110
148
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.on('ready', () => sources.forEach(s => {
|
|
114
|
-
options.silent || console.log('[WATCH]'.yellow, s);
|
|
115
|
-
}))
|
|
116
|
-
.on('add', copy)
|
|
117
|
-
.on('addDir', copy)
|
|
118
|
-
.on('change', copy)
|
|
119
|
-
.on('unlink', remove)
|
|
120
|
-
.on('unlinkDir', remove)
|
|
121
|
-
.on('error', e => console.log('[ERROR]'.red, e));
|
|
149
|
+
if (require.main === module) {
|
|
150
|
+
copyAndWatchFn(process.argv)
|
|
122
151
|
}
|
|
152
|
+
|
|
153
|
+
exports._ui5mainFn = copyAndWatchFn;
|
package/lib/copy-list/index.js
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
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
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const generate = async (argv) => {
|
|
5
|
+
const fileList = argv[2];
|
|
6
|
+
const dest = argv[3];
|
|
7
|
+
const src = "@openui5/sap.ui.core/src/";
|
|
8
|
+
const filesToCopy = (await fs.readFile(fileList)).toString();
|
|
9
|
+
// console.log(filesToCopy);
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
// Support full-line comments starting with # in the used-modules.txt file
|
|
12
|
+
const shouldCopy = file => file.length && !file.startsWith("#");
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
const shouldCopy = file => file.length && !file.startsWith("#");
|
|
14
|
+
const trimFile = file => file.trim();
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const promises = filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
|
|
17
|
+
const srcPath = require.resolve(path.join(src, moduleName), { paths: [process.cwd()] });
|
|
18
|
+
const destPath = path.join(dest, moduleName);
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
21
|
+
return fs.copyFile(srcPath, destPath);
|
|
22
|
+
});
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (err) {
|
|
24
|
-
throw err;
|
|
25
|
-
}
|
|
26
|
-
console.log(`${destPath} created.`);
|
|
24
|
+
return Promise.all(promises).then(() => {
|
|
25
|
+
console.log("Files copied.");
|
|
27
26
|
});
|
|
28
|
-
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if (require.main === module) {
|
|
31
|
+
generate(process.argv)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports._ui5mainFn = generate;
|
|
@@ -1,72 +1,131 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
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 iconTemplate = (name, pathData, ltr, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
|
5
|
+
|
|
6
|
+
const name = "${name}";
|
|
7
|
+
const pathData = "${pathData}";
|
|
8
|
+
const ltr = ${ltr};
|
|
9
|
+
const accData = null;
|
|
10
|
+
const collection = "${collection}";
|
|
11
|
+
const packageName = "${packageName}";
|
|
12
|
+
|
|
13
|
+
registerIcon(name, { pathData, ltr, collection, packageName });
|
|
14
|
+
|
|
15
|
+
export default "${collection}/${name}";
|
|
16
|
+
export { pathData, ltr, accData };`;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName, versioned) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
|
20
|
+
import { ${accData.key} } from "${versioned ? "../" : "./"}generated/i18n/i18n-defaults.js";
|
|
21
|
+
|
|
22
|
+
const name = "${name}";
|
|
23
|
+
const pathData = "${pathData}";
|
|
24
|
+
const ltr = ${ltr};
|
|
25
|
+
const accData = ${accData.key};
|
|
26
|
+
const collection = "${collection}";
|
|
27
|
+
const packageName = "${packageName}";
|
|
28
|
+
|
|
29
|
+
registerIcon(name, { pathData, ltr, accData, collection, packageName });
|
|
30
|
+
|
|
31
|
+
export default "${collection}/${name}";
|
|
32
|
+
export { pathData, ltr, accData };`;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const collectionTemplate = (name, versions, fullName) => `import { isLegacyThemeFamilyAsync } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
|
37
|
+
import { pathData as pathData${versions[0]}, ltr, accData } from "./${versions[0]}/${name}.js";
|
|
38
|
+
import { pathData as pathData${versions[1]} } from "./${versions[1]}/${name}.js";
|
|
39
|
+
|
|
40
|
+
const getPathData = async() => {
|
|
41
|
+
return await isLegacyThemeFamilyAsync() ? pathDatav4 : pathDatav5;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default "${fullName}";
|
|
45
|
+
export { getPathData, ltr, accData };`;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const typeDefinitionTemplate = (name, accData, collection) => `declare const pathData: string;
|
|
49
|
+
declare const ltr: boolean;
|
|
50
|
+
declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
|
|
51
|
+
declare const _default: "${collection}/${name}";
|
|
52
|
+
|
|
53
|
+
export default _default;
|
|
54
|
+
export { pathData, ltr, accData };`
|
|
55
|
+
|
|
56
|
+
const collectionTypeDefinitionTemplate = (name, accData) => `declare const getPathData: () => Promise<string>;
|
|
57
|
+
declare const ltr: boolean;
|
|
58
|
+
declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
|
|
59
|
+
declare const _default: "${name}";
|
|
60
|
+
|
|
61
|
+
export default _default;
|
|
62
|
+
export { getPathData, ltr, accData };`
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
66
|
+
<path d="${pathData}"/>
|
|
67
|
+
</svg>`;
|
|
68
|
+
|
|
69
|
+
const createIcons = async (argv) => {
|
|
70
|
+
const collectionName = argv[2] || "SAP-icons-v4";
|
|
71
|
+
const collectionVersion = argv[3];
|
|
72
|
+
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
|
73
|
+
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
|
74
|
+
await fs.mkdir(destDir, { recursive: true });
|
|
75
|
+
|
|
76
|
+
const json = JSON.parse(await fs.readFile(srcFile));
|
|
77
|
+
|
|
78
|
+
const promises = [];
|
|
79
|
+
for (let name in json.data) {
|
|
80
|
+
const iconData = json.data[name];
|
|
81
|
+
const pathData = iconData.path;
|
|
82
|
+
const ltr = !!iconData.ltr;
|
|
83
|
+
const acc = iconData.acc;
|
|
84
|
+
const packageName = json.packageName;
|
|
85
|
+
const collection = json.collection;
|
|
86
|
+
const versioned = json.version;
|
|
87
|
+
|
|
88
|
+
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName, versioned) : iconTemplate(name, pathData, ltr, collection, packageName);
|
|
89
|
+
|
|
90
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
|
|
91
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
|
|
92
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.d.ts`), typeDefinitionTemplate(name, acc, collection)));
|
|
93
|
+
|
|
94
|
+
// For versioned icons collections, the script creates top level (unversioned) module that internally imports the versioned ones.
|
|
95
|
+
// For example, the top level "@ui5/ui5-webcomponents-icons/dist/accept.js" imports:
|
|
96
|
+
// - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
|
|
97
|
+
// - "@ui5/ui5-webcomponents-icons/dist/v4/accept.js"
|
|
98
|
+
|
|
99
|
+
if (versioned) {
|
|
100
|
+
// The exported value from the top level (unversioned) icon module depends on whether the collection is the default,
|
|
101
|
+
// to add or not the collection name to the exported value:
|
|
102
|
+
// For the default collection (SAPIcons) we export just the icon name - "export default { 'accept' }"
|
|
103
|
+
// For non-default collections (SAPTNTIcons and SAPBSIcons) we export the full name - "export default { 'tnt/actor' }"
|
|
104
|
+
const effectiveName = isDefaultCollection(collection) ? name : getUnversionedFullIconName(name, collection);
|
|
105
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions, effectiveName)));
|
|
106
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(effectiveName, acc)));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return Promise.all(promises)
|
|
111
|
+
.then(() => {
|
|
112
|
+
console.log("Icons created.");
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
|
|
117
|
+
const getUnversionedFullIconName = (name, collection) => `${getUnversionedCollectionName(collection)}/${name}`;
|
|
118
|
+
const getUnversionedCollectionName = collectionName => CollectionVersionedToUnversionedMap[collectionName] || collectionName;
|
|
119
|
+
|
|
120
|
+
const CollectionVersionedToUnversionedMap = {
|
|
121
|
+
"tnt-v2": "tnt",
|
|
122
|
+
"tnt-v3": "tnt",
|
|
123
|
+
"business-suite-v1": "business-suite",
|
|
124
|
+
"business-suite-v2": "business-suite",
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
if (require.main === module) {
|
|
128
|
+
createIcons(process.argv)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exports._ui5mainFn = createIcons;
|