@iobroker/legacy-testing 0.3.0 → 0.3.2
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/LICENSE +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/setup.js +31 -7
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022 bluefox <dogafox@gmail.com>
|
|
3
|
+
Copyright (c) 2022-2023 bluefox <dogafox@gmail.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Legacy test modules for ioBroker
|
|
|
11
11
|
|
|
12
12
|
## Changelog
|
|
13
13
|
<!-- ### **WORK IN PROGRESS** -->
|
|
14
|
-
### 0.3.
|
|
14
|
+
### 0.3.2 (2023-05-08)
|
|
15
15
|
* (bluefox) Added possibility to install additional adapters at start
|
|
16
16
|
* (bluefox) Added setOfflineState/getOfflineState
|
|
17
17
|
|
|
@@ -30,7 +30,7 @@ Legacy test modules for ioBroker
|
|
|
30
30
|
## License
|
|
31
31
|
MIT License
|
|
32
32
|
|
|
33
|
-
Copyright (c) 2022 bluefox <dogafox@gmail.com>
|
|
33
|
+
Copyright (c) 2022-2023 bluefox <dogafox@gmail.com>
|
|
34
34
|
|
|
35
35
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
36
36
|
of this software and associated documentation files (the "Software"), to deal
|
package/package.json
CHANGED
package/setup.js
CHANGED
|
@@ -189,14 +189,13 @@ async function checkIsAdapterInstalled(cb, counter, customAdapterName, customIns
|
|
|
189
189
|
console.log(`[${customAdapterName}] checkIsAdapterInstalled...`);
|
|
190
190
|
|
|
191
191
|
try {
|
|
192
|
-
const obj = await getObject(`system.adapter.${customAdapterName}.${customInstance || 0}`)
|
|
193
|
-
if (obj) {
|
|
194
|
-
console.log(`[${customAdapterName}] checkIsAdapterInstalled: ready
|
|
192
|
+
const obj = await getObject(`system.adapter.${customAdapterName}.${customInstance || 0}`);
|
|
193
|
+
if (obj && obj.common) {
|
|
194
|
+
console.log(`[${customAdapterName}] checkIsAdapterInstalled: ready! ${JSON.stringify(obj)}`);
|
|
195
195
|
setTimeout(() => cb && cb(), 100);
|
|
196
196
|
return;
|
|
197
|
-
} else {
|
|
198
|
-
console.warn(`[${customAdapterName}] checkIsAdapterInstalled: still not ready`);
|
|
199
197
|
}
|
|
198
|
+
console.warn(`[${customAdapterName}] checkIsAdapterInstalled: still not ready`);
|
|
200
199
|
} catch (err) {
|
|
201
200
|
console.log(`[${customAdapterName}] checkIsAdapterInstalled: catch ${err}`);
|
|
202
201
|
}
|
|
@@ -228,7 +227,7 @@ async function checkIsControllerInstalled(cb, counter) {
|
|
|
228
227
|
console.log('checkIsControllerInstalled...');
|
|
229
228
|
try {
|
|
230
229
|
const obj = await getObject('system.certificates');
|
|
231
|
-
if (obj) {
|
|
230
|
+
if (obj && obj.common) {
|
|
232
231
|
console.log('checkIsControllerInstalled: installed!');
|
|
233
232
|
setTimeout(() => cb && cb(), 100);
|
|
234
233
|
return;
|
|
@@ -287,7 +286,31 @@ async function installAdapter(customAdapterName, cb) {
|
|
|
287
286
|
await waitForEndAsync(_pid);
|
|
288
287
|
}
|
|
289
288
|
|
|
290
|
-
|
|
289
|
+
const name = (customAdapterName.split('@')[0]).split('.').pop(); // extract from iobroker.adaptername@version => adaptername
|
|
290
|
+
|
|
291
|
+
try {
|
|
292
|
+
await checkIsAdapterInstalledAsync(null, name);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
console.warn(`[${customAdapterName}] Adapter not installed: ${err}`);
|
|
295
|
+
// try workaround
|
|
296
|
+
installCustomAdapter(customAdapterName);
|
|
297
|
+
// make first install
|
|
298
|
+
if (debug) {
|
|
299
|
+
cp.execSync(`node ${startFile} add ${customAdapterName} --enabled false`, {
|
|
300
|
+
cwd: `${rootDir}tmp`,
|
|
301
|
+
stdio: [0, 1, 2],
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
// add controller
|
|
305
|
+
const _pid = cp.fork(startFile, ['add', customAdapterName, '--enabled', 'false'], {
|
|
306
|
+
cwd: `${rootDir}tmp`,
|
|
307
|
+
stdio: [0, 1, 2, 'ipc'],
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
await waitForEndAsync(_pid);
|
|
311
|
+
}
|
|
312
|
+
await checkIsAdapterInstalledAsync(null, name);
|
|
313
|
+
}
|
|
291
314
|
console.log(`[${customAdapterName}] Adapter installed.`);
|
|
292
315
|
cb && cb();
|
|
293
316
|
}
|
|
@@ -649,6 +672,7 @@ function startCustomAdapter(adapterName, adapterInstance) {
|
|
|
649
672
|
adaptersStarted[id] = true;
|
|
650
673
|
console.log(`startAdapter ${id} ...`);
|
|
651
674
|
const _pkg = adapterName ? require(`${rootDir}tmp/node_modules/iobroker.${adapterName}/package.json`) : pkg;
|
|
675
|
+
adapterName = adapterName || pkg.name;
|
|
652
676
|
if (fs.existsSync(`${rootDir}tmp/node_modules/iobroker.${adapterName}/${_pkg.main || 'main.js'}`)) {
|
|
653
677
|
try {
|
|
654
678
|
if (debug) {
|