@iobroker/repochecker 5.19.12 → 5.20.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
@@ -4,7 +4,7 @@ This is a code for frontend and back-end of the service <https://adapter-check.i
4
4
 
5
5
  If you want to add your adapter to the public ioBroker repository, all tests on this page must be OK.
6
6
 
7
- ## How to test via cli
7
+ ## How to test via cli (standard tests accessing repository data)
8
8
 
9
9
  When running the repository checker via the command line, you **need** to add the repository as parameter, while the branch parameter (`master/main/dev`) is optional. If this parameter is omitted, the `default` branch (typically master / main) will be checked.
10
10
 
@@ -12,6 +12,11 @@ When running the repository checker via the command line, you **need** to add th
12
12
  npx @iobroker/repochecker <repo> [branch]`
13
13
  ```
14
14
 
15
+ ## How to test via cli using local mode
16
+
17
+ > [!NOTE]
18
+ > local mode feature is experimental and untested.
19
+
15
20
  For extra debugging outputs you can pass the `--debug` parameter.
16
21
 
17
22
  For a local test you can pass the `--local` parameter. Most of the files are read locally.
@@ -21,10 +26,16 @@ Example:
21
26
 
22
27
  `npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.repochecker --local`
23
28
 
29
+ ## Changelog
24
30
  <!--
25
31
  Placeholder for the next version (at the beginning of the line):
26
32
  ### **WORK IN PROGRESS**
27
33
  -->
34
+ ### 5.20.0 (2026-07-17)
35
+
36
+ * (Copilot) Add a workflow check that rejects `always()` on standard test-and-release jobs and flags it for review on custom jobs.
37
+ * (Copilot) Warn when tracked files or directories are still covered by `.gitignore` and error if a tracked `/build` directory is ignored.
38
+
28
39
  ### 5.19.12 (2026-07-13)
29
40
 
30
41
  - (Copilot) Redact sensitive Axios error fields so `OWN_GITHUB_TOKEN`/authorization values are never logged in clear text.
@@ -990,8 +990,8 @@ async function checkIOPackageJson(context) {
990
990
  const untranslatedDetails = untranslatedLanguages
991
991
  .map(language => `${language}(${untranslatedNewsByLanguage[language].sort().join(', ')})`)
992
992
  .join('; ');
993
- context.errors.push(
994
- `[E1144] Untranslated "common.news" entries detected (identical to English text): ${untranslatedDetails}.`,
993
+ context.warnings.push(
994
+ `[W1144] Untranslated "common.news" entries detected (identical to English text): ${untranslatedDetails}.`,
995
995
  );
996
996
  }
997
997
 
@@ -387,6 +387,10 @@ function isExplicitlyTrue(value) {
387
387
  return ['true', 'yes', 'on', 'y'].includes(value.trim().toLowerCase());
388
388
  }
389
389
 
390
+ function jobConditionUsesAlways(job) {
391
+ return typeof job?.if === 'string' && /\balways\s*\(\s*\)/i.test(job.if);
392
+ }
393
+
390
394
  function stepUsesActionPrefix(step, actionPrefix) {
391
395
  return typeof step?.uses === 'string' && step.uses.toLowerCase().startsWith(actionPrefix.toLowerCase());
392
396
  }
@@ -1213,6 +1217,20 @@ async function checkTests(context) {
1213
1217
  'ioBroker/testing-action-deploy@',
1214
1218
  ];
1215
1219
  for (const [jobName, job] of Object.entries(jobs)) {
1220
+ if (jobConditionUsesAlways(job)) {
1221
+ if (['check-and-lint', 'adapter-tests', 'deploy'].includes(jobName)) {
1222
+ context.errors.push(
1223
+ `[E3057] "${WORKFLOW_FILE_SHORT}": job "${jobName}" uses "always()" in its job condition. ` +
1224
+ 'Standard jobs must not use "always()"; remove it.',
1225
+ );
1226
+ } else {
1227
+ context.warnings.push(
1228
+ `[S3058] "${WORKFLOW_FILE_SHORT}": job "${jobName}" uses "always()" in its job condition. ` +
1229
+ 'Please verify whether "always()" is really needed.',
1230
+ );
1231
+ }
1232
+ }
1233
+
1216
1234
  if (!Array.isArray(job.steps)) {
1217
1235
  continue;
1218
1236
  }
@@ -1705,3 +1723,5 @@ exports.checkTests = checkTests;
1705
1723
  // [S3054] "${WORKFLOW_FILE_SHORT}": log for "check-and-lint" job in ${formatRunLink(tagRun)} for ${sourceLabel} does no longer exist.`,
1706
1724
  // [S3055] "${WORKFLOW_FILE_SHORT}": log for "${adapterJob.name}" job in ${formatRunLink(tagRun)} for ${sourceLabel} does no longer exist.`,
1707
1725
  // [S3056] "${WORKFLOW_FILE_SHORT}": workflow ${formatRunLink(run)} for ${sourceLabel} is older than 90 days; log files are no longer available.
1726
+ // [E3057] "${WORKFLOW_FILE_SHORT}": job "${jobName}" uses "always()" in its job condition. Standard jobs must not use "always()".
1727
+ // [S3058] "${WORKFLOW_FILE_SHORT}": job "${jobName}" uses "always()" in its job condition. Please verify whether "always()" is really needed.
@@ -33,6 +33,145 @@ const SRC_DIRS_TO_IGNORE = [
33
33
  'admin/src',
34
34
  ];
35
35
 
36
+ function normalizeRepoPath(filePath) {
37
+ const normalized = filePath.replace(/\\/g, '/').replace(/\/+$/, '');
38
+ if (!normalized) {
39
+ return '/';
40
+ }
41
+ return normalized.startsWith('/') ? normalized : `/${normalized}`;
42
+ }
43
+
44
+ function getTrackedRepositoryEntries(filesList) {
45
+ const entries = new Map();
46
+
47
+ for (const file of filesList) {
48
+ const normalized = normalizeRepoPath(file);
49
+ if (normalized === '/') {
50
+ continue;
51
+ }
52
+
53
+ if (!entries.has(normalized)) {
54
+ entries.set(normalized, { path: normalized, isDirectory: false });
55
+ }
56
+
57
+ const parts = normalized.replace(/^\//, '').split('/');
58
+ for (let i = 1; i < parts.length; i++) {
59
+ const directoryPath = `/${parts.slice(0, i).join('/')}`;
60
+ entries.set(directoryPath, { path: directoryPath, isDirectory: true });
61
+ }
62
+ }
63
+
64
+ return [...entries.values()].sort((a, b) => {
65
+ const depthA = a.path.split('/').length;
66
+ const depthB = b.path.split('/').length;
67
+ if (depthA !== depthB) {
68
+ return depthA - depthB;
69
+ }
70
+ if (a.isDirectory !== b.isDirectory) {
71
+ return Number(b.isDirectory) - Number(a.isDirectory);
72
+ }
73
+ return a.path.localeCompare(b.path);
74
+ });
75
+ }
76
+
77
+ function parseIgnoreRules(ignoreFile) {
78
+ return ignoreFile
79
+ .split('\n')
80
+ .map(line => line.replace(/\r/g, '').trim())
81
+ .filter(line => line && !line.startsWith('#'))
82
+ .map(line => {
83
+ let pattern = line;
84
+ let negated = false;
85
+
86
+ if (pattern.startsWith('\\#') || pattern.startsWith('\\!')) {
87
+ pattern = pattern.slice(1);
88
+ } else if (pattern.startsWith('!')) {
89
+ negated = true;
90
+ pattern = pattern.slice(1);
91
+ }
92
+
93
+ const directoryOnly = pattern.endsWith('/');
94
+ const anchored = pattern.startsWith('/');
95
+ pattern = pattern.replace(/^\/+/, '').replace(/\/+$/, '');
96
+
97
+ if (!pattern) {
98
+ return null;
99
+ }
100
+
101
+ return {
102
+ anchored,
103
+ directoryOnly,
104
+ hasSlash: pattern.includes('/'),
105
+ negated,
106
+ pattern,
107
+ };
108
+ })
109
+ .filter(Boolean);
110
+ }
111
+
112
+ function getIgnoreCandidates(filePath, isDirectory) {
113
+ const normalized = normalizeRepoPath(filePath);
114
+ const path = normalized.replace(/^\//, '');
115
+ const candidates = [{ isDirectory, path }];
116
+ const parts = path.split('/');
117
+
118
+ for (let i = 1; i < parts.length; i++) {
119
+ candidates.push({ isDirectory: true, path: parts.slice(0, i).join('/') });
120
+ }
121
+
122
+ return candidates;
123
+ }
124
+
125
+ function matchesIgnoreRule(rule, candidate) {
126
+ if (rule.directoryOnly && !candidate.isDirectory) {
127
+ return false;
128
+ }
129
+
130
+ if (rule.anchored || rule.hasSlash) {
131
+ return minimatch(candidate.path, rule.pattern, { dot: true });
132
+ }
133
+
134
+ return candidate.path.split('/').some(segment => minimatch(segment, rule.pattern, { dot: true }));
135
+ }
136
+
137
+ function isPathIgnoredByRules(filePath, isDirectory, rules) {
138
+ const normalized = normalizeRepoPath(filePath);
139
+ if (normalized === '/') {
140
+ return false;
141
+ }
142
+
143
+ const candidates = getIgnoreCandidates(normalized, isDirectory);
144
+ let ignored = false;
145
+
146
+ for (const rule of rules) {
147
+ if (candidates.some(candidate => matchesIgnoreRule(rule, candidate))) {
148
+ ignored = !rule.negated;
149
+ }
150
+ }
151
+
152
+ return ignored;
153
+ }
154
+
155
+ function findIgnoredTrackedEntries(trackedEntries, rules) {
156
+ const ignoredEntries = [];
157
+ const ignoredDirectories = [];
158
+
159
+ for (const entry of trackedEntries) {
160
+ if (ignoredDirectories.some(directory => entry.path.startsWith(`${directory}/`))) {
161
+ continue;
162
+ }
163
+
164
+ if (isPathIgnoredByRules(entry.path, entry.isDirectory, rules)) {
165
+ ignoredEntries.push(entry);
166
+ if (entry.isDirectory) {
167
+ ignoredDirectories.push(entry.path);
168
+ }
169
+ }
170
+ }
171
+
172
+ return ignoredEntries;
173
+ }
174
+
36
175
  /**
37
176
  * Returns a deduplicated list of i18n directory paths found in the given file list.
38
177
  * Example: '/admin/i18n/en/translations.json' → '/admin/i18n'
@@ -158,22 +297,9 @@ async function checkGitIgnore(context) {
158
297
  if (!context.filesList.includes('/.gitignore')) {
159
298
  context.errors.push(`[E9001] .gitignore not found`);
160
299
  } else {
161
- const rules = (context['/.gitignore'] || '')
162
- .split('\n')
163
- .map(line => line.trim().replace('\r', ''))
164
- .filter(line => line);
165
- let tooComplexToCheck = false;
166
- rules.forEach((name, i) => {
167
- if (name.includes('*')) {
168
- try {
169
- rules[i] = new RegExp(
170
- name.replace('.', '\\.').replace('/', '\\/').replace('**', '.*').replace('*', '[^\\/]*'),
171
- );
172
- } catch {
173
- tooComplexToCheck = true;
174
- }
175
- }
176
- });
300
+ const rules = parseIgnoreRules(context['/.gitignore'] || '');
301
+ const trackedEntries = getTrackedRepositoryEntries(context.filesList);
302
+ const trackedEntriesByPath = new Map(trackedEntries.map(entry => [entry.path, entry]));
177
303
 
178
304
  /* TODO: something is wrong with undefined 'check' variable
179
305
  if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
@@ -184,22 +310,12 @@ async function checkGitIgnore(context) {
184
310
  }
185
311
  */
186
312
 
187
- if (!tooComplexToCheck) {
188
- checkFiles.forEach(file => {
189
- if (context.filesList.includes(`/${file}`)) {
190
- // maybe it is with regex
191
- const check = rules.some(rule => {
192
- if (typeof rule === 'string') {
193
- return rule === file || rule === file.replace(/\/$/, '');
194
- }
195
- return rule.test(file);
196
- });
197
-
198
- !check &&
199
- context.errors.push(`[E9004] file ${file} found in repository, but not found in .gitignore`);
200
- }
201
- });
202
- }
313
+ checkFiles.forEach(file => {
314
+ const trackedEntry = trackedEntriesByPath.get(`/${file}`);
315
+ if (trackedEntry && !isPathIgnoredByRules(trackedEntry.path, trackedEntry.isDirectory, rules)) {
316
+ context.errors.push(`[E9004] file ${file} found in repository, but not found in .gitignore`);
317
+ }
318
+ });
203
319
 
204
320
  // Check for .commitinfo file presence
205
321
  if (context.filesList.includes('/.commitinfo')) {
@@ -207,20 +323,24 @@ async function checkGitIgnore(context) {
207
323
  }
208
324
 
209
325
  // Check if .commitinfo is excluded by .gitignore (independent of file presence)
210
- if (!tooComplexToCheck) {
211
- const isIgnored = rules.some(rule => {
212
- if (typeof rule === 'string') {
213
- return rule === '.commitinfo' || rule === '/.commitinfo';
214
- }
215
- return rule.test('.commitinfo');
216
- });
326
+ if (!isPathIgnoredByRules('/.commitinfo', false, rules)) {
327
+ // convert to warning mid of 2026
328
+ context.warnings.push(
329
+ '[S9006] .commitinfo file should be excluded by .gitignore, please add a line with text ".commitinfo" to .gitignore',
330
+ );
331
+ }
217
332
 
218
- if (!isIgnored) {
219
- // convert to warning mid of 2026
220
- context.warnings.push(
221
- '[S9006] .commitinfo file should be excluded by .gitignore, please add a line with text ".commitinfo" to .gitignore',
333
+ for (const entry of findIgnoredTrackedEntries(trackedEntries, rules)) {
334
+ if (entry.path === '/build' && entry.isDirectory) {
335
+ context.errors.push(
336
+ '[E9007] build directory is tracked but excluded by .gitignore. Either remove the tracked /build directory from git (if generated) or remove the ignore rule (if intentionally tracked).',
222
337
  );
338
+ continue;
223
339
  }
340
+
341
+ context.warnings.push(
342
+ `[W9008] ${entry.isDirectory ? 'directory' : 'file'} ${entry.path.replace(/^\//, '')} is tracked but covered by .gitignore. Remove from git if generated, or remove the ignore rule if intentionally tracked.`,
343
+ );
224
344
  }
225
345
  }
226
346
 
@@ -394,6 +514,8 @@ exports.checkNpmIgnore = checkNpmIgnore;
394
514
  // [9004] file ${file} found in repository, but not found in .gitignore
395
515
  // [9005] .commitinfo file found in repository, please remove it
396
516
  // [9006] .commitinfo file should be excluded by .gitignore, consider adding it to .gitignore
517
+ // [9007] build directory found in repository, but excluded by .gitignore
518
+ // [9008] tracked file or directory is ignored by .gitignore
397
519
 
398
520
  // [9010] file ${file} found in repository, but not found in .npmignore.
399
521
 
@@ -62,6 +62,7 @@ const mapSeverity4New = {
62
62
  W1056: 'E', // [W1056] admin 7.6.17 listed as dependency but 7.6.20 is reW1commended.
63
63
  W0078: 'E', // [W0078] Remove obsolete devDependencies @typescript-eslint/eslint-plugin, @typescript-eslint/parser, eslint when using "@iobroker/eslint-config".
64
64
  W1084: 'E', // [W1084] "common.title" is deprecated and replaced by "common.titleLang".
65
+ W1144: 'E', // [W1144] Untranslated "common.news" entries detected (identical to English text): nl(3.4.11, 3.4.8).
65
66
  W2007: 'E', // [W2007] Version 0.7.0-beta.2 is tagged as "latest" at npm
66
67
  W3009: 'E', // [W3009] Workflow "test-and-release.yml" is missing recommended concurrency configuration.
67
68
  S3014: 'E', // [S3014] Workflow "test-and-release.yml": job "adapter-tests" should declare "needs: check-and-lint" to run after linting.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.19.12",
2
+ "version": "5.20.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.20.0",