@iobroker/repochecker 2.0.5 → 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 +3 -0
- package/index.js +228 -226
- package/package.json +3 -2
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
/*
|
|
3
|
+
/*
|
|
4
4
|
|
|
5
5
|
___ _ _ _____ _ _
|
|
6
6
|
/ _ \ | | | | / __ \ | | |
|
|
@@ -18,13 +18,12 @@ const stream = require('stream');
|
|
|
18
18
|
const Writable = stream.Writable;
|
|
19
19
|
const sizeOf = require('image-size');
|
|
20
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
|
-
let https;
|
|
27
|
-
|
|
28
27
|
const memStore = { };
|
|
29
28
|
|
|
30
29
|
/* Writable memory stream */
|
|
@@ -110,155 +109,160 @@ function checkPackageJson(context) {
|
|
|
110
109
|
.catch(e => reject(e));
|
|
111
110
|
}
|
|
112
111
|
}).then(packageJson => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return resolve(context);
|
|
121
|
-
}
|
|
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;
|
|
122
119
|
}
|
|
120
|
+
}
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
+
}
|
|
129
127
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
+
}
|
|
135
133
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
}
|
|
144
142
|
|
|
145
|
-
|
|
143
|
+
context.adapterName = adapterName;
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
+
}
|
|
152
150
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
+
}
|
|
158
156
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
+
}
|
|
165
163
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
+
}
|
|
171
169
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
+
}
|
|
177
175
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
+
}
|
|
183
181
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
189
187
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
+
}
|
|
195
193
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
+
}
|
|
201
199
|
|
|
202
|
-
|
|
203
|
-
|
|
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/');
|
|
204
208
|
} else {
|
|
205
|
-
context.checks.push('"license"
|
|
209
|
+
context.checks.push('"license" is valid in package.json');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
206
212
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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');
|
|
210
231
|
} else {
|
|
211
|
-
context.checks.push('
|
|
232
|
+
context.checks.push('Repository type is valid: git');
|
|
212
233
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (!context.packageJson.repository) {
|
|
216
|
-
context.errors.push('[E017] No repository found in the package.json');
|
|
217
|
-
} else {
|
|
218
|
-
context.checks.push('Repository found in package.json');
|
|
219
|
-
|
|
220
|
-
const allowedRepoUrls = [
|
|
221
|
-
context.githubApiData.html_url, // https://github.com/klein0r/ioBroker.luftdaten
|
|
222
|
-
`git+${context.githubApiData.html_url}`, // git+https://github.com/klein0r/ioBroker.luftdaten
|
|
223
|
-
context.githubApiData.git_url, // git://github.com/klein0r/ioBroker.luftdaten.git
|
|
224
|
-
context.githubApiData.ssh_url, // git@github.com:klein0r/ioBroker.luftdaten.git
|
|
225
|
-
context.githubApiData.clone_url, // https://github.com/klein0r/ioBroker.luftdaten.git
|
|
226
|
-
`git+${context.githubApiData.clone_url}` // git+https://github.com/klein0r/ioBroker.luftdaten.git
|
|
227
|
-
];
|
|
228
|
-
|
|
229
|
-
// https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
|
|
230
|
-
if (context.packageJson.repository && typeof context.packageJson.repository === 'object') {
|
|
231
|
-
if (context.packageJson.repository.type !== 'git') {
|
|
232
|
-
context.errors.push('[E018] Invalid repository type: ' + context.packageJson.repository.type + '. It should be git');
|
|
233
|
-
} else {
|
|
234
|
-
context.checks.push('Repository type is valid: git');
|
|
235
|
-
}
|
|
236
234
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
} else {
|
|
240
|
-
context.checks.push('Repository URL is valid in package.json');
|
|
241
|
-
}
|
|
242
|
-
} else if (context.packageJson.repository && typeof context.packageJson.repository === 'string') {
|
|
243
|
-
if (!allowedRepoUrls.includes(context.packageJson.repository)) {
|
|
244
|
-
context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
245
|
-
} else {
|
|
246
|
-
context.checks.push('Repository URL is valid in package.json');
|
|
247
|
-
}
|
|
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}`);
|
|
248
237
|
} else {
|
|
249
|
-
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');
|
|
250
245
|
}
|
|
251
|
-
}
|
|
252
|
-
if (reservedAdapterNames.includes(adapterName)) {
|
|
253
|
-
context.errors.push('[E022] Adapter name is reserved!');
|
|
254
246
|
} else {
|
|
255
|
-
context.
|
|
247
|
+
context.errors.push('[E019] Invalid repository URL');
|
|
256
248
|
}
|
|
249
|
+
}
|
|
250
|
+
|
|
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
|
-
|
|
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
|
+
}
|
|
259
262
|
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
// max number is E023
|
|
264
|
+
|
|
265
|
+
return context;
|
|
262
266
|
});
|
|
263
267
|
}
|
|
264
268
|
|
|
@@ -1407,13 +1411,14 @@ function checkCode(context) {
|
|
|
1407
1411
|
|
|
1408
1412
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
1409
1413
|
readFiles.push('admin/jsonConfig.json');
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1414
|
+
readFiles.push('admin/jsonConfig.json5');
|
|
1415
|
+
allowedLanguages.forEach(lang =>
|
|
1416
|
+
readFiles.push(`admin/i18n/${lang}/translations.json`));
|
|
1413
1417
|
}
|
|
1414
1418
|
|
|
1415
1419
|
if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
|
|
1416
1420
|
readFiles.push('admin/jsonCustom.json');
|
|
1421
|
+
readFiles.push('admin/jsonCustom.json5');
|
|
1417
1422
|
}
|
|
1418
1423
|
}
|
|
1419
1424
|
|
|
@@ -1446,7 +1451,7 @@ function checkCode(context) {
|
|
|
1446
1451
|
}
|
|
1447
1452
|
// Get list of all files and .npmignore + .gitignore
|
|
1448
1453
|
|
|
1449
|
-
const name = entry.path.replace(/^[
|
|
1454
|
+
const name = entry.path.replace(/^[^/]+\//, '');
|
|
1450
1455
|
context.filesList.push(name);
|
|
1451
1456
|
|
|
1452
1457
|
if (readFiles.includes(name)) {
|
|
@@ -1501,14 +1506,14 @@ function checkCode(context) {
|
|
|
1501
1506
|
}
|
|
1502
1507
|
|
|
1503
1508
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
1504
|
-
if (context['/admin/jsonConfig.json']) {
|
|
1509
|
+
if (context['/admin/jsonConfig.json'] || context['/admin/jsonConfig.json5']) {
|
|
1505
1510
|
try {
|
|
1506
|
-
JSON.parse(context['/admin/jsonConfig.json']);
|
|
1511
|
+
context['/admin/jsonConfig.json'] ? JSON.parse(context['/admin/jsonConfig.json']) : JSON5.parse(context['/admin/jsonConfig.json5']);
|
|
1507
1512
|
} catch (e) {
|
|
1508
|
-
context.errors.push(
|
|
1513
|
+
context.errors.push(`[E507] Cannot parse "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`);
|
|
1509
1514
|
}
|
|
1510
1515
|
} else {
|
|
1511
|
-
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`);
|
|
1512
1517
|
}
|
|
1513
1518
|
|
|
1514
1519
|
allowedLanguages.forEach(lang => {
|
|
@@ -1525,14 +1530,14 @@ function checkCode(context) {
|
|
|
1525
1530
|
}
|
|
1526
1531
|
|
|
1527
1532
|
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']) {
|
|
1533
|
+
if (context['/admin/jsonCustom.json'] || context['/admin/jsonCustom.json5']) {
|
|
1529
1534
|
try {
|
|
1530
|
-
JSON.parse(context['/admin/jsonCustom.json']);
|
|
1535
|
+
context['/admin/jsonCustom.json'] ? JSON.parse(context['/admin/jsonCustom.json']) : JSON5.parse(context['/admin/jsonCustom.json5']);
|
|
1531
1536
|
} catch (e) {
|
|
1532
|
-
context.errors.push(
|
|
1537
|
+
context.errors.push(`[E511] Cannot parse "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`);
|
|
1533
1538
|
}
|
|
1534
1539
|
} else {
|
|
1535
|
-
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`);
|
|
1536
1541
|
}
|
|
1537
1542
|
}
|
|
1538
1543
|
|
|
@@ -1745,58 +1750,56 @@ function checkNpmIgnore(context) {
|
|
|
1745
1750
|
];
|
|
1746
1751
|
|
|
1747
1752
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
}
|
|
1753
|
+
console.log('checkNpmIgnore [E8xx]');
|
|
1754
|
+
if (context.packageJson.files && context.packageJson.files.length) {
|
|
1755
|
+
return Promise.resolve(context);
|
|
1756
|
+
}
|
|
1753
1757
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
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
|
+
});
|
|
1772
1776
|
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
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
|
+
}
|
|
1781
1785
|
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
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
|
+
});
|
|
1792
1796
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
}
|
|
1797
|
+
!check && context.errors.push(`[E8${paddingNum(i + 11)}] file ${file} found in repository, but not found in .npmignore`);
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1797
1800
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1801
|
+
}
|
|
1802
|
+
return Promise.resolve(context);
|
|
1800
1803
|
}
|
|
1801
1804
|
|
|
1802
1805
|
// E9xx
|
|
@@ -1809,50 +1812,49 @@ function checkGitIgnore(context) {
|
|
|
1809
1812
|
];
|
|
1810
1813
|
|
|
1811
1814
|
// 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`);
|
|
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
|
+
);
|
|
1834
1828
|
}
|
|
1829
|
+
});
|
|
1835
1830
|
|
|
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
|
-
});
|
|
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`);
|
|
1850
1833
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
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);
|
|
1853
1855
|
}
|
|
1854
1856
|
|
|
1855
|
-
function makeResponse(code, data
|
|
1857
|
+
function makeResponse(code, data) {
|
|
1856
1858
|
return {
|
|
1857
1859
|
statusCode: code || 200,
|
|
1858
1860
|
headers: {
|
|
@@ -1870,7 +1872,7 @@ function check(request, ctx, callback) {
|
|
|
1870
1872
|
} else {
|
|
1871
1873
|
const context = {checks: [], errors: [], warnings: []};
|
|
1872
1874
|
let githubUrl = request.queryStringParameters.url;
|
|
1873
|
-
|
|
1875
|
+
const githubBranch = request.queryStringParameters.branch;
|
|
1874
1876
|
|
|
1875
1877
|
githubUrl = githubUrl
|
|
1876
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"
|