@ui5/create-webcomponents-package 0.0.0-cad512aa3 → 0.0.0-cb061e041
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 +70 -0
- package/README.md +2 -1
- package/create-package.js +54 -19
- package/package.json +1 -1
- package/template/.eslintignore +2 -1
- package/template/.eslintrc.js +5 -0
- package/template/gitignore +4 -0
- package/template/npmrc +2 -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,76 @@
|
|
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-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.3...v1.13.0-rc.4) (2023-05-04)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* generate TS from HBS templates ([#6558](https://github.com/SAP/ui5-webcomponents/issues/6558)) ([02611b2](https://github.com/SAP/ui5-webcomponents/commit/02611b2e24b2c2a06129b8e60a8bc680d9501e39))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# [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)
|
18
|
+
|
19
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
# [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)
|
26
|
+
|
27
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
# [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)
|
34
|
+
|
35
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
# [1.13.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0...v1.13.0-rc.0) (2023-04-06)
|
42
|
+
|
43
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
# [1.12.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.3...v1.12.0) (2023-04-04)
|
50
|
+
|
51
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
# [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)
|
58
|
+
|
59
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
# [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)
|
66
|
+
|
67
|
+
|
68
|
+
### Bug Fixes
|
69
|
+
|
70
|
+
* 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))
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
6
76
|
# [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)
|
7
77
|
|
8
78
|
**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
@@ -23,17 +23,36 @@ const toCamelCase = parts => {
|
|
23
23
|
return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
24
24
|
}).join("");
|
25
25
|
};
|
26
|
-
const
|
26
|
+
const isTSRelatedFile = sourcePath => {
|
27
27
|
return ["Assets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
|
28
28
|
};
|
29
29
|
const isJSRelatedFile = sourcePath => {
|
30
30
|
return ["Assets.js", "MyFirstComponent.js"].some(fileName => sourcePath.includes(fileName));
|
31
31
|
};
|
32
|
+
const isGitIgnore = sourcePath => {
|
33
|
+
return sourcePath.includes("gitignore");
|
34
|
+
};
|
35
|
+
const isNPMRC = sourcePath => {
|
36
|
+
return sourcePath.includes("npmrc");
|
37
|
+
};
|
32
38
|
|
33
39
|
// Validation of user input
|
34
|
-
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);
|
35
43
|
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
36
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
|
+
|
37
56
|
// Utils for building the file structure
|
38
57
|
const replaceVarsInFileContent = (vars, content) => {
|
39
58
|
for (let key in vars) {
|
@@ -49,7 +68,7 @@ const replaceVarsInFileName = (vars, fileName) => {
|
|
49
68
|
|
50
69
|
const copyFile = (vars, sourcePath, destPath) => {
|
51
70
|
const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
|
52
|
-
const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT &&
|
71
|
+
const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
|
53
72
|
|
54
73
|
if (ignoreJsRelated || ignoreTsRelated) {
|
55
74
|
return;
|
@@ -58,7 +77,18 @@ const copyFile = (vars, sourcePath, destPath) => {
|
|
58
77
|
let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
|
59
78
|
content = replaceVarsInFileContent(vars, content);
|
60
79
|
destPath = replaceVarsInFileName(vars, destPath);
|
80
|
+
|
61
81
|
fs.writeFileSync(destPath, content);
|
82
|
+
|
83
|
+
// Rename "gitignore" to ".gitignore" (npm init won't include ".gitignore", so we add it as "gitignore" and rename it later)
|
84
|
+
if (isGitIgnore(sourcePath)) {
|
85
|
+
fs.renameSync(destPath, destPath.replace("gitignore", ".gitignore"))
|
86
|
+
}
|
87
|
+
|
88
|
+
// Rename "npmrc" to ".npmrc" (npm init won't include ".npmrc", so we add it as "npmrc" and rename it later)
|
89
|
+
if (isNPMRC(sourcePath)) {
|
90
|
+
fs.renameSync(destPath, destPath.replace("npmrc", ".npmrc"));
|
91
|
+
}
|
62
92
|
};
|
63
93
|
|
64
94
|
const copyFiles = (vars, sourcePath, destPath) => {
|
@@ -75,14 +105,14 @@ const copyFiles = (vars, sourcePath, destPath) => {
|
|
75
105
|
}
|
76
106
|
};
|
77
107
|
|
78
|
-
const generateFilesContent = (name,
|
79
|
-
const
|
108
|
+
const generateFilesContent = (name, componentName, typescript, skipSubfolder) => {
|
109
|
+
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
80
110
|
|
81
111
|
// All variables that will be replaced in the content of the resources/
|
82
112
|
const vars = {
|
83
113
|
INIT_PACKAGE_VAR_NAME: name,
|
84
|
-
INIT_PACKAGE_VAR_TAG:
|
85
|
-
INIT_PACKAGE_VAR_CLASS_NAME:
|
114
|
+
INIT_PACKAGE_VAR_TAG: tagName,
|
115
|
+
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
86
116
|
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
87
117
|
};
|
88
118
|
|
@@ -124,7 +154,7 @@ const generateFilesContent = (name, tag, typescript) => {
|
|
124
154
|
}
|
125
155
|
|
126
156
|
// Update package.json
|
127
|
-
const destDir = path.join(
|
157
|
+
const destDir = skipSubfolder ? path.join("./") : path.join("./", name);
|
128
158
|
mkdirp.sync(destDir);
|
129
159
|
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
130
160
|
// Copy files
|
@@ -153,19 +183,24 @@ const generateFilesContent = (name, tag, typescript) => {
|
|
153
183
|
const createWebcomponentsPackage = async () => {
|
154
184
|
let response;
|
155
185
|
if (argv.name && !isNameValid(argv.name)) {
|
156
|
-
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.");
|
157
191
|
}
|
158
192
|
|
159
193
|
if (argv.tag && !isTagValid(argv.tag) ) {
|
160
|
-
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.");
|
161
195
|
}
|
162
196
|
|
163
197
|
let name = argv.name || "my-package";
|
164
|
-
let
|
198
|
+
let componentName = argv.componentName || "MyComponent";
|
165
199
|
let typescriptSupport = !!argv.enableTypescript;
|
200
|
+
const skipSubfolder = !!argv.skipSubfolder;
|
166
201
|
|
167
202
|
if (argv.skip) {
|
168
|
-
return generateFilesContent(name,
|
203
|
+
return generateFilesContent(name, componentName, typescriptSupport, skipSubfolder);
|
169
204
|
}
|
170
205
|
|
171
206
|
if (!argv.name) {
|
@@ -173,7 +208,7 @@ const createWebcomponentsPackage = async () => {
|
|
173
208
|
type: "text",
|
174
209
|
name: "name",
|
175
210
|
message: "Package name:",
|
176
|
-
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, _, -].",
|
177
212
|
});
|
178
213
|
name = response.name;
|
179
214
|
}
|
@@ -197,18 +232,18 @@ const createWebcomponentsPackage = async () => {
|
|
197
232
|
typescriptSupport = response.language;
|
198
233
|
}
|
199
234
|
|
200
|
-
if (!argv.
|
235
|
+
if (!argv.componentName) {
|
201
236
|
response = await prompts({
|
202
237
|
type: "text",
|
203
|
-
name: "
|
238
|
+
name: "componentName",
|
204
239
|
message: "Component name:",
|
205
|
-
initial: "
|
206
|
-
validate:
|
240
|
+
initial: "MyComponent",
|
241
|
+
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
207
242
|
});
|
208
|
-
|
243
|
+
componentName = response.componentName;
|
209
244
|
}
|
210
245
|
|
211
|
-
return generateFilesContent(name,
|
246
|
+
return generateFilesContent(name, componentName, typescriptSupport, skipSubfolder);
|
212
247
|
};
|
213
248
|
|
214
249
|
createWebcomponentsPackage();
|
package/package.json
CHANGED
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
@@ -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
|