@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
@@ -4,74 +4,89 @@ import * as fs from "fs";
4
4
  import * as path from "path";
5
5
  import { writeFile, mkdir } from "fs/promises";
6
6
  import chokidar from "chokidar";
7
- import scopeVariables from "./scope-variables.mjs";
7
+ import {scopeUi5Variables} from "./scope-variables.mjs";
8
8
  import { writeFileIfChanged, getFileContent } from "./shared.mjs";
9
+ import { pathToFileURL } from "url";
9
10
 
10
- const tsMode = process.env.UI5_TS === "true";
11
- const extension = tsMode ? ".css.ts" : ".css.js";
11
+ const generate = async (argv) => {
12
+ const tsMode = process.env.UI5_TS === "true";
13
+ const extension = tsMode ? ".css.ts" : ".css.js";
12
14
 
13
- const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
14
- const inputFilesGlob = "src/themes/*.css";
15
- const restArgs = process.argv.slice(2);
15
+ const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
16
+ const inputFilesGlob = "src/themes/*.css";
17
+ const restArgs = argv.slice(2);
16
18
 
17
- let customPlugin = {
18
- name: 'ui5-tools',
19
- setup(build) {
20
- build.initialOptions.write = false;
19
+ let customPlugin = {
20
+ name: 'ui5-tools',
21
+ setup(build) {
22
+ build.initialOptions.write = false;
21
23
 
22
- build.onEnd(result => {
23
- result.outputFiles.forEach(async f => {
24
- // scoping
25
- const newText = scopeVariables(f.text, packageJSON);
26
- await mkdir(path.dirname(f.path), {recursive: true});
27
- writeFile(f.path, newText);
24
+ build.onEnd(result => {
25
+ result.outputFiles.forEach(async f => {
26
+ // scoping
27
+ let newText = scopeUi5Variables(f.text, packageJSON);
28
+ newText = newText.replaceAll(/\\/g, "\\\\"); // Escape backslashes as they might appear in css rules
29
+ await mkdir(path.dirname(f.path), { recursive: true });
30
+ writeFile(f.path, newText);
28
31
 
29
- // JS/TS
30
- const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
31
- const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`", true);
32
- writeFileIfChanged(jsPath, jsContent);
33
- });
34
- })
35
- },
36
- }
32
+ // JS/TS
33
+ const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
34
+ const jsContent = getFileContent(packageJSON.name, "\`" + newText + "\`", true);
35
+ writeFileIfChanged(jsPath, jsContent);
36
+ });
37
+ })
38
+ },
39
+ }
40
+
41
+ const getConfig = async () => {
42
+ const config = {
43
+ entryPoints: await globby(inputFilesGlob),
44
+ bundle: true,
45
+ minify: true,
46
+ outdir: 'dist/css',
47
+ outbase: 'src',
48
+ plugins: [
49
+ customPlugin,
50
+ ]
51
+ };
52
+ return config;
53
+ }
37
54
 
38
- const getConfig = async () => {
39
- const config = {
40
- entryPoints: await globby(inputFilesGlob),
41
- bundle: true,
42
- minify: true,
43
- outdir: 'dist/css',
44
- outbase: 'src',
45
- plugins: [
46
- customPlugin,
47
- ]
48
- };
49
- return config;
55
+ if (restArgs.includes("-w")) {
56
+ let ready;
57
+ let config = await getConfig();
58
+ let ctx = await esbuild.context(config);
59
+ await ctx.watch()
60
+ console.log('watching...')
61
+
62
+ // when new component css files are added, they do not trigger a build as no one directly imports them
63
+ // restart the watch mode with the new entry points if a css file is added.
64
+ const watcher = chokidar.watch(inputFilesGlob);
65
+ watcher.on("ready", () => {
66
+ ready = true; // Initial scan is over -> waiting for new files
67
+ });
68
+ watcher.on("add", async path => {
69
+ if (ready) {
70
+ // new file
71
+ ctx.dispose();
72
+ config = await getConfig();
73
+ ctx = await esbuild.context(config);
74
+ ctx.watch();
75
+ }
76
+ });
77
+ } else {
78
+ const config = await getConfig();
79
+ const result = await esbuild.build(config);
80
+ }
50
81
  }
51
82
 
52
- if (restArgs.includes("-w")) {
53
- let ready;
54
- let config = await getConfig();
55
- let ctx = await esbuild.context(config);
56
- await ctx.watch()
57
- console.log('watching...')
83
+ const filePath = process.argv[1];
84
+ const fileUrl = pathToFileURL(filePath).href;
58
85
 
59
- // when new component css files are added, they do not trigger a build as no one directly imports them
60
- // restart the watch mode with the new entry points if a css file is added.
61
- const watcher = chokidar.watch(inputFilesGlob);
62
- watcher.on("ready", () => {
63
- ready = true; // Initial scan is over -> waiting for new files
64
- });
65
- watcher.on("add", async path => {
66
- if (ready) {
67
- // new file
68
- ctx.dispose();
69
- config = await getConfig();
70
- ctx = await esbuild.context(config);
71
- ctx.watch();
72
- }
73
- });
74
- } else {
75
- const config = await getConfig();
76
- const result = await esbuild.build(config);
86
+ if (import.meta.url === fileUrl) {
87
+ generate(process.argv)
77
88
  }
89
+
90
+ export default {
91
+ _ui5mainFn: generate
92
+ }
@@ -5,75 +5,114 @@ import * as path from "path";
5
5
  import { writeFile, mkdir } from "fs/promises";
6
6
  import postcss from "postcss";
7
7
  import combineDuplicatedSelectors from "../postcss-combine-duplicated-selectors/index.js"
8
- import { writeFileIfChanged, stripThemingBaseContent, getFileContent } from "./shared.mjs";
9
- import scopeVariables from "./scope-variables.mjs";
8
+ import { writeFileIfChanged, getFileContent } from "./shared.mjs";
9
+ import { scopeUi5Variables, scopeThemingVariables } from "./scope-variables.mjs";
10
+ import { pathToFileURL } from "url";
10
11
 
11
- const tsMode = process.env.UI5_TS === "true";
12
- const extension = tsMode ? ".css.ts" : ".css.js";
12
+ async function processThemingPackageFile(f) {
13
+ const selector = ':root';
14
+ const newRule = postcss.rule({ selector });
15
+ const result = await postcss().process(f.text);
13
16
 
14
- const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
17
+ result.root.walkRules(selector, rule => {
18
+ for (const decl of rule.nodes) {
19
+ if (decl.type !== 'decl' ) {
20
+ continue;
21
+ } else if (decl.prop.startsWith('--sapFontUrl')) {
22
+ continue;
23
+ } else if (!decl.prop.startsWith('--sap')) {
24
+ newRule.append(decl.clone());
25
+ } else {
26
+ const originalProp = decl.prop;
27
+ const originalValue = decl.value;
15
28
 
16
- let inputFiles = await globby("src/**/parameters-bundle.css");
17
- const restArgs = process.argv.slice(2);
29
+ newRule.append(decl.clone({ prop: originalProp.replace("--sap", "--ui5-sap"), value: `var(${originalProp}, ${originalValue})` }));
30
+ }
31
+ }
32
+ });
18
33
 
19
- const removeDuplicateSelectors = async (text) => {
20
- const result = await postcss(combineDuplicatedSelectors).process(text);
21
- return result.css;
34
+ return newRule.toString();
35
+ };
36
+
37
+ async function processComponentPackageFile(f, packageJSON) {
38
+ let result = await postcss(combineDuplicatedSelectors).process(f.text);
39
+
40
+ result = scopeUi5Variables(result.css, packageJSON, f.path);
41
+
42
+ result = scopeThemingVariables(result);
43
+
44
+ return result;
22
45
  }
23
46
 
24
- let scopingPlugin = {
25
- name: 'scoping',
26
- setup(build) {
27
- build.initialOptions.write = false;
28
-
29
- build.onEnd(result => {
30
- result.outputFiles.forEach(async f => {
31
- // remove duplicate selectors
32
- let newText = await removeDuplicateSelectors(f.text);
33
-
34
- // strip unnecessary theming-base-content
35
- newText = stripThemingBaseContent(newText);
36
-
37
- // scoping
38
- newText = scopeVariables(newText, packageJSON, f.path);
39
- await mkdir(path.dirname(f.path), {recursive: true});
40
- writeFile(f.path, newText);
41
-
42
- // JSON
43
- const jsonPath = f.path.replace(/dist[\/\\]css/, "dist/generated/assets").replace(".css", ".css.json");
44
- await mkdir(path.dirname(jsonPath), {recursive: true});
45
- const data = {
46
- packageName: packageJSON.name,
47
- fileName: jsonPath.substr(jsonPath.lastIndexOf("themes")),
48
- content: newText,
49
- };
50
- writeFileIfChanged(jsonPath, JSON.stringify({_: data}));
51
-
52
- // JS/TS
53
- const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
54
- const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`");
55
- writeFileIfChanged(jsPath, jsContent);
56
- });
57
- })
58
- },
47
+ async function generate(argv) {
48
+ const tsMode = process.env.UI5_TS === "true";
49
+ const extension = tsMode ? ".css.ts" : ".css.js";
50
+
51
+ const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
52
+
53
+ const inputFiles = await globby([
54
+ "src/**/parameters-bundle.css",
55
+ ]);
56
+ const restArgs = argv.slice(2);
57
+
58
+ let scopingPlugin = {
59
+ name: 'scoping',
60
+ setup(build) {
61
+ build.initialOptions.write = false;
62
+
63
+ build.onEnd(result => {
64
+ result.outputFiles.forEach(async f => {
65
+ let newText = f.path.includes("packages/theming") ? await processThemingPackageFile(f) : await processComponentPackageFile(f, packageJSON);
66
+
67
+ await mkdir(path.dirname(f.path), { recursive: true });
68
+ writeFile(f.path, newText);
69
+
70
+ // JSON
71
+ const jsonPath = f.path.replace(/dist[\/\\]css/, "dist/generated/assets").replace(".css", ".css.json");
72
+ await mkdir(path.dirname(jsonPath), { recursive: true });
73
+ writeFileIfChanged(jsonPath, JSON.stringify(newText));
74
+
75
+ // JS/TS
76
+ const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
77
+ const jsContent = getFileContent(packageJSON.name, "\`" + newText + "\`");
78
+ writeFileIfChanged(jsPath, jsContent);
79
+ });
80
+ })
81
+ },
82
+ }
83
+
84
+ const config = {
85
+ entryPoints: inputFiles,
86
+ bundle: true,
87
+ minify: true,
88
+ outdir: 'dist/css',
89
+ outbase: 'src',
90
+ plugins: [
91
+ scopingPlugin,
92
+ ],
93
+ external: ["*.ttf", "*.woff", "*.woff2"],
94
+ };
95
+
96
+ if (restArgs.includes("-w")) {
97
+ let ctx = await esbuild.context(config);
98
+ console.log('watching...')
99
+ await ctx.watch()
100
+ } else {
101
+ await esbuild.build(config);
102
+ }
59
103
  }
60
104
 
61
- const config = {
62
- entryPoints: inputFiles,
63
- bundle: true,
64
- minify: true,
65
- outdir: 'dist/css',
66
- outbase: 'src',
67
- plugins: [
68
- scopingPlugin,
69
- ],
70
- external: ["*.ttf", "*.woff", "*.woff2"],
71
- };
105
+ const filePath = process.argv[1];
106
+ const fileUrl = pathToFileURL(filePath).href;
107
+
108
+ if (import.meta.url === fileUrl) {
109
+ generate(process.argv)
110
+ }
111
+
112
+ export default {
113
+ _ui5mainFn: generate
114
+ }
72
115
 
73
- if (restArgs.includes("-w")) {
74
- let ctx = await esbuild.context(config);
75
- await ctx.watch()
76
- console.log('watching...')
77
- } else {
78
- const result = await esbuild.build(config);
116
+ export {
117
+ processComponentPackageFile
79
118
  }
@@ -9,9 +9,9 @@ const require = createRequire(import.meta.url);
9
9
  * @returns
10
10
  */
11
11
  const getOverrideVersion = filePath => {
12
- if (!filePath) {
13
- return;
14
- }
12
+ if (!filePath) {
13
+ return;
14
+ }
15
15
 
16
16
  if (!filePath.includes(`overrides${path.sep}`)) {
17
17
  return; // The "overrides/" directory is the marker
@@ -36,14 +36,22 @@ const getOverrideVersion = filePath => {
36
36
  return overrideVersion;
37
37
  }
38
38
 
39
- const scopeVariables = (cssText, packageJSON, inputFile) => {
40
- const escapeVersion = version => "v" + version?.replaceAll(/[^0-9A-Za-z\-_]/g, "-");
41
- const versionStr = escapeVersion(getOverrideVersion(inputFile) || packageJSON.version);
39
+ const scopeUi5Variables = (cssText, packageJSON, inputFile) => {
40
+ const escapeVersion = version => "v" + version?.replaceAll(/[^0-9A-Za-z\-_]/g, "-");
41
+ const versionStr = escapeVersion(getOverrideVersion(inputFile) || packageJSON.version);
42
+ const expr = /(--_?ui5)([^\,\:\)\s]+)/g;
43
+ let newText = cssText.replaceAll(expr, `$1-${versionStr}$2`);
42
44
 
43
- const expr = /(--_?ui5)([^\,\:\)\s]+)/g;
45
+ return newText.replaceAll("--sap", `--ui5-sap`);
46
+ }
44
47
 
45
- return cssText.replaceAll(expr, `$1-${versionStr}$2`);
48
+ // Used with CSS text and SVG file content (illustrations)
49
+ const scopeThemingVariables = (cssText) => {
50
+ return cssText.replaceAll("--sap", `--ui5-sap`);
46
51
  }
47
52
 
48
- export default scopeVariables;
53
+ export {
54
+ scopeUi5Variables,
55
+ scopeThemingVariables,
56
+ };
49
57
 
@@ -24,16 +24,6 @@ const writeFileIfChanged = async (fileName, content) => {
24
24
  }
25
25
  }
26
26
 
27
- // strips the unnecessary theming data coming from @sap-theming/theming-base-content and leaves only the css parameters
28
- const stripThemingBaseContent = css => {
29
- css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
30
- css = css.replace(/\.background-image.*{.*}/, "");
31
- css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
32
- css = css.replace(/--sapFontUrl.*\);?/, "");
33
- return css;
34
- }
35
-
36
-
37
27
  const DEFAULT_THEME = assets.themes.default;
38
28
 
39
29
  const getDefaultThemeCode = packageName => {
@@ -42,35 +32,15 @@ const getDefaultThemeCode = packageName => {
42
32
  import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
43
33
  import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
44
34
 
45
- registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", async () => defaultThemeBase);
46
- registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", async () => defaultTheme);
35
+ registerThemePropertiesLoader("@" + "ui5" + "/" + "webcomponents-theming", "${DEFAULT_THEME}", async () => defaultThemeBase);
36
+ registerThemePropertiesLoader(${ packageName.split("").map(c => `"${c}"`).join (" + ") }, "${DEFAULT_THEME}", async () => defaultTheme);
47
37
  `;
48
38
  };
49
39
 
50
- const getFileContent = (tsMode, targetFile, packageName, css, includeDefaultTheme) => {
51
- if (tsMode) {
52
- return getTSContent(targetFile, packageName, css, includeDefaultTheme);
53
- }
54
-
55
- return getJSContent(targetFile, packageName, css, includeDefaultTheme);
56
- }
57
-
58
- const getTSContent = (targetFile, packageName, css, includeDefaultTheme) => {
59
- const typeImport = "import type { StyleData } from \"@ui5/webcomponents-base/dist/types.js\";"
40
+ const getFileContent = (packageName, css, includeDefaultTheme) => {
60
41
  const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
61
-
62
- // tabs are intentionally mixed to have proper identation in the produced file
63
- return `${typeImport}
64
- ${defaultTheme}
65
- const styleData: StyleData = {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}};
66
- export default styleData;
67
- `;
42
+ return `${defaultTheme}export default ${css.trim()}`
68
43
  }
69
44
 
70
- const getJSContent = (targetFile, packageName, css, includeDefaultTheme) => {
71
- const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
72
-
73
- return `${defaultTheme}export default {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
74
- }
75
45
 
76
- export { writeFileIfChanged, stripThemingBaseContent, getFileContent}
46
+ export { writeFileIfChanged, getFileContent}
@@ -1,15 +1,12 @@
1
1
  import fs from "fs/promises";
2
2
  import { createServer } from 'vite';
3
- import yargs from 'yargs/yargs';
4
- import { hideBin } from 'yargs/helpers';
3
+ import yargs from 'yargs';
4
+ import { hideBin } from 'yargs/helpers';
5
+ import { pathToFileURL } from "url";
5
6
 
6
- const argv = yargs(hideBin(process.argv))
7
- .alias("c", "config")
8
- .argv;
9
-
10
- const startVite = async (port) => {
7
+ const startVite = async (config, port) => {
11
8
  const server = await createServer({
12
- configFile: argv.config,
9
+ configFile: config,
13
10
  server: {
14
11
  port: port,
15
12
  strictPort: true,
@@ -28,7 +25,7 @@ const rmPortFile = async () => {
28
25
  // exit handler must be sync
29
26
  try {
30
27
  await fs.rm(".dev-server-port");
31
- } catch (e) {}
28
+ } catch (e) { }
32
29
  process.exit();
33
30
  }
34
31
 
@@ -36,7 +33,11 @@ const rmPortFile = async () => {
36
33
  process.on(eventType, rmPortFile);
37
34
  });
38
35
 
39
- (async () => {
36
+ async function start(outArgv) {
37
+ const argv = yargs(hideBin(outArgv))
38
+ .alias("c", "config")
39
+ .argv;
40
+
40
41
  let retries = 10;
41
42
  let port = 8080;
42
43
  while (retries--) {
@@ -44,7 +45,7 @@ const rmPortFile = async () => {
44
45
  await fs.writeFile(".dev-server-port", `${port}`);
45
46
  try {
46
47
  // execSync(command, {stdio: 'pipe'});
47
- const server = await startVite(port);
48
+ const server = await startVite(argv.config ?? "", port);
48
49
  if (server) {
49
50
  // server started, don't try other ports
50
51
  break;
@@ -63,4 +64,15 @@ const rmPortFile = async () => {
63
64
  // no error normal exit
64
65
  // process.exit();
65
66
  }
66
- })();
67
+ };
68
+
69
+ const filePath = process.argv[1];
70
+ const fileUrl = pathToFileURL(filePath).href;
71
+
72
+ if (import.meta.url === fileUrl) {
73
+ start(process.argv)
74
+ }
75
+
76
+ export default {
77
+ _ui5mainFn: start
78
+ }
@@ -1,23 +1,17 @@
1
- const virtualIndexPlugin = async () => {
2
- const path = await import("path");
3
- const { globby } = await import("globby");
4
- const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
5
-
6
- const pagesPerFolder = {};
7
- files.forEach(file => {
8
- let folder = pagesPerFolder[path.dirname(file)] = pagesPerFolder[path.dirname(file)] || [];
9
- folder.push(path.basename(file));
10
- });
1
+ const virtualIndexPlugin = () => {
2
+ return {
3
+ name: 'virtual-index-html',
4
+ async config() {
5
+ const path = (await import("path")).default;
6
+ const globby = (await import("globby")).globby;
7
+ const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
11
8
 
12
- const rollupInput = {};
9
+ const rollupInput = {};
13
10
 
14
- files.forEach(file => {
15
- rollupInput[file] = path.resolve(process.cwd(), file);
16
- })
11
+ files.forEach(file => {
12
+ rollupInput[file] = path.resolve(process.cwd(), file);
13
+ });
17
14
 
18
- return {
19
- name: 'virtual-index-html',
20
- config() {
21
15
  return {
22
16
  build: {
23
17
  rollupOptions: {
@@ -26,7 +20,17 @@ const virtualIndexPlugin = async () => {
26
20
  }
27
21
  }
28
22
  },
29
- configureServer(server) {
23
+ async configureServer(server) {
24
+ const path = (await import("path")).default;
25
+ const globby = (await import("globby")).globby;
26
+ const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
27
+
28
+ const pagesPerFolder = {};
29
+ files.forEach(file => {
30
+ let folder = pagesPerFolder[path.dirname(file)] = pagesPerFolder[path.dirname(file)] || [];
31
+ folder.push(path.basename(file));
32
+ });
33
+
30
34
  server.middlewares.use((req, res, next) => {
31
35
  if (req.url === "/") {
32
36
  const folders = Object.keys(pagesPerFolder);
@@ -37,8 +41,8 @@ const virtualIndexPlugin = async () => {
37
41
  const pages = pagesPerFolder[folder];
38
42
  return `<h1>${folder}</h1>
39
43
  ${pages.map(page => {
40
- return `<li><a href='${folder}/${page}'>${page}</a></li>`
41
- }).join("")}
44
+ return `<li><a href='${folder}/${page}'>${page}</a></li>`
45
+ }).join("")}
42
46
  `
43
47
  }).join("")}`);
44
48
  } else {
@@ -0,0 +1,44 @@
1
+ const fs = require("fs");
2
+ const { ESLint: ESLint7 } = require("eslint"); // isolated v7
3
+ const path = require("path");
4
+
5
+ const main = async argv => {
6
+ let eslintConfig;
7
+ if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
8
+ // preferred way of custom configuration in root project folder
9
+ eslintConfig = null;
10
+ } else {
11
+ // no custom configuration - use default from tools project
12
+ eslintConfig = require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")
13
+ };
14
+
15
+ const packageDir = path.dirname(require.resolve("@ui5/webcomponents-tools/package.json"));
16
+ const eslint = new ESLint7({
17
+ overrideConfigFile: eslintConfig,
18
+ fix: argv.includes("--fix"),
19
+ resolvePluginsRelativeTo: packageDir,
20
+ });
21
+ console.log("Running ESLint v7...");
22
+
23
+ // Lint files
24
+ const results = await eslint.lintFiles(["."]);
25
+
26
+ // Format results
27
+ const formatter = await eslint.loadFormatter("stylish");
28
+ const resultText = formatter.format(results);
29
+
30
+ // Output results
31
+ console.log(resultText);
32
+
33
+ // Exit with error code if there are errors
34
+ const hasErrors = results.some(result => result.errorCount > 0);
35
+ if (hasErrors) {
36
+ process.exit(1);
37
+ }
38
+ }
39
+
40
+ if (require.main === module) {
41
+ main(process.argv)
42
+ }
43
+
44
+ exports._ui5mainFn = main;