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

balena-settings-storage

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balena-settings-storage - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1-flowzonify-33262bd764f9e88cd566bf49939bb017ac7dd47b-1

.github/workflows/flowzone.yml

4

build/local-storage.js

@@ -96,3 +96,5 @@ "use strict";

// Fallback to filesystem based storage if not in the browser.
const { NodeStorage, } = require('./node-storage');
const { NodeStorage,
// tslint:disable-next-line no-var-requires
} = require('./node-storage');
const storageCache = Object.create(null);

@@ -99,0 +101,0 @@ exports.createStorage = createStorage = (dataDirectory) => {

@@ -39,3 +39,3 @@ "use strict";

const getStorage = ({ dataDirectory, } = {}) => {
const localStorage = local_storage_1.createStorage(dataDirectory);
const localStorage = (0, local_storage_1.createStorage)(dataDirectory);
/**

@@ -42,0 +42,0 @@ * @summary Set a value

@@ -7,4 +7,10 @@ # Change Log

# v7.0.1
## (2022-11-01)
* Fix tests on node18 [Thodoris Greasidis]
* Replace balenaCI with flowzone [JSReds]
# v7.0.0
## (2020-11-04)
## (2020-11-03)

@@ -11,0 +17,0 @@ * Remove package-lock.json because it is not recommended for libraries 'package-lock.json' cannot be published to the npm registry, and will be ignored when npm-installed by packages that depend on resin-multibuild. This can lead to dependency-related errors being masked when resin-multibuild is tested in isolation. Reference: https://docs.npmjs.com/files/package-lock.json [josecoelho]

@@ -1,12 +0,16 @@

const packageJSON = require('./package.json')
const getKarmaConfig = require('balena-config-karma')
const getKarmaConfig = require('balena-config-karma');
const packageJSON = require('./package.json');
module.exports = (config) => {
const karmaConfig = getKarmaConfig(packageJSON)
karmaConfig.webpack.node = {
global: true,
fs: 'empty',
process: 'mock'
const karmaConfig = getKarmaConfig(packageJSON);
// polyfill required for balena-settings-client
karmaConfig.webpack.resolve.fallback = {
fs: false,
os: false,
path: false,
process: false,
util: false,
};
config.set(karmaConfig)
}
config.set(karmaConfig);
};

@@ -47,3 +47,5 @@ /*

await Promise.all(
(await fs.readdir(this.dataDirectory)).map(async (f) => {
(
await fs.readdir(this.dataDirectory)
).map(async (f) => {
f = path.join(this.dataDirectory, f);

@@ -68,3 +70,3 @@ try {

return await fs.readFile(this.getPath(key), 'utf8');
} catch (err) {
} catch (err: any) {
if (err.code === 'EACCES') {

@@ -71,0 +73,0 @@ throw err;

@@ -100,3 +100,3 @@ /*

return result;
} catch (err) {
} catch (err: any) {
if (err.code === 'EACCES') {

@@ -103,0 +103,0 @@ throw new BalenaSettingsPermissionError(err);

{
"name": "balena-settings-storage",
"version": "7.0.0",
"version": "7.0.1-flowzonify-33262bd764f9e88cd566bf49939bb017ac7dd47b-1",
"description": "Balena settings storage utilities",

@@ -27,3 +27,2 @@ "main": "build/storage.js",

"build": "rimraf ./build && npm run prettify && tsc && npm run readme",
"prepublish": "require-npm4-to-publish",
"prepack": "npm run build",

@@ -37,14 +36,17 @@ "prettify": "balena-lint --typescript --fix lib tests",

"@balena/lint": "^5.1.0",
"@resin.io/types-mochainon": "^2.0.1",
"@types/mocha": "^2.2.41",
"balena-config-karma": "^3.0.0",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
"@types/mocha": "^9.1.1",
"@types/sinon": "^10.0.11",
"balena-config-karma": "^4.0.0",
"balena-settings-client": "^4.0.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"jsdoc-to-markdown": "^3.0.0",
"karma": "^3.1.4",
"mocha": "^3.5.0",
"mochainon": "^2.0.0",
"require-npm4-to-publish": "^1.0.0",
"karma": "^5.2.3",
"mocha": "^10.0.0",
"rimraf": "^2.6.1",
"ts-node": "^3.3.0",
"typescript": "^3.9.6"
"sinon": "^13.0.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
},

@@ -58,3 +60,6 @@ "dependencies": {

"node": ">=10.17.0"
},
"versionist": {
"publishedAt": "2022-11-01T18:03:04.495Z"
}
}

@@ -38,4 +38,4 @@ balena-settings-storage

* [~set(name, value)](#module_storage.getStorage..set) ⇒ <code>Promise</code>
* [~get(name)](#module_storage.getStorage..get) ⇒ <code>Promise.&lt;\*&gt;</code>
* [~has(name)](#module_storage.getStorage..has) ⇒ <code>Promise.&lt;Boolean&gt;</code>
* [~get(name)](#module_storage.getStorage..get) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;\*&gt;</code>
* [~has(name)](#module_storage.getStorage..has) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code>
* [~remove(name)](#module_storage.getStorage..remove) ⇒ <code>Promise</code>

@@ -65,4 +65,4 @@ * [~clear()](#module_storage.getStorage..clear) ⇒ <code>Promise</code>

* [~set(name, value)](#module_storage.getStorage..set) ⇒ <code>Promise</code>
* [~get(name)](#module_storage.getStorage..get) ⇒ <code>Promise.&lt;\*&gt;</code>
* [~has(name)](#module_storage.getStorage..has) ⇒ <code>Promise.&lt;Boolean&gt;</code>
* [~get(name)](#module_storage.getStorage..get) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;\*&gt;</code>
* [~has(name)](#module_storage.getStorage..has) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code>
* [~remove(name)](#module_storage.getStorage..remove) ⇒ <code>Promise</code>

@@ -89,6 +89,6 @@ * [~clear()](#module_storage.getStorage..clear) ⇒ <code>Promise</code>

#### getStorage~get(name) ⇒ <code>Promise.&lt;\*&gt;</code>
#### getStorage~get(name) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;\*&gt;</code>
**Kind**: inner method of [<code>getStorage</code>](#module_storage.getStorage)
**Summary**: Get a value
**Returns**: <code>Promise.&lt;\*&gt;</code> - value or undefined
**Returns**: <code>[ &#x27;Promise&#x27; ].&lt;\*&gt;</code> - value or undefined
**Access**: public

@@ -108,6 +108,6 @@

#### getStorage~has(name) ⇒ <code>Promise.&lt;Boolean&gt;</code>
#### getStorage~has(name) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code>
**Kind**: inner method of [<code>getStorage</code>](#module_storage.getStorage)
**Summary**: Check if the value exists
**Returns**: <code>Promise.&lt;Boolean&gt;</code> - has value
**Returns**: <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code> - has value
**Access**: public

@@ -114,0 +114,0 @@

@@ -0,3 +1,3 @@

import { expect } from 'chai';
import * as BalenaSettingsClientModule from 'balena-settings-client';
import * as m from 'mochainon';

@@ -19,9 +19,9 @@ import { createStorage } from '../lib/local-storage';

it('should expose a function called getItem()', () =>
m.chai.expect(localStorage.getItem).to.be.an.instanceof(Function));
expect(localStorage.getItem).to.be.an.instanceof(Function));
it('should expose a function called setItem()', () =>
m.chai.expect(localStorage.setItem).to.be.an.instanceof(Function));
expect(localStorage.setItem).to.be.an.instanceof(Function));
it('should expose a function called removeItem()', () =>
m.chai.expect(localStorage.removeItem).to.be.an.instanceof(Function));
expect(localStorage.removeItem).to.be.an.instanceof(Function));
});

@@ -0,6 +1,10 @@

import * as chai from 'chai';
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as chaiAsPromised from 'chai-as-promised';
import * as BalenaSettingsClientModule from 'balena-settings-client';
import * as FsModule from 'fs';
import * as m from 'mochainon';
import * as path from 'path';
import { BalenaSettingsPermissionError } from 'balena-errors';
chai.use(chaiAsPromised);

@@ -34,3 +38,3 @@ import { createStorage } from '../lib/local-storage';

storage.set('pi', 3.14).then(() => {
return m.chai.expect(storage.get('pi')).to.eventually.equal(3.14);
return expect(storage.get('pi')).to.eventually.equal(3.14);
}));

@@ -40,3 +44,3 @@

storage.set('age', 34).then(() => {
return m.chai.expect(storage.get('age')).to.eventually.equal(34);
return expect(storage.get('age')).to.eventually.equal(34);
}));

@@ -46,3 +50,3 @@

storage.set('pi', 'pi=3.14').then(() => {
return m.chai.expect(storage.get('pi')).to.eventually.equal('pi=3.14');
return expect(storage.get('pi')).to.eventually.equal('pi=3.14');
}));

@@ -54,5 +58,5 @@ });

storage.set('pi', { value: 3.14 }).then(() => {
return m.chai
.expect(storage.get('pi'))
.to.eventually.deep.equal({ value: 3.14 });
return expect(storage.get('pi')).to.eventually.deep.equal({
value: 3.14,
});
}));

@@ -62,3 +66,3 @@

storage.set('empty', {}).then(() => {
return m.chai.expect(storage.get('empty')).to.eventually.deep.equal({});
return expect(storage.get('empty')).to.eventually.deep.equal({});
}));

@@ -70,10 +74,7 @@ });

it('should be able to set a value', () => {
return m.chai
.expect(storage.get('foobar'))
return expect(storage.get('foobar'))
.to.eventually.equal(undefined)
.then(() => storage.set('foobar', 'Hello'))
.then(() => {
return m.chai
.expect(storage.get('foobar'))
.to.eventually.equal('Hello');
return expect(storage.get('foobar')).to.eventually.equal('Hello');
});

@@ -89,8 +90,7 @@ });

it('should be able to change the value', () => {
return m.chai
.expect(storage.get('foobar'))
return expect(storage.get('foobar'))
.to.eventually.equal('Hello')
.then(() => storage.set('foobar', 'World'))
.then(() =>
m.chai.expect(storage.get('foobar')).to.eventually.equal('World'),
expect(storage.get('foobar')).to.eventually.equal('World'),
);

@@ -104,3 +104,3 @@ });

it('should eventually be undefined', () =>
m.chai.expect(storage.get('foobar')).to.eventually.equal(undefined));
expect(storage.get('foobar')).to.eventually.equal(undefined));
});

@@ -112,3 +112,3 @@

it('should eventually be the value', () =>
m.chai.expect(storage.get('foobar')).to.eventually.equal('Hello'));
expect(storage.get('foobar')).to.eventually.equal('Hello'));
});

@@ -119,3 +119,3 @@

beforeEach(() => {
getItemStub = m.sinon.stub(localStorage, 'getItem');
getItemStub = sinon.stub(localStorage, 'getItem');
getItemStub.throws(new Error('ENOENT'));

@@ -129,3 +129,3 @@ });

it('should eventually be undefined', () =>
m.chai.expect(storage.get('foobar')).to.eventually.equal(undefined));
expect(storage.get('foobar')).to.eventually.equal(undefined));
});

@@ -151,3 +151,3 @@

it('should be able to read back', () =>
m.chai.expect(storage.get('foo')).to.eventually.equal('hello world'));
expect(storage.get('foo')).to.eventually.equal('hello world'));
});

@@ -158,3 +158,3 @@

beforeEach(() => {
fsReadFileStub = m.sinon.stub(fs.promises, 'readFile');
fsReadFileStub = sinon.stub(fs.promises, 'readFile');
fsReadFileStub.rejects({ code: 'EACCES' });

@@ -168,5 +168,5 @@ });

it('should raise an error', () => {
return m.chai
.expect(storage.get('bar'))
.to.eventually.be.rejectedWith(BalenaSettingsPermissionError);
return expect(storage.get('bar')).to.eventually.be.rejectedWith(
BalenaSettingsPermissionError,
);
});

@@ -180,3 +180,3 @@ });

it('should eventually be false', () =>
m.chai.expect(storage.has('foobar')).to.eventually.equal(false));
expect(storage.has('foobar')).to.eventually.equal(false));
});

@@ -188,3 +188,3 @@

it('should eventually be true', () =>
m.chai.expect(storage.has('foobar')).to.eventually.equal(true));
expect(storage.has('foobar')).to.eventually.equal(true));
});

@@ -196,8 +196,6 @@ });

it('should do nothing', () => {
m.chai.expect(storage.has('foobar')).to.eventually.equal(false);
expect(storage.has('foobar')).to.eventually.equal(false);
return storage
.remove('foobar')
.then(() =>
m.chai.expect(storage.has('foobar')).to.eventually.equal(false),
);
.then(() => expect(storage.has('foobar')).to.eventually.equal(false));
});

@@ -210,9 +208,6 @@ });

it('should remove the key', () => {
return m.chai
.expect(storage.has('foobar'))
return expect(storage.has('foobar'))
.to.eventually.equal(true)
.then(() => storage.remove('foobar'))
.then(() =>
m.chai.expect(storage.has('foobar')).to.eventually.equal(false),
);
.then(() => expect(storage.has('foobar')).to.eventually.equal(false));
});

@@ -219,0 +214,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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