Skip to content

Commit 604e50d

Browse files
committed
(bluefox) remove non-existing adapters
(bluefox) implement License agreement
1 parent 8bd0fcc commit 604e50d

File tree

2 files changed

+62
-55
lines changed

2 files changed

+62
-55
lines changed

conf/sources-dist.json

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.b-control-em/master/admin/bcontrol.png"
1414
},
1515
"cul": {
16-
"meta": "https://raw.githubusercontent.com/hobbyquaker/ioBroker.cul/master/io-package.json",
17-
"icon": "https://raw.githubusercontent.com/hobbyquaker/ioBroker.cul/master/admin/busware.jpg"
16+
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.cul/master/io-package.json",
17+
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.cul/master/admin/busware.jpg"
1818
},
1919
"dwd": {
2020
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.dwd/master/io-package.json",
@@ -28,17 +28,6 @@
2828
"meta": "/adapter/example/io-package.json",
2929
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/adapter/example/admin/example.png"
3030
},
31-
"geofency": {
32-
"url": "https://github.com/ioBroker/ioBroker.geofency/archive/master.zip"
33-
},
34-
"graphite": {
35-
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.graphite/master/io-package.json",
36-
"url": "https://github.com/ioBroker/ioBroker.graphite/archive/master.zip"
37-
},
38-
"highcharts": {
39-
"meta": "https://raw.githubusercontent.com/hobbyquaker/ioBroker.highcharts/master/io-package.json",
40-
"url": "https://github.com/hobbyquaker/ioBroker.highcharts/archive/master.zip"
41-
},
4231
"history": {
4332
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.history/master/io-package.json",
4433
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.history/master/admin/history.png"
@@ -84,11 +73,6 @@
8473
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.megad/master/io-package.json",
8574
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.megad/master/admin/megad.png"
8675
},
87-
"mobile": {
88-
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.mobile/master/io-package.json",
89-
"url": "https://github.com/ioBroker/ioBroker.mobile/archive/master.zip",
90-
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.mobile/master/admin/jquery-mobile.png"
91-
},
9276
"mqtt": {
9377
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.mqtt/master/io-package.json",
9478
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.mqtt/master/admin/mqtt.png"
@@ -113,11 +97,6 @@
11397
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.socketio/master/io-package.json",
11498
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.socketio/master/admin/socketio.png"
11599
},
116-
"telnet": {
117-
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.telnet/master/io-package.json",
118-
"url": "https://github.com/ioBroker/ioBroker.telnet/archive/master.zip",
119-
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.telnet/master/admin/telnet.png"
120-
},
121100
"onkyo": {
122101
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.onkyo/master/io-package.json",
123102
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.onkyo/master/admin/onkyo.png"
@@ -138,9 +117,6 @@
138117
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.sonos/master/io-package.json",
139118
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.sonos/master/admin/sonos.png"
140119
},
141-
"virtual": {
142-
"url": "https://github.com/ioBroker/ioBroker.virtual/archive/master.zip"
143-
},
144120
"vis": {
145121
"meta": "https://raw.githubusercontent.com/ioBroker/ioBroker.vis/master/io-package.json",
146122
"icon": "https://raw.githubusercontent.com/ioBroker/ioBroker.vis/master/admin/vis.png"

lib/tools.js

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function getJson(urlOrPath, callback) {
158158
}
159159
if (callback) callback(sources, urlOrPath);
160160
} else {
161-
console.log('Json file not found: ' + urlOrPath);
161+
//if (urlOrPath.indexOf('/example/') == -1) console.log('Json file not found: ' + urlOrPath);
162162
if (callback) callback(null, urlOrPath);
163163
return;
164164
}
@@ -169,7 +169,10 @@ function getJson(urlOrPath, callback) {
169169
// Get list of all installed adapters and controller version on this host
170170
function getInstalledInfo(hostRunningVersion) {
171171
var result = {};
172-
var ioPackage = JSON.parse(fs.readFileSync(__dirname + '/../io-package.json'));
172+
var path = __dirname + '/../';
173+
// Get info about host
174+
var ioPackage = JSON.parse(fs.readFileSync(path + 'io-package.json'));
175+
var package = fs.existsSync(path + 'package.json') ? JSON.parse(fs.readFileSync(path + 'package.json')) : {};
173176
result[ioPackage.common.name] = {
174177
controller: true,
175178
version: ioPackage.common.version,
@@ -179,13 +182,17 @@ function getInstalledInfo(hostRunningVersion) {
179182
platform: ioPackage.common.platform,
180183
keywords: ioPackage.common.keywords,
181184
readme: ioPackage.common.readme,
182-
runningVersion: hostRunningVersion
185+
runningVersion: hostRunningVersion,
186+
license: ioPackage.common.license ? ioPackage.common.license : ((package.licenses && package.licenses.length) ? package.licenses[0].type : ''),
187+
licenseUrl: (package.licenses && package.licenses.length) ? package.licenses[0].url : ''
183188
};
184189
var dirs = fs.readdirSync(__dirname + '/../adapter');
185190
for (var i = 0; i < dirs.length; i++) {
186191
try {
187-
if (fs.existsSync(__dirname + '/../adapter/' + dirs[i] + '/io-package.json')) {
188-
ioPackage = JSON.parse(fs.readFileSync(__dirname + '/../adapter/' + dirs[i] + '/io-package.json'));
192+
path = __dirname + '/../adapter/' + dirs[i] + '/';
193+
if (fs.existsSync(path + 'io-package.json')) {
194+
ioPackage = JSON.parse(fs.readFileSync(path + 'io-package.json'));
195+
package = fs.existsSync(path + 'package.json') ? JSON.parse(fs.readFileSync(path + 'package.json')) : {};
189196
result[ioPackage.common.name] = {
190197
controller: false,
191198
version: ioPackage.common.version,
@@ -195,8 +202,9 @@ function getInstalledInfo(hostRunningVersion) {
195202
platform: ioPackage.common.platform,
196203
keywords: ioPackage.common.keywords,
197204
readme: ioPackage.common.readme,
198-
license: ioPackage.common.license,
199-
type: ioPackage.common.type
205+
type: ioPackage.common.type,
206+
license: ioPackage.common.license ? ioPackage.common.license : ((package.licenses && package.licenses.length) ? package.licenses[0].type : ''),
207+
licenseUrl: (package.licenses && package.licenses.length) ? package.licenses[0].url : ''
200208
};
201209
}
202210
} catch (e) {
@@ -206,8 +214,10 @@ function getInstalledInfo(hostRunningVersion) {
206214
dirs = fs.readdirSync(__dirname + '/../node_modules');
207215
for (i = 0; i < dirs.length; i++) {
208216
try {
209-
if (dirs[i].match(/^iobroker\./i) && fs.existsSync(__dirname + '/../node_modules/' + dirs[i] + '/io-package.json')) {
210-
ioPackage = JSON.parse(fs.readFileSync(__dirname + '/../node_modules/' + dirs[i] + '/io-package.json'));
217+
path = __dirname + '/../node_modules/' + dirs[i] + '/';
218+
if (dirs[i].match(/^iobroker\./i) && fs.existsSync(path + 'io-package.json')) {
219+
ioPackage = JSON.parse(fs.readFileSync(path + 'io-package.json'));
220+
package = fs.existsSync(path + 'package.json') ? JSON.parse(fs.readFileSync(path + 'package.json')) : {};
211221
result[ioPackage.common.name] = {
212222
controller: false,
213223
version: ioPackage.common.version,
@@ -217,7 +227,9 @@ function getInstalledInfo(hostRunningVersion) {
217227
platform: ioPackage.common.platform,
218228
keywords: ioPackage.common.keywords,
219229
readme: ioPackage.common.readme,
220-
type: ioPackage.common.type
230+
type: ioPackage.common.type,
231+
license: ioPackage.common.license ? ioPackage.common.license : ((package.licenses && package.licenses.length) ? package.licenses[0].type : ''),
232+
licenseUrl: (package.licenses && package.licenses.length) ? package.licenses[0].url : ''
221233
};
222234
}
223235
} catch (e) {
@@ -229,9 +241,11 @@ function getInstalledInfo(hostRunningVersion) {
229241
dirs = fs.readdirSync(__dirname + '/../..');
230242
for (i = 0; i < dirs.length; i++) {
231243
try {
244+
path = __dirname + '/../../' + dirs[i] + '/';
232245
if (dirs[i].match(/^iobroker\./i) && dirs[i].substring('iobroker.'.length) != 'js-controller' &&
233-
fs.existsSync(__dirname + '/../../' + dirs[i] + '/io-package.json')) {
234-
ioPackage = JSON.parse(fs.readFileSync(__dirname + '/../../' + dirs[i] + '/io-package.json'));
246+
fs.existsSync(path + 'io-package.json')) {
247+
ioPackage = JSON.parse(fs.readFileSync(path + 'io-package.json'));
248+
package = fs.existsSync(path + 'package.json') ? JSON.parse(fs.readFileSync(path + 'package.json')) : {};
235249
result[ioPackage.common.name] = {
236250
controller: false,
237251
version: ioPackage.common.version,
@@ -240,7 +254,9 @@ function getInstalledInfo(hostRunningVersion) {
240254
desc: ioPackage.common.desc,
241255
platform: ioPackage.common.platform,
242256
keywords: ioPackage.common.keywords,
243-
readme: ioPackage.common.readme
257+
readme: ioPackage.common.readme,
258+
license: ioPackage.common.license ? ioPackage.common.license : ((package.licenses && package.licenses.length) ? package.licenses[0].type : ''),
259+
licenseUrl: (package.licenses && package.licenses.length) ? package.licenses[0].url : ''
244260
};
245261
}
246262
} catch (e) {
@@ -320,26 +336,41 @@ function getNpmVersion(adapter, callback) {
320336

321337
function getIoPack(sources, name, callback) {
322338
getJson(sources[name].meta, function (ioPack) {
323-
// If installed from git or something else
324-
// js-controller is exception, because can be installed from npm and from git
325-
if (sources[name].url && name != 'js-controller') {
326-
if (ioPack && ioPack.common) sources[name] = extend(true, sources[name], ioPack.common);
339+
var packUrl = sources[name].meta.replace('io-package.json', 'package.json');
340+
getJson(packUrl, function (pack) {
341+
// If installed from git or something else
342+
// js-controller is exception, because can be installed from npm and from git
343+
if (sources[name].url && name != 'js-controller') {
344+
if (ioPack && ioPack.common) {
345+
sources[name] = extend(true, sources[name], ioPack.common);
346+
if (pack && pack.licenses && pack.licenses.length) {
347+
if (!sources[name].license) sources[name].license = pack.licenses[0].type;
348+
if (!sources[name].licenseUrl) sources[name].licenseUrl = pack.licenses[0].url;
349+
}
350+
}
327351

328-
if (callback) callback(sources, name);
329-
} else {
330-
if (ioPack && ioPack.common) sources[name] = extend(true, sources[name], ioPack.common);
352+
if (callback) callback(sources, name);
353+
} else {
354+
if (ioPack && ioPack.common) {
355+
sources[name] = extend(true, sources[name], ioPack.common);
356+
if (pack && pack.licenses && pack.licenses.length) {
357+
if (!sources[name].license) sources[name].license = pack.licenses[0].type;
358+
if (!sources[name].licenseUrl) sources[name].licenseUrl = pack.licenses[0].url;
359+
}
360+
}
331361

332-
if (sources[name].meta.substring(0, 'http://'.length) == 'http://' ||
333-
sources[name].meta.substring(0, 'https://'.length) == 'https://') {
334-
//installed from npm
335-
getNpmVersion(name, function (err, version) {
336-
if (version) sources[name].version = version;
362+
if (sources[name].meta.substring(0, 'http://'.length) == 'http://' ||
363+
sources[name].meta.substring(0, 'https://'.length) == 'https://') {
364+
//installed from npm
365+
getNpmVersion(name, function (err, version) {
366+
if (version) sources[name].version = version;
367+
if (callback) callback(sources, name);
368+
});
369+
} else {
337370
if (callback) callback(sources, name);
338-
});
339-
} else {
340-
if (callback) callback(sources, name);
371+
}
341372
}
342-
}
373+
});
343374
});
344375
}
345376

0 commit comments

Comments
 (0)