@iobroker/repochecker 5.9.1 → 5.10.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 +7 -0
- package/lib/M2000_Npm.js +1 -1
- package/lib/M3000_Testing.js +20 -19
- package/lib/M4000_Repository.js +5 -0
- package/lib/M5000_Code.js +31 -1
- package/lib/M8900__Dependabot.js +5 -4
- package/lib/M9000_GitNpmIgnore.js +113 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -25,6 +25,13 @@ Example:
|
|
|
25
25
|
Placeholder for the next version (at the beginning of the line):
|
|
26
26
|
### **WORK IN PROGRESS**
|
|
27
27
|
-->
|
|
28
|
+
### 5.10.0 (2026-04-10)
|
|
29
|
+
- (@copilot) Added `minimatch` as an explicit dependency in `package.json` (used by `M9000_GitNpmIgnore.js` for glob pattern matching).
|
|
30
|
+
- (@copilot) Fixed false positives in `[E9507]` when i18n directories are covered by glob patterns in `package.json` `"files"` field.
|
|
31
|
+
- (@copilot) Added [W4047]: warn when adapter is found in the latest repository but not yet available in the stable repository. Related to [#820].
|
|
32
|
+
- (@copilot) Added `[E9506]`: error when an i18n directory is explicitly excluded by `.npmignore`, which would cause translations to be missing from the npm package.
|
|
33
|
+
- (@copilot) Added `[E9507]`: error when an i18n directory is present in the repository but not covered by the `"files"` field in `package.json`, which would cause translations to be missing from the npm package.
|
|
34
|
+
|
|
28
35
|
### 5.9.1 (2026-04-08)
|
|
29
36
|
- (@copilot) Added `isNewAdapter` flag: set to `true` when adapter is not listed in the latest repository, with an info log when set.
|
|
30
37
|
- (@copilot) Added `--strict` command line option: when active, outputs an info log "running in strict mode".
|
package/lib/M2000_Npm.js
CHANGED
|
@@ -104,7 +104,7 @@ async function checkNpm(context) {
|
|
|
104
104
|
context.checks.push('Bluefox found in collaborators on NPM');
|
|
105
105
|
}
|
|
106
106
|
} catch {
|
|
107
|
-
context.errors.push(
|
|
107
|
+
context.errors.push(`[E2000] Package iobroker.${context.adapterName} not found on npm. Please publish`);
|
|
108
108
|
return context;
|
|
109
109
|
}
|
|
110
110
|
} else {
|
package/lib/M3000_Testing.js
CHANGED
|
@@ -11,6 +11,7 @@ const yaml = require('js-yaml');
|
|
|
11
11
|
const common = require('./common.js');
|
|
12
12
|
|
|
13
13
|
const WORKFLOW_FILE = '/.github/workflows/test-and-release.yml';
|
|
14
|
+
const WORKFLOW_FILE_SHORT = 'test-and-release.yml';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Returns true if the given file path exists in the context's filesList,
|
|
@@ -168,7 +169,7 @@ async function checkTests(context) {
|
|
|
168
169
|
// --- W3004: check workflow name ---
|
|
169
170
|
if (workflow.name !== 'Test and Release') {
|
|
170
171
|
context.warnings.push(
|
|
171
|
-
`[W3004] Workflow "name" in "${
|
|
172
|
+
`[W3004] Workflow "name" in "${WORKFLOW_FILE_SHORT}" must be "Test and Release" (found: "${workflow.name || '(not set)'}" ).`,
|
|
172
173
|
);
|
|
173
174
|
} else {
|
|
174
175
|
context.checks.push('Workflow name is "Test and Release".');
|
|
@@ -180,7 +181,7 @@ async function checkTests(context) {
|
|
|
180
181
|
// --- W3005: check for pull_request in 'on' ---
|
|
181
182
|
if (!onAttr || !Object.prototype.hasOwnProperty.call(onAttr, 'pull_request')) {
|
|
182
183
|
context.warnings.push(
|
|
183
|
-
`[W3005] Workflow "${
|
|
184
|
+
`[W3005] Workflow "${WORKFLOW_FILE_SHORT}" should have "pull_request: {}" in the "on" trigger configuration.`,
|
|
184
185
|
);
|
|
185
186
|
} else {
|
|
186
187
|
context.checks.push('Workflow trigger includes "pull_request".');
|
|
@@ -189,7 +190,7 @@ async function checkTests(context) {
|
|
|
189
190
|
// --- E3006 / E3007 / E3008: check for push in 'on' ---
|
|
190
191
|
if (!onAttr || !Object.prototype.hasOwnProperty.call(onAttr, 'push')) {
|
|
191
192
|
context.errors.push(
|
|
192
|
-
`[E3006] Workflow "${
|
|
193
|
+
`[E3006] Workflow "${WORKFLOW_FILE_SHORT}" is missing the "push" trigger in the "on" configuration.`,
|
|
193
194
|
);
|
|
194
195
|
} else {
|
|
195
196
|
context.checks.push('Workflow trigger includes "push".');
|
|
@@ -200,7 +201,7 @@ async function checkTests(context) {
|
|
|
200
201
|
const branches = pushConfig.branches;
|
|
201
202
|
if (!branches || !Array.isArray(branches) || branches.length === 0) {
|
|
202
203
|
context.errors.push(
|
|
203
|
-
`[E3007] Workflow "${
|
|
204
|
+
`[E3007] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger is missing "branches" configuration. ` +
|
|
204
205
|
`Must include "*" or the default branch ("${context.branch}").`,
|
|
205
206
|
);
|
|
206
207
|
} else {
|
|
@@ -209,7 +210,7 @@ async function checkTests(context) {
|
|
|
209
210
|
const hasDefaultBranch = branches.includes(defaultBranch);
|
|
210
211
|
if (!hasWildcard && !hasDefaultBranch) {
|
|
211
212
|
context.errors.push(
|
|
212
|
-
`[E3007] Workflow "${
|
|
213
|
+
`[E3007] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "branches" must include "*" or the default branch "${defaultBranch}". ` +
|
|
213
214
|
`Found: ${JSON.stringify(branches)}`,
|
|
214
215
|
);
|
|
215
216
|
} else {
|
|
@@ -222,7 +223,7 @@ async function checkTests(context) {
|
|
|
222
223
|
const requiredTagPatterns = ['v[0-9]+.[0-9]+.[0-9]+', 'v[0-9]+.[0-9]+.[0-9]+-**'];
|
|
223
224
|
if (!tags || !Array.isArray(tags)) {
|
|
224
225
|
context.errors.push(
|
|
225
|
-
`[E3008] Workflow "${
|
|
226
|
+
`[E3008] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger is missing "tags" configuration. ` +
|
|
226
227
|
`Required tag patterns: ${requiredTagPatterns.join(', ')}`,
|
|
227
228
|
);
|
|
228
229
|
} else {
|
|
@@ -230,7 +231,7 @@ async function checkTests(context) {
|
|
|
230
231
|
const missingPatterns = requiredTagPatterns.filter(pat => !cleanedTags.includes(pat));
|
|
231
232
|
if (missingPatterns.length > 0) {
|
|
232
233
|
context.errors.push(
|
|
233
|
-
`[E3008] Workflow "${
|
|
234
|
+
`[E3008] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "tags" is missing required pattern(s): ${missingPatterns.join(', ')}`,
|
|
234
235
|
);
|
|
235
236
|
} else {
|
|
236
237
|
context.checks.push('Workflow "push" trigger tags are correctly configured.');
|
|
@@ -242,7 +243,7 @@ async function checkTests(context) {
|
|
|
242
243
|
const concurrency = workflow.concurrency;
|
|
243
244
|
if (!concurrency || concurrency.group !== '${{ github.ref }}' || concurrency['cancel-in-progress'] !== true) {
|
|
244
245
|
context.warnings.push(
|
|
245
|
-
`[W3009] Workflow "${
|
|
246
|
+
`[W3009] Workflow "${WORKFLOW_FILE_SHORT}" is missing recommended concurrency configuration. See ` +
|
|
246
247
|
`"https://github.com/ioBroker/ioBroker.example/blob/e7db900495bb3c2b89dc35d863dda4ccf33f5def/JavaScript/.github/workflows/test-and-release.yml#L17" for details.`,
|
|
247
248
|
);
|
|
248
249
|
} else {
|
|
@@ -258,11 +259,11 @@ async function checkTests(context) {
|
|
|
258
259
|
if (!jobs['check-and-lint']) {
|
|
259
260
|
if (!context.cfg.onlyWWW) {
|
|
260
261
|
context.errors.push(
|
|
261
|
-
`[E3010] Workflow "${
|
|
262
|
+
`[E3010] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" is missing. Please add it.`,
|
|
262
263
|
);
|
|
263
264
|
} else {
|
|
264
265
|
context.warnings.push(
|
|
265
|
-
`[S3010] Workflow "${
|
|
266
|
+
`[S3010] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" is missing. Consider adding it.`,
|
|
266
267
|
);
|
|
267
268
|
}
|
|
268
269
|
} else {
|
|
@@ -271,7 +272,7 @@ async function checkTests(context) {
|
|
|
271
272
|
// W3013: check-and-lint must use ioBroker/testing-action-check@v1
|
|
272
273
|
if (!jobHasStepWithAction(jobs['check-and-lint'], 'ioBroker/testing-action-check@')) {
|
|
273
274
|
context.warnings.push(
|
|
274
|
-
`[W3013] Workflow "${
|
|
275
|
+
`[W3013] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" should contain a step using "ioBroker/testing-action-check@v1".`,
|
|
275
276
|
);
|
|
276
277
|
} else {
|
|
277
278
|
context.checks.push('Job "check-and-lint" uses "ioBroker/testing-action-check@v1".');
|
|
@@ -282,14 +283,14 @@ async function checkTests(context) {
|
|
|
282
283
|
if (context.cfg.onlyWWW) {
|
|
283
284
|
context.checks.push('Job "adapter-tests" check skipped (onlyWWW adapter).');
|
|
284
285
|
} else if (!jobs['adapter-tests']) {
|
|
285
|
-
context.errors.push(`[E3011] Workflow "${
|
|
286
|
+
context.errors.push(`[E3011] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" is missing. Please add it.`);
|
|
286
287
|
} else {
|
|
287
288
|
context.checks.push('Job "adapter-tests" found.');
|
|
288
289
|
|
|
289
290
|
// S3014: adapter-tests should need check-and-lint
|
|
290
291
|
if (!jobNeedsAll(jobs['adapter-tests'], ['check-and-lint'])) {
|
|
291
292
|
context.warnings.push(
|
|
292
|
-
`[S3014] Workflow "${
|
|
293
|
+
`[S3014] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" should declare "needs: check-and-lint" to run after linting.`,
|
|
293
294
|
);
|
|
294
295
|
} else {
|
|
295
296
|
context.checks.push('Job "adapter-tests" correctly requires "check-and-lint".');
|
|
@@ -298,7 +299,7 @@ async function checkTests(context) {
|
|
|
298
299
|
// W3015: adapter-tests must use ioBroker/testing-action-adapter@v1
|
|
299
300
|
if (!jobHasStepWithAction(jobs['adapter-tests'], 'ioBroker/testing-action-adapter@')) {
|
|
300
301
|
context.warnings.push(
|
|
301
|
-
`[W3015] Workflow "${
|
|
302
|
+
`[W3015] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" should contain a step using "ioBroker/testing-action-adapter@v1".`,
|
|
302
303
|
);
|
|
303
304
|
} else {
|
|
304
305
|
context.checks.push('Job "adapter-tests" uses "ioBroker/testing-action-adapter@v1".');
|
|
@@ -308,7 +309,7 @@ async function checkTests(context) {
|
|
|
308
309
|
// S3012: deploy job (suggestion if missing)
|
|
309
310
|
if (!jobs['deploy']) {
|
|
310
311
|
context.warnings.push(
|
|
311
|
-
`[S3012] Workflow "${
|
|
312
|
+
`[S3012] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" is not defined. Consider adding it for automated releases.`,
|
|
312
313
|
);
|
|
313
314
|
} else {
|
|
314
315
|
context.checks.push('Job "deploy" found.');
|
|
@@ -318,7 +319,7 @@ async function checkTests(context) {
|
|
|
318
319
|
const requiredDependencies = ['check-and-lint', 'adapter-tests'].filter(j => jobs[j]);
|
|
319
320
|
if (!requiredDependencies.every(req => jobDependsOn(jobs, 'deploy', req))) {
|
|
320
321
|
context.errors.push(
|
|
321
|
-
`[E3016] Workflow "${
|
|
322
|
+
`[E3016] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" must declare "needs" for both "check-and-lint" and "adapter-tests".`,
|
|
322
323
|
);
|
|
323
324
|
} else {
|
|
324
325
|
context.checks.push('Job "deploy" correctly requires "check-and-lint" and "adapter-tests".');
|
|
@@ -327,7 +328,7 @@ async function checkTests(context) {
|
|
|
327
328
|
// W3017: deploy must use ioBroker/testing-action-deploy@v1
|
|
328
329
|
if (!jobHasStepWithAction(jobs['deploy'], 'ioBroker/testing-action-deploy@')) {
|
|
329
330
|
context.warnings.push(
|
|
330
|
-
`[W3017] Workflow "${
|
|
331
|
+
`[W3017] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" should contain a step using "ioBroker/testing-action-deploy@v1".`,
|
|
331
332
|
);
|
|
332
333
|
} else {
|
|
333
334
|
context.checks.push('Job "deploy" uses "ioBroker/testing-action-deploy@v1".');
|
|
@@ -338,7 +339,7 @@ async function checkTests(context) {
|
|
|
338
339
|
const hasIdTokenWrite = permissions && permissions['id-token'] === 'write';
|
|
339
340
|
if (!hasContentsWrite || !hasIdTokenWrite) {
|
|
340
341
|
context.warnings.push(
|
|
341
|
-
`[W3018] Workflow "${
|
|
342
|
+
`[W3018] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" is missing required permissions "contents: write" and "id-token: write" at job level. ` +
|
|
342
343
|
`Trusted publishing will not work without them.`,
|
|
343
344
|
);
|
|
344
345
|
} else {
|
|
@@ -357,7 +358,7 @@ async function checkTests(context) {
|
|
|
357
358
|
Object.prototype.hasOwnProperty.call(deployStep.with, 'npm-token')
|
|
358
359
|
) {
|
|
359
360
|
context.warnings.push(
|
|
360
|
-
`[W3019] Workflow "${
|
|
361
|
+
`[W3019] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" step using "ioBroker/testing-action-deploy@v1" ` +
|
|
361
362
|
`has "npm-token" parameter specified. ` +
|
|
362
363
|
`Trusted publishing will not work while "npm-token" is set.`,
|
|
363
364
|
);
|
package/lib/M4000_Repository.js
CHANGED
|
@@ -165,6 +165,10 @@ async function checkRepository(context) {
|
|
|
165
165
|
context.checks.push('Meta URL (stable) is OK in latest repository');
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
} else if (!context.cfg.isNewAdapter) {
|
|
169
|
+
context.warnings.push(
|
|
170
|
+
`[S4047] Adapter "${context.adapterName}" is not yet available in the stable repository. Please consider adding it.`,
|
|
171
|
+
);
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
174
|
|
|
@@ -545,3 +549,4 @@ exports.checkRepository = checkRepository;
|
|
|
545
549
|
// [4044] Missing schema definition for JSON5 config files in .vscode/settings.json. Add: {"fileMatch": ${JSON.stringify(json5ConfigFiles)}, "url": "${config.schemaUrls.jsonConfig}"}
|
|
546
550
|
// [4045] Incorrect schema URL for JSON5 config files in .vscode/settings.json. Expected: "${config.schemaUrls.jsonConfig}", found: "${json5ConfigSchema.url}"
|
|
547
551
|
// [4046] Could not read .vscode/settings.json file: ${error.message}
|
|
552
|
+
// [4047] Adapter "${context.adapterName}" is not yet available in the stable repository.
|
package/lib/M5000_Code.js
CHANGED
|
@@ -707,10 +707,19 @@ async function checkCode(context) {
|
|
|
707
707
|
context.ioPackageJson.common.adminUI.config === 'json' &&
|
|
708
708
|
context.filesList.includes('/admin/words.js')
|
|
709
709
|
) {
|
|
710
|
+
common.debug('/admin/words.js detected while jsonConfig is used.')
|
|
710
711
|
let isWordsJsUsed = false;
|
|
711
712
|
|
|
713
|
+
const excludeFiles = [
|
|
714
|
+
'/admin/words.js',
|
|
715
|
+
'/eslint.config.js',
|
|
716
|
+
'/eslint.config.cjs',
|
|
717
|
+
'/eslint.config.mjs',
|
|
718
|
+
'/.eslintignore',
|
|
719
|
+
'/.create-adapter.json',
|
|
720
|
+
];
|
|
712
721
|
for (const fileName of Object.keys(context)) {
|
|
713
|
-
if (fileName.startsWith('/') && typeof context[fileName] === 'string' && fileName
|
|
722
|
+
if (fileName.startsWith('/') && typeof context[fileName] === 'string' && !excludeFiles.includes(fileName)) {
|
|
714
723
|
const content = context[fileName];
|
|
715
724
|
// Detect references to words.js in various forms:
|
|
716
725
|
// - Direct file name: words.js (e.g. in HTML script tags)
|
|
@@ -722,6 +731,7 @@ async function checkCode(context) {
|
|
|
722
731
|
/require\s*\(\s*['"`]words['"`]\s*\)/.test(content) ||
|
|
723
732
|
/(?:import|from)\s+['"`]words['"`]/.test(content)
|
|
724
733
|
) {
|
|
734
|
+
common.debug(`/admin.words.js used by ${fileName}`);
|
|
725
735
|
isWordsJsUsed = true;
|
|
726
736
|
break;
|
|
727
737
|
}
|
|
@@ -899,6 +909,24 @@ async function checkCode(context) {
|
|
|
899
909
|
}
|
|
900
910
|
}
|
|
901
911
|
|
|
912
|
+
// W5048: Check for obsolete eslint/prettier config files when @iobroker/eslint-config is used
|
|
913
|
+
if (context.packageJson.devDependencies && context.packageJson.devDependencies['@iobroker/eslint-config']) {
|
|
914
|
+
const obsoleteFiles = [
|
|
915
|
+
'/.eslintignore',
|
|
916
|
+
'/.eslintrc.json',
|
|
917
|
+
'/.prettierignore',
|
|
918
|
+
'/.prettierrc.js',
|
|
919
|
+
'/.prettierrc.json',
|
|
920
|
+
];
|
|
921
|
+
for (const file of obsoleteFiles) {
|
|
922
|
+
if (context.filesList.includes(file)) {
|
|
923
|
+
context.warnings.push(
|
|
924
|
+
`[W5048] "${file.slice(1)}" is most likely obsolete when using "@iobroker/eslint-config". Please remove it.`,
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
902
930
|
if (context.packageJson.devDependencies && context.packageJson.devDependencies['@alcalzone/release-script']) {
|
|
903
931
|
const version = context.packageJson.devDependencies['@alcalzone/release-script'];
|
|
904
932
|
if (compareVersions.compareVersions(version, '3.0.0') >= 0) {
|
|
@@ -1255,6 +1283,7 @@ async function checkCode(context) {
|
|
|
1255
1283
|
'build',
|
|
1256
1284
|
'doc',
|
|
1257
1285
|
'src-admin',
|
|
1286
|
+
'src-editor', // java-script adapter
|
|
1258
1287
|
'src-widgets',
|
|
1259
1288
|
'widgets',
|
|
1260
1289
|
'admin-src',
|
|
@@ -1450,6 +1479,7 @@ exports.checkCode = checkCode;
|
|
|
1450
1479
|
// [E5045] "/admin/jsonTab.json[5]" not found, but tab support is declared
|
|
1451
1480
|
// [W5046] "admin/jsonConfig.json" or "admin/jsonConfig.json5" found but "common.adminUI.config" is not set to "json" in io-package.json. Please add "common.adminUI": { "config": "json" }.
|
|
1452
1481
|
// [W5047] "${file}" is most likely outdated since jsonConfig is used. Please consider removing it.
|
|
1482
|
+
// [W5048] "${file}" is most likely obsolete when using "@iobroker/eslint-config". Please remove it.
|
|
1453
1483
|
// [W5515] Schema validation skipped for "${configFile}" due to parse error: ${e.message}
|
|
1454
1484
|
|
|
1455
1485
|
// [5500 - ] see M5500_jsonConfig.js
|
package/lib/M8900__Dependabot.js
CHANGED
|
@@ -169,11 +169,11 @@ async function checkDependabot(context) {
|
|
|
169
169
|
return context;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
//
|
|
172
|
+
// W8916: Check for github-actions ecosystem
|
|
173
173
|
const hasGithubActions = updates.some(u => u['package-ecosystem'] === 'github-actions');
|
|
174
174
|
if (!hasGithubActions) {
|
|
175
|
-
context.
|
|
176
|
-
`[
|
|
175
|
+
context.warnings.push(
|
|
176
|
+
`[W8916] Dependabot configuration "${DEPENDABOT_FILE}" has no entry with "package-ecosystem: github-actions". Please add one.`,
|
|
177
177
|
);
|
|
178
178
|
} else {
|
|
179
179
|
context.checks.push('Dependabot is configured for "github-actions" ecosystem.');
|
|
@@ -328,7 +328,7 @@ exports.checkDependabot = checkDependabot;
|
|
|
328
328
|
|
|
329
329
|
// [S8901] Dependabot configuration file ".github/dependabot.yml" not found.
|
|
330
330
|
// [E8902] Dependabot configuration file is not valid YAML or cannot be read.
|
|
331
|
-
// [E8903] No entry with "package-ecosystem:
|
|
331
|
+
// [E8903] No entry with "package-ecosystem:" found.
|
|
332
332
|
// [E8904] No entry with "package-ecosystem: npm" found.
|
|
333
333
|
// [W8905] Repository has non-root package.json but npm entry does not use directories wildcard.
|
|
334
334
|
// [S8906] Suggest cron instead of monthly schedule.
|
|
@@ -341,3 +341,4 @@ exports.checkDependabot = checkDependabot;
|
|
|
341
341
|
// [S8913] Suggest to set up automerging.
|
|
342
342
|
// [S8914] Automerging is active but .github/auto-merge.yml not found.
|
|
343
343
|
// [W8915] npm entry has no cooldown or cooldown < 5 days configured.
|
|
344
|
+
// [W8916] Dependabot configuration "${DEPENDABOT_FILE}" has no entry with "package-ecosystem: github-actions". Please add one.
|
|
@@ -15,6 +15,96 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
// const common = require('./common.js');
|
|
18
|
+
const minimatch = require('minimatch');
|
|
19
|
+
|
|
20
|
+
// Source directories whose i18n subdirectories are excluded from npm packaging checks,
|
|
21
|
+
// since their contents are typically compiled/moved to build/ or admin/ during the build process.
|
|
22
|
+
const SRC_DIRS_TO_IGNORE = ['src', 'src-admin', 'admin-src'];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns a deduplicated list of i18n directory paths found in the given file list.
|
|
26
|
+
* Example: '/admin/i18n/en/translations.json' → '/admin/i18n'
|
|
27
|
+
* Directories under src, src-admin or admin-src are excluded as those are build sources
|
|
28
|
+
* and are not packaged directly.
|
|
29
|
+
*
|
|
30
|
+
* @param {string[]} filesList list of file paths from the repository (each with a leading slash)
|
|
31
|
+
* @returns {string[]} array of unique i18n directory paths with leading slash
|
|
32
|
+
*/
|
|
33
|
+
function findI18nDirs(filesList) {
|
|
34
|
+
const i18nDirs = new Set();
|
|
35
|
+
for (const file of filesList) {
|
|
36
|
+
const match = file.match(/^(\/(?:[^/]+\/)*i18n)(?:\/|$)/);
|
|
37
|
+
if (match) {
|
|
38
|
+
const i18nDir = match[1]; // e.g. '/admin/i18n'
|
|
39
|
+
// Skip i18n dirs that reside directly inside a source directory
|
|
40
|
+
const topLevel = i18nDir.replace(/^\//, '').split('/')[0];
|
|
41
|
+
if (!SRC_DIRS_TO_IGNORE.includes(topLevel)) {
|
|
42
|
+
i18nDirs.add(i18nDir);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return [...i18nDirs];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns true if the given entry string contains glob wildcard characters.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} entry a package.json "files" entry
|
|
53
|
+
* @returns {boolean} true if the entry contains glob wildcard characters
|
|
54
|
+
*/
|
|
55
|
+
function isGlobPattern(entry) {
|
|
56
|
+
return /[*?{]/.test(entry);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Checks whether the given i18n directory is covered by any entry in the package.json "files" array.
|
|
61
|
+
* Handles both plain path entries and glob patterns (using minimatch).
|
|
62
|
+
*
|
|
63
|
+
* @param {string} i18nDir e.g. '/admin/i18n'
|
|
64
|
+
* @param {string[]} filesEntries entries from package.json "files"
|
|
65
|
+
* @param {string[]} [allFiles] full list of repository file paths (each with a leading slash); required for glob matching
|
|
66
|
+
* @returns {boolean} true if the i18n directory is included
|
|
67
|
+
*/
|
|
68
|
+
function isI18nDirIncludedInFiles(i18nDir, filesEntries, allFiles) {
|
|
69
|
+
const i18nPath = i18nDir.replace(/^\//, ''); // e.g. 'admin/i18n'
|
|
70
|
+
// Collect all repo files that live inside this i18n directory (strip leading slash)
|
|
71
|
+
const i18nFiles = (allFiles || [])
|
|
72
|
+
.filter(f => {
|
|
73
|
+
const rel = f.replace(/^\//, '');
|
|
74
|
+
return rel === i18nPath || rel.startsWith(`${i18nPath}/`);
|
|
75
|
+
})
|
|
76
|
+
.map(f => f.replace(/^\//, ''));
|
|
77
|
+
|
|
78
|
+
return filesEntries.some(entry => {
|
|
79
|
+
const normalized = entry.replace(/^\.\//, '').replace(/\/+$/, '');
|
|
80
|
+
|
|
81
|
+
if (isGlobPattern(entry)) {
|
|
82
|
+
// Use minimatch to test whether any file inside the i18n directory matches the glob
|
|
83
|
+
return i18nFiles.some(file => minimatch(file, entry, { dot: true }));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Plain path: covered if entry is exactly the i18n dir, a parent dir, or '.' (root)
|
|
87
|
+
return normalized === '.' || normalized === i18nPath || i18nPath.startsWith(`${normalized}/`);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Checks whether the given i18n directory is excluded by any rule in the .npmignore rule list.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} i18nDir e.g. '/admin/i18n'
|
|
95
|
+
* @param {Array<string|RegExp>} rules parsed .npmignore rules
|
|
96
|
+
* @returns {boolean} true if the i18n directory is excluded
|
|
97
|
+
*/
|
|
98
|
+
function isI18nDirExcluded(i18nDir, rules) {
|
|
99
|
+
const i18nPath = i18nDir.replace(/^\//, ''); // e.g. 'admin/i18n'
|
|
100
|
+
return rules.some(rule => {
|
|
101
|
+
if (typeof rule === 'string') {
|
|
102
|
+
const normalized = rule.replace(/^\//, '').replace(/\/+$/, '');
|
|
103
|
+
return normalized === i18nPath;
|
|
104
|
+
}
|
|
105
|
+
return rule.test(i18nPath) || rule.test(`${i18nPath}/`);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
18
108
|
|
|
19
109
|
// 900 - ???
|
|
20
110
|
async function checkGitIgnore(context) {
|
|
@@ -138,6 +228,17 @@ async function checkNpmIgnore(context) {
|
|
|
138
228
|
} else {
|
|
139
229
|
context.checks.push('package.json "files" already used.');
|
|
140
230
|
}
|
|
231
|
+
|
|
232
|
+
// Check that i18n directories present in the repo are covered by the "files" entries
|
|
233
|
+
const i18nDirs = findI18nDirs(context.filesList);
|
|
234
|
+
for (const i18nDir of i18nDirs) {
|
|
235
|
+
if (!isI18nDirIncludedInFiles(i18nDir, context.packageJson.files, context.filesList)) {
|
|
236
|
+
context.errors.push(
|
|
237
|
+
`[E9507] i18n directory "${i18nDir.replace(/^\//, '')}" found in repository but is not included in package.json "files". Translations will be missing from the npm package.`,
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
141
242
|
return context;
|
|
142
243
|
}
|
|
143
244
|
|
|
@@ -192,6 +293,16 @@ async function checkNpmIgnore(context) {
|
|
|
192
293
|
context.errors.push(`[E9010] file ${file} found in repository, but not found in .npmignore`);
|
|
193
294
|
}
|
|
194
295
|
});
|
|
296
|
+
|
|
297
|
+
// Check that i18n directories are not excluded by .npmignore
|
|
298
|
+
const i18nDirs = findI18nDirs(context.filesList);
|
|
299
|
+
for (const i18nDir of i18nDirs) {
|
|
300
|
+
if (isI18nDirExcluded(i18nDir, rules)) {
|
|
301
|
+
context.errors.push(
|
|
302
|
+
`[E9506] i18n directory "${i18nDir.replace(/^\//, '')}" is excluded by .npmignore. Translations will be missing from the npm package.`,
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
195
306
|
}
|
|
196
307
|
}
|
|
197
308
|
return context;
|
|
@@ -217,3 +328,5 @@ exports.checkNpmIgnore = checkNpmIgnore;
|
|
|
217
328
|
// [9503] .npmignore found - consider using package.json object "files" instead.
|
|
218
329
|
// [9504] node_modules not found in `.npmignore`
|
|
219
330
|
// [9505] iob_npm.done not found in .npmignore` ### removed ###
|
|
331
|
+
// [9506] i18n directory excluded by .npmignore
|
|
332
|
+
// [9507] i18n directory not included in package.json "files"
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.10.0",
|
|
3
3
|
"name": "@iobroker/repochecker",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"ajv": "^8.18.0",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"image-size": "^1.2.0",
|
|
9
9
|
"js-yaml": "^4.1.1",
|
|
10
10
|
"json5": "^2.2.3",
|
|
11
|
+
"minimatch": "^10.0.0",
|
|
11
12
|
"semver": "^7.7.4"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|