@ui5/create-webcomponents-package 1.13.0-rc.3 → 1.13.0
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 +22 -0
- package/README.md +2 -1
- package/create-package.js +35 -17
- package/package.json +2 -2
- package/template/.eslintignore +2 -1
- package/template/.eslintrc.js +5 -0
- 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/index.html +5 -4
- package/template/tsconfig.json +2 -1
- package/template/global.d.ts +0 -12
- package/template/src/themes/sap_belize_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
CHANGED
@@ -3,6 +3,28 @@
|
|
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.13.0](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.4...v1.13.0) (2023-05-05)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **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))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# [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)
|
18
|
+
|
19
|
+
|
20
|
+
### Features
|
21
|
+
|
22
|
+
* generate TS from HBS templates ([#6558](https://github.com/SAP/ui5-webcomponents/issues/6558)) ([02611b2](https://github.com/SAP/ui5-webcomponents/commit/02611b2e24b2c2a06129b8e60a8bc680d9501e39))
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
6
28
|
# [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)
|
7
29
|
|
8
30
|
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
package/README.md
CHANGED
@@ -18,7 +18,8 @@ Usage:
|
|
18
18
|
|
19
19
|
Options:
|
20
20
|
--name <string> - defines the package name
|
21
|
-
--
|
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.
|
22
23
|
--enable-typescript - enables TypeScript support for the package
|
23
24
|
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
24
25
|
```
|
package/create-package.js
CHANGED
@@ -37,9 +37,22 @@ const isNPMRC = sourcePath => {
|
|
37
37
|
};
|
38
38
|
|
39
39
|
// Validation of user input
|
40
|
-
const
|
40
|
+
const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
|
41
|
+
const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z][a-zA-Z0-9\-_]+$/);
|
42
|
+
const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
|
41
43
|
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
42
44
|
|
45
|
+
/**
|
46
|
+
* Hyphanates the given PascalCase string, f.e.:
|
47
|
+
* Foo -> "my-foo" (adds preffix)
|
48
|
+
* FooBar -> "foo-bar"
|
49
|
+
*/
|
50
|
+
const hyphaneteComponentName = (componentName) => {
|
51
|
+
const result = componentName.replace(/([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
|
52
|
+
|
53
|
+
return result.includes("-") ? result : `my-${result}`;
|
54
|
+
};
|
55
|
+
|
43
56
|
// Utils for building the file structure
|
44
57
|
const replaceVarsInFileContent = (vars, content) => {
|
45
58
|
for (let key in vars) {
|
@@ -92,14 +105,14 @@ const copyFiles = (vars, sourcePath, destPath) => {
|
|
92
105
|
}
|
93
106
|
};
|
94
107
|
|
95
|
-
const generateFilesContent = (name,
|
96
|
-
const
|
108
|
+
const generateFilesContent = (name, componentName, typescript, skipSubfolder) => {
|
109
|
+
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
97
110
|
|
98
111
|
// All variables that will be replaced in the content of the resources/
|
99
112
|
const vars = {
|
100
113
|
INIT_PACKAGE_VAR_NAME: name,
|
101
|
-
INIT_PACKAGE_VAR_TAG:
|
102
|
-
INIT_PACKAGE_VAR_CLASS_NAME:
|
114
|
+
INIT_PACKAGE_VAR_TAG: tagName,
|
115
|
+
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
103
116
|
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
104
117
|
};
|
105
118
|
|
@@ -141,7 +154,7 @@ const generateFilesContent = (name, tag, typescript) => {
|
|
141
154
|
}
|
142
155
|
|
143
156
|
// Update package.json
|
144
|
-
const destDir = path.join(
|
157
|
+
const destDir = skipSubfolder ? path.join("./") : path.join("./", name);
|
145
158
|
mkdirp.sync(destDir);
|
146
159
|
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
147
160
|
// Copy files
|
@@ -170,19 +183,24 @@ const generateFilesContent = (name, tag, typescript) => {
|
|
170
183
|
const createWebcomponentsPackage = async () => {
|
171
184
|
let response;
|
172
185
|
if (argv.name && !isNameValid(argv.name)) {
|
173
|
-
throw new Error("The package name should be a string
|
186
|
+
throw new Error("The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].");
|
187
|
+
}
|
188
|
+
|
189
|
+
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
190
|
+
throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
|
174
191
|
}
|
175
192
|
|
176
193
|
if (argv.tag && !isTagValid(argv.tag) ) {
|
177
|
-
throw new Error("The tag should be in kebab-case (my-
|
194
|
+
throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
|
178
195
|
}
|
179
196
|
|
180
197
|
let name = argv.name || "my-package";
|
181
|
-
let
|
198
|
+
let componentName = argv.componentName || "MyComponent";
|
182
199
|
let typescriptSupport = !!argv.enableTypescript;
|
200
|
+
const skipSubfolder = !!argv.skipSubfolder;
|
183
201
|
|
184
202
|
if (argv.skip) {
|
185
|
-
return generateFilesContent(name,
|
203
|
+
return generateFilesContent(name, componentName, typescriptSupport, skipSubfolder);
|
186
204
|
}
|
187
205
|
|
188
206
|
if (!argv.name) {
|
@@ -190,7 +208,7 @@ const createWebcomponentsPackage = async () => {
|
|
190
208
|
type: "text",
|
191
209
|
name: "name",
|
192
210
|
message: "Package name:",
|
193
|
-
validate: isNameValid,
|
211
|
+
validate: (value) => isNameValid(value) ? true : "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
|
194
212
|
});
|
195
213
|
name = response.name;
|
196
214
|
}
|
@@ -214,18 +232,18 @@ const createWebcomponentsPackage = async () => {
|
|
214
232
|
typescriptSupport = response.language;
|
215
233
|
}
|
216
234
|
|
217
|
-
if (!argv.
|
235
|
+
if (!argv.componentName) {
|
218
236
|
response = await prompts({
|
219
237
|
type: "text",
|
220
|
-
name: "
|
238
|
+
name: "componentName",
|
221
239
|
message: "Component name:",
|
222
|
-
initial: "
|
223
|
-
validate:
|
240
|
+
initial: "MyComponent",
|
241
|
+
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
224
242
|
});
|
225
|
-
|
243
|
+
componentName = response.componentName;
|
226
244
|
}
|
227
245
|
|
228
|
-
return generateFilesContent(name,
|
246
|
+
return generateFilesContent(name, componentName, typescriptSupport, skipSubfolder);
|
229
247
|
};
|
230
248
|
|
231
249
|
createWebcomponentsPackage();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/create-webcomponents-package",
|
3
|
-
"version": "1.13.0
|
3
|
+
"version": "1.13.0",
|
4
4
|
"description": "UI5 Web Components: create package",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -24,5 +24,5 @@
|
|
24
24
|
"prompts": "^2.4.1",
|
25
25
|
"yargs": "^17.5.1"
|
26
26
|
},
|
27
|
-
"gitHead": "
|
27
|
+
"gitHead": "c85ff70d47ba8f5e8c906066f2f4d36d432d2f6a"
|
28
28
|
}
|
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;
|
@@ -28,13 +28,14 @@
|
|
28
28
|
<li><a href="?sap-ui-theme=sap_fiori_3_dark">Fiori 3 Dark</a></li>
|
29
29
|
<li><a href="?sap-ui-theme=sap_fiori_3_hcb">Fiori 3 High Contrast Black</a></li>
|
30
30
|
<li><a href="?sap-ui-theme=sap_fiori_3_hcw">Fiori 3 High Contrast White</a></li>
|
31
|
-
<li><a href="?sap-ui-theme=
|
32
|
-
<li><a href="?sap-ui-theme=
|
33
|
-
<li><a href="?sap-ui-theme=
|
31
|
+
<li><a href="?sap-ui-theme=sap_horizon">Horizon</a></li>
|
32
|
+
<li><a href="?sap-ui-theme=sap_horizon_dark">Horizon Dark</a></li>
|
33
|
+
<li><a href="?sap-ui-theme=sap_horizon_hcb">Horizon High Contrast Black</a></li>
|
34
|
+
<li><a href="?sap-ui-theme=sap_horizon_hcw">Horizon High Contrast White</a></li>
|
34
35
|
</ul>
|
35
36
|
<br>
|
36
37
|
<span>or in the browser console, for example:</span>
|
37
|
-
<code>window['sap-ui-webcomponents-bundle'].configuration.setTheme("
|
38
|
+
<code>window['sap-ui-webcomponents-bundle'].configuration.setTheme("sap_horizon_hcb")</code>
|
38
39
|
|
39
40
|
<br><br>
|
40
41
|
|
package/template/tsconfig.json
CHANGED
package/template/global.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
// eslint-disable-next-line
|
2
|
-
import "@ui5/webcomponents-base/dist/global";
|
3
|
-
import { TemplateFunction } from "@ui5/webcomponents-base/dist/renderer/executeTemplate.js";
|
4
|
-
|
5
|
-
export {};
|
6
|
-
|
7
|
-
declare global {
|
8
|
-
module "*.lit.js" {
|
9
|
-
const content: TemplateFunction;
|
10
|
-
export default content;
|
11
|
-
}
|
12
|
-
}
|
File without changes
|
File without changes
|