@iobroker/repochecker 2.1.2 → 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 +3 -0
- package/index.js +161 -144
- package/package.json +2 -2
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -13,18 +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
|
|
21
|
-
const JSON5
|
|
19
|
+
const sizeOf = require('image-size');
|
|
20
|
+
const axios = require('axios');
|
|
21
|
+
const JSON5 = require('json5');
|
|
22
22
|
const compareVersions = require('compare-versions');
|
|
23
23
|
|
|
24
|
-
const version
|
|
24
|
+
const version = require('./package.json').version;
|
|
25
25
|
const recommendedJsControllerVersion = '3.3.22';
|
|
26
26
|
|
|
27
|
-
const memStore = {
|
|
27
|
+
const memStore = {};
|
|
28
28
|
|
|
29
29
|
/* Writable memory stream */
|
|
30
30
|
function WMStrm(key, options) {
|
|
@@ -36,6 +36,7 @@ function WMStrm(key, options) {
|
|
|
36
36
|
this.key = key; // save key
|
|
37
37
|
memStore[key] = Buffer.from(''); // empty
|
|
38
38
|
}
|
|
39
|
+
|
|
39
40
|
util.inherits(WMStrm, Writable);
|
|
40
41
|
|
|
41
42
|
WMStrm.prototype._write = function (chunk, enc, cb) {
|
|
@@ -108,162 +109,169 @@ function checkPackageJson(context) {
|
|
|
108
109
|
.then(packageJson => resolve(packageJson))
|
|
109
110
|
.catch(e => reject(e));
|
|
110
111
|
}
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
})
|
|
113
|
+
.then(packageJson => {
|
|
114
|
+
context.packageJson = packageJson;
|
|
115
|
+
if (typeof context.packageJson === 'string') {
|
|
116
|
+
try {
|
|
117
|
+
context.packageJson = JSON.parse(context.packageJson);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
context.errors.push('[E001] Cannot parse packet.json: ' + e);
|
|
120
|
+
return context;
|
|
121
|
+
}
|
|
119
122
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
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
123
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
if (!context.githubUrlOriginal.match(/\/iobroker\./i)) {
|
|
125
|
+
context.errors.push('[E002] No "ioBroker." found in the name of repository');
|
|
126
|
+
} else {
|
|
127
|
+
context.checks.push('"ioBroker" was found in the name of repository');
|
|
128
|
+
}
|
|
133
129
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
context.checks.push('Adapter name found in the URL');
|
|
140
|
-
adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
|
|
141
|
-
}
|
|
130
|
+
if (context.githubUrlOriginal.includes('/iobroker.')) {
|
|
131
|
+
context.errors.push('[E003] Repository must have name ioBroker.adaptername, but now io"b"roker is in lowercase');
|
|
132
|
+
} else {
|
|
133
|
+
context.checks.push('Repository has name ioBroker.adaptername (not iobroker.adaptername)');
|
|
134
|
+
}
|
|
142
135
|
|
|
143
|
-
|
|
136
|
+
const m = context.githubUrlOriginal.match(/\/ioBroker\.(.*)$/);
|
|
137
|
+
let adapterName = '';
|
|
138
|
+
if (!m || !m[1]) {
|
|
139
|
+
context.errors.push('[E004] No adapter name found in URL: ' + context.githubUrlOriginal);
|
|
140
|
+
} else {
|
|
141
|
+
context.checks.push('Adapter name found in the URL');
|
|
142
|
+
adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
|
|
143
|
+
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
context.errors.push('[E005] Adapter name must be lowercase');
|
|
147
|
-
} else {
|
|
148
|
-
context.checks.push('Adapter name is lowercase');
|
|
149
|
-
}
|
|
145
|
+
context.adapterName = adapterName;
|
|
150
146
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
if (adapterName.match(/[A-Z]/)) {
|
|
148
|
+
context.errors.push('[E005] Adapter name must be lowercase');
|
|
149
|
+
} else {
|
|
150
|
+
context.checks.push('Adapter name is lowercase');
|
|
151
|
+
}
|
|
156
152
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
153
|
+
if (adapterName.match(/[^-_a-z\d]/)) {
|
|
154
|
+
context.errors.push(`[E006] Invalid characters found in adapter name "${adapterName}". Only lowercase chars, digits, "-" and "_" are allowed`);
|
|
155
|
+
} else {
|
|
156
|
+
context.checks.push(`No invalid characters found in "${adapterName}"`);
|
|
157
|
+
}
|
|
163
158
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
}
|
|
169
164
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
165
|
+
const n = context.githubUrlOriginal.match(/\/([^/]+)\/iobroker\./i);
|
|
166
|
+
if (!n || !n[1]) {
|
|
167
|
+
context.errors.push('[E007] Cannot find author repo in the URL');
|
|
168
|
+
} else {
|
|
169
|
+
context.authorName = n[1];
|
|
170
|
+
}
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
172
|
+
if (context.packageJson.name !== 'iobroker.' + adapterName.toLowerCase()) {
|
|
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}"`);
|
|
174
|
+
} else {
|
|
175
|
+
context.checks.push(`Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}".`);
|
|
176
|
+
}
|
|
181
177
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
if (!context.packageJson.version) {
|
|
179
|
+
context.errors.push('[E009] No version found in the package.json');
|
|
180
|
+
} else {
|
|
181
|
+
context.checks.push('Version found in package.json');
|
|
182
|
+
}
|
|
187
183
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
184
|
+
if (!context.packageJson.description) {
|
|
185
|
+
context.errors.push('[E010] No description found in the package.json');
|
|
186
|
+
} else {
|
|
187
|
+
context.checks.push('Description found in package.json');
|
|
188
|
+
}
|
|
193
189
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
190
|
+
if (context.packageJson.licenses) {
|
|
191
|
+
context.errors.push('[E021] "licenses" in package.json are deprecated. Please use only "license": "NAME" field.');
|
|
192
|
+
} else {
|
|
193
|
+
context.checks.push('No "licenses" found in package.json');
|
|
194
|
+
}
|
|
199
195
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
if (!context.packageJson.author) {
|
|
197
|
+
context.errors.push('[E013] No author found in the package.json');
|
|
198
|
+
} else {
|
|
199
|
+
context.checks.push('Author found in package.json');
|
|
200
|
+
}
|
|
204
201
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
context.errors.push('[E016] No SPDX license found in package.json. Please use one of listed here: https://spdx.org/licenses/');
|
|
202
|
+
if (context.packageJson._args) {
|
|
203
|
+
context.errors.push('[E014] NPM information found in package.json. Please remove all attributes starting with "_"');
|
|
208
204
|
} else {
|
|
209
|
-
context.checks.push('
|
|
205
|
+
context.checks.push('No npm generated attributes found in package.json');
|
|
210
206
|
}
|
|
211
|
-
}
|
|
212
207
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
}
|
|
208
|
+
if (!context.packageJson.license) {
|
|
209
|
+
context.errors.push('[E015] No license found in package.json');
|
|
210
|
+
} else {
|
|
211
|
+
context.checks.push('"license" found in package.json');
|
|
234
212
|
|
|
235
|
-
if
|
|
236
|
-
|
|
213
|
+
// check if license valid
|
|
214
|
+
if (!licenses.includes(context.packageJson.license)) {
|
|
215
|
+
context.errors.push('[E016] No SPDX license found in package.json. Please use one of listed here: https://spdx.org/licenses/');
|
|
237
216
|
} else {
|
|
238
|
-
context.checks.push('
|
|
217
|
+
context.checks.push('"license" is valid in package.json');
|
|
239
218
|
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (!context.packageJson.repository) {
|
|
222
|
+
context.errors.push('[E017] No repository found in the package.json');
|
|
223
|
+
} else {
|
|
224
|
+
context.checks.push('Repository found in package.json');
|
|
225
|
+
|
|
226
|
+
const allowedRepoUrls = [
|
|
227
|
+
context.githubApiData.html_url, // https://github.com/klein0r/ioBroker.luftdaten
|
|
228
|
+
`git+${context.githubApiData.html_url}`, // git+https://github.com/klein0r/ioBroker.luftdaten
|
|
229
|
+
context.githubApiData.git_url, // git://github.com/klein0r/ioBroker.luftdaten.git
|
|
230
|
+
context.githubApiData.ssh_url, // git@github.com:klein0r/ioBroker.luftdaten.git
|
|
231
|
+
context.githubApiData.clone_url, // https://github.com/klein0r/ioBroker.luftdaten.git
|
|
232
|
+
`git+${context.githubApiData.clone_url}` // git+https://github.com/klein0r/ioBroker.luftdaten.git
|
|
233
|
+
];
|
|
234
|
+
|
|
235
|
+
// https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
|
|
236
|
+
if (context.packageJson.repository && typeof context.packageJson.repository === 'object') {
|
|
237
|
+
if (context.packageJson.repository.type !== 'git') {
|
|
238
|
+
context.errors.push('[E018] Invalid repository type: ' + context.packageJson.repository.type + '. It should be git');
|
|
239
|
+
} else {
|
|
240
|
+
context.checks.push('Repository type is valid: git');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!allowedRepoUrls.includes(context.packageJson.repository.url)) {
|
|
244
|
+
context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
245
|
+
} else {
|
|
246
|
+
context.checks.push('Repository URL is valid in package.json');
|
|
247
|
+
}
|
|
248
|
+
} else if (context.packageJson.repository && typeof context.packageJson.repository === 'string') {
|
|
249
|
+
if (!allowedRepoUrls.includes(context.packageJson.repository)) {
|
|
250
|
+
context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
251
|
+
} else {
|
|
252
|
+
context.checks.push('Repository URL is valid in package.json');
|
|
253
|
+
}
|
|
243
254
|
} else {
|
|
244
|
-
context.
|
|
255
|
+
context.errors.push('[E019] Invalid repository URL');
|
|
245
256
|
}
|
|
246
|
-
} else {
|
|
247
|
-
context.errors.push('[E019] Invalid repository URL');
|
|
248
257
|
}
|
|
249
|
-
}
|
|
250
258
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
259
|
+
if (reservedAdapterNames.includes(adapterName)) {
|
|
260
|
+
context.errors.push('[E022] Adapter name is reserved!');
|
|
261
|
+
} else {
|
|
262
|
+
context.checks.push('Adapter name is not reserved');
|
|
263
|
+
}
|
|
256
264
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
+
}
|
|
262
270
|
|
|
263
|
-
|
|
271
|
+
// max number is E024
|
|
264
272
|
|
|
265
|
-
|
|
266
|
-
|
|
273
|
+
return context;
|
|
274
|
+
});
|
|
267
275
|
}
|
|
268
276
|
|
|
269
277
|
const allowedLanguages = [
|
|
@@ -284,7 +292,7 @@ const allowedModes = {
|
|
|
284
292
|
'daemon': 'always running process (will be restarted if process exits)',
|
|
285
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)',
|
|
286
294
|
'schedule': 'is started by schedule found in system.adapter…common.schedule - reacts on changes of .schedule by rescheduling with new state',
|
|
287
|
-
'once'
|
|
295
|
+
'once': 'his adapter will be started every time the system.adapter.. object changed. It will not be restarted after termination.',
|
|
288
296
|
'extension': ''
|
|
289
297
|
};
|
|
290
298
|
|
|
@@ -1282,7 +1290,7 @@ function checkRepo(context) {
|
|
|
1282
1290
|
context.checks.push('Icon found in latest repository');
|
|
1283
1291
|
|
|
1284
1292
|
if (!context.latestRepo[context.adapterName].icon.startsWith(url)) {
|
|
1285
|
-
context.errors.push('[E405] Icon must be in the following path: '
|
|
1293
|
+
context.errors.push('[E405] Icon must be in the following path: ' + url);
|
|
1286
1294
|
} else {
|
|
1287
1295
|
context.checks.push('Icon found in latest repository');
|
|
1288
1296
|
}
|
|
@@ -1335,7 +1343,7 @@ function checkRepo(context) {
|
|
|
1335
1343
|
context.checks.push('Icon found in stable repository');
|
|
1336
1344
|
|
|
1337
1345
|
if (!context.stableRepo[context.adapterName].icon.startsWith(url)) {
|
|
1338
|
-
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);
|
|
1339
1347
|
} else {
|
|
1340
1348
|
context.checks.push('Icon (stable) found in latest repository');
|
|
1341
1349
|
}
|
|
@@ -1657,7 +1665,7 @@ function checkReadme(context) {
|
|
|
1657
1665
|
} else {
|
|
1658
1666
|
context.checks.push('README.md contains Changelog');
|
|
1659
1667
|
|
|
1660
|
-
if (!data.includes(`### ${context.packageJson.version}`)
|
|
1668
|
+
if (!data.includes(`### ${context.packageJson.version}`)) {
|
|
1661
1669
|
context.errors.push(`[E606] Current adapter version ${context.packageJson.version} not found in README.md`);
|
|
1662
1670
|
} else {
|
|
1663
1671
|
context.checks.push('README.md contains current adapter version');
|
|
@@ -1909,7 +1917,14 @@ function check(request, ctx, callback) {
|
|
|
1909
1917
|
.then(context => checkNpmIgnore(context))
|
|
1910
1918
|
.then(context => checkGitIgnore(context))
|
|
1911
1919
|
.then(context => {
|
|
1912
|
-
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
|
+
}));
|
|
1913
1928
|
})
|
|
1914
1929
|
.catch(err => {
|
|
1915
1930
|
console.error('GLOBAL ERROR' + err);
|
|
@@ -1944,10 +1959,12 @@ if (typeof module !== 'undefined' && module.parent) {
|
|
|
1944
1959
|
}
|
|
1945
1960
|
|
|
1946
1961
|
console.log(`Checking repository ${repoUrl} (branch ${repoBranch})`);
|
|
1947
|
-
check({
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1962
|
+
check({
|
|
1963
|
+
queryStringParameters: {
|
|
1964
|
+
url: repoUrl,
|
|
1965
|
+
branch: repoBranch
|
|
1966
|
+
}
|
|
1967
|
+
}, null, (err, data) => {
|
|
1951
1968
|
const context = JSON.parse(data.body);
|
|
1952
1969
|
console.log(context.result);
|
|
1953
1970
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.1.
|
|
2
|
+
"version": "2.1.3",
|
|
3
3
|
"name": "@iobroker/repochecker",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"axios": "^0.27.2",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@alcalzone/release-script": "^3.5.9",
|
|
16
|
-
"eslint": "^8.
|
|
16
|
+
"eslint": "^8.22.0"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"index.js"
|