@ui5/webcomponents-tools 1.16.0-rc.4 → 1.17.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
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.17.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0...v1.17.0-rc.0) (2023-08-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui5-illustrated-message:** support collection based illustration loading ([#7318](https://github.com/SAP/ui5-webcomponents/issues/7318)) ([6b52dbd](https://github.com/SAP/ui5-webcomponents/commit/6b52dbd157a3c8198e41c84157e3d9ae89e3386e))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.16.0](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.4...v1.16.0) (2023-08-03)
18
+
19
+ **Note:** Version bump only for package @ui5/webcomponents-tools
20
+
21
+
22
+
23
+
24
+
6
25
  # [1.16.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.3...v1.16.0-rc.4) (2023-08-03)
7
26
 
8
27
  **Note:** Version bump only for package @ui5/webcomponents-tools
package/assets-meta.js CHANGED
@@ -9,12 +9,15 @@ const assetsMeta = {
9
9
  "sap_belize_hcw",
10
10
  "sap_fiori_3_hcb",
11
11
  "sap_fiori_3_hcw",
12
- "sap_horizon",
13
- "sap_horizon_dark",
14
- "sap_horizon_hcb",
15
- "sap_horizon_hcw",
16
- "sap_horizon_exp"
17
- ]
12
+ "sap_horizon",
13
+ "sap_horizon_dark",
14
+ "sap_horizon_hcb",
15
+ "sap_horizon_hcw",
16
+ "sap_horizon_exp",
17
+ "sap_horizon_dark_exp",
18
+ "sap_horizon_hcb_exp",
19
+ "sap_horizon_hcw_exp",
20
+ ],
18
21
  },
19
22
  "languages": {
20
23
  "default": "en",
@@ -8,12 +8,12 @@ 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
- const 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} ${illustration.collection}`);
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
- const illustrationDestinationPaths = illustrationsData.map(illustrations => illustrations.destinationPath);
16
- const createIllustrationsLoadersScript = options.fioriPackage ? `node ${LIB}/generate-js-imports/illustrations.js ${illustrationDestinationPaths[0]} ${illustrationDestinationPaths[1]} dist/generated/js-imports` : "";
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
+
17
17
  const tsOption = options.typescript;
18
18
  const tsCommand = tsOption ? "tsc" : "";
19
19
  const tsWatchCommand = tsOption ? "tsc --watch" : "";
@@ -57,10 +57,20 @@ const generate = async () => {
57
57
  const illustrationsPrefix = process.argv[4];
58
58
  const illustrationSet = process.argv[5];
59
59
  const destPath = process.argv[6];
60
+ const collection = process.argv[7];
60
61
  const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
61
62
  // collect each illustration name because each one should have Sample.js file
62
63
  const fileNames = new Set();
63
64
 
65
+ try {
66
+ await fs.access(srcPath);
67
+ } catch (error) {
68
+ console.log(`The path ${srcPath} does not exist.`);
69
+ return Promise.resolve(null);
70
+ }
71
+
72
+ console.log(`Generating illustrations from ${srcPath} to ${destPath}`)
73
+
64
74
  const svgImportTemplate = svgContent => {
65
75
  return `export default \`${svgContent}\`;`
66
76
  };
@@ -95,6 +105,7 @@ import {
95
105
 
96
106
  const name = "${illustrationName}";
97
107
  const set = "${illustrationSet}";
108
+ const collection = "${collection}";
98
109
  const title = IM_TITLE_${illustrationNameUpperCase};
99
110
  const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};
100
111
 
@@ -105,6 +116,7 @@ registerIllustration(name, {
105
116
  title,
106
117
  subtitle,
107
118
  set,
119
+ collection,
108
120
  });
109
121
 
110
122
  export {
@@ -119,12 +131,14 @@ import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
119
131
 
120
132
  const name = "${illustrationName}";
121
133
  const set = "${illustrationSet}";
134
+ const collection = "${collection}";
122
135
 
123
136
  registerIllustration(name, {
124
137
  dialogSvg,
125
138
  sceneSvg,
126
139
  spotSvg,
127
140
  set,
141
+ collection,
128
142
  });
129
143
 
130
144
  export {
@@ -1,72 +1,83 @@
1
1
  const fs = require("fs").promises;
2
- const path = require('path');
3
-
4
- const generate = async () => {
5
- const fioriInputFolder = path.normalize(process.argv[2]);
6
- const tntInputFolder = path.normalize(process.argv[3]);
7
- const outputFile = path.normalize(`${process.argv[4]}/Illustrations.js`);
8
-
9
- const dir = await fs.readdir(fioriInputFolder);
10
- const fioriIllustrationsOnFileSystem = dir.map(illustrationName => {
11
- const fioriMatches = illustrationName.match(/.*\.js$/);
12
- return fioriMatches ? illustrationName : undefined;
13
- }).filter(key => !!key);
14
-
15
- const tntDir = await fs.readdir(tntInputFolder);
16
- const tntIllustrationsOnFileSystem = tntDir.map(illustrationName => {
17
- const tntMatches = illustrationName.match(/.*\.js$/);
18
- return tntMatches ? illustrationName : undefined;
19
- }).filter(key => !!key);
20
-
21
- // dynamic imports for Fiori illustrations
22
- const fioriAvailableIllustrationsArray = `[${fioriIllustrationsOnFileSystem.filter(
23
- // skipping the items starting with sapIllus-Dialog, sapIllus-Scene, sapIllus-Spot since they are included in the illustration's js file
24
- line => !line.startsWith("sapIllus-Dialog") && !line.startsWith("sapIllus-Scene") && !line.startsWith("sapIllus-Spot") && !line.startsWith("AllIllustrations")).map(illustrationName => `"${illustrationName.replace('.js', '')}"`).join(", ")}]`;
25
-
26
- const fioriDynamicImportLines = fioriIllustrationsOnFileSystem.map(illustrationName =>
27
- `\t\tcase "${illustrationName.replace('.js', '')}": return (await import("../../illustrations/${illustrationName}")).default;`).filter(
28
- // skipping the items starting with sapIllus-Dialog, sapIllus-Scene, sapIllus-Spot since they are included in the illustration's js file
29
- line => !line.startsWith("\t\tcase \"sapIllus-Dialog") && !line.startsWith("\t\tcase \"sapIllus-Scene") && !line.startsWith("\t\tcase \"sapIllus-Spot") && !line.startsWith("\t\tcase \"AllIllustrations")).join("\n");
30
-
31
- // dynamic imports for Tnt illustrations
32
- const tntAvailableIllustrationsArray = `[${tntIllustrationsOnFileSystem.filter(
33
- // skipping the items starting with tnt-Dialog, tnt-Scene, tnt-Spot since they are included in the illustration's js file
34
- line => !line.startsWith("tnt-Dialog") && !line.startsWith("tnt-Scene") && !line.startsWith("tnt-Spot")).map(illustrationName => `"Tnt${illustrationName.replace('.js', '')}"`).join(", ")}]`;
35
-
36
- const tntDynamicImportLines = tntIllustrationsOnFileSystem.map(illustrationName =>
37
- `\t\tcase "Tnt${illustrationName.replace('.js', '')}": return (await import("../../illustrations/tnt/${illustrationName}")).default;`).filter(
38
- // skipping the items starting with tnt-Dialog, tnt-Scene, tnt-Spot since they are included in the illustration's js file
39
- line => !line.startsWith("\t\tcase \"Tnttnt-Dialog") && !line.startsWith("\t\tcase \"Tnttnt-Scene") && !line.startsWith("\t\tcase \"Tnttnt-Spot")).join("\n");
40
-
41
-
42
- // dynamic imports file content
43
- const contentDynamic = `import { registerIllustrationLoader } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
44
-
45
- const loadIllustration = async (illustrationName) => {
46
- switch (illustrationName) {
47
- ${fioriDynamicImportLines}
48
- ${tntDynamicImportLines}
49
- default: throw new Error("[Illustrations] Illustration not found: " + illustrationName);
50
- }
2
+ const path = require("path");
3
+
4
+ const generateDynamicImportLines = (fileNames, location, exclusionPatterns = []) => {
5
+ return fileNames
6
+ .filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
7
+ .map((fileName) => {
8
+ const illustrationPath = `${location}/${fileName.replace(".js", "")}`;
9
+ return `\t\tcase "${fileName.replace('.js', '')}": return (await import("${illustrationPath}.js")).default;`;
10
+ })
11
+ .join("\n");
12
+ };
13
+
14
+ const generateAvailableIllustrationsArray = (fileNames, exclusionPatterns = []) => {
15
+ return JSON.stringify(
16
+ fileNames
17
+ .filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
18
+ .map((fileName) => fileName.replace(".js", ""))
19
+ );
20
+ };
21
+
22
+ const generateDynamicImportsFileContent = (dynamicImports, availableIllustrations, collection, prefix = "") => {
23
+ return `import { registerIllustrationLoader } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
24
+
25
+ export const loadIllustration = async (illustrationName) => {
26
+ const collectionAndPrefix = "${collection}/${prefix}";
27
+ const cleanIllustrationName = illustrationName.startsWith(collectionAndPrefix) ? illustrationName.replace(collectionAndPrefix, "") : illustrationName;
28
+ switch (cleanIllustrationName) {
29
+ ${dynamicImports}
30
+ default:
31
+ throw new Error("[Illustrations] Illustration not found: " + illustrationName);
32
+ }
33
+ };
34
+
35
+ const loadAndCheck = async (illustrationName) => {
36
+ const data = await loadIllustration(illustrationName);
37
+ return data;
38
+ };
39
+
40
+ ${availableIllustrations}.forEach((illustrationName) =>
41
+ registerIllustrationLoader(\`${collection}/${prefix}\${illustrationName}\`, loadAndCheck)
42
+ );
43
+ `;
44
+ };
45
+
46
+ const getMatchingFiles = async (folder, pattern) => {
47
+ const dir = await fs.readdir(folder);
48
+ return dir.filter((fileName) => fileName.match(pattern));
51
49
  };
52
- const loadAndCheck = async (illustrationName) => {
53
- const data = await loadIllustration(illustrationName);
54
- return data;
55
- }
56
50
 
51
+ const generateIllustrations = async (config) => {
52
+ const { inputFolder, outputFile, collection, location, prefix, filterOut } = config;
53
+
54
+ const normalizedInputFolder = path.normalize(inputFolder);
55
+ const normalizedOutputFile = path.normalize(outputFile);
56
+
57
+ const illustrations = await getMatchingFiles(normalizedInputFolder, /^.*\.js$/);
57
58
 
58
- ${fioriAvailableIllustrationsArray}.forEach(illustrationName => registerIllustrationLoader(illustrationName, loadAndCheck));
59
- ${tntAvailableIllustrationsArray}.forEach(illustrationName => registerIllustrationLoader(illustrationName, loadAndCheck));`;
60
-
59
+ const dynamicImports = generateDynamicImportLines(illustrations, location, filterOut);
60
+ const availableIllustrations = generateAvailableIllustrationsArray(illustrations, filterOut);
61
+
62
+ const contentDynamic = generateDynamicImportsFileContent(dynamicImports, availableIllustrations, collection, prefix);
63
+
64
+ await fs.mkdir(path.dirname(normalizedOutputFile), { recursive: true });
65
+ await fs.writeFile(normalizedOutputFile, contentDynamic);
66
+
67
+ console.log(`Generated ${normalizedOutputFile}`);
68
+ };
61
69
 
62
- await fs.mkdir(path.dirname(outputFile), { recursive: true });
63
- return Promise.all([fs.writeFile(outputFile, contentDynamic)]);
70
+ // Parse configuration from command-line arguments
71
+ const config = {
72
+ inputFolder: process.argv[2],
73
+ outputFile: process.argv[3],
74
+ collection: process.argv[4],
75
+ location: process.argv[5],
76
+ prefix: process.argv[6],
77
+ filterOut: process.argv.slice(7),
64
78
  };
65
79
 
66
- generate().then(() => {
67
- console.log("Generated Illustrations.js");
68
- })
69
- .catch(err => {
70
- console.error(err);
71
- process.exit(1);
80
+ // Run the generation process
81
+ generateIllustrations(config).catch((error) => {
82
+ console.error("Error generating illustrations:", error);
72
83
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "1.16.0-rc.4",
3
+ "version": "1.17.0-rc.0",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -79,5 +79,5 @@
79
79
  "devDependencies": {
80
80
  "yargs": "^17.5.1"
81
81
  },
82
- "gitHead": "257d826d27b31e33d7f73d61f6536634632a7e23"
82
+ "gitHead": "1a6f71104cf246a2b6d0df6d2482baa5fb94ac51"
83
83
  }