@verdaccio/local-storage 10.3.1 ā 10.3.2
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.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/local-database.js +13 -101
- package/lib/local-database.js.map +1 -1
- package/lib/local-fs.js +11 -89
- package/lib/local-fs.js.map +1 -1
- package/lib/pkg-utils.js +2 -11
- package/lib/pkg-utils.js.map +1 -1
- package/lib/token.js +2 -32
- package/lib/token.js.map +1 -1
- package/lib/utils.js +3 -20
- package/lib/utils.js.map +1 -1
- package/package.json +4 -6
- package/lib/index.d.ts +0 -3
- package/lib/local-database.d.ts +0 -50
- package/lib/local-fs.d.ts +0 -47
- package/lib/pkg-utils.d.ts +0 -2
- package/lib/token.d.ts +0 -12
- package/lib/utils.d.ts +0 -8
package/lib/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","names":["debug","buildDebug","TOKEN_DB_NAME","TokenActions","constructor","config","tokenDb","_dbGenPath","dbName","Path","join","resolve","dirname","self_path","storage","getTokenDb","adapter","process","env","NODE_ENV","FileMemory","pathDb","FileAsync","low","saveToken","token","key","db","userData","get","user","value","_","isNil","set","write","push","getState","deleteToken","tokenKey","userTokens","Error","length","remainingTokens","filter","readTokens","tokens"],"sources":["../src/token.ts"],"sourcesContent":["import Path from 'path';\n\nimport _ from 'lodash';\nimport low from 'lowdb';\nimport FileAsync from 'lowdb/adapters/FileAsync';\nimport FileMemory from 'lowdb/adapters/Memory';\nimport buildDebug from 'debug';\nimport { ITokenActions, Config, Token, TokenFilter } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:plugin:local-storage:token');\n\nconst TOKEN_DB_NAME = '.token-db.json';\n\nexport default class TokenActions implements ITokenActions {\n public config: Config;\n public tokenDb: low.LowdbAsync<any> | null;\n\n public constructor(config: Config) {\n this.config = config;\n this.tokenDb = null;\n }\n\n public _dbGenPath(dbName: string, config: Config): string {\n return Path.join(\n Path.resolve(Path.dirname(config.self_path || ''), config.storage as string, dbName)\n );\n }\n\n private async getTokenDb(): Promise<low.LowdbAsync<any>> {\n if (!this.tokenDb) {\n debug('token database is not defined');\n let adapter;\n if (process.env.NODE_ENV === 'test') {\n debug('token memory adapter');\n adapter = new FileMemory('');\n } else {\n debug('token async adapter');\n const pathDb = this._dbGenPath(TOKEN_DB_NAME, this.config);\n adapter = new FileAsync(pathDb);\n }\n debug('token bd generated');\n this.tokenDb = await low(adapter);\n }\n\n return this.tokenDb;\n }\n\n public async saveToken(token: Token): Promise<void> {\n debug('token key %o', token.key);\n const db = await this.getTokenDb();\n const userData = await db.get(token.user).value();\n debug('user data %o', userData);\n if (_.isNil(userData)) {\n await db.set(token.user, [token]).write();\n debug('token user %o new database', token.user);\n } else {\n // types does not match with valid implementation\n // @ts-ignore\n await db\n .get(token.user)\n // @ts-ignore\n .push(token)\n .write();\n }\n debug('data %o', await db.getState());\n debug('token saved %o', token.user);\n }\n\n public async deleteToken(user: string, tokenKey: string): Promise<void> {\n const db = await this.getTokenDb();\n const userTokens = await db.get(user).value();\n if (_.isNil(userTokens)) {\n throw new Error('user not found');\n }\n debug('tokens %o - %o', userTokens, userTokens.length);\n const remainingTokens = userTokens.filter(({ key }) => {\n debug('key %o', key);\n return key !== tokenKey;\n });\n await db.set(user, remainingTokens).write();\n debug('removed tokens key %o', tokenKey);\n }\n\n public async readTokens(filter: TokenFilter): Promise<Token[]> {\n const { user } = filter;\n debug('read tokens with %o', user);\n const db = await this.getTokenDb();\n const tokens = await db.get(user).value();\n return tokens || [];\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.js","names":["_path","_interopRequireDefault","require","_lodash","_lowdb","_FileAsync","_Memory","_debug","obj","__esModule","default","debug","buildDebug","TOKEN_DB_NAME","TokenActions","constructor","config","tokenDb","_dbGenPath","dbName","Path","join","resolve","dirname","self_path","storage","getTokenDb","adapter","process","env","NODE_ENV","FileMemory","pathDb","FileAsync","low","saveToken","token","key","db","userData","get","user","value","_","isNil","set","write","push","getState","deleteToken","tokenKey","userTokens","Error","length","remainingTokens","filter","readTokens","tokens","exports"],"sources":["../src/token.ts"],"sourcesContent":["import Path from 'path';\n\nimport _ from 'lodash';\nimport low from 'lowdb';\nimport FileAsync from 'lowdb/adapters/FileAsync';\nimport FileMemory from 'lowdb/adapters/Memory';\nimport buildDebug from 'debug';\nimport { ITokenActions, Config, Token, TokenFilter } from '@verdaccio/legacy-types';\n\nconst debug = buildDebug('verdaccio:plugin:local-storage:token');\n\nconst TOKEN_DB_NAME = '.token-db.json';\n\nexport default class TokenActions implements ITokenActions {\n public config: Config;\n public tokenDb: low.LowdbAsync<any> | null;\n\n public constructor(config: Config) {\n this.config = config;\n this.tokenDb = null;\n }\n\n public _dbGenPath(dbName: string, config: Config): string {\n return Path.join(\n Path.resolve(Path.dirname(config.self_path || ''), config.storage as string, dbName)\n );\n }\n\n private async getTokenDb(): Promise<low.LowdbAsync<any>> {\n if (!this.tokenDb) {\n debug('token database is not defined');\n let adapter;\n if (process.env.NODE_ENV === 'test') {\n debug('token memory adapter');\n adapter = new FileMemory('');\n } else {\n debug('token async adapter');\n const pathDb = this._dbGenPath(TOKEN_DB_NAME, this.config);\n adapter = new FileAsync(pathDb);\n }\n debug('token bd generated');\n this.tokenDb = await low(adapter);\n }\n\n return this.tokenDb;\n }\n\n public async saveToken(token: Token): Promise<void> {\n debug('token key %o', token.key);\n const db = await this.getTokenDb();\n const userData = await db.get(token.user).value();\n debug('user data %o', userData);\n if (_.isNil(userData)) {\n await db.set(token.user, [token]).write();\n debug('token user %o new database', token.user);\n } else {\n // types does not match with valid implementation\n // @ts-ignore\n await db\n .get(token.user)\n // @ts-ignore\n .push(token)\n .write();\n }\n debug('data %o', await db.getState());\n debug('token saved %o', token.user);\n }\n\n public async deleteToken(user: string, tokenKey: string): Promise<void> {\n const db = await this.getTokenDb();\n const userTokens = await db.get(user).value();\n if (_.isNil(userTokens)) {\n throw new Error('user not found');\n }\n debug('tokens %o - %o', userTokens, userTokens.length);\n const remainingTokens = userTokens.filter(({ key }) => {\n debug('key %o', key);\n return key !== tokenKey;\n });\n await db.set(user, remainingTokens).write();\n debug('removed tokens key %o', tokenKey);\n }\n\n public async readTokens(filter: TokenFilter): Promise<Token[]> {\n const { user } = filter;\n debug('read tokens with %o', user);\n const db = await this.getTokenDb();\n const tokens = await db.get(user).value();\n return tokens || [];\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAG/B,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,sCAAsC,CAAC;AAEhE,MAAMC,aAAa,GAAG,gBAAgB;AAEvB,MAAMC,YAAY,CAA0B;EAIlDC,WAAWA,CAACC,MAAc,EAAE;IACjC,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAG,IAAI;EACrB;EAEOC,UAAUA,CAACC,MAAc,EAAEH,MAAc,EAAU;IACxD,OAAOI,aAAI,CAACC,IAAI,CACdD,aAAI,CAACE,OAAO,CAACF,aAAI,CAACG,OAAO,CAACP,MAAM,CAACQ,SAAS,IAAI,EAAE,CAAC,EAAER,MAAM,CAACS,OAAO,EAAYN,MAAM,CAAC,CACrF;EACH;EAEA,MAAcO,UAAUA,CAAA,EAAiC;IACvD,IAAI,CAAC,IAAI,CAACT,OAAO,EAAE;MACjBN,KAAK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Property(exports, "__esModule", {
|
|
|
6
6
|
exports.findPackages = findPackages;
|
|
7
7
|
exports.getFileStats = getFileStats;
|
|
8
8
|
exports.readDirectory = readDirectory;
|
|
9
|
-
|
|
10
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
-
|
|
12
10
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
|
|
14
11
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
15
|
-
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
13
|
function getFileStats(packagePath) {
|
|
19
14
|
return new Promise((resolve, reject) => {
|
|
20
15
|
_fs.default.stat(packagePath, (err, stats) => {
|
|
21
16
|
if (_lodash.default.isNil(err) === false) {
|
|
22
17
|
return reject(err);
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
resolve(stats);
|
|
26
20
|
});
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
function readDirectory(packagePath) {
|
|
31
24
|
return new Promise((resolve, reject) => {
|
|
32
25
|
_fs.default.readdir(packagePath, (err, scopedPackages) => {
|
|
33
26
|
if (_lodash.default.isNil(err) === false) {
|
|
34
27
|
return reject(err);
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
resolve(scopedPackages);
|
|
38
30
|
});
|
|
39
31
|
});
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
function hasScope(file) {
|
|
43
34
|
return file.match(/^@/) !== null;
|
|
44
35
|
}
|
|
45
|
-
/* eslint-disable no-async-promise-executor */
|
|
46
|
-
|
|
47
36
|
|
|
37
|
+
/* eslint-disable no-async-promise-executor */
|
|
48
38
|
async function findPackages(storagePath, validationHandler) {
|
|
49
39
|
const listPackages = [];
|
|
50
40
|
return new Promise(async (resolve, reject) => {
|
|
51
41
|
try {
|
|
52
42
|
const scopePath = _path.default.resolve(storagePath);
|
|
53
|
-
|
|
54
43
|
const storageDirs = await readDirectory(scopePath);
|
|
55
|
-
|
|
56
44
|
for (const directory of storageDirs) {
|
|
57
45
|
// we check whether has 2nd level
|
|
58
46
|
if (hasScope(directory)) {
|
|
59
47
|
// we read directory multiple
|
|
60
48
|
const scopeDirectory = _path.default.resolve(storagePath, directory);
|
|
61
|
-
|
|
62
49
|
const scopedPackages = await readDirectory(scopeDirectory);
|
|
63
|
-
|
|
64
50
|
for (const scopedDirName of scopedPackages) {
|
|
65
51
|
if (validationHandler(scopedDirName)) {
|
|
66
52
|
// we build the complete scope path
|
|
67
|
-
const scopePath = _path.default.resolve(storagePath, directory, scopedDirName);
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
const scopePath = _path.default.resolve(storagePath, directory, scopedDirName);
|
|
54
|
+
// list content of such directory
|
|
70
55
|
listPackages.push({
|
|
71
56
|
name: `${directory}/${scopedDirName}`,
|
|
72
57
|
path: scopePath
|
|
@@ -77,7 +62,6 @@ async function findPackages(storagePath, validationHandler) {
|
|
|
77
62
|
// otherwise we read as single level
|
|
78
63
|
if (validationHandler(directory)) {
|
|
79
64
|
const scopePath = _path.default.resolve(storagePath, directory);
|
|
80
|
-
|
|
81
65
|
listPackages.push({
|
|
82
66
|
name: directory,
|
|
83
67
|
path: scopePath
|
|
@@ -88,7 +72,6 @@ async function findPackages(storagePath, validationHandler) {
|
|
|
88
72
|
} catch (error) {
|
|
89
73
|
reject(error);
|
|
90
74
|
}
|
|
91
|
-
|
|
92
75
|
resolve(listPackages);
|
|
93
76
|
});
|
|
94
77
|
}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["getFileStats","packagePath","Promise","resolve","reject","fs","stat","err","stats","_","isNil","readDirectory","readdir","scopedPackages","hasScope","file","match","findPackages","storagePath","validationHandler","listPackages","scopePath","path","storageDirs","directory","scopeDirectory","scopedDirName","push","name","error"],"sources":["../src/utils.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport _ from 'lodash';\n\nexport function getFileStats(packagePath: string): Promise<fs.Stats> {\n return new Promise((resolve, reject): void => {\n fs.stat(packagePath, (err, stats) => {\n if (_.isNil(err) === false) {\n return reject(err);\n }\n resolve(stats);\n });\n });\n}\n\nexport function readDirectory(packagePath: string): Promise<string[]> {\n return new Promise((resolve, reject): void => {\n fs.readdir(packagePath, (err, scopedPackages) => {\n if (_.isNil(err) === false) {\n return reject(err);\n }\n\n resolve(scopedPackages);\n });\n });\n}\n\nfunction hasScope(file: string): boolean {\n return file.match(/^@/) !== null;\n}\n\n/* eslint-disable no-async-promise-executor */\nexport async function findPackages(\n storagePath: string,\n validationHandler: Function\n): Promise<{ name: string; path: string }[]> {\n const listPackages: { name: string; path: string }[] = [];\n return new Promise(async (resolve, reject) => {\n try {\n const scopePath = path.resolve(storagePath);\n const storageDirs = await readDirectory(scopePath);\n for (const directory of storageDirs) {\n // we check whether has 2nd level\n if (hasScope(directory)) {\n // we read directory multiple\n const scopeDirectory = path.resolve(storagePath, directory);\n const scopedPackages = await readDirectory(scopeDirectory);\n for (const scopedDirName of scopedPackages) {\n if (validationHandler(scopedDirName)) {\n // we build the complete scope path\n const scopePath = path.resolve(storagePath, directory, scopedDirName);\n // list content of such directory\n listPackages.push({\n name: `${directory}/${scopedDirName}`,\n path: scopePath,\n });\n }\n }\n } else {\n // otherwise we read as single level\n if (validationHandler(directory)) {\n const scopePath = path.resolve(storagePath, directory);\n listPackages.push({\n name: directory,\n path: scopePath,\n });\n }\n }\n }\n } catch (error) {\n reject(error);\n }\n\n resolve(listPackages);\n });\n}\n/* eslint-enable no-async-promise-executor */\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_fs","_interopRequireDefault","require","_path","_lodash","obj","__esModule","default","getFileStats","packagePath","Promise","resolve","reject","fs","stat","err","stats","_","isNil","readDirectory","readdir","scopedPackages","hasScope","file","match","findPackages","storagePath","validationHandler","listPackages","scopePath","path","storageDirs","directory","scopeDirectory","scopedDirName","push","name","error"],"sources":["../src/utils.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport _ from 'lodash';\n\nexport function getFileStats(packagePath: string): Promise<fs.Stats> {\n return new Promise((resolve, reject): void => {\n fs.stat(packagePath, (err, stats) => {\n if (_.isNil(err) === false) {\n return reject(err);\n }\n resolve(stats);\n });\n });\n}\n\nexport function readDirectory(packagePath: string): Promise<string[]> {\n return new Promise((resolve, reject): void => {\n fs.readdir(packagePath, (err, scopedPackages) => {\n if (_.isNil(err) === false) {\n return reject(err);\n }\n\n resolve(scopedPackages);\n });\n });\n}\n\nfunction hasScope(file: string): boolean {\n return file.match(/^@/) !== null;\n}\n\n/* eslint-disable no-async-promise-executor */\nexport async function findPackages(\n storagePath: string,\n validationHandler: Function\n): Promise<{ name: string; path: string }[]> {\n const listPackages: { name: string; path: string }[] = [];\n return new Promise(async (resolve, reject) => {\n try {\n const scopePath = path.resolve(storagePath);\n const storageDirs = await readDirectory(scopePath);\n for (const directory of storageDirs) {\n // we check whether has 2nd level\n if (hasScope(directory)) {\n // we read directory multiple\n const scopeDirectory = path.resolve(storagePath, directory);\n const scopedPackages = await readDirectory(scopeDirectory);\n for (const scopedDirName of scopedPackages) {\n if (validationHandler(scopedDirName)) {\n // we build the complete scope path\n const scopePath = path.resolve(storagePath, directory, scopedDirName);\n // list content of such directory\n listPackages.push({\n name: `${directory}/${scopedDirName}`,\n path: scopePath,\n });\n }\n }\n } else {\n // otherwise we read as single level\n if (validationHandler(directory)) {\n const scopePath = path.resolve(storagePath, directory);\n listPackages.push({\n name: directory,\n path: scopePath,\n });\n }\n }\n }\n } catch (error) {\n reject(error);\n }\n\n resolve(listPackages);\n });\n}\n/* eslint-enable no-async-promise-executor */\n"],"mappings":";;;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAuB,SAAAD,uBAA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K,MAAMG,SAAS,IAAID,WAAW,EAAE;QACnC;QACA,IAAIT,QAAQ,CAACU,SAAS,CAAC,EAAE;UACvB;UACA,MAAMC,cAAc,GAAGH,aAAI,CAACnB,OAAO,CAACe,WAAW,EAAEM,SAAS,CAAC;UAC3D,MAAMX,cAAc,GAAG,MAAMF,aAAa,CAACc,cAAc,CAAC;UAC1D,KAAK,MAAMC,aAAa,IAAIb,cAAc,EAAE;YAC1C,IAAIM,iBAAiB,CAACO,aAAa,CAAC,EAAE;cACpC;cACA,MAAML,SAAS,GAAGC,aAAI,CAACnB,OAAO,CAACe,WAAW,EAAEM,SAAS,EAAEE,aAAa,CAAC;cACrE;cACAN,YAAY,CAACO,IAAI,CAAC;gBAChBC,IAAI,EAAG,GAAEJ,SAAU,IAAGE,aAAc,EAAC;gBACrCJ,IAAI,EAAED;cACR,CAAC,CAAC;YACJ;UACF;QACF,CAAC,MAAM;UACL;UACA,IAAIF,iBAAiB,CAACK,SAAS,CAAC,EAAE;YAChC,MAAMH,SAAS,GAAGC,aAAI,CAACnB,OAAO,CAACe,WAAW,EAAEM,SAAS,CAAC;YACtDJ,YAAY,CAACO,IAAI,CAAC;cAChBC,IAAI,EAAEJ,SAAS;cACfF,IAAI,EAAED;YACR,CAAC,CAAC;UACJ;QACF;MACF;IACF,CAAC,CAAC,OAAOQ,KAAK,EAAE;MACdzB,MAAM,CAACyB,KAAK,CAAC;IACf;IAEA1B,OAAO,CAACiB,YAAY,CAAC;EACvB,CAAC,CAAC;AACJ;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/local-storage",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.2",
|
|
4
4
|
"description": "Local storage implementation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/minimatch": "^3.0.3",
|
|
45
45
|
"@types/node": "^14.0.0",
|
|
46
|
-
"@verdaccio/types": "
|
|
46
|
+
"@verdaccio/legacy-types": "1.0.1",
|
|
47
47
|
"minimatch": "^4.0.0",
|
|
48
48
|
"rmdir-sync": "^1.0.1"
|
|
49
49
|
},
|
|
@@ -55,10 +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",
|
|
59
58
|
"build:js": "babel src/ --out-dir lib/ --copy-files --extensions \".ts,.tsx\" --source-maps",
|
|
60
59
|
"watch": "pnpm build:js -- --watch",
|
|
61
|
-
"build": "pnpm run build:js
|
|
62
|
-
}
|
|
63
|
-
"readme": "# @verdaccio/local-storage\n\nš¦ File system storage plugin for verdaccio \n\n[](https://www.npmjs.com/package/@verdaccio/local-storage)\n[](https://circleci.com/gh/verdaccio/local-storage/tree/master)\n[](https://snyk.io/test/github/verdaccio/local-storage?targetFile=package.json)\n[](https://codecov.io/gh/verdaccio/local-storage)\n[](https://opencollective.com/verdaccio)\n[](http://chat.verdaccio.org/)\n\n[](https://www.npmjs.com/package/@verdaccio/local-storage)\n\n> This package is already built-in in verdaccio\n\n```\nnpm install @verdaccio/local-storage\n```\n\n### API\n\n### LocalDatabase\n\nThe main object that handle a JSON database the private packages.\n\n#### Constructor\n\n```\nnew LocalDatabase(config, logger);\n```\n\n* **config**: A verdaccio configuration instance.\n* **logger**: A logger instance\n\n### LocalFS\n\nA class that handle an package instance in the File System\n\n```\nnew LocalFS(packageStoragePath, logger);\n```\n\n\n\n## License\nVerdaccio is [MIT licensed](https://github.com/verdaccio/local-storage/blob/master/LICENSE).\n\n\n[](https://app.fossa.io/projects/git%2Bgithub.com%2Fverdaccio%2Flocal-storage?ref=badge_large)\n"
|
|
60
|
+
"build": "pnpm run build:js"
|
|
61
|
+
}
|
|
64
62
|
}
|
package/lib/index.d.ts
DELETED
package/lib/local-database.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Callback, Config, IPackageStorage, IPluginStorage, LocalStorage, Logger } from '@verdaccio/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;
|
package/lib/local-fs.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ReadTarball } from '@verdaccio/streams';
|
|
3
|
-
import { Callback, Logger, Package, ILocalPackageManager, IUploadTarball } from '@verdaccio/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/pkg-utils.d.ts
DELETED
package/lib/token.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import low from 'lowdb';
|
|
2
|
-
import { ITokenActions, Config, Token, TokenFilter } from '@verdaccio/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
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}[]>;
|