@verdaccio/local-storage
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/verdaccio/local-storage/compare/v1.0.3...v1.1.0) (2018-06-08) | ||
### Bug Fixes | ||
* **deps:** update dependency async to v2.6.1 ([487b095](https://github.com/verdaccio/local-storage/commit/487b095)) | ||
### Features | ||
* implement search ([f884a24](https://github.com/verdaccio/local-storage/commit/f884a24)) | ||
<a name="0.2.0"></a> | ||
@@ -7,0 +22,0 @@ # [0.2.0](https://github.com/verdaccio/local-storage/compare/v0.1.4...v0.2.0) (2018-01-17) |
@@ -23,2 +23,6 @@ 'use strict'; | ||
var _async = require('async'); | ||
var _async2 = _interopRequireDefault(_async); | ||
var _mkdirp = require('mkdirp'); | ||
@@ -33,2 +37,4 @@ | ||
*/ | ||
// $FlowFixMe | ||
class LocalDatabase { | ||
@@ -74,2 +80,69 @@ | ||
search(onPackage, onEnd, validateName) { | ||
const storages = this._getCustomPackageLocalStorages(); | ||
const base = _path2.default.dirname(this.config.self_path); | ||
_async2.default.eachSeries(Object.keys(storages), function (storage, cb) { | ||
_fs2.default.readdir(_path2.default.resolve(base, storage), function (err, files) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
_async2.default.eachSeries(files, function (file, cb) { | ||
if (file.match(/^@/)) { | ||
// scoped | ||
_fs2.default.readdir(_path2.default.resolve(base, storage, file), function (err, files) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
_async2.default.eachSeries(files, (file2, cb) => { | ||
if (validateName(file2)) { | ||
const item = { | ||
name: `${file}/${file2}`, | ||
path: _path2.default.resolve(base, storage, file, file2) | ||
}; | ||
onPackage(item, cb); | ||
} else { | ||
cb(); | ||
} | ||
}, cb); | ||
}); | ||
} else if (validateName(file)) { | ||
onPackage({ | ||
name: file, | ||
path: _path2.default.resolve(base, storage, file) | ||
}, cb); | ||
} else { | ||
cb(); | ||
} | ||
}, cb); | ||
}); | ||
}, onEnd); | ||
} | ||
_getCustomPackageLocalStorages() { | ||
const storages = {}; | ||
// add custom storage if exist | ||
if (this.config.storage) { | ||
storages[this.config.storage] = true; | ||
} | ||
const packages = this.config.packages; | ||
if (packages) { | ||
const listPackagesConf = Object.keys(packages || {}); | ||
listPackagesConf.map(pkg => { | ||
if (packages[pkg].storage) { | ||
storages[packages[pkg].storage] = true; | ||
} | ||
}); | ||
} | ||
return storages; | ||
} | ||
/** | ||
@@ -76,0 +149,0 @@ * Remove an element from the database. |
@@ -298,4 +298,4 @@ 'use strict'; | ||
_getStorage(name = '') { | ||
const storagePath = _path2.default.join(this.path, name); | ||
_getStorage(fileName = '') { | ||
const storagePath = _path2.default.join(this.path, fileName); | ||
@@ -302,0 +302,0 @@ return storagePath; |
{ | ||
"name": "@verdaccio/local-storage", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "local storage implementation", | ||
@@ -20,3 +20,3 @@ "main": "lib/index.js", | ||
"@verdaccio/streams": "1.0.0", | ||
"async": "2.6.0", | ||
"async": "2.6.1", | ||
"http-errors": "1.6.2", | ||
@@ -29,3 +29,3 @@ "lodash": "4.17.10", | ||
"@commitlint/config-conventional": "6.1.3", | ||
"@verdaccio/types": "2.2.0", | ||
"@verdaccio/types": "3.0.0", | ||
"babel-cli": "6.26.0", | ||
@@ -32,0 +32,0 @@ "babel-core": "6.26.0", |
@@ -12,2 +12,3 @@ # @verdaccio/local-storage | ||
[![codecov](https://codecov.io/gh/verdaccio/local-storage/branch/master/graph/badge.svg)](https://codecov.io/gh/verdaccio/local-storage) | ||
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fverdaccio%2Flocal-storage.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fverdaccio%2Flocal-storage?ref=badge_shield) | ||
@@ -47,1 +48,4 @@ > This package is already built-in in verdaccio | ||
Verdaccio is [MIT licensed](https://github.com/verdaccio/local-storage/blob/master/LICENSE). | ||
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fverdaccio%2Flocal-storage.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fverdaccio%2Flocal-storage?ref=badge_large) |
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
23720
567
49
+ Addedasync@2.6.1(transitive)
- Removedasync@2.6.0(transitive)
Updatedasync@2.6.1