@ui5/webcomponents-tools 0.0.0-e818f286e → 0.0.0-ebd9a4db3

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 (61) hide show
  1. package/CHANGELOG.md +1743 -0
  2. package/README.md +3 -5
  3. package/assets-meta.js +12 -11
  4. package/components-package/eslint.js +66 -2
  5. package/components-package/nps.js +101 -41
  6. package/components-package/postcss.components.js +1 -21
  7. package/components-package/postcss.themes.js +1 -26
  8. package/components-package/vite.config.js +7 -10
  9. package/components-package/wdio.js +42 -13
  10. package/icons-collection/nps.js +13 -8
  11. package/lib/amd-to-es6/index.js +102 -0
  12. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  13. package/lib/cem/custom-elements-manifest.config.mjs +530 -0
  14. package/lib/cem/event.mjs +168 -0
  15. package/lib/cem/schema-internal.json +1422 -0
  16. package/lib/cem/schema.json +1098 -0
  17. package/lib/cem/types-internal.d.ts +808 -0
  18. package/lib/cem/types.d.ts +736 -0
  19. package/lib/cem/utils.mjs +423 -0
  20. package/lib/cem/validate.js +67 -0
  21. package/lib/copy-list/index.js +2 -2
  22. package/lib/create-icons/index.js +60 -15
  23. package/lib/create-illustrations/index.js +51 -30
  24. package/lib/create-new-component/Component.js +74 -0
  25. package/lib/create-new-component/ComponentTemplate.js +12 -0
  26. package/lib/create-new-component/index.js +60 -101
  27. package/lib/css-processors/css-processor-components.mjs +78 -0
  28. package/lib/css-processors/css-processor-themes.mjs +74 -0
  29. package/lib/css-processors/scope-variables.mjs +49 -0
  30. package/lib/css-processors/shared.mjs +56 -0
  31. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  32. package/lib/dev-server/{dev-server.js → dev-server.mjs} +4 -4
  33. package/lib/dev-server/virtual-index-html-plugin.js +25 -21
  34. package/lib/generate-js-imports/illustrations.js +86 -0
  35. package/lib/generate-json-imports/i18n.js +45 -61
  36. package/lib/generate-json-imports/themes.js +16 -33
  37. package/lib/hbs2lit/src/compiler.js +16 -5
  38. package/lib/hbs2lit/src/litVisitor2.js +85 -22
  39. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  40. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +39 -6
  41. package/lib/hbs2ui5/index.js +23 -6
  42. package/lib/i18n/defaults.js +19 -2
  43. package/lib/i18n/toJSON.js +1 -1
  44. package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
  45. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  46. package/lib/scoping/get-all-tags.js +11 -11
  47. package/lib/scoping/lint-src.js +8 -7
  48. package/lib/scoping/scope-test-pages.js +2 -1
  49. package/lib/test-runner/test-runner.js +10 -2
  50. package/package.json +23 -11
  51. package/tsconfig.json +18 -0
  52. package/components-package/wdio.sync.js +0 -360
  53. package/lib/esm-abs-to-rel/index.js +0 -58
  54. package/lib/jsdoc/config.json +0 -29
  55. package/lib/jsdoc/plugin.js +0 -2436
  56. package/lib/jsdoc/template/publish.js +0 -4112
  57. package/lib/postcss-css-to-esm/index.js +0 -57
  58. package/lib/postcss-css-to-json/index.js +0 -47
  59. package/lib/postcss-new-files/index.js +0 -36
  60. package/lib/postcss-p/postcss-p.mjs +0 -14
  61. package/lib/replace-global-core/index.js +0 -25
package/README.md CHANGED
@@ -1,6 +1,4 @@
1
- ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_wide.png)
2
-
3
- # UI5 Web Components - Tools
1
+ # ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_water.png)UI5 Web Components - Tools
4
2
 
5
3
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
6
4
 
@@ -10,10 +8,10 @@ used by other UI5 Web Components packages, such as `main` and `fiori`.
10
8
  ## Resources
11
9
  - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
12
10
  - [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
13
- - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
11
+ - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/play/)
14
12
 
15
13
  ## Support
16
- We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
14
+ We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com/).
17
15
 
18
16
  ## Contribute
19
17
  Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
package/assets-meta.js CHANGED
@@ -1,20 +1,16 @@
1
1
  const assetsMeta = {
2
2
  "themes": {
3
- "default": "sap_fiori_3",
3
+ "default": "sap_horizon",
4
4
  "all": [
5
5
  "sap_fiori_3",
6
6
  "sap_fiori_3_dark",
7
- "sap_belize",
8
- "sap_belize_hcb",
9
- "sap_belize_hcw",
10
7
  "sap_fiori_3_hcb",
11
8
  "sap_fiori_3_hcw",
12
- "sap_horizon",
13
- "sap_horizon_dark",
14
- "sap_horizon_hcb",
15
- "sap_horizon_hcw",
16
- "sap_horizon_exp"
17
- ]
9
+ "sap_horizon",
10
+ "sap_horizon_dark",
11
+ "sap_horizon_hcb",
12
+ "sap_horizon_hcw",
13
+ ],
18
14
  },
19
15
  "languages": {
20
16
  "default": "en",
@@ -22,6 +18,7 @@ const assetsMeta = {
22
18
  "ar",
23
19
  "bg",
24
20
  "ca",
21
+ "cnr",
25
22
  "cs",
26
23
  "cy",
27
24
  "da",
@@ -41,7 +38,7 @@ const assetsMeta = {
41
38
  "hi",
42
39
  "hr",
43
40
  "hu",
44
- "in",
41
+ "id",
45
42
  "it",
46
43
  "iw",
47
44
  "ja",
@@ -49,6 +46,7 @@ const assetsMeta = {
49
46
  "ko",
50
47
  "lt",
51
48
  "lv",
49
+ "mk",
52
50
  "ms",
53
51
  "nl",
54
52
  "no",
@@ -60,6 +58,7 @@ const assetsMeta = {
60
58
  "sh",
61
59
  "sk",
62
60
  "sl",
61
+ "sr",
63
62
  "sv",
64
63
  "th",
65
64
  "tr",
@@ -77,6 +76,7 @@ const assetsMeta = {
77
76
  "ar_SA",
78
77
  "bg",
79
78
  "ca",
79
+ "cnr",
80
80
  "cs",
81
81
  "da",
82
82
  "de",
@@ -124,6 +124,7 @@ const assetsMeta = {
124
124
  "lt",
125
125
  "lv",
126
126
  "ms",
127
+ "mk",
127
128
  "nb",
128
129
  "nl",
129
130
  "nl_BE",
@@ -1,3 +1,65 @@
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
+
1
63
  module.exports = {
2
64
  "env": {
3
65
  "browser": true,
@@ -5,6 +67,7 @@ module.exports = {
5
67
  },
6
68
  "root": true,
7
69
  "extends": "airbnb-base",
70
+ "overrides": tsMode ? getTsModeOverrides() : [],
8
71
  "parserOptions": {
9
72
  "ecmaVersion": 2018,
10
73
  "sourceType": "module"
@@ -47,6 +110,7 @@ module.exports = {
47
110
  "curly": [2, "all"],
48
111
  // "default-case": 1, // removed for UI5 WebComponents
49
112
  "import/extensions": ["error", "always"], // override for UI5 WebComponents
113
+ "import/order": "off",
50
114
  "no-alert": 2,
51
115
  "no-caller": 2,
52
116
  "no-div-regex": 2,
@@ -88,7 +152,7 @@ module.exports = {
88
152
  "no-shadow-restricted-names": 2,
89
153
  "no-undef-init": 2,
90
154
  "no-undef": 2,
91
- "no-unused-vars": [2, {"vars":"all", "args":"none"}],
155
+ "no-unused-vars": [2, { "vars": "all", "args": "none" }],
92
156
 
93
157
  "brace-style": [2, "1tbs", { "allowSingleLine": true }],
94
158
  "camelcase": [1, { "properties": "never" }], // added for UI5 WebComponents
@@ -104,7 +168,7 @@ module.exports = {
104
168
  "no-new-object": 2,
105
169
  "no-spaced-func": 2,
106
170
  "quote-props": [2, "as-needed", { "keywords": true, "unnecessary": false }],
107
- "semi-spacing": [1, {"before": false, "after": true}],
171
+ "semi-spacing": [1, { "before": false, "after": true }],
108
172
  "semi": 2,
109
173
  "keyword-spacing": 2,
110
174
  "space-infix-ops": 2,
@@ -1,13 +1,60 @@
1
1
  const path = require("path");
2
2
  const fs = require("fs");
3
3
  const LIB = path.join(__dirname, `../lib/`);
4
+ let websiteBaseUrl = "/";
4
5
 
6
+ if (process.env.DEPLOY) {
7
+ websiteBaseUrl = "/ui5-webcomponents/";
8
+ } else if (process.env.DEPLOY_NIGHTLY) {
9
+ websiteBaseUrl = "/ui5-webcomponents/nightly/";
10
+ }
11
+
12
+ const cypressEnvVariables = (options, predefinedVars) => {
13
+ let variables = [];
14
+ const { cypress_code_coverage, cypress_acc_tests } = options.internal ?? {};
15
+
16
+ // Handle environment variables like TEST_SUITE
17
+ if (predefinedVars) {
18
+ variables = [...predefinedVars];
19
+ }
20
+
21
+ // The coverage task is always registered and requires an explicit variable whether to generate a report or not
22
+ variables.push(`CYPRESS_COVERAGE=${!!cypress_code_coverage}`);
23
+
24
+ if (cypress_acc_tests) {
25
+ variables.push("CYPRESS_UI5_ACC=true");
26
+ }
27
+
28
+ return variables.length ? `cross-env ${variables.join(" ")}` : "";
29
+ }
5
30
 
6
31
  const getScripts = (options) => {
7
32
 
8
- let illustrations = options.illustrationsData || [];
9
- illustrations = illustrations.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
10
- let illustrationsScript = illustrations.join(" && ");
33
+ // The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
34
+ const illustrationsData = options.illustrationsData || [];
35
+ const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath} ${illustration.collection}`);
36
+ const createIllustrationsJSImportsScript = illustrations.join(" && ");
37
+
38
+ // The script creates the "src/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
39
+ const createIllustrationsLoadersScript = illustrationsData.map(illustrations => `node ${LIB}/generate-js-imports/illustrations.js ${illustrations.destinationPath} ${illustrations.dynamicImports.outputFile} ${illustrations.set} ${illustrations.collection} ${illustrations.dynamicImports.location} ${illustrations.dynamicImports.filterOut.join(" ")}`).join(" && ");
40
+
41
+ const tsOption = !options.legacy || options.jsx;
42
+ const tsCommandOld = tsOption ? "tsc" : "";
43
+ let tsWatchCommandStandalone = tsOption ? "tsc --watch" : "";
44
+ // this command is only used for standalone projects. monorepo projects get their watch from vite, so opt-out here
45
+ if (options.noWatchTS) {
46
+ tsWatchCommandStandalone = "";
47
+ }
48
+ const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
49
+
50
+ if (tsOption) {
51
+ try {
52
+ require("typescript");
53
+ } catch (e) {
54
+ 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.`);
55
+ process.exit(e.code);
56
+ }
57
+ }
11
58
 
12
59
  let viteConfig;
13
60
  if (fs.existsSync("config/vite.config.js")) {
@@ -22,79 +69,87 @@ const getScripts = (options) => {
22
69
  }
23
70
 
24
71
  let eslintConfig;
25
- if (fs.existsSync("config/.eslintrc.js")) {
26
- // old project setup where config file is in separate folder
27
- eslintConfig = "--config config/.eslintrc.js";
28
- } else if (fs.existsSync(".eslintrc.js")) {
72
+ if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
29
73
  // preferred way of custom configuration in root project folder
30
74
  eslintConfig = "";
31
75
  } else {
32
76
  // no custom configuration - use default from tools project
33
77
  eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
34
78
  }
35
-
79
+
36
80
  const scripts = {
37
- clean: 'rimraf dist && rimraf .port && nps "scope.testPages.clean"',
81
+ clean: 'rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
38
82
  lint: `eslint . ${eslintConfig}`,
39
- lintfix: `eslint . ${eslintConfig}`,
83
+ lintfix: `eslint . ${eslintConfig} --fix`,
84
+ generate: {
85
+ default: `${tsCrossEnv} nps prepare.all`,
86
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copyProps" "nps build.illustrations"',
87
+ styleRelated: "nps build.styles build.jsonImports build.jsImports",
88
+ },
40
89
  prepare: {
41
- default: "nps clean prepare.all",
42
- all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.api" "nps build.illustrations"',
43
- styleRelated: "nps build.styles build.jsonImports",
90
+ default: `${tsCrossEnv} nps clean prepare.all ${options.legacy ? "copy" : ""} copyProps prepare.typescript generateAPI`,
91
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps build.illustrations"',
92
+ styleRelated: "nps build.styles build.jsonImports build.jsImports",
93
+ typescript: tsCommandOld,
44
94
  },
45
95
  build: {
46
- default: "nps lint prepare build.bundle",
47
- templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
96
+ default: "nps prepare lint build.bundle", // build.bundle2
97
+ templates: `mkdirp src/generated/templates && ${tsCrossEnv} node "${LIB}/hbs2ui5/index.js" -d src/ -o src/generated/templates`,
48
98
  styles: {
49
- default: "nps build.styles.themes build.styles.components",
50
- themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
51
- components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
99
+ default: `concurrently "nps build.styles.themes" "nps build.styles.components"`,
100
+ themes: `node "${LIB}/css-processors/css-processor-themes.mjs"`,
101
+ components: `node "${LIB}/css-processors/css-processor-components.mjs"`,
52
102
  },
53
103
  i18n: {
54
104
  default: "nps build.i18n.defaultsjs build.i18n.json",
55
- defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
105
+ defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
56
106
  json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
57
107
  },
58
108
  jsonImports: {
59
- default: "mkdirp dist/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
60
- themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
61
- i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
109
+ default: "mkdirp src/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
110
+ themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes src/generated/json-imports`,
111
+ i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n src/generated/json-imports`,
112
+ },
113
+ jsImports: {
114
+ default: "mkdirp src/generated/js-imports && nps build.jsImports.illustrationsLoaders",
115
+ illustrationsLoaders: createIllustrationsLoadersScript,
62
116
  },
63
- bundle: `vite build ${viteConfig}`,
64
- api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
65
- illustrations: illustrationsScript
117
+ bundle: `vite build ${viteConfig} --mode testing --base ${websiteBaseUrl}`,
118
+ bundle2: ``,
119
+ illustrations: createIllustrationsJSImportsScript,
66
120
  },
121
+ copyProps: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
67
122
  copy: {
68
123
  default: "nps copy.src copy.props",
69
- src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
70
- props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
124
+ src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/`,
125
+ props: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
71
126
  },
72
127
  watch: {
73
- default: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.styles" "nps watch.i18n" "nps watch.props"',
128
+ default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.typescript" ${options.legacy ? '"nps watch.src"' : ""} "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
74
129
  devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
75
130
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
76
- props: 'nps "copy.props --watch --safe --skip-initial-copy"',
77
- bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
131
+ typescript: tsWatchCommandStandalone,
132
+ props: 'nps "copyProps --watch --safe --skip-initial-copy"',
133
+ bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
78
134
  styles: {
79
135
  default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
80
136
  themes: 'nps "build.styles.themes -w"',
81
- components: {
82
- default: 'concurrently "nps watch.styles.components.existingFiles" "nps watch.styles.components.newFiles"',
83
- existingFiles: `nps "build.styles.components -w"`,
84
- newFiles: `node "${LIB}/postcss-new-files/index.js" --srcFiles="src/themes/*.css"`,
85
- },
137
+ components: `nps "build.styles.components -w"`,
86
138
  },
87
- templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
88
- api: 'chokidar "test/**/*.sample.html" -c "nps build.api"',
139
+ templates: 'chokidar "src/**/*.hbs" -i "src/generated" -c "nps build.templates"',
89
140
  i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
90
141
  },
91
142
  start: "nps prepare watch.devServer",
92
143
  test: `node "${LIB}/test-runner/test-runner.js"`,
144
+ "test-cy-ci": `${cypressEnvVariables(options)} yarn cypress run --component --browser chrome`,
145
+ "test-cy-ci-suite-1": `${cypressEnvVariables(options, ["TEST_SUITE=SUITE1"])} yarn cypress run --component --browser chrome`,
146
+ "test-cy-ci-suite-2": `${cypressEnvVariables(options, ["TEST_SUITE=SUITE2"])} yarn cypress run --component --browser chrome`,
147
+ "test-cy-open": `${cypressEnvVariables(options)} yarn cypress open --component --browser chrome`,
93
148
  "test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
94
149
  "test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
95
150
  startWithScope: "nps scope.prepare scope.watchWithBundle",
96
151
  scope: {
97
- prepare: "nps scope.lint prepare scope.testPages",
152
+ prepare: "nps scope.lint scope.testPages",
98
153
  lint: `node "${LIB}/scoping/lint-src.js"`,
99
154
  testPages: {
100
155
  default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
@@ -103,9 +158,14 @@ const getScripts = (options) => {
103
158
  replace: `node "${LIB}/scoping/scope-test-pages.js" test/pages/scoped demo`,
104
159
  },
105
160
  watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
106
- watch: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.props" "nps watch.styles"',
107
- bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
108
- }
161
+ watch: 'concurrently "nps watch.templates" "nps watch.props" "nps watch.styles"',
162
+ bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
163
+ },
164
+ generateAPI: {
165
+ default: tsOption ? "nps generateAPI.generateCEM generateAPI.validateCEM" : "",
166
+ generateCEM: `${options.dev ? "cross-env UI5_CEM_MODE='dev'" : ""} cem analyze --config "${LIB}/cem/custom-elements-manifest.config.mjs"`,
167
+ validateCEM: `${options.dev ? "cross-env UI5_CEM_MODE='dev'" : ""} node "${LIB}/cem/validate.js"`,
168
+ },
109
169
  };
110
170
 
111
171
  return scripts;
@@ -1,21 +1 @@
1
- const postcssImport = require('postcss-import');
2
- const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
3
- const cssnano = require('cssnano');
4
- const fs = require("fs");
5
-
6
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
7
-
8
- module.exports = {
9
- plugins: [
10
- postcssImport(),
11
- cssnano({
12
- preset: [
13
- 'default', {
14
- mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
15
- mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
16
- },
17
- ]
18
- }),
19
- postcssCSStoESM({toReplace: 'src', includeDefaultTheme: true, packageName}),
20
- ]
21
- };
1
+ module.exports = {}
@@ -1,26 +1 @@
1
- const postcssImport = require('postcss-import');
2
- const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
3
- const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
4
- const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
5
- const cssnano = require('cssnano');
6
- const fs = require("fs");
7
-
8
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
9
-
10
- module.exports = {
11
- plugins: [
12
- postcssImport(),
13
- combineSelectors({
14
- removeDuplicatedProperties: true
15
- }),
16
- cssnano({
17
- preset: [
18
- 'default', {
19
- mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
20
- },
21
- ]
22
- },),
23
- postcssCSStoJSON({toReplace: 'src', packageName}),
24
- postcssCSStoESM({toReplace: 'src', packageName}),
25
- ]
26
- };
1
+ module.exports = {};
@@ -1,12 +1,9 @@
1
1
  // vite.config.js
2
- const { defineConfig } = require('vite');
3
- const virtualIndex = require("../lib/dev-server/virtual-index-html-plugin.js");
2
+ const virtualIndex = require('../lib/dev-server/virtual-index-html-plugin.js');
4
3
 
5
- module.exports = defineConfig(async () => {
6
- return {
7
- build: {
8
- emptyOutDir: false,
9
- },
10
- plugins: [await virtualIndex()],
11
- }
12
- });
4
+ module.exports = {
5
+ build: {
6
+ emptyOutDir: false,
7
+ },
8
+ plugins: [virtualIndex()],
9
+ };
@@ -1,3 +1,6 @@
1
+ const dns = require("node:dns");
2
+ const assert = require("chai").assert;
3
+
1
4
  exports.config = {
2
5
  //
3
6
  // ====================
@@ -56,7 +59,16 @@ exports.config = {
56
59
  'goog:chromeOptions': {
57
60
  // to run chrome headless the following flags are required
58
61
  // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
59
- args: ['--headless', '--disable-gpu'],
62
+ args: [
63
+ '--headless',
64
+ '--disable-search-engine-choice-screen',
65
+ '--start-maximized',
66
+ '--no-sandbox',
67
+ '--disable-gpu',
68
+ '--disable-infobars',
69
+ '--disable-extensions',
70
+ '--disable-dev-shm-usage',
71
+ ],
60
72
  // args: ['--disable-gpu'],
61
73
  }
62
74
  }],
@@ -99,8 +111,7 @@ exports.config = {
99
111
  // Services take over a specific job you don't want to take care of. They enhance
100
112
  // your test setup with almost no effort. Unlike plugins, they don't add new
101
113
  // commands. Instead, they hook themselves up into the test process.
102
- services: ['chromedriver', 'devtools',
103
- ['static-server', {
114
+ services: ['chromedriver', ['static-server', {
104
115
  folders: [
105
116
  { mount: '/', path: './dist' },
106
117
  ],
@@ -153,6 +164,9 @@ exports.config = {
153
164
  */
154
165
  // beforeSession: function (config, capabilities, specs) {
155
166
  // },
167
+ beforeSession: () => {
168
+ dns.setDefaultResultOrder('ipv4first');
169
+ },
156
170
  /**
157
171
  * Gets executed before test execution begins. At this point you can access to all global
158
172
  * variables like `browser`. It is the perfect place to define custom commands.
@@ -217,12 +231,17 @@ exports.config = {
217
231
  }, this, className);
218
232
  }, true);
219
233
 
220
- await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
221
- return browser.executeAsync(async (selector, done) => {
222
- const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
223
- done(staticAreaItem.host.classList[0]);
224
- }, selector);
225
- }, false);
234
+ await browser.addCommand("hasAttribute", async function(attrName) {
235
+ return browser.executeAsync((elem, attrName, done) => {
236
+ done(elem.hasAttribute(attrName));
237
+ }, this, attrName);
238
+ }, true);
239
+
240
+ await browser.addCommand("matches", async function(selector) {
241
+ return browser.executeAsync((elem, selector, done) => {
242
+ done(elem.matches(selector));
243
+ }, this, selector);
244
+ }, true);
226
245
 
227
246
  await browser.addLocatorStrategy('activeElement', (selector) => {
228
247
  return document.querySelector(selector).shadowRoot.activeElement;
@@ -238,11 +257,12 @@ exports.config = {
238
257
  "$",
239
258
  "$$",
240
259
  "getAttribute",
260
+ "hasAttribute", // custom
261
+ "matches", // custom
241
262
  "getCSSProperty",
242
263
  "getHTML",
243
264
  "getProperty",
244
265
  "getSize",
245
- "getStaticAreaItemClassName", // custom
246
266
  "getText",
247
267
  "getValue",
248
268
  "hasClass", // custom
@@ -254,7 +274,7 @@ exports.config = {
254
274
  "isFocusedDeep", // custom
255
275
  "isFocusedDeepElement", // custom
256
276
  "shadow$",
257
- "shadow$$",
277
+ "shadow$$"
258
278
  ];
259
279
  if (waitFor.includes(commandName)) {
260
280
  await browser.executeAsync(function (done) {
@@ -291,8 +311,17 @@ exports.config = {
291
311
  * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
292
312
  * @param {Object} test test details
293
313
  */
294
- // afterTest: function (test) {
295
- // },
314
+ afterTest: async function (test) {
315
+ // fetch the browser logs and fail the test if there are `console.error` messages with the `[UI5-FWK]` marker
316
+ const logs = await browser.getLogs('browser');
317
+ const severeLogs = logs
318
+ .filter(l => l.level === "SEVERE" && l.message.includes("[UI5-FWK]"))
319
+ .map(l => l.message);
320
+
321
+ if (severeLogs.length) {
322
+ test.callback(new Error(`[${test.title}]\n\n ${severeLogs.join("\n ")}`));
323
+ }
324
+ },
296
325
  /**
297
326
  * Hook that gets executed after the suite has ended
298
327
  * @param {Object} suite suite details
@@ -21,7 +21,7 @@ const copyIconAssetsCommand = (options) => {
21
21
  return {
22
22
  default: "nps copy.json-imports copy.icon-collection",
23
23
  "json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
24
- "icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json" dist/generated/assets/`,
24
+ "icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json" src/generated/assets/`,
25
25
  }
26
26
  }
27
27
 
@@ -32,7 +32,7 @@ const copyIconAssetsCommand = (options) => {
32
32
 
33
33
  options.versions.forEach((v) => {
34
34
  command.default += ` copy.icon-collection${v}`;
35
- command[`icon-collection${v}`] = `node "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" dist/generated/assets/${v}/`;
35
+ command[`icon-collection${v}`] = `node "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" src/generated/assets/${v}/`;
36
36
  });
37
37
 
38
38
  return command;
@@ -41,23 +41,28 @@ const copyIconAssetsCommand = (options) => {
41
41
  const getScripts = (options) => {
42
42
  const createJSImportsCmd = createIconImportsCommand(options);
43
43
  const copyAssetsCmd = copyIconAssetsCommand(options);
44
+ const tsCommand = !options.legacy ? "tsc --build" : "";
45
+ const tsCrossEnv = !options.legacy ? "cross-env UI5_TS=true" : "";
44
46
 
45
47
  const scripts = {
46
- clean: "rimraf dist",
48
+ clean: "rimraf dist && rimraf src/generated",
47
49
  copy: copyAssetsCmd,
50
+ generate: `${tsCrossEnv} nps clean copy build.i18n build.icons build.jsonImports copyjson`,
51
+ copyjson: "copy-and-watch \"src/generated/**/*.json\" dist/generated/",
48
52
  build: {
49
- default: `nps clean copy build.i18n build.icons build.jsonImports`,
53
+ default: `${tsCrossEnv} nps clean copy build.i18n typescript build.icons build.jsonImports`,
50
54
  i18n: {
51
55
  default: "nps build.i18n.defaultsjs build.i18n.json",
52
- defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
53
- json: `mkdirp dist/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
56
+ defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
57
+ json: `mkdirp src/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n src/generated/assets/i18n`,
54
58
  },
55
59
  jsonImports: {
56
- default: "mkdirp dist/generated/json-imports && nps build.jsonImports.i18n",
57
- i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
60
+ default: "mkdirp src/generated/json-imports && nps build.jsonImports.i18n",
61
+ i18n: `node "${LIB}/generate-json-imports/i18n.js" src/generated/assets/i18n src/generated/json-imports`,
58
62
  },
59
63
  icons: createJSImportsCmd,
60
64
  },
65
+ typescript: tsCommand,
61
66
  };
62
67
 
63
68
  return scripts;