@ui5/webcomponents-tools 1.11.0-rc.0 → 1.11.0-rc.2
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 +16 -0
- package/components-package/nps.js +10 -6
- package/components-package/postcss.components.js +13 -13
- package/components-package/postcss.themes.js +15 -15
- package/icons-collection/nps.js +4 -2
- package/lib/create-icons/index.js +6 -6
- package/lib/i18n/defaults.js +9 -3
- package/lib/postcss-css-to-esm/index.js +37 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
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.11.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.1...v1.11.0-rc.2) (2023-02-16)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [1.11.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.0...v1.11.0-rc.1) (2023-02-09)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
6
22
|
# [1.11.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.10.4-rc.0...v1.11.0-rc.0) (2023-02-02)
|
7
23
|
|
8
24
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
@@ -8,14 +8,17 @@ const getScripts = (options) => {
|
|
8
8
|
|
9
9
|
// The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
|
10
10
|
const illustrationsData = options.illustrationsData || [];
|
11
|
-
illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
|
11
|
+
const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
|
12
12
|
const createIllustrationsJSImportsScript = illustrations.join(" && ");
|
13
13
|
|
14
14
|
// The script creates the "dist/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
|
15
15
|
const illustrationDestinationPaths = illustrationsData.map(illustrations => illustrations.destinationPath);
|
16
16
|
const createIllustrationsLoadersScript = options.fioriPackage ? `node ${LIB}/generate-js-imports/illustrations.js ${illustrationDestinationPaths[0]} ${illustrationDestinationPaths[1]} dist/generated/js-imports` : "";
|
17
|
-
const
|
18
|
-
const
|
17
|
+
const tsOption = options.typescript;
|
18
|
+
const tsCommand = tsOption ? "tsc" : "";
|
19
|
+
const tsWatchCommand = tsOption ? "tsc --watch" : "";
|
20
|
+
const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
|
21
|
+
const copySrcGenerated = tsOption ? "" : "copy.srcGenerated";
|
19
22
|
|
20
23
|
let viteConfig;
|
21
24
|
if (fs.existsSync("config/vite.config.js")) {
|
@@ -46,7 +49,7 @@ const getScripts = (options) => {
|
|
46
49
|
lint: `eslint . ${eslintConfig}`,
|
47
50
|
lintfix: `eslint . ${eslintConfig}`,
|
48
51
|
prepare: {
|
49
|
-
default:
|
52
|
+
default: `${tsCrossEnv} nps clean prepare.all typescript generateAPI`,
|
50
53
|
all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
|
51
54
|
styleRelated: "nps build.styles build.jsonImports build.jsImports",
|
52
55
|
},
|
@@ -55,7 +58,7 @@ const getScripts = (options) => {
|
|
55
58
|
default: "nps prepare lint build.bundle",
|
56
59
|
templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
|
57
60
|
styles: {
|
58
|
-
default:
|
61
|
+
default: `nps build.styles.themes build.styles.components ${copySrcGenerated}`,
|
59
62
|
themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
|
60
63
|
components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
|
61
64
|
},
|
@@ -79,10 +82,11 @@ const getScripts = (options) => {
|
|
79
82
|
copy: {
|
80
83
|
default: "nps copy.src copy.props",
|
81
84
|
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
85
|
+
srcGenerated: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.js" dist/generated/`,
|
82
86
|
props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
|
83
87
|
},
|
84
88
|
watch: {
|
85
|
-
default:
|
89
|
+
default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.typescript" "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
|
86
90
|
devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
|
87
91
|
src: 'nps "copy.src --watch --safe --skip-initial-copy"',
|
88
92
|
typescript: tsWatchCommand,
|
@@ -6,16 +6,16 @@ const fs = require("fs");
|
|
6
6
|
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
7
7
|
|
8
8
|
module.exports = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
9
|
+
plugins: [
|
10
|
+
postcssImport(),
|
11
|
+
cssnano({
|
12
|
+
preset: [
|
13
|
+
'default', {
|
14
|
+
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
15
|
+
mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
|
16
|
+
},
|
17
|
+
]
|
18
|
+
}),
|
19
|
+
postcssCSStoESM({ toReplace: 'src', includeDefaultTheme: true, packageName }),
|
20
|
+
]
|
21
|
+
}
|
@@ -8,19 +8,19 @@ const fs = require("fs");
|
|
8
8
|
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
9
9
|
|
10
10
|
module.exports = {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
11
|
+
plugins: [
|
12
|
+
postcssImport(),
|
13
|
+
combineSelectors({
|
14
|
+
removeDuplicatedProperties: true
|
15
|
+
}),
|
16
|
+
cssnano({
|
17
|
+
preset: [
|
18
|
+
'default', {
|
19
|
+
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
20
|
+
},
|
21
|
+
]
|
22
|
+
},),
|
23
|
+
postcssCSStoJSON({ toReplace: 'src', packageName }),
|
24
|
+
postcssCSStoESM({ toReplace: 'src', packageName }),
|
25
|
+
]
|
26
26
|
};
|
package/icons-collection/nps.js
CHANGED
@@ -41,12 +41,14 @@ 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" : "";
|
45
|
+
const tsCrossEnv = options.typescript ? "cross-env UI5_TS=true" : "";
|
44
46
|
|
45
47
|
const scripts = {
|
46
48
|
clean: "rimraf dist && rimraf src/generated",
|
47
49
|
copy: copyAssetsCmd,
|
48
50
|
build: {
|
49
|
-
default:
|
51
|
+
default: `${tsCrossEnv} nps clean copy build.i18n typescript build.icons build.jsonImports`,
|
50
52
|
i18n: {
|
51
53
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
52
54
|
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
@@ -58,7 +60,7 @@ const getScripts = (options) => {
|
|
58
60
|
},
|
59
61
|
icons: createJSImportsCmd,
|
60
62
|
},
|
61
|
-
typescript:
|
63
|
+
typescript: tsCommand,
|
62
64
|
};
|
63
65
|
|
64
66
|
return scripts;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
const fs = require("fs").promises;
|
2
2
|
const path = require("path");
|
3
3
|
|
4
|
-
const collectionName = process.argv[2] || "SAP-icons";
|
4
|
+
const collectionName = process.argv[2] || "SAP-icons-v4";
|
5
5
|
const collectionVersion = process.argv[3];
|
6
6
|
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
7
7
|
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
@@ -38,11 +38,11 @@ export { pathData, ltr, accData };`;
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
const collectionTemplate = (name) => `import { isThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
42
|
-
import {pathData as
|
43
|
-
import {pathData as
|
41
|
+
const collectionTemplate = (name, versions) => `import { isThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
42
|
+
import { pathData as pathData${versions[0]}, ltr, accData } from "./${versions[0]}/${name}.js";
|
43
|
+
import { pathData as pathData${versions[1]} } from "./${versions[1]}/${name}.js";
|
44
44
|
|
45
|
-
const pathData = isThemeFamily("sap_horizon") ?
|
45
|
+
const pathData = isThemeFamily("sap_horizon") ? pathData${versions[1]} : pathData${versions[0]};
|
46
46
|
|
47
47
|
export default "${name}";
|
48
48
|
export { pathData, ltr, accData };`;
|
@@ -88,7 +88,7 @@ const createIcons = async (file) => {
|
|
88
88
|
promises.push(fs.writeFile(path.join(destDir, `${name}.d.ts`), typeDefinitionTemplate(name, acc, json.collection)));
|
89
89
|
|
90
90
|
if (json.version) {
|
91
|
-
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name)));
|
91
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions)));
|
92
92
|
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(name, acc)));
|
93
93
|
}
|
94
94
|
}
|
package/lib/i18n/defaults.js
CHANGED
@@ -8,7 +8,9 @@ const generate = async () => {
|
|
8
8
|
|
9
9
|
const messageBundle = path.normalize(`${process.argv[2]}/messagebundle.properties`);
|
10
10
|
const messageBundleDefaultLanguage = path.normalize(`${process.argv[2]}/messagebundle_${defaultLanguage}.properties`);
|
11
|
-
const
|
11
|
+
const tsMode = process.env.UI5_TS === "true"; // In Typescript mode, we output .ts files and set the required types, otherwise - output pure .js files
|
12
|
+
|
13
|
+
const outputFile = path.normalize(`${process.argv[3]}/i18n-defaults.${tsMode ? "ts": "js"}`);
|
12
14
|
|
13
15
|
if (!messageBundle || !outputFile) {
|
14
16
|
return;
|
@@ -45,7 +47,10 @@ const generate = async () => {
|
|
45
47
|
let effectiveValue = defaultLanguageValue || value;
|
46
48
|
effectiveValue = effectiveValue.replace(/\"/g, "\\\""); // escape double quotes in translations
|
47
49
|
|
48
|
-
|
50
|
+
if (tsMode) {
|
51
|
+
return `const ${key}: I18nText = {key: "${key}", defaultText: "${effectiveValue}"};`;
|
52
|
+
}
|
53
|
+
return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
|
49
54
|
};
|
50
55
|
|
51
56
|
/*
|
@@ -62,7 +67,8 @@ const generate = async () => {
|
|
62
67
|
const textKeys = Object.keys(properties);
|
63
68
|
const texts = textKeys.map(prop => getTextInfo(prop, properties[prop], defaultLanguageProperties && defaultLanguageProperties[prop])).join('');
|
64
69
|
|
65
|
-
|
70
|
+
// tabs are intentionally mixed to have proper identation in the produced file
|
71
|
+
return `${tsMode ? `import { I18nText } from "@ui5/webcomponents-base/dist/i18nBundle.js";` : ""}
|
66
72
|
${texts}
|
67
73
|
export {${textKeys.join()}};`;
|
68
74
|
};
|
@@ -4,11 +4,9 @@ const mkdirp = require('mkdirp');
|
|
4
4
|
const assets = require("../../assets-meta.js");
|
5
5
|
|
6
6
|
const DEFAULT_THEME = assets.themes.default;
|
7
|
-
const requiredImports = "import type { StyleData } from \"@ui5/webcomponents-base/dist/types.js\";";
|
8
7
|
|
9
8
|
const getDefaultThemeCode = packageName => {
|
10
9
|
return `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
11
|
-
${requiredImports}
|
12
10
|
|
13
11
|
import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
|
14
12
|
import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
|
@@ -18,6 +16,33 @@ registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", async () =>
|
|
18
16
|
`;
|
19
17
|
};
|
20
18
|
|
19
|
+
const getFileContent = (tsMode, targetFile, packageName, css, includeDefaultTheme) => {
|
20
|
+
if (tsMode) {
|
21
|
+
return getTSContent(targetFile, packageName, css, includeDefaultTheme);
|
22
|
+
}
|
23
|
+
|
24
|
+
return getJSContent(targetFile, packageName, css, includeDefaultTheme);
|
25
|
+
}
|
26
|
+
|
27
|
+
const getTSContent = (targetFile, packageName, css, includeDefaultTheme) => {
|
28
|
+
const typeImport = "import type { StyleData } from \"@ui5/webcomponents-base/dist/types.js\";"
|
29
|
+
const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
|
30
|
+
|
31
|
+
// tabs are intentionally mixed to have proper identation in the produced file
|
32
|
+
return `${typeImport}
|
33
|
+
${defaultTheme}
|
34
|
+
const styleData: StyleData = {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}};
|
35
|
+
export default styleData;
|
36
|
+
`;
|
37
|
+
}
|
38
|
+
|
39
|
+
const getJSContent = (targetFile, packageName, css, includeDefaultTheme) => {
|
40
|
+
const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
|
41
|
+
|
42
|
+
return `${defaultTheme}export default {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
|
43
|
+
}
|
44
|
+
|
45
|
+
|
21
46
|
const proccessCSS = css => {
|
22
47
|
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
23
48
|
css = css.replace(/\.background-image.*{.*}/, "");
|
@@ -29,18 +54,23 @@ const proccessCSS = css => {
|
|
29
54
|
module.exports = function (opts) {
|
30
55
|
opts = opts || {};
|
31
56
|
|
57
|
+
const packageName = opts.packageName;
|
58
|
+
const includeDefaultTheme = opts.includeDefaultTheme;
|
59
|
+
const toReplace = opts.toReplace;
|
60
|
+
|
32
61
|
return {
|
33
62
|
postcssPlugin: 'postcss-css-to-esm',
|
34
63
|
Once (root) {
|
64
|
+
const tsMode = process.env.UI5_TS === "true";
|
65
|
+
|
35
66
|
let css = root.toString();
|
36
67
|
css = proccessCSS(css);
|
37
68
|
|
38
|
-
const targetFile = root.source.input.from.replace(`/${
|
69
|
+
const targetFile = root.source.input.from.replace(`/${toReplace}/`, "/src/generated/").replace(`\\${toReplace}\\`, "\\src\\generated\\");
|
39
70
|
mkdirp.sync(path.dirname(targetFile));
|
40
71
|
|
41
|
-
const filePath = `${targetFile}
|
42
|
-
|
43
|
-
|
72
|
+
const filePath = `${targetFile}.${tsMode ? "ts" : "js"}`;
|
73
|
+
|
44
74
|
// it seems slower to read the old content, but writing the same content with no real changes
|
45
75
|
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
|
46
76
|
let oldContent = "";
|
@@ -50,10 +80,7 @@ module.exports = function (opts) {
|
|
50
80
|
// file not found
|
51
81
|
}
|
52
82
|
|
53
|
-
const content =
|
54
|
-
const styleData: StyleData = {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}};
|
55
|
-
export default styleData;
|
56
|
-
`;
|
83
|
+
const content = getFileContent(tsMode, filePath, packageName, css, includeDefaultTheme);
|
57
84
|
if (content !== oldContent) {
|
58
85
|
fs.writeFileSync(filePath, content);
|
59
86
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "1.11.0-rc.
|
3
|
+
"version": "1.11.0-rc.2",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -72,5 +72,5 @@
|
|
72
72
|
"devDependencies": {
|
73
73
|
"yargs": "^17.5.1"
|
74
74
|
},
|
75
|
-
"gitHead": "
|
75
|
+
"gitHead": "a6334749f4f61a49b1ef754b75fe319991c54c17"
|
76
76
|
}
|