New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

verdaccio-memory

Package Overview
Dependencies
Maintainers
3
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

verdaccio-memory - npm Package Compare versions

Comparing version 11.0.0-6-next.4 to 11.0.0-6-next.5

8

build/local-memory.d.ts

@@ -21,6 +21,6 @@ import { Logger, Callback, Config, IPluginStorage, Token, PluginOptions } from '@verdaccio/types';

setSecret(secret: string): Promise<string | null>;
add(name: string, cb: Callback): void;
search(onPackage: Callback, onEnd: Callback, validateName: Function): void;
remove(name: string, cb: Callback): void;
get(cb: Callback): void;
add(name: string): Promise<void>;
search(onPackage: Callback, onEnd: Callback): void;
remove(name: string): Promise<void>;
get(): Promise<any>;
getPackageStorage(packageInfo: string): MemoryHandler;

@@ -27,0 +27,0 @@ private _createEmtpyDatabase;

@@ -56,23 +56,25 @@ "use strict";

add(name, cb) {
const {
list
} = this.data;
async add(name) {
return new Promise((resolve, reject) => {
const {
list
} = this.data;
if (list.length < this.limit) {
if (list.indexOf(name) === -1) {
list.push(name);
if (list.length < this.limit) {
if (list.indexOf(name) === -1) {
list.push(name);
}
resolve();
} else {
this.logger.info({
limit: this.limit
}, 'Storage memory has reached limit of @{limit} packages');
reject(new Error('Storage memory has reached limit of limit packages'));
}
cb(null);
} else {
this.logger.info({
limit: this.limit
}, 'Storage memory has reached limit of @{limit} packages');
cb(new Error('Storage memory has reached limit of limit packages'));
}
});
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
search(onPackage, onEnd, validateName) {
search(onPackage, onEnd) {
this.logger.warn('[verdaccio/memory]: search method not implemented, PR is welcome');

@@ -82,20 +84,22 @@ onEnd();

remove(name, cb) {
const {
list
} = this.data;
const item = list.indexOf(name);
async remove(name) {
return new Promise(resolve => {
const {
list
} = this.data;
const item = list.indexOf(name);
if (item !== -1) {
list.splice(item, 1);
}
if (item !== -1) {
list.splice(item, 1);
}
cb(null);
return resolve();
});
}
get(cb) {
async get() {
var _this$data, _this$data$list, _this$data2;
debug('data list length %o', (_this$data = this.data) === null || _this$data === void 0 ? void 0 : (_this$data$list = _this$data.list) === null || _this$data$list === void 0 ? void 0 : _this$data$list.length);
cb(null, (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.list);
return Promise.resolve((_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.list);
}

@@ -102,0 +106,0 @@

@@ -1,2 +0,2 @@

import { Callback, Logger, IPackageStorageManager, IUploadTarball, IReadTarball, CallbackAction, StorageUpdateCallback, StorageWriteCallback, PackageTransformer, Package, ReadPackageCallback } from '@verdaccio/types';
import { Logger, IPackageStorageManager, IUploadTarball, IReadTarball, CallbackAction, StorageUpdateCallback, StorageWriteCallback, PackageTransformer, Package, ReadPackageCallback } from '@verdaccio/types';
export declare type DataHandler = {

@@ -12,4 +12,4 @@ [key: string]: string;

updatePackage(pkgFileName: string, updateHandler: StorageUpdateCallback, onWrite: StorageWriteCallback, transformPackage: PackageTransformer, onEnd: CallbackAction): void;
deletePackage(pkgName: string, callback: Callback): void;
removePackage(callback: CallbackAction): void;
deletePackage(pkgName: string): Promise<void>;
removePackage(): Promise<void>;
createPackage(name: string, value: Package, cb: CallbackAction): void;

@@ -16,0 +16,0 @@ savePackage(name: string, value: Package, cb: CallbackAction): void;

@@ -66,9 +66,9 @@ "use strict";

deletePackage(pkgName, callback) {
deletePackage(pkgName) {
delete this.data[pkgName];
return callback(null);
return Promise.resolve();
}
removePackage(callback) {
return callback(null);
removePackage() {
return Promise.resolve();
}

@@ -75,0 +75,0 @@

# Change Log
## 11.0.0-6-next.5
### Major Changes
- 459b6fa7: refactor: search v1 endpoint and local-database
- refactor search `api v1` endpoint, improve performance
- remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
- refactor method storage class
- create new module `core` to reduce the ammount of modules with utilities
- use `undici` instead `node-fetch`
- use `fastify` instead `express` for functional test
### Breaking changes
- plugin storage API changes
- remove old search endpoint (return 404)
- filter local private packages at plugin level
The storage api changes for methods `get`, `add`, `remove` as promise base. The `search` methods also changes and recieves a `query` object that contains all query params from the client.
```ts
export interface IPluginStorage<T> extends IPlugin {
add(name: string): Promise<void>;
remove(name: string): Promise<void>;
get(): Promise<any>;
init(): Promise<void>;
getSecret(): Promise<string>;
setSecret(secret: string): Promise<any>;
getPackageStorage(packageInfo: string): IPackageStorage;
search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
saveToken(token: Token): Promise<any>;
deleteToken(user: string, tokenKey: string): Promise<any>;
readTokens(filter: TokenFilter): Promise<Token[]>;
}
```
### Patch Changes
- Updated dependencies [459b6fa7]
- @verdaccio/commons-api@11.0.0-6-next.4
- @verdaccio/streams@11.0.0-6-next.4
## 11.0.0-6-next.4

@@ -4,0 +47,0 @@

{
"name": "verdaccio-memory",
"version": "11.0.0-6-next.4",
"version": "11.0.0-6-next.5",
"description": "Storage implementation in memory",

@@ -34,10 +34,10 @@ "keywords": [

"dependencies": {
"@verdaccio/commons-api": "11.0.0-alpha.3",
"@verdaccio/streams": "11.0.0-alpha.3",
"@verdaccio/commons-api": "11.0.0-6-next.4",
"@verdaccio/streams": "11.0.0-6-next.4",
"memory-fs": "0.5.0",
"debug": "4.3.2",
"memfs": "3.2.3"
"memfs": "3.2.4"
},
"devDependencies": {
"@verdaccio/types": "11.0.0-6-next.7"
"@verdaccio/types": "11.0.0-6-next.8"
},

@@ -44,0 +44,0 @@ "funding": {

@@ -48,21 +48,23 @@ import { getServiceUnavailable } from '@verdaccio/commons-api';

public add(name: string, cb: Callback): void {
const { list } = this.data;
async add(name: string): Promise<void> {
return new Promise((resolve, reject): void => {
const { list } = this.data;
if (list.length < this.limit) {
if (list.indexOf(name) === -1) {
list.push(name);
if (list.length < this.limit) {
if (list.indexOf(name) === -1) {
list.push(name);
}
resolve();
} else {
this.logger.info(
{ limit: this.limit },
'Storage memory has reached limit of @{limit} packages'
);
reject(new Error('Storage memory has reached limit of limit packages'));
}
cb(null);
} else {
this.logger.info(
{ limit: this.limit },
'Storage memory has reached limit of @{limit} packages'
);
cb(new Error('Storage memory has reached limit of limit packages'));
}
});
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public search(onPackage: Callback, onEnd: Callback, validateName: Function): void {
public search(onPackage: Callback, onEnd: Callback): void {
this.logger.warn('[verdaccio/memory]: search method not implemented, PR is welcome');

@@ -72,16 +74,18 @@ onEnd();

public remove(name: string, cb: Callback): void {
const { list } = this.data;
const item = list.indexOf(name);
async remove(name: string): Promise<void> {
return new Promise((resolve): void => {
const { list } = this.data;
const item = list.indexOf(name);
if (item !== -1) {
list.splice(item, 1);
}
if (item !== -1) {
list.splice(item, 1);
}
cb(null);
return resolve();
});
}
public get(cb: Callback): void {
async get(): Promise<any> {
debug('data list length %o', this.data?.list?.length);
cb(null, this.data?.list);
return Promise.resolve(this.data?.list);
}

@@ -88,0 +92,0 @@

@@ -12,3 +12,2 @@ import buildDebug from 'debug';

import {
Callback,
Logger,

@@ -77,9 +76,9 @@ IPackageStorageManager,

public deletePackage(pkgName: string, callback: Callback): void {
public deletePackage(pkgName: string) {
delete this.data[pkgName];
return callback(null);
return Promise.resolve();
}
public removePackage(callback: CallbackAction): void {
return callback(null);
public removePackage() {
return Promise.resolve();
}

@@ -86,0 +85,0 @@

import { Logger, IPluginStorage } from '@verdaccio/types';
import { VerdaccioError } from '@verdaccio/commons-api';

@@ -32,6 +31,4 @@ import { ConfigMemory } from '../src/local-memory';

const localMemory: IPluginStorage<ConfigMemory> = new LocalMemory(config, defaultConfig);
localMemory.add('test', (err: VerdaccioError) => {
expect(err).toBeNull();
localMemory.get((err: VerdaccioError, data: DataHandler) => {
expect(err).toBeNull();
localMemory.add('test').then(() => {
localMemory.get().then((data: DataHandler) => {
expect(data).toHaveLength(1);

@@ -47,7 +44,5 @@ done();

localMemory.add('test1', (err) => {
expect(err).toBeNull();
localMemory.add('test2', (err) => {
expect(err).toBeNull();
localMemory.add('test3', (err) => {
localMemory.add('test1').then(() => {
localMemory.add('test2').then(() => {
localMemory.add('test3').catch((err) => {
expect(err).not.toBeNull();

@@ -64,8 +59,5 @@ expect(err.message).toMatch(/Storage memory has reached limit of limit packages/);

const localMemory: IPluginStorage<ConfigMemory> = new LocalMemory(config, defaultConfig);
localMemory.add(pkgName, (err) => {
expect(err).toBeNull();
localMemory.remove(pkgName, (err) => {
expect(err).toBeNull();
localMemory.get((err, data) => {
expect(err).toBeNull();
localMemory.add(pkgName).then(() => {
localMemory.remove(pkgName).then(() => {
localMemory.get().then((data) => {
expect(data).toHaveLength(0);

@@ -72,0 +64,0 @@ done();

@@ -250,4 +250,4 @@ import { Logger, IPluginStorage, IPackageStorage, ILocalPackageManager } from '@verdaccio/types';

expect(err).toBeNull();
handler.deletePackage(pkgName, (err) => {
expect(err).toBeNull();
handler.deletePackage(pkgName).then((err) => {
expect(err).toBeUndefined();
handler.readPackage(pkgName, (err) => {

@@ -254,0 +254,0 @@ expect(err).not.toBeNull();

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