@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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/index.js +228 -226
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -20,6 +20,9 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
+ ### 2.1.0 (2022-05-26)
24
+ * (bluefox) Added support of jsonConfig.json5 and jsonCustom.json5
25
+
23
26
  ### 2.0.5 (2022-05-22)
24
27
  * (bluefox) Made it possible to run with npx
25
28
 
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /* 1.4.0 2022.04.26
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 = '1.4.0';
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
- return new Promise(resolve => {
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 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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- context.adapterName = adapterName;
143
+ context.adapterName = adapterName;
146
144
 
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
- }
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
- if (adapterName.match(/[^-_a-z0-9]/)) {
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
- }
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
- const n = context.githubUrlOriginal.match(/\/([^\/]+)\/iobroker\./i);
160
- if (!n || !n[1]) {
161
- context.errors.push('[E007] Cannot find author repo in the URL');
162
- } else {
163
- context.authorName = n[1];
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
- if (context.packageJson.name !== 'iobroker.' + adapterName.toLowerCase()) {
167
- context.errors.push('[E020] Name of adapter in package.json must be lowercase and be equal to "iobroker.' + adapterName.toLowerCase() + '". Now is "' + packageJson.name + '"');
168
- } else {
169
- context.checks.push('Name of adapter in package.json must be lowercase and be equal to "iobroker.' + adapterName.toLowerCase() + '".');
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
- if (!context.packageJson.version) {
173
- context.errors.push('[E009] No version found in the package.json');
174
- } else {
175
- context.checks.push('Version found in package.json');
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
- if (!context.packageJson.description) {
179
- context.errors.push('[E010] No description found in the package.json');
180
- } else {
181
- context.checks.push('Description found in package.json');
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
- if (context.packageJson.licenses) {
185
- context.errors.push('[E021] "licenses" in package.json are deprecated. Please use only "license": "NAME" field.');
186
- } else {
187
- context.checks.push('No "licenses" found in package.json');
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
- if (!context.packageJson.author) {
191
- context.errors.push('[E013] No author found in the package.json');
192
- } else {
193
- context.checks.push('Author found in package.json');
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
- if (context.packageJson._args) {
197
- context.errors.push('[E014] NPM information found in package.json. Please remove all attributes starting with "_"');
198
- } else {
199
- context.checks.push('No npm generated attributes found in package.json');
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
- if (!context.packageJson.license) {
203
- 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/');
204
208
  } else {
205
- context.checks.push('"license" found in package.json');
209
+ context.checks.push('"license" is valid in package.json');
210
+ }
211
+ }
206
212
 
207
- // check if license valid
208
- if (!licenses.includes(context.packageJson.license)) {
209
- 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');
210
231
  } else {
211
- context.checks.push('"license" is valid in package.json');
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
- if (!allowedRepoUrls.includes(context.packageJson.repository.url)) {
238
- context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
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.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');
250
245
  }
251
- }
252
- if (reservedAdapterNames.includes(adapterName)) {
253
- context.errors.push('[E022] Adapter name is reserved!');
254
246
  } else {
255
- context.checks.push('Adapter name is not reserved');
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
- // max number is E022
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
- resolve(context);
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
- allowedLanguages.forEach(lang => {
1411
- readFiles.push(`admin/i18n/${lang}/translations.json`);
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('[E507] Cannot parse "admin/jsonConfig.json": ' + e);
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('[E511] Cannot parse "admin/jsonCustom.json": ' + e);
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
- return new Promise((resolve, reject) => {
1749
- console.log('checkNpmIgnore [E8xx]');
1750
- if (context.packageJson.files && context.packageJson.files.length) {
1751
- return resolve(context);
1752
- }
1753
+ console.log('checkNpmIgnore [E8xx]');
1754
+ if (context.packageJson.files && context.packageJson.files.length) {
1755
+ return Promise.resolve(context);
1756
+ }
1753
1757
 
1754
- if (!context.filesList.includes('.npmignore')) {
1755
- context.warnings.push(`[W801] .npmignore not found`);
1756
- } else {
1757
- const rules = (context['/.npmignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
1758
- let tooComplexToCheck = false;
1759
- rules.forEach((name, i) => {
1760
- if (name.includes('*')) {
1761
- rules[i] = new RegExp(name
1762
- .replace('.', '\\.')
1763
- .replace('/', '\\/')
1764
- .replace('**', '.*')
1765
- .replace('*', '[^\\/]*')
1766
- );
1767
- }
1768
- if (name.startsWith('!')) {
1769
- tooComplexToCheck = true;
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
- // 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.
1774
- /*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
1775
- !check && context.errors.push(`[E804] node_modules not found in .npmignore`);
1776
- }*/
1777
- if (!tooComplexToCheck) {
1778
- if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
1779
- !check && context.errors.push(`[E803] iob_npm.done not found in .npmignore`);
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
- checkFiles.forEach((file, i) => {
1783
- if (context.filesList.includes(file)) {
1784
- // may be it is with regex
1785
- const check = rules.some(rule => {
1786
- if (typeof rule === 'string') {
1787
- return rule === file || rule === file.replace(/\/$/, '');
1788
- } else {
1789
- return rule.test(file);
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
- !check && context.errors.push(`[E8${paddingNum(i + 11)}] file ${file} found in repository, but not found in .npmignore`);
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
- resolve(context);
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
- return new Promise((resolve, reject) => {
1813
- console.log('checkGitIgnore [E9xx]');
1814
- if (!context.filesList.includes('.gitignore')) {
1815
- context.warnings.push(`[W901] .gitignore not found`);
1816
- } else {
1817
- const rules = (context['/.gitignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
1818
- rules.forEach((name, i) => {
1819
- if (name.includes('*')) {
1820
- rules[i] = new RegExp(name
1821
- .replace('.', '\\.')
1822
- .replace('/', '\\/')
1823
- .replace('**', '.*')
1824
- .replace('*', '[^\\/]*')
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
- checkFiles.forEach((file, i) => {
1837
- if (context.filesList.includes(file)) {
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
- resolve(context);
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, headers) {
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
- let githubBranch = request.queryStringParameters.branch;
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.5",
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"