@verdaccio/store 7.0.0-next.5 → 8.0.0-next-8.0
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 +359 -0
- package/LICENSE +1 -1
- package/README.md +24 -57
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -12
- package/build/index.js.map +1 -1
- package/build/lib/star-utils.js.map +1 -1
- package/build/lib/storage-utils.d.ts +3 -0
- package/build/lib/storage-utils.js +35 -2
- package/build/lib/storage-utils.js.map +1 -1
- package/build/lib/versions-utils.d.ts +14 -0
- package/build/lib/versions-utils.js +52 -1
- package/build/lib/versions-utils.js.map +1 -1
- package/build/local-storage.js +3 -3
- package/build/local-storage.js.map +1 -1
- package/build/storage.d.ts +14 -15
- package/build/storage.js +199 -162
- package/build/storage.js.map +1 -1
- package/build/type.d.ts +5 -0
- package/build/type.js.map +1 -1
- package/jest.config.js +2 -2
- package/package.json +18 -17
- package/src/index.ts +0 -1
- package/src/lib/storage-utils.ts +40 -2
- package/src/lib/versions-utils.ts +50 -1
- package/src/local-storage.ts +3 -2
- package/src/storage.ts +230 -150
- package/src/type.ts +6 -0
- package/test/fixtures/config/publishWithOwnerAndCheck.yaml +18 -0
- package/test/fixtures/config/publishWithOwnerDefault.yaml +15 -0
- package/test/fixtures/config/syncDoubleUplinksMetadata.yaml +2 -18
- package/test/search.spec.ts +28 -7
- package/test/storage-utils.spec.ts +1 -0
- package/test/storage.spec.ts +466 -80
- package/test/versions.spec.ts +58 -1
- package/build/lib/TransFormResults.d.ts +0 -15
- package/build/lib/TransFormResults.js +0 -51
- package/build/lib/TransFormResults.js.map +0 -1
- package/build/lib/search-utils.d.ts +0 -4
- package/build/lib/search-utils.js +0 -50
- package/build/lib/search-utils.js.map +0 -1
- package/build/lib/uplink-util.d.ts +0 -10
- package/build/lib/uplink-util.js +0 -43
- package/build/lib/uplink-util.js.map +0 -1
- package/src/lib/TransFormResults.ts +0 -42
- package/src/lib/search-utils.ts +0 -50
- package/src/lib/uplink-util.ts +0 -42
- /package/test/fixtures/config/{getTarballNext-getupstream.yaml → getTarball-getupstream.yaml} +0 -0
package/build/type.d.ts
CHANGED
|
@@ -54,3 +54,8 @@ export type UpdateManifestOptions = {
|
|
|
54
54
|
* values in the body.
|
|
55
55
|
*/
|
|
56
56
|
export type StarManifestBody = Pick<Manifest, '_id' | 'users' | '_rev'>;
|
|
57
|
+
/**
|
|
58
|
+
* When the command `npm owner add/rm` is executed, the body only contains the following
|
|
59
|
+
* values in the body.
|
|
60
|
+
*/
|
|
61
|
+
export type OwnerManifestBody = Pick<Manifest, '_id' | 'maintainers' | '_rev'>;
|
package/build/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","names":[],"sources":["../src/type.ts"],"sourcesContent":["import { FetchOptions } from '@verdaccio/proxy';\nimport { Manifest, RemoteUser } from '@verdaccio/types';\nimport { RequestOptions } from '@verdaccio/url';\n\n// @deprecated use IGetPackageOptionsNext\nexport type IGetPackageOptionsNext = {\n /**\n * Package name, could be scoped\n * eg: @scope/package-name or package-name\n */\n name: string;\n /**\n * Package version, optional.\n *\n * @type {string}\n */\n version?: string;\n /**\n * @deprecated use `TBA` instead\n */\n keepUpLinkData?: boolean;\n remoteUser?: RemoteUser;\n // fetch library retry options (mostly used by unit tests)\n retry?: FetchOptions['retry'];\n /**\n * Define if the package should be look up in the uplinks\n */\n uplinksLook: boolean;\n requestOptions: RequestOptions;\n /**\n *\n * The property write=true is used by package managers to get the most frest data\n * internally indicates to avoid any cache layer.\n */\n byPassCache?: boolean;\n\n /**\n * Reduce the package metadata to the minimum required to get the package.\n * https://github.com/npm/registry/blob/c0b573593fb5d6e0268de7d6612addd7059cb779/docs/responses/package-metadata.md#package-metadata\n */\n abbreviated?: boolean;\n};\n\n// @deprecate remove this type\nexport type PublishOptions = {\n signal: AbortSignal;\n} & IGetPackageOptionsNext;\n\nexport type UpdateManifestOptions = {\n name: string;\n version?: string;\n revision?: string;\n keepUpLinkData?: boolean;\n remoteUser?: RemoteUser;\n uplinksLook: boolean;\n requestOptions: RequestOptions;\n signal: AbortSignal;\n};\n\n/**\n * When the command `npm star` is executed, the body only contains the following\n * values in the body.\n */\nexport type StarManifestBody = Pick<Manifest, '_id' | 'users' | '_rev'>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"type.js","names":[],"sources":["../src/type.ts"],"sourcesContent":["import { FetchOptions } from '@verdaccio/proxy';\nimport { Manifest, RemoteUser } from '@verdaccio/types';\nimport { RequestOptions } from '@verdaccio/url';\n\n// @deprecated use IGetPackageOptionsNext\nexport type IGetPackageOptionsNext = {\n /**\n * Package name, could be scoped\n * eg: @scope/package-name or package-name\n */\n name: string;\n /**\n * Package version, optional.\n *\n * @type {string}\n */\n version?: string;\n /**\n * @deprecated use `TBA` instead\n */\n keepUpLinkData?: boolean;\n remoteUser?: RemoteUser;\n // fetch library retry options (mostly used by unit tests)\n retry?: FetchOptions['retry'];\n /**\n * Define if the package should be look up in the uplinks\n */\n uplinksLook: boolean;\n requestOptions: RequestOptions;\n /**\n *\n * The property write=true is used by package managers to get the most frest data\n * internally indicates to avoid any cache layer.\n */\n byPassCache?: boolean;\n\n /**\n * Reduce the package metadata to the minimum required to get the package.\n * https://github.com/npm/registry/blob/c0b573593fb5d6e0268de7d6612addd7059cb779/docs/responses/package-metadata.md#package-metadata\n */\n abbreviated?: boolean;\n};\n\n// @deprecate remove this type\nexport type PublishOptions = {\n signal: AbortSignal;\n} & IGetPackageOptionsNext;\n\nexport type UpdateManifestOptions = {\n name: string;\n version?: string;\n revision?: string;\n keepUpLinkData?: boolean;\n remoteUser?: RemoteUser;\n uplinksLook: boolean;\n requestOptions: RequestOptions;\n signal: AbortSignal;\n};\n\n/**\n * When the command `npm star` is executed, the body only contains the following\n * values in the body.\n */\nexport type StarManifestBody = Pick<Manifest, '_id' | 'users' | '_rev'>;\n\n/**\n * When the command `npm owner add/rm` is executed, the body only contains the following\n * values in the body.\n */\nexport type OwnerManifestBody = Pick<Manifest, '_id' | 'maintainers' | '_rev'>;\n"],"mappings":"","ignoreList":[]}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/store",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-next-8.0",
|
|
4
4
|
"description": "loaders logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,28 +29,29 @@
|
|
|
29
29
|
"node": ">=18"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/config": "
|
|
33
|
-
"@verdaccio/core": "
|
|
34
|
-
"@verdaccio/hooks": "
|
|
35
|
-
"@verdaccio/loaders": "
|
|
36
|
-
"@verdaccio/local-storage": "
|
|
37
|
-
"@verdaccio/logger": "
|
|
38
|
-
"@verdaccio/proxy": "
|
|
39
|
-
"@verdaccio/
|
|
40
|
-
"@verdaccio/
|
|
41
|
-
"@verdaccio/
|
|
32
|
+
"@verdaccio/config": "8.0.0-next-8.0",
|
|
33
|
+
"@verdaccio/core": "8.0.0-next-8.0",
|
|
34
|
+
"@verdaccio/hooks": "8.0.0-next-8.0",
|
|
35
|
+
"@verdaccio/loaders": "8.0.0-next-8.0",
|
|
36
|
+
"@verdaccio/local-storage": "13.0.0-next-8.0",
|
|
37
|
+
"@verdaccio/logger": "8.0.0-next-8.0",
|
|
38
|
+
"@verdaccio/proxy": "8.0.0-next-8.0",
|
|
39
|
+
"@verdaccio/search": "8.0.0-next-8.0",
|
|
40
|
+
"@verdaccio/tarball": "13.0.0-next-8.0",
|
|
41
|
+
"@verdaccio/url": "13.0.0-next-8.0",
|
|
42
|
+
"@verdaccio/utils": "7.0.1-next-8.0",
|
|
42
43
|
"JSONStream": "1.3.5",
|
|
43
|
-
"debug": "4.3.
|
|
44
|
+
"debug": "4.3.7",
|
|
44
45
|
"lodash": "4.17.21",
|
|
45
46
|
"merge2": "1.4.1",
|
|
46
|
-
"semver": "7.
|
|
47
|
+
"semver": "7.6.3"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@verdaccio/test-helper": "
|
|
50
|
-
"@verdaccio/types": "
|
|
50
|
+
"@verdaccio/test-helper": "4.0.0-next-8.0",
|
|
51
|
+
"@verdaccio/types": "13.0.0-next-8.0",
|
|
51
52
|
"mockdate": "3.0.5",
|
|
52
|
-
"nock": "13.
|
|
53
|
-
"node-mocks-http": "1.14.
|
|
53
|
+
"nock": "13.5.1",
|
|
54
|
+
"node-mocks-http": "1.14.1"
|
|
54
55
|
},
|
|
55
56
|
"funding": {
|
|
56
57
|
"type": "opencollective",
|
package/src/index.ts
CHANGED
package/src/lib/storage-utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import semver from 'semver';
|
|
3
3
|
|
|
4
|
-
import { errorUtils, pkgUtils, validatioUtils } from '@verdaccio/core';
|
|
5
|
-
import { API_ERROR, DIST_TAGS, HTTP_STATUS, USERS } from '@verdaccio/core';
|
|
4
|
+
import { errorUtils, pkgUtils, searchUtils, validatioUtils } from '@verdaccio/core';
|
|
5
|
+
import { API_ERROR, DIST_TAGS, HTTP_STATUS, MAINTAINERS, USERS } from '@verdaccio/core';
|
|
6
6
|
import { AttachMents, Manifest, Version, Versions } from '@verdaccio/types';
|
|
7
7
|
import { generateRandomHexString, isNil, isObject } from '@verdaccio/utils';
|
|
8
8
|
|
|
@@ -28,6 +28,7 @@ export function generatePackageTemplate(name: string): Manifest {
|
|
|
28
28
|
time: {},
|
|
29
29
|
[USERS]: {},
|
|
30
30
|
[DIST_TAGS]: {},
|
|
31
|
+
[MAINTAINERS]: [],
|
|
31
32
|
_uplinks: {},
|
|
32
33
|
_distfiles: {},
|
|
33
34
|
_attachments: {},
|
|
@@ -109,6 +110,7 @@ export const WHITELIST = [
|
|
|
109
110
|
'time',
|
|
110
111
|
'_id',
|
|
111
112
|
'users',
|
|
113
|
+
'maintainers',
|
|
112
114
|
];
|
|
113
115
|
|
|
114
116
|
export function cleanUpLinksRef(result: Manifest, keepUpLinkData?: boolean): Manifest {
|
|
@@ -290,6 +292,8 @@ export function mergeVersions(cacheManifest: Manifest, remoteManifest: Manifest)
|
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
|
|
295
|
+
// TODO: Should we merge owners? _cacheManifest[MAINTAINERS]
|
|
296
|
+
|
|
293
297
|
return cacheManifest;
|
|
294
298
|
}
|
|
295
299
|
|
|
@@ -360,3 +364,37 @@ export function hasDeprecatedVersions(pkgInfo: Manifest): boolean {
|
|
|
360
364
|
export function isDeprecatedManifest(manifest: Manifest): boolean {
|
|
361
365
|
return hasDeprecatedVersions(manifest) && Object.keys(manifest._attachments).length === 0;
|
|
362
366
|
}
|
|
367
|
+
|
|
368
|
+
export function mapManifestToSearchPackageBody(
|
|
369
|
+
pkg: Manifest,
|
|
370
|
+
searchItem: searchUtils.SearchItem
|
|
371
|
+
): searchUtils.SearchPackageBody {
|
|
372
|
+
const latest = pkgUtils.getLatest(pkg);
|
|
373
|
+
const version: Version = pkg.versions[latest];
|
|
374
|
+
const result: searchUtils.SearchPackageBody = {
|
|
375
|
+
name: version.name,
|
|
376
|
+
scope: '',
|
|
377
|
+
description: version.description,
|
|
378
|
+
version: latest,
|
|
379
|
+
keywords: version.keywords,
|
|
380
|
+
date: pkg.time[latest],
|
|
381
|
+
// FIXME: type
|
|
382
|
+
author: version.author as any,
|
|
383
|
+
// FIXME: not possible fill this out from a private package
|
|
384
|
+
publisher: {},
|
|
385
|
+
// FIXME: type
|
|
386
|
+
maintainers: version.maintainers as any,
|
|
387
|
+
links: {
|
|
388
|
+
npm: '',
|
|
389
|
+
homepage: version.homepage,
|
|
390
|
+
repository: version.repository,
|
|
391
|
+
bugs: version.bugs,
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
if (typeof searchItem.package.scoped === 'string') {
|
|
396
|
+
result.scope = searchItem.package.scoped;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return result;
|
|
400
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import buildDebug from 'debug';
|
|
1
2
|
import _ from 'lodash';
|
|
2
3
|
import semver, { SemVer } from 'semver';
|
|
3
4
|
|
|
4
|
-
import { DIST_TAGS } from '@verdaccio/core';
|
|
5
|
+
import { DIST_TAGS, searchUtils } from '@verdaccio/core';
|
|
5
6
|
import { Manifest, StringValue, Version, Versions } from '@verdaccio/types';
|
|
6
7
|
|
|
8
|
+
const debug = buildDebug('verdaccio:storage:utils');
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* Gets version from a package object taking into account semver weirdness.
|
|
9
12
|
* @return {String} return the semantic version of a package
|
|
@@ -85,3 +88,49 @@ export function tagVersionNext(manifest: Manifest, version: string, tag: StringV
|
|
|
85
88
|
}
|
|
86
89
|
return data;
|
|
87
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Check if the version is newer than the older version.
|
|
94
|
+
* @param newVersion
|
|
95
|
+
* @param oldVersion
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
export function isNewerVersion(newVersion, oldVersion) {
|
|
99
|
+
const comparisonResult = semver.compare(newVersion, oldVersion);
|
|
100
|
+
|
|
101
|
+
return comparisonResult === 1 || comparisonResult === 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Remove duplicates from search results.
|
|
106
|
+
* @param {Array} objects
|
|
107
|
+
* @return {Array} filtered array
|
|
108
|
+
*/
|
|
109
|
+
export function removeLowerVersions(objects: searchUtils.SearchPackageItem[]) {
|
|
110
|
+
const versionMap = new Map();
|
|
111
|
+
|
|
112
|
+
// Iterate through the array and keep the highest version for each name
|
|
113
|
+
objects.forEach((item) => {
|
|
114
|
+
const { name, version } = item.package;
|
|
115
|
+
const key = name;
|
|
116
|
+
|
|
117
|
+
if (versionMap.has(name) === false || isNewerVersion(version, versionMap.get(name))) {
|
|
118
|
+
debug('keeping %o@%o', name, version);
|
|
119
|
+
versionMap.set(key, version);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Filter objects based on the version map
|
|
124
|
+
return objects.reduce((acc, item) => {
|
|
125
|
+
const { name, version } = item.package;
|
|
126
|
+
if (
|
|
127
|
+
versionMap.has(name) &&
|
|
128
|
+
versionMap.get(name) === version &&
|
|
129
|
+
acc.find((i) => i.package.name === name) === undefined
|
|
130
|
+
) {
|
|
131
|
+
debug('adding %o@%o', name, version);
|
|
132
|
+
acc.push(item);
|
|
133
|
+
}
|
|
134
|
+
return acc;
|
|
135
|
+
}, [] as searchUtils.SearchPackageItem[]);
|
|
136
|
+
}
|
package/src/local-storage.ts
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'assert';
|
|
|
2
2
|
import buildDebug from 'debug';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
|
|
5
|
-
import { errorUtils, pluginUtils } from '@verdaccio/core';
|
|
5
|
+
import { PLUGIN_CATEGORY, errorUtils, pluginUtils } from '@verdaccio/core';
|
|
6
6
|
import { asyncLoadPlugin } from '@verdaccio/loaders';
|
|
7
7
|
import LocalDatabase from '@verdaccio/local-storage';
|
|
8
8
|
import { Config, Logger } from '@verdaccio/types';
|
|
@@ -75,7 +75,8 @@ class LocalStorage {
|
|
|
75
75
|
(plugin) => {
|
|
76
76
|
return typeof plugin.getPackageStorage !== 'undefined';
|
|
77
77
|
},
|
|
78
|
-
this.config?.serverSettings?.pluginPrefix
|
|
78
|
+
this.config?.serverSettings?.pluginPrefix,
|
|
79
|
+
PLUGIN_CATEGORY.STORAGE
|
|
79
80
|
);
|
|
80
81
|
|
|
81
82
|
if (plugins.length > 1) {
|