@ui5/webcomponents-tools 0.0.0-6895c16dd → 0.0.0-6d98d0c29
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 -1
- package/components-package/nps.js +49 -26
- package/components-package/rollup.js +106 -46
- package/components-package/wdio.js +1 -1
- package/icons-collection/nps.js +10 -4
- package/lib/copy-and-watch/index.js +6 -4
- package/lib/copy-list/index.js +28 -0
- package/lib/create-illustrations/index.js +95 -0
- package/lib/create-new-component/index.js +12 -4
- package/lib/esm-abs-to-rel/index.js +54 -0
- package/lib/generate-json-imports/themes.js +2 -2
- package/lib/hash/config.js +10 -0
- package/lib/hash/generate.js +19 -0
- package/lib/hash/upToDate.js +31 -0
- package/lib/hbs2lit/src/litVisitor2.js +21 -4
- package/lib/hbs2lit/src/svgProcessor.js +3 -3
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +4 -11
- package/lib/i18n/toJSON.js +1 -1
- package/lib/init-package/index.js +13 -0
- package/lib/jsdoc/plugin.js +18 -0
- package/lib/jsdoc/template/publish.js +6 -0
- package/lib/polyfill-placeholder/index.js +5 -0
- package/lib/postcss-css-to-esm/index.js +15 -12
- package/lib/postcss-css-to-json/index.js +15 -11
- package/lib/postcss-new-files/index.js +36 -0
- package/lib/replace-global-core/index.js +20 -0
- package/lib/scoping/lint-src.js +1 -1
- package/lib/serve/index.js +46 -0
- package/{components-package → lib/serve}/serve.json +0 -0
- package/package.json +48 -48
package/CHANGELOG.md
CHANGED
@@ -3,9 +3,35 @@
|
|
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.0.0-rc.15](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.14...v1.0.0-rc.15) (2021-07-23)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **tools:** fix build error on MacOS 11 from rollup-plugin-terser ([#3347](https://github.com/SAP/ui5-webcomponents/issues/3347)) ([59892c4](https://github.com/SAP/ui5-webcomponents/commit/59892c4)), closes [#2515](https://github.com/SAP/ui5-webcomponents/issues/2515)
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
# [1.0.0-rc.14](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.13...v1.0.0-rc.14) (2021-04-01)
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
# [1.0.0-rc.13](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.12...v1.0.0-rc.13) (2021-03-26)
|
24
|
+
|
25
|
+
|
26
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
6
32
|
# [1.0.0-rc.12](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.11...v1.0.0-rc.12) (2021-02-18)
|
7
33
|
|
8
|
-
**Note:** Version bump only for package @ui5/webcomponents-
|
34
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
35
|
|
10
36
|
|
11
37
|
|
@@ -1,26 +1,36 @@
|
|
1
1
|
const path = require("path");
|
2
|
+
const fs = require("fs");
|
2
3
|
|
3
4
|
const LIB = path.join(__dirname, `../lib/`);
|
4
|
-
const serveConfig = path.join(__dirname, `serve.json`);
|
5
5
|
const polyfillDir = path.dirname(require.resolve("@webcomponents/webcomponentsjs"));
|
6
|
-
const polyfillPath = path.join(polyfillDir, "/**/*.*");
|
6
|
+
const polyfillPath = path.join(polyfillDir, "{*.js,*.map,*.md,bundles/**/*.*}");
|
7
|
+
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
7
8
|
|
8
9
|
const getScripts = (options) => {
|
9
10
|
|
10
|
-
const port = options.port;
|
11
|
+
const port = options.port || 8080; // preferred port
|
12
|
+
const portStep = options.portStep || 1; // step to check for available ports, if preferred port is already used
|
13
|
+
let illustrations = options.illustrationsPath || [];
|
14
|
+
|
15
|
+
illustrations = illustrations.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
|
16
|
+
|
17
|
+
let illustrationsScript = illustrations.join(" && ");
|
11
18
|
|
12
19
|
const scripts = {
|
13
|
-
clean: "rimraf dist",
|
14
|
-
lint: "",
|
20
|
+
clean: "rimraf dist && rimraf .port",
|
21
|
+
lint: "eslint . --config config/.eslintrc.js",
|
15
22
|
lintfix: "eslint . --config config/.eslintrc.js --fix",
|
16
|
-
prepare:
|
23
|
+
prepare: {
|
24
|
+
default: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples build.illustrations",
|
25
|
+
es5: "nps clean build.templates build.styles build.i18n build.jsonImports copy.es5 build.samples build.illustrations"
|
26
|
+
},
|
17
27
|
build: {
|
18
|
-
default: "nps lint prepare build.bundle",
|
28
|
+
default: "nps lint prepare.es5 build.bundle",
|
19
29
|
templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
|
20
30
|
styles: {
|
21
31
|
default: "nps build.styles.themes build.styles.components",
|
22
32
|
themes: "postcss src/**/parameters-bundle.css --config config/postcss.themes --base src --dir dist/css/",
|
23
|
-
components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/",
|
33
|
+
components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
|
24
34
|
},
|
25
35
|
i18n: {
|
26
36
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
@@ -37,36 +47,49 @@ const getScripts = (options) => {
|
|
37
47
|
default: "nps build.samples.api build.samples.docs",
|
38
48
|
api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
|
39
49
|
docs: `node "${LIB}/documentation/index.js" dist/api.json`,
|
50
|
+
},
|
51
|
+
illustrations: {
|
52
|
+
default: illustrationsScript
|
40
53
|
}
|
41
54
|
},
|
42
55
|
copy: {
|
43
|
-
default: "nps copy.src copy.props copy.test copy.webcomponents-polyfill",
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
56
|
+
default: "nps copy.src copy.props copy.test copy.webcomponents-polyfill-placeholder",
|
57
|
+
es5: "nps copy.src copy.props copy.test copy.webcomponents-polyfill",
|
58
|
+
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
59
|
+
props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
|
60
|
+
test: `node "${LIB}/copy-and-watch/index.js" --silent "test/**/*.*" dist/test-resources`,
|
61
|
+
"webcomponents-polyfill": `node "${LIB}/copy-and-watch/index.js" --silent "${polyfillPath}" dist/webcomponentsjs/`,
|
62
|
+
"webcomponents-polyfill-placeholder": `node "${LIB}/polyfill-placeholder/index.js"`
|
48
63
|
},
|
49
64
|
watch: {
|
50
|
-
default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles"',
|
65
|
+
default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles" "nps watch.i18n"',
|
66
|
+
es5: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle.es5" "nps watch.styles" "nps watch.i18n"',
|
51
67
|
src: 'nps "copy.src --watch --safe --skip-initial-copy"',
|
52
68
|
props: 'nps "copy.props --watch --safe --skip-initial-copy"',
|
53
69
|
test: 'nps "copy.test --watch --safe --skip-initial-copy"',
|
54
|
-
bundle:
|
70
|
+
bundle: {
|
71
|
+
default: 'rollup --config config/rollup.config.js -w --environment DEV,DEPLOY_PUBLIC_PATH:/resources/',
|
72
|
+
es5: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,DEPLOY_PUBLIC_PATH:/resources/'
|
73
|
+
},
|
55
74
|
styles: {
|
56
75
|
default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
|
57
76
|
themes: 'nps "build.styles.themes -w"',
|
58
|
-
components:
|
77
|
+
components: {
|
78
|
+
default: 'concurrently "nps watch.styles.components.existingFiles" "nps watch.styles.components.newFiles"',
|
79
|
+
existingFiles: `nps "build.styles.components -w"`,
|
80
|
+
newFiles: `node "${LIB}/postcss-new-files/index.js" --srcFiles="src/themes/*.css"`,
|
81
|
+
},
|
59
82
|
},
|
60
|
-
templates:
|
61
|
-
samples:
|
83
|
+
templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
|
84
|
+
samples: 'chokidar "test/**/*.sample.html" -c "nps build.samples"',
|
85
|
+
i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
|
62
86
|
},
|
63
|
-
dev:
|
64
|
-
|
65
|
-
|
66
|
-
default: "nps serve.prepare serve.run",
|
67
|
-
prepare: `node "${LIB}/copy-and-watch/index.js" "${serveConfig}" dist/`,
|
68
|
-
run: `serve --no-clipboard -l ${port} dist`,
|
87
|
+
dev: {
|
88
|
+
default: 'concurrently "nps serve" "nps watch"',
|
89
|
+
es5: 'concurrently "nps serve" "nps watch.es5"'
|
69
90
|
},
|
91
|
+
start: "nps prepare dev",
|
92
|
+
serve: `node "${LIB}/serve/index.js" --dir="dist/" --port=${port} --portStep=${portStep} --packageName="${packageName}"`,
|
70
93
|
test: {
|
71
94
|
// --success first - report the exit code of the test run (first command to finish), as serve is always terminated and has a non-0 exit code
|
72
95
|
default: 'concurrently "nps serve" "nps test.run" --kill-others --success first',
|
@@ -80,12 +103,12 @@ const getScripts = (options) => {
|
|
80
103
|
testPages: {
|
81
104
|
default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
|
82
105
|
clean: "rimraf dist/test-resources/pages/scoped",
|
83
|
-
copy: `node "${LIB}/copy-and-watch/index.js" "dist/test-resources/pages/**/*" dist/test-resources/scoped`,
|
106
|
+
copy: `node "${LIB}/copy-and-watch/index.js" --silent "dist/test-resources/pages/**/*" dist/test-resources/scoped`,
|
84
107
|
replace: `node "${LIB}/scoping/scope-test-pages.js" dist/test-resources/scoped demo`,
|
85
108
|
},
|
86
109
|
dev: 'concurrently "nps serve" "nps scope.watch"',
|
87
110
|
watch: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.props" "nps scope.bundle" "nps watch.styles"',
|
88
|
-
bundle:
|
111
|
+
bundle: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,SCOPE'
|
89
112
|
}
|
90
113
|
};
|
91
114
|
|
@@ -6,13 +6,19 @@ const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
|
6
6
|
const url = require("@rollup/plugin-url");
|
7
7
|
const { terser } = require("rollup-plugin-terser");
|
8
8
|
const json = require("@rollup/plugin-json");
|
9
|
-
const
|
10
|
-
const filesize = require(
|
11
|
-
const livereload = require(
|
9
|
+
const colors = require("colors/safe");
|
10
|
+
const filesize = require("rollup-plugin-filesize");
|
11
|
+
const livereload = require("rollup-plugin-livereload");
|
12
12
|
|
13
|
-
const
|
13
|
+
const packageFile = JSON.parse(fs.readFileSync("./package.json"));
|
14
|
+
const packageName = packageFile.name;
|
14
15
|
const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
|
15
16
|
|
17
|
+
const warningsToSkip = [{
|
18
|
+
warningCode: "THIS_IS_UNDEFINED",
|
19
|
+
filePath: /.+zxing.+/,
|
20
|
+
}];
|
21
|
+
|
16
22
|
function ui5DevImportCheckerPlugin() {
|
17
23
|
return {
|
18
24
|
name: "ui5-dev-import-checker-plugin",
|
@@ -21,48 +27,100 @@ function ui5DevImportCheckerPlugin() {
|
|
21
27
|
if (re.test(code)) {
|
22
28
|
throw new Error(`illegal import in ${file}`);
|
23
29
|
}
|
24
|
-
}
|
30
|
+
},
|
31
|
+
};
|
32
|
+
}
|
33
|
+
|
34
|
+
function onwarn(warning, warn) {
|
35
|
+
// Skip warning for known false positives that will otherwise polute the log
|
36
|
+
let skip = warningsToSkip.find(warningToSkip => {
|
37
|
+
let loc, file;
|
38
|
+
return warning.code === warningToSkip.warningCode
|
39
|
+
&& (loc = warning.loc)
|
40
|
+
&& (file = loc.file)
|
41
|
+
&& file.match(warningToSkip.filePath);
|
42
|
+
});
|
43
|
+
if (skip) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
// warn everything else
|
48
|
+
warn( warning );
|
49
|
+
}
|
50
|
+
|
51
|
+
const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
|
52
|
+
function ui5DevReadyMessagePlugin() {
|
53
|
+
return {
|
54
|
+
name: "ui5-dev-message-ready-plugin",
|
55
|
+
writeBundle: (assets, bundle) => {
|
56
|
+
if (reportedForPackages.has(packageName)) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
|
60
|
+
|
61
|
+
if (fs.existsSync(".port")) {
|
62
|
+
const port = `${fs.readFileSync(".port")}`;
|
63
|
+
if (port) {
|
64
|
+
console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
|
65
|
+
}
|
66
|
+
}
|
67
|
+
reportedForPackages.add(packageName);
|
68
|
+
},
|
25
69
|
};
|
26
70
|
}
|
27
71
|
|
28
72
|
const getPlugins = ({ transpile }) => {
|
29
73
|
const plugins = [];
|
30
|
-
let publicPath = DEPLOY_PUBLIC_PATH;
|
31
|
-
|
32
74
|
if (!process.env.DEV) {
|
33
|
-
plugins.push(filesize(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
75
|
+
plugins.push(filesize(
|
76
|
+
{
|
77
|
+
reporter(options, bundle, {
|
78
|
+
minSize, gzipSize, brotliSize, bundleSize,
|
79
|
+
fileName,
|
80
|
+
// "showBeforeSizes: release"
|
81
|
+
lastVersion,
|
82
|
+
// "showBeforeSizes: "release" or "showBeforeSizes": "build"
|
83
|
+
bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
|
84
|
+
}) {
|
85
|
+
// If a promise is returned, it will be awaited before rendering.
|
86
|
+
return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
|
87
|
+
},
|
88
|
+
},
|
89
|
+
|
90
|
+
));
|
38
91
|
}
|
39
92
|
|
93
|
+
const publicPath = DEPLOY_PUBLIC_PATH;
|
94
|
+
|
40
95
|
plugins.push(ui5DevImportCheckerPlugin());
|
41
96
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
97
|
+
if (!transpile) {
|
98
|
+
plugins.push(json({
|
99
|
+
include: [
|
100
|
+
/.*assets\/.*\.json/,
|
101
|
+
],
|
102
|
+
namedExports: false,
|
103
|
+
}));
|
104
|
+
}
|
105
|
+
|
106
|
+
if (transpile) {
|
107
|
+
plugins.push(url({
|
108
|
+
limit: 0,
|
109
|
+
include: [
|
110
|
+
/.*assets\/.*\.json/,
|
111
|
+
],
|
112
|
+
emitFiles: true,
|
113
|
+
fileName: "[name].[hash][extname]",
|
114
|
+
publicPath,
|
115
|
+
}));
|
116
|
+
}
|
60
117
|
|
61
118
|
if (transpile) {
|
62
119
|
plugins.push(babel({
|
63
120
|
presets: ["@babel/preset-env"],
|
64
|
-
exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, //exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
|
121
|
+
exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
|
65
122
|
sourcemap: true,
|
123
|
+
babelHelpers: "bundled",
|
66
124
|
}));
|
67
125
|
}
|
68
126
|
|
@@ -70,14 +128,10 @@ const getPlugins = ({ transpile }) => {
|
|
70
128
|
|
71
129
|
if (!process.env.DEV) {
|
72
130
|
plugins.push(terser({
|
73
|
-
numWorkers: 1,
|
131
|
+
numWorkers: 1,
|
74
132
|
}));
|
75
133
|
}
|
76
134
|
|
77
|
-
if (process.env.DEV) {
|
78
|
-
plugins.push(notify());
|
79
|
-
}
|
80
|
-
|
81
135
|
const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
|
82
136
|
if (es6DevMain && os.platform() !== "win32") {
|
83
137
|
plugins.push(livereload({
|
@@ -85,10 +139,14 @@ const getPlugins = ({ transpile }) => {
|
|
85
139
|
"dist/resources/bundle.esm.js",
|
86
140
|
"dist/**/*.html",
|
87
141
|
"dist/**/*.json",
|
88
|
-
]
|
142
|
+
],
|
89
143
|
}));
|
90
144
|
}
|
91
145
|
|
146
|
+
if (process.env.DEV) {
|
147
|
+
plugins.push(ui5DevReadyMessagePlugin());
|
148
|
+
}
|
149
|
+
|
92
150
|
return plugins;
|
93
151
|
};
|
94
152
|
|
@@ -98,23 +156,24 @@ const getES6Config = (input = "bundle.esm.js") => {
|
|
98
156
|
output: {
|
99
157
|
dir: "dist/resources",
|
100
158
|
format: "esm",
|
101
|
-
sourcemap: true
|
159
|
+
sourcemap: true,
|
102
160
|
},
|
103
|
-
moduleContext:
|
161
|
+
moduleContext: id => {
|
104
162
|
if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
|
105
163
|
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
106
164
|
return "window";
|
107
165
|
}
|
108
166
|
},
|
109
167
|
watch: {
|
110
|
-
clearScreen: false
|
168
|
+
clearScreen: false,
|
111
169
|
},
|
112
|
-
plugins: getPlugins({transpile: false}),
|
170
|
+
plugins: getPlugins({ transpile: false }),
|
171
|
+
onwarn: onwarn,
|
113
172
|
}];
|
114
173
|
};
|
115
174
|
|
116
175
|
const getES5Config = (input = "bundle.es5.js") => {
|
117
|
-
return [
|
176
|
+
return [{
|
118
177
|
input,
|
119
178
|
output: {
|
120
179
|
dir: "dist/resources",
|
@@ -122,18 +181,19 @@ const getES5Config = (input = "bundle.es5.js") => {
|
|
122
181
|
inlineDynamicImports: true,
|
123
182
|
name: "sap-ui-webcomponents-bundle",
|
124
183
|
extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
|
125
|
-
sourcemap: true
|
184
|
+
sourcemap: true,
|
126
185
|
},
|
127
|
-
moduleContext:
|
186
|
+
moduleContext: id => {
|
128
187
|
if (id.includes("url-search-params-polyfill")) {
|
129
188
|
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
130
189
|
return "window";
|
131
190
|
}
|
132
191
|
},
|
133
192
|
watch: {
|
134
|
-
clearScreen: false
|
193
|
+
clearScreen: false,
|
135
194
|
},
|
136
|
-
plugins: getPlugins({transpile: true}),
|
195
|
+
plugins: getPlugins({ transpile: true }),
|
196
|
+
onwarn: onwarn,
|
137
197
|
}];
|
138
198
|
};
|
139
199
|
|
@@ -82,7 +82,7 @@ exports.config = {
|
|
82
82
|
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
|
83
83
|
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
|
84
84
|
// gets prepended directly.
|
85
|
-
baseUrl:
|
85
|
+
baseUrl: undefined, // This is important since WDIO 7+ does not accept an empty string for baseUrl
|
86
86
|
path: '',
|
87
87
|
//
|
88
88
|
// Default timeout for all waitFor* commands.
|
package/icons-collection/nps.js
CHANGED
@@ -1,4 +1,9 @@
|
|
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."`;
|
2
7
|
|
3
8
|
const LIB = path.join(__dirname, `../lib/`);
|
4
9
|
|
@@ -8,11 +13,11 @@ const getScripts = (options) => {
|
|
8
13
|
clean: "rimraf dist",
|
9
14
|
copy: {
|
10
15
|
default: "nps copy.json-imports copy.icon-collection",
|
11
|
-
"json-imports": `node "${LIB}/copy-and-watch/index.js" "src/**/*.js" dist/`,
|
12
|
-
"icon-collection": `node "${LIB}/copy-and-watch/index.js" "src/*.json" dist/generated/assets/`
|
16
|
+
"json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
17
|
+
"icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json" dist/generated/assets/`
|
13
18
|
},
|
14
19
|
build: {
|
15
|
-
default:
|
20
|
+
default: `${UP_TO_DATE} || nps clean copy build.i18n build.icons build.jsonImports hash`,
|
16
21
|
i18n: {
|
17
22
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
18
23
|
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
|
@@ -23,7 +28,8 @@ const getScripts = (options) => {
|
|
23
28
|
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
|
24
29
|
},
|
25
30
|
icons: `node "${LIB}/create-icons/index.js" "${options.collectionName}"`,
|
26
|
-
}
|
31
|
+
},
|
32
|
+
hash: `node "${generateHash}" dist/ hash.txt`,
|
27
33
|
};
|
28
34
|
|
29
35
|
return scripts;
|
@@ -10,7 +10,7 @@ require('colors');
|
|
10
10
|
const args = process.argv.slice(2);
|
11
11
|
const options = {};
|
12
12
|
|
13
|
-
['watch', 'clean', 'skip-initial-copy', 'safe'].forEach(key => {
|
13
|
+
['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
|
14
14
|
const index = args.indexOf(`--${key}`);
|
15
15
|
if (index >= 0) {
|
16
16
|
options[key] = true;
|
@@ -64,12 +64,12 @@ const copy = from => {
|
|
64
64
|
return;
|
65
65
|
}
|
66
66
|
fs.writeFileSync(to, fs.readFileSync(from));
|
67
|
-
console.log('[COPY]'.yellow, from, 'to'.yellow, to);
|
67
|
+
options.silent || console.log('[COPY]'.yellow, from, 'to'.yellow, to);
|
68
68
|
};
|
69
69
|
const remove = from => {
|
70
70
|
const to = findTarget(from);
|
71
71
|
fs.unlinkSync(to);
|
72
|
-
console.log('[DELETE]'.yellow, to);
|
72
|
+
options.silent || console.log('[DELETE]'.yellow, to);
|
73
73
|
};
|
74
74
|
const rimraf = dir => {
|
75
75
|
if (fs.existsSync(dir)) {
|
@@ -110,7 +110,9 @@ if (options.watch) {
|
|
110
110
|
|
111
111
|
chokidar
|
112
112
|
.watch(sources, chokidarOptions)
|
113
|
-
.on('ready', () => sources.forEach(s =>
|
113
|
+
.on('ready', () => sources.forEach(s => {
|
114
|
+
options.silent || console.log('[WATCH]'.yellow, s);
|
115
|
+
}))
|
114
116
|
.on('add', copy)
|
115
117
|
.on('addDir', copy)
|
116
118
|
.on('change', copy)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const mkdirp = require("mkdirp");
|
4
|
+
|
5
|
+
const fileList = process.argv[2];
|
6
|
+
const dest = process.argv[3];
|
7
|
+
const src = "../../node_modules/@openui5/sap.ui.core/src/";
|
8
|
+
|
9
|
+
const filesToCopy = fs.readFileSync(fileList).toString();
|
10
|
+
// console.log(filesToCopy);
|
11
|
+
|
12
|
+
// Support full-line comments starting with # in the used-modules.txt file
|
13
|
+
const shouldCopy = file => file.length && !file.startsWith("#");
|
14
|
+
|
15
|
+
const trimFile = file => file.trim();
|
16
|
+
|
17
|
+
filesToCopy.split("\n").map(trimFile).filter(shouldCopy).forEach(async moduleName => {
|
18
|
+
const srcPath = path.join(src, moduleName);
|
19
|
+
const destPath = path.join(dest, moduleName);
|
20
|
+
|
21
|
+
await mkdirp(path.dirname(destPath));
|
22
|
+
fs.copyFile(srcPath, destPath, (err) => {
|
23
|
+
if (err) {
|
24
|
+
throw err;
|
25
|
+
}
|
26
|
+
console.log(`${destPath} created.`);
|
27
|
+
});
|
28
|
+
});
|
@@ -0,0 +1,95 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const mkdirp = require("mkdirp");
|
4
|
+
|
5
|
+
if (process.argv.length < 7) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
|
9
|
+
const srcPath = process.argv[2];
|
10
|
+
const defaultText = process.argv[3] === "true";
|
11
|
+
const illustrationsPrefix = process.argv[4];
|
12
|
+
const illustrationSet = process.argv[5];
|
13
|
+
const destPath = process.argv[6];
|
14
|
+
const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
|
15
|
+
// collect each illustration name because each one should have Sample.js file
|
16
|
+
const fileNames = new Set();
|
17
|
+
|
18
|
+
const svgImportTemplate = svgContent => { return `export default \`${svgContent}\`;`};
|
19
|
+
const svgToJs = fileName => {
|
20
|
+
const svg = fs.readFileSync(path.join(srcPath, fileName), { encoding: "utf-8" });
|
21
|
+
const fileContent = svgImportTemplate(svg);
|
22
|
+
fileName = fileName.replace(/\.svg$/, ".js");
|
23
|
+
|
24
|
+
fs.writeFileSync(path.join(destPath, fileName), fileContent);
|
25
|
+
};
|
26
|
+
const illustrationImportTemplate = illustrationName => {
|
27
|
+
const illustationNameUpperCase = illustrationName.toUpperCase();
|
28
|
+
|
29
|
+
return defaultText ? `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
30
|
+
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
31
|
+
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
32
|
+
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
33
|
+
import {
|
34
|
+
IM_TITLE_${illustationNameUpperCase},
|
35
|
+
IM_SUBTITLE_${illustationNameUpperCase},
|
36
|
+
} from "../generated/i18n/i18n-defaults.js";
|
37
|
+
|
38
|
+
const name = "${illustrationName}";
|
39
|
+
const set = "${illustrationSet}";
|
40
|
+
const title = IM_TITLE_${illustationNameUpperCase};
|
41
|
+
const subtitle = IM_SUBTITLE_${illustationNameUpperCase};
|
42
|
+
|
43
|
+
registerIllustration(name, {
|
44
|
+
dialogSvg,
|
45
|
+
sceneSvg,
|
46
|
+
spotSvg,
|
47
|
+
title,
|
48
|
+
subtitle,
|
49
|
+
set,
|
50
|
+
});
|
51
|
+
|
52
|
+
export {
|
53
|
+
dialogSvg,
|
54
|
+
sceneSvg,
|
55
|
+
spotSvg,
|
56
|
+
};` :
|
57
|
+
`import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
58
|
+
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
59
|
+
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
60
|
+
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
61
|
+
|
62
|
+
const name = "${illustrationName}";
|
63
|
+
const set = "${illustrationSet}";
|
64
|
+
|
65
|
+
registerIllustration(name, {
|
66
|
+
dialogSvg,
|
67
|
+
sceneSvg,
|
68
|
+
spotSvg,
|
69
|
+
set,
|
70
|
+
});
|
71
|
+
|
72
|
+
export {
|
73
|
+
dialogSvg,
|
74
|
+
sceneSvg,
|
75
|
+
spotSvg,
|
76
|
+
};`
|
77
|
+
};
|
78
|
+
|
79
|
+
mkdirp.sync(destPath);
|
80
|
+
|
81
|
+
const illustrationFileNames = fs.readdirSync(path.normalize(srcPath));
|
82
|
+
|
83
|
+
// convert SVG to JS imports
|
84
|
+
illustrationFileNames.forEach(illustration => {
|
85
|
+
if (fileNamePattern.test(illustration)) {
|
86
|
+
let [fileName, illustrationName] = illustration.match(fileNamePattern);
|
87
|
+
|
88
|
+
svgToJs(fileName);
|
89
|
+
fileNames.add(illustrationName);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
|
93
|
+
for (let illustrationName of fileNames) {
|
94
|
+
fs.writeFileSync(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName));
|
95
|
+
}
|
@@ -139,8 +139,16 @@ console.log(`Successfully generated ${componentName}.js`);
|
|
139
139
|
console.log(`Successfully generated ${componentName}.css`);
|
140
140
|
console.log(`Successfully generated ${componentName}.hbs`);
|
141
141
|
|
142
|
+
const bundleLogger = fs.createWriteStream("./bundle.common.js", {
|
143
|
+
flags: "a" // appending
|
144
|
+
});
|
145
|
+
|
146
|
+
bundleLogger.write(`
|
147
|
+
// TODO: Move this line in order to keep the file sorted alphabetically
|
148
|
+
import ${componentName} from "./dist/${componentName}.js";`);
|
149
|
+
|
142
150
|
// Change the color of the output
|
143
|
-
console.warn('\x1b[33m%s\x1b[0m', `
|
144
|
-
|
145
|
-
|
146
|
-
`);
|
151
|
+
console.warn('\x1b[33m%s\x1b[0m', `
|
152
|
+
Component is imported in bundle.common.js.
|
153
|
+
Do NOT forget to sort the file in alphabeticall order.
|
154
|
+
`);
|
@@ -0,0 +1,54 @@
|
|
1
|
+
const esprima = require("esprima");
|
2
|
+
const escodegen = require("escodegen");
|
3
|
+
|
4
|
+
const fs = require("fs");
|
5
|
+
const path = require("path");
|
6
|
+
const glob = require("glob");
|
7
|
+
const basePath = process.argv[2];
|
8
|
+
|
9
|
+
const convertImports = (srcPath) => {
|
10
|
+
let changed = false;
|
11
|
+
// console.log("scanning imports of", srcPath);
|
12
|
+
let code = fs.readFileSync(srcPath).toString();
|
13
|
+
const tree = esprima.parseModule(code);
|
14
|
+
const importer = srcPath.replace(basePath, "");
|
15
|
+
const importerDir = path.dirname(importer);
|
16
|
+
// console.log("-> ", importer);
|
17
|
+
tree.body.forEach(node => {
|
18
|
+
if (node.type === "ImportDeclaration") {
|
19
|
+
let importee = node.source.value;
|
20
|
+
if (importee.startsWith(".")) {
|
21
|
+
// add .js extension if missing
|
22
|
+
if (!importee.endsWith(".js")) {
|
23
|
+
node.source.value += ".js"
|
24
|
+
changed = true;
|
25
|
+
}
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
let importeeDir = path.dirname(importee);
|
29
|
+
let importeeFile = path.basename(importee);
|
30
|
+
let relativePath = path.relative(importerDir, importeeDir);
|
31
|
+
if (relativePath.length === 0) {
|
32
|
+
relativePath = "."
|
33
|
+
}
|
34
|
+
if (!relativePath.startsWith(".")) {
|
35
|
+
relativePath = "./" + relativePath;
|
36
|
+
}
|
37
|
+
|
38
|
+
relativePath = relativePath.replace(/\\/g, "/"); // the browser expects unix paths
|
39
|
+
let relativeImport = `${relativePath}/${importeeFile}.js`;
|
40
|
+
// console.log(importee + " --> " + relativeImport);
|
41
|
+
node.source.value = relativeImport;
|
42
|
+
changed = true;
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
if (changed) {
|
47
|
+
fs.writeFileSync(srcPath, escodegen.generate(tree));
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
const fileNames = glob.sync(basePath + "**/*.js");
|
52
|
+
// console.log(fileNames);
|
53
|
+
fileNames.forEach(convertImports);
|
54
|
+
console.log("Success: Converted absolute imports to relative for files in:", basePath)
|
@@ -8,14 +8,14 @@ const outputFile = path.normalize(`${process.argv[3]}/Themes-static.js`);
|
|
8
8
|
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.js`);
|
9
9
|
|
10
10
|
// All supported optional themes
|
11
|
-
const
|
11
|
+
const allThemes = assets.themes.all;
|
12
12
|
|
13
13
|
// All themes present in the file system
|
14
14
|
const dirs = fs.readdirSync(inputFolder);
|
15
15
|
const themesOnFileSystem = dirs.map(dir => {
|
16
16
|
const matches = dir.match(/sap_.*$/);
|
17
17
|
return matches ? dir : undefined;
|
18
|
-
}).filter(key => !!key &&
|
18
|
+
}).filter(key => !!key && allThemes.includes(key));
|
19
19
|
|
20
20
|
const packageName = JSON.parse(fs.readFileSync("package.json")).name;
|
21
21
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const process = require("process");
|
4
|
+
const { hashElement } = require("folder-hash");
|
5
|
+
const config = require("./config.js");
|
6
|
+
|
7
|
+
const inputDir = path.normalize(process.argv[2]);
|
8
|
+
const outputFileName = path.normalize(process.argv[3]);
|
9
|
+
|
10
|
+
const generateHash = async (inputDir, outputFileName) => {
|
11
|
+
const result = await hashElement(inputDir, config);
|
12
|
+
const hash = result.hash;
|
13
|
+
fs.writeFileSync(outputFileName, hash);
|
14
|
+
return hash;
|
15
|
+
};
|
16
|
+
|
17
|
+
generateHash(inputDir, outputFileName).then(hash => {
|
18
|
+
console.log(`Generated hash: ${hash}`);
|
19
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const process = require("process");
|
4
|
+
const { hashElement } = require("folder-hash");
|
5
|
+
const config = require("./config.js");
|
6
|
+
|
7
|
+
const inputDir = path.normalize(process.argv[2]);
|
8
|
+
const hashFileName = path.normalize(process.argv[3]);
|
9
|
+
|
10
|
+
const isUpToDate = async (inputDir, hashFileName) => {
|
11
|
+
// No dist/ directory or no hash file
|
12
|
+
if (!fs.existsSync(inputDir) || !fs.existsSync(hashFileName)) {
|
13
|
+
return false;
|
14
|
+
}
|
15
|
+
|
16
|
+
// Empty hash file
|
17
|
+
const existingHash = `${fs.readFileSync(hashFileName)}`;
|
18
|
+
if (!existingHash) {
|
19
|
+
return false;
|
20
|
+
}
|
21
|
+
|
22
|
+
// Calculate the hash of the dist/ directory
|
23
|
+
const result = await hashElement(inputDir, config);
|
24
|
+
const newHash = result.hash;
|
25
|
+
|
26
|
+
return newHash === existingHash;
|
27
|
+
};
|
28
|
+
|
29
|
+
isUpToDate(inputDir, hashFileName).then(upToDate => {
|
30
|
+
process.exit(upToDate ? 0 : 1); // 0 means success (it is up to date), 1 means failure (must rebuild the dist/)
|
31
|
+
});
|
@@ -11,6 +11,20 @@ let isNodeValue = false;
|
|
11
11
|
// matches event handlers @click= and boolean attrs ?disabled=
|
12
12
|
const dynamicAttributeRgx = /\s(\?|@)([a-zA-Z|-]+)="?\s*$/;
|
13
13
|
|
14
|
+
if (!String.prototype.replaceAll) {
|
15
|
+
String.prototype.replaceAll = function(str, newStr){
|
16
|
+
|
17
|
+
// If a regex pattern
|
18
|
+
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
|
19
|
+
return this.replace(str, newStr);
|
20
|
+
}
|
21
|
+
|
22
|
+
// If a string
|
23
|
+
return this.replace(new RegExp(str, 'g'), newStr);
|
24
|
+
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
14
28
|
function HTMLLitVisitor(debug) {
|
15
29
|
this.blockCounter = 0;
|
16
30
|
this.keys = [];
|
@@ -18,7 +32,7 @@ function HTMLLitVisitor(debug) {
|
|
18
32
|
this.result = "";
|
19
33
|
this.mainBlock = "";
|
20
34
|
this.blockPath = "context";
|
21
|
-
this.blockParameters = ["context"];
|
35
|
+
this.blockParameters = ["context", "tags", "suffix"];
|
22
36
|
this.paths = []; //contains all normalized relative paths
|
23
37
|
this.debug = debug;
|
24
38
|
if (this.debug) {
|
@@ -34,7 +48,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
|
|
34
48
|
this.keys.push(key);
|
35
49
|
this.debug && this.blockByNumber.push(key);
|
36
50
|
|
37
|
-
this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") =>
|
51
|
+
this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") => ";
|
38
52
|
|
39
53
|
if (this.keys.length > 1) { //it's a nested block
|
40
54
|
this.blocks[this.prevKey()] += this.currentKey() + "(" + this.blockParameters.join(", ") + ")";
|
@@ -45,7 +59,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
|
|
45
59
|
|
46
60
|
this.blocks[this.currentKey()] += "html`";
|
47
61
|
Visitor.prototype.Program.call(this, program);
|
48
|
-
this.blocks[this.currentKey()] += "`;
|
62
|
+
this.blocks[this.currentKey()] += "`;";
|
49
63
|
|
50
64
|
this.keys.pop(key);
|
51
65
|
};
|
@@ -54,7 +68,7 @@ HTMLLitVisitor.prototype.ContentStatement = function(content) {
|
|
54
68
|
Visitor.prototype.ContentStatement.call(this, content);
|
55
69
|
// let content = content.orgiinal; // attribute="__ attribute = "__ attribute ="__
|
56
70
|
|
57
|
-
|
71
|
+
let contentStatement = content.original;
|
58
72
|
skipIfDefined = !!dynamicAttributeRgx.exec(contentStatement);
|
59
73
|
|
60
74
|
const closingIndex = contentStatement.lastIndexOf(">");
|
@@ -63,6 +77,9 @@ HTMLLitVisitor.prototype.ContentStatement = function(content) {
|
|
63
77
|
isNodeValue = closingIndex > openingIndex;
|
64
78
|
}
|
65
79
|
|
80
|
+
// Scope custom element tags
|
81
|
+
contentStatement = contentStatement.replaceAll(/(<\/?\s*)([a-zA-Z0-9_]+-[a-zA-Z0-9_-]+)/g, "$1\${scopeTag(\"$2\", tags, suffix)}");
|
82
|
+
|
66
83
|
this.blocks[this.currentKey()] += contentStatement;
|
67
84
|
};
|
68
85
|
|
@@ -46,8 +46,8 @@ function getSVGMatches(template) {
|
|
46
46
|
|
47
47
|
function getSVGBlock(input, blockCounter) {
|
48
48
|
return {
|
49
|
-
usage: `\${blockSVG${blockCounter}(context)}`,
|
50
|
-
definition: `\nconst blockSVG${blockCounter} = (context) =>
|
49
|
+
usage: `\${blockSVG${blockCounter}(context, tags, suffix)}`,
|
50
|
+
definition: `\nconst blockSVG${blockCounter} = (context, tags, suffix) => svg\`${input}\`;`,
|
51
51
|
};
|
52
52
|
}
|
53
53
|
|
@@ -55,7 +55,7 @@ function replaceInternalBlocks(template, svgContent) {
|
|
55
55
|
const internalBlocks = svgContent.match(blockrx) || [];
|
56
56
|
|
57
57
|
internalBlocks.forEach(blockName => {
|
58
|
-
const rx = new RegExp(`const ${blockName}.*(html\`)
|
58
|
+
const rx = new RegExp(`const ${blockName}.*(html\`).*;`);
|
59
59
|
template = template.replace(rx, (match, p1) => {
|
60
60
|
return match.replace(p1, "svg\`");
|
61
61
|
});
|
@@ -1,17 +1,10 @@
|
|
1
1
|
const buildRenderer = (controlName, litTemplate) => {
|
2
|
-
return
|
3
|
-
|
4
|
-
|
5
|
-
import { html, svg, repeat, classMap, styleMap, unsafeHTML, setTags, setSuffix } from '@ui5/webcomponents-base/dist/renderer/LitRenderer.js';
|
2
|
+
return `/* eslint no-unused-vars: 0 */
|
3
|
+
import { html, svg, repeat, classMap, styleMap, ifDefined, unsafeHTML, scopeTag } from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
4
|
+
|
6
5
|
${litTemplate}
|
7
6
|
|
8
|
-
|
9
|
-
setTags(tags);
|
10
|
-
setSuffix(suffix);
|
11
|
-
return block0(context);
|
12
|
-
};
|
13
|
-
|
14
|
-
export default main;`
|
7
|
+
export default block0;`;
|
15
8
|
};
|
16
9
|
|
17
10
|
module.exports = {
|
package/lib/i18n/toJSON.js
CHANGED
@@ -30,7 +30,7 @@ const messagesJSONDist = path.normalize(`${process.argv[3]}`);
|
|
30
30
|
const outputFile = path.normalize(`${messagesJSONDist}/${filename}.json`);
|
31
31
|
|
32
32
|
fs.writeFileSync(outputFile, JSON.stringify(properties));
|
33
|
-
console.log(`[i18n]: "${filename}.json" has been generated!`);
|
33
|
+
// console.log(`[i18n]: "${filename}.json" has been generated!`);
|
34
34
|
};
|
35
35
|
|
36
36
|
mkdirp.sync(messagesJSONDist);
|
@@ -107,6 +107,19 @@ const updatePackageFile = () => {
|
|
107
107
|
"prepublishOnly": "npm run build"
|
108
108
|
};
|
109
109
|
|
110
|
+
// make convinient exports (no dist in component path)
|
111
|
+
// export the rest that is used directly or via require.resolve in scripts
|
112
|
+
packageContent.exports = {
|
113
|
+
"./.port": "./.port",
|
114
|
+
"./src/*": "./src/*",
|
115
|
+
"./dist/*": "./dist/*",
|
116
|
+
"./package.json": "./package.json",
|
117
|
+
"./bundle.esm.js": "./bundle.esm.js",
|
118
|
+
"./bundle.es5.js": "./bundle.es5.js",
|
119
|
+
"./bundle.common.js": "./bundle.common.js",
|
120
|
+
"./*": "./dist/*"
|
121
|
+
}
|
122
|
+
|
110
123
|
packageContent.ui5 = {
|
111
124
|
webComponentsPackage: true
|
112
125
|
};
|
package/lib/jsdoc/plugin.js
CHANGED
@@ -31,6 +31,10 @@
|
|
31
31
|
*
|
32
32
|
* tagname
|
33
33
|
*
|
34
|
+
* native
|
35
|
+
*
|
36
|
+
* allowPreventDefault
|
37
|
+
*
|
34
38
|
* It furthermore listens to the following JSDoc3 events to implement additional functionality
|
35
39
|
*
|
36
40
|
* parseBegin
|
@@ -2081,6 +2085,20 @@ exports.defineTags = function(dictionary) {
|
|
2081
2085
|
doclet.tagname = tag.value;
|
2082
2086
|
}
|
2083
2087
|
});
|
2088
|
+
|
2089
|
+
dictionary.defineTag('allowPreventDefault', {
|
2090
|
+
mustHaveValue: false,
|
2091
|
+
onTagged: function(doclet, tag) {
|
2092
|
+
doclet.allowPreventDefault = true;
|
2093
|
+
}
|
2094
|
+
});
|
2095
|
+
|
2096
|
+
dictionary.defineTag('native', {
|
2097
|
+
mustHaveValue: false,
|
2098
|
+
onTagged: function(doclet, tag) {
|
2099
|
+
doclet.native = true;
|
2100
|
+
}
|
2101
|
+
});
|
2084
2102
|
};
|
2085
2103
|
|
2086
2104
|
exports.handlers = {
|
@@ -2882,6 +2882,12 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2882
2882
|
attrib("module", member.__ui5.module);
|
2883
2883
|
attrib("export", undefined, '', true);
|
2884
2884
|
}
|
2885
|
+
if (member.allowPreventDefault) {
|
2886
|
+
attrib("allowPreventDefault", true);
|
2887
|
+
}
|
2888
|
+
if (member.native) {
|
2889
|
+
attrib("native", true);
|
2890
|
+
}
|
2885
2891
|
attrib("visibility", visibility(member), 'public');
|
2886
2892
|
if ( member.scope === 'static' ) {
|
2887
2893
|
attrib("static", true, false, /* raw = */true);
|
@@ -1,4 +1,3 @@
|
|
1
|
-
const postcss = require('postcss');
|
2
1
|
const fs = require('fs');
|
3
2
|
const path = require('path');
|
4
3
|
const mkdirp = require('mkdirp');
|
@@ -25,18 +24,22 @@ const proccessCSS = css => {
|
|
25
24
|
return JSON.stringify(css);
|
26
25
|
}
|
27
26
|
|
28
|
-
module.exports =
|
27
|
+
module.exports = function (opts) {
|
29
28
|
opts = opts || {};
|
30
29
|
|
31
|
-
return
|
32
|
-
|
33
|
-
|
30
|
+
return {
|
31
|
+
postcssPlugin: 'postcss-css-to-esm',
|
32
|
+
Once (root) {
|
33
|
+
let css = root.toString();
|
34
|
+
css = proccessCSS(css);
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
|
37
|
+
mkdirp.sync(path.dirname(targetFile));
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
39
|
+
const filePath = `${targetFile}.js`;
|
40
|
+
const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
|
41
|
+
fs.writeFileSync(filePath, `${defaultTheme}export default ${css};`);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
};
|
45
|
+
module.exports.postcss = true;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
const postcss = require('postcss');
|
2
1
|
const fs = require('fs');
|
3
2
|
const path = require('path');
|
4
3
|
const mkdirp = require('mkdirp');
|
@@ -11,17 +10,22 @@ const proccessCSS = css => {
|
|
11
10
|
return css;
|
12
11
|
}
|
13
12
|
|
14
|
-
module.exports =
|
13
|
+
module.exports = function (opts) {
|
15
14
|
opts = opts || {};
|
16
15
|
|
17
|
-
return
|
18
|
-
|
19
|
-
|
16
|
+
return {
|
17
|
+
postcssPlugin: 'postcss-css-to-json',
|
18
|
+
Once (root) {
|
19
|
+
let css = root.toString();
|
20
|
+
css = proccessCSS(css);
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\assets\\");
|
23
|
+
mkdirp.sync(path.dirname(targetFile));
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
25
|
+
const filePath = `${targetFile}.json`;
|
26
|
+
fs.writeFileSync(filePath, JSON.stringify({_: css}));
|
27
|
+
}
|
28
|
+
};
|
29
|
+
};
|
30
|
+
|
31
|
+
module.exports.postcss = true;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
const chokidar = require("chokidar");
|
2
|
+
const commandLineArgs = require("command-line-args");
|
3
|
+
const { exec } = require("child_process");
|
4
|
+
|
5
|
+
const options = commandLineArgs([
|
6
|
+
{ name: "srcFiles", type: String },
|
7
|
+
]);
|
8
|
+
|
9
|
+
const runPostcss = path => {
|
10
|
+
let command = `postcss ${path} --config config/postcss.components --base src --dir dist/css/`;
|
11
|
+
console.log(`Executing: ${command}`);
|
12
|
+
exec(command, (err, stdout, stderr) => {
|
13
|
+
if (err) {
|
14
|
+
console.log(`Could not run postcss for ${path}. Error: ${err}`);
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
command = `${command} -w`;
|
19
|
+
console.log(`Executing: ${command}`);
|
20
|
+
exec(command, (err, stdout, stderr) => {
|
21
|
+
if (err) {
|
22
|
+
console.log(`Could not run postcss in watch mode for ${path}. Error: ${err}`);
|
23
|
+
}
|
24
|
+
});
|
25
|
+
};
|
26
|
+
|
27
|
+
let ready = false; // Do nothing until the ready event has been fired (we don't want to recompile all files initially)
|
28
|
+
const watcher = chokidar.watch(options.srcFiles);
|
29
|
+
watcher.on("ready", () => {
|
30
|
+
ready = true; // Initial scan is over -> waiting for new files
|
31
|
+
});
|
32
|
+
watcher.on("add", path => {
|
33
|
+
if (ready) {
|
34
|
+
runPostcss(path);
|
35
|
+
}
|
36
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const glob = require("glob");
|
3
|
+
|
4
|
+
const basePath = process.argv[2];
|
5
|
+
|
6
|
+
const replaceGlobalCoreUsage = (srcPath) => {
|
7
|
+
|
8
|
+
const original = fs.readFileSync(srcPath).toString();
|
9
|
+
let replaced = original.replace(/sap\.ui\.getCore\(\)/g, `Core`);
|
10
|
+
|
11
|
+
if (original !== replaced) {
|
12
|
+
replaced = `import Core from 'sap/ui/core/Core';
|
13
|
+
${replaced}`;
|
14
|
+
fs.writeFileSync(srcPath, replaced);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
|
18
|
+
const fileNames = glob.sync(basePath + "**/*.js");
|
19
|
+
fileNames.forEach(replaceGlobalCoreUsage);
|
20
|
+
console.log("Success: Replaced global core usage in:", basePath);
|
package/lib/scoping/lint-src.js
CHANGED
@@ -10,7 +10,7 @@ const errors = [];
|
|
10
10
|
glob.sync(path.join(process.cwd(), "src/**/*.css")).forEach(file => {
|
11
11
|
let content = String(fs.readFileSync(file));
|
12
12
|
tags.forEach(tag => {
|
13
|
-
if (content.match(new RegExp(`(^|[
|
13
|
+
if (content.match(new RegExp(`(^|[^\.\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
|
14
14
|
errors.push(`Warning! ${tag} found in ${file}`);
|
15
15
|
}
|
16
16
|
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const commandLineArgs = require("command-line-args");
|
4
|
+
const { exec } = require("child_process");
|
5
|
+
const colors = require("colors/safe");
|
6
|
+
const isPortReachable = require("is-port-reachable");
|
7
|
+
|
8
|
+
const options = commandLineArgs([
|
9
|
+
{ name: "port", type: Number },
|
10
|
+
{ name: "portStep", type: Number },
|
11
|
+
{ name: "packageName", type: String },
|
12
|
+
{ name: "dir", type: String },
|
13
|
+
{ name: "config", type: String },
|
14
|
+
]);
|
15
|
+
const serveConfig = path.join(__dirname, `serve.json`);
|
16
|
+
|
17
|
+
const requestPort = async () => {
|
18
|
+
const serveProcess = (await gen.next()).value;
|
19
|
+
serveProcess.stdout.on('data', data => {
|
20
|
+
const matches = data.match(/Accepting connections at .*?:(\d+)/);
|
21
|
+
if (matches) {
|
22
|
+
console.log(colors.yellow(`Reserved port ${matches[1]} for the ${options.packageName} package.`));
|
23
|
+
fs.writeFileSync(".port", matches[1]);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
};
|
27
|
+
|
28
|
+
async function* serverGenerator(callback, port = 8080, step = 1) {
|
29
|
+
while (true) {
|
30
|
+
const portInUse = await isPortReachable(port, { host: "127.0.0.1" });
|
31
|
+
if (!portInUse) {
|
32
|
+
const command = `serve --config "${serveConfig}" --no-port-switching --no-clipboard -l ${port} ${options.dir}`;
|
33
|
+
console.log(colors.yellow(`Executing: ${command}`));
|
34
|
+
const serveProcess = exec(command, (err) => {
|
35
|
+
console.log(colors.yellow(`Port ${port} already in use.`));
|
36
|
+
callback();
|
37
|
+
});
|
38
|
+
yield serveProcess;
|
39
|
+
}
|
40
|
+
port += step;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
const gen = serverGenerator(requestPort, options.port, options.portStep);
|
45
|
+
|
46
|
+
requestPort();
|
File without changes
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-6d98d0c29",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -22,63 +22,63 @@
|
|
22
22
|
"directory": "packages/tools"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@babel/cli": "^7.
|
26
|
-
"@babel/core": "^7.
|
27
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
28
|
-
"@babel/preset-env": "^7.
|
29
|
-
"@rollup/plugin-babel": "^5.
|
25
|
+
"@babel/cli": "^7.13.10",
|
26
|
+
"@babel/core": "^7.13.10",
|
27
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
|
28
|
+
"@babel/preset-env": "^7.13.10",
|
29
|
+
"@rollup/plugin-babel": "^5.3.0",
|
30
30
|
"@rollup/plugin-json": "^4.1.0",
|
31
|
-
"@rollup/plugin-node-resolve": "^
|
32
|
-
"@rollup/plugin-url": "^
|
33
|
-
"@wdio/cli": "^
|
34
|
-
"@wdio/dot-reporter": "^
|
35
|
-
"@wdio/local-runner": "^
|
36
|
-
"@wdio/mocha-framework": "^
|
37
|
-
"@wdio/spec-reporter": "^
|
38
|
-
"@wdio/sync": "^
|
39
|
-
"@webcomponents/webcomponentsjs": "^2.
|
40
|
-
"chai": "^4.
|
41
|
-
"
|
42
|
-
"
|
31
|
+
"@rollup/plugin-node-resolve": "^11.2.0",
|
32
|
+
"@rollup/plugin-url": "^6.0.0",
|
33
|
+
"@wdio/cli": "^7.2.0",
|
34
|
+
"@wdio/dot-reporter": "^7.2.0",
|
35
|
+
"@wdio/local-runner": "^7.2.0",
|
36
|
+
"@wdio/mocha-framework": "^7.2.0",
|
37
|
+
"@wdio/spec-reporter": "^7.2.0",
|
38
|
+
"@wdio/sync": "^7.2.0",
|
39
|
+
"@webcomponents/webcomponentsjs": "^2.5.0",
|
40
|
+
"chai": "^4.3.4",
|
41
|
+
"child_process": "^1.0.2",
|
42
|
+
"chokidar": "^3.5.1",
|
43
|
+
"chokidar-cli": "^2.1.0",
|
44
|
+
"clean-css": "^5.1.1",
|
45
|
+
"colors": "^1.4.0",
|
43
46
|
"command-line-args": "^5.1.1",
|
44
|
-
"concurrently": "^
|
45
|
-
"cross-env": "^
|
47
|
+
"concurrently": "^6.0.0",
|
48
|
+
"cross-env": "^7.0.3",
|
46
49
|
"cssnano": "^4.1.10",
|
47
|
-
"escodegen": "^
|
48
|
-
"eslint": "^
|
49
|
-
"eslint-config-airbnb-base": "^
|
50
|
-
"eslint-plugin-import": "^2.
|
50
|
+
"escodegen": "^2.0.0",
|
51
|
+
"eslint": "^7.22.0",
|
52
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
53
|
+
"eslint-plugin-import": "^2.22.1",
|
51
54
|
"esprima": "^4.0.1",
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"
|
55
|
+
"folder-hash": "^4.0.1",
|
56
|
+
"getopts": "^2.3.0",
|
57
|
+
"glob": "^7.1.6",
|
58
|
+
"handlebars": "^4.7.7",
|
59
|
+
"is-port-reachable": "^3.0.0",
|
60
|
+
"jsdoc": "^3.6.6",
|
56
61
|
"json-beautify": "^1.1.1",
|
57
|
-
"mkdirp": "^0.
|
62
|
+
"mkdirp": "^1.0.4",
|
58
63
|
"npm-run-all": "^4.1.3",
|
59
|
-
"nps": "^5.
|
60
|
-
"postcss": "^
|
61
|
-
"postcss-cli": "^
|
62
|
-
"postcss-combine-duplicated-selectors": "^
|
63
|
-
"postcss-import": "^
|
64
|
-
"properties-reader": "^
|
65
|
-
"puppeteer": "^
|
64
|
+
"nps": "^5.10.0",
|
65
|
+
"postcss": "^8.2.10",
|
66
|
+
"postcss-cli": "^8.3.1",
|
67
|
+
"postcss-combine-duplicated-selectors": "^10.0.2",
|
68
|
+
"postcss-import": "^14.0.0",
|
69
|
+
"properties-reader": "^2.2.0",
|
70
|
+
"puppeteer": "^8.0.0",
|
66
71
|
"recursive-readdir": "^2.2.2",
|
67
|
-
"rimraf": "^
|
68
|
-
"rollup": "^2.
|
69
|
-
"rollup-plugin-filesize": "^
|
70
|
-
"rollup-plugin-livereload": "^
|
71
|
-
"rollup-plugin-
|
72
|
-
"rollup-plugin-string": "^2.0.2",
|
72
|
+
"rimraf": "^3.0.2",
|
73
|
+
"rollup": "^2.41.4",
|
74
|
+
"rollup-plugin-filesize": "^9.1.1",
|
75
|
+
"rollup-plugin-livereload": "^2.0.0",
|
76
|
+
"rollup-plugin-string": "^3.0.0",
|
73
77
|
"rollup-plugin-terser": "^7.0.2",
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"wdio-chromedriver-service": "^6.0.2"
|
78
|
+
"serve": "^12.0.0",
|
79
|
+
"wdio-chromedriver-service": "^7.0.0"
|
77
80
|
},
|
78
81
|
"peerDependencies": {
|
79
82
|
"chromedriver": "*"
|
80
|
-
},
|
81
|
-
"resolutions": {
|
82
|
-
"rollup-plugin-livereload/livereload/chokidar": "^3.x"
|
83
83
|
}
|
84
84
|
}
|