@iobroker/repochecker 4.2.1-alpha.0 → 4.3.0-alpha.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/README.md CHANGED
@@ -31,7 +31,8 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
31
31
  Placeholder for the next version (at the beginning of the line):
32
32
  ### **WORK IN PROGRESS**
33
33
  -->
34
- ### 4.2.1-alpha.0 (2025-09-27)
34
+ ### 4.3.0-alpha.0 (2025-09-29)
35
+ - (@copilot) Added version format validation check (E061) for invalid semver format according to ioBroker requirements
35
36
  - (@copilot) Added structured GitHub issue templates for bug reports, false positives, new checks, check changes, and enhancements
36
37
  - (@copilot) Fixed deprecated function checking for adapter methods called outside class context
37
38
 
@@ -234,6 +234,52 @@ const validObjectsPackageJson = [
234
234
  'workspaces',
235
235
  ];
236
236
 
237
+ /**
238
+ * Validates release format according to ioBroker semver subset requirements
239
+ *
240
+ * @param {string} version - Version string to validate
241
+ * @returns {boolean} true if valid, false if invalid
242
+ */
243
+ function validateReleaseFormat(version) {
244
+ if (!version || typeof version !== 'string') {
245
+ return false;
246
+ }
247
+
248
+ // Regex to match the specified format:
249
+ // - version must consist of 3 digits separated by a dot
250
+ // - optionally followed by a Prerelease-Identifier, a dot and a Prerelease version
251
+ // - all numbers must not have leading zeroes (except single zero)
252
+ // - Prerelease-Identifier must only contain characters, numbers and a minus sign ([a-zA-Z0-9-])
253
+ // - Prerelease version must be a number without leading zeroes
254
+ // - empty fields resulting in two or more dots following each other are not valid
255
+
256
+ const regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([a-zA-Z0-9-]+)\.(0|[1-9]\d*))?$/;
257
+
258
+ const match = version.match(regex);
259
+ if (!match) {
260
+ return false;
261
+ }
262
+
263
+ const [, , , , prereleaseId, prereleaseVersion] = match;
264
+
265
+ // Additional validation for prerelease identifier
266
+ if (prereleaseId !== undefined) {
267
+ // Ensure prerelease identifier is valid:
268
+ // - cannot be only numbers (RC5 is invalid)
269
+ // - cannot end with numbers (RC5 is invalid, RC is valid)
270
+ if (/^\d+$/.test(prereleaseId) || /\d+$/.test(prereleaseId)) {
271
+ return false;
272
+ }
273
+
274
+ // Ensure prerelease version is provided when prerelease ID is present
275
+ if (prereleaseVersion === undefined) {
276
+ return false;
277
+ }
278
+ }
279
+
280
+ return true;
281
+ }
282
+
237
283
  async function getPackageJson(context) {
238
284
  console.log('[init] getting package.json');
239
285
 
@@ -362,6 +408,15 @@ async function checkPackageJson(context) {
362
408
  context.errors.push('[E009] No "version" key found in the package.json');
363
409
  } else {
364
410
  context.checks.push('Version found in package.json');
411
+
412
+ // Validate version format according to ioBroker requirements
413
+ if (!validateReleaseFormat(context.packageJson.version)) {
414
+ context.errors.push(
415
+ `[E061] Invalid version format "${context.packageJson.version}". Version must follow semver format: MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-PRERELEASE.NUMBER (e.g., "1.2.3" or "1.2.3-alpha.4").`,
416
+ );
417
+ } else {
418
+ context.checks.push('Version format is valid');
419
+ }
365
420
  }
366
421
 
367
422
  if (!context.packageJson.description) {
@@ -962,6 +1017,7 @@ async function checkPackageJson(context) {
962
1017
 
963
1018
  exports.getPackageJson = getPackageJson;
964
1019
  exports.checkPackageJson = checkPackageJson;
1020
+ exports.validateReleaseFormat = validateReleaseFormat;
965
1021
 
966
1022
  // List of error and warnings used at this module
967
1023
  // ----------------------------------------------
@@ -1030,5 +1086,5 @@ exports.checkPackageJson = checkPackageJson;
1030
1086
  // [058] Key ${objectName} at package.json is not supported. Please remove.
1031
1087
  // [059] No "scripts" key found in the package.json.
1032
1088
  // [060] ${dependency} listed as dependency and as devDependency.
1033
- // [061] Consider using "${dependency}".
1089
+ // [061] Invalid version format "${context.packageJson.version}". Version must follow semver format: MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-PRERELEASE.NUMBER (e.g., "1.2.3" or "1.2.3-alpha.4"). No leading zeros allowed, prerelease identifiers must contain only letters, numbers, and hyphens.
1034
1090
  // [062] No devDependency declared for ${dependency}. Please consider adding "${dependency}":"${recommendedVersion}" to devDependencies at package.json`
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.2.1-alpha.0",
2
+ "version": "4.3.0-alpha.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.17.1",