@iobroker/repochecker 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,9 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
+ ### 2.5.0 (2024-05-30)
24
+ * (mcm1957) Add check ensure that dependency revisions are available at repository. [#180]
25
+
23
26
  ### 2.4.0 (2024-05-30)
24
27
  * (mcm1957) Add check to protect sensitive data. [#195]
25
28
  * (mcm1957) Add check to verify that dependencies and globalDepencies are of type array. [#90]
package/doc/issues.json CHANGED
@@ -401,6 +401,15 @@
401
401
  "E429": {
402
402
  "title": "Adapter name should use `-` instead of `_`"
403
403
  },
404
+ "E430": {
405
+ "title": "Cannot download http://repo.iobroker.live/sources-dist.json"
406
+ },
407
+ "E431": {
408
+ "title": "Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository"
409
+ },
410
+ "E433": {
411
+ "title": "Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository"
412
+ },
404
413
  "E500": {
405
414
  "title": "node_modules found in repo. Please delete it"
406
415
  },
@@ -566,6 +575,15 @@
566
575
  "W400": {
567
576
  "title": "Cannot find adapter in latest repository"
568
577
  },
578
+ "W432": {
579
+ "title": "Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='"
580
+ },
581
+ "W433": {
582
+ "title": "Dependency ${dependency} not available at stable repository"
583
+ },
584
+ "W434": {
585
+ "title": "Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='"
586
+ },
569
587
  "W504": {
570
588
  "title": "setInterval found in main, but no clearInterval detected"
571
589
  },
package/index.js CHANGED
@@ -143,6 +143,43 @@ function getDependencyArray(deps) {
143
143
  .reduce((acc, dep) => acc.concat(dep), []);
144
144
  }
145
145
 
146
+ // dependencies might be:
147
+ // [
148
+ // {"js-controller":">=1.2.3"}
149
+ // ]
150
+ // or
151
+ // [
152
+ // {"js-controller":">=1.2.3"},
153
+ // {"vis":">=1.2.3"}
154
+ // ]
155
+ // or
156
+ // [
157
+ // {
158
+ // "js-controller":">=1.2.3",
159
+ // "vis":">=1.2.3"
160
+ // }
161
+ // ]
162
+ // or
163
+ // [
164
+ // {"js-controller":">=1.2.3"},
165
+ // "vis"
166
+ // ]
167
+ function getDependencies(deps) {
168
+ const ret = {};
169
+ console.log(`deps: ${JSON.stringify(deps)}, type ${typeof deps}`)
170
+ for (let dep of deps ) {
171
+ if (typeof dep === 'object') {
172
+ for (let key in dep ) {
173
+ ret[key] = dep[key];
174
+ }
175
+ } else {
176
+ ret[ dep ] = '>=0';
177
+ }
178
+ }
179
+ console.log(`ret: ${JSON.stringify(ret)}`)
180
+ return ret;
181
+ }
182
+
146
183
  /*
147
184
  function checkLanguages(langObj) {
148
185
  if (Object.keys(langObj).length !== allowedLanguages.length) return false;
@@ -1430,11 +1467,13 @@ function checkIOPackageJson(context) {
1430
1467
  currentJsControllerVersion = jsControllerDependency['js-controller'].replace(/[^\d.]/g, '');
1431
1468
  }
1432
1469
  }
1470
+
1433
1471
  }
1434
1472
  }
1435
1473
 
1436
1474
  if (context.ioPackageJson.common.globalDependencies) {
1437
1475
  const dependencyArray = getDependencyArray(context.ioPackageJson.common.globalDependencies);
1476
+
1438
1477
  if (!(context.ioPackageJson.common.globalDependencies instanceof Array)){
1439
1478
  context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
1440
1479
  } else {
@@ -1443,8 +1482,10 @@ function checkIOPackageJson(context) {
1443
1482
  context.errors.push(`[E161] "js-controller" is not allowed in common.globalDependencies`);
1444
1483
  }
1445
1484
  }
1485
+
1446
1486
  }
1447
1487
 
1488
+
1448
1489
  if (context.packageJson.dependencies && context.packageJson.dependencies['@iobroker/adapter-core']) {
1449
1490
  /*
1450
1491
  - adapter-core <2.3 has no special dep requirements
@@ -1778,7 +1819,7 @@ function checkRepo(context) {
1778
1819
  }
1779
1820
 
1780
1821
  // download stable repo
1781
- const _response = await axios('https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json');
1822
+ let _response = await axios('https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json');
1782
1823
  body = _response.data;
1783
1824
  if (!body) {
1784
1825
  context.errors.push('[E420] Cannot download https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json');
@@ -1830,6 +1871,113 @@ function checkRepo(context) {
1830
1871
  }
1831
1872
  }
1832
1873
  }
1874
+
1875
+ _response = await axios('http://repo.iobroker.live/sources-dist-latest.json');
1876
+ body = _response.data;
1877
+ if (!body) {
1878
+ context.errors.push('[E429] Cannot download http://repo.iobroker.live/sources-dist-latest.json');
1879
+ } else {
1880
+ context.latestRepoLive = body;
1881
+ }
1882
+
1883
+ _response = await axios('http://repo.iobroker.live/sources-dist.json');
1884
+ body = _response.data;
1885
+ if (!body) {
1886
+ context.errors.push('[E430] Cannot download http://repo.iobroker.live/sources-dist.json');
1887
+ } else {
1888
+ context.stableRepoLive = body;
1889
+ }
1890
+
1891
+ if (context.latestRepo && context.latestRepoLive && context.stableRepo && context.stableRepoLive) {
1892
+ if (context.ioPackageJson.common.dependencies) {
1893
+ const dependencies = getDependencies(context.ioPackageJson.common.dependencies);
1894
+ for ( const dependency in dependencies ) {
1895
+
1896
+ if ( !context.latestRepoLive[dependency] ) {
1897
+ context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
1898
+ } else {
1899
+ const versDependency = dependencies[dependency];
1900
+ const versRepository = context.latestRepoLive[dependency].version;
1901
+ //console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
1902
+ if (!versDependency.startsWith('>=')) {
1903
+ context.warnings.push(`[W432] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
1904
+ } else {
1905
+ if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
1906
+ context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
1907
+ } else {
1908
+ context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at latest repository`);
1909
+ }
1910
+ }
1911
+ }
1912
+
1913
+ if ( !context.stableRepoLive[dependency] ) {
1914
+ context.warnings.push(`[W433] Dependency ${dependency} not available at stable repository`);
1915
+ } else {
1916
+ const versDependency = dependencies[dependency];
1917
+ const versRepository = context.stableRepoLive[dependency].version;
1918
+ //console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
1919
+ if (!versDependency.startsWith('>=')) {
1920
+ context.warnings.push(`[W434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
1921
+ } else {
1922
+ if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
1923
+ context.errors.push(`[E433] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
1924
+ } else {
1925
+ context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at stable repository`);
1926
+ }
1927
+ }
1928
+ }
1929
+
1930
+ }
1931
+ } else {
1932
+ context.checks.push('common.dependency check skipped');
1933
+ }
1934
+
1935
+ if (context.ioPackageJson.common.globalDependencies) {
1936
+ const dependencies = getDependencies(context.ioPackageJson.common.globalDependencies);
1937
+ for ( const dependency in dependencies ) {
1938
+
1939
+ if ( !context.latestRepoLive[dependency] ) {
1940
+ context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
1941
+ } else {
1942
+ const versDependency = dependencies[dependency];
1943
+ const versRepository = context.latestRepoLive[dependency].version;
1944
+ console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
1945
+ if (!versDependency.startsWith('>=')) {
1946
+ context.warnings.push(`[W432] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
1947
+ } else {
1948
+ if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
1949
+ context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
1950
+ } else {
1951
+ context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at latest repository`);
1952
+ }
1953
+ }
1954
+ }
1955
+
1956
+ if ( !context.stableRepoLive[dependency] ) {
1957
+ context.warnings.push(`[W433] Dependency ${dependency} not available at stable repository`);
1958
+ } else {
1959
+ const versDependency = dependencies[dependency];
1960
+ const versRepository = context.stableRepoLive[dependency].version;
1961
+ console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
1962
+ if (!versDependency.startsWith('>=')) {
1963
+ context.warnings.push(`[W434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
1964
+ } else {
1965
+ if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
1966
+ context.errors.push(`[E433] Dependency '${dependency}':'${dependencies[dependency]}' not available at stable repository`);
1967
+ } else {
1968
+ context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at stable repository`);
1969
+ }
1970
+ }
1971
+ }
1972
+
1973
+ }
1974
+ } else {
1975
+ context.checks.push('common.globalDependency check skipped');
1976
+ }
1977
+
1978
+ } else {
1979
+ context.checks.push(`Dependency checks skipped due to repository access errors`);
1980
+ }
1833
1981
  return context;
1834
1982
  });
1835
1983
  } else {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.4.0",
2
+ "version": "2.5.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "axios": "^1.6.8",