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

@verdaccio/local-storage

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@verdaccio/local-storage - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

3

lib/local-data.js

@@ -43,4 +43,5 @@ 'use strict';

*/
constructor(path) {
constructor(path, logger) {
this.path = path;
this.logger = logger;
try {

@@ -47,0 +48,0 @@ this.data = JSON.parse((_fs || _load_fs()).default.readFileSync(this.path, 'utf8'));

@@ -7,8 +7,2 @@ 'use strict';

var _toConsumableArray2;
function _load_toConsumableArray() {
return _toConsumableArray2 = _interopRequireDefault(require('babel-runtime/helpers/toConsumableArray'));
}
var _promise;

@@ -38,2 +32,8 @@

var _lodash;
function _load_lodash() {
return _lodash = _interopRequireDefault(require('lodash'));
}
var _mkdirp;

@@ -66,2 +66,3 @@

const fileExist = 'EEXISTS';
const noSuchFile = 'ENOENT';

@@ -108,28 +109,25 @@

constructor(path) {
constructor(path, logger) {
this.path = path;
this.logger = logger;
}
unlink(fileName, callback) {
return (_fs || _load_fs()).default.unlink(fileName, callback);
return (_fs || _load_fs()).default.unlink(this._getStorage(fileName), callback);
}
rmdir(dirPath, callback) {
(_fs || _load_fs()).default.rmdir(dirPath, callback);
(_fs || _load_fs()).default.rmdir(this._getStorage(dirPath), callback);
}
_getStorage(name) {
return (_path || _load_path()).default.join(this.path, name || '');
}
createJSON(name, value, cb) {
this.createFile(this._getStorage(name), (0, (_stringify || _load_stringify()).default)(value, null, '\t'), cb);
this._createFile(this._getStorage(name), (0, (_stringify || _load_stringify()).default)(value, null, '\t'), cb);
}
updateJSON(name, value, cb) {
this.updateFile(this._getStorage(name), (0, (_stringify || _load_stringify()).default)(value, null, '\t'), cb);
this._updateFile(this._getStorage(name), (0, (_stringify || _load_stringify()).default)(value, null, '\t'), cb);
}
writeJSON(name, value, cb) {
this.writeFile(this._getStorage(name), (0, (_stringify || _load_stringify()).default)(value, null, '\t'), cb);
this._writeFile(this._getStorage(name), (0, (_stringify || _load_stringify()).default)(value, null, '\t'), cb);
}

@@ -139,3 +137,3 @@

return new (_promise || _load_promise()).default((resolve, reject) => {
(_fs || _load_fs()).default.readFile(this._getStorage(name), (err, data) => {
(_fs || _load_fs()).default.readFile(name, (err, data) => {
if (err) {

@@ -151,3 +149,3 @@ reject(err);

lock_and_read(name, cb) {
(0, (_fileLocking || _load_fileLocking()).readFile)(name, { lock: true }, function (err, res) {
(0, (_fileLocking || _load_fileLocking()).readFile)(this._getStorage(name), { lock: true }, function (err, res) {
if (err) {

@@ -161,3 +159,3 @@ return cb(err);

lockAndReadJSON(name, cb) {
(0, (_fileLocking || _load_fileLocking()).readFile)(name, {
(0, (_fileLocking || _load_fileLocking()).readFile)(this._getStorage(name), {
lock: true,

@@ -174,6 +172,6 @@ parse: true

unlock_file(name, cb) {
(0, (_fileLocking || _load_fileLocking()).unlockFile)(name, cb);
(0, (_fileLocking || _load_fileLocking()).unlockFile)(this._getStorage(name), cb);
}
createFile(name, contents, callback) {
_createFile(name, contents, callback) {
(_fs || _load_fs()).default.exists(name, exists => {

@@ -183,7 +181,8 @@ if (exists) {

}
this.writeFile(name, contents, callback);
this._writeFile(name, contents, callback);
});
}
updateFile(name, contents, callback) {
_updateFile(name, contents, callback) {
this.logger.debug('_updateFile:pathName', name);
(_fs || _load_fs()).default.exists(name, exists => {

@@ -193,3 +192,3 @@ if (!exists) {

}
this.writeFile(name, contents, callback);
this._writeFile(name, contents, callback);
});

@@ -199,10 +198,10 @@ }

readJSON(name, cb) {
this.readStorageFile(name).then(function (res) {
let args = [];
this.readStorageFile(this._getStorage(name)).then(function (res) {
try {
args = [null, JSON.parse(res.toString('utf8'))];
const data = JSON.parse(res.toString('utf8'));
cb(null, data);
} catch (err) {
args = [err];
cb(err);
}
cb.apply(undefined, (0, (_toConsumableArray2 || _load_toConsumableArray()).default)(args));
}, function (err) {

@@ -215,2 +214,3 @@ return cb(err);

const uploadStream = new (_streams || _load_streams()).UploadTarball();
let _ended = 0;

@@ -221,3 +221,5 @@ uploadStream.on('end', function () {

(_fs || _load_fs()).default.exists(name, function (exists) {
const pathName = this._getStorage(name);
(_fs || _load_fs()).default.exists(pathName, function (exists) {
if (exists) {

@@ -235,3 +237,3 @@ return uploadStream.emit('error', fSError(fileExist));

file.on('close', function () {
renameTmp(temporalName, name, function (err) {
renameTmp(temporalName, pathName, function (err) {
if (err) {

@@ -276,3 +278,5 @@ uploadStream.emit('error', err);

let readStream = (_fs || _load_fs()).default.createReadStream(name);
const pathName = this._getStorage(name);
let readStream = (_fs || _load_fs()).default.createReadStream(pathName);
readStream.on('error', function (err) {

@@ -283,3 +287,5 @@ readTarballStream.emit('error', err);

(_fs || _load_fs()).default.fstat(fd, function (err, stats) {
if (err) return readTarballStream.emit('error', err);
if ((_lodash || _load_lodash()).default.isNil(err) === false) {
return readTarballStream.emit('error', err);
}
readTarballStream.emit('content-length', stats.size);

@@ -298,5 +304,14 @@ readTarballStream.emit('open');

writeFile(dest, data, cb) {
const createTempFile = function createTempFile(cb) {
_getStorage() {
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
const storagePath = (_path || _load_path()).default.join(this.path, name);
return storagePath;
}
_writeFile(dest, data, cb) {
const createTempFile = cb => {
const tempFilePath = tempFile(dest);
(_fs || _load_fs()).default.writeFile(tempFilePath, data, function (err) {

@@ -310,3 +325,3 @@ if (err) {

createTempFile(function (err) {
createTempFile(err => {
if (err && err.code === noSuchFile) {

@@ -313,0 +328,0 @@ (0, (_mkdirp || _load_mkdirp()).default)((_path || _load_path()).default.dirname(dest), function (err) {

@@ -118,3 +118,3 @@ 'use strict';

this.utils = utils;
this.localList = new (_localData || _load_localData()).default(this._buildStoragePath(this.config));
this.localList = new (_localData || _load_localData()).default(this._buildStoragePath(this.config), logger);
this.logger = logger.child({ sub: 'fs' });

@@ -520,3 +520,3 @@ }

// check if package exists to throw an appropriate message
this.getPackageMetadata(name, {}, function (_err, res) {
this.getPackageMetadata(name, function (_err, res) {
if (_err) {

@@ -650,4 +650,3 @@ uploadStream.emit('error', _err);

getPackageMetadata(name) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let callback = arguments[2];
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => {};

@@ -698,3 +697,3 @@

if (stats.mtimeMs > parseInt(startKey, 10)) {
this.getPackageMetadata(item.name, options, (err, data) => {
this.getPackageMetadata(item.name, (err, data) => {
if (err) {

@@ -759,3 +758,3 @@ return cb(err);

return new (_localFs || _load_localFs()).default(storagePath);
return new (_localFs || _load_localFs()).default(storagePath, this.logger);
}

@@ -762,0 +761,0 @@

{
"name": "@verdaccio/local-storage",
"version": "0.0.1",
"version": "0.0.2",
"description": "local storage implementation",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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