@ui5/webcomponents-tools 0.0.0-f2abb18c2 → 0.0.0-f42e7c18c

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 +1620 -4
  2. package/README.md +6 -9
  3. package/assets-meta.js +26 -6
  4. package/bin/dev.js +1 -5
  5. package/components-package/cypress/support/commands.js +39 -0
  6. package/components-package/cypress/support/component-index.html +17 -0
  7. package/components-package/cypress/support/component.d.ts +23 -0
  8. package/components-package/cypress/support/component.js +34 -0
  9. package/components-package/cypress.config.js +19 -0
  10. package/components-package/eslint.js +98 -2
  11. package/components-package/nps.js +116 -55
  12. package/components-package/postcss.components.js +1 -21
  13. package/components-package/postcss.themes.js +1 -23
  14. package/components-package/vite.config.js +13 -0
  15. package/components-package/wdio.js +110 -39
  16. package/icons-collection/nps.js +54 -11
  17. package/lib/amd-to-es6/index.js +102 -0
  18. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  19. package/lib/cem/custom-elements-manifest.config.mjs +527 -0
  20. package/lib/cem/event.mjs +168 -0
  21. package/lib/cem/schema-internal.json +1413 -0
  22. package/lib/cem/schema.json +1098 -0
  23. package/lib/cem/types-internal.d.ts +808 -0
  24. package/lib/cem/types.d.ts +736 -0
  25. package/lib/cem/utils.mjs +408 -0
  26. package/lib/cem/validate.js +70 -0
  27. package/lib/copy-and-watch/index.js +30 -5
  28. package/lib/copy-list/index.js +28 -0
  29. package/lib/create-icons/index.js +126 -52
  30. package/lib/create-illustrations/index.js +182 -0
  31. package/lib/create-new-component/index.js +63 -97
  32. package/lib/create-new-component/tsFileContentTemplate.js +71 -0
  33. package/lib/css-processors/css-processor-components.mjs +77 -0
  34. package/lib/css-processors/css-processor-themes.mjs +79 -0
  35. package/lib/css-processors/scope-variables.mjs +49 -0
  36. package/lib/css-processors/shared.mjs +76 -0
  37. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  38. package/lib/dev-server/dev-server.mjs +66 -0
  39. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  40. package/lib/generate-js-imports/illustrations.js +86 -0
  41. package/lib/generate-json-imports/i18n.js +66 -37
  42. package/lib/generate-json-imports/themes.js +55 -34
  43. package/lib/hbs2lit/src/compiler.js +24 -4
  44. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  45. package/lib/hbs2lit/src/litVisitor2.js +113 -25
  46. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  47. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +40 -14
  48. package/lib/hbs2ui5/index.js +57 -24
  49. package/lib/i18n/defaults.js +66 -57
  50. package/lib/i18n/toJSON.js +13 -12
  51. package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
  52. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  53. package/lib/scoping/get-all-tags.js +11 -11
  54. package/lib/scoping/lint-src.js +9 -8
  55. package/lib/scoping/missing-dependencies.js +65 -0
  56. package/lib/scoping/report-tags-usage.js +28 -0
  57. package/lib/scoping/scope-test-pages.js +2 -1
  58. package/lib/test-runner/test-runner.js +71 -0
  59. package/package.json +59 -53
  60. package/tsconfig.json +16 -0
  61. package/types/index.d.ts +1 -0
  62. package/bin/init-ui5-package.js +0 -3
  63. package/components-package/rollup.js +0 -147
  64. package/components-package/serve.json +0 -3
  65. package/lib/documentation/index.js +0 -143
  66. package/lib/documentation/templates/api-component-since.js +0 -3
  67. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  68. package/lib/documentation/templates/api-events-section.js +0 -35
  69. package/lib/documentation/templates/api-methods-section.js +0 -26
  70. package/lib/documentation/templates/api-properties-section.js +0 -40
  71. package/lib/documentation/templates/api-slots-section.js +0 -28
  72. package/lib/documentation/templates/template.js +0 -38
  73. package/lib/init-package/index.js +0 -123
  74. package/lib/init-package/resources/.eslintignore +0 -3
  75. package/lib/init-package/resources/bundle.es5.js +0 -25
  76. package/lib/init-package/resources/bundle.esm.js +0 -34
  77. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  78. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  79. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  80. package/lib/init-package/resources/config/rollup.config.js +0 -1
  81. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  82. package/lib/init-package/resources/package-scripts.js +0 -11
  83. package/lib/init-package/resources/src/Assets.js +0 -5
  84. package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
  85. package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
  86. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  87. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  88. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  89. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  90. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  91. package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
  92. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  93. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  94. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  95. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  96. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  97. package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  98. package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  99. package/lib/init-package/resources/test/pages/index.html +0 -56
  100. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
  101. package/lib/jsdoc/config.json +0 -29
  102. package/lib/jsdoc/plugin.js +0 -2407
  103. package/lib/jsdoc/template/publish.js +0 -4092
  104. package/lib/postcss-css-to-esm/index.js +0 -42
  105. package/lib/postcss-css-to-json/index.js +0 -27
  106. package/package-lock.json +0 -48
package/README.md CHANGED
@@ -1,24 +1,21 @@
1
- ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/master/docs/images/UI5_logo_wide.png)
1
+ # ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_water.png)UI5 Web Components - Tools
2
2
 
3
- # UI5 Web Components - Tools
4
-
5
- [![Travis CI Build Status](https://travis-ci.org/SAP/ui5-webcomponents.svg?branch=master)](https://travis-ci.org/SAP/ui5-webcomponents)
6
3
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
7
4
 
8
5
  Provides libraries, configuration files and build artifacts,
9
6
  used by other UI5 Web Components packages, such as `main` and `fiori`.
10
7
 
11
8
  ## Resources
12
- - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/master/README.md)
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
- We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/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/).
18
15
 
19
16
  ## Contribute
20
- Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/CONTRIBUTING.md).
17
+ Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
21
18
 
22
19
  ## License
23
20
  Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
24
- This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/master/LICENSE.txt) file.
21
+ This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/main/LICENSE.txt) file.
package/assets-meta.js CHANGED
@@ -1,15 +1,20 @@
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
- "sap_fiori_3_hcw"
12
- ]
8
+ "sap_fiori_3_hcw",
9
+ "sap_horizon",
10
+ "sap_horizon_dark",
11
+ "sap_horizon_hcb",
12
+ "sap_horizon_hcw",
13
+ "sap_horizon_exp",
14
+ "sap_horizon_dark_exp",
15
+ "sap_horizon_hcb_exp",
16
+ "sap_horizon_hcw_exp",
17
+ ],
13
18
  },
14
19
  "languages": {
15
20
  "default": "en",
@@ -17,18 +22,27 @@ const assetsMeta = {
17
22
  "ar",
18
23
  "bg",
19
24
  "ca",
25
+ "cnr",
20
26
  "cs",
27
+ "cy",
21
28
  "da",
22
29
  "de",
23
30
  "el",
24
31
  "en",
32
+ "en_GB",
33
+ "en_US_sappsd",
34
+ "en_US_saprigi",
35
+ "en_US_saptrc",
25
36
  "es",
37
+ "es_MX",
26
38
  "et",
27
39
  "fi",
28
40
  "fr",
41
+ "fr_CA",
29
42
  "hi",
30
43
  "hr",
31
44
  "hu",
45
+ "in",
32
46
  "it",
33
47
  "iw",
34
48
  "ja",
@@ -36,16 +50,19 @@ const assetsMeta = {
36
50
  "ko",
37
51
  "lt",
38
52
  "lv",
53
+ "mk",
39
54
  "ms",
40
55
  "nl",
41
56
  "no",
42
57
  "pl",
58
+ "pt_PT",
43
59
  "pt",
44
60
  "ro",
45
61
  "ru",
46
62
  "sh",
47
63
  "sk",
48
64
  "sl",
65
+ "sr",
49
66
  "sv",
50
67
  "th",
51
68
  "tr",
@@ -63,6 +80,7 @@ const assetsMeta = {
63
80
  "ar_SA",
64
81
  "bg",
65
82
  "ca",
83
+ "cnr",
66
84
  "cs",
67
85
  "da",
68
86
  "de",
@@ -110,6 +128,7 @@ const assetsMeta = {
110
128
  "lt",
111
129
  "lv",
112
130
  "ms",
131
+ "mk",
113
132
  "nb",
114
133
  "nl",
115
134
  "nl_BE",
@@ -122,6 +141,7 @@ const assetsMeta = {
122
141
  "sk",
123
142
  "sl",
124
143
  "sr",
144
+ "sr_Latn",
125
145
  "sv",
126
146
  "th",
127
147
  "tr",
package/bin/dev.js CHANGED
@@ -10,11 +10,7 @@ if (command === "watch") {
10
10
  command = `watch.${argument}`;
11
11
  }
12
12
  } else if (command === "test") {
13
- if (argument === "--no-server") { // yarn test --no-server
14
- command = `test.run`;
15
- } else if (argument) { // yarn test test/specs/Button.spec.js
16
- command = `test.spec --spec ${argument}`;
17
- }
13
+ command = `test ${process.argv.slice(3).join(" ")}`;
18
14
  }
19
15
 
20
16
  child_process.execSync(`npx nps "${command}"`, {stdio: 'inherit'});
@@ -0,0 +1,39 @@
1
+ /// <reference types="cypress" />
2
+ // ***********************************************
3
+ // This example commands.ts shows you how to
4
+ // create various custom commands and overwrite
5
+ // existing commands.
6
+ //
7
+ // For more comprehensive examples of custom
8
+ // commands please read more here:
9
+ // https://on.cypress.io/custom-commands
10
+ // ***********************************************
11
+ //
12
+ //
13
+ // -- This is a parent command --
14
+ // Cypress.Commands.add('login', (email, password) => { ... })
15
+ //
16
+ //
17
+ // -- This is a child command --
18
+ // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19
+ //
20
+ //
21
+ // -- This is a dual command --
22
+ // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23
+ //
24
+ //
25
+ // -- This will overwrite an existing command --
26
+ // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27
+ //
28
+ // declare global {
29
+ // namespace Cypress {
30
+ // interface Chainable {
31
+ // login(email: string, password: string): Chainable<void>
32
+ // drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33
+ // dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34
+ // visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35
+ // }
36
+ // }
37
+ // }
38
+
39
+ import "cypress-real-events";
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
8
+ <meta name="sap-allowedThemeOrigins" content="https://example.com">
9
+ <title>Components App</title>
10
+ <script data-ui5-config type="application/json">{}</script>
11
+ </head>
12
+
13
+ <body>
14
+ <div data-cy-root></div>
15
+ </body>
16
+
17
+ </html>
@@ -0,0 +1,23 @@
1
+ /// <reference types="cypress" />
2
+ import { RenderOptions, HTMLTemplateResult } from 'lit';
3
+ import "cypress-real-events";
4
+
5
+ export type Renderable = HTMLTemplateResult;
6
+ export interface MountUI5Options extends MountLitTemplateOptions {
7
+ ui5Configuration: object;
8
+ }
9
+ export type MountOptions = Partial<MountUI5Options>;
10
+ export declare function mount<T extends keyof HTMLElementTagNameMap = any>(component: string | Renderable, options?: MountOptions): Cypress.Chainable<JQuery<HTMLElementTagNameMap[T]>>;
11
+ declare global {
12
+ namespace Cypress {
13
+ interface Chainable {
14
+ /**
15
+ * Mount your component into Cypress sandbox
16
+ * @param component content to render by lit-html render function
17
+ * @param options render options for custom rendering
18
+ */
19
+ mount: typeof mount;
20
+ }
21
+ }
22
+ }
23
+
@@ -0,0 +1,34 @@
1
+ import { setupHooks } from '@cypress/mount-utils';
2
+ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
3
+ import { mount } from 'cypress-ct-lit'
4
+ import "./commands.js";
5
+
6
+ let dispose;
7
+
8
+ function cleanup() {
9
+ dispose?.();
10
+ }
11
+
12
+ function ui5Mount(component, options = {}) {
13
+ const configurationScript = document.head.querySelector("script[data-ui5-config]")
14
+ cleanup();
15
+
16
+ if (options.ui5Configuration) {
17
+ configurationScript.innerHTML = JSON.stringify(options.ui5Configuration);
18
+
19
+ }
20
+
21
+ dispose = () => {
22
+ configurationScript.innerHTML = "{}";
23
+ }
24
+
25
+ if (typeof component === "string") {
26
+ return mount(unsafeHTML(component), options)
27
+ }
28
+
29
+ return mount(component, options)
30
+ }
31
+
32
+ setupHooks(cleanup);
33
+
34
+ Cypress.Commands.add('mount', ui5Mount)
@@ -0,0 +1,19 @@
1
+ const { defineConfig } = require('cypress')
2
+ const path = require("path");
3
+
4
+ module.exports = defineConfig({
5
+ component: {
6
+ supportFile: path.join(__dirname, "cypress/support/component.js"),
7
+ indexHtmlFile: path.join(__dirname, "cypress/support/component-index.html"),
8
+ specPattern: ["**/specs/*.cy.{js,ts}", "**/specs/**/*.cy.{js,ts}"],
9
+ devServer: {
10
+ framework: 'cypress-ct-lit',
11
+ bundler: 'vite',
12
+ }
13
+ },
14
+ video: false,
15
+ screenshotOnRunFailure: false,
16
+ scrollBehavior: false,
17
+ viewportHeight: 1080,
18
+ viewportWidth: 1440,
19
+ })
@@ -1,3 +1,97 @@
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
+ "./cypress/tsconfig.json",
22
+ ],
23
+ EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
24
+ },
25
+ rules: {
26
+ "no-shadow": "off",
27
+ "@typescript-eslint/consistent-type-imports": "error",
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.rules = {
45
+ ...tsxConfiguration.rules,
46
+ "@typescript-eslint/unbound-method": "off", // to be able to attach on* listeners
47
+ "@typescript-eslint/no-misused-promises": "off", // to be able to have async event listeners
48
+ "operator-linebreak": "off",
49
+ "no-nested-ternary": "off",
50
+ "implicit-arrow-linebreak": "off",
51
+ "function-paren-newline": "off",
52
+ "comma-dangle": "off"
53
+ };
54
+
55
+ const cypressConfiguration = {
56
+ "files": ["**/cypress/**/*.ts"],
57
+
58
+ "plugins": [
59
+ "cypress"
60
+ ],
61
+ extends: [
62
+ "plugin:cypress/recommended"
63
+ ],
64
+ "env": {
65
+ "cypress/globals": true
66
+ },
67
+ "rules": {
68
+ "max-nested-callbacks": 0,
69
+ "@typescript-eslint/no-namespace": "off",
70
+ "cypress/no-assigning-return-values": "error",
71
+ "cypress/no-unnecessary-waiting": "error",
72
+ "cypress/assertion-before-screenshot": "warn",
73
+ "cypress/no-force": "warn",
74
+ "cypress/no-async-tests": "error",
75
+ "cypress/no-async-before": "error",
76
+ "cypress/no-pause": "error",
77
+ "import/no-extraneous-dependencies": [
78
+ "error",
79
+ {
80
+ "devDependencies": [
81
+ "**/cypress/**/*.ts"
82
+ ]
83
+ }
84
+ ]
85
+ }
86
+ }
87
+
88
+ return [
89
+ tsConfiguration,
90
+ tsxConfiguration,
91
+ cypressConfiguration,
92
+ ];
93
+ }
94
+
1
95
  module.exports = {
2
96
  "env": {
3
97
  "browser": true,
@@ -5,6 +99,7 @@ module.exports = {
5
99
  },
6
100
  "root": true,
7
101
  "extends": "airbnb-base",
102
+ "overrides": tsMode ? getTsModeOverrides() : [],
8
103
  "parserOptions": {
9
104
  "ecmaVersion": 2018,
10
105
  "sourceType": "module"
@@ -47,6 +142,7 @@ module.exports = {
47
142
  "curly": [2, "all"],
48
143
  // "default-case": 1, // removed for UI5 WebComponents
49
144
  "import/extensions": ["error", "always"], // override for UI5 WebComponents
145
+ "import/order": "off",
50
146
  "no-alert": 2,
51
147
  "no-caller": 2,
52
148
  "no-div-regex": 2,
@@ -88,7 +184,7 @@ module.exports = {
88
184
  "no-shadow-restricted-names": 2,
89
185
  "no-undef-init": 2,
90
186
  "no-undef": 2,
91
- "no-unused-vars": [2, {"vars":"all", "args":"none"}],
187
+ "no-unused-vars": [2, { "vars": "all", "args": "none" }],
92
188
 
93
189
  "brace-style": [2, "1tbs", { "allowSingleLine": true }],
94
190
  "camelcase": [1, { "properties": "never" }], // added for UI5 WebComponents
@@ -104,7 +200,7 @@ module.exports = {
104
200
  "no-new-object": 2,
105
201
  "no-spaced-func": 2,
106
202
  "quote-props": [2, "as-needed", { "keywords": true, "unnecessary": false }],
107
- "semi-spacing": [1, {"before": false, "after": true}],
203
+ "semi-spacing": [1, { "before": false, "after": true }],
108
204
  "semi": 2,
109
205
  "keyword-spacing": 2,
110
206
  "space-infix-ops": 2,
@@ -1,89 +1,150 @@
1
1
  const path = require("path");
2
-
2
+ const fs = require("fs");
3
3
  const LIB = path.join(__dirname, `../lib/`);
4
- const serveConfig = path.join(__dirname, `serve.json`);
5
- const polyfillDir = path.dirname(require.resolve("@webcomponents/webcomponentsjs"));
6
- const polyfillPath = path.join(polyfillDir, "{*.js,*.map,*.md,bundles/**/*.*}");
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
+ }
7
11
 
8
12
  const getScripts = (options) => {
9
13
 
10
- const port = options.port;
14
+ // The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
15
+ const illustrationsData = options.illustrationsData || [];
16
+ const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath} ${illustration.collection}`);
17
+ const createIllustrationsJSImportsScript = illustrations.join(" && ");
18
+
19
+ // The script creates the "src/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
20
+ 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(" && ");
21
+
22
+ const tsOption = !options.legacy;
23
+ const tsCommandOld = tsOption ? "tsc" : "";
24
+ let tsWatchCommandStandalone = tsOption ? "tsc --watch" : "";
25
+ // this command is only used for standalone projects. monorepo projects get their watch from vite, so opt-out here
26
+ if (options.noWatchTS) {
27
+ tsWatchCommandStandalone = "";
28
+ }
29
+ const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
30
+
31
+ if (tsOption) {
32
+ try {
33
+ require("typescript");
34
+ } catch(e) {
35
+ 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.`);
36
+ process.exit(e.code);
37
+ }
38
+ }
39
+
40
+ let viteConfig;
41
+ if (fs.existsSync("config/vite.config.js")) {
42
+ // old project setup where config file is in separate folder
43
+ viteConfig = "-c config/vite.config.js";
44
+ } else if (fs.existsSync("vite.config.js")) {
45
+ // preferred way of custom configuration in root project folder
46
+ viteConfig = "";
47
+ } else {
48
+ // no custom configuration - use default from tools project
49
+ viteConfig = `-c "${require.resolve("@ui5/webcomponents-tools/components-package/vite.config.js")}"`;
50
+ }
51
+
52
+ let eslintConfig;
53
+ if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
54
+ // preferred way of custom configuration in root project folder
55
+ eslintConfig = "";
56
+ } else {
57
+ // no custom configuration - use default from tools project
58
+ eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
59
+ }
11
60
 
12
61
  const scripts = {
13
- clean: "rimraf dist",
14
- lint: "eslint . --config config/.eslintrc.js",
15
- prepare: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples",
62
+ clean: 'rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
63
+ lint: `eslint . ${eslintConfig}`,
64
+ lintfix: `eslint . ${eslintConfig} --fix`,
65
+ generate: {
66
+ default: `${tsCrossEnv} nps prepare.all`,
67
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copyProps" "nps build.illustrations"',
68
+ styleRelated: "nps build.styles build.jsonImports build.jsImports",
69
+ },
70
+ prepare: {
71
+ default: `${tsCrossEnv} nps clean prepare.all ${options.legacy ? "copy" : ""} copyProps prepare.typescript generateAPI`,
72
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps build.illustrations"',
73
+ styleRelated: "nps build.styles build.jsonImports build.jsImports",
74
+ typescript: tsCommandOld,
75
+ },
16
76
  build: {
17
- default: "nps lint prepare build.bundle",
18
- templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
77
+ default: "nps prepare lint build.bundle", // build.bundle2
78
+ templates: `mkdirp src/generated/templates && ${tsCrossEnv} node "${LIB}/hbs2ui5/index.js" -d src/ -o src/generated/templates`,
19
79
  styles: {
20
- default: "nps build.styles.themes build.styles.components",
21
- themes: "postcss src/**/parameters-bundle.css --config config/postcss.themes --base src --dir dist/css/",
22
- components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/",
80
+ default: `concurrently "nps build.styles.themes" "nps build.styles.components"`,
81
+ themes: `node "${LIB}/css-processors/css-processor-themes.mjs"`,
82
+ components: `node "${LIB}/css-processors/css-processor-components.mjs"`,
23
83
  },
24
84
  i18n: {
25
85
  default: "nps build.i18n.defaultsjs build.i18n.json",
26
- defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
86
+ defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
27
87
  json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
28
88
  },
29
89
  jsonImports: {
30
- default: "mkdirp dist/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
31
- themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
32
- i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
90
+ default: "mkdirp src/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
91
+ themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes src/generated/json-imports`,
92
+ i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n src/generated/json-imports`,
33
93
  },
34
- bundle: "rollup --config config/rollup.config.js --environment ES5_BUILD",
35
- samples: {
36
- default: "nps build.samples.api build.samples.docs",
37
- api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
38
- docs: `node "${LIB}/documentation/index.js" dist/api.json`,
39
- }
94
+ jsImports: {
95
+ default: "mkdirp src/generated/js-imports && nps build.jsImports.illustrationsLoaders",
96
+ illustrationsLoaders: createIllustrationsLoadersScript,
97
+ },
98
+ bundle: `vite build ${viteConfig} --mode testing --base ${websiteBaseUrl}`,
99
+ bundle2: ``,
100
+ illustrations: createIllustrationsJSImportsScript,
40
101
  },
102
+ copyProps: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
41
103
  copy: {
42
- default: "nps copy.src copy.test copy.webcomponents-polyfill",
43
- src: `node "${LIB}/copy-and-watch/index.js" "src/**/*.js" dist/`,
44
- test: `node "${LIB}/copy-and-watch/index.js" "test/**/*.*" dist/test-resources`,
45
- "webcomponents-polyfill": `node "${LIB}/copy-and-watch/index.js" "${polyfillPath}" dist/webcomponentsjs/`,
104
+ default: "nps copy.src copy.props",
105
+ src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/`,
106
+ props: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
46
107
  },
47
108
  watch: {
48
- default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles"',
109
+ default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.typescript" ${options.legacy ? '"nps watch.src"' : ""} "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
110
+ devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
49
111
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
50
- test: 'nps "copy.test --watch --safe --skip-initial-copy"',
51
- bundle: "rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,DEPLOY_PUBLIC_PATH:/resources/",
112
+ typescript: tsWatchCommandStandalone,
113
+ props: 'nps "copyProps --watch --safe --skip-initial-copy"',
114
+ bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
52
115
  styles: {
53
116
  default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
54
117
  themes: 'nps "build.styles.themes -w"',
55
- components: 'nps "build.styles.components -w"',
118
+ components: `nps "build.styles.components -w"`,
56
119
  },
57
- templates: "chokidar \"src/**/*.hbs\" -c \"nps build.templates\"",
58
- samples: "chokidar \"test/**/*.sample.html\" -c \"nps build.samples\"",
59
- },
60
- dev: 'concurrently "nps serve" "nps watch"',
61
- start: "nps prepare dev",
62
- serve: {
63
- default: "nps serve.prepare serve.run",
64
- prepare: `node "${LIB}/copy-and-watch/index.js" "${serveConfig}" dist/`,
65
- run: `serve --no-clipboard -l ${port} dist`,
120
+ templates: 'chokidar "src/**/*.hbs" -i "src/generated" -c "nps build.templates"',
121
+ i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
66
122
  },
67
- test: {
68
- // --success first - report the exit code of the test run (first command to finish), as serve is always terminated and has a non-0 exit code
69
- default: 'concurrently "nps serve" "nps test.run" --kill-others --success first',
70
- run: "cross-env WDIO_LOG_LEVEL=error FORCE_COLOR=0 wdio config/wdio.conf.js",
71
- spec: "wdio run config/wdio.conf.js",
72
- },
73
- startWithScope: "nps scope.prepare scope.dev",
123
+ start: "nps prepare watch.devServer",
124
+ test: `node "${LIB}/test-runner/test-runner.js"`,
125
+ "test-cy-ci": `yarn cypress run --component --browser chrome`,
126
+ "test-cy-open": `yarn cypress open --component --browser chrome`,
127
+ "test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
128
+ "test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
129
+ startWithScope: "nps scope.prepare scope.watchWithBundle",
74
130
  scope: {
75
- prepare: "nps scope.lint prepare scope.testPages",
131
+ prepare: "nps scope.lint scope.testPages",
76
132
  lint: `node "${LIB}/scoping/lint-src.js"`,
77
133
  testPages: {
78
134
  default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
79
- clean: "rimraf dist/test-resources/pages/scoped",
80
- copy: `node "${LIB}/copy-and-watch/index.js" "dist/test-resources/pages/**/*" dist/test-resources/scoped`,
81
- replace: `node "${LIB}/scoping/scope-test-pages.js" dist/test-resources/scoped demo`,
135
+ clean: "rimraf test/pages/scoped",
136
+ copy: `node "${LIB}/copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
137
+ replace: `node "${LIB}/scoping/scope-test-pages.js" test/pages/scoped demo`,
82
138
  },
83
- dev: 'concurrently "nps serve" "nps scope.watch"',
84
- watch: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps scope.bundle" "nps watch.styles"',
85
- bundle: "rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,SCOPE"
86
- }
139
+ watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
140
+ watch: 'concurrently "nps watch.templates" "nps watch.props" "nps watch.styles"',
141
+ bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
142
+ },
143
+ generateAPI: {
144
+ default: tsOption ? "nps generateAPI.generateCEM generateAPI.validateCEM" : "",
145
+ generateCEM: `cem analyze --config "${LIB}/cem/custom-elements-manifest.config.mjs" ${ options.dev ? "--dev" : "" }`,
146
+ validateCEM: `node "${LIB}/cem/validate.js" ${ options.dev ? "--dev" : "" }`,
147
+ },
87
148
  };
88
149
 
89
150
  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 = {}