@ui5/webcomponents-tools 0.0.0-38861c872 → 0.0.0-38f83ffef

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 (48) hide show
  1. package/CHANGELOG.md +1121 -0
  2. package/README.md +2 -5
  3. package/assets-meta.js +3 -11
  4. package/components-package/eslint.js +59 -31
  5. package/components-package/nps.js +48 -26
  6. package/components-package/vite.config.js +7 -11
  7. package/components-package/wdio.js +415 -405
  8. package/icons-collection/nps.js +2 -2
  9. package/lib/amd-to-es6/index.js +102 -0
  10. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  11. package/lib/cem/custom-elements-manifest.config.mjs +129 -55
  12. package/lib/cem/event.mjs +75 -21
  13. package/lib/cem/schema-internal.json +71 -0
  14. package/lib/cem/types-internal.d.ts +564 -785
  15. package/lib/cem/types.d.ts +520 -655
  16. package/lib/cem/utils.mjs +115 -47
  17. package/lib/cem/validate.js +41 -37
  18. package/lib/create-icons/index.js +13 -10
  19. package/lib/create-illustrations/index.js +44 -9
  20. package/lib/create-new-component/{tsFileContentTemplate.js → Component.js} +13 -10
  21. package/lib/create-new-component/ComponentTemplate.js +12 -0
  22. package/lib/create-new-component/index.js +14 -22
  23. package/lib/css-processors/css-processor-components.mjs +3 -2
  24. package/lib/css-processors/css-processor-themes.mjs +2 -7
  25. package/lib/css-processors/scope-variables.mjs +3 -0
  26. package/lib/css-processors/shared.mjs +2 -22
  27. package/lib/dev-server/{dev-server.js → dev-server.mjs} +4 -4
  28. package/lib/dev-server/virtual-index-html-plugin.js +24 -20
  29. package/lib/generate-json-imports/i18n.js +46 -62
  30. package/lib/generate-json-imports/themes.js +13 -32
  31. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +12 -7
  32. package/lib/hbs2ui5/index.js +3 -3
  33. package/lib/i18n/defaults.js +3 -2
  34. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  35. package/lib/scoping/get-all-tags.js +9 -2
  36. package/lib/scoping/lint-src.js +8 -7
  37. package/package.json +11 -8
  38. package/tsconfig.json +18 -0
  39. package/components-package/wdio.sync.js +0 -368
  40. package/lib/create-new-component/jsFileContentTemplate.js +0 -73
  41. package/lib/esm-abs-to-rel/index.js +0 -61
  42. package/lib/generate-custom-elements-manifest/index.js +0 -327
  43. package/lib/jsdoc/config.json +0 -29
  44. package/lib/jsdoc/configTypescript.json +0 -29
  45. package/lib/jsdoc/plugin.js +0 -2468
  46. package/lib/jsdoc/preprocess.js +0 -146
  47. package/lib/jsdoc/template/publish.js +0 -4120
  48. package/lib/replace-global-core/index.js +0 -25
package/README.md CHANGED
@@ -1,7 +1,4 @@
1
- ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_wide.png)
2
-
3
-
4
- # 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
5
2
 
6
3
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
7
4
 
@@ -11,7 +8,7 @@ used by other UI5 Web Components packages, such as `main` and `fiori`.
11
8
  ## Resources
12
9
  - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
13
10
  - [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
14
- - [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/)
15
12
 
16
13
  ## Support
17
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/).
package/assets-meta.js CHANGED
@@ -4,19 +4,12 @@ const assetsMeta = {
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
9
  "sap_horizon",
13
10
  "sap_horizon_dark",
14
11
  "sap_horizon_hcb",
15
12
  "sap_horizon_hcw",
16
- "sap_horizon_exp",
17
- "sap_horizon_dark_exp",
18
- "sap_horizon_hcb_exp",
19
- "sap_horizon_hcw_exp",
20
13
  ],
21
14
  },
22
15
  "languages": {
@@ -45,7 +38,7 @@ const assetsMeta = {
45
38
  "hi",
46
39
  "hr",
47
40
  "hu",
48
- "in",
41
+ "id",
49
42
  "it",
50
43
  "iw",
51
44
  "ja",
@@ -83,7 +76,7 @@ const assetsMeta = {
83
76
  "ar_SA",
84
77
  "bg",
85
78
  "ca",
86
- // "cnr_ME" - cldr for not available yet
79
+ "cnr",
87
80
  "cs",
88
81
  "da",
89
82
  "de",
@@ -131,7 +124,7 @@ const assetsMeta = {
131
124
  "lt",
132
125
  "lv",
133
126
  "ms",
134
- // "mk_MK" cldr not available yet
127
+ "mk",
135
128
  "nb",
136
129
  "nl",
137
130
  "nl_BE",
@@ -144,7 +137,6 @@ const assetsMeta = {
144
137
  "sk",
145
138
  "sl",
146
139
  "sr",
147
- // "sr_Cyrl_RS" - cldr not available yet
148
140
  "sr_Latn",
149
141
  "sv",
150
142
  "th",
@@ -3,35 +3,62 @@ const path = require("path");
3
3
  const tsMode = fs.existsSync(path.join(process.cwd(), "tsconfig.json"));
4
4
 
5
5
  /**
6
- * Typescript Rules
6
+ * Returns eslint rules specific to typescript files
7
+ * @returns
7
8
  */
8
- const overrides = tsMode ? [{
9
- files: ["*.ts"],
10
- parser: "@typescript-eslint/parser",
11
- plugins: ["@typescript-eslint"],
12
- extends: [
13
- "plugin:@typescript-eslint/recommended",
14
- "plugin:@typescript-eslint/recommended-requiring-type-checking"
15
- ],
16
- parserOptions: {
17
- "project": ["./tsconfig.json", "./packages/*/tsconfig.json"],
18
- EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
19
- },
20
- rules: {
21
- "no-shadow": "off",
22
- "@typescript-eslint/no-shadow": ["error"],
23
- "@typescript-eslint/no-unsafe-member-access": "off",
24
- "@typescript-eslint/no-floating-promises": "off",
25
- "@typescript-eslint/no-explicit-any": "off",
26
- "@typescript-eslint/no-unsafe-assignment": "off",
27
- "@typescript-eslint/ban-ts-comment": "off",
28
- "@typescript-eslint/no-unsafe-call": "off",
29
- "@typescript-eslint/no-non-null-assertion": "off",
30
- "@typescript-eslint/no-empty-function": "off",
31
- "@typescript-eslint/no-empty-interface": "off",
32
- "lines-between-class-members": "off",
33
- }
34
- }] : [];
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
+ }
35
62
 
36
63
  module.exports = {
37
64
  "env": {
@@ -40,7 +67,7 @@ module.exports = {
40
67
  },
41
68
  "root": true,
42
69
  "extends": "airbnb-base",
43
- overrides,
70
+ "overrides": tsMode ? getTsModeOverrides() : [],
44
71
  "parserOptions": {
45
72
  "ecmaVersion": 2018,
46
73
  "sourceType": "module"
@@ -83,6 +110,7 @@ module.exports = {
83
110
  "curly": [2, "all"],
84
111
  // "default-case": 1, // removed for UI5 WebComponents
85
112
  "import/extensions": ["error", "always"], // override for UI5 WebComponents
113
+ "import/order": "off",
86
114
  "no-alert": 2,
87
115
  "no-caller": 2,
88
116
  "no-div-regex": 2,
@@ -124,7 +152,7 @@ module.exports = {
124
152
  "no-shadow-restricted-names": 2,
125
153
  "no-undef-init": 2,
126
154
  "no-undef": 2,
127
- "no-unused-vars": [2, {"vars":"all", "args":"none"}],
155
+ "no-unused-vars": [2, { "vars": "all", "args": "none" }],
128
156
 
129
157
  "brace-style": [2, "1tbs", { "allowSingleLine": true }],
130
158
  "camelcase": [1, { "properties": "never" }], // added for UI5 WebComponents
@@ -140,7 +168,7 @@ module.exports = {
140
168
  "no-new-object": 2,
141
169
  "no-spaced-func": 2,
142
170
  "quote-props": [2, "as-needed", { "keywords": true, "unnecessary": false }],
143
- "semi-spacing": [1, {"before": false, "after": true}],
171
+ "semi-spacing": [1, { "before": false, "after": true }],
144
172
  "semi": 2,
145
173
  "keyword-spacing": 2,
146
174
  "space-infix-ops": 2,
@@ -1,8 +1,32 @@
1
1
  const path = require("path");
2
2
  const fs = require("fs");
3
- const resolve = require("resolve");
4
3
  const LIB = path.join(__dirname, `../lib/`);
5
- const preprocessJSDocScript = resolve.sync("@ui5/webcomponents-tools/lib/jsdoc/preprocess.js");
4
+ let websiteBaseUrl = "/";
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
+ }
6
30
 
7
31
  const getScripts = (options) => {
8
32
 
@@ -12,9 +36,9 @@ const getScripts = (options) => {
12
36
  const createIllustrationsJSImportsScript = illustrations.join(" && ");
13
37
 
14
38
  // The script creates the "src/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
15
- 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(" && ");
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(" && ");
16
40
 
17
- const tsOption = options.typescript;
41
+ const tsOption = !options.legacy || options.jsx;
18
42
  const tsCommandOld = tsOption ? "tsc" : "";
19
43
  let tsWatchCommandStandalone = tsOption ? "tsc --watch" : "";
20
44
  // this command is only used for standalone projects. monorepo projects get their watch from vite, so opt-out here
@@ -26,7 +50,7 @@ const getScripts = (options) => {
26
50
  if (tsOption) {
27
51
  try {
28
52
  require("typescript");
29
- } catch(e) {
53
+ } catch (e) {
30
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.`);
31
55
  process.exit(e.code);
32
56
  }
@@ -54,16 +78,16 @@ const getScripts = (options) => {
54
78
  }
55
79
 
56
80
  const scripts = {
57
- clean: 'rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
81
+ clean: 'rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
58
82
  lint: `eslint . ${eslintConfig}`,
59
83
  lintfix: `eslint . ${eslintConfig} --fix`,
60
84
  generate: {
61
85
  default: `${tsCrossEnv} nps prepare.all`,
62
- all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
86
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copyProps" "nps build.illustrations"',
63
87
  styleRelated: "nps build.styles build.jsonImports build.jsImports",
64
88
  },
65
89
  prepare: {
66
- default: `${tsCrossEnv} nps clean prepare.all copy prepare.typescript generateAPI`,
90
+ default: `${tsCrossEnv} nps clean prepare.all ${options.legacy ? "copy" : ""} copyProps prepare.typescript generateAPI`,
67
91
  all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps build.illustrations"',
68
92
  styleRelated: "nps build.styles build.jsonImports build.jsImports",
69
93
  typescript: tsCommandOld,
@@ -90,34 +114,37 @@ const getScripts = (options) => {
90
114
  default: "mkdirp src/generated/js-imports && nps build.jsImports.illustrationsLoaders",
91
115
  illustrationsLoaders: createIllustrationsLoadersScript,
92
116
  },
93
- bundle: `vite build ${viteConfig}`,
117
+ bundle: `vite build ${viteConfig} --mode testing --base ${websiteBaseUrl}`,
94
118
  bundle2: ``,
95
119
  illustrations: createIllustrationsJSImportsScript,
96
120
  },
121
+ copyProps: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
97
122
  copy: {
98
123
  default: "nps copy.src copy.props",
99
124
  src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/`,
100
- // srcGenerated2: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.{js,json}" dist/generated/`,
101
- props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
125
+ props: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
102
126
  },
103
127
  watch: {
104
- default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.typescript" "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"`,
105
129
  devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
106
130
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
107
131
  typescript: tsWatchCommandStandalone,
108
- props: 'nps "copy.props --watch --safe --skip-initial-copy"',
109
- bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
132
+ props: 'nps "copyProps --watch --safe --skip-initial-copy"',
133
+ bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
110
134
  styles: {
111
135
  default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
112
136
  themes: 'nps "build.styles.themes -w"',
113
137
  components: `nps "build.styles.components -w"`,
114
138
  },
115
- templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
116
- api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
139
+ templates: 'chokidar "src/**/*.hbs" -i "src/generated" -c "nps build.templates"',
117
140
  i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
118
141
  },
119
142
  start: "nps prepare watch.devServer",
120
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`,
121
148
  "test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
122
149
  "test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
123
150
  startWithScope: "nps scope.prepare scope.watchWithBundle",
@@ -131,18 +158,13 @@ const getScripts = (options) => {
131
158
  replace: `node "${LIB}/scoping/scope-test-pages.js" test/pages/scoped demo`,
132
159
  },
133
160
  watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
134
- watch: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.props" "nps watch.styles"',
135
- bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
161
+ watch: 'concurrently "nps watch.templates" "nps watch.props" "nps watch.styles"',
162
+ bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
136
163
  },
137
164
  generateAPI: {
138
- default: `nps ${ tsOption ? "generateAPI.generateCEM generateAPI.validateCEM" : "generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup generateAPI.prepareManifest"}`,
139
- generateCEM: `cem analyze --config "${LIB}/cem/custom-elements-manifest.config.mjs"`,
140
- validateCEM: `node "${LIB}/cem/validate.js"`,
141
- prepare: `node "${LIB}/copy-and-watch/index.js" --silent "dist/**/*.js" jsdoc-dist/`,
142
- prepareManifest: `node "${LIB}/generate-custom-elements-manifest/index.js" dist dist`,
143
- preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
144
- jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
145
- cleanup: "rimraf jsdoc-dist/"
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"`,
146
168
  },
147
169
  };
148
170
 
@@ -1,13 +1,9 @@
1
1
  // vite.config.js
2
- import { defineConfig } from 'vite';
3
- import virtualIndex from '../lib/dev-server/virtual-index-html-plugin.js';
2
+ const virtualIndex = require('../lib/dev-server/virtual-index-html-plugin.js');
4
3
 
5
- export default defineConfig(async () => {
6
- const data = await virtualIndex();
7
- return {
8
- build: {
9
- emptyOutDir: false,
10
- },
11
- plugins: [data],
12
- }
13
- })
4
+ module.exports = {
5
+ build: {
6
+ emptyOutDir: false,
7
+ },
8
+ plugins: [virtualIndex()],
9
+ };