@verdaccio/local-storage 11.0.0-6-next.7 → 11.0.0-6-next.11
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/CHANGELOG.md +104 -0
- package/build/dir-utils.d.ts +34 -0
- package/build/dir-utils.js +126 -0
- package/build/dir-utils.js.map +1 -0
- package/build/fs.d.ts +10 -0
- package/build/fs.js +34 -0
- package/build/fs.js.map +1 -0
- package/build/local-database.d.ts +27 -31
- package/build/local-database.js +157 -196
- package/build/local-database.js.map +1 -1
- package/build/local-fs.d.ts +6 -6
- package/build/local-fs.js +68 -47
- package/build/local-fs.js.map +1 -1
- package/build/pkg-utils.js +7 -4
- package/build/pkg-utils.js.map +1 -1
- package/build/token.d.ts +1 -1
- package/build/token.js +2 -8
- package/build/token.js.map +1 -1
- package/build/utils.js +4 -5
- package/build/utils.js.map +1 -1
- package/package.json +17 -11
- package/build/read-file.d.ts +0 -1
- package/build/read-file.js +0 -21
- package/build/read-file.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,109 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 11.0.0-6-next.11
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- a828271d: refactor: download manifest endpoint and integrate fastify
|
|
8
|
+
|
|
9
|
+
Much simpler API for fetching a package
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
const manifest = await storage.getPackageNext({
|
|
13
|
+
name,
|
|
14
|
+
uplinksLook: true,
|
|
15
|
+
req,
|
|
16
|
+
version: queryVersion,
|
|
17
|
+
requestOptions,
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> not perfect, the `req` still is being passed to the proxy (this has to be refactored at proxy package) and then removed from here, in proxy we pass the request instance to the `request` library.
|
|
22
|
+
|
|
23
|
+
### Details
|
|
24
|
+
|
|
25
|
+
- `async/await` sugar for getPackage()
|
|
26
|
+
- Improve and reuse code between current implementation and new fastify endpoint (add scaffolding for request manifest)
|
|
27
|
+
- Improve performance
|
|
28
|
+
- Add new tests
|
|
29
|
+
|
|
30
|
+
### Breaking changes
|
|
31
|
+
|
|
32
|
+
All storage plugins will stop to work since the storage uses `getPackageNext` method which is Promise based, I won't replace this now because will force me to update all plugins, I'll follow up in another PR. Currently will throw http 500
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [24b9be02]
|
|
37
|
+
- @verdaccio/core@6.0.0-6-next.4
|
|
38
|
+
- @verdaccio/file-locking@11.0.0-6-next.4
|
|
39
|
+
- @verdaccio/streams@11.0.0-6-next.5
|
|
40
|
+
|
|
41
|
+
## 11.0.0-6-next.10
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [6c1eb021]
|
|
46
|
+
- @verdaccio/core@6.0.0-6-next.3
|
|
47
|
+
|
|
48
|
+
## 11.0.0-6-next.9
|
|
49
|
+
|
|
50
|
+
### Minor Changes
|
|
51
|
+
|
|
52
|
+
- 154b2ecd: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Updated dependencies [794af76c]
|
|
57
|
+
- Updated dependencies [154b2ecd]
|
|
58
|
+
- @verdaccio/core@6.0.0-6-next.2
|
|
59
|
+
- @verdaccio/file-locking@11.0.0-6-next.4
|
|
60
|
+
- @verdaccio/streams@11.0.0-6-next.5
|
|
61
|
+
|
|
62
|
+
## 11.0.0-6-next.8
|
|
63
|
+
|
|
64
|
+
### Major Changes
|
|
65
|
+
|
|
66
|
+
- 459b6fa7: refactor: search v1 endpoint and local-database
|
|
67
|
+
|
|
68
|
+
- refactor search `api v1` endpoint, improve performance
|
|
69
|
+
- remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
|
|
70
|
+
- refactor method storage class
|
|
71
|
+
- create new module `core` to reduce the ammount of modules with utilities
|
|
72
|
+
- use `undici` instead `node-fetch`
|
|
73
|
+
- use `fastify` instead `express` for functional test
|
|
74
|
+
|
|
75
|
+
### Breaking changes
|
|
76
|
+
|
|
77
|
+
- plugin storage API changes
|
|
78
|
+
- remove old search endpoint (return 404)
|
|
79
|
+
- filter local private packages at plugin level
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
export interface IPluginStorage<T> extends IPlugin {
|
|
85
|
+
add(name: string): Promise<void>;
|
|
86
|
+
remove(name: string): Promise<void>;
|
|
87
|
+
get(): Promise<any>;
|
|
88
|
+
init(): Promise<void>;
|
|
89
|
+
getSecret(): Promise<string>;
|
|
90
|
+
setSecret(secret: string): Promise<any>;
|
|
91
|
+
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
92
|
+
search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
|
|
93
|
+
saveToken(token: Token): Promise<any>;
|
|
94
|
+
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
95
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Updated dependencies [459b6fa7]
|
|
102
|
+
- @verdaccio/commons-api@11.0.0-6-next.4
|
|
103
|
+
- @verdaccio/core@6.0.0-6-next.1
|
|
104
|
+
- @verdaccio/streams@11.0.0-6-next.4
|
|
105
|
+
- @verdaccio/file-locking@11.0.0-alpha.3
|
|
106
|
+
|
|
3
107
|
## 11.0.0-6-next.7
|
|
4
108
|
|
|
5
109
|
### Patch Changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { searchUtils } from '@verdaccio/core';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve a list of absolute paths to all folders in the given storage path
|
|
4
|
+
* @param storagePath the base path of the storage
|
|
5
|
+
* @return a promise that resolves to an array of absolute paths
|
|
6
|
+
*/
|
|
7
|
+
export declare function getFolders(storagePath: string, pattern?: string): Promise<string[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Search packages on the the storage. The storage could be
|
|
10
|
+
* - storage
|
|
11
|
+
* - pkg1
|
|
12
|
+
* - @company
|
|
13
|
+
* - pkg2 -> @scompany/pkg2
|
|
14
|
+
* - storage1
|
|
15
|
+
* - pkg2
|
|
16
|
+
* - pkg3
|
|
17
|
+
* - storage2
|
|
18
|
+
* - @scope
|
|
19
|
+
* - pkg4 > @scope/pkg4
|
|
20
|
+
* The search return a data structure like:
|
|
21
|
+
* [
|
|
22
|
+
* {
|
|
23
|
+
* name: 'pkg1', // package name could be @scope/pkg1
|
|
24
|
+
* path: absolute/path/package/name
|
|
25
|
+
* }
|
|
26
|
+
* ]
|
|
27
|
+
* @param {string} storagePath is the base path of the storage folder,
|
|
28
|
+
* inside could be packages, storages and @scope packages.
|
|
29
|
+
* @param {Set<string>} storages storages are defined peer package access pattern via `storage` property
|
|
30
|
+
* @param query is the search query from the user via npm search command.
|
|
31
|
+
* and are intended to organize packages in a tree structure.
|
|
32
|
+
* @returns {Promise<searchUtils.SearchItemPkg[]>}
|
|
33
|
+
*/
|
|
34
|
+
export declare function searchOnStorage(storagePath: string, storages: Map<string, string>): Promise<searchUtils.SearchItemPkg[]>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFolders = getFolders;
|
|
7
|
+
exports.searchOnStorage = searchOnStorage;
|
|
8
|
+
|
|
9
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
+
|
|
11
|
+
var _globby = _interopRequireDefault(require("globby"));
|
|
12
|
+
|
|
13
|
+
var _path = require("path");
|
|
14
|
+
|
|
15
|
+
var _core = require("@verdaccio/core");
|
|
16
|
+
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
|
|
19
|
+
const debug = (0, _debug.default)('verdaccio:plugin:local-storage:utils');
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve a list of absolute paths to all folders in the given storage path
|
|
22
|
+
* @param storagePath the base path of the storage
|
|
23
|
+
* @return a promise that resolves to an array of absolute paths
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
async function getFolders(storagePath, pattern = '*') {
|
|
27
|
+
// @ts-ignore - check why this fails, types are correct
|
|
28
|
+
const files = await (0, _globby.default)(pattern, {
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
cwd: storagePath,
|
|
31
|
+
expandDirectories: true,
|
|
32
|
+
onlyDirectories: true,
|
|
33
|
+
onlyFiles: false,
|
|
34
|
+
// should not go deeper than the storage path (10 is reseaon for the storage))
|
|
35
|
+
deep: 10,
|
|
36
|
+
dot: false,
|
|
37
|
+
followSymbolicLinks: true,
|
|
38
|
+
caseSensitiveMatch: true,
|
|
39
|
+
unique: true // FIXME: add here list of forbiden patterns
|
|
40
|
+
// don't include scoped folders.
|
|
41
|
+
// ignore: [`@*`],
|
|
42
|
+
|
|
43
|
+
});
|
|
44
|
+
return files;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Search packages on the the storage. The storage could be
|
|
48
|
+
* - storage
|
|
49
|
+
* - pkg1
|
|
50
|
+
* - @company
|
|
51
|
+
* - pkg2 -> @scompany/pkg2
|
|
52
|
+
* - storage1
|
|
53
|
+
* - pkg2
|
|
54
|
+
* - pkg3
|
|
55
|
+
* - storage2
|
|
56
|
+
* - @scope
|
|
57
|
+
* - pkg4 > @scope/pkg4
|
|
58
|
+
* The search return a data structure like:
|
|
59
|
+
* [
|
|
60
|
+
* {
|
|
61
|
+
* name: 'pkg1', // package name could be @scope/pkg1
|
|
62
|
+
* path: absolute/path/package/name
|
|
63
|
+
* }
|
|
64
|
+
* ]
|
|
65
|
+
* @param {string} storagePath is the base path of the storage folder,
|
|
66
|
+
* inside could be packages, storages and @scope packages.
|
|
67
|
+
* @param {Set<string>} storages storages are defined peer package access pattern via `storage` property
|
|
68
|
+
* @param query is the search query from the user via npm search command.
|
|
69
|
+
* and are intended to organize packages in a tree structure.
|
|
70
|
+
* @returns {Promise<searchUtils.SearchItemPkg[]>}
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
async function searchOnStorage(storagePath, storages) {
|
|
75
|
+
const matchedStorages = Array.from(storages);
|
|
76
|
+
const storageFolders = Array.from(storages.keys()); // const getScopedFolders = async (pkgName) => {
|
|
77
|
+
// const scopedPackages = await getFolders(join(storagePath, pkgName), '*');
|
|
78
|
+
// const listScoped = scopedPackages.map((scoped) => ({
|
|
79
|
+
// name: `${pkgName}/${scoped}`,
|
|
80
|
+
// }));
|
|
81
|
+
// };
|
|
82
|
+
|
|
83
|
+
debug('search on %o', storagePath);
|
|
84
|
+
debug('storage folders %o', matchedStorages.length);
|
|
85
|
+
let results = []; // watch base path and ignore storage folders
|
|
86
|
+
|
|
87
|
+
const basePathFolders = (await getFolders(storagePath, '*')).filter(storageFolder => !storageFolders.includes(storageFolder));
|
|
88
|
+
|
|
89
|
+
for (let store of basePathFolders) {
|
|
90
|
+
if (_core.validatioUtils.isPackageNameScoped(store)) {
|
|
91
|
+
const scopedPackages = await getFolders((0, _path.join)(storagePath, store), '*');
|
|
92
|
+
const listScoped = scopedPackages.map(scoped => ({
|
|
93
|
+
name: `${store}/${scoped}`,
|
|
94
|
+
scoped: store
|
|
95
|
+
}));
|
|
96
|
+
results.push(...listScoped);
|
|
97
|
+
} else {
|
|
98
|
+
results.push({
|
|
99
|
+
name: store
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
} // iterate each storage folder
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
for (const store of storageFolders) {
|
|
106
|
+
const foldersOnStorage = await getFolders((0, _path.join)(storagePath, store), '*');
|
|
107
|
+
|
|
108
|
+
for (let pkgName of foldersOnStorage) {
|
|
109
|
+
if (_core.validatioUtils.isPackageNameScoped(pkgName)) {
|
|
110
|
+
const scopedPackages = await getFolders((0, _path.join)(storagePath, store, pkgName), '*');
|
|
111
|
+
const listScoped = scopedPackages.map(scoped => ({
|
|
112
|
+
name: `${pkgName}/${scoped}`,
|
|
113
|
+
scoped: pkgName
|
|
114
|
+
}));
|
|
115
|
+
results.push(...listScoped);
|
|
116
|
+
} else {
|
|
117
|
+
results.push({
|
|
118
|
+
name: pkgName
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=dir-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dir-utils.ts"],"names":["debug","getFolders","storagePath","pattern","files","cwd","expandDirectories","onlyDirectories","onlyFiles","deep","dot","followSymbolicLinks","caseSensitiveMatch","unique","searchOnStorage","storages","matchedStorages","Array","from","storageFolders","keys","length","results","basePathFolders","filter","storageFolder","includes","store","validatioUtils","isPackageNameScoped","scopedPackages","listScoped","map","scoped","name","push","foldersOnStorage","pkgName"],"mappings":"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","sourcesContent":["import buildDebug from 'debug';\nimport globby from 'globby';\nimport { join } from 'path';\n\nimport { searchUtils, validatioUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:local-storage:utils');\n\n/**\n * Retrieve a list of absolute paths to all folders in the given storage path\n * @param storagePath the base path of the storage\n * @return a promise that resolves to an array of absolute paths\n */\nexport async function getFolders(storagePath: string, pattern = '*'): Promise<string[]> {\n // @ts-ignore - check why this fails, types are correct\n const files = await globby(pattern, {\n // @ts-ignore\n cwd: storagePath,\n expandDirectories: true,\n onlyDirectories: true,\n onlyFiles: false,\n // should not go deeper than the storage path (10 is reseaon for the storage))\n deep: 10,\n dot: false,\n followSymbolicLinks: true,\n caseSensitiveMatch: true,\n unique: true,\n // FIXME: add here list of forbiden patterns\n // don't include scoped folders.\n // ignore: [`@*`],\n });\n return files;\n}\n\n/**\n * Search packages on the the storage. The storage could be\n * - storage\n * - pkg1\n * - @company\n * - pkg2 -> @scompany/pkg2\n * - storage1\n * - pkg2\n * - pkg3\n * - storage2\n * - @scope\n * - pkg4 > @scope/pkg4\n * The search return a data structure like:\n * [\n * {\n * name: 'pkg1', // package name could be @scope/pkg1\n * path: absolute/path/package/name\n * }\n * ]\n * @param {string} storagePath is the base path of the storage folder,\n * inside could be packages, storages and @scope packages.\n * @param {Set<string>} storages storages are defined peer package access pattern via `storage` property\n * @param query is the search query from the user via npm search command.\n * and are intended to organize packages in a tree structure.\n * @returns {Promise<searchUtils.SearchItemPkg[]>}\n */\nexport async function searchOnStorage(\n storagePath: string,\n storages: Map<string, string>\n): Promise<searchUtils.SearchItemPkg[]> {\n const matchedStorages = Array.from(storages);\n const storageFolders = Array.from(storages.keys());\n // const getScopedFolders = async (pkgName) => {\n // const scopedPackages = await getFolders(join(storagePath, pkgName), '*');\n // const listScoped = scopedPackages.map((scoped) => ({\n // name: `${pkgName}/${scoped}`,\n // }));\n // };\n debug('search on %o', storagePath);\n debug('storage folders %o', matchedStorages.length);\n let results: searchUtils.SearchItemPkg[] = [];\n // watch base path and ignore storage folders\n const basePathFolders = (await getFolders(storagePath, '*')).filter(\n (storageFolder) => !storageFolders.includes(storageFolder)\n );\n\n for (let store of basePathFolders) {\n if (validatioUtils.isPackageNameScoped(store)) {\n const scopedPackages = await getFolders(join(storagePath, store), '*');\n const listScoped = scopedPackages.map((scoped) => ({\n name: `${store}/${scoped}`,\n scoped: store,\n }));\n results.push(...listScoped);\n } else {\n results.push({\n name: store,\n });\n }\n }\n\n // iterate each storage folder\n for (const store of storageFolders) {\n const foldersOnStorage = await getFolders(join(storagePath, store), '*');\n for (let pkgName of foldersOnStorage) {\n if (validatioUtils.isPackageNameScoped(pkgName)) {\n const scopedPackages = await getFolders(join(storagePath, store, pkgName), '*');\n const listScoped = scopedPackages.map((scoped) => ({\n name: `${pkgName}/${scoped}`,\n scoped: pkgName,\n }));\n results.push(...listScoped);\n } else {\n results.push({\n name: pkgName,\n });\n }\n }\n }\n\n return results;\n}\n"],"file":"dir-utils.js"}
|
package/build/fs.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
declare const mkdirPromise: typeof fs.mkdir.__promisify__;
|
|
4
|
+
declare const writeFilePromise: typeof fs.writeFile.__promisify__;
|
|
5
|
+
declare const readdirPromise: typeof fs.readdir.__promisify__;
|
|
6
|
+
declare const statPromise: typeof fs.stat.__promisify__;
|
|
7
|
+
declare const unlinkPromise: typeof fs.unlink.__promisify__;
|
|
8
|
+
declare const rmdirPromise: typeof fs.rmdir.__promisify__;
|
|
9
|
+
export declare const readFilePromise: (path: any) => Promise<string>;
|
|
10
|
+
export { mkdirPromise, writeFilePromise, readdirPromise, statPromise, unlinkPromise, rmdirPromise };
|
package/build/fs.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.writeFilePromise = exports.unlinkPromise = exports.statPromise = exports.rmdirPromise = exports.readdirPromise = exports.readFilePromise = exports.mkdirPromise = void 0;
|
|
7
|
+
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
|
|
10
|
+
var _util = require("util");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
// FUTURE: when v15 is min replace by fs/promises
|
|
15
|
+
const readFile = (0, _util.promisify)(_fs.default.readFile);
|
|
16
|
+
const mkdirPromise = (0, _util.promisify)(_fs.default.mkdir);
|
|
17
|
+
exports.mkdirPromise = mkdirPromise;
|
|
18
|
+
const writeFilePromise = (0, _util.promisify)(_fs.default.writeFile);
|
|
19
|
+
exports.writeFilePromise = writeFilePromise;
|
|
20
|
+
const readdirPromise = (0, _util.promisify)(_fs.default.readdir);
|
|
21
|
+
exports.readdirPromise = readdirPromise;
|
|
22
|
+
const statPromise = (0, _util.promisify)(_fs.default.stat);
|
|
23
|
+
exports.statPromise = statPromise;
|
|
24
|
+
const unlinkPromise = (0, _util.promisify)(_fs.default.unlink);
|
|
25
|
+
exports.unlinkPromise = unlinkPromise;
|
|
26
|
+
const rmdirPromise = (0, _util.promisify)(_fs.default.rmdir);
|
|
27
|
+
exports.rmdirPromise = rmdirPromise;
|
|
28
|
+
|
|
29
|
+
const readFilePromise = async path => {
|
|
30
|
+
return await readFile(path, 'utf8');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.readFilePromise = readFilePromise;
|
|
34
|
+
//# sourceMappingURL=fs.js.map
|
package/build/fs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fs.ts"],"names":["readFile","fs","mkdirPromise","mkdir","writeFilePromise","writeFile","readdirPromise","readdir","statPromise","stat","unlinkPromise","unlink","rmdirPromise","rmdir","readFilePromise","path"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA;AACA,MAAMA,QAAQ,GAAG,qBAAUC,YAAGD,QAAb,CAAjB;AACA,MAAME,YAAY,GAAG,qBAAUD,YAAGE,KAAb,CAArB;;AACA,MAAMC,gBAAgB,GAAG,qBAAUH,YAAGI,SAAb,CAAzB;;AACA,MAAMC,cAAc,GAAG,qBAAUL,YAAGM,OAAb,CAAvB;;AACA,MAAMC,WAAW,GAAG,qBAAUP,YAAGQ,IAAb,CAApB;;AACA,MAAMC,aAAa,GAAG,qBAAUT,YAAGU,MAAb,CAAtB;;AACA,MAAMC,YAAY,GAAG,qBAAUX,YAAGY,KAAb,CAArB;;;AAEO,MAAMC,eAAe,GAAG,MAAOC,IAAP,IAAgB;AAC7C,SAAO,MAAMf,QAAQ,CAACe,IAAD,EAAO,MAAP,CAArB;AACD,CAFM","sourcesContent":["import fs from 'fs';\nimport { promisify } from 'util';\n\n// FUTURE: when v15 is min replace by fs/promises\nconst readFile = promisify(fs.readFile);\nconst mkdirPromise = promisify(fs.mkdir);\nconst writeFilePromise = promisify(fs.writeFile);\nconst readdirPromise = promisify(fs.readdir);\nconst statPromise = promisify(fs.stat);\nconst unlinkPromise = promisify(fs.unlink);\nconst rmdirPromise = promisify(fs.rmdir);\n\nexport const readFilePromise = async (path) => {\n return await readFile(path, 'utf8');\n};\n\nexport { mkdirPromise, writeFilePromise, readdirPromise, statPromise, unlinkPromise, rmdirPromise };\n"],"file":"fs.js"}
|
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pluginUtils, searchUtils } from '@verdaccio/core';
|
|
2
|
+
import { Config, IPackageStorage, LocalStorage, Logger } from '@verdaccio/types';
|
|
2
3
|
import TokenActions from './token';
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const ERROR_DB_LOCKED = "Database is locked, please check error message printed during startup to prevent data loss";
|
|
5
|
+
declare type IPluginStorage = pluginUtils.IPluginStorage<{}>;
|
|
6
|
+
declare class LocalDatabase extends TokenActions implements IPluginStorage {
|
|
7
|
+
private readonly path;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
readonly config: Config;
|
|
10
|
+
readonly storages: Map<string, string>;
|
|
11
|
+
data: LocalStorage | void;
|
|
8
12
|
locked: boolean;
|
|
9
13
|
constructor(config: Config, logger: Logger);
|
|
10
14
|
init(): Promise<void>;
|
|
11
15
|
getSecret(): Promise<string>;
|
|
12
|
-
setSecret(secret: string): Promise<
|
|
13
|
-
add(name: string
|
|
14
|
-
search(onPackage: Callback, onEnd: Callback, validateName: (name: string) => boolean): void;
|
|
15
|
-
remove(name: string, cb: Callback): void;
|
|
16
|
+
setSecret(secret: string): Promise<void>;
|
|
17
|
+
add(name: string): Promise<void>;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
* The field storage could be absolute or relative.
|
|
20
|
+
* If relative, it will be resolved against the config path.
|
|
21
|
+
* If absolute, it will be returned as is.
|
|
22
|
+
**/
|
|
23
|
+
private getStoragePath;
|
|
24
|
+
private getBaseConfigPath;
|
|
25
|
+
/**
|
|
26
|
+
* Filter by query.
|
|
27
|
+
**/
|
|
28
|
+
filterByQuery(results: searchUtils.SearchItemPkg[], query: searchUtils.SearchQuery): Promise<searchUtils.SearchItemPkg[]>;
|
|
29
|
+
getScore(_pkg: searchUtils.SearchItemPkg): Promise<searchUtils.Score>;
|
|
30
|
+
search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
|
|
31
|
+
remove(name: string): Promise<void>;
|
|
32
|
+
get(): Promise<any>;
|
|
21
33
|
getPackageStorage(packageName: string): IPackageStorage;
|
|
22
|
-
clean(): void
|
|
23
|
-
private getTime;
|
|
34
|
+
clean(): Promise<void>;
|
|
24
35
|
private _getCustomPackageLocalStorages;
|
|
25
|
-
/**
|
|
26
|
-
* Syncronize {create} database whether does not exist.
|
|
27
|
-
* @return {Error|*}
|
|
28
|
-
*/
|
|
29
36
|
private _sync;
|
|
30
|
-
/**
|
|
31
|
-
* Verify the right local storage location.
|
|
32
|
-
* @param {String} path
|
|
33
|
-
* @return {String}
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
37
|
private _getLocalStoragePath;
|
|
37
|
-
/**
|
|
38
|
-
* Fetch local packages.
|
|
39
|
-
* @private
|
|
40
|
-
* @return {Object}
|
|
41
|
-
*/
|
|
42
38
|
private _fetchLocalPackages;
|
|
43
39
|
}
|
|
44
40
|
export default LocalDatabase;
|