@ui5/create-webcomponents-package 0.0.0-fd6264051 → 0.0.0-ff1549e7b
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 +333 -0
- package/README.md +33 -13
- package/create-package.js +263 -0
- package/package.json +4 -3
- package/template/.eslintignore +3 -0
- package/template/.eslintrc.js +5 -0
- package/template/gitignore +4 -0
- package/template/npmrc +2 -0
- package/template/package-scripts.js +2 -1
- package/template/src/Assets.ts +5 -0
- package/template/src/MyFirstComponent.hbs +1 -1
- package/template/src/MyFirstComponent.js +28 -3
- package/template/src/MyFirstComponent.ts +62 -0
- package/template/src/i18n/messagebundle.properties +3 -2
- package/template/src/i18n/messagebundle_de.properties +1 -1
- package/template/src/i18n/messagebundle_en.properties +1 -1
- package/template/src/i18n/messagebundle_es.properties +1 -1
- package/template/src/i18n/messagebundle_fr.properties +1 -1
- package/template/src/themes/MyFirstComponent.css +10 -9
- package/template/src/themes/sap_horizon_hcb/parameters-bundle.css +3 -0
- package/template/test/pages/css/index.css +36 -0
- package/template/test/pages/img/logo.png +0 -0
- package/template/test/pages/index.html +37 -34
- package/template/test/specs/Demo.spec.js +3 -2
- package/template/tsconfig.json +15 -0
- package/index.js +0 -168
- package/template/config/.eslintrc.js +0 -1
- package/template/config/rollup.config.js +0 -1
- package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
- /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
- /package/template/src/themes/{sap_fiori_3_dark → sap_horizon_dark}/parameters-bundle.css +0 -0
- /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,339 @@
|
|
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.14.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0-rc.0...v1.14.0-rc.1) (2023-05-25)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [1.14.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.13.2...v1.14.0-rc.0) (2023-05-18)
|
15
|
+
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
* users can provide a JSDoc namespeace when creating a package ([#7034](https://github.com/SAP/ui5-webcomponents/issues/7034)) ([0af8d23](https://github.com/SAP/ui5-webcomponents/commit/0af8d2376e25e5abe6d940c72286ab7c682eea56))
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## [1.13.1](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.5...v1.13.1) (2023-05-11)
|
26
|
+
|
27
|
+
|
28
|
+
### Bug Fixes
|
29
|
+
|
30
|
+
* **create-package:** revert `moduleResolution` setting to `node` ([#7020](https://github.com/SAP/ui5-webcomponents/issues/7020)) ([9fc84e2](https://github.com/SAP/ui5-webcomponents/commit/9fc84e288452616ee72f3a2b6fc31d9752f05f6f))
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# [1.13.0-rc.5](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.4...v1.13.0-rc.5) (2023-05-11)
|
37
|
+
|
38
|
+
|
39
|
+
### Bug Fixes
|
40
|
+
|
41
|
+
* **create-webcomponents-package:** fix package creation issues with test and lint ([#6976](https://github.com/SAP/ui5-webcomponents/issues/6976)) ([dd70f3a](https://github.com/SAP/ui5-webcomponents/commit/dd70f3aa8ef70b592f1d4e0f3f9894c6280fb1bf))
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
# [1.13.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.3...v1.13.0-rc.4) (2023-05-04)
|
48
|
+
|
49
|
+
|
50
|
+
### Features
|
51
|
+
|
52
|
+
* generate TS from HBS templates ([#6558](https://github.com/SAP/ui5-webcomponents/issues/6558)) ([02611b2](https://github.com/SAP/ui5-webcomponents/commit/02611b2e24b2c2a06129b8e60a8bc680d9501e39))
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
# [1.13.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.2...v1.13.0-rc.3) (2023-04-27)
|
59
|
+
|
60
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
# [1.13.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.1...v1.13.0-rc.2) (2023-04-20)
|
67
|
+
|
68
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
# [1.13.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.0...v1.13.0-rc.1) (2023-04-13)
|
75
|
+
|
76
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
# [1.13.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0...v1.13.0-rc.0) (2023-04-06)
|
83
|
+
|
84
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
# [1.12.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.3...v1.12.0) (2023-04-04)
|
91
|
+
|
92
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
# [1.12.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.2...v1.12.0-rc.3) (2023-03-30)
|
99
|
+
|
100
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
# [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)
|
107
|
+
|
108
|
+
|
109
|
+
### Bug Fixes
|
110
|
+
|
111
|
+
* inline sources in the .map file so the src folder is not mandatory ([#6732](https://github.com/SAP/ui5-webcomponents/issues/6732)) ([16771a6](https://github.com/SAP/ui5-webcomponents/commit/16771a64d7b13f418af9afa1a03b224fe3762775))
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
# [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)
|
118
|
+
|
119
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
# [1.12.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0...v1.12.0-rc.0) (2023-03-09)
|
126
|
+
|
127
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
# [1.11.0](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.4...v1.11.0) (2023-03-06)
|
134
|
+
|
135
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
# [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)
|
142
|
+
|
143
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
# [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)
|
150
|
+
|
151
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
# [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)
|
158
|
+
|
159
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
# [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)
|
166
|
+
|
167
|
+
|
168
|
+
### Features
|
169
|
+
|
170
|
+
* **framework:** add option to define package name, tag and typescript support from CLI ([#6379](https://github.com/SAP/ui5-webcomponents/issues/6379)) ([687c0f7](https://github.com/SAP/ui5-webcomponents/commit/687c0f7a420a72f77f294ace2898223c48708ae2)), closes [#6382](https://github.com/SAP/ui5-webcomponents/issues/6382)
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
# [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)
|
177
|
+
|
178
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
## [1.10.4-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.10.3...v1.10.4-rc.0) (2023-01-26)
|
185
|
+
|
186
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
## [1.10.3](https://github.com/SAP/ui5-webcomponents/compare/v1.10.2...v1.10.3) (2023-01-25)
|
193
|
+
|
194
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
## [1.10.1](https://github.com/SAP/ui5-webcomponents/compare/v0.0.0-7b49a7ff1...v1.10.1) (2023-01-24)
|
201
|
+
|
202
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
# [1.10.0](https://github.com/SAP/ui5-webcomponents/compare/v1.9.3...v1.10.0) (2023-01-20)
|
209
|
+
|
210
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
## [1.9.3](https://github.com/SAP/ui5-webcomponents/compare/v1.9.2...v1.9.3) (2022-12-16)
|
217
|
+
|
218
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
## [1.9.1](https://github.com/SAP/ui5-webcomponents/compare/v1.9.0...v1.9.1) (2022-11-10)
|
225
|
+
|
226
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
# [1.9.0](https://github.com/SAP/ui5-webcomponents/compare/v1.8.0...v1.9.0) (2022-10-31)
|
233
|
+
|
234
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
# [1.8.0](https://github.com/SAP/ui5-webcomponents/compare/v1.7.1...v1.8.0) (2022-10-03)
|
241
|
+
|
242
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
## [1.7.1](https://github.com/SAP/ui5-webcomponents/compare/v1.7.0...v1.7.1) (2022-09-08)
|
249
|
+
|
250
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
# [1.7.0](https://github.com/SAP/ui5-webcomponents/compare/v1.6.0...v1.7.0) (2022-09-02)
|
257
|
+
|
258
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
# [1.6.0](https://github.com/SAP/ui5-webcomponents/compare/v1.5.0...v1.6.0) (2022-07-25)
|
265
|
+
|
266
|
+
|
267
|
+
### Bug Fixes
|
268
|
+
|
269
|
+
* create package bugs ([#5517](https://github.com/SAP/ui5-webcomponents/issues/5517)) ([f528f5c](https://github.com/SAP/ui5-webcomponents/commit/f528f5c))
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
# [1.5.0](https://github.com/SAP/ui5-webcomponents/compare/v1.4.0...v1.5.0) (2022-07-03)
|
276
|
+
|
277
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
# [1.4.0](https://github.com/SAP/ui5-webcomponents/compare/v1.3.1...v1.4.0) (2022-05-25)
|
284
|
+
|
285
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
## [1.3.1](https://github.com/SAP/ui5-webcomponents/compare/v1.3.0...v1.3.1) (2022-04-27)
|
292
|
+
|
293
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
# [1.3.0](https://github.com/SAP/ui5-webcomponents/compare/v1.2.4...v1.3.0) (2022-04-19)
|
300
|
+
|
301
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
## [1.2.4](https://github.com/SAP/ui5-webcomponents/compare/v1.2.3...v1.2.4) (2022-03-30)
|
308
|
+
|
309
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
## [1.2.3](https://github.com/SAP/ui5-webcomponents/compare/v1.2.2...v1.2.3) (2022-03-23)
|
316
|
+
|
317
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
## [1.2.2](https://github.com/SAP/ui5-webcomponents/compare/v1.2.1...v1.2.2) (2022-03-22)
|
324
|
+
|
325
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
## [1.2.1](https://github.com/SAP/ui5-webcomponents/compare/v1.2.0...v1.2.1) (2022-03-02)
|
332
|
+
|
333
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
6
339
|
# [1.2.0](https://github.com/SAP/ui5-webcomponents/compare/v1.1.2...v1.2.0) (2022-02-28)
|
7
340
|
|
8
341
|
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
package/README.md
CHANGED
@@ -1,38 +1,58 @@
|
|
1
|
-

|
2
2
|
|
3
3
|
# UI5 Web Components - Create Package
|
4
4
|
|
5
|
-
[](https://travis-ci.org/SAP/ui5-webcomponents)
|
6
5
|
[](https://www.npmjs.com/package/@ui5/webcomponents)
|
7
6
|
|
8
7
|
Provides an `npm init` script for creating new "UI5 Web Components" packages.
|
9
8
|
|
10
|
-
## Usage
|
9
|
+
## Usage with npm
|
11
10
|
|
12
|
-
|
11
|
+
```
|
12
|
+
Usage:
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
# npm 6.x
|
15
|
+
npm init @ui5/webcomponents-package [OPTIONS]
|
16
|
+
# npm 7+, an extra double-dash is needed:
|
17
|
+
npm init @ui5/webcomponents-package -- [OPTIONS]
|
16
18
|
|
17
|
-
|
19
|
+
Options:
|
20
|
+
--name <string> - defines the package name
|
21
|
+
--componentName <string> - defines the component class name that will be created in your new package
|
22
|
+
--tag <string> - defines the tag name of the sample web component that will be created in your new package. The tag will be derived from the component name if not provided.
|
23
|
+
--enable-typescript - enables TypeScript support for the package
|
24
|
+
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
25
|
+
```
|
18
26
|
|
19
|
-
|
20
|
-
|
27
|
+
The script creates a new directory, and fills it with a `package.json` file and all necessary source files, and resources for a new
|
28
|
+
components package.
|
29
|
+
|
30
|
+
## Usage with yarn
|
31
|
+
|
32
|
+
```
|
33
|
+
Usage:
|
34
|
+
yarn create @ui5/webcomponents-package [OPTIONS]
|
35
|
+
Options:
|
36
|
+
--name <string> - defines the package name
|
37
|
+
--tag <string> - defines the tag name of the sample web component that will be created in your new package
|
38
|
+
--enable-typescript - enables TypeScript support for the package
|
39
|
+
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
40
|
+
```
|
21
41
|
|
22
42
|
The script creates a new directory, and fills it with a `package.json` file and all necessary source files, and resources for a new
|
23
43
|
components package.
|
24
44
|
|
25
45
|
## Resources
|
26
|
-
- [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/
|
46
|
+
- [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
|
27
47
|
- [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
|
28
48
|
- [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
|
29
49
|
|
30
50
|
## Support
|
31
|
-
We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/
|
51
|
+
We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
|
32
52
|
|
33
53
|
## Contribute
|
34
|
-
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/
|
54
|
+
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
|
35
55
|
|
36
56
|
## License
|
37
57
|
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
|
38
|
-
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/
|
58
|
+
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.
|
@@ -0,0 +1,263 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
const fs = require("fs");
|
4
|
+
const path = require("path");
|
5
|
+
const mkdirp = require("mkdirp");
|
6
|
+
const prompts = require("prompts");
|
7
|
+
const parser = require("npm-config-user-agent-parser");
|
8
|
+
const yargs = require("yargs/yargs");
|
9
|
+
const { hideBin } = require("yargs/helpers");
|
10
|
+
|
11
|
+
const argv = yargs(hideBin(process.argv)).argv;
|
12
|
+
|
13
|
+
const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))).version;
|
14
|
+
|
15
|
+
// from where all the files will be copied
|
16
|
+
const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
|
17
|
+
|
18
|
+
// String utils
|
19
|
+
const isTSRelatedFile = sourcePath => {
|
20
|
+
return ["Assets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
|
21
|
+
};
|
22
|
+
const isJSRelatedFile = sourcePath => {
|
23
|
+
return ["Assets.js", "MyFirstComponent.js"].some(fileName => sourcePath.includes(fileName));
|
24
|
+
};
|
25
|
+
const isGitIgnore = sourcePath => {
|
26
|
+
return sourcePath.includes("gitignore");
|
27
|
+
};
|
28
|
+
const isNPMRC = sourcePath => {
|
29
|
+
return sourcePath.includes("npmrc");
|
30
|
+
};
|
31
|
+
|
32
|
+
// Validation of user input
|
33
|
+
const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
|
34
|
+
const NamespacePattern = /^[a-z][a-z0-9\.\-]+$/;
|
35
|
+
const isPackageNameValid = name => typeof name === "string" && name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
|
36
|
+
const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
|
37
|
+
const isNamespaceValid = name => typeof name === "string" && NamespacePattern.test(name);
|
38
|
+
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Hyphanates the given PascalCase string, f.e.:
|
42
|
+
* Foo -> "my-foo" (adds preffix)
|
43
|
+
* FooBar -> "foo-bar"
|
44
|
+
*/
|
45
|
+
const hyphaneteComponentName = (componentName) => {
|
46
|
+
const result = componentName.replace(/([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
|
47
|
+
|
48
|
+
return result.includes("-") ? result : `my-${result}`;
|
49
|
+
};
|
50
|
+
|
51
|
+
// Utils for building the file structure
|
52
|
+
const replaceVarsInFileContent = (vars, content) => {
|
53
|
+
for (let key in vars) {
|
54
|
+
const re = new RegExp(key, "g");
|
55
|
+
content = content.replace(re, vars[key]);
|
56
|
+
}
|
57
|
+
return content;
|
58
|
+
};
|
59
|
+
|
60
|
+
const replaceVarsInFileName = (vars, fileName) => {
|
61
|
+
return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
|
62
|
+
};
|
63
|
+
|
64
|
+
const copyFile = (vars, sourcePath, destPath) => {
|
65
|
+
const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
|
66
|
+
const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
|
67
|
+
|
68
|
+
if (ignoreJsRelated || ignoreTsRelated) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
|
72
|
+
let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
|
73
|
+
content = replaceVarsInFileContent(vars, content);
|
74
|
+
destPath = replaceVarsInFileName(vars, destPath);
|
75
|
+
|
76
|
+
fs.writeFileSync(destPath, content);
|
77
|
+
|
78
|
+
// Rename "gitignore" to ".gitignore" (npm init won't include ".gitignore", so we add it as "gitignore" and rename it later)
|
79
|
+
if (isGitIgnore(sourcePath)) {
|
80
|
+
fs.renameSync(destPath, destPath.replace("gitignore", ".gitignore"))
|
81
|
+
}
|
82
|
+
|
83
|
+
// Rename "npmrc" to ".npmrc" (npm init won't include ".npmrc", so we add it as "npmrc" and rename it later)
|
84
|
+
if (isNPMRC(sourcePath)) {
|
85
|
+
fs.renameSync(destPath, destPath.replace("npmrc", ".npmrc"));
|
86
|
+
}
|
87
|
+
};
|
88
|
+
|
89
|
+
const copyFiles = (vars, sourcePath, destPath) => {
|
90
|
+
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
91
|
+
if (isDir) {
|
92
|
+
if (destPath) {
|
93
|
+
mkdirp.sync(destPath);
|
94
|
+
}
|
95
|
+
fs.readdirSync(sourcePath).forEach(file => {
|
96
|
+
copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
|
97
|
+
});
|
98
|
+
} else {
|
99
|
+
copyFile(vars, sourcePath, destPath);
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
|
104
|
+
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
105
|
+
|
106
|
+
// All variables that will be replaced in the content of the resources/
|
107
|
+
const vars = {
|
108
|
+
INIT_PACKAGE_VAR_NAMESPACE: namespace, // namespace must be replaced before name
|
109
|
+
INIT_PACKAGE_VAR_NAME: packageName,
|
110
|
+
INIT_PACKAGE_VAR_TAG: tagName,
|
111
|
+
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
112
|
+
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
113
|
+
};
|
114
|
+
|
115
|
+
const packageContent = {
|
116
|
+
packageName,
|
117
|
+
version: "0.0.1",
|
118
|
+
ui5: {
|
119
|
+
webComponentsPackage: true,
|
120
|
+
},
|
121
|
+
scripts: {
|
122
|
+
"clean": "wc-dev clean",
|
123
|
+
"lint": "wc-dev lint",
|
124
|
+
"start": "wc-dev start",
|
125
|
+
"watch": "wc-dev watch",
|
126
|
+
"build": "wc-dev build",
|
127
|
+
"test": "wc-dev test",
|
128
|
+
"create-ui5-element": "wc-create-ui5-element",
|
129
|
+
"prepublishOnly": "npm run build",
|
130
|
+
},
|
131
|
+
exports: {
|
132
|
+
"./src/*": "./src/*",
|
133
|
+
"./dist/*": "./dist/*",
|
134
|
+
"./package.json": "./package.json",
|
135
|
+
"./bundle.js": "./bundle.js",
|
136
|
+
"./*": "./dist/*",
|
137
|
+
},
|
138
|
+
"dependencies": {
|
139
|
+
"@ui5/webcomponents-base": version,
|
140
|
+
"@ui5/webcomponents-theming": version,
|
141
|
+
},
|
142
|
+
"devDependencies": {
|
143
|
+
"@ui5/webcomponents-tools": version,
|
144
|
+
"chromedriver": "*",
|
145
|
+
},
|
146
|
+
};
|
147
|
+
|
148
|
+
if (typescript) {
|
149
|
+
packageContent.devDependencies.typescript = "^4.9.4";
|
150
|
+
}
|
151
|
+
|
152
|
+
// Update package.json
|
153
|
+
let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
|
154
|
+
|
155
|
+
destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
|
156
|
+
mkdirp.sync(destDir);
|
157
|
+
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
158
|
+
// Copy files
|
159
|
+
copyFiles(vars, TEMPLATE_DIR, destDir);
|
160
|
+
|
161
|
+
console.log("\nPackage successfully created!\nNext steps:\n");
|
162
|
+
console.log(`$ cd ${destDir}`);
|
163
|
+
|
164
|
+
let userAgentInfo;
|
165
|
+
try {
|
166
|
+
userAgentInfo = parser(process.env.npm_config_user_agent);
|
167
|
+
} catch (e) {}
|
168
|
+
|
169
|
+
if (userAgentInfo && userAgentInfo.yarn) {
|
170
|
+
console.log(`$ yarn`);
|
171
|
+
console.log(`$ yarn start`);
|
172
|
+
} else {
|
173
|
+
console.log(`$ npm i`);
|
174
|
+
console.log(`$ npm start`);
|
175
|
+
}
|
176
|
+
|
177
|
+
console.log("\n");
|
178
|
+
};
|
179
|
+
|
180
|
+
// Main function
|
181
|
+
const createWebcomponentsPackage = async () => {
|
182
|
+
let response;
|
183
|
+
if (argv.name && !isPackageNameValid(argv.name)) {
|
184
|
+
throw new Error("The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].");
|
185
|
+
}
|
186
|
+
|
187
|
+
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
188
|
+
throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
|
189
|
+
}
|
190
|
+
|
191
|
+
if (argv.namespace && !isNamespaceValid(argv.namespace)) {
|
192
|
+
throw new Error("The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.");
|
193
|
+
}
|
194
|
+
|
195
|
+
if (argv.tag && !isTagValid(argv.tag) ) {
|
196
|
+
throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
|
197
|
+
}
|
198
|
+
|
199
|
+
let packageName = argv.name || "my-package";
|
200
|
+
let componentName = argv.componentName || "MyComponent";
|
201
|
+
let namespace = argv.namespace || "demo.components";
|
202
|
+
let typescriptSupport = !!argv.enableTypescript;
|
203
|
+
const skipSubfolder = !!argv.skipSubfolder;
|
204
|
+
|
205
|
+
if (argv.skip) {
|
206
|
+
return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
|
207
|
+
}
|
208
|
+
|
209
|
+
if (!argv.name) {
|
210
|
+
response = await prompts({
|
211
|
+
type: "text",
|
212
|
+
name: "name",
|
213
|
+
message: "Package name:",
|
214
|
+
validate: (value) => isPackageNameValid(value) ? true : "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
|
215
|
+
});
|
216
|
+
packageName = response.name;
|
217
|
+
}
|
218
|
+
|
219
|
+
if (!typescriptSupport) {
|
220
|
+
response = await prompts({
|
221
|
+
type: "select",
|
222
|
+
name: "language",
|
223
|
+
message: "Project type:",
|
224
|
+
choices: [
|
225
|
+
{
|
226
|
+
title: "JavaScript",
|
227
|
+
value: false,
|
228
|
+
},
|
229
|
+
{
|
230
|
+
title: "TypeScript",
|
231
|
+
value: true,
|
232
|
+
},
|
233
|
+
],
|
234
|
+
});
|
235
|
+
typescriptSupport = response.language;
|
236
|
+
}
|
237
|
+
|
238
|
+
if (!argv.componentName) {
|
239
|
+
response = await prompts({
|
240
|
+
type: "text",
|
241
|
+
name: "componentName",
|
242
|
+
message: "Component name:",
|
243
|
+
initial: "MyComponent",
|
244
|
+
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
245
|
+
});
|
246
|
+
componentName = response.componentName;
|
247
|
+
}
|
248
|
+
|
249
|
+
if (!argv.namespace) {
|
250
|
+
response = await prompts({
|
251
|
+
type: "text",
|
252
|
+
name: "namespace",
|
253
|
+
message: "JSDoc namespace:",
|
254
|
+
initial: "demo.components",
|
255
|
+
validate: (value) => isNamespaceValid(value) ? true : "The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.",
|
256
|
+
});
|
257
|
+
namespace = response.namespace;
|
258
|
+
}
|
259
|
+
|
260
|
+
return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
|
261
|
+
};
|
262
|
+
|
263
|
+
createWebcomponentsPackage();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/create-webcomponents-package",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-ff1549e7b",
|
4
4
|
"description": "UI5 Web Components: create package",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"ui5"
|
12
12
|
],
|
13
13
|
"bin": {
|
14
|
-
"create-webcomponents-package": "
|
14
|
+
"create-webcomponents-package": "create-package.js"
|
15
15
|
},
|
16
16
|
"repository": {
|
17
17
|
"type": "git",
|
@@ -21,6 +21,7 @@
|
|
21
21
|
"dependencies": {
|
22
22
|
"mkdirp": "^1.0.4",
|
23
23
|
"npm-config-user-agent-parser": "^1.0.0",
|
24
|
-
"prompts": "^2.4.1"
|
24
|
+
"prompts": "^2.4.1",
|
25
|
+
"yargs": "^17.5.1"
|
25
26
|
}
|
26
27
|
}
|
package/template/.eslintignore
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
const config = require("@ui5/webcomponents-tools/components-package/eslint.js");
|
2
|
+
|
3
|
+
// This eslint config is defined @ui5/webcomponents-tools,
|
4
|
+
// Feel free to override part of the configuration or provide entirely new config to fit your dev requirements.
|
5
|
+
module.exports = config;
|
package/template/npmrc
ADDED
@@ -1 +1 @@
|
|
1
|
-
<div>
|
1
|
+
<div @click="{{onClick}}">{{counterText}} :: {{counter}}</div>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
2
2
|
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
3
3
|
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
4
|
+
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
|
4
5
|
|
5
6
|
// Template
|
6
7
|
import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
|
@@ -8,11 +9,18 @@ import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACK
|
|
8
9
|
// Styles
|
9
10
|
import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
|
10
11
|
|
11
|
-
import {
|
12
|
+
import { COUNTER } from "./generated/i18n/i18n-defaults.js";
|
12
13
|
|
14
|
+
/**
|
15
|
+
* @public
|
16
|
+
*/
|
13
17
|
const metadata = {
|
14
18
|
tag: "INIT_PACKAGE_VAR_TAG",
|
15
19
|
properties: {
|
20
|
+
counter: {
|
21
|
+
type: Integer,
|
22
|
+
defaultValue: 0,
|
23
|
+
},
|
16
24
|
},
|
17
25
|
slots: {
|
18
26
|
},
|
@@ -20,6 +28,19 @@ const metadata = {
|
|
20
28
|
},
|
21
29
|
};
|
22
30
|
|
31
|
+
/**
|
32
|
+
* @class
|
33
|
+
*
|
34
|
+
* <h3 class="comment-api-title">Overview</h3>
|
35
|
+
*
|
36
|
+
* The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
|
37
|
+
*
|
38
|
+
* @constructor
|
39
|
+
* @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
|
40
|
+
* @extends sap.ui.webc.base.UI5Element
|
41
|
+
* @tagname INIT_PACKAGE_VAR_TAG
|
42
|
+
* @public
|
43
|
+
*/
|
23
44
|
class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
24
45
|
static get metadata() {
|
25
46
|
return metadata;
|
@@ -41,8 +62,12 @@ class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
|
41
62
|
INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
|
42
63
|
}
|
43
64
|
|
44
|
-
|
45
|
-
|
65
|
+
onClick() {
|
66
|
+
this.counter++;
|
67
|
+
}
|
68
|
+
|
69
|
+
get counterText() {
|
70
|
+
return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNTER);
|
46
71
|
}
|
47
72
|
}
|
48
73
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
2
|
+
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
3
|
+
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
4
|
+
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
5
|
+
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
6
|
+
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
7
|
+
|
8
|
+
// Template
|
9
|
+
import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
|
10
|
+
|
11
|
+
// Styles
|
12
|
+
import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
|
13
|
+
|
14
|
+
import { COUNTER } from "./generated/i18n/i18n-defaults.js";
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @class
|
18
|
+
*
|
19
|
+
* <h3 class="comment-api-title">Overview</h3>
|
20
|
+
*
|
21
|
+
* The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
|
22
|
+
*
|
23
|
+
* @constructor
|
24
|
+
* @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
|
25
|
+
* @extends sap.ui.webc.base.UI5Element
|
26
|
+
* @tagname INIT_PACKAGE_VAR_TAG
|
27
|
+
* @public
|
28
|
+
*/
|
29
|
+
@customElement({
|
30
|
+
tag: "INIT_PACKAGE_VAR_TAG",
|
31
|
+
renderer: litRender,
|
32
|
+
styles: INIT_PACKAGE_VAR_CLASS_NAMECss,
|
33
|
+
template: INIT_PACKAGE_VAR_CLASS_NAMETemplate,
|
34
|
+
})
|
35
|
+
class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
36
|
+
static i18nBundle: I18nBundle;
|
37
|
+
|
38
|
+
static async onDefine() {
|
39
|
+
INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Defines the component counter.
|
44
|
+
* @name NIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME.prototype.counter
|
45
|
+
* @public
|
46
|
+
* @type { number }
|
47
|
+
*/
|
48
|
+
@property({ defaultValue: 0 })
|
49
|
+
counter!: number;
|
50
|
+
|
51
|
+
onClick() {
|
52
|
+
this.counter++;
|
53
|
+
}
|
54
|
+
|
55
|
+
get counterText() {
|
56
|
+
return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNTER);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
INIT_PACKAGE_VAR_CLASS_NAME.define();
|
61
|
+
|
62
|
+
export default INIT_PACKAGE_VAR_CLASS_NAME;
|
@@ -1,2 +1,3 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# the "counter" text for the sample component
|
2
|
+
COUNTER=Counter
|
3
|
+
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNTER=Schalter
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNTER=Counter
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNTER=Encimera
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNTER=Comptoir
|
@@ -1,11 +1,12 @@
|
|
1
1
|
:host {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
padding: 0 2rem;
|
3
|
+
color: var(--sapAvatar_6_TextColor);
|
4
|
+
background-color: var(--sapAvatar_6_Background);
|
5
|
+
border: 2px solid var(--my-component-border-color);
|
6
|
+
border-radius: 0.5rem;
|
7
|
+
box-shadow: var(--sapContent_Shadow0);
|
8
|
+
text-align: center;
|
9
|
+
line-height: 3rem;
|
10
|
+
font-size: 1.25rem;
|
11
|
+
user-select: none;
|
11
12
|
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
body {
|
2
|
+
color: var(--sapTextColor);
|
3
|
+
background-color: var(--sapBackgroundColor);
|
4
|
+
font-size: var(--sapFontSize);
|
5
|
+
font-family: var(--sapFontFamily);
|
6
|
+
}
|
7
|
+
|
8
|
+
h1 {
|
9
|
+
font-size: var(--sapFontHeader2Size);
|
10
|
+
margin-bottom: 0.5rem;
|
11
|
+
}
|
12
|
+
|
13
|
+
h2 {
|
14
|
+
font-size: var(--sapFontHeader3Size);
|
15
|
+
margin-bottom: 0.5rem;
|
16
|
+
}
|
17
|
+
|
18
|
+
.app, .app-first-component, .app-settings, .app-docs {
|
19
|
+
display: flex;
|
20
|
+
align-items: center;
|
21
|
+
justify-content: center;
|
22
|
+
flex-direction: column;
|
23
|
+
}
|
24
|
+
|
25
|
+
.app-first-component {
|
26
|
+
margin-bottom: 3rem;
|
27
|
+
}
|
28
|
+
|
29
|
+
.app-docs {
|
30
|
+
margin-top: 3rem;
|
31
|
+
}
|
32
|
+
|
33
|
+
a {
|
34
|
+
margin: 0.25rem;
|
35
|
+
color: var(--sapLinkColor);
|
36
|
+
}
|
Binary file
|
@@ -2,53 +2,56 @@
|
|
2
2
|
<html>
|
3
3
|
|
4
4
|
<head>
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
5
|
<meta charset="utf-8">
|
7
6
|
|
8
7
|
<title>INIT_PACKAGE_VAR_TAG</title>
|
9
8
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
10
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
11
9
|
<meta charset="utf-8">
|
12
10
|
|
13
11
|
<script data-ui5-config type="application/json">
|
14
12
|
{
|
13
|
+
"theme": "sap_horizon_dark",
|
15
14
|
"language": "EN"
|
16
15
|
}
|
17
16
|
</script>
|
18
|
-
|
19
|
-
<
|
20
|
-
|
21
|
-
<style>
|
22
|
-
code { color: blue; font-size: small; }
|
23
|
-
</style>
|
24
|
-
|
17
|
+
|
18
|
+
<link rel="stylesheet" type="text/css" href="./css/index.css">
|
19
|
+
<script src="../../bundle.esm.js" type="module"></script>
|
25
20
|
</head>
|
26
21
|
|
27
22
|
<body>
|
28
|
-
<
|
29
|
-
|
30
|
-
|
31
|
-
<
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
23
|
+
<div class="app">
|
24
|
+
<a href="https://sap.github.io/ui5-webcomponents/playground/getting-started" target="_blank"><img src="./img/logo.png" alt="logo"/></a>
|
25
|
+
|
26
|
+
<div class="app-first-component">
|
27
|
+
<h1>Hooray! It's Your First Web Component!</h1>
|
28
|
+
<div> <pre><INIT_PACKAGE_VAR_TAG></INIT_PACKAGE_VAR_TAG> </pre></div>
|
29
|
+
<INIT_PACKAGE_VAR_TAG id="myFirstComponent"></INIT_PACKAGE_VAR_TAG>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class="app-settings">
|
33
|
+
|
34
|
+
<h2>Switch themes</h2>
|
35
|
+
<div style="display: flex; flex-direction: row;">
|
36
|
+
<a class="link" href="?sap-ui-theme=sap_horizon">Horizon</a>
|
37
|
+
<a class="link" href="?sap-ui-theme=sap_horizon_dark">Horizon Dark</a>
|
38
|
+
<a class="link" href="?sap-ui-theme=sap_horizon_hcb">Horizon High Contrast Black</a>
|
39
|
+
<a class="link" href="?sap-ui-theme=sap_horizon_hcw">Horizon High Contrast White</a>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<h2>Switch language</h2>
|
43
|
+
<div>
|
44
|
+
<a class="link" href="?sap-ui-language=en">English</a>
|
45
|
+
<a class="link" href="?sap-ui-language=de">German</a>
|
46
|
+
<a class="link" href="?sap-ui-language=es">Spanish</a>
|
47
|
+
<a class="link" href="?sap-ui-language=fr">French</a>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="app-docs">
|
52
|
+
<h2>Documentation</h2>
|
53
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/playground/development">Custom Component Development</a>
|
54
|
+
</div>
|
55
|
+
</div>
|
52
56
|
</body>
|
53
|
-
|
54
57
|
</html>
|
@@ -1,10 +1,11 @@
|
|
1
1
|
const assert = require("assert");
|
2
2
|
|
3
3
|
describe("INIT_PACKAGE_VAR_TAG rendering", async () => {
|
4
|
-
|
4
|
+
before(async () => {
|
5
|
+
await browser.url("test/pages/index.html");
|
6
|
+
});
|
5
7
|
|
6
8
|
it("tests if web component is correctly rendered", async () => {
|
7
|
-
|
8
9
|
const innerContent = await browser.$("#myFirstComponent").shadow$("div");
|
9
10
|
|
10
11
|
assert.ok(innerContent, "content rendered");
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"include": ["src/**/*", "global.d.ts"],
|
3
|
+
"compilerOptions": {
|
4
|
+
"target": "ES2021",
|
5
|
+
// Generate d.ts files
|
6
|
+
"declaration": true,
|
7
|
+
"outDir": "dist",
|
8
|
+
"skipLibCheck": true,
|
9
|
+
"sourceMap": true,
|
10
|
+
"inlineSources": true,
|
11
|
+
"strict": true,
|
12
|
+
"moduleResolution": "node",
|
13
|
+
"experimentalDecorators": true,
|
14
|
+
},
|
15
|
+
}
|
package/index.js
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
const fs = require("fs");
|
4
|
-
const path = require("path");
|
5
|
-
const mkdirp = require("mkdirp");
|
6
|
-
const prompts = require("prompts");
|
7
|
-
const parser = require("npm-config-user-agent-parser");
|
8
|
-
|
9
|
-
// from where all the files will be copied
|
10
|
-
const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
|
11
|
-
|
12
|
-
// String utils
|
13
|
-
const capitalizeFirst = str => str.substr(0,1).toUpperCase() + str.substr(1);
|
14
|
-
const kebabToCamelCase = string => toCamelCase(string.split("-"));
|
15
|
-
const toCamelCase = parts => {
|
16
|
-
return parts.map((string, index) => {
|
17
|
-
return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
18
|
-
}).join("");
|
19
|
-
};
|
20
|
-
|
21
|
-
// Validation of user input
|
22
|
-
const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
|
23
|
-
const isPortValid = port => typeof port === "string" && port.match(/^[0-9]+$/);
|
24
|
-
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
25
|
-
|
26
|
-
// Utils for building the file structure
|
27
|
-
const replaceVarsInFileContent = (vars, content) => {
|
28
|
-
for (let key in vars) {
|
29
|
-
const re = new RegExp(key, "g");
|
30
|
-
content = content.replace(re, vars[key]);
|
31
|
-
}
|
32
|
-
return content;
|
33
|
-
};
|
34
|
-
|
35
|
-
const replaceVarsInFileName = (vars, fileName) => {
|
36
|
-
return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
|
37
|
-
};
|
38
|
-
|
39
|
-
const copyFile = (vars, sourcePath, destPath) => {
|
40
|
-
let content = fs.readFileSync(sourcePath, {encoding: "UTF-8"});
|
41
|
-
content = replaceVarsInFileContent(vars, content);
|
42
|
-
destPath = replaceVarsInFileName(vars, destPath);
|
43
|
-
fs.writeFileSync(destPath, content);
|
44
|
-
};
|
45
|
-
|
46
|
-
const copyFiles = (vars, sourcePath, destPath) => {
|
47
|
-
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
48
|
-
if (isDir) {
|
49
|
-
if (destPath) {
|
50
|
-
mkdirp.sync(destPath);
|
51
|
-
}
|
52
|
-
fs.readdirSync(sourcePath).forEach(file => {
|
53
|
-
copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
|
54
|
-
});
|
55
|
-
} else {
|
56
|
-
copyFile(vars, sourcePath, destPath);
|
57
|
-
}
|
58
|
-
};
|
59
|
-
|
60
|
-
// Main function
|
61
|
-
const createWebcomponentsPackage = async () => {
|
62
|
-
let response;
|
63
|
-
|
64
|
-
// Get the name
|
65
|
-
let name = process.argv[2];
|
66
|
-
|
67
|
-
if (!isNameValid(name)) {
|
68
|
-
response = await prompts({
|
69
|
-
type: "text",
|
70
|
-
name: "name",
|
71
|
-
message: "Package name:",
|
72
|
-
validate: isNameValid,
|
73
|
-
});
|
74
|
-
name = response.name;
|
75
|
-
}
|
76
|
-
|
77
|
-
// Get the port
|
78
|
-
response = await prompts({
|
79
|
-
type: "text",
|
80
|
-
name: "port",
|
81
|
-
message: "Dev server port:",
|
82
|
-
validate: isPortValid,
|
83
|
-
initial: "8080",
|
84
|
-
});
|
85
|
-
const port = response.port;
|
86
|
-
|
87
|
-
// Get the tag
|
88
|
-
response = await prompts({
|
89
|
-
type: "text",
|
90
|
-
name: "tag",
|
91
|
-
message: "Demo component name:",
|
92
|
-
initial: "my-first-component",
|
93
|
-
validate: isTagValid,
|
94
|
-
});
|
95
|
-
const tag = response.tag;
|
96
|
-
|
97
|
-
const className = capitalizeFirst(kebabToCamelCase(tag));
|
98
|
-
|
99
|
-
// All variables that will be replaced in the content of the resources/
|
100
|
-
const vars = {
|
101
|
-
INIT_PACKAGE_VAR_NAME: name,
|
102
|
-
INIT_PACKAGE_VAR_PORT: port,
|
103
|
-
INIT_PACKAGE_VAR_TAG: tag,
|
104
|
-
INIT_PACKAGE_VAR_CLASS_NAME: className,
|
105
|
-
};
|
106
|
-
|
107
|
-
const packageContent = {
|
108
|
-
name,
|
109
|
-
version: "0.0.1",
|
110
|
-
ui5: {
|
111
|
-
webComponentsPackage: true,
|
112
|
-
},
|
113
|
-
scripts: {
|
114
|
-
"clean": "wc-dev clean",
|
115
|
-
"lint": "wc-dev lint",
|
116
|
-
"start": "wc-dev start",
|
117
|
-
"watch": "wc-dev watch",
|
118
|
-
"serve": "wc-dev serve",
|
119
|
-
"build": "wc-dev build",
|
120
|
-
"test": "wc-dev test",
|
121
|
-
"create-ui5-element": "wc-create-ui5-element",
|
122
|
-
"prepublishOnly": "npm run build",
|
123
|
-
},
|
124
|
-
exports: {
|
125
|
-
"./.port": "./.port",
|
126
|
-
"./src/*": "./src/*",
|
127
|
-
"./dist/*": "./dist/*",
|
128
|
-
"./package.json": "./package.json",
|
129
|
-
"./bundle.js": "./bundle.js",
|
130
|
-
"./*": "./dist/*",
|
131
|
-
},
|
132
|
-
"dependencies": {
|
133
|
-
"@ui5/webcomponents-base": "1.1.1",
|
134
|
-
"@ui5/webcomponents-theming": "1.1.1",
|
135
|
-
},
|
136
|
-
"devDependencies": {
|
137
|
-
"@ui5/webcomponents-tools": "1.1.1",
|
138
|
-
"chromedriver": "*",
|
139
|
-
},
|
140
|
-
};
|
141
|
-
|
142
|
-
// Update package.json
|
143
|
-
const destDir = path.join(`./`, name);
|
144
|
-
mkdirp.sync(destDir);
|
145
|
-
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
146
|
-
// Copy files
|
147
|
-
copyFiles(vars, TEMPLATE_DIR, destDir);
|
148
|
-
|
149
|
-
console.log("\nPackage successfully created!\nNext steps:\n");
|
150
|
-
console.log(`$ cd ${name}`);
|
151
|
-
|
152
|
-
let userAgentInfo;
|
153
|
-
try {
|
154
|
-
userAgentInfo = parser(process.env.npm_config_user_agent);
|
155
|
-
} catch (e) {}
|
156
|
-
|
157
|
-
if (userAgentInfo && userAgentInfo.yarn) {
|
158
|
-
console.log(`$ yarn`);
|
159
|
-
console.log(`$ yarn start`);
|
160
|
-
} else {
|
161
|
-
console.log(`$ npm i`);
|
162
|
-
console.log(`$ npm start`);
|
163
|
-
}
|
164
|
-
|
165
|
-
console.log("\n");
|
166
|
-
};
|
167
|
-
|
168
|
-
createWebcomponentsPackage();
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/eslint.js"); // eslint-disable-line
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/rollup.js"); // eslint-disable-line
|
File without changes
|
File without changes
|
File without changes
|