@verdaccio/store 6.0.0-6-next.27 → 6.0.0-6-next.28
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 +81 -0
- package/build/local-storage.d.ts +2 -2
- package/build/local-storage.js +15 -8
- package/build/local-storage.js.map +1 -1
- package/build/storage.d.ts +5 -6
- package/build/storage.js +40 -35
- package/build/storage.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +14 -14
- package/src/local-storage.ts +19 -15
- package/src/storage.ts +42 -46
- package/test/fixtures/config/deprecate.yaml +15 -0
- package/test/storage.spec.ts +337 -190
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# @verdaccio/store
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.28
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 9fc2e796: feat(plugins): improve plugin loader
|
|
8
|
+
|
|
9
|
+
### Changes
|
|
10
|
+
|
|
11
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
12
|
+
- Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
|
|
13
|
+
- https://github.com/verdaccio/verdaccio/issues/1394
|
|
14
|
+
- `config.plugins` plugin path validations
|
|
15
|
+
- Updated algorithm for plugin loader.
|
|
16
|
+
- improved documentation (included dev)
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
21
|
+
- Custom prefix:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
// config.yaml
|
|
25
|
+
server:
|
|
26
|
+
pluginPrefix: mycompany
|
|
27
|
+
middleware:
|
|
28
|
+
audit:
|
|
29
|
+
foo: 1
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
|
|
33
|
+
|
|
34
|
+
## Breaking Changes
|
|
35
|
+
|
|
36
|
+
### sinopia plugins
|
|
37
|
+
|
|
38
|
+
- `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
|
|
39
|
+
|
|
40
|
+
### plugin filter
|
|
41
|
+
|
|
42
|
+
- method rename `filter_metadata`->`filterMetadata`
|
|
43
|
+
|
|
44
|
+
### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
|
|
45
|
+
|
|
46
|
+
The plugin receives as first argument `config`, which represents the config of the plugin. Example:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
// config.yaml
|
|
50
|
+
auth:
|
|
51
|
+
plugin:
|
|
52
|
+
foo: 1
|
|
53
|
+
bar: 2
|
|
54
|
+
|
|
55
|
+
export class Plugin<T> {
|
|
56
|
+
public constructor(config: T, options: PluginOptions) {
|
|
57
|
+
console.log(config);
|
|
58
|
+
// {foo:1, bar: 2}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Minor Changes
|
|
64
|
+
|
|
65
|
+
- 62c24b63: feat: add passwordValidationRegex property
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- 43f32687: fix: abbreviated headers handle quality values
|
|
70
|
+
- Updated dependencies [43f32687]
|
|
71
|
+
- Updated dependencies [9fc2e796]
|
|
72
|
+
- Updated dependencies [62c24b63]
|
|
73
|
+
- @verdaccio/core@6.0.0-6-next.48
|
|
74
|
+
- @verdaccio/config@6.0.0-6-next.48
|
|
75
|
+
- @verdaccio/loaders@6.0.0-6-next.17
|
|
76
|
+
- @verdaccio/local-storage@11.0.0-6-next.18
|
|
77
|
+
- @verdaccio/utils@6.0.0-6-next.16
|
|
78
|
+
- @verdaccio/tarball@11.0.0-6-next.17
|
|
79
|
+
- @verdaccio/url@11.0.0-6-next.14
|
|
80
|
+
- @verdaccio/hooks@6.0.0-6-next.18
|
|
81
|
+
- @verdaccio/logger@6.0.0-6-next.16
|
|
82
|
+
- @verdaccio/proxy@6.0.0-6-next.26
|
|
83
|
+
|
|
3
84
|
## 6.0.0-6-next.27
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
package/build/local-storage.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare class LocalStorage {
|
|
|
14
14
|
init(): Promise<void>;
|
|
15
15
|
getStoragePlugin(): IPluginStorage;
|
|
16
16
|
getSecret(config: Config): Promise<void>;
|
|
17
|
-
private
|
|
18
|
-
private
|
|
17
|
+
private loadStorage;
|
|
18
|
+
private loadStorePlugin;
|
|
19
19
|
}
|
|
20
20
|
export { LocalStorage };
|
package/build/local-storage.js
CHANGED
|
@@ -41,7 +41,7 @@ class LocalStorage {
|
|
|
41
41
|
|
|
42
42
|
async init() {
|
|
43
43
|
if (this.storagePlugin === null) {
|
|
44
|
-
this.storagePlugin = this.
|
|
44
|
+
this.storagePlugin = await this.loadStorage(this.config, this.logger);
|
|
45
45
|
debug('storage plugin init');
|
|
46
46
|
await this.storagePlugin.init();
|
|
47
47
|
debug('storage plugin initialized');
|
|
@@ -65,25 +65,32 @@ class LocalStorage {
|
|
|
65
65
|
return this.storagePlugin.setSecret(config.checkSecretKey(secretKey));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
const Storage = this.
|
|
68
|
+
async loadStorage(config, logger) {
|
|
69
|
+
const Storage = await this.loadStorePlugin();
|
|
70
70
|
|
|
71
71
|
if (_lodash.default.isNil(Storage)) {
|
|
72
72
|
(0, _assert.default)(this.config.storage, 'CONFIG: storage path not defined');
|
|
73
|
+
debug('no custom storage found, loading default storage @verdaccio/local-storage');
|
|
73
74
|
return new _localStorage.default(config, logger);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
return Storage;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
async loadStorePlugin() {
|
|
81
|
+
var _this$config, _this$config$serverSe;
|
|
82
|
+
|
|
83
|
+
const plugins = await (0, _loaders.asyncLoadPlugin)(this.config.store, {
|
|
81
84
|
config: this.config,
|
|
82
85
|
logger: this.logger
|
|
83
|
-
}
|
|
84
|
-
const plugins = (0, _loaders.loadPlugin)(this.config, this.config.store, plugin_params, plugin => {
|
|
86
|
+
}, plugin => {
|
|
85
87
|
return plugin.getPackageStorage;
|
|
86
|
-
});
|
|
88
|
+
}, (_this$config = this.config) === null || _this$config === void 0 ? void 0 : (_this$config$serverSe = _this$config.serverSettings) === null || _this$config$serverSe === void 0 ? void 0 : _this$config$serverSe.pluginPrefix);
|
|
89
|
+
|
|
90
|
+
if (plugins.length > 1) {
|
|
91
|
+
this.logger.warn('more than one storage plugins has been detected, multiple storage are not supported, one will be selected automatically');
|
|
92
|
+
}
|
|
93
|
+
|
|
87
94
|
return _lodash.default.head(plugins);
|
|
88
95
|
}
|
|
89
96
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.js","names":["debug","buildDebug","noSuchFile","resourceNotAvailable","LocalStorage","constructor","config","logger","child","sub","storagePlugin","init","
|
|
1
|
+
{"version":3,"file":"local-storage.js","names":["debug","buildDebug","noSuchFile","resourceNotAvailable","LocalStorage","constructor","config","logger","child","sub","storagePlugin","init","loadStorage","warn","getStoragePlugin","errorUtils","getInternalError","getSecret","secretKey","setSecret","checkSecretKey","Storage","loadStorePlugin","_","isNil","assert","storage","LocalDatabase","plugins","asyncLoadPlugin","store","plugin","getPackageStorage","serverSettings","pluginPrefix","length","head"],"sources":["../src/local-storage.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { errorUtils, pluginUtils } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport LocalDatabase from '@verdaccio/local-storage';\nimport { Config, Logger } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:storage:local');\n\nexport const noSuchFile = 'ENOENT';\nexport const resourceNotAvailable = 'EAGAIN';\nexport type IPluginStorage = pluginUtils.IPluginStorage<Config>;\n\n/**\n * Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).\n */\nclass LocalStorage {\n public config: Config;\n public storagePlugin: IPluginStorage;\n public logger: Logger;\n\n public constructor(config: Config, logger: Logger) {\n debug('local storage created');\n this.logger = logger.child({ sub: 'fs' });\n this.config = config;\n // @ts-expect-error\n this.storagePlugin = null;\n }\n\n public async init() {\n if (this.storagePlugin === null) {\n this.storagePlugin = await this.loadStorage(this.config, this.logger);\n debug('storage plugin init');\n await this.storagePlugin.init();\n debug('storage plugin initialized');\n } else {\n this.logger.warn('storage plugin has been already initialized');\n }\n return;\n }\n\n public getStoragePlugin(): IPluginStorage {\n if (this.storagePlugin === null) {\n throw errorUtils.getInternalError('storage plugin is not initialized');\n }\n\n return this.storagePlugin;\n }\n\n public async getSecret(config: Config): Promise<void> {\n const secretKey = await this.storagePlugin.getSecret();\n\n return this.storagePlugin.setSecret(config.checkSecretKey(secretKey));\n }\n\n private async loadStorage(config: Config, logger: Logger): Promise<IPluginStorage> {\n const Storage = await this.loadStorePlugin();\n if (_.isNil(Storage)) {\n assert(this.config.storage, 'CONFIG: storage path not defined');\n debug('no custom storage found, loading default storage @verdaccio/local-storage');\n return new LocalDatabase(config, logger);\n }\n return Storage as IPluginStorage;\n }\n\n private async loadStorePlugin(): Promise<IPluginStorage | undefined> {\n const plugins: IPluginStorage[] = await asyncLoadPlugin<IPluginStorage>(\n this.config.store,\n {\n config: this.config,\n logger: this.logger,\n },\n (plugin): IPluginStorage => {\n return plugin.getPackageStorage;\n },\n this.config?.serverSettings?.pluginPrefix\n );\n\n if (plugins.length > 1) {\n this.logger.warn(\n 'more than one storage plugins has been detected, multiple storage are not supported, one will be selected automatically'\n );\n }\n\n return _.head(plugins);\n }\n}\n\nexport { LocalStorage };\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAGA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,yBAAX,CAAd;AAEO,MAAMC,UAAU,GAAG,QAAnB;;AACA,MAAMC,oBAAoB,GAAG,QAA7B;;;AAGP;AACA;AACA;AACA,MAAMC,YAAN,CAAmB;EAKVC,WAAW,CAACC,MAAD,EAAiBC,MAAjB,EAAiC;IACjDP,KAAK,CAAC,uBAAD,CAAL;IACA,KAAKO,MAAL,GAAcA,MAAM,CAACC,KAAP,CAAa;MAAEC,GAAG,EAAE;IAAP,CAAb,CAAd;IACA,KAAKH,MAAL,GAAcA,MAAd,CAHiD,CAIjD;;IACA,KAAKI,aAAL,GAAqB,IAArB;EACD;;EAEgB,MAAJC,IAAI,GAAG;IAClB,IAAI,KAAKD,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,KAAKA,aAAL,GAAqB,MAAM,KAAKE,WAAL,CAAiB,KAAKN,MAAtB,EAA8B,KAAKC,MAAnC,CAA3B;MACAP,KAAK,CAAC,qBAAD,CAAL;MACA,MAAM,KAAKU,aAAL,CAAmBC,IAAnB,EAAN;MACAX,KAAK,CAAC,4BAAD,CAAL;IACD,CALD,MAKO;MACL,KAAKO,MAAL,CAAYM,IAAZ,CAAiB,6CAAjB;IACD;;IACD;EACD;;EAEMC,gBAAgB,GAAmB;IACxC,IAAI,KAAKJ,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,MAAMK,gBAAA,CAAWC,gBAAX,CAA4B,mCAA5B,CAAN;IACD;;IAED,OAAO,KAAKN,aAAZ;EACD;;EAEqB,MAATO,SAAS,CAACX,MAAD,EAAgC;IACpD,MAAMY,SAAS,GAAG,MAAM,KAAKR,aAAL,CAAmBO,SAAnB,EAAxB;IAEA,OAAO,KAAKP,aAAL,CAAmBS,SAAnB,CAA6Bb,MAAM,CAACc,cAAP,CAAsBF,SAAtB,CAA7B,CAAP;EACD;;EAEwB,MAAXN,WAAW,CAACN,MAAD,EAAiBC,MAAjB,EAA0D;IACjF,MAAMc,OAAO,GAAG,MAAM,KAAKC,eAAL,EAAtB;;IACA,IAAIC,eAAA,CAAEC,KAAF,CAAQH,OAAR,CAAJ,EAAsB;MACpB,IAAAI,eAAA,EAAO,KAAKnB,MAAL,CAAYoB,OAAnB,EAA4B,kCAA5B;MACA1B,KAAK,CAAC,2EAAD,CAAL;MACA,OAAO,IAAI2B,qBAAJ,CAAkBrB,MAAlB,EAA0BC,MAA1B,CAAP;IACD;;IACD,OAAOc,OAAP;EACD;;EAE4B,MAAfC,eAAe,GAAwC;IAAA;;IACnE,MAAMM,OAAyB,GAAG,MAAM,IAAAC,wBAAA,EACtC,KAAKvB,MAAL,CAAYwB,KAD0B,EAEtC;MACExB,MAAM,EAAE,KAAKA,MADf;MAEEC,MAAM,EAAE,KAAKA;IAFf,CAFsC,EAMrCwB,MAAD,IAA4B;MAC1B,OAAOA,MAAM,CAACC,iBAAd;IACD,CARqC,kBAStC,KAAK1B,MATiC,0EAStC,aAAa2B,cATyB,0DAStC,sBAA6BC,YATS,CAAxC;;IAYA,IAAIN,OAAO,CAACO,MAAR,GAAiB,CAArB,EAAwB;MACtB,KAAK5B,MAAL,CAAYM,IAAZ,CACE,yHADF;IAGD;;IAED,OAAOU,eAAA,CAAEa,IAAF,CAAOR,OAAP,CAAP;EACD;;AArEgB"}
|
package/build/storage.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const resourceNotAvailable = "EAGAIN";
|
|
|
12
12
|
export declare const PROTO_NAME = "__proto__";
|
|
13
13
|
declare class Storage {
|
|
14
14
|
localStorage: LocalStorage;
|
|
15
|
-
filters: IPluginFilters;
|
|
15
|
+
filters: IPluginFilters | null;
|
|
16
16
|
readonly config: Config;
|
|
17
17
|
readonly logger: Logger;
|
|
18
18
|
readonly uplinks: ProxyInstanceList;
|
|
@@ -23,7 +23,7 @@ declare class Storage {
|
|
|
23
23
|
Function changes a package info from local storage and all uplinks with write access./
|
|
24
24
|
Used storages: local (write)
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
changePackage(name: string, metadata: Manifest, revision: string): Promise<void>;
|
|
27
27
|
removePackage(name: string, revision: any): Promise<void>;
|
|
28
28
|
/**
|
|
29
29
|
Remove a tarball from a system
|
|
@@ -70,7 +70,7 @@ declare class Storage {
|
|
|
70
70
|
* @param filters IPluginFilters
|
|
71
71
|
* @returns Storage instance
|
|
72
72
|
*/
|
|
73
|
-
init(config: Config
|
|
73
|
+
init(config: Config): Promise<void>;
|
|
74
74
|
/**
|
|
75
75
|
* Consume the upstream and pipe it to a transformable stream.
|
|
76
76
|
*/
|
|
@@ -114,7 +114,6 @@ declare class Storage {
|
|
|
114
114
|
*/
|
|
115
115
|
mergeTagsNext(name: string, tags: MergeTags): Promise<Manifest>;
|
|
116
116
|
private getUpLinkForDistFile;
|
|
117
|
-
updateLocalMetadata(pkgName: string): Promise<void>;
|
|
118
117
|
updateManifest(manifest: Manifest, options: UpdateManifestOptions): Promise<void>;
|
|
119
118
|
private deprecate;
|
|
120
119
|
private star;
|
|
@@ -183,14 +182,14 @@ declare class Storage {
|
|
|
183
182
|
*/
|
|
184
183
|
private checkPackageRemote;
|
|
185
184
|
private setDefaultRevision;
|
|
186
|
-
private
|
|
185
|
+
private writePackage;
|
|
187
186
|
/**
|
|
188
187
|
* @param {*} name package name
|
|
189
188
|
* @param {*} updateHandler function(package, cb) - update function
|
|
190
189
|
* @param {*} callback callback that gets invoked after it's all updated
|
|
191
190
|
* @return {Function}
|
|
192
191
|
*/
|
|
193
|
-
private
|
|
192
|
+
private updatePackage;
|
|
194
193
|
/**
|
|
195
194
|
*
|
|
196
195
|
* @protected
|
package/build/storage.js
CHANGED
|
@@ -23,6 +23,8 @@ var _config = require("@verdaccio/config");
|
|
|
23
23
|
|
|
24
24
|
var _core = require("@verdaccio/core");
|
|
25
25
|
|
|
26
|
+
var _loaders = require("@verdaccio/loaders");
|
|
27
|
+
|
|
26
28
|
var _logger = require("@verdaccio/logger");
|
|
27
29
|
|
|
28
30
|
var _proxy = require("@verdaccio/proxy");
|
|
@@ -68,20 +70,20 @@ class Storage {
|
|
|
68
70
|
this.logger = _logger.logger.child({
|
|
69
71
|
module: 'storage'
|
|
70
72
|
});
|
|
71
|
-
this.filters =
|
|
73
|
+
this.filters = null; // @ts-ignore
|
|
72
74
|
|
|
73
75
|
this.localStorage = null;
|
|
74
76
|
debug('uplinks available %o', Object.keys(this.uplinks));
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
static ABBREVIATED_HEADER = 'application/vnd.npm.install-v1+json
|
|
79
|
+
static ABBREVIATED_HEADER = 'application/vnd.npm.install-v1+json';
|
|
78
80
|
/**
|
|
79
81
|
* Change an existing package (i.e. unpublish one version)
|
|
80
82
|
Function changes a package info from local storage and all uplinks with write access./
|
|
81
83
|
Used storages: local (write)
|
|
82
84
|
*/
|
|
83
85
|
|
|
84
|
-
async
|
|
86
|
+
async changePackage(name, metadata, revision) {
|
|
85
87
|
debug('change existing package for package %o revision %o', name, revision);
|
|
86
88
|
debug(`change manifest tags for %o revision %s`, name, revision);
|
|
87
89
|
|
|
@@ -91,7 +93,7 @@ class Storage {
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
debug(`change manifest udapting manifest for %o`, name);
|
|
94
|
-
await this.
|
|
96
|
+
await this.updatePackage(name, async localData => {
|
|
95
97
|
// eslint-disable-next-line guard-for-in
|
|
96
98
|
for (const version in localData.versions) {
|
|
97
99
|
const incomingVersion = metadata.versions[version];
|
|
@@ -178,7 +180,7 @@ class Storage {
|
|
|
178
180
|
throw err;
|
|
179
181
|
}
|
|
180
182
|
|
|
181
|
-
const manifest = await this.
|
|
183
|
+
const manifest = await this.updatePackage(name, async data => {
|
|
182
184
|
let newData = { ...data
|
|
183
185
|
};
|
|
184
186
|
delete data._attachments[filename];
|
|
@@ -634,10 +636,8 @@ class Storage {
|
|
|
634
636
|
*/
|
|
635
637
|
|
|
636
638
|
|
|
637
|
-
async init(config
|
|
639
|
+
async init(config) {
|
|
638
640
|
if (this.localStorage === null) {
|
|
639
|
-
this.filters = filters || [];
|
|
640
|
-
debug('filters available %o', filters);
|
|
641
641
|
this.localStorage = new _localStorage.LocalStorage(this.config, _logger.logger);
|
|
642
642
|
await this.localStorage.init();
|
|
643
643
|
debug('local init storage initialized');
|
|
@@ -647,6 +647,18 @@ class Storage {
|
|
|
647
647
|
debug('storage has been already initialized');
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
+
if (!this.filters) {
|
|
651
|
+
var _this$config, _this$config$serverSe;
|
|
652
|
+
|
|
653
|
+
this.filters = await (0, _loaders.asyncLoadPlugin)(this.config.filters, {
|
|
654
|
+
config: this.config,
|
|
655
|
+
logger: this.logger
|
|
656
|
+
}, plugin => {
|
|
657
|
+
return plugin.filterMetadata;
|
|
658
|
+
}, (_this$config = this.config) === null || _this$config === void 0 ? void 0 : (_this$config$serverSe = _this$config.serverSettings) === null || _this$config$serverSe === void 0 ? void 0 : _this$config$serverSe.pluginPrefix);
|
|
659
|
+
debug('filters available %o', this.filters);
|
|
660
|
+
}
|
|
661
|
+
|
|
650
662
|
return;
|
|
651
663
|
}
|
|
652
664
|
/**
|
|
@@ -876,7 +888,7 @@ class Storage {
|
|
|
876
888
|
|
|
877
889
|
|
|
878
890
|
async mergeTagsNext(name, tags) {
|
|
879
|
-
return await this.
|
|
891
|
+
return await this.updatePackage(name, async data => {
|
|
880
892
|
let newData = { ...data
|
|
881
893
|
};
|
|
882
894
|
|
|
@@ -920,14 +932,6 @@ class Storage {
|
|
|
920
932
|
return uplink;
|
|
921
933
|
}
|
|
922
934
|
|
|
923
|
-
async updateLocalMetadata(pkgName) {
|
|
924
|
-
const storage = this.getPrivatePackageStorage(pkgName);
|
|
925
|
-
|
|
926
|
-
if (!storage) {
|
|
927
|
-
throw _core.errorUtils.getNotFound();
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
|
|
931
935
|
async updateManifest(manifest, options) {
|
|
932
936
|
if ((0, _2.isDeprecatedManifest)(manifest)) {
|
|
933
937
|
// if the manifest is deprecated, we need to update the package.json
|
|
@@ -967,15 +971,14 @@ class Storage {
|
|
|
967
971
|
|
|
968
972
|
throw _core.errorUtils.getBadRequest(_core.API_ERROR.UNSUPORTED_REGISTRY_CALL);
|
|
969
973
|
}
|
|
970
|
-
}
|
|
971
|
-
|
|
974
|
+
}
|
|
972
975
|
|
|
973
|
-
async deprecate(
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
976
|
+
async deprecate(manifest, options) {
|
|
977
|
+
const {
|
|
978
|
+
name
|
|
979
|
+
} = manifest;
|
|
980
|
+
debug('deprecating %s', name);
|
|
981
|
+
return this.changePackage(name, manifest, options.revision);
|
|
979
982
|
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
980
983
|
|
|
981
984
|
|
|
@@ -1073,7 +1076,7 @@ class Storage {
|
|
|
1073
1076
|
const buffer = this.getBufferManifest(body._attachments[firstAttachmentKey].data);
|
|
1074
1077
|
|
|
1075
1078
|
try {
|
|
1076
|
-
var _this$
|
|
1079
|
+
var _this$config2, _this$config2$publish;
|
|
1077
1080
|
|
|
1078
1081
|
// we check if package exist already locally
|
|
1079
1082
|
const manifest = await this.getPackagelocalByNameNext(name); // if continue, the version to be published does not exist
|
|
@@ -1083,7 +1086,7 @@ class Storage {
|
|
|
1083
1086
|
throw _core.errorUtils.getConflict();
|
|
1084
1087
|
}
|
|
1085
1088
|
|
|
1086
|
-
const uplinksLook = ((_this$
|
|
1089
|
+
const uplinksLook = ((_this$config2 = this.config) === null || _this$config2 === void 0 ? void 0 : (_this$config2$publish = _this$config2.publish) === null || _this$config2$publish === void 0 ? void 0 : _this$config2$publish.allow_offline) === false; // if execution get here, package does not exist locally, we search upstream
|
|
1087
1090
|
|
|
1088
1091
|
const remoteManifest = await this.checkPackageRemote(name, uplinksLook);
|
|
1089
1092
|
|
|
@@ -1268,7 +1271,7 @@ class Storage {
|
|
|
1268
1271
|
try {
|
|
1269
1272
|
debug('uploaded tarball %o for %o', filename, pkgName); // update the package metadata
|
|
1270
1273
|
|
|
1271
|
-
await this.
|
|
1274
|
+
await this.updatePackage(pkgName, async data => {
|
|
1272
1275
|
const newData = { ...data
|
|
1273
1276
|
};
|
|
1274
1277
|
debug('added _attachment for %o', pkgName);
|
|
@@ -1306,7 +1309,7 @@ class Storage {
|
|
|
1306
1309
|
|
|
1307
1310
|
async addVersionNext(name, version, metadata, tag) {
|
|
1308
1311
|
debug(`add version %s package for %s`, version, name);
|
|
1309
|
-
await this.
|
|
1312
|
+
await this.updatePackage(name, async data => {
|
|
1310
1313
|
// keep only one readme per package
|
|
1311
1314
|
data.readme = metadata.readme;
|
|
1312
1315
|
debug('%s` readme mutated', name); // TODO: lodash remove
|
|
@@ -1470,13 +1473,15 @@ class Storage {
|
|
|
1470
1473
|
|
|
1471
1474
|
|
|
1472
1475
|
if (_lodash.default.isNil(this.config._debug)) {
|
|
1476
|
+
const prev = json._rev;
|
|
1473
1477
|
json._rev = (0, _storageUtils.generateRevision)(json._rev);
|
|
1478
|
+
debug('revision metadata for %s updated from %s to %s', json.name, prev, json._rev);
|
|
1474
1479
|
}
|
|
1475
1480
|
|
|
1476
1481
|
return json;
|
|
1477
1482
|
}
|
|
1478
1483
|
|
|
1479
|
-
async
|
|
1484
|
+
async writePackage(name, json) {
|
|
1480
1485
|
const storage = this.getPrivatePackageStorage(name);
|
|
1481
1486
|
|
|
1482
1487
|
if (_lodash.default.isNil(storage)) {
|
|
@@ -1494,7 +1499,7 @@ class Storage {
|
|
|
1494
1499
|
*/
|
|
1495
1500
|
|
|
1496
1501
|
|
|
1497
|
-
async
|
|
1502
|
+
async updatePackage(name, updateHandler) {
|
|
1498
1503
|
const storage = this.getPrivatePackageStorage(name);
|
|
1499
1504
|
|
|
1500
1505
|
if (!storage) {
|
|
@@ -1505,7 +1510,7 @@ class Storage {
|
|
|
1505
1510
|
const updatedManifest = await storage.updatePackage(name, updateHandler); // after correctly updated write to the storage
|
|
1506
1511
|
|
|
1507
1512
|
try {
|
|
1508
|
-
await this.
|
|
1513
|
+
await this.writePackage(name, (0, _storageUtils.normalizePackage)(updatedManifest));
|
|
1509
1514
|
return updatedManifest;
|
|
1510
1515
|
} catch (err) {
|
|
1511
1516
|
if (err.code === resourceNotAvailable) {
|
|
@@ -1734,7 +1739,7 @@ class Storage {
|
|
|
1734
1739
|
|
|
1735
1740
|
|
|
1736
1741
|
async applyFilters(manifest) {
|
|
1737
|
-
if (this.filters.length === 0) {
|
|
1742
|
+
if (this.filters === null || this.filters.length === 0) {
|
|
1738
1743
|
return [manifest, []];
|
|
1739
1744
|
}
|
|
1740
1745
|
|
|
@@ -1747,7 +1752,7 @@ class Storage {
|
|
|
1747
1752
|
// and return it directly for
|
|
1748
1753
|
// performance (i.e. need not be pure)
|
|
1749
1754
|
try {
|
|
1750
|
-
filteredManifest = await filter.
|
|
1755
|
+
filteredManifest = await filter.filterMetadata(manifest);
|
|
1751
1756
|
} catch (err) {
|
|
1752
1757
|
this.logger.error({
|
|
1753
1758
|
err: err.message
|
|
@@ -1912,7 +1917,7 @@ class Storage {
|
|
|
1912
1917
|
|
|
1913
1918
|
if (change) {
|
|
1914
1919
|
debug('updating package info %o', name);
|
|
1915
|
-
await this.
|
|
1920
|
+
await this.writePackage(name, cacheManifest);
|
|
1916
1921
|
return cacheManifest;
|
|
1917
1922
|
} else {
|
|
1918
1923
|
return cacheManifest;
|