@verdaccio/local-storage
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -44,6 +44,13 @@ 'use strict'; | ||
this.data = this._fetchLocalPackages(); | ||
this.data.secret = this.config.checkSecretKey(this.data.secret); | ||
this.sync(); | ||
this._sync(); | ||
} | ||
getSecret() { | ||
return this.data.secret; | ||
} | ||
setSecret(secret) { | ||
this.data.secret = secret; | ||
} | ||
/** | ||
@@ -57,3 +64,3 @@ * Add a new element. | ||
this.data.list.push(name); | ||
return this.sync(); | ||
return this._sync(); | ||
} | ||
@@ -73,3 +80,3 @@ } | ||
return this.sync(); | ||
return this._sync(); | ||
} | ||
@@ -89,3 +96,3 @@ | ||
*/ | ||
sync() { | ||
_sync() { | ||
if (this.locked) { | ||
@@ -145,4 +152,7 @@ this.logger.error('Database is locked, please check error message printed during startup to prevent data loss.'); | ||
_buildStoragePath(config) { | ||
// FUTURE: the database might be parameterizable from config.yaml | ||
return _path2.default.join(_path2.default.resolve(_path2.default.dirname(config.self_path || ''), config.storage, '.sinopia-db.json')); | ||
const selfPath = _path2.default.resolve(_path2.default.dirname(config.self_path || '')); | ||
// $FlowFixMe | ||
const storagePath = _path2.default.join(selfPath, config.storage, config.databaseName || '.sinopia-db.json'); | ||
return storagePath; | ||
} | ||
@@ -199,5 +209,4 @@ | ||
} | ||
} | ||
exports.default = LocalDatabase; |
@@ -92,16 +92,16 @@ 'use strict'; | ||
/** | ||
* This function allows to update the package thread-safely | ||
Algorithm: | ||
1. lock package.json for writing | ||
2. read package.json | ||
3. updateFn(pkg, cb), and wait for cb | ||
4. write package.json.tmp | ||
5. move package.json.tmp package.json | ||
6. callback(err?) | ||
* @param {*} name | ||
* @param {*} updateHandler | ||
* @param {*} onWrite | ||
* @param {*} transformPackage | ||
* @param {*} onEnd | ||
*/ | ||
* This function allows to update the package thread-safely | ||
Algorithm: | ||
1. lock package.json for writing | ||
2. read package.json | ||
3. updateFn(pkg, cb), and wait for cb | ||
4. write package.json.tmp | ||
5. move package.json.tmp package.json | ||
6. callback(err?) | ||
* @param {*} name | ||
* @param {*} updateHandler | ||
* @param {*} onWrite | ||
* @param {*} transformPackage | ||
* @param {*} onEnd | ||
*/ | ||
updatePackage(name, updateHandler, onWrite, transformPackage, onEnd) { | ||
@@ -348,5 +348,4 @@ this._lockAndReadJSON(pkgFileName, (err, json) => { | ||
} | ||
} | ||
exports.default = LocalFS; |
{ | ||
"name": "@verdaccio/local-storage", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "local storage implementation", | ||
@@ -14,2 +14,3 @@ "main": "lib/index.js", | ||
"prepublish": "npm run build", | ||
"format": "prettier --single-quote --trailing-comma none --write \"{src,test}/**/*.js\"", | ||
"cover": "cross-env NODE_ENV=test nyc npm t" | ||
@@ -28,3 +29,3 @@ }, | ||
"@commitlint/config-conventional": "^6.0.2", | ||
"@verdaccio/types": "^2.0.0", | ||
"@verdaccio/types": "^2.0.4", | ||
"babel-cli": "6.26.0", | ||
@@ -37,3 +38,3 @@ "babel-core": "6.26.0", | ||
"babel-preset-flow": "6.23.0", | ||
"flow-bin": "0.66.0", | ||
"flow-bin": "0.69.0", | ||
"flow-runtime": "0.17.0", | ||
@@ -44,4 +45,7 @@ "cross-env": "5.1.3", | ||
"eslint-plugin-flowtype": "2.46.1", | ||
"eslint-config-prettier": "2.9.0", | ||
"eslint-plugin-prettier": "2.5.0", | ||
"eslint-plugin-jest": "21.12.3", | ||
"husky": "^0.14.3", | ||
"prettier": "1.10.2", | ||
"jest": "22.4.2", | ||
@@ -48,0 +52,0 @@ "rmdir-sync": "1.0.1", |
@@ -1,2 +0,45 @@ | ||
# local-storage | ||
Local storage is an implementation to store packages in a file system | ||
# @verdaccio/local-storage | ||
📦 File system storage plugin for verdaccio | ||
[![CircleCI](https://circleci.com/gh/verdaccio/local-storage/tree/master.svg?style=svg)](https://circleci.com/gh/verdaccio/local-storage/tree/master) | ||
[![Backers on Open Collective](https://opencollective.com/verdaccio/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/verdaccio/sponsors/badge.svg)](#sponsors) | ||
[![Gitter chat](https://badges.gitter.im/verdaccio/questions.png)](https://gitter.im/verdaccio/) | ||
[![dependencies Status](https://david-dm.org/verdaccio/local-storage/status.svg)](https://david-dm.org/verdaccio/local-storage) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/verdaccio/local-storage/badge.svg?targetFile=package.json)](https://snyk.io/test/github/verdaccio/local-storage?targetFile=package.json) | ||
[![codecov](https://codecov.io/gh/verdaccio/local-storage/branch/master/graph/badge.svg)](https://codecov.io/gh/verdaccio/local-storage) | ||
> This package is already built-in in verdaccio | ||
``` | ||
npm install @verdaccio/local-storage | ||
``` | ||
### API | ||
### LocalDatabase | ||
The main object that handle a JSON database the private packages. | ||
#### Constructor | ||
``` | ||
new LocalDatabase(config, logger); | ||
``` | ||
* **config**: A verdaccio configuration instance. | ||
* **logger**: A logger instance | ||
### LocalFS | ||
A class that handle an package instance in the File System | ||
``` | ||
new LocalFS(packageStoragePath, logger); | ||
``` | ||
## License | ||
Verdaccio is [MIT licensed](https://github.com/verdaccio/local-storage/blob/master/LICENSE). |
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
20840
11
500
46
24