@iobroker/repochecker 4.2.0-alpha.2 → 4.2.0-alpha.4
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 +3 -4
- package/lib/M100_IOPackageJson.js +70 -0
- package/lib/M500_Code.js +4 -4
- package/lib/M800_Github.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -33,11 +33,10 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
|
|
|
33
33
|
-->
|
|
34
34
|
|
|
35
35
|
## Changelog
|
|
36
|
-
### 4.2.0-alpha.
|
|
36
|
+
### 4.2.0-alpha.4 (2025-09-15)
|
|
37
|
+
- (copilot) Added io-package.json schema validation against official schema (W205, W207, W208) [#503].
|
|
37
38
|
- (copilot) Added check for deprecated adapter methods (createState/createChannel/createDevice/deleteState/deleteChannel/deleteDevice) (W533) [#182].
|
|
38
|
-
- (copilot) Added check for outdated lib/tools.js file usage (W532) [#432].
|
|
39
|
-
|
|
40
|
-
### 4.2.0-alpha.1 (2025-09-14)
|
|
39
|
+
- (copilot) Added check for outdated lib/tools.js file usage (W532) [#432].
|
|
41
40
|
- (copilot) Added VS Code schema definitions checker for .vscode/settings.json - validates json.schemas for io-package.json and jsonConfig files [#336].
|
|
42
41
|
- (copilot) Change W510 to E510: Convert missing admin i18n files from warning to error [#400].
|
|
43
42
|
- (copilot) Renumbered all issues in M500__JsonConfig.js from 500-511 range to 550-561 range [#481].
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
const compareVersions = require('compare-versions');
|
|
11
11
|
const sizeOf = require('image-size');
|
|
12
|
+
const Ajv = require('ajv');
|
|
12
13
|
|
|
13
14
|
const common = require('./common.js');
|
|
15
|
+
const config = require('./config.js');
|
|
14
16
|
|
|
15
17
|
async function getIOPackageJson(context) {
|
|
16
18
|
console.log('[init] getting io-package.json');
|
|
@@ -96,6 +98,68 @@ const blacklistIOPackageJson = {
|
|
|
96
98
|
},
|
|
97
99
|
};
|
|
98
100
|
|
|
101
|
+
async function validateIOPackageSchema(context) {
|
|
102
|
+
common.debug('[schema] validating io-package.json against schema');
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
// Download the schema
|
|
106
|
+
const schemaUrl = config.schemaUrls['io-package'];
|
|
107
|
+
common.debug(`Downloading schema from ${schemaUrl}`);
|
|
108
|
+
|
|
109
|
+
const schemaData = await common.downloadURL(schemaUrl, false);
|
|
110
|
+
if (!schemaData) {
|
|
111
|
+
context.warnings.push('[W207] Could not download io-package.json schema for validation');
|
|
112
|
+
return context;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const schema = JSON.parse(schemaData);
|
|
116
|
+
|
|
117
|
+
// Initialize AJV validator
|
|
118
|
+
const ajv = new Ajv({ allErrors: true, verbose: true });
|
|
119
|
+
const validate = ajv.compile(schema);
|
|
120
|
+
|
|
121
|
+
// Validate io-package.json against schema
|
|
122
|
+
const valid = validate(context.ioPackageJson);
|
|
123
|
+
|
|
124
|
+
if (valid) {
|
|
125
|
+
context.checks.push('io-package.json validates against schema');
|
|
126
|
+
} else {
|
|
127
|
+
// Log individual validation errors
|
|
128
|
+
if (validate.errors) {
|
|
129
|
+
for (const error of validate.errors) {
|
|
130
|
+
common.debug(`Schema validation error block:\n ${JSON.stringify(error)}`);
|
|
131
|
+
|
|
132
|
+
const path = error.instancePath || 'root';
|
|
133
|
+
const message = error.message;
|
|
134
|
+
|
|
135
|
+
// Create a concise, developer-friendly error message
|
|
136
|
+
let errorMsg;
|
|
137
|
+
if (error.keyword === 'required') {
|
|
138
|
+
errorMsg = `Missing required property "${error.params.missingProperty}" in ${path || 'io-package.json'}`;
|
|
139
|
+
} else if (error.keyword === 'additionalProperties') {
|
|
140
|
+
errorMsg = `Unknown property "${error.params.additionalProperty}" in ${path}`;
|
|
141
|
+
} else if (error.keyword === 'type') {
|
|
142
|
+
errorMsg = `Property "${path}" should be ${error.params.type}`;
|
|
143
|
+
} else if (error.keyword === 'enum') {
|
|
144
|
+
errorMsg = `Property "${path}" should be one of: ${error.params.allowedValues?.join(', ')}`;
|
|
145
|
+
} else {
|
|
146
|
+
errorMsg = `Property "${path}" ${message}`;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
context.warnings.push(`[W205] Schema validation: ${errorMsg}`);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
context.warnings.push('[W205] io-package.json does not validate against schema');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
common.debug(`Schema validation error: ${error.message}`);
|
|
157
|
+
context.warnings.push(`[W208] Schema validation failed: ${error.message}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return context;
|
|
161
|
+
}
|
|
162
|
+
|
|
99
163
|
async function checkIOPackageJson(context) {
|
|
100
164
|
console.log('\n[E100 - E249] checking io-package.json');
|
|
101
165
|
|
|
@@ -222,6 +286,9 @@ async function checkIOPackageJson(context) {
|
|
|
222
286
|
}
|
|
223
287
|
context.checks.push('"common" found in io-package.json');
|
|
224
288
|
|
|
289
|
+
// Validate io-package.json against its schema
|
|
290
|
+
await validateIOPackageSchema(context);
|
|
291
|
+
|
|
225
292
|
if (!context.ioPackageJson.common.name || context.ioPackageJson.common.name !== context.adapterName.toLowerCase()) {
|
|
226
293
|
context.errors.push(
|
|
227
294
|
`[E103] "common.name" in io-package.json must be equal to "${context.adapterName.toLowerCase()}'". Now is ${context.ioPackageJson.common.name}`,
|
|
@@ -1219,3 +1286,6 @@ exports.checkIOPackageJson = checkIOPackageJson;
|
|
|
1219
1286
|
// [202] Consider adding 'vis-2' to "common.restartAdapters" as 'vis' is already listed in io-package.json
|
|
1220
1287
|
// [203] Encryption of array elements "${key}" is not yet available
|
|
1221
1288
|
// [204] allowInit is only used with scheduled adapters and should be removed
|
|
1289
|
+
// [205] Schema validation: ${errorMsg}
|
|
1290
|
+
// [207] Could not download io-package.json schema for validation
|
|
1291
|
+
// [208] Schema validation failed: ${error.message}
|
package/lib/M500_Code.js
CHANGED
|
@@ -536,7 +536,9 @@ async function checkCode(context) {
|
|
|
536
536
|
if (
|
|
537
537
|
content.includes('lib/tools') ||
|
|
538
538
|
content.includes('./lib/tools') ||
|
|
539
|
-
content.includes('../lib/tools')
|
|
539
|
+
content.includes('../lib/tools') ||
|
|
540
|
+
content.includes('./tools') ||
|
|
541
|
+
content.includes('../tools')
|
|
540
542
|
) {
|
|
541
543
|
isUsed = true;
|
|
542
544
|
break;
|
|
@@ -545,9 +547,7 @@ async function checkCode(context) {
|
|
|
545
547
|
}
|
|
546
548
|
|
|
547
549
|
if (!isUsed) {
|
|
548
|
-
context.warnings.push(
|
|
549
|
-
'[S532] "lib/tools.js" found in repo but not used anywhere. Consider removing this outdated file.',
|
|
550
|
-
);
|
|
550
|
+
context.warnings.push('[S532] "lib/tools.js" found in repo but not used anywhere. Consider removing file.');
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
|
package/lib/M800_Github.js
CHANGED
|
@@ -19,7 +19,7 @@ const issuesToWatchAsError = [
|
|
|
19
19
|
const issuesToWatchAsWarning = [
|
|
20
20
|
'Migration to ESLint 9 and @iobroker/eslint-config',
|
|
21
21
|
'Translations update from ioBroker Translation System',
|
|
22
|
-
|
|
22
|
+
];
|
|
23
23
|
|
|
24
24
|
// disable axios caching
|
|
25
25
|
axios.defaults.headers.common = {
|