@iobroker/repochecker 3.1.4 → 3.2.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 +173 -111
- package/index.js +135 -109
- package/lib/M000_PackageJson.js +23 -23
- package/lib/M100_IOPackageJson.js +51 -45
- package/lib/M250_Npm.js +3 -5
- package/lib/M400_Repository.js +10 -10
- package/lib/M500_Code.js +266 -150
- package/lib/M500__JsonConfig.js +603 -0
- package/lib/M700_License.js +3 -3
- package/lib/M800_Github.js +21 -21
- package/lib/M900_GitNpmIgnore.js +1 -1
- package/lib/common.js +48 -32
- package/package.json +1 -1
package/lib/common.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
6
|
const axios = require('axios');
|
|
7
|
+
const fs = require('node:fs/promises');
|
|
7
8
|
const compareVersions = require('compare-versions');
|
|
8
9
|
|
|
9
10
|
// disable axios caching
|
|
@@ -14,41 +15,55 @@ axios.defaults.headers = {
|
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
let gDebug = false;
|
|
17
|
-
function setDebug(flag){
|
|
18
|
+
function setDebug(flag) {
|
|
18
19
|
gDebug = flag;
|
|
20
|
+
debug('debug messages have been enabled');
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
function debug(msg) {
|
|
22
|
-
console.log(`[DEBUG] ${msg}`);
|
|
24
|
+
gDebug && console.log(`[DEBUG] ${msg}`);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
let gLocal = false;
|
|
28
|
+
function setLocal(flag) {
|
|
29
|
+
gLocal = flag;
|
|
30
|
+
console.log(`[INFO] running in LOCAL mode`);
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
function isLocal() {
|
|
34
|
+
return gLocal;
|
|
35
|
+
}
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
+
function checkLanguages(langObj, languages) {
|
|
38
|
+
return languages.filter((lang) => !langObj[lang]);
|
|
39
|
+
}
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
async function downloadFile(githubUrl, path, binary, noError) {
|
|
42
|
+
if (!isLocal()) {
|
|
43
|
+
console.log(`Download ${githubUrl}${path || ''}`);
|
|
44
|
+
const options = {};
|
|
45
|
+
if (binary) {
|
|
46
|
+
options.responseType = 'arraybuffer';
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const response = await axios(githubUrl + (path || ''), options);
|
|
50
|
+
debug(`download succeded`);
|
|
51
|
+
return response.data;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
(!noError || gDebug) && console.error(`Cannot download ${githubUrl}${path || ''} ${e}`);
|
|
54
|
+
throw e;
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
console.log(`Download local ${path || ''}`);
|
|
58
|
+
// remove first / from path
|
|
59
|
+
path = path.replace(/^\/+/, '');
|
|
60
|
+
const file = await fs.readFile(path, binary ? null : 'utf8');
|
|
61
|
+
return file;
|
|
45
62
|
}
|
|
46
|
-
|
|
47
63
|
}
|
|
48
|
-
|
|
49
64
|
function getDependencyArray(deps) {
|
|
50
65
|
return deps
|
|
51
|
-
.map(dep => typeof dep === 'object' ? Object.keys(dep) : [dep])
|
|
66
|
+
.map((dep) => (typeof dep === 'object' ? Object.keys(dep) : [dep]))
|
|
52
67
|
.reduce((acc, dep) => acc.concat(dep), []);
|
|
53
68
|
}
|
|
54
69
|
|
|
@@ -77,13 +92,13 @@ function getDependencies(deps) {
|
|
|
77
92
|
const ret = {};
|
|
78
93
|
console.log(`deps: ${JSON.stringify(deps)}, type ${typeof deps}`);
|
|
79
94
|
if (deps instanceof Array) {
|
|
80
|
-
for (const dep of deps
|
|
95
|
+
for (const dep of deps) {
|
|
81
96
|
if (typeof dep === 'object') {
|
|
82
|
-
for (const key in dep
|
|
97
|
+
for (const key in dep) {
|
|
83
98
|
ret[key] = dep[key];
|
|
84
99
|
}
|
|
85
100
|
} else {
|
|
86
|
-
ret[
|
|
101
|
+
ret[dep] = '>=0';
|
|
87
102
|
}
|
|
88
103
|
}
|
|
89
104
|
}
|
|
@@ -101,12 +116,13 @@ function maxVersion(v1, v2) {
|
|
|
101
116
|
return v2;
|
|
102
117
|
}
|
|
103
118
|
|
|
104
|
-
exports.setDebug=setDebug;
|
|
105
|
-
exports.debug=debug;
|
|
106
|
-
|
|
107
|
-
exports.
|
|
108
|
-
exports.downloadFile=downloadFile;
|
|
109
|
-
exports.getDependencyArray=getDependencyArray;
|
|
110
|
-
exports.getDependencies=getDependencies;
|
|
111
|
-
exports.maxVersion=maxVersion;
|
|
119
|
+
exports.setDebug = setDebug;
|
|
120
|
+
exports.debug = debug;
|
|
121
|
+
exports.setLocal = setLocal;
|
|
122
|
+
exports.isLocal = isLocal;
|
|
112
123
|
|
|
124
|
+
exports.checkLanguages = checkLanguages;
|
|
125
|
+
exports.downloadFile = downloadFile;
|
|
126
|
+
exports.getDependencyArray = getDependencyArray;
|
|
127
|
+
exports.getDependencies = getDependencies;
|
|
128
|
+
exports.maxVersion = maxVersion;
|
package/package.json
CHANGED