@ui5/webcomponents-tools 0.0.0-037d08c67

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 (124) hide show
  1. package/CHANGELOG.md +2474 -0
  2. package/LICENSE.txt +201 -0
  3. package/README.md +21 -0
  4. package/assets-meta.js +154 -0
  5. package/bin/create-ui5-element.js +3 -0
  6. package/bin/dev.js +22 -0
  7. package/bin/ui5nps.js +301 -0
  8. package/components-package/eslint.js +195 -0
  9. package/components-package/nps.js +177 -0
  10. package/components-package/postcss.components.js +1 -0
  11. package/components-package/postcss.themes.js +1 -0
  12. package/components-package/vite.config.js +9 -0
  13. package/components-package/wdio.js +421 -0
  14. package/icons-collection/nps.js +80 -0
  15. package/lib/amd-to-es6/index.js +109 -0
  16. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  17. package/lib/cem/cem.js +16 -0
  18. package/lib/cem/custom-elements-manifest.config.mjs +575 -0
  19. package/lib/cem/event.mjs +168 -0
  20. package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
  21. package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
  22. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
  23. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
  24. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
  25. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
  26. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
  27. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
  28. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
  29. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
  30. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
  31. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
  32. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
  33. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
  34. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
  35. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
  36. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
  37. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
  38. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
  39. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
  40. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
  41. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
  42. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
  43. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
  44. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
  45. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
  46. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
  47. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
  48. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
  49. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
  50. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
  51. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
  52. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
  53. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
  54. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
  55. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
  56. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
  57. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
  58. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
  59. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
  60. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
  61. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
  62. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
  63. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
  64. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
  65. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
  66. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
  67. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
  68. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
  69. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
  70. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
  71. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
  72. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
  73. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
  74. package/lib/cem/schema-internal.json +1422 -0
  75. package/lib/cem/schema.json +1098 -0
  76. package/lib/cem/types-internal.d.ts +808 -0
  77. package/lib/cem/types.d.ts +736 -0
  78. package/lib/cem/utils.mjs +429 -0
  79. package/lib/cem/validate.js +81 -0
  80. package/lib/chokidar/chokidar.js +28 -0
  81. package/lib/copy-and-watch/index.js +158 -0
  82. package/lib/copy-list/index.js +36 -0
  83. package/lib/create-icons/index.js +131 -0
  84. package/lib/create-illustrations/index.js +210 -0
  85. package/lib/create-new-component/Component.js +74 -0
  86. package/lib/create-new-component/ComponentTemplate.js +12 -0
  87. package/lib/create-new-component/index.js +115 -0
  88. package/lib/css-processors/css-processor-components.mjs +101 -0
  89. package/lib/css-processors/css-processor-themes.mjs +121 -0
  90. package/lib/css-processors/postcss-plugin.mjs +153 -0
  91. package/lib/css-processors/scope-variables.mjs +51 -0
  92. package/lib/css-processors/shared.mjs +47 -0
  93. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  94. package/lib/dev-server/dev-server.mjs +78 -0
  95. package/lib/dev-server/virtual-index-html-plugin.js +56 -0
  96. package/lib/eslint/eslint.js +44 -0
  97. package/lib/generate-js-imports/illustrations.js +87 -0
  98. package/lib/generate-json-imports/i18n.js +93 -0
  99. package/lib/generate-json-imports/themes.js +75 -0
  100. package/lib/hbs2lit/index.js +3 -0
  101. package/lib/hbs2lit/src/compiler.js +60 -0
  102. package/lib/hbs2lit/src/extendedAttributeMapping.js +12 -0
  103. package/lib/hbs2lit/src/includesReplacer.js +31 -0
  104. package/lib/hbs2lit/src/litVisitor2.js +278 -0
  105. package/lib/hbs2lit/src/partials2.js +51 -0
  106. package/lib/hbs2lit/src/partialsVisitor.js +187 -0
  107. package/lib/hbs2lit/src/svgProcessor.js +76 -0
  108. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +45 -0
  109. package/lib/hbs2ui5/index.js +119 -0
  110. package/lib/i18n/defaults.js +90 -0
  111. package/lib/i18n/toJSON.js +71 -0
  112. package/lib/icons-hash/icons-hash.mjs +149 -0
  113. package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
  114. package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
  115. package/lib/rimraf/rimraf.js +31 -0
  116. package/lib/scoping/get-all-tags.js +44 -0
  117. package/lib/scoping/lint-src.js +32 -0
  118. package/lib/scoping/missing-dependencies.js +65 -0
  119. package/lib/scoping/report-tags-usage.js +28 -0
  120. package/lib/scoping/scope-test-pages.js +41 -0
  121. package/lib/test-runner/test-runner.js +79 -0
  122. package/lib/vite-bundler/vite-bundler.mjs +35 -0
  123. package/package.json +86 -0
  124. package/tsconfig.json +18 -0
package/bin/ui5nps.js ADDED
@@ -0,0 +1,301 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const { exec } = require("child_process");
8
+ var { parseArgsStringToArgv } = require('string-argv');
9
+
10
+ const SCRIPT_NAMES = [
11
+ "package-scripts.js",
12
+ "package-scripts.cjs",
13
+ "package-scripts.mjs"
14
+ ]
15
+
16
+ /**
17
+ * Check if verbose mode is enabled via CLI flag or environment variable.
18
+ * @returns {boolean}
19
+ */
20
+ function isVerbose() {
21
+ return process.env.UI5_VERBOSE === "true";
22
+ }
23
+
24
+ /**
25
+ * Log a message only in verbose mode.
26
+ * @param {...any} args - Arguments to pass to console.log
27
+ */
28
+ function verboseLog(...args) {
29
+ if (isVerbose()) {
30
+ console.log(...args);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Parser for UI5 package scripts with support for parallel and sequential execution
36
+ */
37
+ class Parser {
38
+ scripts;
39
+ envs;
40
+ parsedScripts = new Map();
41
+ resolvedScripts = new Map();
42
+
43
+ constructor() {
44
+ const { scripts, envs } = this.getScripts();
45
+
46
+ this.scripts = scripts;
47
+ this.envs = envs;
48
+
49
+ // Parse scripts on initialization
50
+ this.parseScripts();
51
+
52
+ [...this.parsedScripts.keys()].forEach(key => {
53
+ this.resolveScripts(`${key}`);
54
+ });
55
+ }
56
+
57
+ /**
58
+ * Recursively parses script definitions from package-scripts file
59
+ * @param {Object} scripts - Script definitions object
60
+ * @param {string} parentKey - Parent key for nested scripts
61
+ */
62
+ parseScripts(scripts = this.scripts, parentKey = "") {
63
+ for (const [key, value] of Object.entries(scripts)) {
64
+ if (key === "__ui5envs") continue; // Skip envs key
65
+
66
+ if (parentKey && key === "default") {
67
+ this.parsedScripts.set(parentKey, value);
68
+ }
69
+
70
+ const fullKey = parentKey ? `${parentKey}.${key}` : key;
71
+
72
+ if (typeof value === "string") {
73
+ this.parsedScripts.set(fullKey, value);
74
+ } else if (typeof value === "object") {
75
+ this.parseScripts(value, fullKey);
76
+ } else {
77
+ throw new Error(`Invalid script definition for key: ${fullKey}`);
78
+ }
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Resolves script commands and determines if they should run in parallel
84
+ * @param {string} commandName - Name of the command to resolve
85
+ * @returns {Object} Resolved command object with commands array and parallel flag
86
+ */
87
+ resolveScripts(commandName) {
88
+ if (this.resolvedScripts.has(commandName)) {
89
+ return this.resolvedScripts.get(commandName);
90
+ }
91
+
92
+ let executableCommand = this.parsedScripts.get(commandName);
93
+ if (executableCommand === undefined) {
94
+ throw new Error(`Command "${commandName}" not found in scripts`);
95
+ }
96
+
97
+ if (!executableCommand.startsWith("ui5nps") || executableCommand.startsWith("ui5nps-script")) {
98
+ this.resolvedScripts.set(commandName, { commandName, commands: [executableCommand], parallel: false });
99
+ return this.resolvedScripts.get(commandName);
100
+ }
101
+
102
+ const parts = executableCommand.trim().split(" ").filter(Boolean).slice(1); // Remove "ui5nps" or ui5nps-p part
103
+ const commands = [];
104
+ for (const part of parts) {
105
+ if (!this.parsedScripts.has(part)) {
106
+ throw new Error(`Referenced command "${part}" not found in scripts`);
107
+ }
108
+
109
+ const parsedScript = this.parsedScripts.get(part);
110
+
111
+ if (parsedScript && (parsedScript.startsWith("ui5nps") || parsedScript.startsWith("ui5nps-p"))) {
112
+ this.resolveScripts(part);
113
+ }
114
+
115
+ commands.push(this.resolvedScripts.get(part) || { commandName: part, commands: [parsedScript], parallel: parsedScript.startsWith("ui5nps-p") });
116
+ }
117
+
118
+
119
+ this.resolvedScripts.set(commandName, { commandName, commands, parallel: executableCommand.startsWith("ui5nps-p") });
120
+
121
+ return this.resolvedScripts.get(commandName);
122
+ }
123
+
124
+ /**
125
+ * Loads and validates package-scripts file
126
+ * @returns {Object} Object containing scripts and environment variables
127
+ */
128
+ getScripts() {
129
+ let packageScriptPath;
130
+
131
+ for (const scriptName of SCRIPT_NAMES) {
132
+ const filePath = path.join(process.cwd(), scriptName);
133
+ if (fs.existsSync(filePath)) {
134
+ packageScriptPath = filePath;
135
+ break;
136
+ }
137
+ }
138
+
139
+ // Package-script file should be in the current working directory
140
+ if (!packageScriptPath) {
141
+ console.error("No package-scripts.js/cjs/mjs file found in the current directory.");
142
+ process.exit(1);
143
+ }
144
+
145
+ const packageScript = require(packageScriptPath);
146
+ let scripts;
147
+ let envs;
148
+
149
+ if (packageScript.__esModule) {
150
+ scripts = packageScript.default.scripts;
151
+ } else {
152
+ scripts = packageScript.scripts;
153
+ }
154
+
155
+ // Package-script should provide default export with scripts object
156
+ if (!scripts || typeof scripts !== "object") {
157
+ console.error("No valid 'scripts' object found in package-scripts file.");
158
+ process.exit(1);
159
+ }
160
+
161
+ envs = JSON.parse(JSON.stringify(scripts.__ui5envs || {}));
162
+
163
+ Object.entries(envs).forEach(([key, value]) => {
164
+ envs[key] = String(value);
165
+ });
166
+
167
+ // Package-script should provide default export with scripts object
168
+ if (envs && typeof envs !== "object") {
169
+ console.error("No valid 'envs' object found in package-scripts file.");
170
+ process.exit(1);
171
+ }
172
+
173
+ return { scripts, envs };
174
+ }
175
+
176
+ /**
177
+ * Executes a command or command object (with parallel/sequential support)
178
+ * @param {string|Object} command - Command string or command object with commands array
179
+ * @returns {Promise} Promise that resolves when command(s) complete
180
+ */
181
+ async executeCommand(command, commandName = "unknown") {
182
+ if (typeof command === "string" && command) {
183
+ return new Promise(async (resolve, reject) => {
184
+ if (command.trim().startsWith("ui5nps-script")) {
185
+ const argv = parseArgsStringToArgv(command);
186
+ if (!path.isAbsolute(argv[1])) {
187
+ throw new Error(`Script path must be absolute: ${argv[1]}`);
188
+ }
189
+
190
+ const importPath = argv[1];
191
+ const importedContent = require(importPath);
192
+ let _ui5mainFn;
193
+
194
+ if (importedContent.__esModule) {
195
+ _ui5mainFn = importedContent.default._ui5mainFn;
196
+ } else {
197
+ _ui5mainFn = importedContent._ui5mainFn;
198
+ }
199
+
200
+ if (!_ui5mainFn) {
201
+ return reject(new Error(`No valid _ui5mainFn function exported from ${importPath} tried to be executed with ui5nps-script. Either provide a valid _ui5mainFn function or use another way to execute the script (via node).`));
202
+ }
203
+
204
+ verboseLog(` | Executing command ${commandName} as module.`);
205
+ const result = _ui5mainFn(argv);
206
+
207
+ if (result instanceof Promise) {
208
+ return result.then(resolve).catch(reject);
209
+ } else {
210
+ return resolve();
211
+ }
212
+ }
213
+
214
+ verboseLog(` | Executing command ${commandName} as command.\n Running: ${command}`);
215
+ const child = exec(command, { stdio: "inherit", env: { ...process.env, ...this.envs } });
216
+
217
+ child.stdout.on("data", (data) => {
218
+ verboseLog(data);
219
+ });
220
+
221
+ child.stderr.on("data", (data) => {
222
+ console.error(data);
223
+ });
224
+
225
+ child.on("error", (err) => {
226
+ console.error("Failed to start:", err);
227
+ reject(err);
228
+ });
229
+
230
+ child.on("close", (code) => {
231
+ code === 0 ? resolve() : reject(new Error(`Exit ${code}`));
232
+ });
233
+ });
234
+ } else if (typeof command === "object" && command.commands) {
235
+ if (command.parallel) {
236
+ // Execute commands in parallel
237
+ const promises = command.commands.filter(Boolean).map(cmd => this.executeCommand(cmd, cmd.commandName || commandName));
238
+ await Promise.all(promises);
239
+ } else {
240
+ // Execute commands sequentially
241
+ for (const cmd of command.commands) {
242
+ await this.executeCommand(cmd, cmd.commandName || commandName);
243
+ }
244
+ }
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Main execution method for a named command
250
+ * @param {string} commandName - Name of the command to execute
251
+ * @returns {Promise} Promise that resolves when execution completes
252
+ */
253
+ async execute(commandName) {
254
+ const command = this.resolvedScripts.get(commandName);
255
+
256
+ if (!command) {
257
+ throw new Error(`Command "${commandName}" not found in scripts`);
258
+ }
259
+
260
+ return this.executeCommand(this.resolvedScripts.get(commandName), commandName);
261
+ }
262
+ }
263
+
264
+ const parser = new Parser();
265
+
266
+ // Basic input validation
267
+ const commands = process.argv.slice(2).filter(arg => arg !== "--verbose" && arg !== "-v");
268
+ const verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
269
+
270
+ // Set verbose environment variable for child scripts
271
+ if (verbose) {
272
+ process.env.UI5_VERBOSE = "true";
273
+ }
274
+
275
+ if (commands.length === 0) {
276
+ console.error("Usage: ui5nps [--verbose|-v] <command> [command2] [command3] ...");
277
+ console.error("No commands provided.");
278
+ process.exit(1);
279
+ }
280
+
281
+ if (commands.includes("--help") || commands.includes("-h")) {
282
+ console.log("Usage: ui5nps [--verbose|-v] <command> [command2] [command3] ...");
283
+ console.log("\nOptions:");
284
+ console.log(" --verbose, -v Show detailed output (default: quiet, errors only)");
285
+ console.log("\nAvailable commands:");
286
+ for (const [key, value] of parser.parsedScripts.entries()) {
287
+ console.log(` - ${key}: ${value}`);
288
+ }
289
+ process.exit(0);
290
+ }
291
+
292
+ (async () => {
293
+ process.env = { ...process.env, ...parser.envs };
294
+
295
+ for (const commandName of commands) {
296
+ await parser.execute(commandName);
297
+ }
298
+ })().catch(error => {
299
+ console.error("Error executing commands:", error);
300
+ process.exit(1);
301
+ });
@@ -0,0 +1,195 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const tsMode = fs.existsSync(path.join(process.cwd(), "tsconfig.json"));
4
+
5
+ /**
6
+ * Returns eslint rules specific to typescript files
7
+ * @returns
8
+ */
9
+ const getTsModeOverrides = () => {
10
+ const tsConfiguration = {
11
+ files: ["*.ts"],
12
+ parser: "@typescript-eslint/parser",
13
+ plugins: ["@typescript-eslint"],
14
+ extends: [
15
+ "plugin:@typescript-eslint/recommended",
16
+ "plugin:@typescript-eslint/recommended-requiring-type-checking"
17
+ ],
18
+ parserOptions: {
19
+ "project": [
20
+ "./tsconfig.json"
21
+ ],
22
+ EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
23
+ },
24
+ rules: {
25
+ "no-shadow": "off",
26
+ "@typescript-eslint/consistent-type-imports": "error",
27
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
28
+ "@typescript-eslint/no-shadow": ["error"],
29
+ "@typescript-eslint/no-unsafe-member-access": "off",
30
+ "@typescript-eslint/no-floating-promises": "off",
31
+ "@typescript-eslint/no-explicit-any": "off",
32
+ "@typescript-eslint/no-unsafe-assignment": "off",
33
+ "@typescript-eslint/ban-ts-comment": "off",
34
+ "@typescript-eslint/no-unsafe-call": "off",
35
+ "@typescript-eslint/no-non-null-assertion": "off",
36
+ "@typescript-eslint/no-empty-function": "off",
37
+ "@typescript-eslint/no-empty-interface": "off",
38
+ "lines-between-class-members": "off",
39
+ }
40
+ };
41
+
42
+ const tsxConfiguration = JSON.parse(JSON.stringify(tsConfiguration));
43
+ tsxConfiguration.files = ["*.tsx"];
44
+ tsxConfiguration.plugins.push("jsx-no-leaked-values");
45
+ tsxConfiguration.rules = {
46
+ ...tsxConfiguration.rules,
47
+ "jsx-no-leaked-values/jsx-no-leaked-values": "error",
48
+ "@typescript-eslint/unbound-method": "off", // to be able to attach on* listeners
49
+ "@typescript-eslint/no-misused-promises": "off", // to be able to have async event listeners
50
+ "operator-linebreak": "off",
51
+ "no-nested-ternary": "off",
52
+ "implicit-arrow-linebreak": "off",
53
+ "function-paren-newline": "off",
54
+ "comma-dangle": "off"
55
+ };
56
+
57
+ return [
58
+ tsConfiguration,
59
+ tsxConfiguration
60
+ ];
61
+ }
62
+
63
+ module.exports = {
64
+ "env": {
65
+ "browser": true,
66
+ "es6": true
67
+ },
68
+ "root": true,
69
+ "extends": "airbnb-base",
70
+ "overrides": tsMode ? getTsModeOverrides() : [],
71
+ "parserOptions": {
72
+ "ecmaVersion": 2018,
73
+ "sourceType": "module"
74
+ },
75
+ "rules": {
76
+ "comma-dangle": [2, "always-multiline"], // difference from openui5
77
+ "no-cond-assign": 2,
78
+ "no-console": 2,
79
+ "no-constant-condition": 2,
80
+ "no-control-regex": 2,
81
+ "no-debugger": 2,
82
+ "no-dupe-args": 2,
83
+ "no-dupe-keys": 2,
84
+ "no-duplicate-case": 2,
85
+ "no-empty-character-class": 2,
86
+ "no-empty": 2,
87
+ "no-ex-assign": 2,
88
+ "no-extra-boolean-cast": 1,
89
+ "no-extra-parens": [2, "functions"],
90
+ "no-extra-semi": 2,
91
+ "no-func-assign": 2,
92
+ "no-inner-declarations": [2, "functions"],
93
+ "no-invalid-regexp": 2,
94
+ "no-irregular-whitespace": 2,
95
+ "no-negated-in-lhs": 2,
96
+ "no-obj-calls": 2,
97
+ "no-regex-spaces": 2,
98
+ "no-sparse-arrays": 2,
99
+ "no-trailing-spaces": 2,
100
+ "no-unreachable": 2,
101
+ "use-isnan": 2,
102
+ // "valid-jsdoc": [1, { removed for UI5 WebComponents
103
+ // "requireReturn": false
104
+ // }],
105
+ "valid-typeof": 2,
106
+
107
+ "accessor-pairs": 2,
108
+ "block-scoped-var": 1,
109
+ // "consistent-return": 1, // removed for UI5 WebComponents
110
+ "curly": [2, "all"],
111
+ // "default-case": 1, // removed for UI5 WebComponents
112
+ "import/extensions": ["error", "always"], // override for UI5 WebComponents
113
+ "import/order": "off",
114
+ "no-alert": 2,
115
+ "no-caller": 2,
116
+ "no-div-regex": 2,
117
+ "no-eval": 2,
118
+ "no-extend-native": 2,
119
+ "no-extra-bind": 2,
120
+ "no-fallthrough": 2,
121
+ "no-floating-decimal": 2,
122
+ "no-implied-eval": 2,
123
+ "no-iterator": 2,
124
+ "no-labels": 2,
125
+ "no-lone-blocks": 2,
126
+ "no-loop-func": 2,
127
+ "no-native-reassign": 2,
128
+ "no-new-func": 2,
129
+ "no-new-wrappers": 1,
130
+ "no-new": 1,
131
+ "no-octal-escape": 2,
132
+ "no-octal": 2,
133
+ "no-proto": 2,
134
+ "no-redeclare": 1,
135
+ "no-return-assign": 2,
136
+ "no-script-url": 2,
137
+ "no-self-compare": 2,
138
+ "no-sequences": 2,
139
+ "no-unused-expressions": [1, { allowShortCircuit: true }],
140
+ "no-void": 2,
141
+ "no-warning-comments": 1,
142
+ "no-with": 2,
143
+ "radix": [2, "as-needed"],
144
+ "wrap-iife": [2, "any"],
145
+ "yoda": 2,
146
+
147
+ "strict": [2, "function"],
148
+
149
+ "no-catch-shadow": 2,
150
+ "no-delete-var": 2,
151
+ "no-label-var": 2,
152
+ "no-shadow-restricted-names": 2,
153
+ "no-undef-init": 2,
154
+ "no-undef": 2,
155
+ "no-unused-vars": [2, { "vars": "all", "args": "none" }],
156
+
157
+ "brace-style": [2, "1tbs", { "allowSingleLine": true }],
158
+ "camelcase": [1, { "properties": "never" }], // added for UI5 WebComponents
159
+ "consistent-this": [1, "that"],
160
+ "linebreak-style": 2,
161
+ "max-nested-callbacks": [1, 3],
162
+ "new-cap": 1,
163
+ "new-parens": 2,
164
+ "no-array-constructor": 2,
165
+ "no-lonely-if": 1,
166
+ "no-mixed-spaces-and-tabs": [2, "smart-tabs"],
167
+ "no-nested-ternary": 2,
168
+ "no-new-object": 2,
169
+ "no-spaced-func": 2,
170
+ "quote-props": [2, "as-needed", { "keywords": true, "unnecessary": false }],
171
+ "semi-spacing": [1, { "before": false, "after": true }],
172
+ "semi": 2,
173
+ "keyword-spacing": 2,
174
+ "space-infix-ops": 2,
175
+ "space-unary-ops": [2, { "words": true, "nonwords": false }],
176
+ // airbnb overrides
177
+ "indent": [2, "tab"],
178
+ "no-underscore-dangle": 0,
179
+ "no-tabs": 0,
180
+ "quotes": [2, "double", { "allowTemplateLiterals": true }],
181
+ "no-useless-constructor": 0,
182
+ "no-param-reassign": 0,
183
+ "one-var": 0,
184
+ "max-len": 0,
185
+ "arrow-parens": [2, "as-needed"],
186
+ "class-methods-use-this": 0,
187
+ "no-plusplus": 0,
188
+ "default-case": 0,
189
+ "consistent-return": 0,
190
+ "prefer-destructuring": 0,
191
+ "arrow-body-style": 0,
192
+ "import/no-unresolved": 0,
193
+ "no-use-before-define": 0
194
+ }
195
+ };
@@ -0,0 +1,177 @@
1
+ const path = require("path");
2
+ const fs = require("fs");
3
+ const LIB = path.join(__dirname, `../lib/`);
4
+ let websiteBaseUrl = "/";
5
+
6
+ const isPreview = !!process.env.PR_NUMBER;
7
+ const getPreviewBaseUrl = () => {
8
+ if (process.env.DEPLOYMENT_TYPE === "netlify_preview") {
9
+ return "/";
10
+ }
11
+ return `/webcomponents/pr-${process.env.PR_NUMBER}/`;
12
+ }
13
+
14
+ if (process.env.DEPLOY) {
15
+ websiteBaseUrl = "/webcomponents/";
16
+ } else if (process.env.DEPLOY_NIGHTLY) {
17
+ websiteBaseUrl = "/webcomponents/nightly/";
18
+ } else if (isPreview) {
19
+ websiteBaseUrl = getPreviewBaseUrl();
20
+ }
21
+
22
+ const getScripts = (options) => {
23
+ // The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
24
+ const illustrationsData = options.illustrationsData || [];
25
+ const createIllustrationsJSImportsScript = {
26
+ default: `ui5nps-p ${illustrationsData.map(illustrations => `build.illustrations.build-${illustrations.set}-${illustrations.collection}`).join(" ")}` // concurently,
27
+ }
28
+ illustrationsData.forEach((illustration) => {
29
+ createIllustrationsJSImportsScript[`build-${illustration.set}-${illustration.collection}`] = `ui5nps-script "${LIB}create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath} ${illustration.collection}`
30
+ });
31
+ // The script creates the "src/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
32
+ const createIllustrationsLoadersScript = {
33
+ default: `ui5nps-p ${illustrationsData.map(illustrations => `build.jsImports.illustrationsLoaders.generate-${illustrations.set}-${illustrations.collection}`).join(" ")}` // concurently,
34
+ }
35
+ illustrationsData.forEach((illustrations) => {
36
+ createIllustrationsLoadersScript[`generate-${illustrations.set}-${illustrations.collection}`] = `ui5nps-script ${LIB}generate-js-imports/illustrations.js ${illustrations.path} ${illustrations.dynamicImports.outputFile} ${illustrations.set} ${illustrations.collection} ${illustrations.dynamicImports.location} ${illustrations.dynamicImports.filterOut.join(",")}`
37
+ });
38
+
39
+
40
+ const tsOption = !!(!options.legacy || options.jsx);
41
+ const tsCommandOld = tsOption ? "tsc" : "";
42
+ let tsWatchCommandStandalone = tsOption ? "tsc --watch" : "";
43
+ // this command is only used for standalone projects. monorepo projects get their watch from vite, so opt-out here
44
+ if (options.noWatchTS) {
45
+ tsWatchCommandStandalone = "";
46
+ }
47
+
48
+ if (tsOption) {
49
+ try {
50
+ require("typescript");
51
+ } catch (e) {
52
+ console.error(`TypeScript is not found. Try to install it by running \`npm install --save-dev typescript\` if you are using npm or by running \`yarn add --dev typescript\` if you are using yarn.`);
53
+ process.exit(e.code);
54
+ }
55
+ }
56
+
57
+ let viteConfig;
58
+ if (fs.existsSync("config/vite.config.js")) {
59
+ // old project setup where config file is in separate folder
60
+ viteConfig = "-c config/vite.config.js";
61
+ } else if (fs.existsSync("vite.config.js")) {
62
+ // preferred way of custom configuration in root project folder
63
+ viteConfig = "";
64
+ } else {
65
+ // no custom configuration - use default from tools project
66
+ viteConfig = `-c "${require.resolve("@ui5/webcomponents-tools/components-package/vite.config.js")}"`;
67
+ }
68
+
69
+ const scripts = {
70
+ __ui5envs: {
71
+ UI5_CEM_MODE: options.dev,
72
+ UI5_TS: `${tsOption}`,
73
+ CSS_VARIABLES_TARGET: options.cssVariablesTarget ?? "root",
74
+ CYPRESS_COVERAGE: !!(options.internal?.cypress_code_coverage),
75
+ },
76
+ clean: {
77
+ "default": "ui5nps clean.generated clean.dist scope.testPages.clean",
78
+ "generated": `ui5nps-script "${LIB}/rimraf/rimraf.js src/generated`,
79
+ "dist": `ui5nps-script "${LIB}/rimraf/rimraf.js dist`,
80
+ },
81
+ lint: `ui5nps-script "${LIB}eslint/eslint.js"`,
82
+ lintfix: `ui5nps-script "${LIB}eslint/eslint.js" --fix`,
83
+ generate: {
84
+ default: `ui5nps prepare.all`,
85
+ all: `ui5nps-p build.templates build.i18n prepare.styleRelated copyProps build.illustrations`, // concurently
86
+ styleRelated: "ui5nps build.styles build.jsonImports build.jsImports",
87
+ },
88
+ prepare: {
89
+ default: `ui5nps clean prepare.all copy copyProps prepare.typescript generateAPI`,
90
+ all: `ui5nps-p build.templates build.i18n prepare.styleRelated build.illustrations`, // concurently
91
+ styleRelated: "ui5nps build.styles build.jsonImports build.jsImports",
92
+ typescript: tsCommandOld,
93
+ },
94
+ build: {
95
+ default: "ui5nps prepare lint build.bundle", // build.bundle2
96
+ templates: options.legacy ? `node "${LIB}hbs2ui5/index.js" -d src/ -o src/generated/templates` : "",
97
+ styles: {
98
+ default: `ui5nps-p build.styles.themes build.styles.components`, // concurently
99
+ themes: `ui5nps-script "${LIB}css-processors/css-processor-themes.mjs"`,
100
+ themesWithWatch: `ui5nps-script "${LIB}css-processors/css-processor-themes.mjs" -w`,
101
+ components: `ui5nps-script "${LIB}css-processors/css-processor-components.mjs"`,
102
+ componentsWithWatch: `ui5nps-script "${LIB}css-processors/css-processor-components.mjs" -w`,
103
+ },
104
+ i18n: {
105
+ default: "ui5nps build.i18n.defaultsjs build.i18n.json",
106
+ defaultsjs: `ui5nps-script "${LIB}i18n/defaults.js" src/i18n src/generated/i18n`,
107
+ json: `ui5nps-script "${LIB}i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
108
+ },
109
+ jsonImports: {
110
+ default: "ui5nps build.jsonImports.themes build.jsonImports.i18n",
111
+ themes: `ui5nps-script "${LIB}generate-json-imports/themes.js" src/themes src/generated/json-imports`,
112
+ i18n: `ui5nps-script "${LIB}generate-json-imports/i18n.js" src/i18n src/generated/json-imports`,
113
+ },
114
+ jsImports: {
115
+ default: "ui5nps build.jsImports.illustrationsLoaders",
116
+ illustrationsLoaders: createIllustrationsLoadersScript,
117
+ },
118
+ bundle: `ui5nps-script "${LIB}vite-bundler/vite-bundler.mjs" ${viteConfig} --mode testing --base ${websiteBaseUrl}`,
119
+ bundle2: ``,
120
+ illustrations: createIllustrationsJSImportsScript,
121
+ },
122
+ copyProps: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
123
+ copyPropsWithWatch: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/ --watch --safe --skip-initial-copy`,
124
+ copySrcWithWatch: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/ --watch --safe --skip-initial-copy`,
125
+ copy: {
126
+ default: options.legacy ? "ui5nps copy.src copy.props" : "",
127
+ src: options.legacy ? `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/` : "",
128
+ props: options.legacy ? `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/` : "",
129
+ },
130
+ watch: {
131
+ default: `ui5nps-p watch.templates watch.typescript watch.src watch.styles watch.i18n watch.props`, // concurently
132
+ devServer: 'ui5nps-p watch.default watch.bundle', // concurently
133
+ src: options.legacy ? 'ui5nps copySrcWithWatch' : "",
134
+ typescript: tsWatchCommandStandalone,
135
+ props: 'ui5nps copyPropsWithWatch',
136
+ bundle: `ui5nps-script ${LIB}dev-server/dev-server.mjs ${viteConfig}`,
137
+ styles: {
138
+ default: 'ui5nps-p watch.styles.themes watch.styles.components', // concurently
139
+ themes: 'ui5nps build.styles.themesWithWatch',
140
+ components: `ui5nps build.styles.componentsWithWatch`,
141
+ },
142
+ templates: options.legacy ? `ui5nps-script "${LIB}chokidar/chokidar.js" "src/**/*.hbs" "ui5nps build.templates"` : "",
143
+ i18n: `ui5nps-script "${LIB}chokidar/chokidar.js" "src/i18n/messagebundle.properties" "ui5nps build.i18n.defaultsjs"`
144
+ },
145
+ start: "ui5nps prepare watch.devServer",
146
+ test: `ui5nps-script "${LIB}/test-runner/test-runner.js"`,
147
+ "test-cy-ci": `cypress run --component --browser chrome`,
148
+ "test-cy-ci-suite-1": `cypress run --component --browser chrome --spec "**/specs/[A-C]*.cy.{js,jsx,ts,tsx},**/specs/[^D-Z]*.cy.{js,jsx,ts,tsx}"`,
149
+ "test-cy-ci-suite-2": `cypress run --component --browser chrome --spec "**/specs/[D-L]*.cy.{js,jsx,ts,tsx}"`,
150
+ "test-cy-ci-suite-3": `cypress run --component --browser chrome --spec "**/specs/[M-S]*.cy.{js,jsx,ts,tsx}"`,
151
+ "test-cy-ci-suite-4": `cypress run --component --browser chrome --spec "**/specs/[T-Z]*.cy.{js,jsx,ts,tsx}"`,
152
+ "test-cy-open": `cypress open --component --browser chrome`,
153
+ startWithScope: "ui5nps scope.prepare scope.watchWithBundle",
154
+ scope: {
155
+ prepare: "ui5nps scope.lint scope.testPages",
156
+ lint: `ui5nps-script "${LIB}scoping/lint-src.js"`,
157
+ testPages: {
158
+ default: "ui5nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
159
+ "clean": `ui5nps-script "${LIB}/rimraf/rimraf.js test/pages/scoped`,
160
+ copy: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
161
+ replace: `ui5nps-script "${LIB}scoping/scope-test-pages.js" test/pages/scoped demo`,
162
+ },
163
+ watchWithBundle: 'ui5nps-p scope.watch scope.bundle', // concurently
164
+ watch: 'ui5nps-p watch.templates watch.props watch.styles', // concurently
165
+ bundle: `ui5nps-script ${LIB}dev-server/dev-server.mjs ${viteConfig}`,
166
+ },
167
+ generateAPI: {
168
+ default: tsOption ? "ui5nps generateAPI.generateCEM generateAPI.validateCEM" : "",
169
+ generateCEM: `ui5nps-script "${LIB}cem/cem.js" analyze --config "${LIB}cem/custom-elements-manifest.config.mjs"`,
170
+ validateCEM: `ui5nps-script "${LIB}cem/validate.js"`,
171
+ },
172
+ };
173
+
174
+ return scripts;
175
+ };
176
+
177
+ module.exports = getScripts;
@@ -0,0 +1 @@
1
+ module.exports = {}
@@ -0,0 +1 @@
1
+ module.exports = {};
@@ -0,0 +1,9 @@
1
+ // vite.config.js
2
+ const virtualIndex = require('../lib/dev-server/virtual-index-html-plugin.js');
3
+
4
+ module.exports = {
5
+ build: {
6
+ emptyOutDir: false,
7
+ },
8
+ plugins: [virtualIndex()],
9
+ };