@ui5/create-webcomponents-package 0.0.0-db2be6526 → 0.0.0-db622d8a8
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 +349 -0
- package/README.md +33 -13
- package/create-package.js +271 -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 +33 -4
- 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_fiori_3/parameters-bundle.css +1 -1
- package/template/src/themes/sap_horizon_dark/parameters-bundle.css +3 -0
- 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_dark/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_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,349 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
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
|
+
|
339
|
+
# [1.2.0](https://github.com/SAP/ui5-webcomponents/compare/v1.1.2...v1.2.0) (2022-02-28)
|
340
|
+
|
341
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
## [1.1.2](https://github.com/SAP/ui5-webcomponents/compare/v1.1.1...v1.1.2) (2022-01-26)
|
348
|
+
|
349
|
+
**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,271 @@
|
|
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 isLogo = sourcePath => {
|
29
|
+
return sourcePath.includes("logo");
|
30
|
+
};
|
31
|
+
const isNPMRC = sourcePath => {
|
32
|
+
return sourcePath.includes("npmrc");
|
33
|
+
};
|
34
|
+
|
35
|
+
// Validation of user input
|
36
|
+
const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
|
37
|
+
const NamespacePattern = /^[a-z][a-z0-9\.\-]+$/;
|
38
|
+
const isPackageNameValid = name => typeof name === "string" && name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
|
39
|
+
const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
|
40
|
+
const isNamespaceValid = name => typeof name === "string" && NamespacePattern.test(name);
|
41
|
+
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Hyphanates the given PascalCase string, f.e.:
|
45
|
+
* Foo -> "my-foo" (adds preffix)
|
46
|
+
* FooBar -> "foo-bar"
|
47
|
+
*/
|
48
|
+
const hyphaneteComponentName = (componentName) => {
|
49
|
+
const result = componentName.replace(/([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
|
50
|
+
|
51
|
+
return result.includes("-") ? result : `my-${result}`;
|
52
|
+
};
|
53
|
+
|
54
|
+
// Utils for building the file structure
|
55
|
+
const replaceVarsInFileContent = (vars, content) => {
|
56
|
+
for (let key in vars) {
|
57
|
+
const re = new RegExp(key, "g");
|
58
|
+
content = content.replace(re, vars[key]);
|
59
|
+
}
|
60
|
+
return content;
|
61
|
+
};
|
62
|
+
|
63
|
+
const replaceVarsInFileName = (vars, fileName) => {
|
64
|
+
return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
|
65
|
+
};
|
66
|
+
|
67
|
+
const copyFile = (vars, sourcePath, destPath) => {
|
68
|
+
const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
|
69
|
+
const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
|
70
|
+
|
71
|
+
if (ignoreJsRelated || ignoreTsRelated) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
75
|
+
if (isLogo(sourcePath)) {
|
76
|
+
fs.copyFileSync(sourcePath, destPath);
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
|
80
|
+
let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
|
81
|
+
content = replaceVarsInFileContent(vars, content);
|
82
|
+
destPath = replaceVarsInFileName(vars, destPath);
|
83
|
+
|
84
|
+
fs.writeFileSync(destPath, content);
|
85
|
+
|
86
|
+
// Rename "gitignore" to ".gitignore" (npm init won't include ".gitignore", so we add it as "gitignore" and rename it later)
|
87
|
+
if (isGitIgnore(sourcePath)) {
|
88
|
+
fs.renameSync(destPath, destPath.replace("gitignore", ".gitignore"))
|
89
|
+
}
|
90
|
+
|
91
|
+
// Rename "npmrc" to ".npmrc" (npm init won't include ".npmrc", so we add it as "npmrc" and rename it later)
|
92
|
+
if (isNPMRC(sourcePath)) {
|
93
|
+
fs.renameSync(destPath, destPath.replace("npmrc", ".npmrc"));
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
const copyFiles = (vars, sourcePath, destPath) => {
|
98
|
+
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
99
|
+
if (isDir) {
|
100
|
+
if (destPath) {
|
101
|
+
mkdirp.sync(destPath);
|
102
|
+
}
|
103
|
+
fs.readdirSync(sourcePath).forEach(file => {
|
104
|
+
copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
|
105
|
+
});
|
106
|
+
} else {
|
107
|
+
copyFile(vars, sourcePath, destPath);
|
108
|
+
}
|
109
|
+
};
|
110
|
+
|
111
|
+
const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
|
112
|
+
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
113
|
+
|
114
|
+
// All variables that will be replaced in the content of the resources/
|
115
|
+
const vars = {
|
116
|
+
INIT_PACKAGE_VAR_NAMESPACE: namespace, // namespace must be replaced before name
|
117
|
+
INIT_PACKAGE_VAR_NAME: packageName,
|
118
|
+
INIT_PACKAGE_VAR_TAG: tagName,
|
119
|
+
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
120
|
+
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
121
|
+
};
|
122
|
+
|
123
|
+
const packageContent = {
|
124
|
+
name: packageName,
|
125
|
+
version: "0.0.1",
|
126
|
+
ui5: {
|
127
|
+
webComponentsPackage: true,
|
128
|
+
},
|
129
|
+
scripts: {
|
130
|
+
"clean": "wc-dev clean",
|
131
|
+
"lint": "wc-dev lint",
|
132
|
+
"start": "wc-dev start",
|
133
|
+
"watch": "wc-dev watch",
|
134
|
+
"build": "wc-dev build",
|
135
|
+
"test": "wc-dev test",
|
136
|
+
"create-ui5-element": "wc-create-ui5-element",
|
137
|
+
"prepublishOnly": "npm run build",
|
138
|
+
},
|
139
|
+
exports: {
|
140
|
+
"./src/*": "./src/*",
|
141
|
+
"./dist/*": "./dist/*",
|
142
|
+
"./package.json": "./package.json",
|
143
|
+
"./bundle.js": "./bundle.js",
|
144
|
+
"./*": "./dist/*",
|
145
|
+
},
|
146
|
+
"dependencies": {
|
147
|
+
"@ui5/webcomponents-base": version,
|
148
|
+
"@ui5/webcomponents-theming": version,
|
149
|
+
},
|
150
|
+
"devDependencies": {
|
151
|
+
"@ui5/webcomponents-tools": version,
|
152
|
+
"chromedriver": "*",
|
153
|
+
},
|
154
|
+
};
|
155
|
+
|
156
|
+
if (typescript) {
|
157
|
+
packageContent.devDependencies.typescript = "^4.9.4";
|
158
|
+
}
|
159
|
+
|
160
|
+
// Update package.json
|
161
|
+
let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
|
162
|
+
|
163
|
+
destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
|
164
|
+
mkdirp.sync(destDir);
|
165
|
+
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
166
|
+
// Copy files
|
167
|
+
copyFiles(vars, TEMPLATE_DIR, destDir);
|
168
|
+
|
169
|
+
console.log("\nPackage successfully created!\nNext steps:\n");
|
170
|
+
console.log(`$ cd ${destDir}`);
|
171
|
+
|
172
|
+
let userAgentInfo;
|
173
|
+
try {
|
174
|
+
userAgentInfo = parser(process.env.npm_config_user_agent);
|
175
|
+
} catch (e) {}
|
176
|
+
|
177
|
+
if (userAgentInfo && userAgentInfo.yarn) {
|
178
|
+
console.log(`$ yarn`);
|
179
|
+
console.log(`$ yarn start`);
|
180
|
+
} else {
|
181
|
+
console.log(`$ npm i`);
|
182
|
+
console.log(`$ npm start`);
|
183
|
+
}
|
184
|
+
|
185
|
+
console.log("\n");
|
186
|
+
};
|
187
|
+
|
188
|
+
// Main function
|
189
|
+
const createWebcomponentsPackage = async () => {
|
190
|
+
let response;
|
191
|
+
if (argv.name && !isPackageNameValid(argv.name)) {
|
192
|
+
throw new Error("The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].");
|
193
|
+
}
|
194
|
+
|
195
|
+
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
196
|
+
throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
|
197
|
+
}
|
198
|
+
|
199
|
+
if (argv.namespace && !isNamespaceValid(argv.namespace)) {
|
200
|
+
throw new Error("The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.");
|
201
|
+
}
|
202
|
+
|
203
|
+
if (argv.tag && !isTagValid(argv.tag) ) {
|
204
|
+
throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
|
205
|
+
}
|
206
|
+
|
207
|
+
let packageName = argv.name || "my-package";
|
208
|
+
let componentName = argv.componentName || "MyComponent";
|
209
|
+
let namespace = argv.namespace || "demo.components";
|
210
|
+
let typescriptSupport = !!argv.enableTypescript;
|
211
|
+
const skipSubfolder = !!argv.skipSubfolder;
|
212
|
+
|
213
|
+
if (argv.skip) {
|
214
|
+
return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
|
215
|
+
}
|
216
|
+
|
217
|
+
if (!argv.name) {
|
218
|
+
response = await prompts({
|
219
|
+
type: "text",
|
220
|
+
name: "name",
|
221
|
+
message: "Package name:",
|
222
|
+
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, _, -].",
|
223
|
+
});
|
224
|
+
packageName = response.name;
|
225
|
+
}
|
226
|
+
|
227
|
+
if (!typescriptSupport) {
|
228
|
+
response = await prompts({
|
229
|
+
type: "select",
|
230
|
+
name: "language",
|
231
|
+
message: "Project type:",
|
232
|
+
choices: [
|
233
|
+
{
|
234
|
+
title: "JavaScript",
|
235
|
+
value: false,
|
236
|
+
},
|
237
|
+
{
|
238
|
+
title: "TypeScript",
|
239
|
+
value: true,
|
240
|
+
},
|
241
|
+
],
|
242
|
+
});
|
243
|
+
typescriptSupport = response.language;
|
244
|
+
}
|
245
|
+
|
246
|
+
if (!argv.componentName) {
|
247
|
+
response = await prompts({
|
248
|
+
type: "text",
|
249
|
+
name: "componentName",
|
250
|
+
message: "Component name:",
|
251
|
+
initial: "MyComponent",
|
252
|
+
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
253
|
+
});
|
254
|
+
componentName = response.componentName;
|
255
|
+
}
|
256
|
+
|
257
|
+
if (!argv.namespace) {
|
258
|
+
response = await prompts({
|
259
|
+
type: "text",
|
260
|
+
name: "namespace",
|
261
|
+
message: "JSDoc namespace:",
|
262
|
+
initial: "demo.components",
|
263
|
+
validate: (value) => isNamespaceValid(value) ? true : "The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.",
|
264
|
+
});
|
265
|
+
namespace = response.namespace;
|
266
|
+
}
|
267
|
+
|
268
|
+
return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
|
269
|
+
};
|
270
|
+
|
271
|
+
createWebcomponentsPackage();
|