@ui5/webcomponents-tools 0.0.0-b132dd7b9 → 0.0.0-b3a4f8020

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +501 -0
  2. package/LICENSE.txt +201 -0
  3. package/README.md +7 -7
  4. package/bin/dev.js +10 -4
  5. package/bin/ui5nps.js +301 -0
  6. package/components-package/nps.js +97 -94
  7. package/components-package/wdio.js +8 -2
  8. package/icons-collection/nps.js +30 -21
  9. package/lib/amd-to-es6/index.js +17 -10
  10. package/lib/cem/cem.js +16 -0
  11. package/lib/cem/custom-elements-manifest.config.mjs +56 -4
  12. package/lib/cem/merge.mjs +220 -0
  13. package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
  14. package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
  15. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
  16. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
  17. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
  18. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
  19. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
  20. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
  21. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
  22. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
  23. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
  24. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
  25. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
  26. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
  27. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
  28. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
  29. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
  30. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
  31. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
  32. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
  33. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
  34. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
  35. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
  36. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
  37. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
  38. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
  39. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
  40. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
  41. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
  42. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
  43. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
  44. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
  45. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
  46. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
  47. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
  48. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
  49. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
  50. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
  51. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
  52. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
  53. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
  54. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
  55. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
  56. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
  57. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
  58. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
  59. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
  60. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
  61. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
  62. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
  63. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
  64. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
  65. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
  66. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
  67. package/lib/cem/schema-internal.json +41 -1
  68. package/lib/cem/schema.json +41 -1
  69. package/lib/cem/types-internal.d.ts +32 -2
  70. package/lib/cem/types.d.ts +32 -2
  71. package/lib/cem/utils.mjs +13 -3
  72. package/lib/cem/validate.js +61 -47
  73. package/lib/chokidar/chokidar.js +28 -0
  74. package/lib/copy-and-watch/index.js +110 -97
  75. package/lib/copy-list/index.js +18 -10
  76. package/lib/create-icons/index.js +19 -15
  77. package/lib/create-illustrations/index.js +57 -29
  78. package/lib/create-new-component/index.js +5 -3
  79. package/lib/css-processors/css-processor-components.mjs +85 -60
  80. package/lib/css-processors/css-processor-themes.mjs +105 -57
  81. package/lib/css-processors/postcss-plugin.mjs +153 -0
  82. package/lib/css-processors/scope-variables.mjs +26 -1
  83. package/lib/css-processors/shared.mjs +8 -17
  84. package/lib/dev-server/dev-server.mjs +23 -11
  85. package/lib/eslint/eslint.js +44 -0
  86. package/lib/generate-js-imports/illustrations.js +55 -54
  87. package/lib/generate-json-imports/i18n.js +22 -11
  88. package/lib/generate-json-imports/themes.js +24 -12
  89. package/lib/i18n/defaults.js +14 -7
  90. package/lib/i18n/toJSON.js +40 -12
  91. package/lib/icons-hash/icons-hash.mjs +149 -0
  92. package/lib/remove-dev-mode/remove-dev-mode.mjs +38 -24
  93. package/lib/rimraf/rimraf.js +31 -0
  94. package/lib/test-runner/test-runner.js +56 -48
  95. package/lib/vite-bundler/vite-bundler.mjs +35 -0
  96. package/package.json +15 -14
@@ -5,63 +5,77 @@ const path = require('path');
5
5
  const extenalSchema = require('./schema.json');
6
6
  const internalSchema = require('./schema-internal.json');
7
7
 
8
- // Load your JSON data from the input file
9
- const inputFilePath = path.join(process.cwd(), "dist/custom-elements.json"); // Update with your file path
10
- const customManifest = fs.readFileSync(inputFilePath, 'utf8');
11
- const inputDataInternal = JSON.parse(customManifest);
12
- const devMode = process.env.UI5_CEM_MODE === "dev";
8
+ const isVerbose = () => process.env.UI5_VERBOSE === "true";
13
9
 
14
- inputDataInternal.modules.forEach(moduleDoc => {
15
- moduleDoc.exports = moduleDoc.exports.
16
- filter(e => moduleDoc.declarations.find(d => d.name === e.declaration.name && ["class", "function", "variable", "enum"].includes(d.kind)) || e.name === "default");
17
- })
10
+ const validateFn = async () => {
11
+ // Load your JSON data from the input file
12
+ const inputFilePath = path.join(process.cwd(), "dist/custom-elements.json"); // Update with your file path
13
+ const customManifest = fs.readFileSync(inputFilePath, 'utf8');
14
+ const inputDataInternal = JSON.parse(customManifest);
15
+ const devMode = process.env.UI5_CEM_MODE === "dev";
18
16
 
19
- const clearProps = (data) => {
20
- if (Array.isArray(data)) {
21
- for (let i = 0; i < data.length; i++) {
22
- if (typeof data[i] === "object") {
23
- if (["enum", "interface"].includes(data[i].kind)) {
24
- data.splice(i, 1);
25
- i--;
26
- } else {
27
- clearProps(data[i]);
17
+ inputDataInternal.modules.forEach(moduleDoc => {
18
+ moduleDoc.exports = moduleDoc.exports.
19
+ filter(e => moduleDoc.declarations.find(d => d.name === e.declaration.name && ["class", "function", "variable", "enum"].includes(d.kind)) || e.name === "default");
20
+ })
21
+
22
+ const clearProps = (data) => {
23
+ if (Array.isArray(data)) {
24
+ for (let i = 0; i < data.length; i++) {
25
+ if (typeof data[i] === "object") {
26
+ if (["enum", "interface"].includes(data[i].kind)) {
27
+ data.splice(i, 1);
28
+ i--;
29
+ } else {
30
+ clearProps(data[i]);
31
+ }
28
32
  }
29
33
  }
34
+ } else if (typeof data === "object") {
35
+ Object.keys(data).forEach(prop => {
36
+ if (prop.startsWith("_ui5")) {
37
+ delete data[prop];
38
+ } else if (typeof data[prop] === "object") {
39
+ clearProps(data[prop]);
40
+ }
41
+ });
30
42
  }
31
- } else if (typeof data === "object") {
32
- Object.keys(data).forEach(prop => {
33
- if (prop.startsWith("_ui5")) {
34
- delete data[prop];
35
- } else if (typeof data[prop] === "object") {
36
- clearProps(data[prop]);
37
- }
38
- });
43
+
44
+ return data;
39
45
  }
40
46
 
41
- return data;
42
- }
47
+ const ajv = new Ajv({ allowUnionTypes: true, allError: true })
48
+ let validate = ajv.compile(internalSchema)
43
49
 
44
- const ajv = new Ajv({ allowUnionTypes: true, allError: true })
45
- let validate = ajv.compile(internalSchema)
50
+ // Validate the JSON data against the schema
51
+ if (devMode) {
52
+ if (validate(inputDataInternal)) {
53
+ if (isVerbose()) {
54
+ console.log('Internal custom element manifest is validated successfully');
55
+ }
56
+ } else {
57
+ console.log(validate.errors)
58
+ throw new Error(`Validation of internal custom elements manifest failed: ${validate.errors}`);
59
+ }
60
+ }
61
+
62
+ const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));
63
+ validate = ajv.compile(extenalSchema)
46
64
 
47
- // Validate the JSON data against the schema
48
- if (devMode) {
49
- if (validate(inputDataInternal)) {
50
- console.log('Internal custom element manifest is validated successfully');
51
- } else {
52
- console.log(validate.errors)
53
- throw new Error(`Validation of internal custom elements manifest failed: ${validate.errors}`);
65
+ // Validate the JSON data against the schema
66
+ if (validate(inputDataExternal)) {
67
+ if (isVerbose()) {
68
+ console.log('Custom element manifest is validated successfully');
69
+ }
70
+ fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
71
+ fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
72
+ } else if (devMode) {
73
+ throw new Error(`Validation of public custom elements manifest failed: ${validate.errors}`);
54
74
  }
55
75
  }
56
76
 
57
- const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));
58
- validate = ajv.compile(extenalSchema)
77
+ if (require.main === module) {
78
+ validateFn()
79
+ }
59
80
 
60
- // Validate the JSON data against the schema
61
- if (validate(inputDataExternal)) {
62
- console.log('Custom element manifest is validated successfully');
63
- fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
64
- fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
65
- } else if (devMode) {
66
- throw new Error(`Validation of public custom elements manifest failed: ${validate.errors}`);
67
- }
81
+ exports._ui5mainFn = validateFn;
@@ -0,0 +1,28 @@
1
+ const chokidar = require('chokidar');
2
+ const { exec } = require("child_process");
3
+
4
+ const main = async (argv) => {
5
+ if (argv.length < 4) {
6
+ console.error("Please provide a file pattern to watch and a command to execute on changes.");
7
+ console.error("<file-pattern> <command>");
8
+ process.exit(1);
9
+ }
10
+
11
+ const filePattern = argv[2];
12
+ const command = argv.slice(3).join(' ');
13
+
14
+ const watcher = new chokidar.FSWatcher();
15
+
16
+ watcher.add(filePattern);
17
+ watcher.unwatch("src/generated");
18
+
19
+ watcher.on('change', async () => {
20
+ exec(command);
21
+ });
22
+ };
23
+
24
+ if (require.main === module) {
25
+ main(process.argv)
26
+ }
27
+
28
+ exports._ui5mainFn = main;
@@ -30,116 +30,129 @@ const globParent = require('glob-parent');
30
30
 
31
31
  /* CODE */
32
32
 
33
- const args = process.argv.slice(2);
34
- const options = {};
35
-
36
- ['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
37
- const index = args.indexOf(`--${key}`);
38
- if (index >= 0) {
39
- options[key] = true;
40
- args.splice(index, 1);
41
- }
42
- });
33
+ const copyAndWatchFn = async (argv) => {
34
+ const args = argv.slice(2);
35
+ const options = {};
36
+
37
+ ['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
38
+ const index = args.indexOf(`--${key}`);
39
+ if (index >= 0) {
40
+ options[key] = true;
41
+ args.splice(index, 1);
42
+ }
43
+ });
43
44
 
44
- if (args.length < 2) {
45
- console.error('Not enough arguments: copy-and-watch [options] <sources> <target>'.red);
46
- process.exit(1);
47
- }
45
+ // Default to silent mode unless verbose is enabled
46
+ if (process.env.UI5_VERBOSE !== "true") {
47
+ options.silent = true;
48
+ }
48
49
 
49
- if (options['skip-initial-copy'] && !options['watch']) {
50
- console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied'.red);
51
- process.exit(1);
52
- }
50
+ if (args.length < 2) {
51
+ console.error('Not enough arguments: copy-and-watch [options] <sources> <target>');
52
+ process.exit(1);
53
+ }
53
54
 
54
- const target = args.pop();
55
- const sources = args;
56
- const parents = [...new Set(sources.map(globParent))];
57
-
58
- const findTarget = from => {
59
- const parent = parents
60
- .filter(p => from.indexOf(p) >= 0)
61
- .sort()
62
- .reverse()[0];
63
- return path.join(target, path.relative(parent, from));
64
- };
65
- const createDirIfNotExist = to => {
66
- 'use strict';
67
-
68
- const dirs = [];
69
- let dir = path.dirname(to);
70
-
71
- while (dir !== path.dirname(dir)) {
72
- dirs.unshift(dir);
73
- dir = path.dirname(dir);
55
+ if (options['skip-initial-copy'] && !options['watch']) {
56
+ console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied');
57
+ process.exit(1);
74
58
  }
75
59
 
76
- dirs.forEach(dir => {
77
- if (!fs.existsSync(dir)) {
78
- fs.mkdirSync(dir);
60
+ const target = args.pop();
61
+ const sources = args;
62
+ const parents = [...new Set(sources.map(globParent))];
63
+
64
+ const findTarget = from => {
65
+ const parent = parents
66
+ .filter(p => from.indexOf(p) >= 0)
67
+ .sort()
68
+ .reverse()[0];
69
+ return path.join(target, path.relative(parent, from));
70
+ };
71
+ const createDirIfNotExist = to => {
72
+ 'use strict';
73
+
74
+ const dirs = [];
75
+ let dir = path.dirname(to);
76
+
77
+ while (dir !== path.dirname(dir)) {
78
+ dirs.unshift(dir);
79
+ dir = path.dirname(dir);
79
80
  }
80
- });
81
- };
82
- const copy = from => {
83
- const to = findTarget(from);
84
- createDirIfNotExist(to);
85
- const stats = fs.statSync(from);
86
- if (stats.isDirectory()) {
87
- return;
88
- }
89
- fs.writeFileSync(to, fs.readFileSync(from));
90
- options.silent || console.log('[COPY]'.yellow, from, 'to'.yellow, to);
91
- };
92
- const remove = from => {
93
- const to = findTarget(from);
94
- fs.unlinkSync(to);
95
- options.silent || console.log('[DELETE]'.yellow, to);
96
- };
97
- const rimraf = dir => {
98
- if (fs.existsSync(dir)) {
99
- fs.readdirSync(dir).forEach(entry => {
100
- const entryPath = path.join(dir, entry);
101
- if (fs.lstatSync(entryPath).isDirectory()) {
102
- rimraf(entryPath);
103
- } else {
104
- fs.unlinkSync(entryPath);
81
+
82
+ dirs.forEach(dir => {
83
+ if (!fs.existsSync(dir)) {
84
+ fs.mkdirSync(dir);
105
85
  }
106
86
  });
107
- fs.rmdirSync(dir);
87
+ };
88
+ const copy = from => {
89
+ const to = findTarget(from);
90
+ createDirIfNotExist(to);
91
+ const stats = fs.statSync(from);
92
+ if (stats.isDirectory()) {
93
+ return;
94
+ }
95
+ fs.writeFileSync(to, fs.readFileSync(from));
96
+ options.silent || console.log('[COPY]', from, 'to', to);
97
+ };
98
+ const remove = from => {
99
+ const to = findTarget(from);
100
+ fs.unlinkSync(to);
101
+ options.silent || console.log('[DELETE]', to);
102
+ };
103
+ const rimraf = dir => {
104
+ if (fs.existsSync(dir)) {
105
+ fs.readdirSync(dir).forEach(entry => {
106
+ const entryPath = path.join(dir, entry);
107
+ if (fs.lstatSync(entryPath).isDirectory()) {
108
+ rimraf(entryPath);
109
+ } else {
110
+ fs.unlinkSync(entryPath);
111
+ }
112
+ });
113
+ fs.rmdirSync(dir);
114
+ }
115
+ };
116
+
117
+ // clean
118
+ if (options.clean) {
119
+ rimraf(target);
108
120
  }
109
- };
110
121
 
111
- // clean
112
- if (options.clean) {
113
- rimraf(target);
114
- }
122
+ // initial copy
123
+ if (!options['skip-initial-copy']) {
124
+ sources.forEach(s => glob.sync(s).forEach(copy));
125
+ }
115
126
 
116
- // initial copy
117
- if (!options['skip-initial-copy']) {
118
- sources.forEach(s => glob.sync(s).forEach(copy));
119
- }
127
+ // watch
128
+ if (options.watch) {
129
+ const chokidarOptions = {
130
+ ignoreInitial: true
131
+ };
120
132
 
121
- // watch
122
- if (options.watch) {
123
- const chokidarOptions = {
124
- ignoreInitial: true
125
- };
133
+ if (options.safe) {
134
+ chokidarOptions.awaitWriteFinish = {
135
+ stabilityThreshold: 500,
136
+ pollInterval: 100
137
+ };
138
+ }
126
139
 
127
- if (options.safe) {
128
- chokidarOptions.awaitWriteFinish = {
129
- stabilityThreshold: 500,
130
- pollInterval: 100
131
- };
140
+ chokidar
141
+ .watch(sources, chokidarOptions)
142
+ .on('ready', () => sources.forEach(s => {
143
+ options.silent || console.log('[WATCH]', s);
144
+ }))
145
+ .on('add', copy)
146
+ .on('addDir', copy)
147
+ .on('change', copy)
148
+ .on('unlink', remove)
149
+ .on('unlinkDir', remove)
150
+ .on('error', e => console.log('[ERROR]', e));
132
151
  }
152
+ }
133
153
 
134
- chokidar
135
- .watch(sources, chokidarOptions)
136
- .on('ready', () => sources.forEach(s => {
137
- options.silent || console.log('[WATCH]'.yellow, s);
138
- }))
139
- .on('add', copy)
140
- .on('addDir', copy)
141
- .on('change', copy)
142
- .on('unlink', remove)
143
- .on('unlinkDir', remove)
144
- .on('error', e => console.log('[ERROR]'.red, e));
154
+ if (require.main === module) {
155
+ copyAndWatchFn(process.argv)
145
156
  }
157
+
158
+ exports._ui5mainFn = copyAndWatchFn;
@@ -1,11 +1,10 @@
1
1
  const fs = require("fs").promises;
2
2
  const path = require("path");
3
3
 
4
- const fileList = process.argv[2];
5
- const dest = process.argv[3];
6
- const src = "@openui5/sap.ui.core/src/";
7
-
8
- const generate = async () => {
4
+ const generate = async (argv) => {
5
+ const fileList = argv[2];
6
+ const dest = argv[3];
7
+ const src = "@openui5/sap.ui.core/src/";
9
8
  const filesToCopy = (await fs.readFile(fileList)).toString();
10
9
  // console.log(filesToCopy);
11
10
 
@@ -14,15 +13,24 @@ const generate = async () => {
14
13
 
15
14
  const trimFile = file => file.trim();
16
15
 
17
- return filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
18
- const srcPath = require.resolve(path.join(src, moduleName), {paths: [process.cwd()]});
16
+ const promises = filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
17
+ const srcPath = require.resolve(path.join(src, moduleName), { paths: [process.cwd()] });
19
18
  const destPath = path.join(dest, moduleName);
20
19
 
21
20
  await fs.mkdir(path.dirname(destPath), { recursive: true });
22
21
  return fs.copyFile(srcPath, destPath);
23
22
  });
23
+
24
+ return Promise.all(promises).then(() => {
25
+ if (process.env.UI5_VERBOSE === "true") {
26
+ console.log("Files copied.");
27
+ }
28
+ });
24
29
  };
25
30
 
26
- generate().then(() => {
27
- console.log("Files copied.");
28
- });
31
+
32
+ if (require.main === module) {
33
+ generate(process.argv)
34
+ }
35
+
36
+ exports._ui5mainFn = generate;
@@ -1,11 +1,6 @@
1
1
  const fs = require("fs").promises;
2
2
  const path = require("path");
3
3
 
4
- const collectionName = process.argv[2] || "SAP-icons-v4";
5
- const collectionVersion = process.argv[3];
6
- const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
7
- const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
8
-
9
4
  const iconTemplate = (name, pathData, ltr, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
10
5
 
11
6
  const name = "${name}";
@@ -71,10 +66,14 @@ const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewB
71
66
  <path d="${pathData}"/>
72
67
  </svg>`;
73
68
 
74
- const createIcons = async (file) => {
69
+ const createIcons = async (argv) => {
70
+ const collectionName = argv[2] || "SAP-icons-v4";
71
+ const collectionVersion = argv[3];
72
+ const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
73
+ const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
75
74
  await fs.mkdir(destDir, { recursive: true });
76
75
 
77
- const json = JSON.parse(await fs.readFile(file));
76
+ const json = JSON.parse(await fs.readFile(srcFile));
78
77
 
79
78
  const promises = [];
80
79
  for (let name in json.data) {
@@ -82,8 +81,8 @@ const createIcons = async (file) => {
82
81
  const pathData = iconData.path;
83
82
  const ltr = !!iconData.ltr;
84
83
  const acc = iconData.acc;
85
- const packageName = json.packageName;
86
- const collection = json.collection;
84
+ const packageName = json.packageName;
85
+ const collection = json.collection;
87
86
  const versioned = json.version;
88
87
 
89
88
  const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName, versioned) : iconTemplate(name, pathData, ltr, collection, packageName);
@@ -104,14 +103,17 @@ const createIcons = async (file) => {
104
103
  // For non-default collections (SAPTNTIcons and SAPBSIcons) we export the full name - "export default { 'tnt/actor' }"
105
104
  const effectiveName = isDefaultCollection(collection) ? name : getUnversionedFullIconName(name, collection);
106
105
  promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions, effectiveName)));
107
- promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(effectiveName, acc)));
106
+ promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(effectiveName, acc)));
108
107
  }
109
108
  }
110
109
 
111
- return Promise.all(promises);
110
+ return Promise.all(promises)
111
+ .then(() => {
112
+ console.log("Icons created.");
113
+ });
112
114
  };
113
115
 
114
- const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
116
+ const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
115
117
  const getUnversionedFullIconName = (name, collection) => `${getUnversionedCollectionName(collection)}/${name}`;
116
118
  const getUnversionedCollectionName = collectionName => CollectionVersionedToUnversionedMap[collectionName] || collectionName;
117
119
 
@@ -122,6 +124,8 @@ const CollectionVersionedToUnversionedMap = {
122
124
  "business-suite-v2": "business-suite",
123
125
  };
124
126
 
125
- createIcons(srcFile).then(() => {
126
- console.log("Icons created.");
127
- });
127
+ if (require.main === module) {
128
+ createIcons(process.argv)
129
+ }
130
+
131
+ exports._ui5mainFn = createIcons;
@@ -1,11 +1,10 @@
1
1
  const fs = require("fs").promises;
2
2
  const path = require("path");
3
3
 
4
- if (process.argv.length < 7) {
5
- throw new Error("Not enough arguments");
6
- }
7
-
8
- const generate = async () => {
4
+ const generate = async (argv) => {
5
+ if (argv.length < 7) {
6
+ throw new Error("Not enough arguments");
7
+ }
9
8
 
10
9
  const ORIGINAL_TEXTS = {
11
10
  UnableToLoad: "UnableToLoad",
@@ -20,7 +19,15 @@ const generate = async () => {
20
19
  SuccessScreen: "SuccessScreen",
21
20
  NoMail: "NoMail",
22
21
  NoSavedItems: "NoSavedItems",
23
- NoTasks: "NoTasks"
22
+ NoTasks: "NoTasks",
23
+ NoDimensionsSet: "NoDimensionsSet",
24
+ AddPeople: "AddPeople",
25
+ AddColumn: "AddColumn",
26
+ SortColumn: "SortColumn",
27
+ FilterTable: "FilterTable",
28
+ ResizeColumn: "ResizeColumn",
29
+ GroupTable: "GroupTable",
30
+ UploadCollection: "UploadCollection"
24
31
  };
25
32
 
26
33
  const FALLBACK_TEXTS = {
@@ -47,17 +54,27 @@ const generate = async () => {
47
54
  SimpleNotFoundMagnifier: ORIGINAL_TEXTS.NoSearchResults,
48
55
  SimpleReload: ORIGINAL_TEXTS.UnableToLoad,
49
56
  SimpleTask: ORIGINAL_TEXTS.NoTasks,
57
+ NoChartData: ORIGINAL_TEXTS.NoDimensionsSet,
58
+ AddingColumns: ORIGINAL_TEXTS.AddColumn,
59
+ SortingColumns: ORIGINAL_TEXTS.SortColumn,
60
+ FilteringColumns: ORIGINAL_TEXTS.FilterTable,
61
+ ResizingColumns: ORIGINAL_TEXTS.ResizeColumn,
62
+ GroupingColumns: ORIGINAL_TEXTS.GroupTable,
63
+ AddPeopleToCalendar: ORIGINAL_TEXTS.AddPeople,
64
+ DragFilesToUpload: ORIGINAL_TEXTS.UploadCollection,
65
+ KeyTask: ORIGINAL_TEXTS.SuccessScreen,
66
+ ReceiveAppreciation: ORIGINAL_TEXTS.BalloonSky,
50
67
  SuccessBalloon: ORIGINAL_TEXTS.BalloonSky,
51
68
  SuccessCheckMark: ORIGINAL_TEXTS.SuccessScreen,
52
69
  SuccessHighFive: ORIGINAL_TEXTS.BalloonSky
53
70
  };
54
71
 
55
- const srcPath = process.argv[2];
56
- const defaultText = process.argv[3] === "true";
57
- const illustrationsPrefix = process.argv[4];
58
- const illustrationSet = process.argv[5];
59
- const destPath = process.argv[6];
60
- const collection = process.argv[7];
72
+ const srcPath = argv[2];
73
+ const defaultText = argv[3] === "true";
74
+ const illustrationsPrefix = argv[4];
75
+ const illustrationSet = argv[5];
76
+ const destPath = argv[6];
77
+ const collection = argv[7];
61
78
  const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
62
79
  // collect each illustration name because each one should have Sample.js file
63
80
  const fileNames = new Set();
@@ -67,11 +84,15 @@ const generate = async () => {
67
84
  try {
68
85
  await fs.access(srcPath);
69
86
  } catch (error) {
70
- console.log(`The path ${srcPath} does not exist.`);
87
+ if (process.env.UI5_VERBOSE === "true") {
88
+ console.log(`The path ${srcPath} does not exist.`);
89
+ }
71
90
  return Promise.resolve(null);
72
91
  }
73
92
 
74
- console.log(`Generating illustrations from ${srcPath} to ${destPath}`)
93
+ if (process.env.UI5_VERBOSE === "true") {
94
+ console.log(`Generating illustrations from ${srcPath} to ${destPath}`);
95
+ }
75
96
 
76
97
  const svgImportTemplate = svgContent => {
77
98
  return `export default \`${svgContent}\`;`
@@ -104,12 +125,11 @@ const generate = async () => {
104
125
  // If no Dot is present, Spot will be imported as Dot
105
126
  const hasDot = dotIllustrationNames.indexOf(illustrationName) !== -1 ? 'Dot' : 'Spot';
106
127
 
107
- return `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
128
+ return `import { unsafeRegisterIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
108
129
  import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
109
130
  import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
110
131
  import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
111
- import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${
112
- defaultText ? `import {
132
+ import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${defaultText ? `import {
113
133
  IM_TITLE_${illustrationNameUpperCase},
114
134
  IM_SUBTITLE_${illustrationNameUpperCase},
115
135
  } from "../generated/i18n/i18n-defaults.js";` : ``}
@@ -120,7 +140,7 @@ const collection = "${collection}";${defaultText ? `
120
140
  const title = IM_TITLE_${illustrationNameUpperCase};
121
141
  const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};` : ``}
122
142
 
123
- registerIllustration(name, {
143
+ unsafeRegisterIllustration(name, {
124
144
  dialogSvg,
125
145
  sceneSvg,
126
146
  spotSvg,
@@ -166,17 +186,25 @@ export { dialogSvg, sceneSvg, spotSvg, dotSvg };`
166
186
  }
167
187
  });
168
188
 
169
- return Promise.all(promises).then(() => {
170
- const nestedPromises = [];
171
- for (let illustrationName of fileNames) {
172
- nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
173
- nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.d.ts`), illustrationTypeDefinition(illustrationName)));
174
- }
189
+ return Promise.all(promises)
190
+ .then(() => {
191
+ const nestedPromises = [];
192
+ for (let illustrationName of fileNames) {
193
+ nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
194
+ nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.d.ts`), illustrationTypeDefinition(illustrationName)));
195
+ }
175
196
 
176
- return Promise.all(nestedPromises);
177
- });
197
+ return Promise.all(nestedPromises);
198
+ })
199
+ .then(() => {
200
+ if (process.env.UI5_VERBOSE === "true") {
201
+ console.log("Illustrations generated.");
202
+ }
203
+ });
178
204
  };
179
205
 
180
- generate().then(() => {
181
- console.log("Illustrations generated.");
182
- });
206
+ if (require.main === module) {
207
+ generate(process.argv)
208
+ }
209
+
210
+ exports._ui5mainFn = generate;