verdaccio-memory
Advanced tools
Comparing version 10.3.0 to 10.3.1
@@ -13,9 +13,6 @@ "use strict"; | ||
exports.default = void 0; | ||
var _localMemory = _interopRequireDefault(require("./local-memory")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = _localMemory.default; | ||
exports.default = _default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Logger, Callback, Config, IPluginStorage, Token, TokenFilter, PluginOptions } from '@verdaccio/types'; | ||
import { Logger, Callback, Config, IPluginStorage, Token, TokenFilter, PluginOptions } from '@verdaccio/legacy-types'; | ||
import MemoryHandler, { DataHandler } from './memory-handler'; | ||
@@ -3,0 +3,0 @@ export declare type ConfigMemory = Config & { |
@@ -7,25 +7,8 @@ "use strict"; | ||
exports.default = void 0; | ||
var _commonsApi = require("@verdaccio/commons-api"); | ||
var _memoryHandler = _interopRequireDefault(require("./memory-handler")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
const DEFAULT_LIMIT = 1000; | ||
class LocalMemory { | ||
constructor(config, options) { | ||
_defineProperty(this, "path", void 0); | ||
_defineProperty(this, "limit", void 0); | ||
_defineProperty(this, "logger", void 0); | ||
_defineProperty(this, "data", void 0); | ||
_defineProperty(this, "config", void 0); | ||
this.config = config; | ||
@@ -37,7 +20,5 @@ this.limit = config.limit || DEFAULT_LIMIT; | ||
} | ||
getSecret() { | ||
return Promise.resolve(this.data.secret); | ||
} | ||
setSecret(secret) { | ||
@@ -49,3 +30,2 @@ return new Promise(resolve => { | ||
} | ||
add(name, cb) { | ||
@@ -55,3 +35,2 @@ const { | ||
} = this.data; | ||
if (list.length < this.limit) { | ||
@@ -61,3 +40,2 @@ if (list.indexOf(name) === -1) { | ||
} | ||
cb(null); | ||
@@ -70,5 +48,5 @@ } else { | ||
} | ||
} // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
search(onPackage, onEnd, validateName) { | ||
@@ -78,3 +56,2 @@ this.logger.warn('[verdaccio/memory]: search method not implemented, PR is welcome'); | ||
} | ||
remove(name, cb) { | ||
@@ -85,18 +62,13 @@ const { | ||
const item = list.indexOf(name); | ||
if (item !== -1) { | ||
list.splice(item, 1); | ||
} | ||
cb(null); | ||
} | ||
get(cb) { | ||
cb(null, this.data.list); | ||
} | ||
getPackageStorage(packageInfo) { | ||
return new _memoryHandler.default(packageInfo, this.data.files, this.logger); | ||
} | ||
_createEmtpyDatabase() { | ||
@@ -112,3 +84,2 @@ const list = []; | ||
} | ||
saveToken(token) { | ||
@@ -118,3 +89,2 @@ this.logger.warn('[verdaccio/memory][saveToken] save token has not been implemented yet'); | ||
} | ||
deleteToken(user, tokenKey) { | ||
@@ -127,3 +97,2 @@ this.logger.warn({ | ||
} | ||
readTokens(filter) { | ||
@@ -133,7 +102,5 @@ this.logger.warn('[verdaccio/memory][readTokens] read tokens has not been implemented yet '); | ||
} | ||
} | ||
var _default = LocalMemory; | ||
exports.default = _default; | ||
//# sourceMappingURL=local-memory.js.map |
@@ -1,2 +0,2 @@ | ||
import { Callback, Logger, IPackageStorageManager, IUploadTarball, IReadTarball, CallbackAction, StorageUpdateCallback, StorageWriteCallback, PackageTransformer, Package, ReadPackageCallback } from '@verdaccio/types'; | ||
import { Callback, Logger, IPackageStorageManager, IUploadTarball, IReadTarball, CallbackAction, StorageUpdateCallback, StorageWriteCallback, PackageTransformer, Package, ReadPackageCallback } from '@verdaccio/legacy-types'; | ||
export declare type DataHandler = { | ||
@@ -3,0 +3,0 @@ [key: string]: string; |
@@ -7,29 +7,11 @@ "use strict"; | ||
exports.default = void 0; | ||
var _path = _interopRequireDefault(require("path")); | ||
var _commonsApi = require("@verdaccio/commons-api"); | ||
var _memoryFs = _interopRequireDefault(require("memory-fs")); | ||
var _streams = require("@verdaccio/streams"); | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
const fs = new _memoryFs.default(); | ||
class MemoryHandler { | ||
constructor(packageName, data, logger) { | ||
_defineProperty(this, "data", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "path", void 0); | ||
_defineProperty(this, "logger", void 0); | ||
// this is not need it | ||
@@ -41,8 +23,5 @@ this.data = data; | ||
} | ||
updatePackage(pkgFileName, updateHandler, onWrite, transformPackage, onEnd) { | ||
const json = this._getStorage(pkgFileName); | ||
let pkg; | ||
try { | ||
@@ -53,3 +32,2 @@ pkg = (0, _utils.parsePackage)(json); | ||
} | ||
updateHandler(pkg, err => { | ||
@@ -59,3 +37,2 @@ if (err) { | ||
} | ||
try { | ||
@@ -68,3 +45,2 @@ onWrite(pkgFileName, transformPackage(pkg), onEnd); | ||
} | ||
deletePackage(pkgName, callback) { | ||
@@ -74,11 +50,8 @@ delete this.data[pkgName]; | ||
} | ||
removePackage(callback) { | ||
return callback(null); | ||
} | ||
createPackage(name, value, cb) { | ||
this.savePackage(name, value, cb); | ||
} | ||
savePackage(name, value, cb) { | ||
@@ -93,8 +66,5 @@ try { | ||
} | ||
readPackage(name, cb) { | ||
const json = this._getStorage(name); | ||
const isJson = typeof json === 'undefined'; | ||
try { | ||
@@ -106,3 +76,2 @@ return cb(isJson ? (0, _commonsApi.getNotFound)() : null, (0, _utils.parsePackage)(json)); | ||
} | ||
writeTarball(name) { | ||
@@ -116,3 +85,2 @@ const uploadStream = new _streams.UploadTarball({}); | ||
} | ||
fs.stat(temporalName, function (fileError, stats) { | ||
@@ -122,7 +90,5 @@ if (!fileError && stats) { | ||
} | ||
try { | ||
const file = fs.createWriteStream(temporalName); | ||
uploadStream.pipe(file); | ||
uploadStream.done = function () { | ||
@@ -132,6 +98,4 @@ const onEnd = function () { | ||
}; | ||
uploadStream.on('end', onEnd); | ||
}; | ||
uploadStream.abort = function () { | ||
@@ -141,3 +105,2 @@ uploadStream.emit('error', (0, _commonsApi.getBadRequest)('transmision aborted')); | ||
}; | ||
uploadStream.emit('open'); | ||
@@ -154,3 +117,2 @@ return; | ||
} | ||
readTarball(name) { | ||
@@ -164,3 +126,2 @@ const pathName = `${this.path}/${name}`; | ||
} | ||
try { | ||
@@ -176,7 +137,5 @@ const readStream = fs.createReadStream(pathName); | ||
}); | ||
readTarballStream.abort = function () { | ||
readStream.destroy((0, _commonsApi.getBadRequest)('read has been aborted')); | ||
}; | ||
return; | ||
@@ -191,11 +150,8 @@ } catch (err) { | ||
} | ||
_getStorage(name = '') { | ||
return this.data[name]; | ||
} | ||
} | ||
var _default = MemoryHandler; | ||
exports.default = _default; | ||
//# sourceMappingURL=memory-handler.js.map |
@@ -1,3 +0,3 @@ | ||
import { Package } from '@verdaccio/types'; | ||
import { Package } from '@verdaccio/legacy-types'; | ||
export declare function stringifyPackage(pkg: Package): string; | ||
export declare function parsePackage(pkg: string): any; |
@@ -8,7 +8,5 @@ "use strict"; | ||
exports.stringifyPackage = stringifyPackage; | ||
function stringifyPackage(pkg) { | ||
return JSON.stringify(pkg, null, '\t'); | ||
} | ||
function parsePackage(pkg) { | ||
@@ -15,0 +13,0 @@ return JSON.parse(pkg); |
{ | ||
"name": "verdaccio-memory", | ||
"version": "10.3.0", | ||
"version": "10.3.1", | ||
"description": "Storage implementation in memory", | ||
@@ -36,3 +36,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@verdaccio/types": "10.5.0" | ||
"@verdaccio/legacy-types": "1.0.1" | ||
}, | ||
@@ -51,4 +51,3 @@ "funding": { | ||
"build": "pnpm run build:js && pnpm run build:types" | ||
}, | ||
"readme": "# verdaccio-memory\n\n[![CircleCI](https://circleci.com/gh/verdaccio/verdaccio-memory.svg?style=svg)](https://circleci.com/gh/ayusharma/verdaccio-memory)\n[![codecov](https://codecov.io/gh/verdaccio/verdaccio-memory/branch/master/graph/badge.svg)](https://codecov.io/gh/verdaccio/verdaccio-memory)\n[![verdaccio (latest)](https://img.shields.io/npm/v/verdaccio-memory/latest.svg)](https://www.npmjs.com/package/verdaccio-memory)\n[![Known Vulnerabilities](https://snyk.io/test/github/verdaccio/verdaccio-memory/badge.svg?targetFile=package.json)](https://snyk.io/test/github/verdaccio/verdaccio-memory?targetFile=package.json)\n[![backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio)\n[![discord](https://img.shields.io/discord/388674437219745793.svg)](http://chat.verdaccio.org/)\n![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)\n[![node](https://img.shields.io/node/v/verdaccio-memory/latest.svg)](https://www.npmjs.com/package/verdaccio-memory)\n\n\nA memory based **storage plugin**.\n\n```\n npm install --global verdaccio-memory\n```\n\n### Requirements\n\n>`verdaccio@3.0.0` or `verdaccio@4.x`\n\n```\nnpm install -g verdaccio\n```\n\nComplete configuration example:\n\n```yaml\nstore:\n memory:\n limit: 1000\n```\n\nin `config.yaml`\n\nIf `store:` is present `storage:` fallback is being ignored.\n\n```yaml\nstorage: /Users/user/.local/share/verdaccio/storage\nauth:\n htpasswd:\n file: ./htpasswd\nstore:\n memory:\n limit: 1000\n```\n\n## Disclaimer\n\nThis plugin should not be use for production environments. It might be useful for testing or such places as CI where data does not need to be persisted.\n\n## License\n\n[MIT](http://www.opensource.org/licenses/mit-license.php)\n" | ||
} | ||
} |
@@ -21,3 +21,3 @@ # verdaccio-memory | ||
>`verdaccio@3.0.0` or `verdaccio@4.x` | ||
>`verdaccio@3.0.0`, `verdaccio@4.x`, `verdaccio@5.x` | ||
@@ -24,0 +24,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
Sorry, the diff of this file is not supported yet
33528
314