@ui5/create-webcomponents-package 0.0.0-b93bc8b37 → 0.0.0-c0e494b02
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 +52 -0
- package/README.md +2 -1
- package/create-package.js +37 -22
- package/package.json +1 -1
- package/template/src/MyFirstComponent.js +1 -1
- package/template/src/MyFirstComponent.ts +1 -1
- package/template/global.d.ts +0 -12
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,58 @@
|
|
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
|
+
|
6
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)
|
7
59
|
|
8
60
|
**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
@@ -16,13 +16,6 @@ const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))
|
|
16
16
|
const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
|
17
17
|
|
18
18
|
// String utils
|
19
|
-
const capitalizeFirst = str => str.substr(0,1).toUpperCase() + str.substr(1);
|
20
|
-
const kebabToCamelCase = string => toCamelCase(string.split("-"));
|
21
|
-
const toCamelCase = parts => {
|
22
|
-
return parts.map((string, index) => {
|
23
|
-
return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
24
|
-
}).join("");
|
25
|
-
};
|
26
19
|
const isTSRelatedFile = sourcePath => {
|
27
20
|
return ["Assets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
|
28
21
|
};
|
@@ -38,8 +31,10 @@ const isNPMRC = sourcePath => {
|
|
38
31
|
|
39
32
|
// Validation of user input
|
40
33
|
const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
|
41
|
-
const
|
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-._~]*$/);
|
42
36
|
const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
|
37
|
+
const isNamespaceValid = name => typeof name === "string" && NamespacePattern.test(name);
|
43
38
|
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
44
39
|
|
45
40
|
/**
|
@@ -105,17 +100,20 @@ const copyFiles = (vars, sourcePath, destPath) => {
|
|
105
100
|
}
|
106
101
|
};
|
107
102
|
|
108
|
-
const generateFilesContent = (
|
103
|
+
const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
|
104
|
+
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
105
|
+
|
109
106
|
// All variables that will be replaced in the content of the resources/
|
110
107
|
const vars = {
|
111
|
-
|
108
|
+
INIT_PACKAGE_VAR_NAMESPACE: namespace, // namespace must be replaced before name
|
109
|
+
INIT_PACKAGE_VAR_NAME: packageName,
|
112
110
|
INIT_PACKAGE_VAR_TAG: tagName,
|
113
111
|
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
114
112
|
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
115
113
|
};
|
116
114
|
|
117
115
|
const packageContent = {
|
118
|
-
|
116
|
+
packageName,
|
119
117
|
version: "0.0.1",
|
120
118
|
ui5: {
|
121
119
|
webComponentsPackage: true,
|
@@ -152,14 +150,16 @@ const generateFilesContent = (name, componentName, tagName, typescript, skipSubf
|
|
152
150
|
}
|
153
151
|
|
154
152
|
// Update package.json
|
155
|
-
|
153
|
+
let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
|
154
|
+
|
155
|
+
destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
|
156
156
|
mkdirp.sync(destDir);
|
157
157
|
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
158
158
|
// Copy files
|
159
159
|
copyFiles(vars, TEMPLATE_DIR, destDir);
|
160
160
|
|
161
161
|
console.log("\nPackage successfully created!\nNext steps:\n");
|
162
|
-
console.log(`$ cd ${
|
162
|
+
console.log(`$ cd ${destDir}`);
|
163
163
|
|
164
164
|
let userAgentInfo;
|
165
165
|
try {
|
@@ -180,26 +180,30 @@ const generateFilesContent = (name, componentName, tagName, typescript, skipSubf
|
|
180
180
|
// Main function
|
181
181
|
const createWebcomponentsPackage = async () => {
|
182
182
|
let response;
|
183
|
-
if (argv.name && !
|
184
|
-
throw new Error("The package name should be a string
|
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
185
|
}
|
186
186
|
|
187
187
|
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
188
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
189
|
}
|
190
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
|
+
|
191
195
|
if (argv.tag && !isTagValid(argv.tag) ) {
|
192
196
|
throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
|
193
197
|
}
|
194
198
|
|
195
|
-
let
|
199
|
+
let packageName = argv.name || "my-package";
|
196
200
|
let componentName = argv.componentName || "MyComponent";
|
201
|
+
let namespace = argv.namespace || "demo.components";
|
197
202
|
let typescriptSupport = !!argv.enableTypescript;
|
198
|
-
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
199
203
|
const skipSubfolder = !!argv.skipSubfolder;
|
200
204
|
|
201
205
|
if (argv.skip) {
|
202
|
-
return generateFilesContent(
|
206
|
+
return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
|
203
207
|
}
|
204
208
|
|
205
209
|
if (!argv.name) {
|
@@ -207,9 +211,9 @@ const createWebcomponentsPackage = async () => {
|
|
207
211
|
type: "text",
|
208
212
|
name: "name",
|
209
213
|
message: "Package name:",
|
210
|
-
validate:
|
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, _, -].",
|
211
215
|
});
|
212
|
-
|
216
|
+
packageName = response.name;
|
213
217
|
}
|
214
218
|
|
215
219
|
if (!typescriptSupport) {
|
@@ -237,12 +241,23 @@ const createWebcomponentsPackage = async () => {
|
|
237
241
|
name: "componentName",
|
238
242
|
message: "Component name:",
|
239
243
|
initial: "MyComponent",
|
240
|
-
validate: isComponentNameValid,
|
244
|
+
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
241
245
|
});
|
242
246
|
componentName = response.componentName;
|
243
247
|
}
|
244
248
|
|
245
|
-
|
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);
|
246
261
|
};
|
247
262
|
|
248
263
|
createWebcomponentsPackage();
|
package/package.json
CHANGED
@@ -31,7 +31,7 @@ const metadata = {
|
|
31
31
|
* The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
|
32
32
|
*
|
33
33
|
* @constructor
|
34
|
-
* @alias
|
34
|
+
* @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
|
35
35
|
* @extends sap.ui.webc.base.UI5Element
|
36
36
|
* @tagname INIT_PACKAGE_VAR_TAG
|
37
37
|
* @public
|
@@ -20,7 +20,7 @@ import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
|
|
20
20
|
* The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
|
21
21
|
*
|
22
22
|
* @constructor
|
23
|
-
* @alias
|
23
|
+
* @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
|
24
24
|
* @extends sap.ui.webc.base.UI5Element
|
25
25
|
* @tagname INIT_PACKAGE_VAR_TAG
|
26
26
|
* @public
|
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
|
-
}
|