Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iobroker/adapter-core

Package Overview
Dependencies
Maintainers
5
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iobroker/adapter-core - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

13

build/index.d.ts

@@ -1,2 +0,11 @@

import * as utils from "./utils";
export = utils;
/// <reference types="iobroker" />
export * from "./utils";
/**
* Returns the absolute path of the data directory for the current host. On linux, this is usually `/opt/iobroker/iobroker-data`.
*/
export declare function getAbsoluteDefaultDataDir(): string;
/**
* Returns the absolute path of the data directory for the current adapter instance.
* On linux, this is usually `/opt/iobroker/iobroker-data/<adapterName>.<instanceNr>`
*/
export declare function getAbsoluteInstanceDataDir(adapterObject: ioBroker.Adapter): string;
"use strict";
/* eslint-disable @typescript-eslint/no-var-requires */
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
// Export all methods that used to be in utils.js
__export(require("./utils"));
const path = require("path");
const utils = require("./utils");
module.exports = utils;
// Export some additional utility methods
const controllerTools = require(path.join(utils.controllerDir, "lib/tools"));
/**
* Returns the absolute path of the data directory for the current host. On linux, this is usually `/opt/iobroker/iobroker-data`.
*/
function getAbsoluteDefaultDataDir() {
return path.join(utils.controllerDir, controllerTools.getDefaultDataDir());
}
exports.getAbsoluteDefaultDataDir = getAbsoluteDefaultDataDir;
/**
* Returns the absolute path of the data directory for the current adapter instance.
* On linux, this is usually `/opt/iobroker/iobroker-data/<adapterName>.<instanceNr>`
*/
function getAbsoluteInstanceDataDir(adapterObject) {
return path.join(getAbsoluteDefaultDataDir(), adapterObject.namespace);
}
exports.getAbsoluteInstanceDataDir = getAbsoluteInstanceDataDir;
// TODO: Expose some system utilities here, e.g. for installing npm modules (GH#1)

4

package.json
{
"name": "@iobroker/adapter-core",
"version": "2.0.0",
"version": "2.1.0",
"description": "Core module to be used in ioBroker adapters. Acts as the bridge to js-controller.",

@@ -40,3 +40,3 @@ "author": {

"@types/mocha": "^5.2.5",
"@types/node": "^12.0.0",
"@types/node": "^13.1.1",
"@types/proxyquire": "^1.3.28",

@@ -43,0 +43,0 @@ "@types/sinon": "^7.0.2",

@@ -20,5 +20,48 @@ # Adapter-Core

```js
// old style
const adapter = utils.adapter(/* options */);
// new style (classes). See https://github.com/ioBroker/ioBroker.template/ for a more detailed usage
class MyAdapter extends utils.Adapter {...}
```
## Utility methods
Compared to the old `utils.js`, some utility methods were added.
### `getAbsoluteDefaultDataDir`
```js
const dataDir = utils.getAbsoluteDefaultDataDir();
```
This returns the absolute path of the data directory for the current host. On linux, this is usually `/opt/iobroker/iobroker-data`
### `getAbsoluteInstanceDataDir`
```js
// old style
const instanceDataDir = utils.getAbsoluteInstanceDataDir(adapter);
// new style (classes)
const instanceDataDir = utils.getAbsoluteInstanceDataDir(this);
```
Returns the absolute path of the data directory for the current adapter instance.
On linux, this is usually `/opt/iobroker/iobroker-data/<adapterName>.<instanceNr>`
## Automatic backup of data files
ioBroker has the ability to include files written by adapters in its backups. To enable that, you need to add the following to `io-package.json`:
```json
{
// ...
"common": {
// ...
"dataFolder": "path/where/your/files/are"
}
}
```
This path is relative to the path returned by `getAbsoluteDefaultDataDir()`. The placeholder `%INSTANCE%` is automatically replaced by the instance number of each adapter, for example `"dataFolder": "my-adapter.%INSTANCE%"`.
## Tips while working on this module

@@ -25,0 +68,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc