@iobroker/repochecker 3.1.3 → 3.2.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 +175 -106
- package/index.js +135 -109
- package/lib/M000_PackageJson.js +62 -29
- package/lib/M100_IOPackageJson.js +72 -68
- package/lib/M250_Npm.js +4 -6
- package/lib/M300_Testing.js +1 -1
- package/lib/M400_Repository.js +14 -12
- package/lib/M500_Code.js +269 -153
- package/lib/M500__JsonConfig.js +603 -0
- package/lib/M700_License.js +5 -5
- package/lib/M800_Github.js +22 -22
- package/lib/M900_GitNpmIgnore.js +6 -6
- package/lib/common.js +49 -32
- package/package.json +1 -1
package/lib/M500_Code.js
CHANGED
|
@@ -7,15 +7,19 @@
|
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const path = require('node:path');
|
|
12
|
+
const util = require('node:util');
|
|
12
13
|
const stream = require('node:stream');
|
|
13
14
|
const unzipper = require('unzipper');
|
|
14
|
-
const util = require('node:util');
|
|
15
|
-
const Writable = stream.Writable;
|
|
16
15
|
|
|
16
|
+
const compareVersions = require('compare-versions');
|
|
17
|
+
const JSON5 = require('json5');
|
|
18
|
+
|
|
19
|
+
const Writable = stream.Writable;
|
|
17
20
|
|
|
18
21
|
const common = require('./common.js');
|
|
22
|
+
const M500__jsonConfig = require('./M500__JsonConfig.js');
|
|
19
23
|
|
|
20
24
|
const memStore = {};
|
|
21
25
|
|
|
@@ -34,9 +38,9 @@ util.inherits(WMStrm, Writable);
|
|
|
34
38
|
|
|
35
39
|
WMStrm.prototype._write = function (chunk, enc, cb) {
|
|
36
40
|
// our memory store stores things in buffers
|
|
37
|
-
const buffer = Buffer.isBuffer(chunk)
|
|
38
|
-
chunk
|
|
39
|
-
new Buffer(chunk, enc);
|
|
41
|
+
const buffer = Buffer.isBuffer(chunk)
|
|
42
|
+
? chunk // already is Buffer use it
|
|
43
|
+
: new Buffer(chunk, enc); // string, convert
|
|
40
44
|
|
|
41
45
|
// concat to the buffer already there
|
|
42
46
|
memStore[this.key] = Buffer.concat([memStore[this.key], buffer]);
|
|
@@ -73,10 +77,29 @@ function extractWords(words) {
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
function getAllFiles(context, dirPath, root, filesList) {
|
|
81
|
+
const skipDirectories = ['.dev-server', 'node_modules', '.git', '.vscode'];
|
|
82
|
+
const files = fs.readdirSync(dirPath);
|
|
83
|
+
filesList = filesList || [];
|
|
84
|
+
files.forEach((file) => {
|
|
85
|
+
if (fs.statSync(path.join(dirPath, file)).isDirectory()) {
|
|
86
|
+
if (!skipDirectories.includes(file)) {
|
|
87
|
+
filesList = getAllFiles(context, path.join(dirPath, file), [root, file].join('/'), filesList);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
filesList.push([root, file].join('/').slice(1));
|
|
91
|
+
if (context.readFiles.includes([root, file].join('/').slice(1))) {
|
|
92
|
+
context[[root, file].join('/')] = fs.readFileSync(path.join(dirPath, file), 'utf8');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return filesList;
|
|
97
|
+
}
|
|
98
|
+
|
|
76
99
|
// E5xx
|
|
77
100
|
async function checkCode(context) {
|
|
78
101
|
console.log('\ncheckCode [E5xx]');
|
|
79
|
-
|
|
102
|
+
|
|
80
103
|
const readFiles = [
|
|
81
104
|
'.npmignore',
|
|
82
105
|
'.gitignore',
|
|
@@ -95,18 +118,14 @@ async function checkCode(context) {
|
|
|
95
118
|
'admin/jsonCustom.json5',
|
|
96
119
|
'admin/blockly.js',
|
|
97
120
|
|
|
98
|
-
'src-admin/package.json',
|
|
99
|
-
'src-widgets/package.json',
|
|
100
|
-
'src/package.json',
|
|
121
|
+
'src-admin/package.json', // check if react is used
|
|
122
|
+
'src-widgets/package.json', // check if react is used
|
|
123
|
+
'src/package.json', // check if react is used
|
|
101
124
|
];
|
|
102
125
|
|
|
103
|
-
context.cfg.allowedLanguages.forEach(lang =>
|
|
104
|
-
readFiles.push(`admin/i18n/${lang}/translations.json`)
|
|
105
|
-
);
|
|
126
|
+
context.cfg.allowedLanguages.forEach((lang) => readFiles.push(`admin/i18n/${lang}/translations.json`));
|
|
106
127
|
|
|
107
|
-
context.cfg.allowedLanguages.forEach(lang =>
|
|
108
|
-
readFiles.push(`admin/i18n/${lang}.json`)
|
|
109
|
-
);
|
|
128
|
+
context.cfg.allowedLanguages.forEach((lang) => readFiles.push(`admin/i18n/${lang}.json`));
|
|
110
129
|
|
|
111
130
|
if (context.packageJson.main) {
|
|
112
131
|
readFiles.push(context.packageJson.main);
|
|
@@ -138,82 +157,100 @@ async function checkCode(context) {
|
|
|
138
157
|
// }
|
|
139
158
|
|
|
140
159
|
// https://github.com/userName/ioBroker.adaptername/archive/${context.branch}.zip
|
|
141
|
-
const data = await common.downloadFile(context.githubUrlOriginal, `/archive/${context.branch}.zip`, true)
|
|
142
|
-
console.log(`${context.branch}.zip ${data.length} bytes`);
|
|
143
|
-
|
|
144
|
-
let found = false;
|
|
145
|
-
const bufferStream = new stream.PassThrough();
|
|
146
|
-
bufferStream.end(data);
|
|
147
|
-
context.filesList = [];
|
|
148
|
-
|
|
149
|
-
// parse zip file
|
|
150
|
-
const promises = [];
|
|
151
|
-
await (function () { return new Promise(_resolve => {
|
|
152
|
-
common.debug('init bufferstream');
|
|
153
|
-
let root='';
|
|
154
|
-
bufferStream
|
|
155
|
-
.pipe(unzipper.Parse())
|
|
156
|
-
.on('entry', entry => {
|
|
157
|
-
common.debug('on.entry ' + entry.path);
|
|
158
|
-
if (root === '') {
|
|
159
|
-
root=entry.path;
|
|
160
|
-
console.log(`Directory root set to ${root}`);
|
|
161
|
-
}
|
|
162
|
-
//if (!found && entry.type === 'Directory' && entry.path.match(/\/node_modules\/$/)) {
|
|
163
|
-
if (!found && entry.type === 'Directory' && entry.path === `${root}node_modules/`) {
|
|
164
|
-
console.log(`Found ${entry.path}`);
|
|
165
|
-
found = true;
|
|
166
|
-
context.errors.push('[E500] Directory node_modules found in root of repository. Please delete directory.');
|
|
167
|
-
}
|
|
168
160
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
common.debug('
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
161
|
+
if (common.isLocal()) {
|
|
162
|
+
// check a list of all files in the current path and all subdirectories
|
|
163
|
+
context.readFiles = readFiles;
|
|
164
|
+
context.filesList = [];
|
|
165
|
+
getAllFiles(context, process.cwd(), '', context.filesList);
|
|
166
|
+
} else {
|
|
167
|
+
const data = await common.downloadFile(context.githubUrlOriginal, `/archive/${context.branch}.zip`, true);
|
|
168
|
+
console.log(`${context.branch}.zip ${data.length} bytes`);
|
|
169
|
+
|
|
170
|
+
let found = false;
|
|
171
|
+
const bufferStream = new stream.PassThrough();
|
|
172
|
+
bufferStream.end(data);
|
|
173
|
+
context.filesList = [];
|
|
174
|
+
|
|
175
|
+
// parse zip file
|
|
176
|
+
const promises = [];
|
|
177
|
+
await (function () {
|
|
178
|
+
return new Promise((_resolve) => {
|
|
179
|
+
common.debug('init bufferstream');
|
|
180
|
+
let root = '';
|
|
181
|
+
bufferStream
|
|
182
|
+
.pipe(unzipper.Parse())
|
|
183
|
+
.on('entry', (entry) => {
|
|
184
|
+
common.debug('on.entry ' + entry.path);
|
|
185
|
+
if (root === '') {
|
|
186
|
+
root = entry.path;
|
|
187
|
+
console.log(`Directory root set to ${root}`);
|
|
188
|
+
}
|
|
189
|
+
//if (!found && entry.type === 'Directory' && entry.path.match(/\/node_modules\/$/)) {
|
|
190
|
+
if (!found && entry.type === 'Directory' && entry.path === `${root}node_modules/`) {
|
|
191
|
+
console.log(`Found ${entry.path}`);
|
|
192
|
+
found = true;
|
|
193
|
+
context.errors.push(
|
|
194
|
+
'[E500] Directory node_modules found in root of repository. Please delete directory.',
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Get a list of all files and `.npmignore` + `.gitignore`
|
|
199
|
+
const name = entry.path.replace(/^[^/]+\//, '');
|
|
200
|
+
context.filesList.push(name);
|
|
201
|
+
|
|
202
|
+
if (readFiles.includes(name)) {
|
|
203
|
+
promises.push(
|
|
204
|
+
new Promise((resolve) => {
|
|
205
|
+
const wstream = new WMStrm(name);
|
|
206
|
+
wstream.on('finish', () => {
|
|
207
|
+
context[`/${name}`] = memStore[name].toString();
|
|
208
|
+
resolve(context[`/${name}`]);
|
|
209
|
+
});
|
|
210
|
+
entry.pipe(wstream);
|
|
211
|
+
}),
|
|
212
|
+
);
|
|
213
|
+
} else {
|
|
214
|
+
entry.autodrain();
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
.on('error', () => {
|
|
218
|
+
common.debug('on.error');
|
|
219
|
+
context.errors.push(`[E501] Cannot get ${context.branch}.zip on github`);
|
|
220
|
+
return Promise.all(promises).then(() => _resolve(context));
|
|
221
|
+
})
|
|
222
|
+
.on('close', () => {
|
|
223
|
+
common.debug('on.close');
|
|
224
|
+
return Promise.all(promises).then(() => _resolve(context));
|
|
225
|
+
});
|
|
194
226
|
});
|
|
195
|
-
});
|
|
196
|
-
}
|
|
227
|
+
})();
|
|
228
|
+
}
|
|
197
229
|
|
|
198
230
|
let usesReact = false;
|
|
199
|
-
if (
|
|
200
|
-
|
|
231
|
+
if (
|
|
232
|
+
context.packageJson.devDependencies &&
|
|
233
|
+
(context.packageJson.devDependencies['@iobroker/adapter-react-v5'] ||
|
|
234
|
+
context.packageJson.devDependencies['react'])
|
|
235
|
+
) {
|
|
201
236
|
console.log('REACT detected at package devDependencies');
|
|
202
237
|
usesReact = true;
|
|
203
238
|
}
|
|
204
|
-
if (
|
|
205
|
-
|
|
239
|
+
if (
|
|
240
|
+
context.packageJson.dependencies &&
|
|
241
|
+
(context.packageJson.dependencies['@iobroker/adapter-react-v5'] || context.packageJson.dependencies['react'])
|
|
242
|
+
) {
|
|
206
243
|
console.log('REACT detected at package dependencies');
|
|
207
244
|
usesReact = true;
|
|
208
245
|
}
|
|
209
246
|
if (context['/src-admin/package.json']) {
|
|
210
247
|
//console.log('"src-admin/package.json" exists');
|
|
211
248
|
const packageJson = JSON.parse(context['/src-admin/package.json']);
|
|
212
|
-
if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5']
|
|
249
|
+
if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5']) {
|
|
213
250
|
console.log('REACT detected at src-admin/package devDependencies');
|
|
214
251
|
usesReact = true;
|
|
215
252
|
}
|
|
216
|
-
if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5']
|
|
253
|
+
if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5']) {
|
|
217
254
|
console.log('REACT detected at src-admin/package dependencies');
|
|
218
255
|
usesReact = true;
|
|
219
256
|
}
|
|
@@ -221,13 +258,17 @@ async function checkCode(context) {
|
|
|
221
258
|
if (context['/src-widgets/package.json']) {
|
|
222
259
|
//console.log('"src-widgets/package.json" exists');
|
|
223
260
|
const packageJson = JSON.parse(context['/src-widgets/package.json']);
|
|
224
|
-
if (
|
|
225
|
-
packageJson.devDependencies
|
|
261
|
+
if (
|
|
262
|
+
packageJson.devDependencies &&
|
|
263
|
+
(packageJson.devDependencies['@iobroker/adapter-react-v5'] || packageJson.devDependencies['react'])
|
|
264
|
+
) {
|
|
226
265
|
console.log('REACT detected at src-widgets/package devDependencies');
|
|
227
266
|
usesReact = true;
|
|
228
267
|
}
|
|
229
|
-
if (
|
|
230
|
-
packageJson.dependencies
|
|
268
|
+
if (
|
|
269
|
+
packageJson.dependencies &&
|
|
270
|
+
(packageJson.dependencies['@iobroker/adapter-react-v5'] || packageJson.dependencies['react'])
|
|
271
|
+
) {
|
|
231
272
|
console.log('REACT detected at src-widgets/package dependencies');
|
|
232
273
|
usesReact = true;
|
|
233
274
|
}
|
|
@@ -235,25 +276,35 @@ async function checkCode(context) {
|
|
|
235
276
|
if (context['/src/package.json']) {
|
|
236
277
|
//console.log('"src/package.json" exists');
|
|
237
278
|
const packageJson = JSON.parse(context['/src/package.json']);
|
|
238
|
-
if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5']
|
|
279
|
+
if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5']) {
|
|
239
280
|
// console.log('REACT detected');
|
|
240
281
|
usesReact = true;
|
|
241
282
|
}
|
|
242
|
-
if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5']
|
|
283
|
+
if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5']) {
|
|
243
284
|
// console.log('REACT detected');
|
|
244
285
|
usesReact = true;
|
|
245
286
|
}
|
|
246
287
|
}
|
|
247
288
|
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
289
|
+
if (
|
|
290
|
+
!usesReact &&
|
|
291
|
+
!context.ioPackageJson.common.noConfig &&
|
|
292
|
+
(!context.ioPackageJson.common.adminUI ||
|
|
293
|
+
(context.ioPackageJson.common.adminUI.config !== 'json' &&
|
|
294
|
+
context.ioPackageJson.common.adminUI.config !== 'none'))
|
|
295
|
+
) {
|
|
252
296
|
context.warnings.push('[S522] Please consider migrating to admin 5 UI (jsonConfig).');
|
|
253
297
|
}
|
|
254
298
|
|
|
255
|
-
if (
|
|
256
|
-
|
|
299
|
+
if (
|
|
300
|
+
context.ioPackageJson.common.materialize ||
|
|
301
|
+
(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'materialize')
|
|
302
|
+
) {
|
|
303
|
+
if (
|
|
304
|
+
context['/admin/index_m.html'] &&
|
|
305
|
+
context['/admin/index_m.html'].includes('selectID.js') &&
|
|
306
|
+
!context.filesList.includes('admin/img/info-big.png')
|
|
307
|
+
) {
|
|
257
308
|
context.errors.push('[E502] "admin/img/info-big.png" not found, but selectID.js used in index_m.html ');
|
|
258
309
|
}
|
|
259
310
|
|
|
@@ -261,16 +312,22 @@ async function checkCode(context) {
|
|
|
261
312
|
// at least 3 languages must be in
|
|
262
313
|
const words = extractWords(context['/admin/words.js']);
|
|
263
314
|
if (words) {
|
|
264
|
-
const problem = Object.keys(words).filter(word => !words[word].de || !words[word].ru);
|
|
315
|
+
const problem = Object.keys(words).filter((word) => !words[word].de || !words[word].ru);
|
|
265
316
|
if (problem.length > 3) {
|
|
266
|
-
context.errors.push(
|
|
317
|
+
context.errors.push(
|
|
318
|
+
`[E506] More non translated in german or russian words found in admin/words.js. You can use https://translator.iobroker.in/ for translations`,
|
|
319
|
+
);
|
|
267
320
|
} else {
|
|
268
|
-
problem.forEach(word => {
|
|
321
|
+
problem.forEach((word) => {
|
|
269
322
|
if (!words[word].de) {
|
|
270
|
-
context.errors.push(
|
|
323
|
+
context.errors.push(
|
|
324
|
+
`[E506] Word "${word}" is not translated to german in admin/words.js. You can use https://translator.iobroker.in/ for translations`,
|
|
325
|
+
);
|
|
271
326
|
}
|
|
272
327
|
if (!words[word].ru) {
|
|
273
|
-
context.errors.push(
|
|
328
|
+
context.errors.push(
|
|
329
|
+
`[E506] Word "${word}" is not translated to russian in admin/words.js. You can use https://translator.iobroker.in/ for translations`,
|
|
330
|
+
);
|
|
274
331
|
}
|
|
275
332
|
});
|
|
276
333
|
}
|
|
@@ -284,47 +341,71 @@ async function checkCode(context) {
|
|
|
284
341
|
let jsonConfig;
|
|
285
342
|
if (context['/admin/jsonConfig.json'] || context['/admin/jsonConfig.json5']) {
|
|
286
343
|
try {
|
|
287
|
-
jsonConfig = context['/admin/jsonConfig.json']
|
|
344
|
+
jsonConfig = context['/admin/jsonConfig.json']
|
|
345
|
+
? JSON.parse(context['/admin/jsonConfig.json'])
|
|
346
|
+
: JSON5.parse(context['/admin/jsonConfig.json5']);
|
|
288
347
|
} catch (e) {
|
|
289
|
-
context.errors.push(
|
|
348
|
+
context.errors.push(
|
|
349
|
+
`[E507] Cannot parse "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`,
|
|
350
|
+
);
|
|
290
351
|
}
|
|
291
352
|
} else {
|
|
292
|
-
context.errors.push(
|
|
353
|
+
context.errors.push(
|
|
354
|
+
`[E508] "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}" not found, but admin support is declared`,
|
|
355
|
+
);
|
|
293
356
|
}
|
|
294
357
|
|
|
295
|
-
if (jsonConfig
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
358
|
+
if (jsonConfig) {
|
|
359
|
+
if (jsonConfig.i18n === true) {
|
|
360
|
+
context.cfg.allowedLanguages.forEach((lang) => {
|
|
361
|
+
if (context[`/admin/i18n/${lang}/translations.json`]) {
|
|
362
|
+
try {
|
|
363
|
+
JSON.parse(context[`/admin/i18n/${lang}/translations.json`]);
|
|
364
|
+
} catch (e) {
|
|
365
|
+
context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}/translations.json": ${e}`);
|
|
366
|
+
}
|
|
367
|
+
} else if (context[`/admin/i18n/${lang}.json`]) {
|
|
368
|
+
try {
|
|
369
|
+
JSON.parse(context[`/admin/i18n/${lang}.json`]);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}.json": ${e}`);
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
context.warnings.push(
|
|
375
|
+
`[W510] "/admin/i18n/${lang}/translations.json" or "admin/i18n/${lang}.json" not found, but admin support is declared. Please add.`,
|
|
376
|
+
);
|
|
308
377
|
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
378
|
+
});
|
|
379
|
+
} else if (jsonConfig.i18n === false) {
|
|
380
|
+
context.warnings.push(`[W515] Why did you decide to disable i18n support?`);
|
|
381
|
+
} else {
|
|
382
|
+
context.warnings.push(`[W522] Why did you decide not to use i18n support?`);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
M500__jsonConfig.checkJsonConfig(context, `admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}`, jsonConfig);
|
|
386
|
+
|
|
387
|
+
} // if (jsonConfig) ...
|
|
317
388
|
}
|
|
318
389
|
|
|
319
|
-
if (
|
|
390
|
+
if (
|
|
391
|
+
context.ioPackageJson.common.supportCustoms ||
|
|
392
|
+
context.ioPackageJson.common.jsonCustom ||
|
|
393
|
+
(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')
|
|
394
|
+
) {
|
|
320
395
|
if (context['/admin/jsonCustom.json'] || context['/admin/jsonCustom.json5']) {
|
|
321
396
|
try {
|
|
322
|
-
context['/admin/jsonCustom.json']
|
|
397
|
+
context['/admin/jsonCustom.json']
|
|
398
|
+
? JSON.parse(context['/admin/jsonCustom.json'])
|
|
399
|
+
: JSON5.parse(context['/admin/jsonCustom.json5']);
|
|
323
400
|
} catch (e) {
|
|
324
|
-
context.errors.push(
|
|
401
|
+
context.errors.push(
|
|
402
|
+
`[E511] Cannot parse "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`,
|
|
403
|
+
);
|
|
325
404
|
}
|
|
326
405
|
} else {
|
|
327
|
-
context.errors.push(
|
|
406
|
+
context.errors.push(
|
|
407
|
+
`[E512] "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`,
|
|
408
|
+
);
|
|
328
409
|
}
|
|
329
410
|
}
|
|
330
411
|
|
|
@@ -334,27 +415,29 @@ async function checkCode(context) {
|
|
|
334
415
|
|
|
335
416
|
if (context.ioPackageJson.common.javascriptRules) {
|
|
336
417
|
if (!context.ioPackageJson.common.javascriptRules.url) {
|
|
337
|
-
context.errors.push(
|
|
418
|
+
context.errors.push(
|
|
419
|
+
'[E517] JavaScript-Rules support is declared, but no location in property common.javascriptRules.url defined',
|
|
420
|
+
);
|
|
338
421
|
}
|
|
339
422
|
if (!context.filesList.includes('admin/' + context.ioPackageJson.common.javascriptRules.url)) {
|
|
340
|
-
context.errors.push(
|
|
423
|
+
context.errors.push(
|
|
424
|
+
`[E516] "${context.ioPackageJson.common.javascriptRules.url}" not found, but JavaScript-Rules support is declared`,
|
|
425
|
+
);
|
|
341
426
|
}
|
|
342
427
|
}
|
|
343
428
|
|
|
344
|
-
const forbiddenFiles = [
|
|
345
|
-
'iob_npm.done',
|
|
346
|
-
'iob',
|
|
347
|
-
'iobroker'
|
|
348
|
-
];
|
|
429
|
+
const forbiddenFiles = ['iob_npm.done', 'iob', 'iobroker'];
|
|
349
430
|
|
|
350
|
-
forbiddenFiles.forEach(
|
|
431
|
+
forbiddenFiles.forEach((file) => {
|
|
351
432
|
if (context.filesList.includes(file)) {
|
|
352
433
|
context.errors.push(`[E503] File "${file}" found in repo! Please remove file.`);
|
|
353
434
|
}
|
|
354
435
|
});
|
|
355
436
|
|
|
356
437
|
if (!context.filesList.includes('package-lock.json')) {
|
|
357
|
-
context.warnings.push(
|
|
438
|
+
context.warnings.push(
|
|
439
|
+
'[S523] "package-lock.json" not found in repo! Please consider to commit it to github repository.',
|
|
440
|
+
);
|
|
358
441
|
}
|
|
359
442
|
|
|
360
443
|
if (context['/.travis.yml']) {
|
|
@@ -363,24 +446,32 @@ async function checkCode(context) {
|
|
|
363
446
|
|
|
364
447
|
if (context['/gulpfile.js']) {
|
|
365
448
|
if (!usesReact) {
|
|
366
|
-
context.warnings.push(
|
|
449
|
+
context.warnings.push(
|
|
450
|
+
'[W513] "gulpfile.js" found in repo! Think about migrating to @iobroker/adapter-dev package',
|
|
451
|
+
);
|
|
367
452
|
}
|
|
368
453
|
if (!context.packageJson.devDependencies['gulp']) {
|
|
369
|
-
context.warnings.push(
|
|
454
|
+
context.warnings.push(
|
|
455
|
+
'[W520] "gulpfile.js" found in repo but "gulp" not found at devDependencies at package.json. Check whether it can be removed.',
|
|
456
|
+
);
|
|
370
457
|
}
|
|
371
458
|
} else {
|
|
372
459
|
if (context.packageJson.devDependencies['gulp']) {
|
|
373
|
-
context.warnings.push(
|
|
460
|
+
context.warnings.push(
|
|
461
|
+
'[W521] "gulp" found at devDependencies at package.json but no "gulpfile.js" found. Is this dependency really required?',
|
|
462
|
+
);
|
|
374
463
|
}
|
|
375
464
|
}
|
|
376
465
|
|
|
377
|
-
if (context.packageJson.devDependencies && context.packageJson.devDependencies['@alcalzone/release-script']
|
|
466
|
+
if (context.packageJson.devDependencies && context.packageJson.devDependencies['@alcalzone/release-script']) {
|
|
378
467
|
const version = context.packageJson.devDependencies['@alcalzone/release-script'];
|
|
379
|
-
if (
|
|
468
|
+
if (compareVersions.compareVersions(version, '3.0.0') >= 0) {
|
|
380
469
|
if (!context['/.releaseconfig.json']) {
|
|
381
|
-
context.errors.push(
|
|
470
|
+
context.errors.push(
|
|
471
|
+
'[E518] "@alcalzone/release-script" (>=3.0.0) is used, but ".releaseconfig.json" not found. Please create.',
|
|
472
|
+
);
|
|
382
473
|
} else {
|
|
383
|
-
console.log('context[/.releaseconfig.json: '+ context['/.releaseconfig.json']);
|
|
474
|
+
console.log('context[/.releaseconfig.json: ' + context['/.releaseconfig.json']);
|
|
384
475
|
try {
|
|
385
476
|
const releaseConfigJson = JSON.parse(context['/.releaseconfig.json']);
|
|
386
477
|
console.log(`releaseConfigJson: ${releaseConfigJson}`);
|
|
@@ -388,26 +479,34 @@ async function checkCode(context) {
|
|
|
388
479
|
const plugins = releaseConfigJson.plugins;
|
|
389
480
|
console.log(`plugins: ${plugins}`);
|
|
390
481
|
if (!context.packageJson.devDependencies['@alcalzone/release-script-plugin-iobroker']) {
|
|
391
|
-
context.errors.push(
|
|
482
|
+
context.errors.push(
|
|
483
|
+
'[E524] "@alcalzone/release-script" requires plugin "@alcalzone/release-script-plugin-iobroker". Please add.',
|
|
484
|
+
);
|
|
392
485
|
} else {
|
|
393
486
|
if (!plugins.includes('iobroker')) {
|
|
394
487
|
context.errors.push('[E527] Plugin "iobroker" missing at .releaseconfig.json. Please add.');
|
|
395
488
|
}
|
|
396
489
|
}
|
|
397
490
|
if (!context.packageJson.devDependencies['@alcalzone/release-script-plugin-license']) {
|
|
398
|
-
context.errors.push(
|
|
491
|
+
context.errors.push(
|
|
492
|
+
'[E525] "@alcalzone/release-script" requires plugin "@alcalzone/release-script-plugin-license". Please add.',
|
|
493
|
+
);
|
|
399
494
|
} else {
|
|
400
495
|
if (!plugins.includes('license')) {
|
|
401
496
|
context.errors.push('[E528] Plugin "license" missing at .releaseconfig.json. Please add.');
|
|
402
497
|
}
|
|
403
498
|
}
|
|
404
499
|
if (!context.packageJson.devDependencies['@alcalzone/release-script-plugin-manual-review']) {
|
|
405
|
-
context.warnings.push(
|
|
500
|
+
context.warnings.push(
|
|
501
|
+
'[S526] Consider adding plugin "@alcalzone/release-script-plugin-manual-review".',
|
|
502
|
+
);
|
|
406
503
|
} else {
|
|
407
504
|
if (!plugins.includes('manual-review')) {
|
|
408
|
-
context.warnings.push(
|
|
505
|
+
context.warnings.push(
|
|
506
|
+
'[W529] Plugin "manual-review" missing at .releaseconfig.json. Please add.',
|
|
507
|
+
);
|
|
409
508
|
}
|
|
410
|
-
}
|
|
509
|
+
}
|
|
411
510
|
} catch (e) {
|
|
412
511
|
context.errors.push(`[E530] .releaseconfig.json is no valid json file - ${e}.`);
|
|
413
512
|
}
|
|
@@ -418,31 +517,47 @@ async function checkCode(context) {
|
|
|
418
517
|
if (context.packageJson.main && context.packageJson.main.endsWith('.js')) {
|
|
419
518
|
if (!context[`/${context.packageJson.main}`]) {
|
|
420
519
|
if (!context.ioPackageJson.common.nogit) {
|
|
421
|
-
context.errors.push(
|
|
520
|
+
context.errors.push(
|
|
521
|
+
`[E519] "${context.packageJson.main}" found in package.json, but not found as file`,
|
|
522
|
+
);
|
|
422
523
|
}
|
|
423
524
|
} else {
|
|
424
|
-
if (
|
|
525
|
+
if (
|
|
526
|
+
context[`/${context.packageJson.main}`].includes('setInterval(') &&
|
|
527
|
+
!context[`/${context.packageJson.main}`].includes('clearInterval(')
|
|
528
|
+
) {
|
|
425
529
|
if (context.ioPackageJson.common.compact) {
|
|
426
530
|
// if compact mode supported, it is critical
|
|
427
|
-
context.errors.push(
|
|
531
|
+
context.errors.push(
|
|
532
|
+
`[E504] setInterval found in "${context.packageJson.main}", but no clearInterval detected`,
|
|
533
|
+
);
|
|
428
534
|
} else {
|
|
429
|
-
context.warnings.push(
|
|
535
|
+
context.warnings.push(
|
|
536
|
+
`[W504] setInterval found in "${context.packageJson.main}", but no clearInterval detected`,
|
|
537
|
+
);
|
|
430
538
|
}
|
|
431
539
|
}
|
|
432
|
-
if (
|
|
540
|
+
if (
|
|
541
|
+
context['/' + context.packageJson.main].includes('setTimeout(') &&
|
|
542
|
+
!context['/' + context.packageJson.main].includes('clearTimeout(')
|
|
543
|
+
) {
|
|
433
544
|
if (context.ioPackageJson.common.compact) {
|
|
434
545
|
// if compact mode supported, it is critical
|
|
435
546
|
// context.errors.push(`[E505] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`);
|
|
436
|
-
context.warnings.push(
|
|
547
|
+
context.warnings.push(
|
|
548
|
+
`[W505] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`,
|
|
549
|
+
);
|
|
437
550
|
} else {
|
|
438
|
-
context.warnings.push(
|
|
551
|
+
context.warnings.push(
|
|
552
|
+
`[W505] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`,
|
|
553
|
+
);
|
|
439
554
|
}
|
|
440
555
|
}
|
|
441
556
|
}
|
|
442
557
|
}
|
|
443
558
|
|
|
444
|
-
// single free 522
|
|
445
559
|
// first free 0530
|
|
560
|
+
// 550 - xxx reserved for jsonConfig module
|
|
446
561
|
|
|
447
562
|
return context;
|
|
448
563
|
}
|
|
@@ -454,7 +569,7 @@ exports.checkCode = checkCode;
|
|
|
454
569
|
|
|
455
570
|
// [500] node_modules found in repo. Please delete it
|
|
456
571
|
// [501] Cannot get ${context.branch}.zip on github
|
|
457
|
-
// [502] "admin/img/info-big.png" not found, but selectID.js used in index_m.html
|
|
572
|
+
// [502] "admin/img/info-big.png" not found, but selectID.js used in index_m.html
|
|
458
573
|
// [503] File "${file}" found in repo! Please remove file.
|
|
459
574
|
// [504] setInterval found in "${context.packageJson.main}", but no clearInterval detected
|
|
460
575
|
// [504] setInterval found in "${context.packageJson.main}", but no clearInterval detected
|
|
@@ -480,7 +595,7 @@ exports.checkCode = checkCode;
|
|
|
480
595
|
// [519] "${context.packageJson.main}" found in package.json, but not found as file
|
|
481
596
|
// [520] "gulpfile.js" found in repo but "gulp" not found at devDependencies at package.json. Check whether it can be removed.
|
|
482
597
|
// [521] "gulp" found at devDependencies at package.json but no "gulpfile.js" found. Is this dependency really required?
|
|
483
|
-
// [522]
|
|
598
|
+
// [522] "Why did you decide not to use i18n support?"
|
|
484
599
|
// [523] "package-lock.json" not found in repo! Please remove from .gitignore!
|
|
485
600
|
// [524] "@alcalzone/release-script" requires plugin "@alcalzone/release-script-plugin-iobroker". Please add.
|
|
486
601
|
// [525] "@alcalzone/release-script" requires plugin "@alcalzone/release-script-plugin-license". Please add.
|
|
@@ -490,3 +605,4 @@ exports.checkCode = checkCode;
|
|
|
490
605
|
// [529] Plugin "manual-review" missing at .releaseconfig.json. Please add.
|
|
491
606
|
// [530] .releaseconfig.json is no valid json file - ${e}.
|
|
492
607
|
|
|
608
|
+
// [550 - ] see M500_jsonConfig.js
|