@iobroker/adapter-core
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -62,3 +62,3 @@ "use strict"; | ||
const importPaths = [ | ||
// Attempt 1: JS-Controller 5.1+ | ||
// Attempt 1: JS-Controller 6+ | ||
path.join(utils.controllerDir, "build/cjs/lib", name), | ||
@@ -65,0 +65,0 @@ // Attempt 2: JS-Controller 4.1+ |
@@ -37,19 +37,7 @@ "use strict"; | ||
function resolveAdapterConstructor() { | ||
const adapterPaths = [ | ||
// Attempt 1: Resolve @iobroker/js-controller-adapter from here - JS-Controller 4.1+ | ||
(0, helpers_1.tryResolvePackage)(["@iobroker/js-controller-adapter"]), | ||
// Attempt 2: Resolve @iobroker/js-controller-adapter in JS-Controller dir - JS-Controller 4.1+ | ||
(0, helpers_1.tryResolvePackage)(["@iobroker/js-controller-adapter"], [path.join(exports.controllerDir, "node_modules")]), | ||
// Attempt 3: JS-Controller 4.1+ with adapter stub | ||
path.join(exports.controllerDir, "build/lib/adapter.js"), | ||
// Attempt 4: JS-Controller 5.1+ with adapter stub | ||
path.join(exports.controllerDir, "build/cjs/lib/adapter.js"), | ||
// Attempt 5: Legacy resolve - until JS-Controller 4.0 | ||
path.join(exports.controllerDir, "lib/adapter.js"), | ||
]; | ||
for (const adapterPath of adapterPaths) { | ||
if (!adapterPath) | ||
continue; | ||
// Attempt 1: Resolve @iobroker/js-controller-adapter from here - JS-Controller 4.1+ | ||
let adapterPath = (0, helpers_1.tryResolvePackage)(["@iobroker/js-controller-adapter"]); | ||
if (adapterPath) { | ||
try { | ||
const Adapter = require(adapterPath); | ||
const { Adapter } = require(adapterPath); | ||
if (Adapter) | ||
@@ -62,2 +50,47 @@ return Adapter; | ||
} | ||
// Attempt 2: Resolve @iobroker/js-controller-adapter in JS-Controller dir - JS-Controller 4.1+ | ||
adapterPath = (0, helpers_1.tryResolvePackage)(["@iobroker/js-controller-adapter"], [path.join(exports.controllerDir, "node_modules")]); | ||
if (adapterPath) { | ||
try { | ||
const { Adapter } = require(adapterPath); | ||
if (Adapter) | ||
return Adapter; | ||
} | ||
catch (_b) { | ||
// did not work, continue | ||
} | ||
} | ||
// Attempt 3: JS-Controller 6+ with adapter stub | ||
adapterPath = path.join(exports.controllerDir, "build/cjs/lib/adapter.js"); | ||
try { | ||
// This was a default export prior to the TS migration | ||
const Adapter = require(adapterPath); | ||
if (Adapter) | ||
return Adapter; | ||
} | ||
catch (_c) { | ||
// did not work, continue | ||
} | ||
// Attempt 4: JS-Controller 4.1+ with adapter stub | ||
adapterPath = path.join(exports.controllerDir, "build/lib/adapter.js"); | ||
try { | ||
// This was a default export prior to the TS migration | ||
const Adapter = require(adapterPath); | ||
if (Adapter) | ||
return Adapter; | ||
} | ||
catch (_d) { | ||
// did not work, continue | ||
} | ||
// Attempt 5: Legacy resolve - until JS-Controller 4.0 | ||
adapterPath = path.join(exports.controllerDir, "lib/adapter.js"); | ||
try { | ||
// This was a default export prior to the TS migration | ||
const Adapter = require(adapterPath); | ||
if (Adapter) | ||
return Adapter; | ||
} | ||
catch (_e) { | ||
// did not work, continue | ||
} | ||
throw new Error("Cannot resolve adapter class"); | ||
@@ -64,0 +97,0 @@ return process.exit(10); |
{ | ||
"name": "@iobroker/adapter-core", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Core module to be used in ioBroker adapters. Acts as the bridge to js-controller.", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -116,2 +116,6 @@ # Adapter-Core | ||
--> | ||
### 3.0.6 (2024-03-24) | ||
- (foxriver76) hotfix previous release: compatibility with next controller with new esm/cjs exports | ||
### 3.0.5 (2024-03-24) | ||
@@ -118,0 +122,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34419
552
231
12