@iobroker/repochecker 2.0.5 → 2.1.3
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 +9 -0
- package/index.js +179 -144
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -20,6 +20,15 @@ Branch (`master/main/dev`) is optional.
|
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
22
|
## Changelog
|
|
23
|
+
### 2.1.3 (2022-08-19)
|
|
24
|
+
* (bluefox) Added check for adapter name: it may not start with '_'
|
|
25
|
+
|
|
26
|
+
### 2.1.2 (2022-07-14)
|
|
27
|
+
* (bluefox) Fixed some errors
|
|
28
|
+
|
|
29
|
+
### 2.1.0 (2022-05-26)
|
|
30
|
+
* (bluefox) Added support of jsonConfig.json5 and jsonCustom.json5
|
|
31
|
+
|
|
23
32
|
### 2.0.5 (2022-05-22)
|
|
24
33
|
* (bluefox) Made it possible to run with npx
|
|
25
34
|
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
/*
|
|
3
|
+
/*
|
|
4
4
|
|
|
5
5
|
___ _ _ _____ _ _
|
|
6
6
|
/ _ \ | | | | / __ \ | | |
|
|
@@ -13,19 +13,18 @@
|
|
|
13
13
|
|
|
14
14
|
*/
|
|
15
15
|
const unzipper = require('unzipper');
|
|
16
|
-
const util
|
|
17
|
-
const stream
|
|
16
|
+
const util = require('util');
|
|
17
|
+
const stream = require('stream');
|
|
18
18
|
const Writable = stream.Writable;
|
|
19
|
-
const sizeOf
|
|
20
|
-
const axios
|
|
19
|
+
const sizeOf = require('image-size');
|
|
20
|
+
const axios = require('axios');
|
|
21
|
+
const JSON5 = require('json5');
|
|
21
22
|
const compareVersions = require('compare-versions');
|
|
22
23
|
|
|
23
|
-
const version
|
|
24
|
+
const version = require('./package.json').version;
|
|
24
25
|
const recommendedJsControllerVersion = '3.3.22';
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const memStore = { };
|
|
27
|
+
const memStore = {};
|
|
29
28
|
|
|
30
29
|
/* Writable memory stream */
|
|
31
30
|
function WMStrm(key, options) {
|
|
@@ -37,6 +36,7 @@ function WMStrm(key, options) {
|
|
|
37
36
|
this.key = key; // save key
|
|
38
37
|
memStore[key] = Buffer.from(''); // empty
|
|
39
38
|
}
|
|
39
|
+
|
|
40
40
|
util.inherits(WMStrm, Writable);
|
|
41
41
|
|
|
42
42
|
WMStrm.prototype._write = function (chunk, enc, cb) {
|
|
@@ -109,15 +109,15 @@ function checkPackageJson(context) {
|
|
|
109
109
|
.then(packageJson => resolve(packageJson))
|
|
110
110
|
.catch(e => reject(e));
|
|
111
111
|
}
|
|
112
|
-
})
|
|
113
|
-
|
|
112
|
+
})
|
|
113
|
+
.then(packageJson => {
|
|
114
114
|
context.packageJson = packageJson;
|
|
115
115
|
if (typeof context.packageJson === 'string') {
|
|
116
116
|
try {
|
|
117
117
|
context.packageJson = JSON.parse(context.packageJson);
|
|
118
118
|
} catch (e) {
|
|
119
119
|
context.errors.push('[E001] Cannot parse packet.json: ' + e);
|
|
120
|
-
return
|
|
120
|
+
return context;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -150,13 +150,19 @@ function checkPackageJson(context) {
|
|
|
150
150
|
context.checks.push('Adapter name is lowercase');
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
if (adapterName.match(/[^-_a-
|
|
153
|
+
if (adapterName.match(/[^-_a-z\d]/)) {
|
|
154
154
|
context.errors.push(`[E006] Invalid characters found in adapter name "${adapterName}". Only lowercase chars, digits, "-" and "_" are allowed`);
|
|
155
155
|
} else {
|
|
156
156
|
context.checks.push(`No invalid characters found in "${adapterName}"`);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
if (adapterName.startsWith('_')) {
|
|
160
|
+
context.errors.push(`[E024] Adapter name "${adapterName}" may not start from '_'`);
|
|
161
|
+
} else {
|
|
162
|
+
context.checks.push(`Adapter name "${adapterName}" does not start from '_'`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const n = context.githubUrlOriginal.match(/\/([^/]+)\/iobroker\./i);
|
|
160
166
|
if (!n || !n[1]) {
|
|
161
167
|
context.errors.push('[E007] Cannot find author repo in the URL');
|
|
162
168
|
} else {
|
|
@@ -164,9 +170,9 @@ function checkPackageJson(context) {
|
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
if (context.packageJson.name !== 'iobroker.' + adapterName.toLowerCase()) {
|
|
167
|
-
context.errors.push(
|
|
173
|
+
context.errors.push(`[E020] Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}". Now is "${packageJson.name}"`);
|
|
168
174
|
} else {
|
|
169
|
-
context.checks.push(
|
|
175
|
+
context.checks.push(`Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}".`);
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
if (!context.packageJson.version) {
|
|
@@ -249,17 +255,23 @@ function checkPackageJson(context) {
|
|
|
249
255
|
context.errors.push('[E019] Invalid repository URL');
|
|
250
256
|
}
|
|
251
257
|
}
|
|
258
|
+
|
|
252
259
|
if (reservedAdapterNames.includes(adapterName)) {
|
|
253
260
|
context.errors.push('[E022] Adapter name is reserved!');
|
|
254
261
|
} else {
|
|
255
262
|
context.checks.push('Adapter name is not reserved');
|
|
256
263
|
}
|
|
257
264
|
|
|
258
|
-
|
|
265
|
+
if ((context.packageJson.dependencies && context.packageJson.dependencies.npm) || (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies.npm)) {
|
|
266
|
+
context.errors.push('[E023] Do not include "npm" as dependency!');
|
|
267
|
+
} else {
|
|
268
|
+
context.checks.push('npm is not in dependencies');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// max number is E024
|
|
259
272
|
|
|
260
|
-
|
|
273
|
+
return context;
|
|
261
274
|
});
|
|
262
|
-
});
|
|
263
275
|
}
|
|
264
276
|
|
|
265
277
|
const allowedLanguages = [
|
|
@@ -280,7 +292,7 @@ const allowedModes = {
|
|
|
280
292
|
'daemon': 'always running process (will be restarted if process exits)',
|
|
281
293
|
'subscribe': 'is started when state system.adapter…alive changes to true. Is killed when .alive changes to false and sets .alive to false if process exits (will not be restarted when process exits)',
|
|
282
294
|
'schedule': 'is started by schedule found in system.adapter…common.schedule - reacts on changes of .schedule by rescheduling with new state',
|
|
283
|
-
'once'
|
|
295
|
+
'once': 'his adapter will be started every time the system.adapter.. object changed. It will not be restarted after termination.',
|
|
284
296
|
'extension': ''
|
|
285
297
|
};
|
|
286
298
|
|
|
@@ -1180,8 +1192,10 @@ function checkNpm(context) {
|
|
|
1180
1192
|
!body.collected ||
|
|
1181
1193
|
!body.collected.metadata ||
|
|
1182
1194
|
!body.collected.metadata.version ||
|
|
1183
|
-
context.packageJson.version !== body.collected.metadata.version
|
|
1184
|
-
|
|
1195
|
+
context.packageJson.version !== body.collected.metadata.version
|
|
1196
|
+
) {
|
|
1197
|
+
context.warnings.push(`[W202] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${
|
|
1198
|
+
(body && body.collected && body.collected.metadata && body.collected.metadata.version) || JSON.stringify(body)})`);
|
|
1185
1199
|
} else {
|
|
1186
1200
|
context.checks.push('Version of package.json matches latest version on NPM');
|
|
1187
1201
|
}
|
|
@@ -1276,7 +1290,7 @@ function checkRepo(context) {
|
|
|
1276
1290
|
context.checks.push('Icon found in latest repository');
|
|
1277
1291
|
|
|
1278
1292
|
if (!context.latestRepo[context.adapterName].icon.startsWith(url)) {
|
|
1279
|
-
context.errors.push('[E405] Icon must be in the following path: '
|
|
1293
|
+
context.errors.push('[E405] Icon must be in the following path: ' + url);
|
|
1280
1294
|
} else {
|
|
1281
1295
|
context.checks.push('Icon found in latest repository');
|
|
1282
1296
|
}
|
|
@@ -1329,7 +1343,7 @@ function checkRepo(context) {
|
|
|
1329
1343
|
context.checks.push('Icon found in stable repository');
|
|
1330
1344
|
|
|
1331
1345
|
if (!context.stableRepo[context.adapterName].icon.startsWith(url)) {
|
|
1332
|
-
context.errors.push('[E426] Icon (stable) must be in the following path: '
|
|
1346
|
+
context.errors.push('[E426] Icon (stable) must be in the following path: ' + url);
|
|
1333
1347
|
} else {
|
|
1334
1348
|
context.checks.push('Icon (stable) found in latest repository');
|
|
1335
1349
|
}
|
|
@@ -1407,13 +1421,14 @@ function checkCode(context) {
|
|
|
1407
1421
|
|
|
1408
1422
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
1409
1423
|
readFiles.push('admin/jsonConfig.json');
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1424
|
+
readFiles.push('admin/jsonConfig.json5');
|
|
1425
|
+
allowedLanguages.forEach(lang =>
|
|
1426
|
+
readFiles.push(`admin/i18n/${lang}/translations.json`));
|
|
1413
1427
|
}
|
|
1414
1428
|
|
|
1415
1429
|
if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
|
|
1416
1430
|
readFiles.push('admin/jsonCustom.json');
|
|
1431
|
+
readFiles.push('admin/jsonCustom.json5');
|
|
1417
1432
|
}
|
|
1418
1433
|
}
|
|
1419
1434
|
|
|
@@ -1446,7 +1461,7 @@ function checkCode(context) {
|
|
|
1446
1461
|
}
|
|
1447
1462
|
// Get list of all files and .npmignore + .gitignore
|
|
1448
1463
|
|
|
1449
|
-
const name = entry.path.replace(/^[
|
|
1464
|
+
const name = entry.path.replace(/^[^/]+\//, '');
|
|
1450
1465
|
context.filesList.push(name);
|
|
1451
1466
|
|
|
1452
1467
|
if (readFiles.includes(name)) {
|
|
@@ -1501,38 +1516,44 @@ function checkCode(context) {
|
|
|
1501
1516
|
}
|
|
1502
1517
|
|
|
1503
1518
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
1504
|
-
|
|
1519
|
+
let jsonConfig;
|
|
1520
|
+
if (context['/admin/jsonConfig.json'] || context['/admin/jsonConfig.json5']) {
|
|
1505
1521
|
try {
|
|
1506
|
-
JSON.parse(context['/admin/jsonConfig.json']);
|
|
1522
|
+
jsonConfig = context['/admin/jsonConfig.json'] ? JSON.parse(context['/admin/jsonConfig.json']) : JSON5.parse(context['/admin/jsonConfig.json5']);
|
|
1507
1523
|
} catch (e) {
|
|
1508
|
-
context.errors.push(
|
|
1524
|
+
context.errors.push(`[E507] Cannot parse "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`);
|
|
1509
1525
|
}
|
|
1510
1526
|
} else {
|
|
1511
|
-
context.errors.push(`[E508] "admin/jsonConfig.json" not found, but admin support is declared`);
|
|
1527
|
+
context.errors.push(`[E508] "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}" not found, but admin support is declared`);
|
|
1512
1528
|
}
|
|
1513
1529
|
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1530
|
+
if (jsonConfig && jsonConfig.i18n === true) {
|
|
1531
|
+
allowedLanguages.forEach(lang => {
|
|
1532
|
+
if (context[`/admin/i18n/${lang}/translations.json`]) {
|
|
1533
|
+
try {
|
|
1534
|
+
JSON.parse(context[`/admin/i18n/${lang}/translations.json`]);
|
|
1535
|
+
} catch (e) {
|
|
1536
|
+
context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}/translations.json": ${e}`);
|
|
1537
|
+
}
|
|
1538
|
+
} else {
|
|
1539
|
+
context.errors.push(`[E510] "/admin/i18n/${lang}/translations.json" not found, but admin support is declared`);
|
|
1520
1540
|
}
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
if (jsonConfig && jsonConfig.i18n === false) {
|
|
1544
|
+
context.warnings.push(`[W515] Why you decided to disable i18n support?`);
|
|
1545
|
+
}
|
|
1525
1546
|
}
|
|
1526
1547
|
|
|
1527
1548
|
if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
|
|
1528
|
-
if (context['/admin/jsonCustom.json']) {
|
|
1549
|
+
if (context['/admin/jsonCustom.json'] || context['/admin/jsonCustom.json5']) {
|
|
1529
1550
|
try {
|
|
1530
|
-
JSON.parse(context['/admin/jsonCustom.json']);
|
|
1551
|
+
context['/admin/jsonCustom.json'] ? JSON.parse(context['/admin/jsonCustom.json']) : JSON5.parse(context['/admin/jsonCustom.json5']);
|
|
1531
1552
|
} catch (e) {
|
|
1532
|
-
context.errors.push(
|
|
1553
|
+
context.errors.push(`[E511] Cannot parse "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`);
|
|
1533
1554
|
}
|
|
1534
1555
|
} else {
|
|
1535
|
-
context.errors.push(`[E512] "admin/jsonCustom.json" not found, but custom support is declared`);
|
|
1556
|
+
context.errors.push(`[E512] "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`);
|
|
1536
1557
|
}
|
|
1537
1558
|
}
|
|
1538
1559
|
|
|
@@ -1574,7 +1595,7 @@ function checkCode(context) {
|
|
|
1574
1595
|
}
|
|
1575
1596
|
}
|
|
1576
1597
|
}
|
|
1577
|
-
// max
|
|
1598
|
+
// max E515
|
|
1578
1599
|
resolve(context);
|
|
1579
1600
|
})
|
|
1580
1601
|
.catch(e => reject(e));
|
|
@@ -1644,7 +1665,7 @@ function checkReadme(context) {
|
|
|
1644
1665
|
} else {
|
|
1645
1666
|
context.checks.push('README.md contains Changelog');
|
|
1646
1667
|
|
|
1647
|
-
if (!data.includes(`### ${context.packageJson.version}`)
|
|
1668
|
+
if (!data.includes(`### ${context.packageJson.version}`)) {
|
|
1648
1669
|
context.errors.push(`[E606] Current adapter version ${context.packageJson.version} not found in README.md`);
|
|
1649
1670
|
} else {
|
|
1650
1671
|
context.checks.push('README.md contains current adapter version');
|
|
@@ -1745,58 +1766,56 @@ function checkNpmIgnore(context) {
|
|
|
1745
1766
|
];
|
|
1746
1767
|
|
|
1747
1768
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
}
|
|
1769
|
+
console.log('checkNpmIgnore [E8xx]');
|
|
1770
|
+
if (context.packageJson.files && context.packageJson.files.length) {
|
|
1771
|
+
return Promise.resolve(context);
|
|
1772
|
+
}
|
|
1753
1773
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1774
|
+
if (!context.filesList.includes('.npmignore')) {
|
|
1775
|
+
context.warnings.push(`[W801] .npmignore not found`);
|
|
1776
|
+
} else {
|
|
1777
|
+
const rules = (context['/.npmignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
|
|
1778
|
+
let tooComplexToCheck = false;
|
|
1779
|
+
rules.forEach((name, i) => {
|
|
1780
|
+
if (name.includes('*')) {
|
|
1781
|
+
rules[i] = new RegExp(name
|
|
1782
|
+
.replace('.', '\\.')
|
|
1783
|
+
.replace('/', '\\/')
|
|
1784
|
+
.replace('**', '.*')
|
|
1785
|
+
.replace('*', '[^\\/]*')
|
|
1786
|
+
);
|
|
1787
|
+
}
|
|
1788
|
+
if (name.startsWith('!')) {
|
|
1789
|
+
tooComplexToCheck = true;
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1772
1792
|
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1793
|
+
// There's no need to put node_modules in .npmignore. npm will never publish node_modules in the package, except if one of the modules is explicitly mentioned in bundledDependencies.
|
|
1794
|
+
/*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
1795
|
+
!check && context.errors.push(`[E804] node_modules not found in .npmignore`);
|
|
1796
|
+
}*/
|
|
1797
|
+
if (!tooComplexToCheck) {
|
|
1798
|
+
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
1799
|
+
!check && context.errors.push(`[E803] iob_npm.done not found in .npmignore`);
|
|
1800
|
+
}
|
|
1781
1801
|
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1802
|
+
checkFiles.forEach((file, i) => {
|
|
1803
|
+
if (context.filesList.includes(file)) {
|
|
1804
|
+
// maybe it is with regex
|
|
1805
|
+
const check = rules.some(rule => {
|
|
1806
|
+
if (typeof rule === 'string') {
|
|
1807
|
+
return rule === file || rule === file.replace(/\/$/, '');
|
|
1808
|
+
} else {
|
|
1809
|
+
return rule.test(file);
|
|
1810
|
+
}
|
|
1811
|
+
});
|
|
1792
1812
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
}
|
|
1813
|
+
!check && context.errors.push(`[E8${paddingNum(i + 11)}] file ${file} found in repository, but not found in .npmignore`);
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1797
1816
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1817
|
+
}
|
|
1818
|
+
return Promise.resolve(context);
|
|
1800
1819
|
}
|
|
1801
1820
|
|
|
1802
1821
|
// E9xx
|
|
@@ -1809,50 +1828,49 @@ function checkGitIgnore(context) {
|
|
|
1809
1828
|
];
|
|
1810
1829
|
|
|
1811
1830
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.gitignore
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
);
|
|
1826
|
-
}
|
|
1827
|
-
});
|
|
1828
|
-
|
|
1829
|
-
if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
1830
|
-
!check && context.errors.push(`[E902] node_modules not found in .npmignore`);
|
|
1831
|
-
}
|
|
1832
|
-
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
1833
|
-
!check && context.errors.push(`[E903] iob_npm.done not found in .gitignore`);
|
|
1831
|
+
console.log('checkGitIgnore [E9xx]');
|
|
1832
|
+
if (!context.filesList.includes('.gitignore')) {
|
|
1833
|
+
context.warnings.push(`[W901] .gitignore not found`);
|
|
1834
|
+
} else {
|
|
1835
|
+
const rules = (context['/.gitignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
|
|
1836
|
+
rules.forEach((name, i) => {
|
|
1837
|
+
if (name.includes('*')) {
|
|
1838
|
+
rules[i] = new RegExp(name
|
|
1839
|
+
.replace('.', '\\.')
|
|
1840
|
+
.replace('/', '\\/')
|
|
1841
|
+
.replace('**', '.*')
|
|
1842
|
+
.replace('*', '[^\\/]*')
|
|
1843
|
+
);
|
|
1834
1844
|
}
|
|
1845
|
+
});
|
|
1835
1846
|
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
// may be it is with regex
|
|
1839
|
-
const check = rules.some(rule => {
|
|
1840
|
-
if (typeof rule === 'string') {
|
|
1841
|
-
return rule === file || rule === file.replace(/\/$/, '');
|
|
1842
|
-
} else {
|
|
1843
|
-
return rule.test(file);
|
|
1844
|
-
}
|
|
1845
|
-
});
|
|
1846
|
-
|
|
1847
|
-
!check && context.errors.push(`[E9${paddingNum(i + 11)}] file ${file} found in repository, but not found in .gitignore`);
|
|
1848
|
-
}
|
|
1849
|
-
});
|
|
1847
|
+
if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
1848
|
+
!check && context.errors.push(`[E902] node_modules not found in .npmignore`);
|
|
1850
1849
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1850
|
+
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
1851
|
+
!check && context.errors.push(`[E903] iob_npm.done not found in .gitignore`);
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
checkFiles.forEach((file, i) => {
|
|
1855
|
+
if (context.filesList.includes(file)) {
|
|
1856
|
+
// maybe it is with regex
|
|
1857
|
+
const check = rules.some(rule => {
|
|
1858
|
+
if (typeof rule === 'string') {
|
|
1859
|
+
return rule === file || rule === file.replace(/\/$/, '');
|
|
1860
|
+
} else {
|
|
1861
|
+
return rule.test(file);
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
|
|
1865
|
+
!check && context.errors.push(`[E9${paddingNum(i + 11)}] file ${file} found in repository, but not found in .gitignore`);
|
|
1866
|
+
}
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
return Promise.resolve(context);
|
|
1853
1871
|
}
|
|
1854
1872
|
|
|
1855
|
-
function makeResponse(code, data
|
|
1873
|
+
function makeResponse(code, data) {
|
|
1856
1874
|
return {
|
|
1857
1875
|
statusCode: code || 200,
|
|
1858
1876
|
headers: {
|
|
@@ -1870,7 +1888,7 @@ function check(request, ctx, callback) {
|
|
|
1870
1888
|
} else {
|
|
1871
1889
|
const context = {checks: [], errors: [], warnings: []};
|
|
1872
1890
|
let githubUrl = request.queryStringParameters.url;
|
|
1873
|
-
|
|
1891
|
+
const githubBranch = request.queryStringParameters.branch;
|
|
1874
1892
|
|
|
1875
1893
|
githubUrl = githubUrl
|
|
1876
1894
|
.replace('http://', 'https://')
|
|
@@ -1899,12 +1917,27 @@ function check(request, ctx, callback) {
|
|
|
1899
1917
|
.then(context => checkNpmIgnore(context))
|
|
1900
1918
|
.then(context => checkGitIgnore(context))
|
|
1901
1919
|
.then(context => {
|
|
1902
|
-
return callback(null, makeResponse(200, {
|
|
1920
|
+
return callback(null, makeResponse(200, {
|
|
1921
|
+
result: 'OK',
|
|
1922
|
+
checks: context.checks,
|
|
1923
|
+
errors: context.errors,
|
|
1924
|
+
warnings: context.warnings,
|
|
1925
|
+
version,
|
|
1926
|
+
hasTravis: context.hasTravis
|
|
1927
|
+
}));
|
|
1903
1928
|
})
|
|
1904
1929
|
.catch(err => {
|
|
1905
|
-
console.error(err);
|
|
1906
|
-
|
|
1907
|
-
return callback(
|
|
1930
|
+
console.error('GLOBAL ERROR' + err);
|
|
1931
|
+
|
|
1932
|
+
return callback(null, makeResponse(200, {
|
|
1933
|
+
result: 'Errors found',
|
|
1934
|
+
checks: context.checks,
|
|
1935
|
+
errors: context.errors,
|
|
1936
|
+
warnings: context.warnings,
|
|
1937
|
+
version,
|
|
1938
|
+
hasTravis: context.hasTravis,
|
|
1939
|
+
error: `${err.request ? err.request.path : ''} ${err.message}`,
|
|
1940
|
+
}));
|
|
1908
1941
|
});
|
|
1909
1942
|
}
|
|
1910
1943
|
}
|
|
@@ -1912,7 +1945,7 @@ function check(request, ctx, callback) {
|
|
|
1912
1945
|
if (typeof module !== 'undefined' && module.parent) {
|
|
1913
1946
|
exports.handler = check;
|
|
1914
1947
|
} else {
|
|
1915
|
-
let repoUrl = 'https://github.com/
|
|
1948
|
+
let repoUrl = 'https://github.com/Dirk-Peter-md/ioBroker.sprinklecontrol';
|
|
1916
1949
|
let repoBranch = null;
|
|
1917
1950
|
|
|
1918
1951
|
// Get url from parameters if possible
|
|
@@ -1926,10 +1959,12 @@ if (typeof module !== 'undefined' && module.parent) {
|
|
|
1926
1959
|
}
|
|
1927
1960
|
|
|
1928
1961
|
console.log(`Checking repository ${repoUrl} (branch ${repoBranch})`);
|
|
1929
|
-
check({
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1962
|
+
check({
|
|
1963
|
+
queryStringParameters: {
|
|
1964
|
+
url: repoUrl,
|
|
1965
|
+
branch: repoBranch
|
|
1966
|
+
}
|
|
1967
|
+
}, null, (err, data) => {
|
|
1933
1968
|
const context = JSON.parse(data.body);
|
|
1934
1969
|
console.log(context.result);
|
|
1935
1970
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.1.3",
|
|
3
3
|
"name": "@iobroker/repochecker",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"axios": "^0.27.2",
|
|
6
6
|
"compare-versions": "^4.1.3",
|
|
7
|
-
"image-size": "^1.0.
|
|
8
|
-
"unzipper": "^0.10.11"
|
|
7
|
+
"image-size": "^1.0.2",
|
|
8
|
+
"unzipper": "^0.10.11",
|
|
9
|
+
"json5": "^2.2.1"
|
|
9
10
|
},
|
|
10
11
|
"publishConfig": {
|
|
11
12
|
"access": "public"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
15
|
"@alcalzone/release-script": "^3.5.9",
|
|
15
|
-
"eslint": "^8.
|
|
16
|
+
"eslint": "^8.22.0"
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
18
19
|
"index.js"
|