@ui5/webcomponents-tools 0.0.0-c6c04c609 → 0.0.0-c8721b8d2
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 +83 -0
- package/assets-meta.js +6 -0
- package/components-package/eslint.js +1 -0
- package/components-package/nps.js +31 -26
- package/components-package/postcss.components.js +1 -24
- package/components-package/postcss.themes.js +1 -30
- package/icons-collection/nps.js +6 -4
- package/lib/css-processors/css-processor-components.mjs +77 -0
- package/lib/css-processors/css-processor-themes.mjs +79 -0
- package/lib/{postcss-scope-vars/index.js → css-processors/scope-variables.mjs} +17 -30
- package/lib/{postcss-css-to-esm/index.js → css-processors/shared.mjs} +36 -50
- package/lib/dev-server/custom-hot-update-plugin.js +4 -4
- package/lib/esm-abs-to-rel/index.js +4 -1
- package/lib/generate-js-imports/illustrations.js +8 -5
- package/lib/generate-json-imports/i18n.js +9 -4
- package/lib/generate-json-imports/themes.js +9 -4
- package/lib/jsdoc/preprocess.js +1 -1
- package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
- package/lib/scoping/get-all-tags.js +1 -1
- package/lib/scoping/scope-test-pages.js +2 -1
- package/package.json +5 -7
- package/lib/postcss-css-to-json/index.js +0 -47
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/postcss-p/postcss-p.mjs +0 -14
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,89 @@
|
|
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.21.0](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.5...v1.21.0) (2024-01-05)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [1.21.0-rc.5](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.4...v1.21.0-rc.5) (2024-01-04)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
# [1.21.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.3...v1.21.0-rc.4) (2023-12-28)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
# [1.21.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.2...v1.21.0-rc.3) (2023-12-21)
|
31
|
+
|
32
|
+
|
33
|
+
### Bug Fixes
|
34
|
+
|
35
|
+
* declare webpackChunkName in more generated dynamic imports ([#8029](https://github.com/SAP/ui5-webcomponents/issues/8029)) ([c85fa23](https://github.com/SAP/ui5-webcomponents/commit/c85fa23bd32574434f537df95c7507a7f1a48b5e))
|
36
|
+
|
37
|
+
|
38
|
+
### Features
|
39
|
+
|
40
|
+
* **tools:** Optimize build by switching css processing to esbuild ([#8008](https://github.com/SAP/ui5-webcomponents/issues/8008)) ([b4d411f](https://github.com/SAP/ui5-webcomponents/commit/b4d411f00f8d74ccecb2d02254126243faf53dfd))
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
# [1.21.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.1...v1.21.0-rc.2) (2023-12-14)
|
47
|
+
|
48
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
# [1.21.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.0...v1.21.0-rc.1) (2023-12-08)
|
55
|
+
|
56
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
# [1.21.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.20.0...v1.21.0-rc.0) (2023-12-07)
|
63
|
+
|
64
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
# [1.20.0](https://github.com/SAP/ui5-webcomponents/compare/v1.20.0-rc.3...v1.20.0) (2023-12-04)
|
71
|
+
|
72
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
# [1.20.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.20.0-rc.2...v1.20.0-rc.3) (2023-11-30)
|
79
|
+
|
80
|
+
|
81
|
+
### Features
|
82
|
+
|
83
|
+
* register custom theme properties ([#7750](https://github.com/SAP/ui5-webcomponents/issues/7750)) ([c6c04c6](https://github.com/SAP/ui5-webcomponents/commit/c6c04c609d82a7442bdf79ef5bba46a406859a27))
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
6
89
|
# [1.20.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.20.0-rc.1...v1.20.0-rc.2) (2023-11-23)
|
7
90
|
|
8
91
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
package/assets-meta.js
CHANGED
@@ -25,6 +25,7 @@ const assetsMeta = {
|
|
25
25
|
"ar",
|
26
26
|
"bg",
|
27
27
|
"ca",
|
28
|
+
"cnr",
|
28
29
|
"cs",
|
29
30
|
"cy",
|
30
31
|
"da",
|
@@ -52,6 +53,7 @@ const assetsMeta = {
|
|
52
53
|
"ko",
|
53
54
|
"lt",
|
54
55
|
"lv",
|
56
|
+
"mk",
|
55
57
|
"ms",
|
56
58
|
"nl",
|
57
59
|
"no",
|
@@ -63,6 +65,7 @@ const assetsMeta = {
|
|
63
65
|
"sh",
|
64
66
|
"sk",
|
65
67
|
"sl",
|
68
|
+
"sr",
|
66
69
|
"sv",
|
67
70
|
"th",
|
68
71
|
"tr",
|
@@ -80,6 +83,7 @@ const assetsMeta = {
|
|
80
83
|
"ar_SA",
|
81
84
|
"bg",
|
82
85
|
"ca",
|
86
|
+
// "cnr_ME" - cldr for not available yet
|
83
87
|
"cs",
|
84
88
|
"da",
|
85
89
|
"de",
|
@@ -127,6 +131,7 @@ const assetsMeta = {
|
|
127
131
|
"lt",
|
128
132
|
"lv",
|
129
133
|
"ms",
|
134
|
+
// "mk_MK" cldr not available yet
|
130
135
|
"nb",
|
131
136
|
"nl",
|
132
137
|
"nl_BE",
|
@@ -139,6 +144,7 @@ const assetsMeta = {
|
|
139
144
|
"sk",
|
140
145
|
"sl",
|
141
146
|
"sr",
|
147
|
+
// "sr_Cyrl_RS" - cldr not available yet
|
142
148
|
"sr_Latn",
|
143
149
|
"sv",
|
144
150
|
"th",
|
@@ -11,14 +11,17 @@ const getScripts = (options) => {
|
|
11
11
|
const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath} ${illustration.collection}`);
|
12
12
|
const createIllustrationsJSImportsScript = illustrations.join(" && ");
|
13
13
|
|
14
|
-
// The script creates the "
|
14
|
+
// The script creates the "src/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
|
15
15
|
const createIllustrationsLoadersScript = illustrationsData.map(illustrations => `node ${LIB}/generate-js-imports/illustrations.js ${illustrations.destinationPath} ${illustrations.dynamicImports.outputFile} ${illustrations.collection} ${illustrations.dynamicImports.location} ${illustrations.dynamicImports.prefix || '\"\"'} ${illustrations.dynamicImports.filterOut.join(" ")}`).join(" && ");
|
16
16
|
|
17
17
|
const tsOption = options.typescript;
|
18
|
-
const
|
19
|
-
|
18
|
+
const tsCommandOld = tsOption ? "tsc" : "";
|
19
|
+
let tsWatchCommandStandalone = tsOption ? "tsc --watch" : "";
|
20
|
+
// this command is only used for standalone projects. monorepo projects get their watch from vite, so opt-out here
|
21
|
+
if (options.noWatchTS) {
|
22
|
+
tsWatchCommandStandalone = "";
|
23
|
+
}
|
20
24
|
const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
|
21
|
-
const copySrcGenerated = tsOption ? "" : "copy.srcGenerated";
|
22
25
|
|
23
26
|
if (tsOption) {
|
24
27
|
try {
|
@@ -54,19 +57,24 @@ const getScripts = (options) => {
|
|
54
57
|
clean: 'rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
|
55
58
|
lint: `eslint . ${eslintConfig}`,
|
56
59
|
lintfix: `eslint . ${eslintConfig} --fix`,
|
57
|
-
|
58
|
-
default: `${tsCrossEnv} nps
|
60
|
+
generate: {
|
61
|
+
default: `${tsCrossEnv} nps prepare.all`,
|
59
62
|
all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
|
60
63
|
styleRelated: "nps build.styles build.jsonImports build.jsImports",
|
61
64
|
},
|
62
|
-
|
65
|
+
prepare: {
|
66
|
+
default: `${tsCrossEnv} nps clean prepare.all copy prepare.typescript generateAPI`,
|
67
|
+
all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps build.illustrations"',
|
68
|
+
styleRelated: "nps build.styles build.jsonImports build.jsImports",
|
69
|
+
typescript: tsCommandOld,
|
70
|
+
},
|
63
71
|
build: {
|
64
|
-
default: "nps prepare lint build.bundle",
|
65
|
-
templates: `mkdirp
|
72
|
+
default: "nps prepare lint build.bundle", // build.bundle2
|
73
|
+
templates: `mkdirp src/generated/templates && ${tsCrossEnv} node "${LIB}/hbs2ui5/index.js" -d src/ -o src/generated/templates`,
|
66
74
|
styles: {
|
67
|
-
default: `nps build.styles.themes build.styles.components
|
68
|
-
themes: `node "${LIB}/
|
69
|
-
components: "
|
75
|
+
default: `concurrently "nps build.styles.themes" "nps build.styles.components"`,
|
76
|
+
themes: `node "${LIB}/css-processors/css-processor-themes.mjs"`,
|
77
|
+
components: `node "${LIB}/css-processors/css-processor-components.mjs"`,
|
70
78
|
},
|
71
79
|
i18n: {
|
72
80
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
@@ -74,38 +82,35 @@ const getScripts = (options) => {
|
|
74
82
|
json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
|
75
83
|
},
|
76
84
|
jsonImports: {
|
77
|
-
default: "mkdirp
|
78
|
-
themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes
|
79
|
-
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n
|
85
|
+
default: "mkdirp src/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
|
86
|
+
themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes src/generated/json-imports`,
|
87
|
+
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n src/generated/json-imports`,
|
80
88
|
},
|
81
89
|
jsImports: {
|
82
|
-
default: "mkdirp
|
90
|
+
default: "mkdirp src/generated/js-imports && nps build.jsImports.illustrationsLoaders",
|
83
91
|
illustrationsLoaders: createIllustrationsLoadersScript,
|
84
92
|
},
|
85
93
|
bundle: `vite build ${viteConfig}`,
|
94
|
+
bundle2: ``,
|
86
95
|
illustrations: createIllustrationsJSImportsScript,
|
87
96
|
},
|
88
97
|
copy: {
|
89
98
|
default: "nps copy.src copy.props",
|
90
|
-
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
91
|
-
|
99
|
+
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/`,
|
100
|
+
// srcGenerated2: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.{js,json}" dist/generated/`,
|
92
101
|
props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
|
93
102
|
},
|
94
103
|
watch: {
|
95
|
-
default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.
|
104
|
+
default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.typescript" "nps watch.api" "nps watch.src" "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
|
96
105
|
devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
|
97
106
|
src: 'nps "copy.src --watch --safe --skip-initial-copy"',
|
98
|
-
typescript:
|
107
|
+
typescript: tsWatchCommandStandalone,
|
99
108
|
props: 'nps "copy.props --watch --safe --skip-initial-copy"',
|
100
109
|
bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
|
101
110
|
styles: {
|
102
111
|
default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
|
103
112
|
themes: 'nps "build.styles.themes -w"',
|
104
|
-
components:
|
105
|
-
default: 'concurrently "nps watch.styles.components.existingFiles" "nps watch.styles.components.newFiles"',
|
106
|
-
existingFiles: `nps "build.styles.components -w"`,
|
107
|
-
newFiles: `node "${LIB}/postcss-new-files/index.js" --srcFiles="src/themes/*.css"`,
|
108
|
-
},
|
113
|
+
components: `nps "build.styles.components -w"`,
|
109
114
|
},
|
110
115
|
templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
|
111
116
|
api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
|
@@ -117,7 +122,7 @@ const getScripts = (options) => {
|
|
117
122
|
"test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
|
118
123
|
startWithScope: "nps scope.prepare scope.watchWithBundle",
|
119
124
|
scope: {
|
120
|
-
prepare: "nps scope.lint
|
125
|
+
prepare: "nps scope.lint scope.testPages",
|
121
126
|
lint: `node "${LIB}/scoping/lint-src.js"`,
|
122
127
|
testPages: {
|
123
128
|
default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
|
@@ -1,24 +1 @@
|
|
1
|
-
|
2
|
-
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
3
|
-
const postcssScopeVars = require('../lib/postcss-scope-vars/index.js');
|
4
|
-
const cssnano = require('cssnano');
|
5
|
-
const fs = require("fs")
|
6
|
-
|
7
|
-
|
8
|
-
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
9
|
-
|
10
|
-
module.exports = {
|
11
|
-
plugins: [
|
12
|
-
postcssImport(),
|
13
|
-
cssnano({
|
14
|
-
preset: [
|
15
|
-
'default', {
|
16
|
-
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
17
|
-
mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
|
18
|
-
},
|
19
|
-
]
|
20
|
-
}),
|
21
|
-
postcssScopeVars({version: packageJSON.version}),
|
22
|
-
postcssCSStoESM({ toReplace: 'src', includeDefaultTheme: true, packageName: packageJSON.name }),
|
23
|
-
]
|
24
|
-
}
|
1
|
+
module.exports = {}
|
@@ -1,30 +1 @@
|
|
1
|
-
|
2
|
-
const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
|
3
|
-
const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
|
4
|
-
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
5
|
-
const postcssScopeVars = require('../lib/postcss-scope-vars/index.js');
|
6
|
-
const cssnano = require('cssnano');
|
7
|
-
const fs = require("fs");
|
8
|
-
|
9
|
-
|
10
|
-
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
11
|
-
const packageName = packageJSON.name;
|
12
|
-
|
13
|
-
module.exports = {
|
14
|
-
plugins: [
|
15
|
-
postcssScopeVars({version: packageJSON.version}),
|
16
|
-
postcssImport(),
|
17
|
-
combineSelectors({
|
18
|
-
removeDuplicatedProperties: true
|
19
|
-
}),
|
20
|
-
cssnano({
|
21
|
-
preset: [
|
22
|
-
'default', {
|
23
|
-
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
24
|
-
},
|
25
|
-
]
|
26
|
-
},),
|
27
|
-
postcssCSStoJSON({ toReplace: 'src', packageName }),
|
28
|
-
postcssCSStoESM({ toReplace: 'src', packageName }),
|
29
|
-
]
|
30
|
-
};
|
1
|
+
module.exports = {};
|
package/icons-collection/nps.js
CHANGED
@@ -41,22 +41,24 @@ const copyIconAssetsCommand = (options) => {
|
|
41
41
|
const getScripts = (options) => {
|
42
42
|
const createJSImportsCmd = createIconImportsCommand(options);
|
43
43
|
const copyAssetsCmd = copyIconAssetsCommand(options);
|
44
|
-
const tsCommand = options.typescript ? "tsc" : "";
|
44
|
+
const tsCommand = options.typescript ? "tsc --build" : "";
|
45
45
|
const tsCrossEnv = options.typescript ? "cross-env UI5_TS=true" : "";
|
46
46
|
|
47
47
|
const scripts = {
|
48
48
|
clean: "rimraf dist && rimraf src/generated",
|
49
49
|
copy: copyAssetsCmd,
|
50
|
+
generate: `${tsCrossEnv} nps clean copy build.i18n build.icons build.jsonImports copyjson`,
|
51
|
+
copyjson: "copy-and-watch \"src/generated/**/*.json\" dist/generated/",
|
50
52
|
build: {
|
51
53
|
default: `${tsCrossEnv} nps clean copy build.i18n typescript build.icons build.jsonImports`,
|
52
54
|
i18n: {
|
53
55
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
54
56
|
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
55
|
-
json: `mkdirp
|
57
|
+
json: `mkdirp src/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n src/generated/assets/i18n`,
|
56
58
|
},
|
57
59
|
jsonImports: {
|
58
|
-
default: "mkdirp
|
59
|
-
i18n: `node "${LIB}/generate-json-imports/i18n.js"
|
60
|
+
default: "mkdirp src/generated/json-imports && nps build.jsonImports.i18n",
|
61
|
+
i18n: `node "${LIB}/generate-json-imports/i18n.js" src/generated/assets/i18n src/generated/json-imports`,
|
60
62
|
},
|
61
63
|
icons: createJSImportsCmd,
|
62
64
|
},
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { globby } from "globby";
|
2
|
+
import * as esbuild from 'esbuild'
|
3
|
+
import * as fs from "fs";
|
4
|
+
import * as path from "path";
|
5
|
+
import { writeFile, mkdir } from "fs/promises";
|
6
|
+
import chokidar from "chokidar";
|
7
|
+
import scopeVariables from "./scope-variables.mjs";
|
8
|
+
import { writeFileIfChanged, getFileContent } from "./shared.mjs";
|
9
|
+
|
10
|
+
const tsMode = process.env.UI5_TS === "true";
|
11
|
+
const extension = tsMode ? ".css.ts" : ".css.js";
|
12
|
+
|
13
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
14
|
+
const inputFilesGlob = "src/themes/*.css";
|
15
|
+
const restArgs = process.argv.slice(2);
|
16
|
+
|
17
|
+
let customPlugin = {
|
18
|
+
name: 'ui5-tools',
|
19
|
+
setup(build) {
|
20
|
+
build.initialOptions.write = false;
|
21
|
+
|
22
|
+
build.onEnd(result => {
|
23
|
+
result.outputFiles.forEach(async f => {
|
24
|
+
// scoping
|
25
|
+
const newText = scopeVariables(f.text, packageJSON);
|
26
|
+
await mkdir(path.dirname(f.path), {recursive: true});
|
27
|
+
writeFile(f.path, newText);
|
28
|
+
|
29
|
+
// JS/TS
|
30
|
+
const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
|
31
|
+
const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`", true);
|
32
|
+
writeFileIfChanged(jsPath, jsContent);
|
33
|
+
});
|
34
|
+
})
|
35
|
+
},
|
36
|
+
}
|
37
|
+
|
38
|
+
const getConfig = async () => {
|
39
|
+
const config = {
|
40
|
+
entryPoints: await globby(inputFilesGlob),
|
41
|
+
bundle: true,
|
42
|
+
minify: true,
|
43
|
+
outdir: 'dist/css',
|
44
|
+
outbase: 'src',
|
45
|
+
plugins: [
|
46
|
+
customPlugin,
|
47
|
+
]
|
48
|
+
};
|
49
|
+
return config;
|
50
|
+
}
|
51
|
+
|
52
|
+
if (restArgs.includes("-w")) {
|
53
|
+
let ready;
|
54
|
+
let config = await getConfig();
|
55
|
+
let ctx = await esbuild.context(config);
|
56
|
+
await ctx.watch()
|
57
|
+
console.log('watching...')
|
58
|
+
|
59
|
+
// when new component css files are added, they do not trigger a build as no one directly imports them
|
60
|
+
// restart the watch mode with the new entry points if a css file is added.
|
61
|
+
const watcher = chokidar.watch(inputFilesGlob);
|
62
|
+
watcher.on("ready", () => {
|
63
|
+
ready = true; // Initial scan is over -> waiting for new files
|
64
|
+
});
|
65
|
+
watcher.on("add", async path => {
|
66
|
+
if (ready) {
|
67
|
+
// new file
|
68
|
+
ctx.dispose();
|
69
|
+
config = await getConfig();
|
70
|
+
ctx = await esbuild.context(config);
|
71
|
+
ctx.watch();
|
72
|
+
}
|
73
|
+
});
|
74
|
+
} else {
|
75
|
+
const config = await getConfig();
|
76
|
+
const result = await esbuild.build(config);
|
77
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { globby } from "globby";
|
2
|
+
import * as esbuild from 'esbuild'
|
3
|
+
import * as fs from "fs";
|
4
|
+
import * as path from "path";
|
5
|
+
import { writeFile, mkdir } from "fs/promises";
|
6
|
+
import postcss from "postcss";
|
7
|
+
import combineDuplicatedSelectors from "../postcss-combine-duplicated-selectors/index.js"
|
8
|
+
import { writeFileIfChanged, stripThemingBaseContent, getFileContent } from "./shared.mjs";
|
9
|
+
import scopeVariables from "./scope-variables.mjs";
|
10
|
+
|
11
|
+
const tsMode = process.env.UI5_TS === "true";
|
12
|
+
const extension = tsMode ? ".css.ts" : ".css.js";
|
13
|
+
|
14
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
15
|
+
|
16
|
+
let inputFiles = await globby("src/**/parameters-bundle.css");
|
17
|
+
const restArgs = process.argv.slice(2);
|
18
|
+
|
19
|
+
const removeDuplicateSelectors = async (text) => {
|
20
|
+
const result = await postcss(combineDuplicatedSelectors).process(text);
|
21
|
+
return result.css;
|
22
|
+
}
|
23
|
+
|
24
|
+
let scopingPlugin = {
|
25
|
+
name: 'scoping',
|
26
|
+
setup(build) {
|
27
|
+
build.initialOptions.write = false;
|
28
|
+
|
29
|
+
build.onEnd(result => {
|
30
|
+
result.outputFiles.forEach(async f => {
|
31
|
+
// remove duplicate selectors
|
32
|
+
let newText = await removeDuplicateSelectors(f.text);
|
33
|
+
|
34
|
+
// strip unnecessary theming-base-content
|
35
|
+
newText = stripThemingBaseContent(newText);
|
36
|
+
|
37
|
+
// scoping
|
38
|
+
newText = scopeVariables(newText, packageJSON, f.path);
|
39
|
+
await mkdir(path.dirname(f.path), {recursive: true});
|
40
|
+
writeFile(f.path, newText);
|
41
|
+
|
42
|
+
// JSON
|
43
|
+
const jsonPath = f.path.replace(/dist[\/\\]css/, "dist/generated/assets").replace(".css", ".css.json");
|
44
|
+
await mkdir(path.dirname(jsonPath), {recursive: true});
|
45
|
+
const data = {
|
46
|
+
packageName: packageJSON.name,
|
47
|
+
fileName: jsonPath.substr(jsonPath.lastIndexOf("themes")),
|
48
|
+
content: newText,
|
49
|
+
};
|
50
|
+
writeFileIfChanged(jsonPath, JSON.stringify({_: data}));
|
51
|
+
|
52
|
+
// JS/TS
|
53
|
+
const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
|
54
|
+
const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`");
|
55
|
+
writeFileIfChanged(jsPath, jsContent);
|
56
|
+
});
|
57
|
+
})
|
58
|
+
},
|
59
|
+
}
|
60
|
+
|
61
|
+
const config = {
|
62
|
+
entryPoints: inputFiles,
|
63
|
+
bundle: true,
|
64
|
+
minify: true,
|
65
|
+
outdir: 'dist/css',
|
66
|
+
outbase: 'src',
|
67
|
+
plugins: [
|
68
|
+
scopingPlugin,
|
69
|
+
],
|
70
|
+
external: ["*.ttf", "*.woff", "*.woff2"],
|
71
|
+
};
|
72
|
+
|
73
|
+
if (restArgs.includes("-w")) {
|
74
|
+
let ctx = await esbuild.context(config);
|
75
|
+
await ctx.watch()
|
76
|
+
console.log('watching...')
|
77
|
+
} else {
|
78
|
+
const result = await esbuild.build(config);
|
79
|
+
}
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
const name = "postcss-scope-vars";
|
3
|
-
|
4
|
-
const escapeVersion = version => "v" + version?.replaceAll(/[^0-9A-Za-z\-_]/g, "-");
|
1
|
+
import * as path from "path";
|
5
2
|
|
6
3
|
/**
|
7
4
|
* Tries to detect an override for a package
|
8
5
|
* @param {*} filePath For example: /my_project/src/themes/overrides/@ui5/webcomponents/my_custom_theme/parameters-bundle.css
|
9
|
-
* @returns
|
6
|
+
* @returns
|
10
7
|
*/
|
11
8
|
const getOverrideVersion = filePath => {
|
12
|
-
|
9
|
+
if (!filePath) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
|
13
13
|
if (!filePath.includes(`overrides${path.sep}`)) {
|
14
14
|
return; // The "overrides/" directory is the marker
|
15
15
|
}
|
@@ -33,27 +33,14 @@ const getOverrideVersion = filePath => {
|
|
33
33
|
return overrideVersion;
|
34
34
|
}
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
// add version after ui5
|
49
|
-
const expr = /(--_?ui5)([^\,\:\)\s]+)/g
|
50
|
-
declaration.prop = declaration.prop.replaceAll(expr, `$1-${versionStr}$2`)
|
51
|
-
declaration.value = declaration.value.replaceAll(expr, `$1-${versionStr}$2`)
|
52
|
-
declaration.__ui5_replaced = true;
|
53
|
-
},
|
54
|
-
};
|
55
|
-
},
|
56
|
-
};
|
57
|
-
};
|
58
|
-
|
59
|
-
module.exports.postcss = true;
|
36
|
+
const scopeVariables = (cssText, packageJSON, inputFile) => {
|
37
|
+
const escapeVersion = version => "v" + version?.replaceAll(/[^0-9A-Za-z\-_]/g, "-");
|
38
|
+
const versionStr = escapeVersion(getOverrideVersion(inputFile) || packageJSON.version);
|
39
|
+
|
40
|
+
const expr = /(--_?ui5)([^\,\:\)\s]+)/g;
|
41
|
+
|
42
|
+
return cssText.replaceAll(expr, `$1-${versionStr}$2`);
|
43
|
+
}
|
44
|
+
|
45
|
+
export default scopeVariables;
|
46
|
+
|
@@ -1,7 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { writeFile, readFile, mkdir } from "fs/promises";
|
2
|
+
import * as path from "path";
|
3
|
+
import assets from "../../assets-meta.js";
|
4
|
+
|
5
|
+
const readOldContent = async (fileName) => {
|
6
|
+
// it seems slower to read the old content, but writing the same content with no real changes
|
7
|
+
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
|
8
|
+
let oldContent = "";
|
9
|
+
try {
|
10
|
+
oldContent = (await readFile(fileName)).toString();
|
11
|
+
} catch (e) {
|
12
|
+
// file not found
|
13
|
+
}
|
14
|
+
return oldContent;
|
15
|
+
}
|
16
|
+
|
17
|
+
const writeFileIfChanged = async (fileName, content) => {
|
18
|
+
const oldContent = await readOldContent(fileName);
|
19
|
+
if (content !== oldContent) {
|
20
|
+
if (!oldContent) {
|
21
|
+
await mkdir(path.dirname(fileName), {recursive: true});
|
22
|
+
}
|
23
|
+
return writeFile(fileName, content);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
// strips the unnecessary theming data coming from @sap-theming/theming-base-content and leaves only the css parameters
|
28
|
+
const stripThemingBaseContent = css => {
|
29
|
+
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
30
|
+
css = css.replace(/\.background-image.*{.*}/, "");
|
31
|
+
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
32
|
+
css = css.replace(/--sapFontUrl.*\);?/, "");
|
33
|
+
return css;
|
34
|
+
}
|
35
|
+
|
5
36
|
|
6
37
|
const DEFAULT_THEME = assets.themes.default;
|
7
38
|
|
@@ -42,49 +73,4 @@ const getJSContent = (targetFile, packageName, css, includeDefaultTheme) => {
|
|
42
73
|
return `${defaultTheme}export default {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
|
43
74
|
}
|
44
75
|
|
45
|
-
|
46
|
-
const proccessCSS = css => {
|
47
|
-
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
48
|
-
css = css.replace(/\.background-image.*{.*}/, "");
|
49
|
-
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
50
|
-
css = css.replace(/--sapFontUrl.*\);?/, "");
|
51
|
-
return JSON.stringify(css);
|
52
|
-
}
|
53
|
-
|
54
|
-
module.exports = function (opts) {
|
55
|
-
opts = opts || {};
|
56
|
-
|
57
|
-
const packageName = opts.packageName;
|
58
|
-
const includeDefaultTheme = opts.includeDefaultTheme;
|
59
|
-
const toReplace = opts.toReplace;
|
60
|
-
|
61
|
-
return {
|
62
|
-
postcssPlugin: 'postcss-css-to-esm',
|
63
|
-
OnceExit(root) {
|
64
|
-
const tsMode = process.env.UI5_TS === "true";
|
65
|
-
|
66
|
-
let css = root.toString();
|
67
|
-
css = proccessCSS(css);
|
68
|
-
|
69
|
-
const targetFile = root.source.input.from.replace(`/${toReplace}/`, "/src/generated/").replace(`\\${toReplace}\\`, "\\src\\generated\\");
|
70
|
-
mkdirp.sync(path.dirname(targetFile));
|
71
|
-
|
72
|
-
const filePath = `${targetFile}.${tsMode ? "ts" : "js"}`;
|
73
|
-
|
74
|
-
// it seems slower to read the old content, but writing the same content with no real changes
|
75
|
-
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
|
76
|
-
let oldContent = "";
|
77
|
-
try {
|
78
|
-
oldContent = fs.readFileSync(filePath).toString();
|
79
|
-
} catch (e) {
|
80
|
-
// file not found
|
81
|
-
}
|
82
|
-
|
83
|
-
const content = getFileContent(tsMode, targetFile, packageName, css, includeDefaultTheme);
|
84
|
-
if (content !== oldContent) {
|
85
|
-
fs.writeFileSync(filePath, content);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
};
|
89
|
-
};
|
90
|
-
module.exports.postcss = true;
|
76
|
+
export { writeFileIfChanged, stripThemingBaseContent, getFileContent}
|
@@ -3,15 +3,15 @@ const fs = require("fs");
|
|
3
3
|
/**
|
4
4
|
* A change is observed on MacOS since 13.5, where the build generates a large amount
|
5
5
|
* of JSON file that spotlight search has to index, as they are considered new files.
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* Starting the vitejs dev server reads all of these files and this triggers the indexing.
|
8
8
|
* The indexing has a side effect of changing some file metadata (can be checked with `mdls <path_to_file>`).
|
9
9
|
* This metadata change is changing the ctime of the file, but not the mtime. This can be checked with `stat -x <path_to_file>
|
10
|
-
*
|
10
|
+
*
|
11
11
|
* Essentially only metadata is changed, not content. This should not cause a page refresh,
|
12
12
|
* but chokidar reports this change and vite refreshes the page.
|
13
13
|
* The indexing is running with a 10 second interval, so for roughtly 20 minutes vite is refreshing the page every 10 seconds
|
14
|
-
*
|
14
|
+
*
|
15
15
|
* This plugin checks if the file causing the refresh is a generated json file (dist/*.json) and if ctime is changed after mtime
|
16
16
|
* In that case, returing an empty array tells vitejs that a custom update will be made by the plugin,
|
17
17
|
* which is in effect ignoring the page refresh.
|
@@ -22,7 +22,7 @@ const customHotUpdate = async () => {
|
|
22
22
|
name: 'custom-hot-update',
|
23
23
|
handleHotUpdate(ctx) {
|
24
24
|
// custom check for generated json files
|
25
|
-
if (ctx.file.
|
25
|
+
if (ctx.file.endsWith(".json")) {
|
26
26
|
const stat = fs.statSync(ctx.file);
|
27
27
|
|
28
28
|
// metadata change only
|
@@ -7,8 +7,11 @@ const basePath = process.argv[2];
|
|
7
7
|
|
8
8
|
const convertImports = async (srcPath) => {
|
9
9
|
let changed = false;
|
10
|
-
// console.log("scanning imports of", srcPath);
|
11
10
|
let code = (await fs.readFile(srcPath)).toString();
|
11
|
+
if (code.includes("import(")) {
|
12
|
+
// esprima can't parse this, but it's from the project files
|
13
|
+
return;
|
14
|
+
}
|
12
15
|
const tree = esprima.parseModule(code);
|
13
16
|
const importer = srcPath.replace(basePath, "");
|
14
17
|
const importerDir = path.dirname(importer);
|
@@ -1,12 +1,14 @@
|
|
1
1
|
const fs = require("fs").promises;
|
2
2
|
const path = require("path");
|
3
3
|
|
4
|
-
const generateDynamicImportLines = (fileNames, location, exclusionPatterns = []) => {
|
4
|
+
const generateDynamicImportLines = async (fileNames, location, exclusionPatterns = []) => {
|
5
|
+
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
5
6
|
return fileNames
|
6
7
|
.filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
|
7
8
|
.map((fileName) => {
|
8
|
-
const
|
9
|
-
|
9
|
+
const illustrationName = fileName.replace(".js", "");
|
10
|
+
const illustrationPath = `${location}/${illustrationName}`;
|
11
|
+
return `\t\tcase "${fileName.replace('.js', '')}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${illustrationName.toLowerCase()}" */ "${illustrationPath}.js")).default;`;
|
10
12
|
})
|
11
13
|
.join("\n");
|
12
14
|
};
|
@@ -20,7 +22,8 @@ const generateAvailableIllustrationsArray = (fileNames, exclusionPatterns = [])
|
|
20
22
|
};
|
21
23
|
|
22
24
|
const generateDynamicImportsFileContent = (dynamicImports, availableIllustrations, collection, prefix = "") => {
|
23
|
-
return
|
25
|
+
return `// @ts-nocheck
|
26
|
+
import { registerIllustrationLoader } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
24
27
|
|
25
28
|
export const loadIllustration = async (illustrationName) => {
|
26
29
|
const collectionAndPrefix = "${collection}/${prefix}";
|
@@ -56,7 +59,7 @@ const generateIllustrations = async (config) => {
|
|
56
59
|
|
57
60
|
const illustrations = await getMatchingFiles(normalizedInputFolder, /^.*\.js$/);
|
58
61
|
|
59
|
-
const dynamicImports = generateDynamicImportLines(illustrations, location, filterOut);
|
62
|
+
const dynamicImports = await generateDynamicImportLines(illustrations, location, filterOut);
|
60
63
|
const availableIllustrations = generateAvailableIllustrationsArray(illustrations, filterOut);
|
61
64
|
|
62
65
|
const contentDynamic = generateDynamicImportsFileContent(dynamicImports, availableIllustrations, collection, prefix);
|
@@ -1,13 +1,16 @@
|
|
1
1
|
const fs = require("fs").promises;
|
2
2
|
const path = require('path');
|
3
3
|
|
4
|
+
const isTypeScript = process.env.UI5_TS;
|
5
|
+
const ext = isTypeScript ? 'ts' : 'js';
|
6
|
+
|
4
7
|
const generate = async () => {
|
5
8
|
|
6
9
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
7
10
|
|
8
11
|
const inputFolder = path.normalize(process.argv[2]);
|
9
|
-
const outputFile = path.normalize(`${process.argv[3]}/i18n-static
|
10
|
-
const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n
|
12
|
+
const outputFile = path.normalize(`${process.argv[3]}/i18n-static.${ext}`);
|
13
|
+
const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.${ext}`);
|
11
14
|
|
12
15
|
// All languages present in the file system
|
13
16
|
const files = await fs.readdir(inputFolder);
|
@@ -32,7 +35,8 @@ const generate = async () => {
|
|
32
35
|
const assetsImportsString = languages.map(key => `import _${key} from "../assets/i18n/messagebundle_${key}.json";`).join("\n");
|
33
36
|
|
34
37
|
// static imports
|
35
|
-
contentStatic =
|
38
|
+
contentStatic = `// @ts-nocheck
|
39
|
+
import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
36
40
|
|
37
41
|
${assetsImportsString}
|
38
42
|
|
@@ -59,7 +63,8 @@ localeIds.forEach(localeId => {
|
|
59
63
|
const dynamicImportsString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
|
60
64
|
|
61
65
|
// Resulting file content
|
62
|
-
contentDynamic =
|
66
|
+
contentDynamic = `// @ts-nocheck
|
67
|
+
import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
63
68
|
|
64
69
|
const importMessageBundle = async (localeId) => {
|
65
70
|
switch (localeId) {
|
@@ -2,10 +2,13 @@ const fs = require("fs").promises;
|
|
2
2
|
const path = require('path');
|
3
3
|
const assets = require("../../assets-meta.js");
|
4
4
|
|
5
|
+
const isTypeScript = process.env.UI5_TS;
|
6
|
+
const ext = isTypeScript ? 'ts' : 'js';
|
7
|
+
|
5
8
|
const generate = async () => {
|
6
9
|
const inputFolder = path.normalize(process.argv[2]);
|
7
|
-
const outputFile = path.normalize(`${process.argv[3]}/Themes-static
|
8
|
-
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes
|
10
|
+
const outputFile = path.normalize(`${process.argv[3]}/Themes-static.${ext}`);
|
11
|
+
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.${ext}`);
|
9
12
|
|
10
13
|
// All supported optional themes
|
11
14
|
const allThemes = assets.themes.all;
|
@@ -26,7 +29,8 @@ const generate = async () => {
|
|
26
29
|
|
27
30
|
|
28
31
|
// static imports file content
|
29
|
-
const contentStatic =
|
32
|
+
const contentStatic = `// @ts-nocheck
|
33
|
+
import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
30
34
|
|
31
35
|
${importLines}
|
32
36
|
|
@@ -47,7 +51,8 @@ ${availableThemesArray}
|
|
47
51
|
|
48
52
|
|
49
53
|
// dynamic imports file content
|
50
|
-
const contentDynamic =
|
54
|
+
const contentDynamic = `// @ts-nocheck
|
55
|
+
import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
51
56
|
|
52
57
|
const loadThemeProperties = async (themeName) => {
|
53
58
|
switch (themeName) {
|
package/lib/jsdoc/preprocess.js
CHANGED
@@ -116,7 +116,7 @@ const processComponentFile = async (fileName) => {
|
|
116
116
|
const destFileName = fileName.replace(sourceDir, inputDir).replace(/\.ts$/, ".js");
|
117
117
|
let jsFileContent = `${await fs.readFile(destFileName)}`;
|
118
118
|
|
119
|
-
const classDefinitionRegExp = new RegExp(`let.*? = class`, "gm");
|
119
|
+
const classDefinitionRegExp = new RegExp(`(let.*? = class)|(^class.*?)`, "gm");
|
120
120
|
let classDefinitionMatch = jsFileContent.match(classDefinitionRegExp);
|
121
121
|
if (!classDefinitionMatch) {
|
122
122
|
return; // not a file, generated by typescript, nothing to do here
|
@@ -154,22 +154,29 @@ module.exports = (options) => {
|
|
154
154
|
options.removeDuplicatedProperties ||
|
155
155
|
options.removeDuplicatedValues
|
156
156
|
) {
|
157
|
-
removeDupProperties(
|
158
|
-
|
159
|
-
|
160
|
-
);
|
157
|
+
// removeDupProperties(
|
158
|
+
// destination,
|
159
|
+
// options.removeDuplicatedValues,
|
160
|
+
// );
|
161
161
|
}
|
162
162
|
} else {
|
163
163
|
if (
|
164
164
|
options.removeDuplicatedProperties ||
|
165
165
|
options.removeDuplicatedValues
|
166
166
|
) {
|
167
|
-
removeDupProperties(rule, options.removeDuplicatedValues);
|
167
|
+
// removeDupProperties(rule, options.removeDuplicatedValues);
|
168
168
|
}
|
169
169
|
// add new selector to symbol table
|
170
170
|
map.set(selector, rule);
|
171
171
|
}
|
172
172
|
},
|
173
|
+
OnceExit(root) {
|
174
|
+
root.nodes.forEach(node => {
|
175
|
+
if (node.type === "rule") {
|
176
|
+
removeDupProperties(node, options.removeDuplicatedValues);
|
177
|
+
}
|
178
|
+
})
|
179
|
+
}
|
173
180
|
};
|
174
181
|
},
|
175
182
|
};
|
@@ -10,7 +10,7 @@ const getTag = file => {
|
|
10
10
|
|
11
11
|
const getPackageTags = (packageDir) => {
|
12
12
|
const srcDir = path.join(packageDir, "src/");
|
13
|
-
return glob.sync(path.join(srcDir, "/**/*.
|
13
|
+
return glob.sync(path.join(srcDir, "/**/*.ts")).flatMap(file => {
|
14
14
|
const tag = getTag(file);
|
15
15
|
return [tag];
|
16
16
|
}).filter(item => !!item);
|
@@ -18,6 +18,7 @@ const replaceTagsHTML = content => {
|
|
18
18
|
|
19
19
|
// Replace tags in any content
|
20
20
|
const replaceTagsAny = content => {
|
21
|
+
console.log(tags.length);
|
21
22
|
tags.forEach(tag => {
|
22
23
|
content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
|
23
24
|
});
|
@@ -27,7 +28,7 @@ const replaceTagsAny = content => {
|
|
27
28
|
// Replace bundle names and HTML tag names in test pages
|
28
29
|
glob.sync(path.join(root, "/**/*.html")).forEach(file => {
|
29
30
|
let content = String(fs.readFileSync(file));
|
30
|
-
content = content.replace(
|
31
|
+
content = content.replace("%VITE_BUNDLE_PATH%", "%VITE_BUNDLE_PATH_SCOPED%");
|
31
32
|
content = replaceTagsHTML(content);
|
32
33
|
fs.writeFileSync(file, content);
|
33
34
|
});
|
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-c8721b8d2",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -21,8 +21,8 @@
|
|
21
21
|
"directory": "packages/tools"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
|
-
"@typescript-eslint/eslint-plugin": "^
|
25
|
-
"@typescript-eslint/parser": "^
|
24
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
25
|
+
"@typescript-eslint/parser": "^6.9.0",
|
26
26
|
"@wdio/cli": "^7.19.7",
|
27
27
|
"@wdio/dot-reporter": "^7.19.7",
|
28
28
|
"@wdio/local-runner": "^7.19.7",
|
@@ -36,7 +36,6 @@
|
|
36
36
|
"command-line-args": "^5.1.1",
|
37
37
|
"concurrently": "^6.0.0",
|
38
38
|
"cross-env": "^7.0.3",
|
39
|
-
"cssnano": "^6.0.1",
|
40
39
|
"escodegen": "^2.0.0",
|
41
40
|
"eslint": "^7.22.0",
|
42
41
|
"eslint-config-airbnb-base": "^14.2.1",
|
@@ -54,7 +53,6 @@
|
|
54
53
|
"nps": "^5.10.0",
|
55
54
|
"postcss": "^8.4.5",
|
56
55
|
"postcss-cli": "^9.1.0",
|
57
|
-
"postcss-import": "^14.0.2",
|
58
56
|
"postcss-selector-parser": "^6.0.10",
|
59
57
|
"prompts": "^2.4.2",
|
60
58
|
"properties-reader": "^2.2.0",
|
@@ -63,8 +61,7 @@
|
|
63
61
|
"rimraf": "^3.0.2",
|
64
62
|
"slash": "3.0.0",
|
65
63
|
"vite": "^4.4.9",
|
66
|
-
"wdio-chromedriver-service": "^7.3.2"
|
67
|
-
"zx": "^7.2.3"
|
64
|
+
"wdio-chromedriver-service": "^7.3.2"
|
68
65
|
},
|
69
66
|
"peerDependencies": {
|
70
67
|
"chromedriver": "*",
|
@@ -76,6 +73,7 @@
|
|
76
73
|
}
|
77
74
|
},
|
78
75
|
"devDependencies": {
|
76
|
+
"esbuild": "^0.19.9",
|
79
77
|
"yargs": "^17.5.1"
|
80
78
|
}
|
81
79
|
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
const fs = require('fs');
|
2
|
-
const path = require('path');
|
3
|
-
const mkdirp = require('mkdirp');
|
4
|
-
|
5
|
-
const proccessCSS = css => {
|
6
|
-
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
7
|
-
css = css.replace(/\.background-image.*{.*}/, "");
|
8
|
-
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
9
|
-
css = css.replace(/--sapFontUrl.*\);?/, "");
|
10
|
-
return css;
|
11
|
-
}
|
12
|
-
|
13
|
-
module.exports = function (opts) {
|
14
|
-
opts = opts || {};
|
15
|
-
|
16
|
-
return {
|
17
|
-
postcssPlugin: 'postcss-css-to-json',
|
18
|
-
OnceExit (root) {
|
19
|
-
let css = root.toString();
|
20
|
-
css = proccessCSS(css);
|
21
|
-
|
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));
|
24
|
-
|
25
|
-
const filePath = `${targetFile}.json`;
|
26
|
-
const data = {
|
27
|
-
packageName: opts.packageName,
|
28
|
-
fileName: targetFile.substr(targetFile.lastIndexOf("themes")),
|
29
|
-
content: css
|
30
|
-
};
|
31
|
-
// it seems slower to read the old content, but writing the same content with no real changes
|
32
|
-
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
|
33
|
-
let oldContent = "";
|
34
|
-
try {
|
35
|
-
oldContent = fs.readFileSync(filePath).toString();
|
36
|
-
} catch (e) {
|
37
|
-
// file not found
|
38
|
-
}
|
39
|
-
const content = JSON.stringify({_: data});
|
40
|
-
if (content !== oldContent) {
|
41
|
-
fs.writeFileSync(filePath, content);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
};
|
45
|
-
};
|
46
|
-
|
47
|
-
module.exports.postcss = true;
|
@@ -1,36 +0,0 @@
|
|
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
|
-
});
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import 'zx/globals';
|
2
|
-
|
3
|
-
// don't print executed commands and their output
|
4
|
-
$.verbose = false;
|
5
|
-
|
6
|
-
const inputFiles = await globby("src/**/parameters-bundle.css");
|
7
|
-
|
8
|
-
const restArgs = process.argv.slice(2);
|
9
|
-
|
10
|
-
// run all postcss processes in parallel as passing the glob directly to postcss makes them processed sequentially.
|
11
|
-
// and the amount of imports give a big speed up when run in parallel
|
12
|
-
await Promise.all(inputFiles.map(file => {
|
13
|
-
return $`postcss ${file} --config config/postcss.themes --base src --dir dist/css/ ${restArgs}`;
|
14
|
-
}));
|