@iobroker/repochecker 2.0.4 → 2.1.2

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.
Files changed (3) hide show
  1. package/README.md +7 -1
  2. package/index.js +263 -243
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -20,7 +20,13 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
- ### 2.0.4 (2022-05-22)
23
+ ### 2.1.2 (2022-07-14)
24
+ * (bluefox) Fixed some errors
25
+
26
+ ### 2.1.0 (2022-05-26)
27
+ * (bluefox) Added support of jsonConfig.json5 and jsonCustom.json5
28
+
29
+ ### 2.0.5 (2022-05-22)
24
30
  * (bluefox) Made it possible to run with npx
25
31
 
26
32
  ## License
package/index.js CHANGED
@@ -1,4 +1,6 @@
1
- /* 1.4.0 2022.04.26
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 = '1.4.0';
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
- return new Promise(resolve => {
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 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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- context.adapterName = adapterName;
143
+ context.adapterName = adapterName;
144
144
 
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
- }
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
- if (adapterName.match(/[^-_a-z0-9]/)) {
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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- if (!context.packageJson.license) {
201
- context.errors.push('[E015] No license found in package.json');
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" found in package.json');
209
+ context.checks.push('"license" is valid in package.json');
210
+ }
211
+ }
204
212
 
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/');
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('"license" is valid in package.json');
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
- 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}`);
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.errors.push('[E019] Invalid repository URL');
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.checks.push('Adapter name is not reserved');
247
+ context.errors.push('[E019] Invalid repository URL');
254
248
  }
249
+ }
255
250
 
256
- // max number is E022
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
- resolve(context);
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
 
@@ -1178,8 +1184,10 @@ function checkNpm(context) {
1178
1184
  !body.collected ||
1179
1185
  !body.collected.metadata ||
1180
1186
  !body.collected.metadata.version ||
1181
- context.packageJson.version !== body.collected.metadata.version) {
1182
- context.warnings.push(`[W202] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${body.collected.metadata.version})`);
1187
+ context.packageJson.version !== body.collected.metadata.version
1188
+ ) {
1189
+ context.warnings.push(`[W202] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${
1190
+ (body && body.collected && body.collected.metadata && body.collected.metadata.version) || JSON.stringify(body)})`);
1183
1191
  } else {
1184
1192
  context.checks.push('Version of package.json matches latest version on NPM');
1185
1193
  }
@@ -1405,13 +1413,14 @@ function checkCode(context) {
1405
1413
 
1406
1414
  if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
1407
1415
  readFiles.push('admin/jsonConfig.json');
1408
- allowedLanguages.forEach(lang => {
1409
- readFiles.push(`admin/i18n/${lang}/translations.json`);
1410
- });
1416
+ readFiles.push('admin/jsonConfig.json5');
1417
+ allowedLanguages.forEach(lang =>
1418
+ readFiles.push(`admin/i18n/${lang}/translations.json`));
1411
1419
  }
1412
1420
 
1413
1421
  if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
1414
1422
  readFiles.push('admin/jsonCustom.json');
1423
+ readFiles.push('admin/jsonCustom.json5');
1415
1424
  }
1416
1425
  }
1417
1426
 
@@ -1444,7 +1453,7 @@ function checkCode(context) {
1444
1453
  }
1445
1454
  // Get list of all files and .npmignore + .gitignore
1446
1455
 
1447
- const name = entry.path.replace(/^[^\/]+\//, '');
1456
+ const name = entry.path.replace(/^[^/]+\//, '');
1448
1457
  context.filesList.push(name);
1449
1458
 
1450
1459
  if (readFiles.includes(name)) {
@@ -1499,38 +1508,44 @@ function checkCode(context) {
1499
1508
  }
1500
1509
 
1501
1510
  if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
1502
- if (context['/admin/jsonConfig.json']) {
1511
+ let jsonConfig;
1512
+ if (context['/admin/jsonConfig.json'] || context['/admin/jsonConfig.json5']) {
1503
1513
  try {
1504
- JSON.parse(context['/admin/jsonConfig.json']);
1514
+ jsonConfig = context['/admin/jsonConfig.json'] ? JSON.parse(context['/admin/jsonConfig.json']) : JSON5.parse(context['/admin/jsonConfig.json5']);
1505
1515
  } catch (e) {
1506
- context.errors.push('[E507] Cannot parse "admin/jsonConfig.json": ' + e);
1516
+ context.errors.push(`[E507] Cannot parse "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`);
1507
1517
  }
1508
1518
  } else {
1509
- context.errors.push(`[E508] "admin/jsonConfig.json" not found, but admin support is declared`);
1519
+ context.errors.push(`[E508] "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}" not found, but admin support is declared`);
1510
1520
  }
1511
1521
 
1512
- allowedLanguages.forEach(lang => {
1513
- if (context[`/admin/i18n/${lang}/translations.json`]) {
1514
- try {
1515
- JSON.parse(context[`/admin/i18n/${lang}/translations.json`]);
1516
- } catch (e) {
1517
- context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}/translations.json": ${e}`);
1522
+ if (jsonConfig && jsonConfig.i18n === true) {
1523
+ allowedLanguages.forEach(lang => {
1524
+ if (context[`/admin/i18n/${lang}/translations.json`]) {
1525
+ try {
1526
+ JSON.parse(context[`/admin/i18n/${lang}/translations.json`]);
1527
+ } catch (e) {
1528
+ context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}/translations.json": ${e}`);
1529
+ }
1530
+ } else {
1531
+ context.errors.push(`[E510] "/admin/i18n/${lang}/translations.json" not found, but admin support is declared`);
1518
1532
  }
1519
- } else {
1520
- context.errors.push(`[E510] "/admin/i18n/${lang}/translations.json" not found, but admin support is declared`);
1521
- }
1522
- });
1533
+ });
1534
+ }
1535
+ if (jsonConfig && jsonConfig.i18n === false) {
1536
+ context.warnings.push(`[W515] Why you decided to disable i18n support?`);
1537
+ }
1523
1538
  }
1524
1539
 
1525
1540
  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']) {
1541
+ if (context['/admin/jsonCustom.json'] || context['/admin/jsonCustom.json5']) {
1527
1542
  try {
1528
- JSON.parse(context['/admin/jsonCustom.json']);
1543
+ context['/admin/jsonCustom.json'] ? JSON.parse(context['/admin/jsonCustom.json']) : JSON5.parse(context['/admin/jsonCustom.json5']);
1529
1544
  } catch (e) {
1530
- context.errors.push('[E511] Cannot parse "admin/jsonCustom.json": ' + e);
1545
+ context.errors.push(`[E511] Cannot parse "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`);
1531
1546
  }
1532
1547
  } else {
1533
- context.errors.push(`[E512] "admin/jsonCustom.json" not found, but custom support is declared`);
1548
+ context.errors.push(`[E512] "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`);
1534
1549
  }
1535
1550
  }
1536
1551
 
@@ -1572,7 +1587,7 @@ function checkCode(context) {
1572
1587
  }
1573
1588
  }
1574
1589
  }
1575
- // max E514
1590
+ // max E515
1576
1591
  resolve(context);
1577
1592
  })
1578
1593
  .catch(e => reject(e));
@@ -1743,58 +1758,56 @@ function checkNpmIgnore(context) {
1743
1758
  ];
1744
1759
 
1745
1760
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
1746
- return new Promise((resolve, reject) => {
1747
- console.log('checkNpmIgnore [E8xx]');
1748
- if (context.packageJson.files && context.packageJson.files.length) {
1749
- return resolve(context);
1750
- }
1761
+ console.log('checkNpmIgnore [E8xx]');
1762
+ if (context.packageJson.files && context.packageJson.files.length) {
1763
+ return Promise.resolve(context);
1764
+ }
1751
1765
 
1752
- if (!context.filesList.includes('.npmignore')) {
1753
- context.warnings.push(`[W801] .npmignore not found`);
1754
- } else {
1755
- const rules = (context['/.npmignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
1756
- let tooComplexToCheck = false;
1757
- rules.forEach((name, i) => {
1758
- if (name.includes('*')) {
1759
- rules[i] = new RegExp(name
1760
- .replace('.', '\\.')
1761
- .replace('/', '\\/')
1762
- .replace('**', '.*')
1763
- .replace('*', '[^\\/]*')
1764
- );
1765
- }
1766
- if (name.startsWith('!')) {
1767
- tooComplexToCheck = true;
1768
- }
1769
- });
1766
+ if (!context.filesList.includes('.npmignore')) {
1767
+ context.warnings.push(`[W801] .npmignore not found`);
1768
+ } else {
1769
+ const rules = (context['/.npmignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
1770
+ let tooComplexToCheck = false;
1771
+ rules.forEach((name, i) => {
1772
+ if (name.includes('*')) {
1773
+ rules[i] = new RegExp(name
1774
+ .replace('.', '\\.')
1775
+ .replace('/', '\\/')
1776
+ .replace('**', '.*')
1777
+ .replace('*', '[^\\/]*')
1778
+ );
1779
+ }
1780
+ if (name.startsWith('!')) {
1781
+ tooComplexToCheck = true;
1782
+ }
1783
+ });
1770
1784
 
1771
- // 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.
1772
- /*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
1773
- !check && context.errors.push(`[E804] node_modules not found in .npmignore`);
1774
- }*/
1775
- if (!tooComplexToCheck) {
1776
- if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
1777
- !check && context.errors.push(`[E803] iob_npm.done not found in .npmignore`);
1778
- }
1785
+ // 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.
1786
+ /*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
1787
+ !check && context.errors.push(`[E804] node_modules not found in .npmignore`);
1788
+ }*/
1789
+ if (!tooComplexToCheck) {
1790
+ if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
1791
+ !check && context.errors.push(`[E803] iob_npm.done not found in .npmignore`);
1792
+ }
1779
1793
 
1780
- checkFiles.forEach((file, i) => {
1781
- if (context.filesList.includes(file)) {
1782
- // may be it is with regex
1783
- const check = rules.some(rule => {
1784
- if (typeof rule === 'string') {
1785
- return rule === file || rule === file.replace(/\/$/, '');
1786
- } else {
1787
- return rule.test(file);
1788
- }
1789
- });
1794
+ checkFiles.forEach((file, i) => {
1795
+ if (context.filesList.includes(file)) {
1796
+ // maybe it is with regex
1797
+ const check = rules.some(rule => {
1798
+ if (typeof rule === 'string') {
1799
+ return rule === file || rule === file.replace(/\/$/, '');
1800
+ } else {
1801
+ return rule.test(file);
1802
+ }
1803
+ });
1790
1804
 
1791
- !check && context.errors.push(`[E8${paddingNum(i + 11)}] file ${file} found in repository, but not found in .npmignore`);
1792
- }
1793
- });
1794
- }
1805
+ !check && context.errors.push(`[E8${paddingNum(i + 11)}] file ${file} found in repository, but not found in .npmignore`);
1806
+ }
1807
+ });
1795
1808
  }
1796
- resolve(context);
1797
- });
1809
+ }
1810
+ return Promise.resolve(context);
1798
1811
  }
1799
1812
 
1800
1813
  // E9xx
@@ -1807,50 +1820,49 @@ function checkGitIgnore(context) {
1807
1820
  ];
1808
1821
 
1809
1822
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.gitignore
1810
- return new Promise((resolve, reject) => {
1811
- console.log('checkGitIgnore [E9xx]');
1812
- if (!context.filesList.includes('.gitignore')) {
1813
- context.warnings.push(`[W901] .gitignore not found`);
1814
- } else {
1815
- const rules = (context['/.gitignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
1816
- rules.forEach((name, i) => {
1817
- if (name.includes('*')) {
1818
- rules[i] = new RegExp(name
1819
- .replace('.', '\\.')
1820
- .replace('/', '\\/')
1821
- .replace('**', '.*')
1822
- .replace('*', '[^\\/]*')
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`);
1823
+ console.log('checkGitIgnore [E9xx]');
1824
+ if (!context.filesList.includes('.gitignore')) {
1825
+ context.warnings.push(`[W901] .gitignore not found`);
1826
+ } else {
1827
+ const rules = (context['/.gitignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
1828
+ rules.forEach((name, i) => {
1829
+ if (name.includes('*')) {
1830
+ rules[i] = new RegExp(name
1831
+ .replace('.', '\\.')
1832
+ .replace('/', '\\/')
1833
+ .replace('**', '.*')
1834
+ .replace('*', '[^\\/]*')
1835
+ );
1832
1836
  }
1837
+ });
1833
1838
 
1834
- checkFiles.forEach((file, i) => {
1835
- if (context.filesList.includes(file)) {
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
- });
1839
+ if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
1840
+ !check && context.errors.push(`[E902] node_modules not found in .npmignore`);
1848
1841
  }
1849
- resolve(context);
1850
- });
1842
+ if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
1843
+ !check && context.errors.push(`[E903] iob_npm.done not found in .gitignore`);
1844
+ }
1845
+
1846
+ checkFiles.forEach((file, i) => {
1847
+ if (context.filesList.includes(file)) {
1848
+ // maybe it is with regex
1849
+ const check = rules.some(rule => {
1850
+ if (typeof rule === 'string') {
1851
+ return rule === file || rule === file.replace(/\/$/, '');
1852
+ } else {
1853
+ return rule.test(file);
1854
+ }
1855
+ });
1856
+
1857
+ !check && context.errors.push(`[E9${paddingNum(i + 11)}] file ${file} found in repository, but not found in .gitignore`);
1858
+ }
1859
+ });
1860
+ }
1861
+
1862
+ return Promise.resolve(context);
1851
1863
  }
1852
1864
 
1853
- function makeResponse(code, data, headers) {
1865
+ function makeResponse(code, data) {
1854
1866
  return {
1855
1867
  statusCode: code || 200,
1856
1868
  headers: {
@@ -1868,7 +1880,7 @@ function check(request, ctx, callback) {
1868
1880
  } else {
1869
1881
  const context = {checks: [], errors: [], warnings: []};
1870
1882
  let githubUrl = request.queryStringParameters.url;
1871
- let githubBranch = request.queryStringParameters.branch;
1883
+ const githubBranch = request.queryStringParameters.branch;
1872
1884
 
1873
1885
  githubUrl = githubUrl
1874
1886
  .replace('http://', 'https://')
@@ -1900,9 +1912,17 @@ function check(request, ctx, callback) {
1900
1912
  return callback(null, makeResponse(200, {result: 'OK', checks: context.checks, errors: context.errors, warnings: context.warnings, version, hasTravis: context.hasTravis}));
1901
1913
  })
1902
1914
  .catch(err => {
1903
- console.error(err);
1904
-
1905
- return callback(err, makeResponse(200, {result: 'Errors found', checks: context.checks, errors: context.errors, warnings: context.warnings, version, hasTravis: context.hasTravis}));
1915
+ console.error('GLOBAL ERROR' + err);
1916
+
1917
+ return callback(null, makeResponse(200, {
1918
+ result: 'Errors found',
1919
+ checks: context.checks,
1920
+ errors: context.errors,
1921
+ warnings: context.warnings,
1922
+ version,
1923
+ hasTravis: context.hasTravis,
1924
+ error: `${err.request ? err.request.path : ''} ${err.message}`,
1925
+ }));
1906
1926
  });
1907
1927
  }
1908
1928
  }
@@ -1910,7 +1930,7 @@ function check(request, ctx, callback) {
1910
1930
  if (typeof module !== 'undefined' && module.parent) {
1911
1931
  exports.handler = check;
1912
1932
  } else {
1913
- let repoUrl = 'https://github.com/ioBroker/ioBroker.admin';
1933
+ let repoUrl = 'https://github.com/Dirk-Peter-md/ioBroker.sprinklecontrol';
1914
1934
  let repoBranch = null;
1915
1935
 
1916
1936
  // Get url from parameters if possible
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
- "version": "2.0.4",
2
+ "version": "2.1.2",
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.1",
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"