@ui5/create-webcomponents-package 1.14.0-rc.0 → 1.14.0-rc.2

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 CHANGED
@@ -3,6 +3,22 @@
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.2](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0-rc.1...v1.14.0-rc.2) (2023-06-01)
7
+
8
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
9
+
10
+
11
+
12
+
13
+
14
+ # [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)
15
+
16
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
17
+
18
+
19
+
20
+
21
+
6
22
  # [1.14.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.13.2...v1.14.0-rc.0) (2023-05-18)
7
23
 
8
24
 
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
  };
@@ -39,7 +32,7 @@ const isNPMRC = sourcePath => {
39
32
  // Validation of user input
40
33
  const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
41
34
  const NamespacePattern = /^[a-z][a-z0-9\.\-]+$/;
42
- const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z][a-zA-Z0-9\-_]+$/);
35
+ const isPackageNameValid = name => typeof name === "string" && name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
43
36
  const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
44
37
  const isNamespaceValid = name => typeof name === "string" && NamespacePattern.test(name);
45
38
  const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
@@ -107,20 +100,20 @@ const copyFiles = (vars, sourcePath, destPath) => {
107
100
  }
108
101
  };
109
102
 
110
- const generateFilesContent = (name, componentName, namespace, typescript, skipSubfolder) => {
103
+ const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
111
104
  const tagName = argv.tag || hyphaneteComponentName(componentName);
112
105
 
113
106
  // All variables that will be replaced in the content of the resources/
114
107
  const vars = {
115
108
  INIT_PACKAGE_VAR_NAMESPACE: namespace, // namespace must be replaced before name
116
- INIT_PACKAGE_VAR_NAME: name,
109
+ INIT_PACKAGE_VAR_NAME: packageName,
117
110
  INIT_PACKAGE_VAR_TAG: tagName,
118
111
  INIT_PACKAGE_VAR_CLASS_NAME: componentName,
119
112
  INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
120
113
  };
121
114
 
122
115
  const packageContent = {
123
- name,
116
+ packageName,
124
117
  version: "0.0.1",
125
118
  ui5: {
126
119
  webComponentsPackage: true,
@@ -157,14 +150,16 @@ const generateFilesContent = (name, componentName, namespace, typescript, skipSu
157
150
  }
158
151
 
159
152
  // Update package.json
160
- const destDir = skipSubfolder ? path.join("./") : path.join("./", name);
153
+ let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
154
+
155
+ destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
161
156
  mkdirp.sync(destDir);
162
157
  fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
163
158
  // Copy files
164
159
  copyFiles(vars, TEMPLATE_DIR, destDir);
165
160
 
166
161
  console.log("\nPackage successfully created!\nNext steps:\n");
167
- console.log(`$ cd ${name}`);
162
+ console.log(`$ cd ${destDir}`);
168
163
 
169
164
  let userAgentInfo;
170
165
  try {
@@ -185,7 +180,7 @@ const generateFilesContent = (name, componentName, namespace, typescript, skipSu
185
180
  // Main function
186
181
  const createWebcomponentsPackage = async () => {
187
182
  let response;
188
- if (argv.name && !isNameValid(argv.name)) {
183
+ if (argv.name && !isPackageNameValid(argv.name)) {
189
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].");
190
185
  }
191
186
 
@@ -201,14 +196,14 @@ const createWebcomponentsPackage = async () => {
201
196
  throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
202
197
  }
203
198
 
204
- let name = argv.name || "my-package";
199
+ let packageName = argv.name || "my-package";
205
200
  let componentName = argv.componentName || "MyComponent";
206
201
  let namespace = argv.namespace || "demo.components";
207
202
  let typescriptSupport = !!argv.enableTypescript;
208
203
  const skipSubfolder = !!argv.skipSubfolder;
209
204
 
210
205
  if (argv.skip) {
211
- return generateFilesContent(name, componentName, namespace, typescriptSupport, skipSubfolder);
206
+ return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
212
207
  }
213
208
 
214
209
  if (!argv.name) {
@@ -216,9 +211,9 @@ const createWebcomponentsPackage = async () => {
216
211
  type: "text",
217
212
  name: "name",
218
213
  message: "Package name:",
219
- 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, _, -].",
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, _, -].",
220
215
  });
221
- name = response.name;
216
+ packageName = response.name;
222
217
  }
223
218
 
224
219
  if (!typescriptSupport) {
@@ -262,7 +257,7 @@ const createWebcomponentsPackage = async () => {
262
257
  namespace = response.namespace;
263
258
  }
264
259
 
265
- return generateFilesContent(name, componentName, namespace, typescriptSupport, skipSubfolder);
260
+ return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
266
261
  };
267
262
 
268
263
  createWebcomponentsPackage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/create-webcomponents-package",
3
- "version": "1.14.0-rc.0",
3
+ "version": "1.14.0-rc.2",
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": "16aabf49d35a4ac30a5639fa5a88e46cb56024d8"
27
+ "gitHead": "ace23889ee6ba92032a07ffa7c024284e2853e1f"
28
28
  }