@verdaccio/store 9.0.0-next-9.2 → 9.0.0-next-9.4
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/build/_virtual/_rolldown/runtime.js +23 -0
- package/build/index.js +36 -63
- package/build/index.mjs +5 -0
- package/build/lib/star-utils.js +25 -36
- package/build/lib/star-utils.js.map +1 -1
- package/build/lib/star-utils.mjs +31 -0
- package/build/lib/star-utils.mjs.map +1 -0
- package/build/lib/storage-utils.d.ts +8 -8
- package/build/lib/storage-utils.js +240 -316
- package/build/lib/storage-utils.js.map +1 -1
- package/build/lib/storage-utils.mjs +260 -0
- package/build/lib/storage-utils.mjs.map +1 -0
- package/build/lib/versions-utils.js +84 -124
- package/build/lib/versions-utils.js.map +1 -1
- package/build/lib/versions-utils.mjs +94 -0
- package/build/lib/versions-utils.mjs.map +1 -0
- package/build/local-storage.d.ts +2 -2
- package/build/local-storage.js +69 -168
- package/build/local-storage.js.map +1 -1
- package/build/local-storage.mjs +66 -0
- package/build/local-storage.mjs.map +1 -0
- package/build/storage.d.ts +5 -5
- package/build/storage.js +1368 -3147
- package/build/storage.js.map +1 -1
- package/build/storage.mjs +1364 -0
- package/build/storage.mjs.map +1 -0
- package/build/type.d.ts +3 -3
- package/package.json +28 -17
- package/build/index.js.map +0 -1
- package/build/type.js +0 -6
- package/build/type.js.map +0 -1
|
@@ -1,357 +1,281 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.isDeprecatedManifest = isDeprecatedManifest;
|
|
15
|
-
exports.mapManifestToSearchPackageBody = mapManifestToSearchPackageBody;
|
|
16
|
-
exports.mergeUplinkTimeIntoLocal = mergeUplinkTimeIntoLocal;
|
|
17
|
-
exports.mergeUplinkTimeIntoLocalNext = mergeUplinkTimeIntoLocalNext;
|
|
18
|
-
exports.mergeVersions = mergeVersions;
|
|
19
|
-
exports.normalizeContributors = normalizeContributors;
|
|
20
|
-
exports.normalizeDistTags = normalizeDistTags;
|
|
21
|
-
exports.normalizePackage = normalizePackage;
|
|
22
|
-
exports.prepareSearchPackage = prepareSearchPackage;
|
|
23
|
-
exports.updateUpLinkMetadata = updateUpLinkMetadata;
|
|
24
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
25
|
-
var _semver = _interopRequireDefault(require("semver"));
|
|
26
|
-
var _core = require("@verdaccio/core");
|
|
27
|
-
var _versionsUtils = require("./versions-utils");
|
|
28
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
29
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
30
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
33
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
34
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
35
|
-
var STORAGE = exports.STORAGE = {
|
|
36
|
-
PACKAGE_FILE_NAME: 'package.json',
|
|
37
|
-
FILE_EXIST_ERROR: 'EEXISTS',
|
|
38
|
-
NO_SUCH_FILE_ERROR: 'ENOENT',
|
|
39
|
-
DEFAULT_REVISION: '0-0000000000000000'
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_versions_utils = require("./versions-utils.js");
|
|
3
|
+
let lodash = require("lodash");
|
|
4
|
+
lodash = require_runtime.__toESM(lodash);
|
|
5
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
6
|
+
let semver = require("semver");
|
|
7
|
+
semver = require_runtime.__toESM(semver);
|
|
8
|
+
//#region src/lib/storage-utils.ts
|
|
9
|
+
var STORAGE = {
|
|
10
|
+
PACKAGE_FILE_NAME: "package.json",
|
|
11
|
+
FILE_EXIST_ERROR: "EEXISTS",
|
|
12
|
+
NO_SUCH_FILE_ERROR: "ENOENT",
|
|
13
|
+
DEFAULT_REVISION: "0-0000000000000000"
|
|
40
14
|
};
|
|
41
|
-
|
|
42
15
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
16
|
+
* Create a new package in the storage, return a boilerplate package
|
|
17
|
+
* @param name package name
|
|
18
|
+
* @returns {Manifest}
|
|
19
|
+
*/
|
|
47
20
|
function generatePackageTemplate(name) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
21
|
+
return {
|
|
22
|
+
name,
|
|
23
|
+
versions: {},
|
|
24
|
+
time: {},
|
|
25
|
+
[_verdaccio_core.USERS]: {},
|
|
26
|
+
[_verdaccio_core.DIST_TAGS]: {},
|
|
27
|
+
[_verdaccio_core.MAINTAINERS]: [],
|
|
28
|
+
_uplinks: {},
|
|
29
|
+
_distfiles: {},
|
|
30
|
+
_attachments: {},
|
|
31
|
+
_rev: ""
|
|
32
|
+
};
|
|
54
33
|
}
|
|
55
|
-
|
|
56
34
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
35
|
+
* Normalize package properties, tags, revision id.
|
|
36
|
+
* @param {Object} pkg package reference.
|
|
37
|
+
*/
|
|
60
38
|
function normalizePackage(pkg) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// normalize dist-tags
|
|
76
|
-
return normalizeDistTags(pkg);
|
|
39
|
+
[
|
|
40
|
+
"versions",
|
|
41
|
+
"dist-tags",
|
|
42
|
+
"_distfiles",
|
|
43
|
+
"_attachments",
|
|
44
|
+
"_uplinks",
|
|
45
|
+
"time"
|
|
46
|
+
].forEach((key) => {
|
|
47
|
+
const pkgProp = pkg[key];
|
|
48
|
+
if (lodash.default.isNil(pkgProp) || _verdaccio_core.validationUtils.isObject(pkgProp) === false) pkg[key] = {};
|
|
49
|
+
});
|
|
50
|
+
if (typeof pkg?._rev !== "string") pkg._rev = STORAGE.DEFAULT_REVISION;
|
|
51
|
+
if (typeof pkg?._id !== "string") pkg._id = pkg.name;
|
|
52
|
+
return normalizeDistTags(pkg);
|
|
77
53
|
}
|
|
78
54
|
function generateRevision(rev) {
|
|
79
|
-
|
|
80
|
-
return (+_rev[0] || 0) + 1 + '-' + _core.cryptoUtils.generateRandomHexString();
|
|
55
|
+
return (+rev.split("-")[0] || 0) + 1 + "-" + _verdaccio_core.cryptoUtils.generateRandomHexString();
|
|
81
56
|
}
|
|
82
57
|
function getLatestReadme(pkg) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
return readme;
|
|
58
|
+
const versions = pkg["versions"] || {};
|
|
59
|
+
const distTags = pkg[_verdaccio_core.DIST_TAGS] || {};
|
|
60
|
+
const latestVersion = distTags["latest"] ? versions[distTags["latest"]] || {} : {};
|
|
61
|
+
let readme = lodash.default.trim(pkg.readme || latestVersion.readme || "");
|
|
62
|
+
if (readme) return readme;
|
|
63
|
+
[
|
|
64
|
+
"next",
|
|
65
|
+
"beta",
|
|
66
|
+
"alpha",
|
|
67
|
+
"test",
|
|
68
|
+
"dev",
|
|
69
|
+
"canary"
|
|
70
|
+
].forEach(function(tag) {
|
|
71
|
+
if (readme) return readme;
|
|
72
|
+
const version = distTags[tag] ? versions[distTags[tag]] || {} : {};
|
|
73
|
+
readme = lodash.default.trim(version.readme || readme);
|
|
74
|
+
});
|
|
75
|
+
return readme;
|
|
103
76
|
}
|
|
104
|
-
|
|
105
77
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
78
|
+
* Cleanup readme from package version
|
|
79
|
+
*
|
|
80
|
+
* By default, we don't keep readmes for package versions, only one readme per package.
|
|
81
|
+
* Using publish.keep_readmes you can override this behavior and keep all readmes
|
|
82
|
+
* or only readmes for tagged versions.
|
|
83
|
+
*/
|
|
112
84
|
function cleanUpReadme(version, distTags, keepReadmes) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
if (_lodash["default"].isNil(version) === false) {
|
|
121
|
-
version.readme = '';
|
|
122
|
-
}
|
|
123
|
-
return version;
|
|
85
|
+
if (keepReadmes === "all") return version;
|
|
86
|
+
else if (keepReadmes === "tagged") {
|
|
87
|
+
if (distTags && Object.values(distTags).includes(version.version)) return version;
|
|
88
|
+
}
|
|
89
|
+
if (lodash.default.isNil(version) === false) version.readme = "";
|
|
90
|
+
return version;
|
|
124
91
|
}
|
|
125
|
-
var WHITELIST =
|
|
92
|
+
var WHITELIST = [
|
|
93
|
+
"_rev",
|
|
94
|
+
"name",
|
|
95
|
+
"versions",
|
|
96
|
+
"dist-tags",
|
|
97
|
+
"readme",
|
|
98
|
+
"time",
|
|
99
|
+
"_id",
|
|
100
|
+
"users",
|
|
101
|
+
"maintainers"
|
|
102
|
+
];
|
|
126
103
|
function cleanUpLinksRef(result, keepUpLinkData) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
for (var i in result) {
|
|
132
|
-
if (propertyToKeep.indexOf(i) === -1) {
|
|
133
|
-
// Remove sections like '_uplinks' from response
|
|
134
|
-
delete result[i];
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return result;
|
|
104
|
+
const propertyToKeep = [...WHITELIST];
|
|
105
|
+
if (keepUpLinkData === true) propertyToKeep.push("_uplinks");
|
|
106
|
+
for (const i in result) if (propertyToKeep.indexOf(i) === -1) delete result[i];
|
|
107
|
+
return result;
|
|
138
108
|
}
|
|
139
|
-
|
|
140
|
-
// TODO: move to abstract storage
|
|
141
|
-
// @deprecated use abstract.storage.ts:checkPackageRemote
|
|
142
109
|
function checkPackageRemote(name, isAllowPublishOffline, syncMetadata) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// if uplink fails with a status other than 404, we report failure
|
|
157
|
-
if (_lodash["default"].isNil(upLinksErrors[errorItem][0]) === false) {
|
|
158
|
-
if (upLinksErrors[errorItem][0].status !== _core.HTTP_STATUS.NOT_FOUND) {
|
|
159
|
-
if (isAllowPublishOffline) {
|
|
160
|
-
return resolve();
|
|
161
|
-
}
|
|
162
|
-
return reject(_core.errorUtils.getServiceUnavailable(_core.API_ERROR.UPLINK_OFFLINE_PUBLISH));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return resolve();
|
|
167
|
-
});
|
|
168
|
-
});
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
syncMetadata(name, null, {}, (err, packageJsonLocal, upLinksErrors) => {
|
|
112
|
+
if (err && err.status !== _verdaccio_core.HTTP_STATUS.NOT_FOUND) return reject(err);
|
|
113
|
+
if (lodash.default.isNil(packageJsonLocal) === false) return reject(_verdaccio_core.errorUtils.getConflict(_verdaccio_core.API_ERROR.PACKAGE_EXIST));
|
|
114
|
+
for (let errorItem = 0; errorItem < upLinksErrors.length; errorItem++) if (lodash.default.isNil(upLinksErrors[errorItem][0]) === false) {
|
|
115
|
+
if (upLinksErrors[errorItem][0].status !== _verdaccio_core.HTTP_STATUS.NOT_FOUND) {
|
|
116
|
+
if (isAllowPublishOffline) return resolve();
|
|
117
|
+
return reject(_verdaccio_core.errorUtils.getServiceUnavailable(_verdaccio_core.API_ERROR.UPLINK_OFFLINE_PUBLISH));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return resolve();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
169
123
|
}
|
|
170
|
-
|
|
171
|
-
// @deprecated use export function mergeUplinkTimeIntoLocalNext
|
|
172
124
|
function mergeUplinkTimeIntoLocal(localMetadata, remoteMetadata) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
return localMetadata.time;
|
|
125
|
+
if ("time" in remoteMetadata) return Object.assign({}, localMetadata.time, remoteMetadata.time);
|
|
126
|
+
return localMetadata.time;
|
|
177
127
|
}
|
|
178
128
|
function mergeUplinkTimeIntoLocalNext(cacheManifest, remoteManifest) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
129
|
+
if ("time" in remoteManifest) return {
|
|
130
|
+
...cacheManifest,
|
|
131
|
+
time: {
|
|
132
|
+
...cacheManifest.time,
|
|
133
|
+
...remoteManifest.time
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return cacheManifest;
|
|
186
137
|
}
|
|
187
138
|
function updateUpLinkMetadata(uplinkName, manifest, etag) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
139
|
+
const _uplinks = {
|
|
140
|
+
...manifest._uplinks,
|
|
141
|
+
[uplinkName]: {
|
|
142
|
+
etag,
|
|
143
|
+
fetched: Date.now()
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
...manifest,
|
|
148
|
+
_uplinks
|
|
149
|
+
};
|
|
195
150
|
}
|
|
196
151
|
function prepareSearchPackage(data) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
152
|
+
const latest = _verdaccio_core.pkgUtils.getLatest(data);
|
|
153
|
+
if (latest && data.versions[latest]) {
|
|
154
|
+
const version = data.versions[latest];
|
|
155
|
+
const versions = { [latest]: "latest" };
|
|
156
|
+
return {
|
|
157
|
+
name: version.name,
|
|
158
|
+
description: version.description,
|
|
159
|
+
[_verdaccio_core.DIST_TAGS]: { latest },
|
|
160
|
+
maintainers: version.maintainers || [version.author].filter(Boolean),
|
|
161
|
+
author: version.author,
|
|
162
|
+
repository: version.repository,
|
|
163
|
+
readmeFilename: version.readmeFilename || "",
|
|
164
|
+
homepage: version.homepage,
|
|
165
|
+
keywords: version.keywords,
|
|
166
|
+
bugs: version.bugs,
|
|
167
|
+
license: version.license,
|
|
168
|
+
versions
|
|
169
|
+
};
|
|
170
|
+
}
|
|
209
171
|
}
|
|
210
|
-
|
|
211
172
|
/**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
173
|
+
* Function gets a local info and an info from uplinks and tries to merge it
|
|
174
|
+
exported for unit tests only.
|
|
175
|
+
* @param {*} cacheManifest
|
|
176
|
+
* @param {*} remoteManifest
|
|
177
|
+
*/
|
|
217
178
|
function mergeVersions(cacheManifest, remoteManifest) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
for (var _i in time) {
|
|
232
|
-
if (typeof _cacheManifest.time[_i] === 'undefined') {
|
|
233
|
-
_cacheManifest.time[_i] = time[_i];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
for (var distTag in remoteManifest[_core.DIST_TAGS]) {
|
|
237
|
-
if (_cacheManifest[_core.DIST_TAGS][distTag] !== remoteManifest[_core.DIST_TAGS][distTag]) {
|
|
238
|
-
if (!_cacheManifest[_core.DIST_TAGS][distTag] || _semver["default"].lte(_cacheManifest[_core.DIST_TAGS][distTag], remoteManifest[_core.DIST_TAGS][distTag])) {
|
|
239
|
-
_cacheManifest[_core.DIST_TAGS][distTag] = remoteManifest[_core.DIST_TAGS][distTag];
|
|
240
|
-
}
|
|
241
|
-
if (distTag === 'latest' && _cacheManifest[_core.DIST_TAGS][distTag] === remoteManifest[_core.DIST_TAGS][distTag]) {
|
|
242
|
-
// NOTE: this override the latest publish readme from local cache with
|
|
243
|
-
// the remote one
|
|
244
|
-
_cacheManifest = _objectSpread(_objectSpread({}, _cacheManifest), {}, {
|
|
245
|
-
readme: remoteManifest.readme
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return _cacheManifest;
|
|
179
|
+
let _cacheManifest = { ...cacheManifest };
|
|
180
|
+
const { versions, time } = remoteManifest;
|
|
181
|
+
for (const i in versions) if (typeof _cacheManifest.versions[i] === "undefined") _cacheManifest.versions[i] = versions[i];
|
|
182
|
+
else if (versions[i].deprecated) _cacheManifest.versions[i].deprecated = versions[i].deprecated;
|
|
183
|
+
for (const i in time) if (typeof _cacheManifest.time[i] === "undefined") _cacheManifest.time[i] = time[i];
|
|
184
|
+
for (const distTag in remoteManifest[_verdaccio_core.DIST_TAGS]) if (_cacheManifest[_verdaccio_core.DIST_TAGS][distTag] !== remoteManifest[_verdaccio_core.DIST_TAGS][distTag]) {
|
|
185
|
+
if (!_cacheManifest[_verdaccio_core.DIST_TAGS][distTag] || semver.default.lte(_cacheManifest[_verdaccio_core.DIST_TAGS][distTag], remoteManifest[_verdaccio_core.DIST_TAGS][distTag])) _cacheManifest[_verdaccio_core.DIST_TAGS][distTag] = remoteManifest[_verdaccio_core.DIST_TAGS][distTag];
|
|
186
|
+
if (distTag === "latest" && _cacheManifest[_verdaccio_core.DIST_TAGS][distTag] === remoteManifest[_verdaccio_core.DIST_TAGS][distTag]) _cacheManifest = {
|
|
187
|
+
..._cacheManifest,
|
|
188
|
+
readme: remoteManifest.readme
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return _cacheManifest;
|
|
251
192
|
}
|
|
252
|
-
|
|
253
193
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
194
|
+
* Normalize dist-tags.
|
|
195
|
+
*
|
|
196
|
+
* There is a legacy behaviour where the dist-tags could be an array, in such
|
|
197
|
+
* case, the array is orderded and the highest version becames the
|
|
198
|
+
* latest.
|
|
199
|
+
*
|
|
200
|
+
* The dist-tag tags must be plain strigs, if the latest is empty (for whatever reason) is
|
|
201
|
+
* normalized to be the highest version available.
|
|
202
|
+
*
|
|
203
|
+
* This function cleans up every invalid version on dist-tags, but does not remove
|
|
204
|
+
* invalid versions from the manifest.
|
|
205
|
+
*
|
|
206
|
+
* @param {*} data
|
|
207
|
+
*/
|
|
268
208
|
function normalizeDistTags(manifest) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// this should not happen, tags should be plain strings, legacy fallback
|
|
283
|
-
if (_lodash["default"].isArray(manifest[_core.DIST_TAGS][tag])) {
|
|
284
|
-
if (manifest[_core.DIST_TAGS][tag].length) {
|
|
285
|
-
// sort array
|
|
286
|
-
// FIXME: this is clearly wrong, we need to research why this is like this.
|
|
287
|
-
// @ts-ignore
|
|
288
|
-
sorted = (0, _versionsUtils.sortVersionsAndFilterInvalid)(manifest[_core.DIST_TAGS][tag]);
|
|
289
|
-
if (sorted.length) {
|
|
290
|
-
// use highest version based on semver sort
|
|
291
|
-
manifest[_core.DIST_TAGS][tag] = sorted.pop();
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
delete manifest[_core.DIST_TAGS][tag];
|
|
295
|
-
}
|
|
296
|
-
} else if (_lodash["default"].isString(manifest[_core.DIST_TAGS][tag])) {
|
|
297
|
-
if (!_semver["default"].parse(manifest[_core.DIST_TAGS][tag], true)) {
|
|
298
|
-
// if the version is invalid, delete the dist-tag entry
|
|
299
|
-
delete manifest[_core.DIST_TAGS][tag];
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return manifest;
|
|
209
|
+
let sorted;
|
|
210
|
+
if (!manifest[_verdaccio_core.DIST_TAGS].latest) {
|
|
211
|
+
sorted = require_versions_utils.sortVersionsAndFilterInvalid(Object.keys(manifest.versions));
|
|
212
|
+
if (sorted?.length) manifest[_verdaccio_core.DIST_TAGS].latest = sorted.pop();
|
|
213
|
+
}
|
|
214
|
+
for (const tag in manifest[_verdaccio_core.DIST_TAGS]) if (lodash.default.isArray(manifest[_verdaccio_core.DIST_TAGS][tag])) if (manifest[_verdaccio_core.DIST_TAGS][tag].length) {
|
|
215
|
+
sorted = require_versions_utils.sortVersionsAndFilterInvalid(manifest[_verdaccio_core.DIST_TAGS][tag]);
|
|
216
|
+
if (sorted.length) manifest[_verdaccio_core.DIST_TAGS][tag] = sorted.pop();
|
|
217
|
+
} else delete manifest[_verdaccio_core.DIST_TAGS][tag];
|
|
218
|
+
else if (lodash.default.isString(manifest[_verdaccio_core.DIST_TAGS][tag])) {
|
|
219
|
+
if (!semver.default.parse(manifest[_verdaccio_core.DIST_TAGS][tag], true)) delete manifest[_verdaccio_core.DIST_TAGS][tag];
|
|
220
|
+
}
|
|
221
|
+
return manifest;
|
|
304
222
|
}
|
|
305
223
|
function hasDeprecatedVersions(pkgInfo) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return false;
|
|
224
|
+
const { versions } = pkgInfo;
|
|
225
|
+
for (const version in versions) if (Object.prototype.hasOwnProperty.call(versions[version], "deprecated")) return true;
|
|
226
|
+
return false;
|
|
313
227
|
}
|
|
314
228
|
function isDeprecatedManifest(manifest) {
|
|
315
|
-
|
|
229
|
+
return hasDeprecatedVersions(manifest) && (typeof manifest._attachments === "undefined" || Object.keys(manifest._attachments).length === 0);
|
|
316
230
|
}
|
|
317
231
|
function mapManifestToSearchPackageBody(pkg, searchItem) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
};
|
|
340
|
-
if (typeof searchItem["package"].scoped === 'string') {
|
|
341
|
-
result.scope = searchItem["package"].scoped;
|
|
342
|
-
}
|
|
343
|
-
return result;
|
|
232
|
+
const latest = _verdaccio_core.pkgUtils.getLatest(pkg);
|
|
233
|
+
const version = pkg.versions[latest];
|
|
234
|
+
const result = {
|
|
235
|
+
name: version.name,
|
|
236
|
+
scope: "",
|
|
237
|
+
description: version.description,
|
|
238
|
+
version: latest,
|
|
239
|
+
keywords: version.keywords,
|
|
240
|
+
date: pkg.time[latest],
|
|
241
|
+
author: version.author,
|
|
242
|
+
publisher: {},
|
|
243
|
+
maintainers: version.maintainers,
|
|
244
|
+
links: {
|
|
245
|
+
npm: "",
|
|
246
|
+
homepage: version.homepage,
|
|
247
|
+
repository: version.repository,
|
|
248
|
+
bugs: version.bugs
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
if (typeof searchItem.package.scoped === "string") result.scope = searchItem.package.scoped;
|
|
252
|
+
return result;
|
|
344
253
|
}
|
|
345
254
|
function normalizeContributors(contributors) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
} else if (_lodash["default"].isString(contributors)) {
|
|
351
|
-
return [{
|
|
352
|
-
name: contributors
|
|
353
|
-
}];
|
|
354
|
-
}
|
|
355
|
-
return contributors;
|
|
255
|
+
if (lodash.default.isNil(contributors)) return [];
|
|
256
|
+
else if (contributors && lodash.default.isArray(contributors) === false) return [contributors];
|
|
257
|
+
else if (lodash.default.isString(contributors)) return [{ name: contributors }];
|
|
258
|
+
return contributors;
|
|
356
259
|
}
|
|
260
|
+
//#endregion
|
|
261
|
+
exports.STORAGE = STORAGE;
|
|
262
|
+
exports.WHITELIST = WHITELIST;
|
|
263
|
+
exports.checkPackageRemote = checkPackageRemote;
|
|
264
|
+
exports.cleanUpLinksRef = cleanUpLinksRef;
|
|
265
|
+
exports.cleanUpReadme = cleanUpReadme;
|
|
266
|
+
exports.generatePackageTemplate = generatePackageTemplate;
|
|
267
|
+
exports.generateRevision = generateRevision;
|
|
268
|
+
exports.getLatestReadme = getLatestReadme;
|
|
269
|
+
exports.hasDeprecatedVersions = hasDeprecatedVersions;
|
|
270
|
+
exports.isDeprecatedManifest = isDeprecatedManifest;
|
|
271
|
+
exports.mapManifestToSearchPackageBody = mapManifestToSearchPackageBody;
|
|
272
|
+
exports.mergeUplinkTimeIntoLocal = mergeUplinkTimeIntoLocal;
|
|
273
|
+
exports.mergeUplinkTimeIntoLocalNext = mergeUplinkTimeIntoLocalNext;
|
|
274
|
+
exports.mergeVersions = mergeVersions;
|
|
275
|
+
exports.normalizeContributors = normalizeContributors;
|
|
276
|
+
exports.normalizeDistTags = normalizeDistTags;
|
|
277
|
+
exports.normalizePackage = normalizePackage;
|
|
278
|
+
exports.prepareSearchPackage = prepareSearchPackage;
|
|
279
|
+
exports.updateUpLinkMetadata = updateUpLinkMetadata;
|
|
280
|
+
|
|
357
281
|
//# sourceMappingURL=storage-utils.js.map
|