@verdaccio/local-storage 10.3.2 → 10.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +3 -0
- package/lib/local-database.d.ts +50 -0
- package/lib/local-fs.d.ts +47 -0
- package/lib/pkg-utils.d.ts +2 -0
- package/lib/token.d.ts +12 -0
- package/lib/utils.d.ts +8 -0
- package/package.json +5 -5
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Callback, Config, IPackageStorage, IPluginStorage, LocalStorage, Logger } from '@verdaccio/legacy-types';
|
|
2
|
+
import TokenActions from './token';
|
|
3
|
+
declare class LocalDatabase extends TokenActions implements IPluginStorage<{}> {
|
|
4
|
+
path: string;
|
|
5
|
+
logger: Logger;
|
|
6
|
+
data: LocalStorage;
|
|
7
|
+
config: Config;
|
|
8
|
+
locked: boolean;
|
|
9
|
+
constructor(config: Config, logger: Logger);
|
|
10
|
+
getSecret(): Promise<string>;
|
|
11
|
+
setSecret(secret: string): Promise<Error | null>;
|
|
12
|
+
add(name: string, cb: Callback): void;
|
|
13
|
+
search(onPackage: Callback, onEnd: Callback, validateName: (name: string) => boolean): void;
|
|
14
|
+
remove(name: string, cb: Callback): void;
|
|
15
|
+
/**
|
|
16
|
+
* Return all database elements.
|
|
17
|
+
* @return {Array}
|
|
18
|
+
*/
|
|
19
|
+
get(cb: Callback): void;
|
|
20
|
+
getPackageStorage(packageName: string): IPackageStorage;
|
|
21
|
+
clean(): void;
|
|
22
|
+
private getTime;
|
|
23
|
+
private _getCustomPackageLocalStorages;
|
|
24
|
+
/**
|
|
25
|
+
* Syncronize {create} database whether does not exist.
|
|
26
|
+
* @return {Error|*}
|
|
27
|
+
*/
|
|
28
|
+
private _sync;
|
|
29
|
+
/**
|
|
30
|
+
* Verify the right local storage location.
|
|
31
|
+
* @param {String} path
|
|
32
|
+
* @return {String}
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
private _getLocalStoragePath;
|
|
36
|
+
/**
|
|
37
|
+
* Build the local database path.
|
|
38
|
+
* @param {Object} config
|
|
39
|
+
* @return {string|String|*}
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
private _buildStoragePath;
|
|
43
|
+
/**
|
|
44
|
+
* Fetch local packages.
|
|
45
|
+
* @private
|
|
46
|
+
* @return {Object}
|
|
47
|
+
*/
|
|
48
|
+
private _fetchLocalPackages;
|
|
49
|
+
}
|
|
50
|
+
export default LocalDatabase;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ReadTarball } from '@verdaccio/streams';
|
|
3
|
+
import { Callback, Logger, Package, ILocalPackageManager, IUploadTarball } from '@verdaccio/legacy-types';
|
|
4
|
+
import { VerdaccioError } from '@verdaccio/commons-api';
|
|
5
|
+
export declare const fileExist = "EEXISTS";
|
|
6
|
+
export declare const noSuchFile = "ENOENT";
|
|
7
|
+
export declare const resourceNotAvailable = "EAGAIN";
|
|
8
|
+
export declare const pkgFileName = "package.json";
|
|
9
|
+
export declare const fSError: (message: string, code?: number) => VerdaccioError;
|
|
10
|
+
export declare type ILocalFSPackageManager = ILocalPackageManager & {
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
export default class LocalFS implements ILocalFSPackageManager {
|
|
14
|
+
path: string;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
constructor(path: string, logger: Logger);
|
|
17
|
+
/**
|
|
18
|
+
* This function allows to update the package thread-safely
|
|
19
|
+
Algorithm:
|
|
20
|
+
1. lock package.json for writing
|
|
21
|
+
2. read package.json
|
|
22
|
+
3. updateFn(pkg, cb), and wait for cb
|
|
23
|
+
4. write package.json.tmp
|
|
24
|
+
5. move package.json.tmp package.json
|
|
25
|
+
6. callback(err?)
|
|
26
|
+
* @param {*} name
|
|
27
|
+
* @param {*} updateHandler
|
|
28
|
+
* @param {*} onWrite
|
|
29
|
+
* @param {*} transformPackage
|
|
30
|
+
* @param {*} onEnd
|
|
31
|
+
*/
|
|
32
|
+
updatePackage(name: string, updateHandler: Callback, onWrite: Callback, transformPackage: Function, onEnd: Callback): void;
|
|
33
|
+
deletePackage(packageName: string, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
34
|
+
removePackage(callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
35
|
+
createPackage(name: string, value: Package, cb: Callback): void;
|
|
36
|
+
savePackage(name: string, value: Package, cb: Callback): void;
|
|
37
|
+
readPackage(name: string, cb: Callback): void;
|
|
38
|
+
writeTarball(name: string): IUploadTarball;
|
|
39
|
+
readTarball(name: string): ReadTarball;
|
|
40
|
+
private _createFile;
|
|
41
|
+
private _readStorageFile;
|
|
42
|
+
private _convertToString;
|
|
43
|
+
private _getStorage;
|
|
44
|
+
private _writeFile;
|
|
45
|
+
private _lockAndReadJSON;
|
|
46
|
+
private _unlockJSON;
|
|
47
|
+
}
|
package/lib/token.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import low from 'lowdb';
|
|
2
|
+
import { ITokenActions, Config, Token, TokenFilter } from '@verdaccio/legacy-types';
|
|
3
|
+
export default class TokenActions implements ITokenActions {
|
|
4
|
+
config: Config;
|
|
5
|
+
tokenDb: low.LowdbAsync<any> | null;
|
|
6
|
+
constructor(config: Config);
|
|
7
|
+
_dbGenPath(dbName: string, config: Config): string;
|
|
8
|
+
private getTokenDb;
|
|
9
|
+
saveToken(token: Token): Promise<void>;
|
|
10
|
+
deleteToken(user: string, tokenKey: string): Promise<void>;
|
|
11
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
12
|
+
}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
export declare function getFileStats(packagePath: string): Promise<fs.Stats>;
|
|
4
|
+
export declare function readDirectory(packagePath: string): Promise<string[]>;
|
|
5
|
+
export declare function findPackages(storagePath: string, validationHandler: Function): Promise<{
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
}[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/local-storage",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.3",
|
|
4
4
|
"description": "Local storage implementation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@verdaccio/commons-api": "10.2.0",
|
|
35
|
-
"@verdaccio/file-locking": "10.3.
|
|
36
|
-
"@verdaccio/streams": "10.2.
|
|
35
|
+
"@verdaccio/file-locking": "10.3.1",
|
|
36
|
+
"@verdaccio/streams": "10.2.1",
|
|
37
37
|
"async": "3.2.4",
|
|
38
38
|
"debug": "4.3.4",
|
|
39
39
|
"lodash": "4.17.21",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"clean": "rimraf ./build",
|
|
56
56
|
"test": "cross-env NODE_ENV=test BABEL_ENV=test jest",
|
|
57
57
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
58
|
+
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
58
59
|
"build:js": "babel src/ --out-dir lib/ --copy-files --extensions \".ts,.tsx\" --source-maps",
|
|
59
|
-
"
|
|
60
|
-
"build": "pnpm run build:js"
|
|
60
|
+
"build": "pnpm run build:js && pnpm run build:types"
|
|
61
61
|
}
|
|
62
62
|
}
|