@ui5/create-webcomponents-package 0.0.0-4b9b0ab7c → 0.0.0-5e31d3069
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 +67 -0
- package/create-package.js +60 -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/test/specs/Demo.spec.js +3 -1
- package/template/tsconfig.json +1 -0
- 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,73 @@
|
|
|
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.3](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.2...v1.13.0-rc.3) (2023-04-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [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)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [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)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [1.13.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0...v1.13.0-rc.0) (2023-04-06)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [1.12.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.3...v1.12.0) (2023-04-04)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# [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)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [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)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Bug Fixes
|
|
58
|
+
|
|
59
|
+
* 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))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# [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)
|
|
66
|
+
|
|
67
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
6
73
|
# [1.12.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0...v1.12.0-rc.0) (2023-03-09)
|
|
7
74
|
|
|
8
75
|
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
package/create-package.js
CHANGED
|
@@ -23,14 +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
|
+
const isJSRelatedFile = sourcePath => {
|
|
30
|
+
return ["Assets.js", "MyFirstComponent.js"].some(fileName => sourcePath.includes(fileName));
|
|
31
|
+
};
|
|
32
|
+
const isGitIgnore = sourcePath => {
|
|
33
|
+
return sourcePath.includes("gitignore");
|
|
34
|
+
};
|
|
35
|
+
const isNPMRC = sourcePath => {
|
|
36
|
+
return sourcePath.includes("npmrc");
|
|
37
|
+
};
|
|
29
38
|
|
|
30
39
|
// Validation of user input
|
|
40
|
+
const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
|
|
31
41
|
const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
|
|
42
|
+
const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
|
|
32
43
|
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
|
33
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
|
+
|
|
34
56
|
// Utils for building the file structure
|
|
35
57
|
const replaceVarsInFileContent = (vars, content) => {
|
|
36
58
|
for (let key in vars) {
|
|
@@ -45,8 +67,8 @@ const replaceVarsInFileName = (vars, fileName) => {
|
|
|
45
67
|
};
|
|
46
68
|
|
|
47
69
|
const copyFile = (vars, sourcePath, destPath) => {
|
|
48
|
-
const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && sourcePath
|
|
49
|
-
const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT &&
|
|
70
|
+
const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
|
|
71
|
+
const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
|
|
50
72
|
|
|
51
73
|
if (ignoreJsRelated || ignoreTsRelated) {
|
|
52
74
|
return;
|
|
@@ -55,7 +77,18 @@ const copyFile = (vars, sourcePath, destPath) => {
|
|
|
55
77
|
let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
|
|
56
78
|
content = replaceVarsInFileContent(vars, content);
|
|
57
79
|
destPath = replaceVarsInFileName(vars, destPath);
|
|
80
|
+
|
|
58
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
|
+
}
|
|
59
92
|
};
|
|
60
93
|
|
|
61
94
|
const copyFiles = (vars, sourcePath, destPath) => {
|
|
@@ -72,14 +105,12 @@ const copyFiles = (vars, sourcePath, destPath) => {
|
|
|
72
105
|
}
|
|
73
106
|
};
|
|
74
107
|
|
|
75
|
-
const generateFilesContent = (name,
|
|
76
|
-
const className = capitalizeFirst(kebabToCamelCase(tag));
|
|
77
|
-
|
|
108
|
+
const generateFilesContent = (name, componentName, tagName, typescript, skipSubfolder) => {
|
|
78
109
|
// All variables that will be replaced in the content of the resources/
|
|
79
110
|
const vars = {
|
|
80
111
|
INIT_PACKAGE_VAR_NAME: name,
|
|
81
|
-
INIT_PACKAGE_VAR_TAG:
|
|
82
|
-
INIT_PACKAGE_VAR_CLASS_NAME:
|
|
112
|
+
INIT_PACKAGE_VAR_TAG: tagName,
|
|
113
|
+
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
|
83
114
|
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
|
84
115
|
};
|
|
85
116
|
|
|
@@ -116,8 +147,12 @@ const generateFilesContent = (name, tag, typescript) => {
|
|
|
116
147
|
},
|
|
117
148
|
};
|
|
118
149
|
|
|
150
|
+
if (typescript) {
|
|
151
|
+
packageContent.devDependencies.typescript = "^4.9.4";
|
|
152
|
+
}
|
|
153
|
+
|
|
119
154
|
// Update package.json
|
|
120
|
-
const destDir = path.join(
|
|
155
|
+
const destDir = skipSubfolder ? path.join("./") : path.join("./", name);
|
|
121
156
|
mkdirp.sync(destDir);
|
|
122
157
|
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
|
123
158
|
// Copy files
|
|
@@ -149,16 +184,22 @@ const createWebcomponentsPackage = async () => {
|
|
|
149
184
|
throw new Error("The package name should be a string (a-z, A-Z, 0-9).");
|
|
150
185
|
}
|
|
151
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
|
+
|
|
152
191
|
if (argv.tag && !isTagValid(argv.tag) ) {
|
|
153
|
-
throw new Error("The tag should be in kebab-case (my-
|
|
192
|
+
throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
|
|
154
193
|
}
|
|
155
194
|
|
|
156
195
|
let name = argv.name || "my-package";
|
|
157
|
-
let
|
|
196
|
+
let componentName = argv.componentName || "MyComponent";
|
|
158
197
|
let typescriptSupport = !!argv.enableTypescript;
|
|
198
|
+
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
|
199
|
+
const skipSubfolder = !!argv.skipSubfolder;
|
|
159
200
|
|
|
160
201
|
if (argv.skip) {
|
|
161
|
-
return generateFilesContent(name,
|
|
202
|
+
return generateFilesContent(name, componentName, tagName, typescriptSupport, skipSubfolder);
|
|
162
203
|
}
|
|
163
204
|
|
|
164
205
|
if (!argv.name) {
|
|
@@ -166,7 +207,7 @@ const createWebcomponentsPackage = async () => {
|
|
|
166
207
|
type: "text",
|
|
167
208
|
name: "name",
|
|
168
209
|
message: "Package name:",
|
|
169
|
-
validate: isNameValid,
|
|
210
|
+
validate: (value) => isNameValid(value) ? true : "Package name should be a string containing the following symbols [a-z,A-Z,0-9,_,-].",
|
|
170
211
|
});
|
|
171
212
|
name = response.name;
|
|
172
213
|
}
|
|
@@ -190,18 +231,18 @@ const createWebcomponentsPackage = async () => {
|
|
|
190
231
|
typescriptSupport = response.language;
|
|
191
232
|
}
|
|
192
233
|
|
|
193
|
-
if (!argv.
|
|
234
|
+
if (!argv.componentName) {
|
|
194
235
|
response = await prompts({
|
|
195
236
|
type: "text",
|
|
196
|
-
name: "
|
|
237
|
+
name: "componentName",
|
|
197
238
|
message: "Component name:",
|
|
198
|
-
initial: "
|
|
199
|
-
validate:
|
|
239
|
+
initial: "MyComponent",
|
|
240
|
+
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase pattern (f.e. Button, MyButton, etc.).",
|
|
200
241
|
});
|
|
201
|
-
|
|
242
|
+
componentName = response.componentName;
|
|
202
243
|
}
|
|
203
244
|
|
|
204
|
-
return generateFilesContent(name,
|
|
245
|
+
return generateFilesContent(name, componentName, tagName, typescriptSupport, skipSubfolder);
|
|
205
246
|
};
|
|
206
247
|
|
|
207
248
|
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
|
|
|
@@ -1,7 +1,9 @@
|
|
|
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
9
|
|
package/template/tsconfig.json
CHANGED
|
File without changes
|
|
File without changes
|