@ui5/webcomponents-tools 0.0.0-4738ea0dc → 0.0.0-47cc17a26

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 (125) hide show
  1. package/CHANGELOG.md +1912 -0
  2. package/LICENSE.txt +201 -0
  3. package/README.md +7 -9
  4. package/assets-meta.js +12 -11
  5. package/bin/dev.js +3 -2
  6. package/bin/ui5nps.js +265 -0
  7. package/components-package/eslint.js +51 -15
  8. package/components-package/nps.js +122 -77
  9. package/components-package/postcss.components.js +1 -21
  10. package/components-package/postcss.themes.js +1 -26
  11. package/components-package/vite.config.js +7 -10
  12. package/components-package/wdio.js +43 -15
  13. package/icons-collection/nps.js +31 -20
  14. package/lib/amd-to-es6/index.js +107 -0
  15. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  16. package/lib/cem/cem.js +12 -0
  17. package/lib/cem/custom-elements-manifest.config.mjs +530 -0
  18. package/lib/cem/event.mjs +168 -0
  19. package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
  20. package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
  21. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
  22. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
  23. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
  24. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
  25. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
  26. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
  27. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
  28. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
  29. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
  30. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
  31. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
  32. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
  33. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
  34. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
  35. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
  36. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
  37. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
  38. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
  39. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
  40. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
  41. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
  42. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
  43. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
  44. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
  45. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
  46. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
  47. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
  48. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
  49. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
  50. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
  51. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
  52. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
  53. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
  54. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
  55. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
  56. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
  57. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
  58. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
  59. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
  60. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
  61. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
  62. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
  63. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
  64. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
  65. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
  66. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
  67. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
  68. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
  69. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
  70. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
  71. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
  72. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
  73. package/lib/cem/schema-internal.json +1422 -0
  74. package/lib/cem/schema.json +1098 -0
  75. package/lib/cem/types-internal.d.ts +808 -0
  76. package/lib/cem/types.d.ts +736 -0
  77. package/lib/cem/utils.mjs +423 -0
  78. package/lib/cem/validate.js +76 -0
  79. package/lib/copy-and-watch/index.js +105 -97
  80. package/lib/copy-list/index.js +16 -10
  81. package/lib/create-icons/index.js +32 -25
  82. package/lib/create-illustrations/index.js +88 -45
  83. package/lib/create-new-component/Component.js +74 -0
  84. package/lib/create-new-component/ComponentTemplate.js +12 -0
  85. package/lib/create-new-component/index.js +62 -101
  86. package/lib/css-processors/css-processor-components.mjs +92 -0
  87. package/lib/css-processors/css-processor-themes.mjs +102 -0
  88. package/lib/css-processors/scope-variables.mjs +49 -0
  89. package/lib/css-processors/shared.mjs +46 -0
  90. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  91. package/lib/dev-server/{dev-server.js → dev-server.mjs} +26 -14
  92. package/lib/dev-server/virtual-index-html-plugin.js +24 -21
  93. package/lib/generate-js-imports/illustrations.js +77 -64
  94. package/lib/generate-json-imports/i18n.js +62 -69
  95. package/lib/generate-json-imports/themes.js +34 -43
  96. package/lib/hbs2lit/src/compiler.js +9 -6
  97. package/lib/hbs2lit/src/litVisitor2.js +42 -17
  98. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  99. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +39 -6
  100. package/lib/hbs2ui5/index.js +23 -6
  101. package/lib/i18n/defaults.js +15 -9
  102. package/lib/i18n/toJSON.js +15 -11
  103. package/lib/icons-hash/icons-hash.mjs +149 -0
  104. package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
  105. package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
  106. package/lib/rimraf/rimraf.js +31 -0
  107. package/lib/scoping/get-all-tags.js +10 -3
  108. package/lib/scoping/lint-src.js +8 -7
  109. package/lib/scoping/scope-test-pages.js +2 -1
  110. package/lib/test-runner/test-runner.js +10 -2
  111. package/package.json +36 -23
  112. package/tsconfig.json +18 -0
  113. package/components-package/wdio.sync.js +0 -360
  114. package/lib/esm-abs-to-rel/index.js +0 -58
  115. package/lib/generate-custom-elements-manifest/index.js +0 -327
  116. package/lib/jsdoc/config.json +0 -29
  117. package/lib/jsdoc/configTypescript.json +0 -29
  118. package/lib/jsdoc/plugin.js +0 -2468
  119. package/lib/jsdoc/preprocess.js +0 -146
  120. package/lib/jsdoc/template/publish.js +0 -4120
  121. package/lib/postcss-css-to-esm/index.js +0 -90
  122. package/lib/postcss-css-to-json/index.js +0 -47
  123. package/lib/postcss-new-files/index.js +0 -36
  124. package/lib/postcss-p/postcss-p.mjs +0 -14
  125. package/lib/replace-global-core/index.js +0 -25
@@ -1,11 +1,13 @@
1
- module.exports = {
2
- "env": {
3
- "browser": true,
4
- "es6": true
5
- },
6
- "root": true,
7
- "extends": "airbnb-base",
8
- overrides: [{
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 = {
9
11
  files: ["*.ts"],
10
12
  parser: "@typescript-eslint/parser",
11
13
  plugins: ["@typescript-eslint"],
@@ -14,13 +16,15 @@ module.exports = {
14
16
  "plugin:@typescript-eslint/recommended-requiring-type-checking"
15
17
  ],
16
18
  parserOptions: {
17
- "project": ["./tsconfig.json", "./packages/*/tsconfig.json"],
19
+ "project": [
20
+ "./tsconfig.json"
21
+ ],
22
+ EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
18
23
  },
19
- /**
20
- * Typescript Rules
21
- */
22
24
  rules: {
23
25
  "no-shadow": "off",
26
+ "@typescript-eslint/consistent-type-imports": "error",
27
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
24
28
  "@typescript-eslint/no-shadow": ["error"],
25
29
  "@typescript-eslint/no-unsafe-member-access": "off",
26
30
  "@typescript-eslint/no-floating-promises": "off",
@@ -30,9 +34,40 @@ module.exports = {
30
34
  "@typescript-eslint/no-unsafe-call": "off",
31
35
  "@typescript-eslint/no-non-null-assertion": "off",
32
36
  "@typescript-eslint/no-empty-function": "off",
37
+ "@typescript-eslint/no-empty-interface": "off",
33
38
  "lines-between-class-members": "off",
34
39
  }
35
- }],
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() : [],
36
71
  "parserOptions": {
37
72
  "ecmaVersion": 2018,
38
73
  "sourceType": "module"
@@ -75,6 +110,7 @@ module.exports = {
75
110
  "curly": [2, "all"],
76
111
  // "default-case": 1, // removed for UI5 WebComponents
77
112
  "import/extensions": ["error", "always"], // override for UI5 WebComponents
113
+ "import/order": "off",
78
114
  "no-alert": 2,
79
115
  "no-caller": 2,
80
116
  "no-div-regex": 2,
@@ -116,7 +152,7 @@ module.exports = {
116
152
  "no-shadow-restricted-names": 2,
117
153
  "no-undef-init": 2,
118
154
  "no-undef": 2,
119
- "no-unused-vars": [2, {"vars":"all", "args":"none"}],
155
+ "no-unused-vars": [2, { "vars": "all", "args": "none" }],
120
156
 
121
157
  "brace-style": [2, "1tbs", { "allowSingleLine": true }],
122
158
  "camelcase": [1, { "properties": "never" }], // added for UI5 WebComponents
@@ -132,7 +168,7 @@ module.exports = {
132
168
  "no-new-object": 2,
133
169
  "no-spaced-func": 2,
134
170
  "quote-props": [2, "as-needed", { "keywords": true, "unnecessary": false }],
135
- "semi-spacing": [1, {"before": false, "after": true}],
171
+ "semi-spacing": [1, { "before": false, "after": true }],
136
172
  "semi": 2,
137
173
  "keyword-spacing": 2,
138
174
  "space-infix-ops": 2,
@@ -1,24 +1,58 @@
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 = "/";
6
5
 
7
- const getScripts = (options) => {
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
+ }
8
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) => {
9
23
  // The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
10
24
  const illustrationsData = options.illustrationsData || [];
11
- const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
12
- const createIllustrationsJSImportsScript = illustrations.join(" && ");
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
+
13
39
 
14
- // The script creates the "dist/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
15
- const illustrationDestinationPaths = illustrationsData.map(illustrations => illustrations.destinationPath);
16
- const createIllustrationsLoadersScript = options.fioriPackage ? `node ${LIB}/generate-js-imports/illustrations.js ${illustrationDestinationPaths[0]} ${illustrationDestinationPaths[1]} dist/generated/js-imports` : "";
17
- const tsOption = options.typescript;
18
- const tsCommand = tsOption ? "tsc" : "";
19
- const tsWatchCommand = tsOption ? "tsc --watch" : "";
20
- const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
21
- const copySrcGenerated = tsOption ? "" : "copy.srcGenerated";
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
+ }
22
56
 
23
57
  let viteConfig;
24
58
  if (fs.existsSync("config/vite.config.js")) {
@@ -33,103 +67,114 @@ const getScripts = (options) => {
33
67
  }
34
68
 
35
69
  let eslintConfig;
36
- if (fs.existsSync("config/.eslintrc.js")) {
37
- // old project setup where config file is in separate folder
38
- eslintConfig = "--config config/.eslintrc.js";
39
- } else if (fs.existsSync(".eslintrc.js")) {
70
+ if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
40
71
  // preferred way of custom configuration in root project folder
41
72
  eslintConfig = "";
42
73
  } else {
43
74
  // no custom configuration - use default from tools project
44
- eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
75
+ eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
45
76
  }
46
77
 
47
78
  const scripts = {
48
- clean: 'rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
79
+ __ui5envs: {
80
+ UI5_CEM_MODE: options.dev,
81
+ UI5_TS: `${tsOption}`,
82
+ CYPRESS_COVERAGE: !!(options.internal?.cypress_code_coverage),
83
+ },
84
+ clean: {
85
+ "default": "ui5nps clean.generated clean.dist scope.testPages.clean",
86
+ "generated": `ui5nps-script "${LIB}/rimraf/rimraf.js src/generated`,
87
+ "dist": `ui5nps-script "${LIB}/rimraf/rimraf.js dist`,
88
+ },
49
89
  lint: `eslint . ${eslintConfig}`,
50
- lintfix: `eslint . ${eslintConfig}`,
90
+ lintfix: `eslint . ${eslintConfig} --fix`,
91
+ generate: {
92
+ default: `ui5nps prepare.all`,
93
+ all: `ui5nps-p build.templates build.i18n prepare.styleRelated copyProps build.illustrations`, // concurently
94
+ styleRelated: "ui5nps build.styles build.jsonImports build.jsImports",
95
+ },
51
96
  prepare: {
52
- default: `${tsCrossEnv} nps clean prepare.all typescript generateAPI`,
53
- all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
54
- styleRelated: "nps build.styles build.jsonImports build.jsImports",
97
+ default: `ui5nps clean prepare.all copy copyProps prepare.typescript generateAPI`,
98
+ all: `ui5nps-p build.templates build.i18n prepare.styleRelated build.illustrations`, // concurently
99
+ styleRelated: "ui5nps build.styles build.jsonImports build.jsImports",
100
+ typescript: tsCommandOld,
55
101
  },
56
- typescript: tsCommand,
57
102
  build: {
58
- default: "nps prepare lint build.bundle",
59
- templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
103
+ default: "ui5nps prepare lint build.bundle", // build.bundle2
104
+ templates: options.legacy ? `mkdirp src/generated/templates && node "${LIB}hbs2ui5/index.js" -d src/ -o src/generated/templates` : "",
60
105
  styles: {
61
- default: `nps build.styles.themes build.styles.components ${copySrcGenerated}`,
62
- themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
63
- components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
106
+ default: `ui5nps-p build.styles.themes build.styles.components`, // concurently
107
+ themes: `ui5nps-script "${LIB}css-processors/css-processor-themes.mjs"`,
108
+ themesWithWatch: `ui5nps-script "${LIB}css-processors/css-processor-themes.mjs" -w`,
109
+ components: `ui5nps-script "${LIB}css-processors/css-processor-components.mjs"`,
110
+ componentsWithWatch: `ui5nps-script "${LIB}css-processors/css-processor-components.mjs" -w`,
64
111
  },
65
112
  i18n: {
66
- default: "nps build.i18n.defaultsjs build.i18n.json",
67
- defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
68
- json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
113
+ default: "ui5nps build.i18n.defaultsjs build.i18n.json",
114
+ defaultsjs: `ui5nps-script "${LIB}i18n/defaults.js" src/i18n src/generated/i18n`,
115
+ json: `ui5nps-script "${LIB}i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
69
116
  },
70
117
  jsonImports: {
71
- default: "mkdirp dist/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
72
- themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
73
- i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
118
+ default: "ui5nps build.jsonImports.themes build.jsonImports.i18n",
119
+ themes: `ui5nps-script "${LIB}generate-json-imports/themes.js" src/themes src/generated/json-imports`,
120
+ i18n: `ui5nps-script "${LIB}generate-json-imports/i18n.js" src/i18n src/generated/json-imports`,
74
121
  },
75
122
  jsImports: {
76
- default: "mkdirp dist/generated/js-imports && nps build.jsImports.illustrationsLoaders",
123
+ default: "ui5nps build.jsImports.illustrationsLoaders",
77
124
  illustrationsLoaders: createIllustrationsLoadersScript,
78
125
  },
79
- bundle: `vite build ${viteConfig}`,
126
+ bundle: `vite build ${viteConfig} --mode testing --base ${websiteBaseUrl}`,
127
+ bundle2: ``,
80
128
  illustrations: createIllustrationsJSImportsScript,
81
129
  },
130
+ copyProps: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
131
+ copyPropsWithWatch: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/ --watch --safe --skip-initial-copy`,
82
132
  copy: {
83
- default: "nps copy.src copy.props",
84
- src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
85
- srcGenerated: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.js" dist/generated/`,
86
- props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
133
+ default: options.legacy ? "ui5nps copy.src copy.props" : "",
134
+ src: options.legacy ? `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/` : "",
135
+ props: options.legacy ? `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/` : "",
87
136
  },
88
137
  watch: {
89
- default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.typescript" "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
90
- devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
91
- src: 'nps "copy.src --watch --safe --skip-initial-copy"',
92
- typescript: tsWatchCommand,
93
- props: 'nps "copy.props --watch --safe --skip-initial-copy"',
94
- bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
138
+ default: `ui5nps-p watch.templates watch.typescript watch.src watch.styles watch.i18n watch.props`, // concurently
139
+ devServer: 'ui5nps-p watch.default watch.bundle', // concurently
140
+ src: options.legacy ? 'ui5nps "copy.src --watch --safe --skip-initial-copy"' : "",
141
+ typescript: tsWatchCommandStandalone,
142
+ props: 'ui5nps copyPropsWithWatch',
143
+ bundle: `ui5nps-script ${LIB}dev-server/dev-server.mjs ${viteConfig}`,
95
144
  styles: {
96
- default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
97
- themes: 'nps "build.styles.themes -w"',
98
- components: {
99
- default: 'concurrently "nps watch.styles.components.existingFiles" "nps watch.styles.components.newFiles"',
100
- existingFiles: `nps "build.styles.components -w"`,
101
- newFiles: `node "${LIB}/postcss-new-files/index.js" --srcFiles="src/themes/*.css"`,
102
- },
145
+ default: 'ui5nps-p watch.styles.themes watch.styles.components', // concurently
146
+ themes: 'ui5nps build.styles.themesWithWatch',
147
+ components: `ui5nps build.styles.componentsWithWatch`,
103
148
  },
104
- templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
105
- api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
106
- i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
149
+ templates: options.legacy ? 'chokidar "src/**/*.hbs" -i "src/generated" -c "ui5nps build.templates"' : "",
150
+ i18n: 'chokidar "src/i18n/messagebundle.properties" -c "ui5nps build.i18n.defaultsjs"'
107
151
  },
108
- start: "nps prepare watch.devServer",
109
- test: `node "${LIB}/test-runner/test-runner.js"`,
110
- "test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
111
- "test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
112
- startWithScope: "nps scope.prepare scope.watchWithBundle",
152
+ start: "ui5nps prepare watch.devServer",
153
+ test: `ui5nps-script "${LIB}/test-runner/test-runner.js"`,
154
+ "test-cy-ci": `cypress run --component --browser chrome`,
155
+ "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}"`,
156
+ "test-cy-ci-suite-2": `cypress run --component --browser chrome --spec "**/specs/[D-L]*.cy.{js,jsx,ts,tsx}"`,
157
+ "test-cy-ci-suite-3": `cypress run --component --browser chrome --spec "**/specs/[M-S]*.cy.{js,jsx,ts,tsx}"`,
158
+ "test-cy-ci-suite-4": `cypress run --component --browser chrome --spec "**/specs/[T-Z]*.cy.{js,jsx,ts,tsx}"`,
159
+ "test-cy-open": `cypress open --component --browser chrome`,
160
+ startWithScope: "ui5nps scope.prepare scope.watchWithBundle",
113
161
  scope: {
114
- prepare: "nps scope.lint prepare scope.testPages",
115
- lint: `node "${LIB}/scoping/lint-src.js"`,
162
+ prepare: "ui5nps scope.lint scope.testPages",
163
+ lint: `ui5nps-script "${LIB}scoping/lint-src.js"`,
116
164
  testPages: {
117
- default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
118
- clean: "rimraf test/pages/scoped",
119
- copy: `node "${LIB}/copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
120
- replace: `node "${LIB}/scoping/scope-test-pages.js" test/pages/scoped demo`,
165
+ default: "ui5nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
166
+ "clean": `ui5nps-script "${LIB}/rimraf/rimraf.js test/pages/scoped`,
167
+ copy: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
168
+ replace: `ui5nps-script "${LIB}scoping/scope-test-pages.js" test/pages/scoped demo`,
121
169
  },
122
- watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
123
- watch: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.props" "nps watch.styles"',
124
- bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
170
+ watchWithBundle: 'ui5nps-p scope.watch scope.bundle', // concurently
171
+ watch: 'ui5nps-p watch.templates watch.props watch.styles', // concurently
172
+ bundle: `ui5nps-script ${LIB}dev-server/dev-server.mjs ${viteConfig}`,
125
173
  },
126
174
  generateAPI: {
127
- default: "nps generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup generateAPI.prepareManifest",
128
- prepare: `node "${LIB}/copy-and-watch/index.js" --silent "dist/**/*.js" jsdoc-dist/`,
129
- prepareManifest: `node "${LIB}/generate-custom-elements-manifest/index.js" dist dist`,
130
- preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
131
- jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
132
- cleanup: "rimraf jsdoc-dist/"
175
+ default: tsOption ? "ui5nps generateAPI.generateCEM generateAPI.validateCEM" : "",
176
+ generateCEM: `ui5nps-script "${LIB}cem/cem.js" analyze --config "${LIB}cem/custom-elements-manifest.config.mjs"`,
177
+ validateCEM: `ui5nps-script "${LIB}cem/validate.js"`,
133
178
  },
134
179
  };
135
180
 
@@ -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.
@@ -223,12 +237,11 @@ exports.config = {
223
237
  }, this, attrName);
224
238
  }, true);
225
239
 
226
- await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
227
- return browser.executeAsync(async (selector, done) => {
228
- const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
229
- done(staticAreaItem.host.classList[0]);
230
- }, selector);
231
- }, false);
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);
232
245
 
233
246
  await browser.addLocatorStrategy('activeElement', (selector) => {
234
247
  return document.querySelector(selector).shadowRoot.activeElement;
@@ -245,11 +258,11 @@ exports.config = {
245
258
  "$$",
246
259
  "getAttribute",
247
260
  "hasAttribute", // custom
261
+ "matches", // custom
248
262
  "getCSSProperty",
249
263
  "getHTML",
250
264
  "getProperty",
251
265
  "getSize",
252
- "getStaticAreaItemClassName", // custom
253
266
  "getText",
254
267
  "getValue",
255
268
  "hasClass", // custom
@@ -261,7 +274,7 @@ exports.config = {
261
274
  "isFocusedDeep", // custom
262
275
  "isFocusedDeepElement", // custom
263
276
  "shadow$",
264
- "shadow$$",
277
+ "shadow$$"
265
278
  ];
266
279
  if (waitFor.includes(commandName)) {
267
280
  await browser.executeAsync(function (done) {
@@ -298,8 +311,17 @@ exports.config = {
298
311
  * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
299
312
  * @param {Object} test test details
300
313
  */
301
- // afterTest: function (test) {
302
- // },
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
+ },
303
325
  /**
304
326
  * Hook that gets executed after the suite has ended
305
327
  * @param {Object} suite suite details
@@ -381,8 +403,14 @@ exports.config = {
381
403
  * @param {Array.<Object>} capabilities list of capabilities details
382
404
  * @param {<Object>} results object containing test results
383
405
  */
384
- // onComplete: function(exitCode, config, capabilities, results) {
385
- // },
406
+ onComplete: function (exitCode, config, capabilities, results) {
407
+ // The results object looks like: { finished: 0, passed: 0, retries: 0, failed: 0 }.
408
+ // If all values are 0, consider that no tests were found or executed.
409
+ if (exitCode === 1 && Object.values(results).every(result => result === 0)) {
410
+ console.log("✅ No specs were found or executed – treating as success.");
411
+ process.exit(0);
412
+ }
413
+ }
386
414
  /**
387
415
  * Gets executed when a refresh happens.
388
416
  * @param {String} oldSessionId session ID of the old session