@iobroker/legacy-testing 2.1.2 → 3.0.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 +11 -0
- package/build/setup.js +40 -5
- package/build/tests/testPackageFiles.js +27 -20
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -15,7 +15,18 @@ Legacy test modules for ioBroker
|
|
|
15
15
|
|
|
16
16
|
Set `process.env.JS_CONTROLLER_VERSION` to version e.g. `5.0.5-alpha.0-20230617-464b0fd6`
|
|
17
17
|
|
|
18
|
+
## Usage of the specific admin version
|
|
19
|
+
|
|
20
|
+
Set `process.env.ADMIN_VERSION` to version e.g. `7.6.0`. It is used for the GUI tests, where the admin is started.
|
|
21
|
+
If it is not set, the js-controller installs the version from the ioBroker repository (normally the latest one).
|
|
22
|
+
The variable is ignored if the admin itself is the adapter under test.
|
|
23
|
+
|
|
24
|
+
<!-- ### **WORK IN PROGRESS** -->
|
|
18
25
|
## Changelog
|
|
26
|
+
### 3.0.0 (2026-08-03)
|
|
27
|
+
- (@GermanBluefox) Added `ADMIN_VERSION` environment variable to install a specific admin version
|
|
28
|
+
- (@GermanBluefox) Removed `chai`. Use `node:assert` instead
|
|
29
|
+
|
|
19
30
|
### 2.1.2 (2026-07-12)
|
|
20
31
|
- (@GermanBluefox) The module was rewritten in TypeScript. The sources live now in `src/` and are compiled to `build/`. The public API and import paths stayed the same.
|
|
21
32
|
- (@GermanBluefox) If `JS_CONTROLLER_VERSION` is not set, js-controller `7.2.2` is installed on Node.js <= 20 and the `dev` build on newer Node.js versions.
|
package/build/setup.js
CHANGED
|
@@ -26,6 +26,8 @@ const node_child_process_1 = require("node:child_process");
|
|
|
26
26
|
const node_net_1 = require("node:net");
|
|
27
27
|
let rootDir = (0, node_path_1.normalize)(`${__dirname}/../../../../`);
|
|
28
28
|
const debug = typeof globalThis.v8debug === 'object';
|
|
29
|
+
/** npm package name of the admin adapter */
|
|
30
|
+
const ADMIN_PACKAGE = 'iobroker.admin';
|
|
29
31
|
let JSONLDB;
|
|
30
32
|
let adapterParts = (0, node_path_1.normalize)(rootDir).replace(/\\/g, '/').split('/');
|
|
31
33
|
if (adapterParts[adapterParts.length - 2] === 'vis-2-widgets-testing') {
|
|
@@ -265,6 +267,15 @@ async function installAdapter(customAdapterName, cb) {
|
|
|
265
267
|
customAdapterName = null;
|
|
266
268
|
}
|
|
267
269
|
customAdapterName ||= pkg.name;
|
|
270
|
+
// Install the requested admin version, but never overwrite the adapter under test,
|
|
271
|
+
// e.g. if the admin itself is tested
|
|
272
|
+
const adminVersion = getAdminVersion();
|
|
273
|
+
if (adminVersion &&
|
|
274
|
+
pkg.name !== ADMIN_PACKAGE &&
|
|
275
|
+
(customAdapterName === 'admin' || customAdapterName === ADMIN_PACKAGE)) {
|
|
276
|
+
console.log(`[admin] Use version "${adminVersion}" from ADMIN_VERSION`);
|
|
277
|
+
customAdapterName = `${ADMIN_PACKAGE}@${adminVersion}`;
|
|
278
|
+
}
|
|
268
279
|
console.log(`[${customAdapterName}] Install adapter...`);
|
|
269
280
|
if (customAdapterName.includes('@')) {
|
|
270
281
|
installCustomAdapter(customAdapterName);
|
|
@@ -325,6 +336,14 @@ function getJsControllerVersion() {
|
|
|
325
336
|
const nodeMajor = parseInt(process.versions.node.split('.')[0], 10);
|
|
326
337
|
return nodeMajor <= 20 ? '7.2.2' : 'dev';
|
|
327
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Determine the admin version to install: the explicitly requested `ADMIN_VERSION`
|
|
341
|
+
* or - if none is given - `undefined`, so the js-controller installs the version
|
|
342
|
+
* from the configured repository (normally the latest one).
|
|
343
|
+
*/
|
|
344
|
+
function getAdminVersion() {
|
|
345
|
+
return process.env.ADMIN_VERSION || undefined;
|
|
346
|
+
}
|
|
328
347
|
async function installJsController(preInstalledAdapters, cb) {
|
|
329
348
|
if (typeof preInstalledAdapters === 'function') {
|
|
330
349
|
cb = preInstalledAdapters;
|
|
@@ -493,13 +512,29 @@ function copyAdapterToController() {
|
|
|
493
512
|
console.log('Adapter uploaded.');
|
|
494
513
|
}
|
|
495
514
|
function installCustomAdapter(customAdapterName) {
|
|
496
|
-
|
|
515
|
+
// split `iobroker.admin@7.6.0` into name and version
|
|
516
|
+
const atPos = customAdapterName.lastIndexOf('@');
|
|
517
|
+
const name = atPos > 0 ? customAdapterName.substring(0, atPos) : customAdapterName;
|
|
518
|
+
const version = atPos > 0 ? customAdapterName.substring(atPos + 1) : '';
|
|
519
|
+
const packageJsonPath = `${rootDir}tmp/node_modules/${name}/package.json`;
|
|
520
|
+
if ((0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
521
|
+
if (!version) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
// re-install only if another version is installed
|
|
525
|
+
const pack = require(packageJsonPath);
|
|
526
|
+
if (pack.version === version) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
console.log(`Install ${customAdapterName} (installed: ${pack.version})`);
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
497
532
|
console.log(`Install ${customAdapterName}`);
|
|
498
|
-
(0, node_child_process_1.execSync)(`npm install ${customAdapterName} --prefix ./ --omit=dev`, {
|
|
499
|
-
cwd: `${rootDir}tmp/`,
|
|
500
|
-
stdio: [0, 1, 2],
|
|
501
|
-
});
|
|
502
533
|
}
|
|
534
|
+
(0, node_child_process_1.execSync)(`npm install ${customAdapterName} --prefix ./ --omit=dev`, {
|
|
535
|
+
cwd: `${rootDir}tmp/`,
|
|
536
|
+
stdio: [0, 1, 2],
|
|
537
|
+
});
|
|
503
538
|
}
|
|
504
539
|
function clearControllerLog() {
|
|
505
540
|
const dirPath = `${rootDir}tmp/log`;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
4
7
|
const node_fs_1 = require("node:fs");
|
|
5
8
|
// node_modules/@iobroker/legacy-testing/tests/testPackageFiles.js
|
|
6
9
|
const adapterDir = process.env.IOBROKER_ROOT_DIR || `${__dirname}/../../../../../`;
|
|
7
10
|
const alternativeAdapterDir = `${__dirname}/../../../../../`;
|
|
11
|
+
/** Assert that the value is neither `null` nor `undefined` */
|
|
12
|
+
function assertExists(value, message) {
|
|
13
|
+
node_assert_1.default.ok(value !== null && value !== undefined, message);
|
|
14
|
+
}
|
|
8
15
|
describe('Test package.json and io-package.json', () => {
|
|
9
16
|
it('Test package files', done => {
|
|
10
17
|
console.log();
|
|
@@ -12,34 +19,34 @@ describe('Test package.json and io-package.json', () => {
|
|
|
12
19
|
const ioPackage = JSON.parse(fileContentIOPackage);
|
|
13
20
|
const fileContentNPMPackage = (0, node_fs_1.readFileSync)(`${adapterDir}/package.json`, 'utf8');
|
|
14
21
|
const npmPackage = JSON.parse(fileContentNPMPackage);
|
|
15
|
-
(
|
|
16
|
-
(
|
|
17
|
-
(
|
|
18
|
-
(
|
|
19
|
-
|
|
22
|
+
node_assert_1.default.ok(ioPackage && typeof ioPackage === 'object', 'ERROR: io-package.json must contain an object');
|
|
23
|
+
node_assert_1.default.ok(npmPackage && typeof npmPackage === 'object', 'ERROR: package.json must contain an object');
|
|
24
|
+
assertExists(ioPackage.common.version, 'ERROR: Version number in io-package.json needs to exist');
|
|
25
|
+
assertExists(npmPackage.version, 'ERROR: Version number in package.json needs to exist');
|
|
26
|
+
node_assert_1.default.strictEqual(ioPackage.common.version, npmPackage.version, 'ERROR: Version numbers in package.json and io-package.json needs to match');
|
|
20
27
|
if (!ioPackage.common.news || !ioPackage.common.news[ioPackage.common.version]) {
|
|
21
28
|
console.log('WARNING: No news entry for current version exists in io-package.json, no rollback in Admin possible!');
|
|
22
29
|
console.log();
|
|
23
30
|
}
|
|
24
|
-
(
|
|
25
|
-
(
|
|
26
|
-
(
|
|
31
|
+
assertExists(npmPackage.author, 'ERROR: Author in package.json needs to exist');
|
|
32
|
+
assertExists(ioPackage.common.authors, 'ERROR: Authors in io-package.json needs to exist');
|
|
33
|
+
assertExists(ioPackage.common.license || ioPackage.common.licenseInformation?.license, 'ERROR: License missing in io-package in common.license or in common.licenseInformation.license');
|
|
27
34
|
if (ioPackage.common.name.includes('template')) {
|
|
28
35
|
if (Array.isArray(ioPackage.common.authors)) {
|
|
29
|
-
|
|
36
|
+
node_assert_1.default.notStrictEqual(ioPackage.common.authors.length, 0, 'ERROR: Author in io-package.json needs to be set');
|
|
30
37
|
if (ioPackage.common.authors.length === 1) {
|
|
31
|
-
|
|
38
|
+
node_assert_1.default.notStrictEqual(ioPackage.common.authors[0], 'my Name <my@email.com>', 'ERROR: Author in io-package.json needs to be a real name');
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
else {
|
|
35
|
-
|
|
42
|
+
node_assert_1.default.notStrictEqual(ioPackage.common.authors, 'my Name <my@email.com>', 'ERROR: Author in io-package.json needs to be a real name');
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
else {
|
|
39
46
|
console.log('WARNING: Testing for set authors field in io-package skipped because template adapter');
|
|
40
47
|
console.log();
|
|
41
48
|
}
|
|
42
|
-
|
|
49
|
+
node_assert_1.default.ok((0, node_fs_1.existsSync)(`${adapterDir}/README.md`) || (0, node_fs_1.existsSync)(`${alternativeAdapterDir}/README.md`), 'ERROR: README.md needs to exist! Please create one with description, detail information and changelog. English is mandatory.');
|
|
43
50
|
if (!ioPackage.common.titleLang || typeof ioPackage.common.titleLang !== 'object') {
|
|
44
51
|
console.log('WARNING: titleLang is not existing in io-package.json. Please add');
|
|
45
52
|
console.log();
|
|
@@ -53,18 +60,18 @@ describe('Test package.json and io-package.json', () => {
|
|
|
53
60
|
}
|
|
54
61
|
if (!ioPackage.common.controller && !ioPackage.common.onlyWWW && !ioPackage.common.noConfig) {
|
|
55
62
|
if (ioPackage.common.materialize || ioPackage.common.adminUI?.conifg === 'materialize') {
|
|
56
|
-
|
|
63
|
+
node_assert_1.default.ok((0, node_fs_1.existsSync)(`${adapterDir}/admin/index_m.html`), 'Admin3 support is enabled in io-package.json, but index_m.html is missing!');
|
|
57
64
|
}
|
|
58
65
|
if (ioPackage.common.jsonConfig || ioPackage.common.adminUI?.conifg === 'json') {
|
|
59
|
-
|
|
60
|
-
(0, node_fs_1.existsSync)(`${adapterDir}/admin/jsonConfig.json5`), 'Admin3 support is enabled in io-package.json, but jsonConfig.json(5) is missing!')
|
|
66
|
+
node_assert_1.default.ok((0, node_fs_1.existsSync)(`${adapterDir}/admin/jsonConfig.json`) ||
|
|
67
|
+
(0, node_fs_1.existsSync)(`${adapterDir}/admin/jsonConfig.json5`), 'Admin3 support is enabled in io-package.json, but jsonConfig.json(5) is missing!');
|
|
61
68
|
}
|
|
62
69
|
if (ioPackage.common.adminUI?.custom === 'json') {
|
|
63
|
-
|
|
64
|
-
(0, node_fs_1.existsSync)(`${adapterDir}/admin/jsonCustom.json5`), 'Custom config support is enabled in io-package.json, but jsonCustom.json(5) is missing!')
|
|
70
|
+
node_assert_1.default.ok((0, node_fs_1.existsSync)(`${adapterDir}/admin/jsonCustom.json`) ||
|
|
71
|
+
(0, node_fs_1.existsSync)(`${adapterDir}/admin/jsonCustom.json5`), 'Custom config support is enabled in io-package.json, but jsonCustom.json(5) is missing!');
|
|
65
72
|
}
|
|
66
73
|
if (ioPackage.common.adminUI?.tab === 'html') {
|
|
67
|
-
|
|
74
|
+
node_assert_1.default.ok((0, node_fs_1.existsSync)(`${adapterDir}/admin/tab.html`) || (0, node_fs_1.existsSync)(`${adapterDir}/admin/tab_m.html`), 'HTML-Tab support is enabled in io-package.json, but tab(_m).html is missing!');
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
const licenseFileExists = (0, node_fs_1.existsSync)(`${adapterDir}/LICENSE`);
|
|
@@ -75,7 +82,7 @@ describe('Test package.json and io-package.json', () => {
|
|
|
75
82
|
console.log('Warning: The README.md should have a section ## Changelog');
|
|
76
83
|
console.log();
|
|
77
84
|
}
|
|
78
|
-
|
|
85
|
+
node_assert_1.default.ok(licenseFileExists || fileContentReadme.includes('## License'), 'A LICENSE must exist as LICENSE file or as part of the README.md');
|
|
79
86
|
if (!licenseFileExists) {
|
|
80
87
|
console.log('Warning: The License should also exist as LICENSE file');
|
|
81
88
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "3.0.0",
|
|
3
3
|
"name": "@iobroker/legacy-testing",
|
|
4
4
|
"main": "build/setup.js",
|
|
5
5
|
"types": "build/setup.d.ts",
|
|
@@ -47,19 +47,17 @@
|
|
|
47
47
|
"email": "dogafox@gmail.com"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"mocha": "^11.
|
|
51
|
-
"chai": "^4.5.0"
|
|
50
|
+
"mocha": "^11.8.0"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
53
|
"@alcalzone/jsonl-db": "^4.0.2",
|
|
55
54
|
"@alcalzone/release-script": "^5.2.1",
|
|
56
|
-
"@alcalzone/release-script-plugin-license": "^5.2.
|
|
55
|
+
"@alcalzone/release-script-plugin-license": "^5.2.2",
|
|
57
56
|
"@iobroker/db-objects-redis": "^7.2.2",
|
|
58
57
|
"@iobroker/db-states-redis": "^7.2.2",
|
|
59
58
|
"@iobroker/eslint-config": "^2.3.4",
|
|
60
59
|
"@iobroker/types": "^7.2.2",
|
|
61
60
|
"@tsconfig/node18": "^18.2.6",
|
|
62
|
-
"@types/chai": "^4.3.20",
|
|
63
61
|
"@types/mocha": "^10.0.10",
|
|
64
62
|
"@types/node": "^18.19.130",
|
|
65
63
|
"typescript": "^6.0.3"
|