@ui5/webcomponents-tools 0.0.0-9261ac932 → 0.0.0-95afb1087

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 (106) hide show
  1. package/CHANGELOG.md +737 -0
  2. package/LICENSE.txt +201 -0
  3. package/README.md +7 -7
  4. package/assets-meta.js +1 -5
  5. package/bin/dev.js +3 -2
  6. package/bin/ui5nps.js +265 -0
  7. package/components-package/eslint.js +29 -39
  8. package/components-package/nps.js +98 -75
  9. package/components-package/vite.config.js +7 -11
  10. package/components-package/wdio.js +9 -3
  11. package/icons-collection/nps.js +30 -21
  12. package/lib/amd-to-es6/index.js +15 -10
  13. package/lib/cem/cem.js +12 -0
  14. package/lib/cem/custom-elements-manifest.config.mjs +58 -39
  15. package/lib/cem/event.mjs +51 -31
  16. package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
  17. package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
  18. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
  19. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
  20. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
  21. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
  22. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
  23. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
  24. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
  25. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
  26. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
  27. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
  28. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
  29. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
  30. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
  31. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
  32. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
  33. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
  34. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
  35. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
  36. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
  37. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
  38. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
  39. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
  40. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
  41. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
  42. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
  43. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
  44. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
  45. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
  46. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
  47. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
  48. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
  49. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
  50. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
  51. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
  52. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
  53. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
  54. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
  55. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
  56. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
  57. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
  58. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
  59. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
  60. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
  61. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
  62. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
  63. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
  64. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
  65. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
  66. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
  67. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
  68. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
  69. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
  70. package/lib/cem/schema-internal.json +9 -0
  71. package/lib/cem/utils.mjs +50 -25
  72. package/lib/cem/validate.js +61 -55
  73. package/lib/chokidar/chokidar.js +29 -0
  74. package/lib/copy-and-watch/index.js +105 -97
  75. package/lib/copy-list/index.js +16 -10
  76. package/lib/create-icons/index.js +24 -19
  77. package/lib/create-illustrations/index.js +51 -28
  78. package/lib/create-new-component/{tsFileContentTemplate.js → Component.js} +11 -8
  79. package/lib/create-new-component/ComponentTemplate.js +12 -0
  80. package/lib/create-new-component/index.js +13 -10
  81. package/lib/css-processors/css-processor-components.mjs +75 -60
  82. package/lib/css-processors/css-processor-themes.mjs +101 -62
  83. package/lib/css-processors/scope-variables.mjs +17 -9
  84. package/lib/css-processors/shared.mjs +5 -35
  85. package/lib/dev-server/dev-server.mjs +24 -12
  86. package/lib/dev-server/virtual-index-html-plugin.js +24 -20
  87. package/lib/eslint/eslint.js +44 -0
  88. package/lib/generate-js-imports/illustrations.js +53 -54
  89. package/lib/generate-json-imports/i18n.js +20 -11
  90. package/lib/generate-json-imports/themes.js +20 -12
  91. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +8 -3
  92. package/lib/i18n/defaults.js +12 -7
  93. package/lib/i18n/toJSON.js +15 -12
  94. package/lib/icons-hash/icons-hash.mjs +149 -0
  95. package/lib/remove-dev-mode/remove-dev-mode.mjs +38 -24
  96. package/lib/rimraf/rimraf.js +31 -0
  97. package/lib/test-runner/test-runner.js +56 -48
  98. package/lib/vite-bundler/vite-bundler.mjs +35 -0
  99. package/package.json +19 -22
  100. package/tsconfig.json +2 -0
  101. package/components-package/cypress/support/commands.js +0 -39
  102. package/components-package/cypress/support/component-index.html +0 -17
  103. package/components-package/cypress/support/component.d.ts +0 -23
  104. package/components-package/cypress/support/component.js +0 -34
  105. package/components-package/cypress.config.js +0 -19
  106. package/types/index.d.ts +0 -1
@@ -30,116 +30,124 @@ 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);
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
+ });
44
+
45
+ if (args.length < 2) {
46
+ console.error('Not enough arguments: copy-and-watch [options] <sources> <target>');
47
+ process.exit(1);
41
48
  }
42
- });
43
49
 
44
- if (args.length < 2) {
45
- console.error('Not enough arguments: copy-and-watch [options] <sources> <target>'.red);
46
- process.exit(1);
47
- }
50
+ if (options['skip-initial-copy'] && !options['watch']) {
51
+ console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied');
52
+ process.exit(1);
53
+ }
48
54
 
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
- }
55
+ const target = args.pop();
56
+ const sources = args;
57
+ const parents = [...new Set(sources.map(globParent))];
53
58
 
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);
74
- }
59
+ const findTarget = from => {
60
+ const parent = parents
61
+ .filter(p => from.indexOf(p) >= 0)
62
+ .sort()
63
+ .reverse()[0];
64
+ return path.join(target, path.relative(parent, from));
65
+ };
66
+ const createDirIfNotExist = to => {
67
+ 'use strict';
68
+
69
+ const dirs = [];
70
+ let dir = path.dirname(to);
75
71
 
76
- dirs.forEach(dir => {
77
- if (!fs.existsSync(dir)) {
78
- fs.mkdirSync(dir);
72
+ while (dir !== path.dirname(dir)) {
73
+ dirs.unshift(dir);
74
+ dir = path.dirname(dir);
79
75
  }
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);
76
+
77
+ dirs.forEach(dir => {
78
+ if (!fs.existsSync(dir)) {
79
+ fs.mkdirSync(dir);
105
80
  }
106
81
  });
107
- fs.rmdirSync(dir);
82
+ };
83
+ const copy = from => {
84
+ const to = findTarget(from);
85
+ createDirIfNotExist(to);
86
+ const stats = fs.statSync(from);
87
+ if (stats.isDirectory()) {
88
+ return;
89
+ }
90
+ fs.writeFileSync(to, fs.readFileSync(from));
91
+ options.silent || console.log('[COPY]', from, 'to', to);
92
+ };
93
+ const remove = from => {
94
+ const to = findTarget(from);
95
+ fs.unlinkSync(to);
96
+ options.silent || console.log('[DELETE]', to);
97
+ };
98
+ const rimraf = dir => {
99
+ if (fs.existsSync(dir)) {
100
+ fs.readdirSync(dir).forEach(entry => {
101
+ const entryPath = path.join(dir, entry);
102
+ if (fs.lstatSync(entryPath).isDirectory()) {
103
+ rimraf(entryPath);
104
+ } else {
105
+ fs.unlinkSync(entryPath);
106
+ }
107
+ });
108
+ fs.rmdirSync(dir);
109
+ }
110
+ };
111
+
112
+ // clean
113
+ if (options.clean) {
114
+ rimraf(target);
108
115
  }
109
- };
110
116
 
111
- // clean
112
- if (options.clean) {
113
- rimraf(target);
114
- }
117
+ // initial copy
118
+ if (!options['skip-initial-copy']) {
119
+ sources.forEach(s => glob.sync(s).forEach(copy));
120
+ }
115
121
 
116
- // initial copy
117
- if (!options['skip-initial-copy']) {
118
- sources.forEach(s => glob.sync(s).forEach(copy));
119
- }
122
+ // watch
123
+ if (options.watch) {
124
+ const chokidarOptions = {
125
+ ignoreInitial: true
126
+ };
120
127
 
121
- // watch
122
- if (options.watch) {
123
- const chokidarOptions = {
124
- ignoreInitial: true
125
- };
128
+ if (options.safe) {
129
+ chokidarOptions.awaitWriteFinish = {
130
+ stabilityThreshold: 500,
131
+ pollInterval: 100
132
+ };
133
+ }
126
134
 
127
- if (options.safe) {
128
- chokidarOptions.awaitWriteFinish = {
129
- stabilityThreshold: 500,
130
- pollInterval: 100
131
- };
135
+ chokidar
136
+ .watch(sources, chokidarOptions)
137
+ .on('ready', () => sources.forEach(s => {
138
+ options.silent || console.log('[WATCH]', s);
139
+ }))
140
+ .on('add', copy)
141
+ .on('addDir', copy)
142
+ .on('change', copy)
143
+ .on('unlink', remove)
144
+ .on('unlinkDir', remove)
145
+ .on('error', e => console.log('[ERROR]', e));
132
146
  }
147
+ }
133
148
 
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));
149
+ if (require.main === module) {
150
+ copyAndWatchFn(process.argv)
145
151
  }
152
+
153
+ 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,22 @@ 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
+ console.log("Files copied.");
26
+ });
24
27
  };
25
28
 
26
- generate().then(() => {
27
- console.log("Files copied.");
28
- });
29
+
30
+ if (require.main === module) {
31
+ generate(process.argv)
32
+ }
33
+
34
+ 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}";
@@ -21,8 +16,8 @@ export default "${collection}/${name}";
21
16
  export { pathData, ltr, accData };`;
22
17
 
23
18
 
24
- const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
25
- import { ${accData.key} } from "../generated/i18n/i18n-defaults.js";
19
+ const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName, versioned) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
20
+ import { ${accData.key} } from "${versioned ? "../" : "./"}generated/i18n/i18n-defaults.js";
26
21
 
27
22
  const name = "${name}";
28
23
  const pathData = "${pathData}";
@@ -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,10 +81,11 @@ 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;
86
+ const versioned = json.version;
87
87
 
88
- const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName) : iconTemplate(name, pathData, ltr, collection, packageName);
88
+ const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName, versioned) : iconTemplate(name, pathData, ltr, collection, packageName);
89
89
 
90
90
  promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
91
91
  promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
@@ -96,21 +96,24 @@ const createIcons = async (file) => {
96
96
  // - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
97
97
  // - "@ui5/ui5-webcomponents-icons/dist/v4/accept.js"
98
98
 
99
- if (json.version) {
99
+ if (versioned) {
100
100
  // The exported value from the top level (unversioned) icon module depends on whether the collection is the default,
101
101
  // to add or not the collection name to the exported value:
102
102
  // For the default collection (SAPIcons) we export just the icon name - "export default { 'accept' }"
103
103
  // For non-default collections (SAPTNTIcons and SAPBSIcons) we export the full name - "export default { 'tnt/actor' }"
104
104
  const effectiveName = isDefaultCollection(collection) ? name : getUnversionedFullIconName(name, collection);
105
105
  promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions, effectiveName)));
106
- 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)));
107
107
  }
108
108
  }
109
109
 
110
- return Promise.all(promises);
110
+ return Promise.all(promises)
111
+ .then(() => {
112
+ console.log("Icons created.");
113
+ });
111
114
  };
112
115
 
113
- const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
116
+ const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
114
117
  const getUnversionedFullIconName = (name, collection) => `${getUnversionedCollectionName(collection)}/${name}`;
115
118
  const getUnversionedCollectionName = collectionName => CollectionVersionedToUnversionedMap[collectionName] || collectionName;
116
119
 
@@ -121,6 +124,8 @@ const CollectionVersionedToUnversionedMap = {
121
124
  "business-suite-v2": "business-suite",
122
125
  };
123
126
 
124
- createIcons(srcFile).then(() => {
125
- console.log("Icons created.");
126
- });
127
+ if (require.main === module) {
128
+ createIcons(process.argv)
129
+ }
130
+
131
+ exports._ui5mainFn = createIcons;
@@ -1,11 +1,11 @@
1
1
  const fs = require("fs").promises;
2
2
  const path = require("path");
3
+ const { scopeThemingVariables } = require("../css-processors/scope-variables.mjs");
3
4
 
4
- if (process.argv.length < 7) {
5
- throw new Error("Not enough arguments");
6
- }
7
-
8
- const generate = async () => {
5
+ const generate = async (argv) => {
6
+ if (argv.length < 7) {
7
+ throw new Error("Not enough arguments");
8
+ }
9
9
 
10
10
  const ORIGINAL_TEXTS = {
11
11
  UnableToLoad: "UnableToLoad",
@@ -20,7 +20,15 @@ const generate = async () => {
20
20
  SuccessScreen: "SuccessScreen",
21
21
  NoMail: "NoMail",
22
22
  NoSavedItems: "NoSavedItems",
23
- NoTasks: "NoTasks"
23
+ NoTasks: "NoTasks",
24
+ NoDimensionsSet: "NoDimensionsSet",
25
+ AddPeople: "AddPeople",
26
+ AddColumn: "AddColumn",
27
+ SortColumn: "SortColumn",
28
+ FilterTable: "FilterTable",
29
+ ResizeColumn: "ResizeColumn",
30
+ GroupTable: "GroupTable",
31
+ UploadCollection: "UploadCollection"
24
32
  };
25
33
 
26
34
  const FALLBACK_TEXTS = {
@@ -47,17 +55,27 @@ const generate = async () => {
47
55
  SimpleNotFoundMagnifier: ORIGINAL_TEXTS.NoSearchResults,
48
56
  SimpleReload: ORIGINAL_TEXTS.UnableToLoad,
49
57
  SimpleTask: ORIGINAL_TEXTS.NoTasks,
58
+ NoChartData: ORIGINAL_TEXTS.NoDimensionsSet,
59
+ AddingColumns: ORIGINAL_TEXTS.AddColumn,
60
+ SortingColumns: ORIGINAL_TEXTS.SortColumn,
61
+ FilteringColumns: ORIGINAL_TEXTS.FilterTable,
62
+ ResizingColumns: ORIGINAL_TEXTS.ResizeColumn,
63
+ GroupingColumns: ORIGINAL_TEXTS.GroupTable,
64
+ AddPeopleToCalendar: ORIGINAL_TEXTS.AddPeople,
65
+ DragFilesToUpload: ORIGINAL_TEXTS.UploadCollection,
66
+ KeyTask: ORIGINAL_TEXTS.SuccessScreen,
67
+ ReceiveAppreciation: ORIGINAL_TEXTS.BalloonSky,
50
68
  SuccessBalloon: ORIGINAL_TEXTS.BalloonSky,
51
69
  SuccessCheckMark: ORIGINAL_TEXTS.SuccessScreen,
52
70
  SuccessHighFive: ORIGINAL_TEXTS.BalloonSky
53
71
  };
54
72
 
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];
73
+ const srcPath = argv[2];
74
+ const defaultText = argv[3] === "true";
75
+ const illustrationsPrefix = argv[4];
76
+ const illustrationSet = argv[5];
77
+ const destPath = argv[6];
78
+ const collection = argv[7];
61
79
  const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
62
80
  // collect each illustration name because each one should have Sample.js file
63
81
  const fileNames = new Set();
@@ -74,7 +92,7 @@ const generate = async () => {
74
92
  console.log(`Generating illustrations from ${srcPath} to ${destPath}`)
75
93
 
76
94
  const svgImportTemplate = svgContent => {
77
- return `export default \`${svgContent}\`;`
95
+ return `export default \`${scopeThemingVariables(svgContent)}\`;`
78
96
  };
79
97
  const svgToJs = async fileName => {
80
98
  const svg = await fs.readFile(path.join(srcPath, fileName), { encoding: "utf-8" });
@@ -104,12 +122,11 @@ const generate = async () => {
104
122
  // If no Dot is present, Spot will be imported as Dot
105
123
  const hasDot = dotIllustrationNames.indexOf(illustrationName) !== -1 ? 'Dot' : 'Spot';
106
124
 
107
- return `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
125
+ return `import { unsafeRegisterIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
108
126
  import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
109
127
  import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
110
128
  import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
111
- import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${
112
- defaultText ? `import {
129
+ import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${defaultText ? `import {
113
130
  IM_TITLE_${illustrationNameUpperCase},
114
131
  IM_SUBTITLE_${illustrationNameUpperCase},
115
132
  } from "../generated/i18n/i18n-defaults.js";` : ``}
@@ -120,7 +137,7 @@ const collection = "${collection}";${defaultText ? `
120
137
  const title = IM_TITLE_${illustrationNameUpperCase};
121
138
  const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};` : ``}
122
139
 
123
- registerIllustration(name, {
140
+ unsafeRegisterIllustration(name, {
124
141
  dialogSvg,
125
142
  sceneSvg,
126
143
  spotSvg,
@@ -166,17 +183,23 @@ export { dialogSvg, sceneSvg, spotSvg, dotSvg };`
166
183
  }
167
184
  });
168
185
 
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
- }
186
+ return Promise.all(promises)
187
+ .then(() => {
188
+ const nestedPromises = [];
189
+ for (let illustrationName of fileNames) {
190
+ nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
191
+ nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.d.ts`), illustrationTypeDefinition(illustrationName)));
192
+ }
175
193
 
176
- return Promise.all(nestedPromises);
177
- });
194
+ return Promise.all(nestedPromises);
195
+ })
196
+ .then(() => {
197
+ console.log("Illustrations generated.");
198
+ });
178
199
  };
179
200
 
180
- generate().then(() => {
181
- console.log("Illustrations generated.");
182
- });
201
+ if (require.main === module) {
202
+ generate(process.argv)
203
+ }
204
+
205
+ exports._ui5mainFn = generate;
@@ -1,12 +1,12 @@
1
- const tsFileContentTemplate = (componentName, tagName, library, packageName) => {
1
+ const Component = (componentName, tagName, library, packageName) => {
2
2
  return `import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
3
3
  import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
4
4
  import property from "@ui5/webcomponents-base/dist/decorators/property.js";
5
5
  import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
6
- import event from "@ui5/webcomponents-base/dist/decorators/event.js";
7
- import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
6
+ import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
7
+ import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
8
8
 
9
- import ${componentName}Template from "./generated/templates/${componentName}Template.lit.js";
9
+ import ${componentName}Template from "./${componentName}Template.js";
10
10
 
11
11
  // Styles
12
12
  import ${componentName}Css from "./generated/themes/${componentName}.css.js";
@@ -30,10 +30,9 @@ import ${componentName}Css from "./generated/themes/${componentName}.css.js";
30
30
  */
31
31
  @customElement({
32
32
  tag: "${tagName}",
33
- renderer: litRender,
33
+ renderer: jsxRenderer,
34
34
  styles: ${componentName}Css,
35
35
  template: ${componentName}Template,
36
- dependencies: [],
37
36
  })
38
37
 
39
38
  /**
@@ -42,8 +41,12 @@ import ${componentName}Css from "./generated/themes/${componentName}.css.js";
42
41
  *
43
42
  * @public
44
43
  */
45
- @event("interact", { detail: { /* event payload ( optional ) */ } })
44
+ @event("interact")
46
45
  class ${componentName} extends UI5Element {
46
+ eventDetails!: {
47
+ "interact": void,
48
+ };
49
+
47
50
  /**
48
51
  * Defines the value of the component.
49
52
  *
@@ -68,4 +71,4 @@ export default ${componentName};
68
71
  `;
69
72
  };
70
73
 
71
- module.exports = tsFileContentTemplate;
74
+ module.exports = Component;
@@ -0,0 +1,12 @@
1
+ const ComponentTemplate = (componentName) => {
2
+ return `import type ${componentName} from "./${componentName}.js";
3
+
4
+ export default function ${componentName}Template(this: ${componentName}) {
5
+ return (
6
+ <div>Hello World!</div>
7
+ );
8
+ }
9
+ `;
10
+ };
11
+
12
+ module.exports = ComponentTemplate;
@@ -1,16 +1,19 @@
1
1
  const fs = require("fs");
2
2
  const prompts = require("prompts");
3
- const tsFileContentTemplate = require("./tsFileContentTemplate.js");
3
+ const Component = require("./Component.js");
4
+ const ComponentTemplate= require("./ComponentTemplate.js");
5
+ const dotenv = require('dotenv');
6
+ dotenv.config();
4
7
 
5
8
  /**
6
- * Hyphanates the given PascalCase string, f.e.:
7
- * Foo -> "my-foo" (adds preffix)
8
- * FooBar -> "foo-bar"
9
+ * Hyphanates the given PascalCase string and adds prefix, f.e.:
10
+ * Foo -> "my-foo"
11
+ * FooBar -> "my-foo-bar"
9
12
  */
10
13
  const hyphaneteComponentName = (componentName) => {
11
14
  const result = componentName.replace(/([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
12
15
 
13
- return result.includes("-") ? result : `my-${result}`;
16
+ return `${process.env.UI5_TAG_NAME_PREFIX ?? "my"}-${result}`;
14
17
  };
15
18
 
16
19
  /**
@@ -61,12 +64,12 @@ const generateFiles = (componentName, tagName, library, packageName) => {
61
64
  const filePaths = {
62
65
  "main": `./src/${componentName}.ts`,
63
66
  "css": `./src/themes/${componentName}.css`,
64
- "template": `./src/${componentName}.hbs`,
67
+ "template": `./src/${componentName}${process.env.UI5_TEMPLATE_FILENAME_SUFFIX ?? "Template"}.tsx`,
65
68
  };
66
69
 
67
- fs.writeFileSync(filePaths.main, tsFileContentTemplate(componentName, tagName, library, packageName), { flag: "wx+" });
70
+ fs.writeFileSync(filePaths.main, Component(componentName, tagName, library, packageName), { flag: "wx+" });
68
71
  fs.writeFileSync(filePaths.css, "", { flag: "wx+" });
69
- fs.writeFileSync(filePaths.template, "<div>Hello World</div>", { flag: "wx+" });
72
+ fs.writeFileSync(filePaths.template, ComponentTemplate(componentName), { flag: "wx+" });
70
73
 
71
74
  console.log(`Successfully generated ${filePaths.main}`);
72
75
  console.log(`Successfully generated ${filePaths.css}`);
@@ -74,8 +77,8 @@ const generateFiles = (componentName, tagName, library, packageName) => {
74
77
 
75
78
  // Change the color of the output
76
79
  console.warn('\x1b[33m%s\x1b[0m', `
77
- Make sure to import the component in your bundle by using:
78
- import "./dist/${componentName}.js";`);
80
+ Now, import the component in "src/bundle.esm.ts" via: import "./${componentName}.js";
81
+ And, add it to your HTML: <${tagName}></${tagName}>.`);
79
82
  }
80
83
 
81
84
  // Main function