@iobroker/repochecker 3.5.8 → 4.0.0-alpha.1

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 CHANGED
@@ -33,6 +33,10 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
33
33
  -->
34
34
 
35
35
  ## Changelog
36
+ ### 4.0.0-alpha.1 (2025-05-31)
37
+
38
+ - (mcm1957) use jsdelivr.com to retrive files from github.
39
+
36
40
  ### 3.5.8 (2025-05-17)
37
41
 
38
42
  - (mcm1957) add authorization for github using OWN_GITHUB_TOKEN.
package/index.js CHANGED
@@ -14,7 +14,7 @@
14
14
  */
15
15
  const axios = require('axios');
16
16
 
17
- const issues = require('./doc/issues');
17
+ //const issues = require('./doc/issues');
18
18
  const version = require('./package.json').version;
19
19
 
20
20
  // include submodules
@@ -32,11 +32,11 @@ const M800_Github = require('./lib/M800_Github.js');
32
32
  const M900_GitNpmIgnore = require('./lib/M900_GitNpmIgnore.js');
33
33
 
34
34
  // disable axios caching
35
- axios.defaults.headers = {
36
- 'Cache-Control': 'no-cache',
37
- Pragma: 'no-cache',
38
- Expires: '0',
39
- };
35
+ // axios.defaults.headers = {
36
+ // 'Cache-Control': 'no-cache',
37
+ // Pragma: 'no-cache',
38
+ // Expires: '0',
39
+ // };
40
40
 
41
41
  // Error ranges
42
42
  // E0xx
@@ -74,7 +74,7 @@ function getGithubApiData(context) {
74
74
  common.debug('getGithubApiData');
75
75
  common.debug(`reading url '${context.githubUrlApi}'`);
76
76
  axios
77
- .get(context.githubUrlApi, { cache: false })
77
+ .get(context.githubUrlApi)
78
78
  .then(response => {
79
79
  context.githubApiData = response.data;
80
80
  // console.log(`API Data: ${JSON.stringify(context.githubApiData)}`);
@@ -116,6 +116,7 @@ function check(request, ctx, callback) {
116
116
  if (!request.queryStringParameters.url) {
117
117
  return callback(null, makeResponse(500, { error: 'No github URL provided' }));
118
118
  }
119
+
119
120
  const context = {};
120
121
  context.checks = [];
121
122
  context.warnings = [];
@@ -140,12 +141,14 @@ function check(request, ctx, callback) {
140
141
  context.githubUrlOriginal = githubUrl;
141
142
  context.githubUrlApi = githubUrl.replace('https://github.com/', 'https://api.github.com/repos/');
142
143
  context.branch = githubBranch || null;
144
+ context.repository = githubUrl.replace('https://github.com/', '');
143
145
 
144
146
  getGithubApiData(context)
145
147
  .then(context => M800_Github.getCommitInfos(context))
146
148
  .then(context => M000_PackageJson.getPackageJson(context))
147
149
  .then(context => M100_IOPackageJson.getIOPackageJson(context))
148
150
  .then(context => config.updateConfig(context))
151
+ .then(context => config.logEnvironment(context))
149
152
  .then(context => M000_PackageJson.checkPackageJson(context))
150
153
  .then(context => M100_IOPackageJson.checkIOPackageJson(context))
151
154
  .then(context => M250_Npm.checkNpm(context))
@@ -191,15 +194,15 @@ function check(request, ctx, callback) {
191
194
  });
192
195
  }
193
196
 
194
- function getText(text, lang) {
195
- if (typeof text === 'object') {
196
- if (text[lang]) {
197
- return text[lang];
198
- }
199
- return text.en;
200
- }
201
- return text;
202
- }
197
+ // function getText(text, lang) {
198
+ // if (typeof text === 'object') {
199
+ // if (text[lang]) {
200
+ // return text[lang];
201
+ // }
202
+ // return text.en;
203
+ // }
204
+ // return text;
205
+ // }
203
206
 
204
207
  if (typeof module !== 'undefined' && module.parent) {
205
208
  exports.handler = check;
@@ -218,11 +221,6 @@ if (typeof module !== 'undefined' && module.parent) {
218
221
  common.setDebug(true);
219
222
  }
220
223
 
221
- if (process.argv.includes('--local')) {
222
- process.argv.splice(process.argv.indexOf('--local'), 1);
223
- common.setLocal(true);
224
- }
225
-
226
224
  if (process.argv.includes('--noinfo')) {
227
225
  process.argv.splice(process.argv.indexOf('--noinfo'), 1);
228
226
  common.setInfo(common.isDebug() ? true : false);
@@ -230,6 +228,16 @@ if (typeof module !== 'undefined' && module.parent) {
230
228
  common.setInfo(true);
231
229
  }
232
230
 
231
+ if (process.argv.includes('--success')) {
232
+ process.argv.splice(process.argv.indexOf('--success'), 1);
233
+ common.setSuccess(true);
234
+ }
235
+
236
+ if (process.argv.includes('--local')) {
237
+ process.argv.splice(process.argv.indexOf('--local'), 1);
238
+ common.setLocal(true);
239
+ }
240
+
233
241
  // Get url from parameters if possible
234
242
  if (process.argv.length > 2) {
235
243
  repoUrl = process.argv[2];
@@ -258,10 +266,15 @@ if (typeof module !== 'undefined' && module.parent) {
258
266
  null,
259
267
  (err, data) => {
260
268
  const context = JSON.parse(data.body);
269
+ if (!common.isSuccess()) {
270
+ common.info('');
271
+ common.info('Summary of successful checks skipped, use --success to enable output');
272
+ }
273
+
261
274
  console.log(`\nFINAL status '${context.result}'`);
262
275
 
263
- if (common.isInfo()) {
264
- console.log('\n\n########## SUMMARY ##########\n');
276
+ if (common.isSuccess()) {
277
+ console.log('\n\n########## SUMMARY of successfull checks ##########\n');
265
278
  if (context.checks.length) {
266
279
  context.checks.forEach(msg => {
267
280
  console.log(msg);
@@ -273,22 +286,22 @@ if (typeof module !== 'undefined' && module.parent) {
273
286
  if (context.errors.length) {
274
287
  console.log('\n\nErrors:');
275
288
  context.errors.sort().forEach(err => {
276
- const issue = err.substring(1, 5);
289
+ // const issue = err.substring(1, 5);
277
290
  console.error(err);
278
- if (issues[issue]) {
279
- //if (issues[issue].title) {
280
- // console.error(getText(issues[issue].title, 'en'));
281
- //}
282
- if (issues[issue].explanation) {
283
- console.error(getText(issues[issue].explanation, 'en'));
284
- }
285
- if (issues[issue].resolving) {
286
- console.error(getText(issues[issue].resolving, 'en'));
287
- }
288
- if (issues[issue].notes) {
289
- console.error(getText(issues[issue].notes, 'en'));
290
- }
291
- }
291
+ // if (issues[issue]) {
292
+ // //if (issues[issue].title) {
293
+ // // console.error(getText(issues[issue].title, 'en'));
294
+ // //}
295
+ // if (issues[issue].explanation) {
296
+ // console.error(getText(issues[issue].explanation, 'en'));
297
+ // }
298
+ // if (issues[issue].resolving) {
299
+ // console.error(getText(issues[issue].resolving, 'en'));
300
+ // }
301
+ // if (issues[issue].notes) {
302
+ // console.error(getText(issues[issue].notes, 'en'));
303
+ // }
304
+ // }
292
305
  });
293
306
  } else {
294
307
  console.log('\n\nNO errors encountered.');
@@ -296,22 +309,22 @@ if (typeof module !== 'undefined' && module.parent) {
296
309
  if (context.warnings.length) {
297
310
  console.log('\nWarnings:');
298
311
  context.warnings.sort().forEach(err => {
299
- const issue = err.substring(1, 5);
312
+ //const issue = err.substring(1, 5);
300
313
  console.warn(err);
301
- if (issues[issue]) {
302
- //if (issues[issue].title) {
303
- // console.warn(getText(issues[issue].title, 'en'));
304
- //}
305
- if (issues[issue].explanation) {
306
- console.warn(getText(issues[issue].explanation, 'en'));
307
- }
308
- if (issues[issue].resolving) {
309
- console.warn(getText(issues[issue].resolving, 'en'));
310
- }
311
- if (issues[issue].notes) {
312
- console.warn(getText(issues[issue].notes, 'en'));
313
- }
314
- }
314
+ // if (issues[issue]) {
315
+ // //if (issues[issue].title) {
316
+ // // console.warn(getText(issues[issue].title, 'en'));
317
+ // //}
318
+ // if (issues[issue].explanation) {
319
+ // console.warn(getText(issues[issue].explanation, 'en'));
320
+ // }
321
+ // if (issues[issue].resolving) {
322
+ // console.warn(getText(issues[issue].resolving, 'en'));
323
+ // }
324
+ // if (issues[issue].notes) {
325
+ // console.warn(getText(issues[issue].notes, 'en'));
326
+ // }
327
+ // }
315
328
  });
316
329
  } else {
317
330
  console.log('\n\nNO warnings encountered.');
@@ -218,7 +218,7 @@ const validObjectsPackageJson = [
218
218
  async function getPackageJson(context) {
219
219
  console.log('[init] getting package.json');
220
220
 
221
- const packageJson = await common.downloadFile(context.githubUrl, '/package.json');
221
+ const packageJson = await common.getFile(context, '/package.json');
222
222
  context.packageJson = packageJson;
223
223
  if (typeof context.packageJson === 'string') {
224
224
  try {
@@ -15,7 +15,7 @@ const common = require('./common.js');
15
15
  async function getIOPackageJson(context) {
16
16
  console.log('[init] getting io-package.json');
17
17
 
18
- const ioPackageJson = await common.downloadFile(context.githubUrl, '/io-package.json');
18
+ const ioPackageJson = await common.getFile(context, '/io-package.json');
19
19
  context.ioPackageJson = ioPackageJson;
20
20
  if (typeof context.ioPackageJson === 'string') {
21
21
  try {
@@ -988,9 +988,9 @@ async function checkIOPackageJson(context) {
988
988
  try {
989
989
  if (common.isLocal()) {
990
990
  const url = context.ioPackageJson.common.extIcon.replace(context.githubUrl, '');
991
- icon = await common.downloadFile(null, url, true);
991
+ icon = await common.getFile(null, url, true); // TO BE ADAPTED
992
992
  } else {
993
- icon = await common.downloadFile(context.ioPackageJson.common.extIcon, null, true);
993
+ icon = await common.downloadURL(context.ioPackageJson.common.extIcon, true);
994
994
  }
995
995
  context.checks.push('"extIcon" could be downloaded');
996
996
  //console.log(icon);
@@ -1033,7 +1033,7 @@ async function checkIOPackageJson(context) {
1033
1033
 
1034
1034
  if (!context.ioPackageJson.common.onlyWWW && context.packageJson.main) {
1035
1035
  try {
1036
- await common.downloadFile(context.githubUrl, `/${context.packageJson.main}`);
1036
+ await common.getFile(context, `/${context.packageJson.main}`);
1037
1037
  context.checks.push(`${context.packageJson.main} could be downloaded`);
1038
1038
  } catch (e) {
1039
1039
  common.debug(e);
@@ -11,11 +11,11 @@ const axios = require('axios');
11
11
  const compareVersions = require('compare-versions');
12
12
 
13
13
  // disable axios caching
14
- axios.defaults.headers = {
15
- 'Cache-Control': 'no-cache',
16
- Pragma: 'no-cache',
17
- Expires: '0',
18
- };
14
+ // axios.defaults.headers = {
15
+ // 'Cache-Control': 'no-cache',
16
+ // Pragma: 'no-cache',
17
+ // Expires: '0',
18
+ // };
19
19
 
20
20
  const common = require('./common.js');
21
21
 
package/lib/M500_Code.js CHANGED
@@ -9,44 +9,13 @@
9
9
 
10
10
  const fs = require('node:fs');
11
11
  const path = require('node:path');
12
- const util = require('node:util');
13
- const stream = require('node:stream');
14
- const unzipper = require('unzipper');
15
12
 
16
13
  const compareVersions = require('compare-versions');
17
14
  const JSON5 = require('json5');
18
15
 
19
- const Writable = stream.Writable;
20
-
21
16
  const common = require('./common.js');
22
17
  const M500__jsonConfig = require('./M500__JsonConfig.js');
23
18
 
24
- const memStore = {};
25
-
26
- /* Writable memory stream */
27
- function WMStrm(key, options) {
28
- // allow use without a new operator
29
- if (!(this instanceof WMStrm)) {
30
- return new WMStrm(key, options);
31
- }
32
- Writable.call(this, options); // init super
33
- this.key = key; // save key
34
- memStore[key] = Buffer.from(''); // empty
35
- }
36
-
37
- util.inherits(WMStrm, Writable);
38
-
39
- WMStrm.prototype._write = function (chunk, enc, cb) {
40
- // our memory store stores things in buffers
41
- const buffer = Buffer.isBuffer(chunk)
42
- ? chunk // already is Buffer use it
43
- : new Buffer(chunk, enc); // string, convert
44
-
45
- // concat to the buffer already there
46
- memStore[this.key] = Buffer.concat([memStore[this.key], buffer]);
47
- cb();
48
- };
49
-
50
19
  // utility to parse words.js
51
20
  function extractWords(words) {
52
21
  try {
@@ -101,34 +70,34 @@ async function checkCode(context) {
101
70
  console.log('\n[E500 - E599] checkCode');
102
71
 
103
72
  const readFiles = [
104
- '.npmignore',
105
- '.gitignore',
106
- 'iob_npm.done',
107
- '.travis.yml',
108
- 'gulpfile.js',
109
- '.releaseconfig.json',
73
+ '/.npmignore',
74
+ '/.gitignore',
75
+ '/iob_npm.done',
76
+ '/.travis.yml',
77
+ '/gulpfile.js',
78
+ '/.releaseconfig.json',
110
79
 
111
80
  // Add all potential files anyway. If they exist, they must be valid.
112
81
  // If they are unnecessary, a warning could be issued
113
- 'admin/index_m.html',
114
- 'admin/words.js',
115
- 'admin/jsonConfig.json',
116
- 'admin/jsonConfig.json5',
117
- 'admin/jsonCustom.json',
118
- 'admin/jsonCustom.json5',
119
- 'admin/blockly.js',
120
-
121
- 'src-admin/package.json', // check if react is used
122
- 'src-widgets/package.json', // check if react is used
123
- 'src/package.json', // check if react is used
82
+ '/admin/index_m.html',
83
+ '/admin/words.js',
84
+ '/admin/jsonConfig.json',
85
+ '/admin/jsonConfig.json5',
86
+ '/admin/jsonCustom.json',
87
+ '/admin/jsonCustom.json5',
88
+ '/admin/blockly.js',
89
+
90
+ '/src-admin/package.json', // check if react is used
91
+ '/src-widgets/package.json', // check if react is used
92
+ '/src/package.json', // check if react is used
124
93
  ];
125
94
 
126
- context.cfg.allowedLanguages.forEach(lang => readFiles.push(`admin/i18n/${lang}/translations.json`));
95
+ context.cfg.allowedLanguages.forEach(lang => readFiles.push(`/admin/i18n/${lang}/translations.json`));
127
96
 
128
- context.cfg.allowedLanguages.forEach(lang => readFiles.push(`admin/i18n/${lang}.json`));
97
+ context.cfg.allowedLanguages.forEach(lang => readFiles.push(`/admin/i18n/${lang}.json`));
129
98
 
130
99
  if (context.packageJson.main) {
131
- readFiles.push(context.packageJson.main);
100
+ readFiles.push(`/${context.packageJson.main}`);
132
101
  }
133
102
 
134
103
  // if (!context.ioPackageJson.common.noConfig) {
@@ -164,67 +133,24 @@ async function checkCode(context) {
164
133
  context.filesList = [];
165
134
  getAllFiles(context, process.cwd(), '', context.filesList);
166
135
  } else {
167
- const data = await common.downloadFile(context.githubUrlOriginal, `/archive/${context.branch}.zip`, true);
168
- common.debug(`${context.branch}.zip ${data.length} bytes`);
136
+ context.filesList = await common.getFilesList(context);
169
137
 
170
- let found = false;
171
- const bufferStream = new stream.PassThrough();
172
- bufferStream.end(data);
173
- context.filesList = [];
138
+ for (const fileName of context.filesList) {
139
+ common.debug(`checking file ${fileName}`);
174
140
 
175
- // parse zip file
176
- const promises = [];
177
- await (function () {
178
- return new Promise(_resolve => {
179
- common.debug('init bufferstream');
180
- let root = '';
181
- bufferStream
182
- .pipe(unzipper.Parse())
183
- .on('entry', entry => {
184
- common.debug(`on.entry ${entry.path}`);
185
- if (root === '') {
186
- root = entry.path;
187
- common.debug(`Directory root set to ${root}`);
188
- }
189
- //if (!found && entry.type === 'Directory' && entry.path.match(/\/node_modules\/$/)) {
190
- if (!found && entry.type === 'Directory' && entry.path === `${root}node_modules/`) {
191
- common.debug(`Found ${entry.path}`);
192
- found = true;
193
- context.errors.push(
194
- '[E500] Directory node_modules found in root of repository. Please delete directory.',
195
- );
196
- }
141
+ const found = [];
142
+ if (fileName.match(/^\/node_modules\//) && !found.includes('node_module')) {
143
+ context.errors.push(
144
+ '[E500] Directory node_modules found in root of repository. Please delete directory.',
145
+ );
146
+ found.push('node_modules');
147
+ }
197
148
 
198
- // Get a list of all files and `.npmignore` + `.gitignore`
199
- const name = entry.path.replace(/^[^/]+\//, '');
200
- context.filesList.push(name);
201
-
202
- if (readFiles.includes(name)) {
203
- promises.push(
204
- new Promise(resolve => {
205
- const wstream = new WMStrm(name);
206
- wstream.on('finish', () => {
207
- context[`/${name}`] = memStore[name].toString();
208
- resolve(context[`/${name}`]);
209
- });
210
- entry.pipe(wstream);
211
- }),
212
- );
213
- } else {
214
- entry.autodrain();
215
- }
216
- })
217
- .on('error', () => {
218
- common.debug('on.error');
219
- context.errors.push(`[E501] Cannot get ${context.branch}.zip on github`);
220
- return Promise.all(promises).then(() => _resolve(context));
221
- })
222
- .on('close', () => {
223
- common.debug('on.close');
224
- return Promise.all(promises).then(() => _resolve(context));
225
- });
226
- });
227
- })();
149
+ if (readFiles.includes(fileName)) {
150
+ common.debug(` reading ${fileName}`);
151
+ context[fileName] = await common.getFile(context, fileName);
152
+ }
153
+ }
228
154
  }
229
155
 
230
156
  let usesReact = false;
@@ -303,9 +229,9 @@ async function checkCode(context) {
303
229
  if (
304
230
  context['/admin/index_m.html'] &&
305
231
  context['/admin/index_m.html'].includes('selectID.js') &&
306
- !context.filesList.includes('admin/img/info-big.png')
232
+ !context.filesList.includes('/admin/img/info-big.png')
307
233
  ) {
308
- context.errors.push('[E502] "admin/img/info-big.png" not found, but selectID.js used in index_m.html ');
234
+ context.errors.push('[E502] "/admin/img/info-big.png" not found, but selectID.js used in index_m.html ');
309
235
  }
310
236
 
311
237
  if (context['/admin/words.js']) {
@@ -346,7 +272,7 @@ async function checkCode(context) {
346
272
  : JSON5.parse(context['/admin/jsonConfig.json5']);
347
273
  } catch (e) {
348
274
  context.errors.push(
349
- `[E507] Cannot parse "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`,
275
+ `[E507] Cannot parse "/admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`,
350
276
  );
351
277
  }
352
278
  } else {
@@ -402,18 +328,18 @@ async function checkCode(context) {
402
328
  : JSON5.parse(context['/admin/jsonCustom.json5']);
403
329
  } catch (e) {
404
330
  context.errors.push(
405
- `[E511] Cannot parse "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`,
331
+ `[E511] Cannot parse "/admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`,
406
332
  );
407
333
  }
408
334
  } else {
409
335
  context.errors.push(
410
- `[E512] "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`,
336
+ `[E512] "/admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`,
411
337
  );
412
338
  }
413
339
  }
414
340
 
415
341
  if (context.ioPackageJson.common.blockly && !context['/admin/blockly.js']) {
416
- context.errors.push('[E514] "admin/blockly.js" not found, but blockly support is declared');
342
+ context.errors.push('[E514] "/admin/blockly.js" not found, but blockly support is declared');
417
343
  }
418
344
 
419
345
  if (context.ioPackageJson.common.javascriptRules) {
@@ -422,14 +348,14 @@ async function checkCode(context) {
422
348
  '[E517] JavaScript-Rules support is declared, but no location in property common.javascriptRules.url defined',
423
349
  );
424
350
  }
425
- if (!context.filesList.includes(`admin/${context.ioPackageJson.common.javascriptRules.url}`)) {
351
+ if (!context.filesList.includes(`/admin/${context.ioPackageJson.common.javascriptRules.url}`)) {
426
352
  context.errors.push(
427
- `[E516] "${context.ioPackageJson.common.javascriptRules.url}" not found, but JavaScript-Rules support is declared`,
353
+ `[E516] "/admin/${context.ioPackageJson.common.javascriptRules.url}" not found, but JavaScript-Rules support is declared`,
428
354
  );
429
355
  }
430
356
  }
431
357
 
432
- const forbiddenFiles = ['iob_npm.done', 'iob', 'iobroker'];
358
+ const forbiddenFiles = ['/iob_npm.done', '/iob', '/iobroker'];
433
359
 
434
360
  forbiddenFiles.forEach(file => {
435
361
  if (context.filesList.includes(file)) {
@@ -437,7 +363,7 @@ async function checkCode(context) {
437
363
  }
438
364
  });
439
365
 
440
- if (!context.filesList.includes('package-lock.json')) {
366
+ if (!context.filesList.includes('/package-lock.json')) {
441
367
  context.warnings.push(
442
368
  '[S523] "package-lock.json" not found in repo! Please consider to commit it to github repository.',
443
369
  );
@@ -22,7 +22,7 @@ async function checkReadme(context) {
22
22
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/README.md
23
23
  console.log('\n[E600 - E699] checkReadme');
24
24
 
25
- const data = await common.downloadFile(context.githubUrl, '/README.md');
25
+ const data = await common.getFile(context, '/README.md');
26
26
  if (!data) {
27
27
  context.errors.push('[E601] No README.md found');
28
28
  } else {
@@ -24,7 +24,7 @@ async function checkLicenseFile(context) {
24
24
 
25
25
  let data;
26
26
  try {
27
- data = await common.downloadFile(context.githubUrl, '/LICENSE');
27
+ data = await common.getFile(context, '/LICENSE');
28
28
  } catch (e) {
29
29
  if (e.status == 404) {
30
30
  context.errors.push('[E700] File LICENSE not found. Please add.');
@@ -34,7 +34,7 @@ async function checkGitIgnore(context) {
34
34
  throw 'FATAL:context.fileslist is undefined';
35
35
  }
36
36
 
37
- if (!context.filesList.includes('.gitignore')) {
37
+ if (!context.filesList.includes('/.gitignore')) {
38
38
  context.errors.push(`[E901] .gitignore not found`);
39
39
  } else {
40
40
  const rules = (context['/.gitignore'] || '')
@@ -88,13 +88,13 @@ async function checkGitIgnore(context) {
88
88
  async function checkNpmIgnore(context) {
89
89
  console.log('\n[E950 - E989] checkNpmIgnore');
90
90
  const checkFiles = [
91
- 'node_modules/',
92
- 'test/',
93
- 'src/',
94
- 'appveyor.yml',
95
- '.travis.yml',
96
- 'tsconfig.json',
97
- 'tsconfig.build.json',
91
+ '/node_modules/',
92
+ '/test/',
93
+ '/src/',
94
+ '/appveyor.yml',
95
+ '/.travis.yml',
96
+ '/tsconfig.json',
97
+ '/tsconfig.build.json',
98
98
  // 'iob_npm.done',
99
99
  // '.git/',
100
100
  // '.github/',
@@ -116,7 +116,7 @@ async function checkNpmIgnore(context) {
116
116
 
117
117
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
118
118
  if (context.packageJson.files && context.packageJson.files.length) {
119
- if (context.filesList.includes('.npmignore')) {
119
+ if (context.filesList.includes('/.npmignore')) {
120
120
  context.warnings.push(
121
121
  `[W951] .npmignore found but "files" is used at package.json. Please remove .npmignore.`,
122
122
  );
@@ -127,7 +127,7 @@ async function checkNpmIgnore(context) {
127
127
  }
128
128
 
129
129
  // package.json files section is NOT used
130
- if (!context.filesList.includes('.npmignore')) {
130
+ if (!context.filesList.includes('/.npmignore')) {
131
131
  context.errors.push(
132
132
  `[E952] neither files section at package.json nor file .npmignore not found. npm package will contain unwanted files.`,
133
133
  );
package/lib/common.js CHANGED
@@ -10,6 +10,7 @@ const semverValid = require('semver/functions/valid');
10
10
 
11
11
  let gDebug = false;
12
12
  let gInfo = true;
13
+ let gSuccess = false;
13
14
  let gLocal = false;
14
15
 
15
16
  // disable axios caching
@@ -53,6 +54,10 @@ function isInfo() {
53
54
  return gInfo;
54
55
  }
55
56
 
57
+ function isSuccess() {
58
+ return gSuccess;
59
+ }
60
+
56
61
  function isLocal() {
57
62
  return gLocal;
58
63
  }
@@ -67,6 +72,11 @@ function setInfo(flag) {
67
72
  console.log(`[INFO] info messages have been ${gInfo ? 'enabled' : 'disabled'}`);
68
73
  }
69
74
 
75
+ function setSuccess(flag) {
76
+ gInfo = flag;
77
+ console.log(`[INFO] success messages have been ${gSuccess ? 'enabled' : 'disabled'}`);
78
+ }
79
+
70
80
  function setLocal(flag) {
71
81
  gLocal = flag;
72
82
  info(`running in LOCAL mode`);
@@ -76,28 +86,56 @@ function checkLanguages(langObj, languages) {
76
86
  return languages.filter(lang => !langObj[lang]);
77
87
  }
78
88
 
79
- async function downloadFile(githubUrl, path, binary, noError) {
89
+ async function downloadURL(url, binary) {
90
+ debug(`Download file ${url} ${binary ? ' using binary mode' : ''})`);
91
+ const options = {};
92
+ options.responseType = binary ? 'arraybuffer' : 'text';
93
+ try {
94
+ //const response = await axios(githubUrl + (path || ''), options);
95
+ // @ts-expect-error options work this way
96
+ const response = await axios(url, options);
97
+ debug(`Download succeded`);
98
+ return response.data;
99
+ } catch (e) {
100
+ error(`Cannot download ${url} ${e}`);
101
+ return '';
102
+ }
103
+ }
104
+
105
+ async function getFile(context, path, binary) {
106
+ let file;
80
107
  if (!isLocal()) {
81
- debug(`Download ${githubUrl}${path || ''}`);
82
- const options = {};
83
- if (binary) {
84
- options.responseType = 'arraybuffer';
85
- }
86
- try {
87
- const response = await axios(githubUrl + (path || ''), options);
88
- debug(`download succeded`);
89
- return response.data;
90
- } catch (e) {
91
- (!noError || gDebug) && error(`Cannot download ${githubUrl}${path || ''} ${e}`);
92
- return '';
93
- }
108
+ const url = context
109
+ ? `https://cdn.jsdelivr.net/gh/${context.repository}@${context.lastCommitSha}${path || ''}`
110
+ : path;
111
+ file = await downloadURL(url, binary);
94
112
  } else {
95
113
  debug(`Download local ${path || ''}`);
96
114
  // remove first / from path
97
115
  path = path.replace(/^\/+/, '');
98
- const file = await fs.readFile(path, binary ? null : 'utf8');
99
- return file;
116
+ file = await fs.readFile(path, binary ? null : 'utf8');
100
117
  }
118
+ return file;
119
+ }
120
+
121
+ async function getFilesList(context) {
122
+ const url = `https://data.jsdelivr.com/v1/packages/gh/${context.repository}@${context.lastCommitSha}?structure=flat`;
123
+ debug(`Download ${url}`);
124
+ const filesList = [];
125
+ try {
126
+ const response = await axios(url);
127
+ debug(`download succeded`);
128
+ if (response.data?.files) {
129
+ response.data.files.forEach(fileInfo => filesList.push(fileInfo.name));
130
+ }
131
+ } catch (e) {
132
+ error(`Cannot download ${url} ${e}`);
133
+ }
134
+
135
+ debug('Files detected at repository:');
136
+ filesList.forEach(filename => debug(` ${filename}`));
137
+
138
+ return filesList;
101
139
  }
102
140
 
103
141
  function getDependencyArray(deps) {
@@ -198,14 +236,18 @@ exports.warn = warn;
198
236
 
199
237
  exports.isDebug = isDebug;
200
238
  exports.isInfo = isInfo;
239
+ exports.isSuccess = isSuccess;
201
240
  exports.isLocal = isLocal;
202
241
 
203
242
  exports.setDebug = setDebug;
204
243
  exports.setInfo = setInfo;
244
+ exports.setSuccess = setSuccess;
205
245
  exports.setLocal = setLocal;
206
246
 
207
247
  exports.checkLanguages = checkLanguages;
208
- exports.downloadFile = downloadFile;
248
+ exports.downloadURL = downloadURL;
249
+ exports.getFile = getFile;
250
+ exports.getFilesList = getFilesList;
209
251
  exports.getDependencyArray = getDependencyArray;
210
252
  exports.getDependencies = getDependencies;
211
253
  exports.maxVersion = maxVersion;
package/lib/config.js CHANGED
@@ -439,18 +439,41 @@ function initConfig(context) {
439
439
  function updateConfig(context) {
440
440
  console.log('[init] updating configuration');
441
441
 
442
+ if (common.isLocal()) {
443
+ context.cfg.mode = 'LOCAL';
444
+ } else {
445
+ context.cfg.mode = 'GITHUB';
446
+ }
447
+
442
448
  context.cfg.onlyWWW = !!context.ioPackageJson.common?.onlyWWW;
443
449
  context.cfg.hasJsonConfig = !!(
444
450
  context.ioPackageJson.common.adminUI?.config === 'json' ||
445
451
  context.ioPackageJson.common.adminUI?.custom === 'json'
446
452
  );
447
453
 
454
+ return context;
455
+ }
456
+
457
+ function logEnvironment(context) {
448
458
  common.info('');
459
+ common.info('Environment');
460
+ common.info(` repository ${context.repository}`);
461
+ common.info(` checking mode is ${context.cfg.mode}`);
462
+ common.info(` retrieving data from ${common.isLocal() ? `local storage` : `jsdelivr.com`}`);
463
+ if (context.cfg.mode === 'GITHUB') {
464
+ common.info(` using Github SHA ${context.lastCommitSha}`);
465
+ }
466
+ if (context.cfg.mode === 'LOCAL') {
467
+ common.info(` working directors is ${process.cwd()}`);
468
+ }
469
+ common.info(' ');
449
470
  common.info('Configuration flags set:');
450
471
  common.info(` hasJsonConfig: ${context.cfg.hasJsonConfig ? 'true' : 'false'}`);
451
472
  common.info(` onlyWWW: ${context.cfg.onlyWWW ? 'true' : 'false'}`);
473
+
452
474
  return context;
453
475
  }
454
476
 
455
477
  exports.initConfig = initConfig;
478
+ exports.logEnvironment = logEnvironment;
456
479
  exports.updateConfig = updateConfig;
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
- "version": "3.5.8",
2
+ "version": "4.0.0-alpha.1",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "axios": "^1.8.4",
6
6
  "compare-versions": "^6.1.1",
7
7
  "image-size": "^1.2.0",
8
8
  "json5": "^2.2.3",
9
- "semver": "^7.7.1",
10
- "unzipper": "^0.12.3"
9
+ "semver": "^7.7.1"
11
10
  },
12
11
  "devDependencies": {
13
12
  "@alcalzone/release-script": "^3.8.0",