@iobroker/repochecker 2.0.3 → 2.1.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 +4 -1
- package/index.js +230 -226
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -20,7 +20,10 @@ Branch (`master/main/dev`) is optional.
|
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
22
|
## Changelog
|
|
23
|
-
### 2.0
|
|
23
|
+
### 2.1.0 (2022-05-26)
|
|
24
|
+
* (bluefox) Added support of jsonConfig.json5 and jsonCustom.json5
|
|
25
|
+
|
|
26
|
+
### 2.0.5 (2022-05-22)
|
|
24
27
|
* (bluefox) Made it possible to run with npx
|
|
25
28
|
|
|
26
29
|
## License
|
package/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/*
|
|
2
4
|
|
|
3
5
|
___ _ _ _____ _ _
|
|
4
6
|
/ _ \ | | | | / __ \ | | |
|
|
@@ -16,13 +18,12 @@ const stream = require('stream');
|
|
|
16
18
|
const Writable = stream.Writable;
|
|
17
19
|
const sizeOf = require('image-size');
|
|
18
20
|
const axios = require('axios');
|
|
21
|
+
const JSON5 = require('json5');
|
|
19
22
|
const compareVersions = require('compare-versions');
|
|
20
23
|
|
|
21
|
-
const version = '
|
|
24
|
+
const version = require('./package.json').version;
|
|
22
25
|
const recommendedJsControllerVersion = '3.3.22';
|
|
23
26
|
|
|
24
|
-
let https;
|
|
25
|
-
|
|
26
27
|
const memStore = { };
|
|
27
28
|
|
|
28
29
|
/* Writable memory stream */
|
|
@@ -108,155 +109,160 @@ function checkPackageJson(context) {
|
|
|
108
109
|
.catch(e => reject(e));
|
|
109
110
|
}
|
|
110
111
|
}).then(packageJson => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return resolve(context);
|
|
119
|
-
}
|
|
112
|
+
context.packageJson = packageJson;
|
|
113
|
+
if (typeof context.packageJson === 'string') {
|
|
114
|
+
try {
|
|
115
|
+
context.packageJson = JSON.parse(context.packageJson);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
context.errors.push('[E001] Cannot parse packet.json: ' + e);
|
|
118
|
+
return context;
|
|
120
119
|
}
|
|
120
|
+
}
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
if (!context.githubUrlOriginal.match(/\/iobroker\./i)) {
|
|
123
|
+
context.errors.push('[E002] No "ioBroker." found in the name of repository');
|
|
124
|
+
} else {
|
|
125
|
+
context.checks.push('"ioBroker" was found in the name of repository');
|
|
126
|
+
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
if (context.githubUrlOriginal.includes('/iobroker.')) {
|
|
129
|
+
context.errors.push('[E003] Repository must have name ioBroker.adaptername, but now io"b"roker is in lowercase');
|
|
130
|
+
} else {
|
|
131
|
+
context.checks.push('Repository has name ioBroker.adaptername (not iobroker.adaptername)');
|
|
132
|
+
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
const m = context.githubUrlOriginal.match(/\/ioBroker\.(.*)$/);
|
|
135
|
+
let adapterName = '';
|
|
136
|
+
if (!m || !m[1]) {
|
|
137
|
+
context.errors.push('[E004] No adapter name found in URL: ' + context.githubUrlOriginal);
|
|
138
|
+
} else {
|
|
139
|
+
context.checks.push('Adapter name found in the URL');
|
|
140
|
+
adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
|
|
141
|
+
}
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
context.adapterName = adapterName;
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
if (adapterName.match(/[A-Z]/)) {
|
|
146
|
+
context.errors.push('[E005] Adapter name must be lowercase');
|
|
147
|
+
} else {
|
|
148
|
+
context.checks.push('Adapter name is lowercase');
|
|
149
|
+
}
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
if (adapterName.match(/[^-_a-z\d]/)) {
|
|
152
|
+
context.errors.push(`[E006] Invalid characters found in adapter name "${adapterName}". Only lowercase chars, digits, "-" and "_" are allowed`);
|
|
153
|
+
} else {
|
|
154
|
+
context.checks.push(`No invalid characters found in "${adapterName}"`);
|
|
155
|
+
}
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
const n = context.githubUrlOriginal.match(/\/([^/]+)\/iobroker\./i);
|
|
158
|
+
if (!n || !n[1]) {
|
|
159
|
+
context.errors.push('[E007] Cannot find author repo in the URL');
|
|
160
|
+
} else {
|
|
161
|
+
context.authorName = n[1];
|
|
162
|
+
}
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
if (context.packageJson.name !== 'iobroker.' + adapterName.toLowerCase()) {
|
|
165
|
+
context.errors.push(`[E020] Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}". Now is "${packageJson.name}"`);
|
|
166
|
+
} else {
|
|
167
|
+
context.checks.push(`Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}".`);
|
|
168
|
+
}
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
if (!context.packageJson.version) {
|
|
171
|
+
context.errors.push('[E009] No version found in the package.json');
|
|
172
|
+
} else {
|
|
173
|
+
context.checks.push('Version found in package.json');
|
|
174
|
+
}
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
if (!context.packageJson.description) {
|
|
177
|
+
context.errors.push('[E010] No description found in the package.json');
|
|
178
|
+
} else {
|
|
179
|
+
context.checks.push('Description found in package.json');
|
|
180
|
+
}
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
if (context.packageJson.licenses) {
|
|
183
|
+
context.errors.push('[E021] "licenses" in package.json are deprecated. Please use only "license": "NAME" field.');
|
|
184
|
+
} else {
|
|
185
|
+
context.checks.push('No "licenses" found in package.json');
|
|
186
|
+
}
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
if (!context.packageJson.author) {
|
|
189
|
+
context.errors.push('[E013] No author found in the package.json');
|
|
190
|
+
} else {
|
|
191
|
+
context.checks.push('Author found in package.json');
|
|
192
|
+
}
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
if (context.packageJson._args) {
|
|
195
|
+
context.errors.push('[E014] NPM information found in package.json. Please remove all attributes starting with "_"');
|
|
196
|
+
} else {
|
|
197
|
+
context.checks.push('No npm generated attributes found in package.json');
|
|
198
|
+
}
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
if (!context.packageJson.license) {
|
|
201
|
+
context.errors.push('[E015] No license found in package.json');
|
|
202
|
+
} else {
|
|
203
|
+
context.checks.push('"license" found in package.json');
|
|
204
|
+
|
|
205
|
+
// check if license valid
|
|
206
|
+
if (!licenses.includes(context.packageJson.license)) {
|
|
207
|
+
context.errors.push('[E016] No SPDX license found in package.json. Please use one of listed here: https://spdx.org/licenses/');
|
|
202
208
|
} else {
|
|
203
|
-
context.checks.push('"license"
|
|
209
|
+
context.checks.push('"license" is valid in package.json');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
204
212
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
213
|
+
if (!context.packageJson.repository) {
|
|
214
|
+
context.errors.push('[E017] No repository found in the package.json');
|
|
215
|
+
} else {
|
|
216
|
+
context.checks.push('Repository found in package.json');
|
|
217
|
+
|
|
218
|
+
const allowedRepoUrls = [
|
|
219
|
+
context.githubApiData.html_url, // https://github.com/klein0r/ioBroker.luftdaten
|
|
220
|
+
`git+${context.githubApiData.html_url}`, // git+https://github.com/klein0r/ioBroker.luftdaten
|
|
221
|
+
context.githubApiData.git_url, // git://github.com/klein0r/ioBroker.luftdaten.git
|
|
222
|
+
context.githubApiData.ssh_url, // git@github.com:klein0r/ioBroker.luftdaten.git
|
|
223
|
+
context.githubApiData.clone_url, // https://github.com/klein0r/ioBroker.luftdaten.git
|
|
224
|
+
`git+${context.githubApiData.clone_url}` // git+https://github.com/klein0r/ioBroker.luftdaten.git
|
|
225
|
+
];
|
|
226
|
+
|
|
227
|
+
// https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
|
|
228
|
+
if (context.packageJson.repository && typeof context.packageJson.repository === 'object') {
|
|
229
|
+
if (context.packageJson.repository.type !== 'git') {
|
|
230
|
+
context.errors.push('[E018] Invalid repository type: ' + context.packageJson.repository.type + '. It should be git');
|
|
208
231
|
} else {
|
|
209
|
-
context.checks.push('
|
|
232
|
+
context.checks.push('Repository type is valid: git');
|
|
210
233
|
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (!context.packageJson.repository) {
|
|
214
|
-
context.errors.push('[E017] No repository found in the package.json');
|
|
215
|
-
} else {
|
|
216
|
-
context.checks.push('Repository found in package.json');
|
|
217
|
-
|
|
218
|
-
const allowedRepoUrls = [
|
|
219
|
-
context.githubApiData.html_url, // https://github.com/klein0r/ioBroker.luftdaten
|
|
220
|
-
`git+${context.githubApiData.html_url}`, // git+https://github.com/klein0r/ioBroker.luftdaten
|
|
221
|
-
context.githubApiData.git_url, // git://github.com/klein0r/ioBroker.luftdaten.git
|
|
222
|
-
context.githubApiData.ssh_url, // git@github.com:klein0r/ioBroker.luftdaten.git
|
|
223
|
-
context.githubApiData.clone_url, // https://github.com/klein0r/ioBroker.luftdaten.git
|
|
224
|
-
`git+${context.githubApiData.clone_url}` // git+https://github.com/klein0r/ioBroker.luftdaten.git
|
|
225
|
-
];
|
|
226
|
-
|
|
227
|
-
// https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
|
|
228
|
-
if (context.packageJson.repository && typeof context.packageJson.repository === 'object') {
|
|
229
|
-
if (context.packageJson.repository.type !== 'git') {
|
|
230
|
-
context.errors.push('[E018] Invalid repository type: ' + context.packageJson.repository.type + '. It should be git');
|
|
231
|
-
} else {
|
|
232
|
-
context.checks.push('Repository type is valid: git');
|
|
233
|
-
}
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
} else {
|
|
238
|
-
context.checks.push('Repository URL is valid in package.json');
|
|
239
|
-
}
|
|
240
|
-
} else if (context.packageJson.repository && typeof context.packageJson.repository === 'string') {
|
|
241
|
-
if (!allowedRepoUrls.includes(context.packageJson.repository)) {
|
|
242
|
-
context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
243
|
-
} else {
|
|
244
|
-
context.checks.push('Repository URL is valid in package.json');
|
|
245
|
-
}
|
|
235
|
+
if (!allowedRepoUrls.includes(context.packageJson.repository.url)) {
|
|
236
|
+
context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
246
237
|
} else {
|
|
247
|
-
context.
|
|
238
|
+
context.checks.push('Repository URL is valid in package.json');
|
|
239
|
+
}
|
|
240
|
+
} else if (context.packageJson.repository && typeof context.packageJson.repository === 'string') {
|
|
241
|
+
if (!allowedRepoUrls.includes(context.packageJson.repository)) {
|
|
242
|
+
context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
243
|
+
} else {
|
|
244
|
+
context.checks.push('Repository URL is valid in package.json');
|
|
248
245
|
}
|
|
249
|
-
}
|
|
250
|
-
if (reservedAdapterNames.includes(adapterName)) {
|
|
251
|
-
context.errors.push('[E022] Adapter name is reserved!');
|
|
252
246
|
} else {
|
|
253
|
-
context.
|
|
247
|
+
context.errors.push('[E019] Invalid repository URL');
|
|
254
248
|
}
|
|
249
|
+
}
|
|
255
250
|
|
|
256
|
-
|
|
251
|
+
if (reservedAdapterNames.includes(adapterName)) {
|
|
252
|
+
context.errors.push('[E022] Adapter name is reserved!');
|
|
253
|
+
} else {
|
|
254
|
+
context.checks.push('Adapter name is not reserved');
|
|
255
|
+
}
|
|
257
256
|
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
if ((context.packageJson.dependencies && context.packageJson.dependencies.npm) || (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies.npm)) {
|
|
258
|
+
context.errors.push('[E023] Do not include "npm" as dependency!');
|
|
259
|
+
} else {
|
|
260
|
+
context.checks.push('npm is not in dependencies');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// max number is E023
|
|
264
|
+
|
|
265
|
+
return context;
|
|
260
266
|
});
|
|
261
267
|
}
|
|
262
268
|
|
|
@@ -1405,13 +1411,14 @@ function checkCode(context) {
|
|
|
1405
1411
|
|
|
1406
1412
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
1407
1413
|
readFiles.push('admin/jsonConfig.json');
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1414
|
+
readFiles.push('admin/jsonConfig.json5');
|
|
1415
|
+
allowedLanguages.forEach(lang =>
|
|
1416
|
+
readFiles.push(`admin/i18n/${lang}/translations.json`));
|
|
1411
1417
|
}
|
|
1412
1418
|
|
|
1413
1419
|
if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
|
|
1414
1420
|
readFiles.push('admin/jsonCustom.json');
|
|
1421
|
+
readFiles.push('admin/jsonCustom.json5');
|
|
1415
1422
|
}
|
|
1416
1423
|
}
|
|
1417
1424
|
|
|
@@ -1444,7 +1451,7 @@ function checkCode(context) {
|
|
|
1444
1451
|
}
|
|
1445
1452
|
// Get list of all files and .npmignore + .gitignore
|
|
1446
1453
|
|
|
1447
|
-
const name = entry.path.replace(/^[
|
|
1454
|
+
const name = entry.path.replace(/^[^/]+\//, '');
|
|
1448
1455
|
context.filesList.push(name);
|
|
1449
1456
|
|
|
1450
1457
|
if (readFiles.includes(name)) {
|
|
@@ -1499,14 +1506,14 @@ function checkCode(context) {
|
|
|
1499
1506
|
}
|
|
1500
1507
|
|
|
1501
1508
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
1502
|
-
if (context['/admin/jsonConfig.json']) {
|
|
1509
|
+
if (context['/admin/jsonConfig.json'] || context['/admin/jsonConfig.json5']) {
|
|
1503
1510
|
try {
|
|
1504
|
-
JSON.parse(context['/admin/jsonConfig.json']);
|
|
1511
|
+
context['/admin/jsonConfig.json'] ? JSON.parse(context['/admin/jsonConfig.json']) : JSON5.parse(context['/admin/jsonConfig.json5']);
|
|
1505
1512
|
} catch (e) {
|
|
1506
|
-
context.errors.push(
|
|
1513
|
+
context.errors.push(`[E507] Cannot parse "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`);
|
|
1507
1514
|
}
|
|
1508
1515
|
} else {
|
|
1509
|
-
context.errors.push(`[E508] "admin/jsonConfig.json" not found, but admin support is declared`);
|
|
1516
|
+
context.errors.push(`[E508] "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}" not found, but admin support is declared`);
|
|
1510
1517
|
}
|
|
1511
1518
|
|
|
1512
1519
|
allowedLanguages.forEach(lang => {
|
|
@@ -1523,14 +1530,14 @@ function checkCode(context) {
|
|
|
1523
1530
|
}
|
|
1524
1531
|
|
|
1525
1532
|
if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
|
|
1526
|
-
if (context['/admin/jsonCustom.json']) {
|
|
1533
|
+
if (context['/admin/jsonCustom.json'] || context['/admin/jsonCustom.json5']) {
|
|
1527
1534
|
try {
|
|
1528
|
-
JSON.parse(context['/admin/jsonCustom.json']);
|
|
1535
|
+
context['/admin/jsonCustom.json'] ? JSON.parse(context['/admin/jsonCustom.json']) : JSON5.parse(context['/admin/jsonCustom.json5']);
|
|
1529
1536
|
} catch (e) {
|
|
1530
|
-
context.errors.push(
|
|
1537
|
+
context.errors.push(`[E511] Cannot parse "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`);
|
|
1531
1538
|
}
|
|
1532
1539
|
} else {
|
|
1533
|
-
context.errors.push(`[E512] "admin/jsonCustom.json" not found, but custom support is declared`);
|
|
1540
|
+
context.errors.push(`[E512] "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`);
|
|
1534
1541
|
}
|
|
1535
1542
|
}
|
|
1536
1543
|
|
|
@@ -1743,58 +1750,56 @@ function checkNpmIgnore(context) {
|
|
|
1743
1750
|
];
|
|
1744
1751
|
|
|
1745
1752
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
}
|
|
1753
|
+
console.log('checkNpmIgnore [E8xx]');
|
|
1754
|
+
if (context.packageJson.files && context.packageJson.files.length) {
|
|
1755
|
+
return Promise.resolve(context);
|
|
1756
|
+
}
|
|
1751
1757
|
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1758
|
+
if (!context.filesList.includes('.npmignore')) {
|
|
1759
|
+
context.warnings.push(`[W801] .npmignore not found`);
|
|
1760
|
+
} else {
|
|
1761
|
+
const rules = (context['/.npmignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
|
|
1762
|
+
let tooComplexToCheck = false;
|
|
1763
|
+
rules.forEach((name, i) => {
|
|
1764
|
+
if (name.includes('*')) {
|
|
1765
|
+
rules[i] = new RegExp(name
|
|
1766
|
+
.replace('.', '\\.')
|
|
1767
|
+
.replace('/', '\\/')
|
|
1768
|
+
.replace('**', '.*')
|
|
1769
|
+
.replace('*', '[^\\/]*')
|
|
1770
|
+
);
|
|
1771
|
+
}
|
|
1772
|
+
if (name.startsWith('!')) {
|
|
1773
|
+
tooComplexToCheck = true;
|
|
1774
|
+
}
|
|
1775
|
+
});
|
|
1770
1776
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1777
|
+
// 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.
|
|
1778
|
+
/*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
1779
|
+
!check && context.errors.push(`[E804] node_modules not found in .npmignore`);
|
|
1780
|
+
}*/
|
|
1781
|
+
if (!tooComplexToCheck) {
|
|
1782
|
+
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
1783
|
+
!check && context.errors.push(`[E803] iob_npm.done not found in .npmignore`);
|
|
1784
|
+
}
|
|
1779
1785
|
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1786
|
+
checkFiles.forEach((file, i) => {
|
|
1787
|
+
if (context.filesList.includes(file)) {
|
|
1788
|
+
// maybe it is with regex
|
|
1789
|
+
const check = rules.some(rule => {
|
|
1790
|
+
if (typeof rule === 'string') {
|
|
1791
|
+
return rule === file || rule === file.replace(/\/$/, '');
|
|
1792
|
+
} else {
|
|
1793
|
+
return rule.test(file);
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1790
1796
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
}
|
|
1797
|
+
!check && context.errors.push(`[E8${paddingNum(i + 11)}] file ${file} found in repository, but not found in .npmignore`);
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1795
1800
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1801
|
+
}
|
|
1802
|
+
return Promise.resolve(context);
|
|
1798
1803
|
}
|
|
1799
1804
|
|
|
1800
1805
|
// E9xx
|
|
@@ -1807,50 +1812,49 @@ function checkGitIgnore(context) {
|
|
|
1807
1812
|
];
|
|
1808
1813
|
|
|
1809
1814
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.gitignore
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
);
|
|
1824
|
-
}
|
|
1825
|
-
});
|
|
1826
|
-
|
|
1827
|
-
if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
1828
|
-
!check && context.errors.push(`[E902] node_modules not found in .npmignore`);
|
|
1829
|
-
}
|
|
1830
|
-
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
1831
|
-
!check && context.errors.push(`[E903] iob_npm.done not found in .gitignore`);
|
|
1815
|
+
console.log('checkGitIgnore [E9xx]');
|
|
1816
|
+
if (!context.filesList.includes('.gitignore')) {
|
|
1817
|
+
context.warnings.push(`[W901] .gitignore not found`);
|
|
1818
|
+
} else {
|
|
1819
|
+
const rules = (context['/.gitignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
|
|
1820
|
+
rules.forEach((name, i) => {
|
|
1821
|
+
if (name.includes('*')) {
|
|
1822
|
+
rules[i] = new RegExp(name
|
|
1823
|
+
.replace('.', '\\.')
|
|
1824
|
+
.replace('/', '\\/')
|
|
1825
|
+
.replace('**', '.*')
|
|
1826
|
+
.replace('*', '[^\\/]*')
|
|
1827
|
+
);
|
|
1832
1828
|
}
|
|
1829
|
+
});
|
|
1833
1830
|
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
// may be it is with regex
|
|
1837
|
-
const check = rules.some(rule => {
|
|
1838
|
-
if (typeof rule === 'string') {
|
|
1839
|
-
return rule === file || rule === file.replace(/\/$/, '');
|
|
1840
|
-
} else {
|
|
1841
|
-
return rule.test(file);
|
|
1842
|
-
}
|
|
1843
|
-
});
|
|
1844
|
-
|
|
1845
|
-
!check && context.errors.push(`[E9${paddingNum(i + 11)}] file ${file} found in repository, but not found in .gitignore`);
|
|
1846
|
-
}
|
|
1847
|
-
});
|
|
1831
|
+
if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
1832
|
+
!check && context.errors.push(`[E902] node_modules not found in .npmignore`);
|
|
1848
1833
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1834
|
+
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
1835
|
+
!check && context.errors.push(`[E903] iob_npm.done not found in .gitignore`);
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
checkFiles.forEach((file, i) => {
|
|
1839
|
+
if (context.filesList.includes(file)) {
|
|
1840
|
+
// maybe it is with regex
|
|
1841
|
+
const check = rules.some(rule => {
|
|
1842
|
+
if (typeof rule === 'string') {
|
|
1843
|
+
return rule === file || rule === file.replace(/\/$/, '');
|
|
1844
|
+
} else {
|
|
1845
|
+
return rule.test(file);
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1848
|
+
|
|
1849
|
+
!check && context.errors.push(`[E9${paddingNum(i + 11)}] file ${file} found in repository, but not found in .gitignore`);
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
return Promise.resolve(context);
|
|
1851
1855
|
}
|
|
1852
1856
|
|
|
1853
|
-
function makeResponse(code, data
|
|
1857
|
+
function makeResponse(code, data) {
|
|
1854
1858
|
return {
|
|
1855
1859
|
statusCode: code || 200,
|
|
1856
1860
|
headers: {
|
|
@@ -1868,7 +1872,7 @@ function check(request, ctx, callback) {
|
|
|
1868
1872
|
} else {
|
|
1869
1873
|
const context = {checks: [], errors: [], warnings: []};
|
|
1870
1874
|
let githubUrl = request.queryStringParameters.url;
|
|
1871
|
-
|
|
1875
|
+
const githubBranch = request.queryStringParameters.branch;
|
|
1872
1876
|
|
|
1873
1877
|
githubUrl = githubUrl
|
|
1874
1878
|
.replace('http://', 'https://')
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0
|
|
2
|
+
"version": "2.1.0",
|
|
3
3
|
"name": "@iobroker/repochecker",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"axios": "^0.27.2",
|
|
6
6
|
"compare-versions": "^4.1.3",
|
|
7
7
|
"image-size": "^1.0.1",
|
|
8
|
-
"unzipper": "^0.10.11"
|
|
8
|
+
"unzipper": "^0.10.11",
|
|
9
|
+
"json5": "^2.2.1"
|
|
9
10
|
},
|
|
10
11
|
"publishConfig": {
|
|
11
12
|
"access": "public"
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
"index.js"
|
|
19
20
|
],
|
|
20
21
|
"main": "index.js",
|
|
21
|
-
"bin": "
|
|
22
|
+
"bin": "index.js",
|
|
22
23
|
"scripts": {
|
|
23
24
|
"start": "node index.js",
|
|
24
25
|
"lint": "eslint",
|