@ui5/webcomponents-tools 0.0.0-998083e44 → 0.0.0-99b763015

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,199 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.12.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.1...v1.12.0-rc.2) (2023-03-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix eslint for JS 3rd party projects ([#6725](https://github.com/SAP/ui5-webcomponents/issues/6725)) ([215a888](https://github.com/SAP/ui5-webcomponents/commit/215a888b006e46d431edd6324812b9d39249aef4))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.12.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.0...v1.12.0-rc.1) (2023-03-16)
18
+
19
+ **Note:** Version bump only for package @ui5/webcomponents-tools
20
+
21
+
22
+
23
+
24
+
25
+ # [1.12.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0...v1.12.0-rc.0) (2023-03-09)
26
+
27
+
28
+ ### Features
29
+
30
+ * enhance create-ui5-element command to create component in TS ([#6609](https://github.com/SAP/ui5-webcomponents/issues/6609)) ([d870065](https://github.com/SAP/ui5-webcomponents/commit/d8700650a4e5991862e2076cc2c93482011c4c90))
31
+
32
+
33
+
34
+
35
+
36
+ # [1.11.0](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.4...v1.11.0) (2023-03-06)
37
+
38
+ **Note:** Version bump only for package @ui5/webcomponents-tools
39
+
40
+
41
+
42
+
43
+
44
+ # [1.11.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.3...v1.11.0-rc.4) (2023-03-02)
45
+
46
+ **Note:** Version bump only for package @ui5/webcomponents-tools
47
+
48
+
49
+
50
+
51
+
52
+ # [1.11.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.2...v1.11.0-rc.3) (2023-02-23)
53
+
54
+
55
+ ### Features
56
+
57
+ * **playground:** next playground with storybook ([#5831](https://github.com/SAP/ui5-webcomponents/issues/5831)) ([79274c8](https://github.com/SAP/ui5-webcomponents/commit/79274c8e442cf5854a7fe6327f25aaed04312103)), closes [#5898](https://github.com/SAP/ui5-webcomponents/issues/5898)
58
+
59
+
60
+
61
+
62
+
63
+ # [1.11.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.1...v1.11.0-rc.2) (2023-02-16)
64
+
65
+ **Note:** Version bump only for package @ui5/webcomponents-tools
66
+
67
+
68
+
69
+
70
+
71
+ # [1.11.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.0...v1.11.0-rc.1) (2023-02-09)
72
+
73
+ **Note:** Version bump only for package @ui5/webcomponents-tools
74
+
75
+
76
+
77
+
78
+
79
+ # [1.11.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.10.4-rc.0...v1.11.0-rc.0) (2023-02-02)
80
+
81
+ **Note:** Version bump only for package @ui5/webcomponents-tools
82
+
83
+
84
+
85
+
86
+
87
+ ## [1.10.4-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.10.3...v1.10.4-rc.0) (2023-01-26)
88
+
89
+ **Note:** Version bump only for package @ui5/webcomponents-tools
90
+
91
+
92
+
93
+
94
+
95
+ ## [1.10.3](https://github.com/SAP/ui5-webcomponents/compare/v1.10.2...v1.10.3) (2023-01-25)
96
+
97
+ **Note:** Version bump only for package @ui5/webcomponents-tools
98
+
99
+
100
+
101
+
102
+
103
+ ## [1.10.2](https://github.com/SAP/ui5-webcomponents/compare/v1.10.1...v1.10.2) (2023-01-25)
104
+
105
+ **Note:** Version bump only for package ui5-webcomponents
106
+
107
+ ## [1.10.1](https://github.com/SAP/ui5-webcomponents/compare/v0.0.0-7b49a7ff1...v1.10.1) (2023-01-24)
108
+
109
+ **Note:** Version bump only for package @ui5/webcomponents-tools
110
+
111
+
112
+
113
+
114
+
115
+ # [1.10.0](https://github.com/SAP/ui5-webcomponents/compare/v1.9.3...v1.10.0) (2023-01-20)
116
+
117
+
118
+ ### Bug Fixes
119
+
120
+ * **infra:** set Content-Type header on testsuite ([#6108](https://github.com/SAP/ui5-webcomponents/issues/6108)) ([fae3f91](https://github.com/SAP/ui5-webcomponents/commit/fae3f91975ab1dad7135bea2227f61986eff403f))
121
+
122
+
123
+ ### Features
124
+
125
+ * enable TS in main, fiori ([#6064](https://github.com/SAP/ui5-webcomponents/issues/6064)) ([0b56130](https://github.com/SAP/ui5-webcomponents/commit/0b561307b93b8af465dc5bee67650069ee138f7f))
126
+ * migrate illustrated-message component to TS, small refactor ([#6195](https://github.com/SAP/ui5-webcomponents/issues/6195)) ([046c779](https://github.com/SAP/ui5-webcomponents/commit/046c779f654648172619dd720c0d90342ec78fb9))
127
+ * support decorators for custom elements metadata ([#6072](https://github.com/SAP/ui5-webcomponents/issues/6072)) ([fc9ee6e](https://github.com/SAP/ui5-webcomponents/commit/fc9ee6e2af10b4315fde072a50ab37efa180c809))
128
+ * **ui5-button, ui5-date-picker, ui5-calendar:** migrate to TS ([#6173](https://github.com/SAP/ui5-webcomponents/issues/6173)) ([7232ca0](https://github.com/SAP/ui5-webcomponents/commit/7232ca08f286c5dde10080373fb62247f1acf7b7)), closes [#6080](https://github.com/SAP/ui5-webcomponents/issues/6080)
129
+ * use Typescript for the `base` package ([#5982](https://github.com/SAP/ui5-webcomponents/issues/5982)) ([bd184d8](https://github.com/SAP/ui5-webcomponents/commit/bd184d81a4218328bc7bf04baf2bc1f69a361679))
130
+
131
+
132
+
133
+
134
+
135
+ ## [1.9.3](https://github.com/SAP/ui5-webcomponents/compare/v1.9.2...v1.9.3) (2022-12-16)
136
+
137
+ **Note:** Version bump only for package @ui5/webcomponents-tools
138
+
139
+
140
+
141
+
142
+
143
+ ## [1.9.1](https://github.com/SAP/ui5-webcomponents/compare/v1.9.0...v1.9.1) (2022-11-10)
144
+
145
+
146
+ ### Bug Fixes
147
+
148
+ * **framework:** fix paths for generating illustration imports in nps ([#5997](https://github.com/SAP/ui5-webcomponents/issues/5997)) ([e932f7d](https://github.com/SAP/ui5-webcomponents/commit/e932f7d069ebf10f73219bff7154558b7b0d849e))
149
+
150
+
151
+
152
+
153
+
154
+ # [1.9.0](https://github.com/SAP/ui5-webcomponents/compare/v1.8.0...v1.9.0) (2022-10-31)
155
+
156
+
157
+ ### Bug Fixes
158
+
159
+ * **framework:** fix contexts management in hbs-2-lit compiler ([#5958](https://github.com/SAP/ui5-webcomponents/issues/5958)) ([94d1619](https://github.com/SAP/ui5-webcomponents/commit/94d16199ed7dc79b21d99a0637533e93af54c90a)), closes [#4701](https://github.com/SAP/ui5-webcomponents/issues/4701)
160
+
161
+
162
+ ### Features
163
+
164
+ * **framework:** fetch illustrations on demand ([#5927](https://github.com/SAP/ui5-webcomponents/issues/5927)) ([f8e1033](https://github.com/SAP/ui5-webcomponents/commit/f8e1033643626261dcad8a38f65c325ba9aff99f))
165
+ * **framework:** generate custom elements manifest ([#5964](https://github.com/SAP/ui5-webcomponents/issues/5964)) ([0d62770](https://github.com/SAP/ui5-webcomponents/commit/0d62770cace54fd9aef73d9632dd06d8a83680e9))
166
+
167
+
168
+
169
+
170
+
171
+ # [1.8.0](https://github.com/SAP/ui5-webcomponents/compare/v1.7.1...v1.8.0) (2022-10-03)
172
+
173
+
174
+ ### Features
175
+
176
+ * **icons:** create type-definitions for icon imports ([#5753](https://github.com/SAP/ui5-webcomponents/issues/5753)) ([2de4a04](https://github.com/SAP/ui5-webcomponents/commit/2de4a045f56e2f166d3e846ff11e6f9d76e98009)), closes [#5747](https://github.com/SAP/ui5-webcomponents/issues/5747) [#5335](https://github.com/SAP/ui5-webcomponents/issues/5335)
177
+ * **main:** add support for custom SVG icons ([#5865](https://github.com/SAP/ui5-webcomponents/issues/5865)) ([d8b7200](https://github.com/SAP/ui5-webcomponents/commit/d8b7200f30c16d94b7f15ddbdf9808d8efbaa38c))
178
+
179
+
180
+
181
+
182
+
183
+ ## [1.7.1](https://github.com/SAP/ui5-webcomponents/compare/v1.7.0...v1.7.1) (2022-09-08)
184
+
185
+ **Note:** Version bump only for package @ui5/webcomponents-tools
186
+
187
+
188
+
189
+
190
+
191
+ # [1.7.0](https://github.com/SAP/ui5-webcomponents/compare/v1.6.0...v1.7.0) (2022-09-02)
192
+
193
+ **Note:** Version bump only for package @ui5/webcomponents-tools
194
+
195
+
196
+
197
+
198
+
6
199
  # [1.6.0](https://github.com/SAP/ui5-webcomponents/compare/v1.5.0...v1.6.0) (2022-07-25)
7
200
 
8
201
 
@@ -1,3 +1,36 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const tsMode = fs.existsSync(path.join(process.cwd(), "tsconfig.json"));
4
+
5
+ /**
6
+ * Typescript Rules
7
+ */
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
+ },
19
+ rules: {
20
+ "no-shadow": "off",
21
+ "@typescript-eslint/no-shadow": ["error"],
22
+ "@typescript-eslint/no-unsafe-member-access": "off",
23
+ "@typescript-eslint/no-floating-promises": "off",
24
+ "@typescript-eslint/no-explicit-any": "off",
25
+ "@typescript-eslint/no-unsafe-assignment": "off",
26
+ "@typescript-eslint/ban-ts-comment": "off",
27
+ "@typescript-eslint/no-unsafe-call": "off",
28
+ "@typescript-eslint/no-non-null-assertion": "off",
29
+ "@typescript-eslint/no-empty-function": "off",
30
+ "lines-between-class-members": "off",
31
+ }
32
+ }] : [];
33
+
1
34
  module.exports = {
2
35
  "env": {
3
36
  "browser": true,
@@ -5,6 +38,7 @@ module.exports = {
5
38
  },
6
39
  "root": true,
7
40
  "extends": "airbnb-base",
41
+ overrides,
8
42
  "parserOptions": {
9
43
  "ecmaVersion": 2018,
10
44
  "sourceType": "module"
@@ -1,13 +1,33 @@
1
1
  const path = require("path");
2
2
  const fs = require("fs");
3
+ const resolve = require("resolve");
3
4
  const LIB = path.join(__dirname, `../lib/`);
4
-
5
+ const preprocessJSDocScript = resolve.sync("@ui5/webcomponents-tools/lib/jsdoc/preprocess.js");
5
6
 
6
7
  const getScripts = (options) => {
7
8
 
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(" && ");
9
+ // The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
10
+ 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(" && ");
13
+
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";
22
+
23
+ if (tsOption) {
24
+ try {
25
+ require("typescript");
26
+ } catch(e) {
27
+ 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.`);
28
+ process.exit(e.code);
29
+ }
30
+ }
11
31
 
12
32
  let viteConfig;
13
33
  if (fs.existsSync("config/vite.config.js")) {
@@ -32,27 +52,28 @@ const getScripts = (options) => {
32
52
  // no custom configuration - use default from tools project
33
53
  eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
34
54
  }
35
-
55
+
36
56
  const scripts = {
37
- clean: 'rimraf dist && rimraf .port && nps "scope.testPages.clean"',
57
+ clean: 'rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
38
58
  lint: `eslint . ${eslintConfig}`,
39
- lintfix: `eslint . ${eslintConfig}`,
59
+ lintfix: `eslint . ${eslintConfig} --fix`,
40
60
  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",
61
+ default: `${tsCrossEnv} nps clean prepare.all typescript generateAPI`,
62
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
63
+ styleRelated: "nps build.styles build.jsonImports build.jsImports",
44
64
  },
65
+ typescript: tsCommand,
45
66
  build: {
46
- default: "nps lint prepare build.bundle",
67
+ default: "nps prepare lint build.bundle",
47
68
  templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
48
69
  styles: {
49
- default: "nps build.styles.themes build.styles.components",
70
+ default: `nps build.styles.themes build.styles.components ${copySrcGenerated}`,
50
71
  themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
51
72
  components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
52
73
  },
53
74
  i18n: {
54
75
  default: "nps build.i18n.defaultsjs build.i18n.json",
55
- defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
76
+ defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
56
77
  json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
57
78
  },
58
79
  jsonImports: {
@@ -60,19 +81,24 @@ const getScripts = (options) => {
60
81
  themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
61
82
  i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
62
83
  },
84
+ jsImports: {
85
+ default: "mkdirp dist/generated/js-imports && nps build.jsImports.illustrationsLoaders",
86
+ illustrationsLoaders: createIllustrationsLoadersScript,
87
+ },
63
88
  bundle: `vite build ${viteConfig}`,
64
- api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
65
- illustrations: illustrationsScript
89
+ illustrations: createIllustrationsJSImportsScript,
66
90
  },
67
91
  copy: {
68
92
  default: "nps copy.src copy.props",
69
93
  src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
94
+ srcGenerated: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.js" dist/generated/`,
70
95
  props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
71
96
  },
72
97
  watch: {
73
- default: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.styles" "nps watch.i18n" "nps watch.props"',
98
+ default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.typescript" "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
74
99
  devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
75
100
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
101
+ typescript: tsWatchCommand,
76
102
  props: 'nps "copy.props --watch --safe --skip-initial-copy"',
77
103
  bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
78
104
  styles: {
@@ -85,7 +111,7 @@ const getScripts = (options) => {
85
111
  },
86
112
  },
87
113
  templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
88
- api: 'chokidar "test/**/*.sample.html" -c "nps build.api"',
114
+ api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
89
115
  i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
90
116
  },
91
117
  start: "nps prepare watch.devServer",
@@ -105,7 +131,15 @@ const getScripts = (options) => {
105
131
  watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
106
132
  watch: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.props" "nps watch.styles"',
107
133
  bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
108
- }
134
+ },
135
+ generateAPI: {
136
+ default: "nps generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup generateAPI.prepareManifest",
137
+ prepare: `node "${LIB}/copy-and-watch/index.js" --silent "dist/**/*.js" jsdoc-dist/`,
138
+ prepareManifest: `node "${LIB}/generate-custom-elements-manifest/index.js" dist dist`,
139
+ preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
140
+ jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
141
+ cleanup: "rimraf jsdoc-dist/"
142
+ },
109
143
  };
110
144
 
111
145
  return scripts;
@@ -6,16 +6,16 @@ const fs = require("fs");
6
6
  const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
7
7
 
8
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
- };
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
+ }
@@ -8,19 +8,19 @@ const fs = require("fs");
8
8
  const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
9
9
 
10
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
- ]
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
26
  };
@@ -56,8 +56,15 @@ exports.config = {
56
56
  'goog:chromeOptions': {
57
57
  // to run chrome headless the following flags are required
58
58
  // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
59
- args: ['--headless', '--disable-gpu'],
60
- // args: ['--disable-gpu'],
59
+ args: [
60
+ 'headless', // start in headless mode
61
+ 'start-maximized', // maximize the window
62
+ 'no-sandbox', // disable sandbox isolation
63
+ 'disable-infobars', // disable the infos
64
+ 'disable-gpu', // on windows disable gpu hw acceleration
65
+ 'disable-extensions', // disable extensions
66
+ 'disable-dev-shm-usage' // disable /dev/shm in CI
67
+ ],
61
68
  }
62
69
  }],
63
70
  //
@@ -217,6 +224,12 @@ exports.config = {
217
224
  }, this, className);
218
225
  }, true);
219
226
 
227
+ await browser.addCommand("hasAttribute", async function(attrName) {
228
+ return browser.executeAsync((elem, attrName, done) => {
229
+ done(elem.hasAttribute(attrName));
230
+ }, this, attrName);
231
+ }, true);
232
+
220
233
  await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
221
234
  return browser.executeAsync(async (selector, done) => {
222
235
  const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
@@ -238,6 +251,7 @@ exports.config = {
238
251
  "$",
239
252
  "$$",
240
253
  "getAttribute",
254
+ "hasAttribute", // custom
241
255
  "getCSSProperty",
242
256
  "getHTML",
243
257
  "getProperty",
@@ -41,15 +41,17 @@ const copyIconAssetsCommand = (options) => {
41
41
  const getScripts = (options) => {
42
42
  const createJSImportsCmd = createIconImportsCommand(options);
43
43
  const copyAssetsCmd = copyIconAssetsCommand(options);
44
+ const tsCommand = options.typescript ? "tsc" : "";
45
+ const tsCrossEnv = options.typescript ? "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,
48
50
  build: {
49
- default: `nps clean copy build.i18n build.icons build.jsonImports`,
51
+ default: `${tsCrossEnv} nps clean copy build.i18n typescript build.icons build.jsonImports`,
50
52
  i18n: {
51
53
  default: "nps build.i18n.defaultsjs build.i18n.json",
52
- defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
54
+ defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
53
55
  json: `mkdirp dist/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
54
56
  },
55
57
  jsonImports: {
@@ -58,6 +60,7 @@ const getScripts = (options) => {
58
60
  },
59
61
  icons: createJSImportsCmd,
60
62
  },
63
+ typescript: tsCommand,
61
64
  };
62
65
 
63
66
  return scripts;
@@ -3,7 +3,7 @@ const path = require("path");
3
3
 
4
4
  const fileList = process.argv[2];
5
5
  const dest = process.argv[3];
6
- const src = "../../node_modules/@openui5/sap.ui.core/src/";
6
+ const src = "@openui5/sap.ui.core/src/";
7
7
 
8
8
  const generate = async () => {
9
9
  const filesToCopy = (await fs.readFile(fileList)).toString();
@@ -15,7 +15,7 @@ const generate = async () => {
15
15
  const trimFile = file => file.trim();
16
16
 
17
17
  return filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
18
- const srcPath = path.join(src, moduleName);
18
+ const srcPath = require.resolve(path.join(src, moduleName), {paths: [process.cwd()]});
19
19
  const destPath = path.join(dest, moduleName);
20
20
 
21
21
  await fs.mkdir(path.dirname(destPath), { recursive: true });
@@ -1,7 +1,7 @@
1
1
  const fs = require("fs").promises;
2
2
  const path = require("path");
3
3
 
4
- const collectionName = process.argv[2] || "SAP-icons";
4
+ const collectionName = process.argv[2] || "SAP-icons-v4";
5
5
  const collectionVersion = process.argv[3];
6
6
  const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
7
7
  const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
@@ -17,7 +17,7 @@ const packageName = "${packageName}";
17
17
 
18
18
  registerIcon(name, { pathData, ltr, collection, packageName });
19
19
 
20
- export default "${name}";
20
+ export default "${collection}/${name}";
21
21
  export { pathData, ltr, accData };`;
22
22
 
23
23
 
@@ -33,21 +33,38 @@ const packageName = "${packageName}";
33
33
 
34
34
  registerIcon(name, { pathData, ltr, accData, collection, packageName });
35
35
 
36
- export default "${name}";
36
+ export default "${collection}/${name}";
37
37
  export { pathData, ltr, accData };`;
38
38
 
39
39
 
40
40
 
41
- const collectionTemplate = (name) => `import { isThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
42
- import {pathData as pathDataV5, ltr, accData} from "./v5/${name}.js";
43
- import {pathData as pathDataV4} from "./v4/${name}.js";
41
+ const collectionTemplate = (name, versions, fullName) => `import { isThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
42
+ import { pathData as pathData${versions[0]}, ltr, accData } from "./${versions[0]}/${name}.js";
43
+ import { pathData as pathData${versions[1]} } from "./${versions[1]}/${name}.js";
44
44
 
45
- const pathData = isThemeFamily("sap_horizon") ? pathDataV5 : pathDataV4;
45
+ const pathData = isThemeFamily("sap_horizon") ? pathData${versions[1]} : pathData${versions[0]};
46
46
 
47
- export default "${name}";
47
+ export default "${fullName}";
48
48
  export { pathData, ltr, accData };`;
49
49
 
50
50
 
51
+ const typeDefinitionTemplate = (name, accData, collection) => `declare const pathData: string;
52
+ declare const ltr: boolean;
53
+ declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
54
+ declare const _default: "${collection}/${name}";
55
+
56
+ export default _default;
57
+ export { pathData, ltr, accData };`
58
+
59
+ const collectionTypeDefinitionTemplate = (name, accData) => `declare const pathData: string;
60
+ declare const ltr: boolean;
61
+ declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
62
+ declare const _default: "${name}";
63
+
64
+ export default _default;
65
+ export { pathData, ltr, accData };`
66
+
67
+
51
68
  const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
52
69
  <path d="${pathData}"/>
53
70
  </svg>`;
@@ -63,20 +80,45 @@ const createIcons = async (file) => {
63
80
  const pathData = iconData.path;
64
81
  const ltr = !!iconData.ltr;
65
82
  const acc = iconData.acc;
83
+ const packageName = json.packageName;
84
+ const collection = json.collection;
66
85
 
67
- const content = acc ? iconAccTemplate(name, pathData, ltr, acc, json.collection, json.packageName) : iconTemplate(name, pathData, ltr, json.collection, json.packageName);
86
+ const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName) : iconTemplate(name, pathData, ltr, collection, packageName);
68
87
 
69
88
  promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
70
89
  promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
90
+ promises.push(fs.writeFile(path.join(destDir, `${name}.d.ts`), typeDefinitionTemplate(name, acc, collection)));
91
+
92
+ // For versioned icons collections, the script creates top level (unversioned) module that internally imports the versioned ones.
93
+ // For example, the top level "@ui5/ui5-webcomponents-icons/dist/accept.js" imports:
94
+ // - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
95
+ // - "@ui5/ui5-webcomponents-icons/dist/v4/accept.js"
71
96
 
72
97
  if (json.version) {
73
- promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name)));
98
+ // The exported value from the top level (unversioned) icon module depends on whether the collection is the default,
99
+ // to add or not the collection name to the exported value:
100
+ // For the default collection (SAPIcons) we export just the icon name - "export default { 'accept' }"
101
+ // For non-default collections (SAPTNTIcons and SAPBSIcons) we export the full name - "export default { 'tnt/actor' }"
102
+ const effectiveName = isDefaultCollection(collection) ? name : getUnversionedFullIconName(name, collection);
103
+ promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions, effectiveName)));
104
+ promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(effectiveName, acc)));
74
105
  }
75
106
  }
76
107
 
77
108
  return Promise.all(promises);
78
109
  };
79
110
 
111
+ const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
112
+ const getUnversionedFullIconName = (name, collection) => `${getUnversionedCollectionName(collection)}/${name}`;
113
+ const getUnversionedCollectionName = collectionName => CollectionVersionedToUnversionedMap[collectionName] || collectionName;
114
+
115
+ const CollectionVersionedToUnversionedMap = {
116
+ "tnt-v2": "tnt",
117
+ "tnt-v3": "tnt",
118
+ "business-suite-v1": "business-suite",
119
+ "business-suite-v2": "business-suite",
120
+ };
121
+
80
122
  createIcons(srcFile).then(() => {
81
123
  console.log("Icons created.");
82
124
  });