@verdaccio/store 6.0.0-6-next.30 → 6.0.0-6-next.32
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 +31 -0
- package/build/index.js +0 -11
- package/build/index.js.map +1 -1
- package/build/lib/TransFormResults.js +3 -13
- package/build/lib/TransFormResults.js.map +1 -1
- package/build/lib/search-utils.js +0 -9
- package/build/lib/search-utils.js.map +1 -1
- package/build/lib/star-utils.js +7 -10
- package/build/lib/star-utils.js.map +1 -1
- package/build/lib/storage-utils.js +38 -82
- package/build/lib/storage-utils.js.map +1 -1
- package/build/lib/uplink-util.js +4 -11
- package/build/lib/uplink-util.js.map +1 -1
- package/build/lib/versions-utils.js +9 -22
- package/build/lib/versions-utils.js.map +1 -1
- package/build/local-storage.d.ts +1 -1
- package/build/local-storage.js +2 -25
- package/build/local-storage.js.map +1 -1
- package/build/storage.d.ts +4 -4
- package/build/storage.js +204 -413
- package/build/storage.js.map +1 -1
- package/build/type.d.ts +4 -4
- package/package.json +13 -13
- package/src/storage.ts +5 -5
- package/test/storage.spec.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @verdaccio/store
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@6.0.0-6-next.52
|
|
8
|
+
- @verdaccio/config@6.0.0-6-next.52
|
|
9
|
+
- @verdaccio/tarball@11.0.0-6-next.21
|
|
10
|
+
- @verdaccio/url@11.0.0-6-next.18
|
|
11
|
+
- @verdaccio/hooks@6.0.0-6-next.22
|
|
12
|
+
- @verdaccio/loaders@6.0.0-6-next.21
|
|
13
|
+
- @verdaccio/logger@6.0.0-6-next.20
|
|
14
|
+
- @verdaccio/local-storage@11.0.0-6-next.22
|
|
15
|
+
- @verdaccio/proxy@6.0.0-6-next.30
|
|
16
|
+
- @verdaccio/utils@6.0.0-6-next.20
|
|
17
|
+
|
|
18
|
+
## 6.0.0-6-next.31
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [4b29d715]
|
|
23
|
+
- @verdaccio/config@6.0.0-6-next.51
|
|
24
|
+
- @verdaccio/core@6.0.0-6-next.51
|
|
25
|
+
- @verdaccio/url@11.0.0-6-next.17
|
|
26
|
+
- @verdaccio/local-storage@11.0.0-6-next.21
|
|
27
|
+
- @verdaccio/hooks@6.0.0-6-next.21
|
|
28
|
+
- @verdaccio/loaders@6.0.0-6-next.20
|
|
29
|
+
- @verdaccio/proxy@6.0.0-6-next.29
|
|
30
|
+
- @verdaccio/tarball@11.0.0-6-next.20
|
|
31
|
+
- @verdaccio/logger@6.0.0-6-next.19
|
|
32
|
+
- @verdaccio/utils@6.0.0-6-next.19
|
|
33
|
+
|
|
3
34
|
## 6.0.0-6-next.30
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/build/index.js
CHANGED
|
@@ -12,11 +12,8 @@ Object.defineProperty(exports, "Storage", {
|
|
|
12
12
|
return _storage.Storage;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
|
|
16
15
|
var _storage = require("./storage");
|
|
17
|
-
|
|
18
16
|
var _storageUtils = require("./lib/storage-utils");
|
|
19
|
-
|
|
20
17
|
Object.keys(_storageUtils).forEach(function (key) {
|
|
21
18
|
if (key === "default" || key === "__esModule") return;
|
|
22
19
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -28,9 +25,7 @@ Object.keys(_storageUtils).forEach(function (key) {
|
|
|
28
25
|
}
|
|
29
26
|
});
|
|
30
27
|
});
|
|
31
|
-
|
|
32
28
|
var _searchUtils = require("./lib/search-utils");
|
|
33
|
-
|
|
34
29
|
Object.keys(_searchUtils).forEach(function (key) {
|
|
35
30
|
if (key === "default" || key === "__esModule") return;
|
|
36
31
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -42,9 +37,7 @@ Object.keys(_searchUtils).forEach(function (key) {
|
|
|
42
37
|
}
|
|
43
38
|
});
|
|
44
39
|
});
|
|
45
|
-
|
|
46
40
|
var _versionsUtils = require("./lib/versions-utils");
|
|
47
|
-
|
|
48
41
|
Object.keys(_versionsUtils).forEach(function (key) {
|
|
49
42
|
if (key === "default" || key === "__esModule") return;
|
|
50
43
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -56,9 +49,7 @@ Object.keys(_versionsUtils).forEach(function (key) {
|
|
|
56
49
|
}
|
|
57
50
|
});
|
|
58
51
|
});
|
|
59
|
-
|
|
60
52
|
var _starUtils = require("./lib/star-utils");
|
|
61
|
-
|
|
62
53
|
Object.keys(_starUtils).forEach(function (key) {
|
|
63
54
|
if (key === "default" || key === "__esModule") return;
|
|
64
55
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -70,9 +61,7 @@ Object.keys(_starUtils).forEach(function (key) {
|
|
|
70
61
|
}
|
|
71
62
|
});
|
|
72
63
|
});
|
|
73
|
-
|
|
74
64
|
var _type = require("./type");
|
|
75
|
-
|
|
76
65
|
Object.keys(_type).forEach(function (key) {
|
|
77
66
|
if (key === "default" || key === "__esModule") return;
|
|
78
67
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Storage } from './storage';\nexport * from './lib/storage-utils';\nexport * from './lib/search-utils';\nexport * from './lib/versions-utils';\nexport * from './lib/star-utils';\nexport * from './type';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Storage } from './storage';\nexport * from './lib/storage-utils';\nexport * from './lib/search-utils';\nexport * from './lib/versions-utils';\nexport * from './lib/star-utils';\nexport * from './type';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TransFormResults = void 0;
|
|
7
|
-
|
|
8
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
|
|
10
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
-
|
|
12
9
|
var _stream = require("stream");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
const debug = (0, _debug.default)('verdaccio:storage:search:transform');
|
|
17
|
-
|
|
18
12
|
class TransFormResults extends _stream.Transform {
|
|
19
13
|
constructor(options) {
|
|
20
14
|
super(options);
|
|
21
15
|
}
|
|
16
|
+
|
|
22
17
|
/**
|
|
23
18
|
* Transform either array of packages or a single package into a stream of packages.
|
|
24
19
|
* From uplinks the chunks are array but from local packages are objects.
|
|
@@ -28,18 +23,16 @@ class TransFormResults extends _stream.Transform {
|
|
|
28
23
|
* @returns {void}
|
|
29
24
|
* @override
|
|
30
25
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
26
|
_transform(chunk, _encoding, callback) {
|
|
34
27
|
if (_lodash.default.isArray(chunk)) {
|
|
35
28
|
// from remotes we should expect chunks as arrays
|
|
36
29
|
chunk.filter(pkgItem => {
|
|
37
30
|
var _pkgItem$package;
|
|
38
|
-
|
|
39
31
|
debug(`streaming remote pkg name ${pkgItem === null || pkgItem === void 0 ? void 0 : (_pkgItem$package = pkgItem.package) === null || _pkgItem$package === void 0 ? void 0 : _pkgItem$package.name}`);
|
|
40
32
|
return true;
|
|
41
33
|
}).forEach(pkgItem => {
|
|
42
|
-
this.push({
|
|
34
|
+
this.push({
|
|
35
|
+
...pkgItem,
|
|
43
36
|
verdaccioPkgCached: false,
|
|
44
37
|
verdaccioPrivate: false
|
|
45
38
|
});
|
|
@@ -47,15 +40,12 @@ class TransFormResults extends _stream.Transform {
|
|
|
47
40
|
return callback();
|
|
48
41
|
} else {
|
|
49
42
|
var _chunk$package;
|
|
50
|
-
|
|
51
43
|
// local we expect objects
|
|
52
44
|
debug(`streaming local pkg name ${chunk === null || chunk === void 0 ? void 0 : (_chunk$package = chunk.package) === null || _chunk$package === void 0 ? void 0 : _chunk$package.name}`);
|
|
53
45
|
this.push(chunk);
|
|
54
46
|
return callback();
|
|
55
47
|
}
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
exports.TransFormResults = TransFormResults;
|
|
61
51
|
//# sourceMappingURL=TransFormResults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransFormResults.js","names":["debug","buildDebug","TransFormResults","Transform","constructor","options","_transform","chunk","_encoding","callback","_","isArray","filter","pkgItem","package","name","forEach","push","verdaccioPkgCached","verdaccioPrivate"],"sources":["../../src/lib/TransFormResults.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { Transform } from 'stream';\n\nimport { searchUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:storage:search:transform');\n\nexport class TransFormResults extends Transform {\n public constructor(options) {\n super(options);\n }\n\n /**\n * Transform either array of packages or a single package into a stream of packages.\n * From uplinks the chunks are array but from local packages are objects.\n * @param {string} chunk\n * @param {string} encoding\n * @param {function} done\n * @returns {void}\n * @override\n */\n public _transform(chunk, _encoding, callback) {\n if (_.isArray(chunk)) {\n // from remotes we should expect chunks as arrays\n (chunk as searchUtils.SearchItem[])\n .filter((pkgItem) => {\n debug(`streaming remote pkg name ${pkgItem?.package?.name}`);\n return true;\n })\n .forEach((pkgItem) => {\n this.push({ ...pkgItem, verdaccioPkgCached: false, verdaccioPrivate: false });\n });\n return callback();\n } else {\n // local we expect objects\n debug(`streaming local pkg name ${chunk?.package?.name}`);\n this.push(chunk);\n return callback();\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransFormResults.js","names":["debug","buildDebug","TransFormResults","Transform","constructor","options","_transform","chunk","_encoding","callback","_","isArray","filter","pkgItem","package","name","forEach","push","verdaccioPkgCached","verdaccioPrivate"],"sources":["../../src/lib/TransFormResults.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { Transform } from 'stream';\n\nimport { searchUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:storage:search:transform');\n\nexport class TransFormResults extends Transform {\n public constructor(options) {\n super(options);\n }\n\n /**\n * Transform either array of packages or a single package into a stream of packages.\n * From uplinks the chunks are array but from local packages are objects.\n * @param {string} chunk\n * @param {string} encoding\n * @param {function} done\n * @returns {void}\n * @override\n */\n public _transform(chunk, _encoding, callback) {\n if (_.isArray(chunk)) {\n // from remotes we should expect chunks as arrays\n (chunk as searchUtils.SearchItem[])\n .filter((pkgItem) => {\n debug(`streaming remote pkg name ${pkgItem?.package?.name}`);\n return true;\n })\n .forEach((pkgItem) => {\n this.push({ ...pkgItem, verdaccioPkgCached: false, verdaccioPrivate: false });\n });\n return callback();\n } else {\n // local we expect objects\n debug(`streaming local pkg name ${chunk?.package?.name}`);\n this.push(chunk);\n return callback();\n }\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAAmC;AAInC,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,oCAAoC,CAAC;AAEvD,MAAMC,gBAAgB,SAASC,iBAAS,CAAC;EACvCC,WAAW,CAACC,OAAO,EAAE;IAC1B,KAAK,CAACA,OAAO,CAAC;EAChB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACSC,UAAU,CAACC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAE;IAC5C,IAAIC,eAAC,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;MACpB;MACCA,KAAK,CACHK,MAAM,CAAEC,OAAO,IAAK;QAAA;QACnBb,KAAK,CAAE,6BAA4Ba,OAAO,aAAPA,OAAO,2CAAPA,OAAO,CAAEC,OAAO,qDAAhB,iBAAkBC,IAAK,EAAC,CAAC;QAC5D,OAAO,IAAI;MACb,CAAC,CAAC,CACDC,OAAO,CAAEH,OAAO,IAAK;QACpB,IAAI,CAACI,IAAI,CAAC;UAAE,GAAGJ,OAAO;UAAEK,kBAAkB,EAAE,KAAK;UAAEC,gBAAgB,EAAE;QAAM,CAAC,CAAC;MAC/E,CAAC,CAAC;MACJ,OAAOV,QAAQ,EAAE;IACnB,CAAC,MAAM;MAAA;MACL;MACAT,KAAK,CAAE,4BAA2BO,KAAK,aAALA,KAAK,yCAALA,KAAK,CAAEO,OAAO,mDAAd,eAAgBC,IAAK,EAAC,CAAC;MACzD,IAAI,CAACE,IAAI,CAACV,KAAK,CAAC;MAChB,OAAOE,QAAQ,EAAE;IACnB;EACF;AACF;AAAC"}
|
|
@@ -5,29 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.mapManifestToSearchPackageBody = mapManifestToSearchPackageBody;
|
|
7
7
|
exports.removeDuplicates = removeDuplicates;
|
|
8
|
-
|
|
9
8
|
var _lodash = require("lodash");
|
|
10
|
-
|
|
11
9
|
var _core = require("@verdaccio/core");
|
|
12
|
-
|
|
13
10
|
function removeDuplicates(results) {
|
|
14
11
|
const pkgNames = [];
|
|
15
12
|
const orderByResults = (0, _lodash.orderBy)(results, ['verdaccioPrivate', 'asc']);
|
|
16
13
|
return orderByResults.filter(pkg => {
|
|
17
14
|
var _pkg$package, _pkg$package2;
|
|
18
|
-
|
|
19
15
|
if (pkgNames.includes(pkg === null || pkg === void 0 ? void 0 : (_pkg$package = pkg.package) === null || _pkg$package === void 0 ? void 0 : _pkg$package.name)) {
|
|
20
16
|
return false;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
pkgNames.push(pkg === null || pkg === void 0 ? void 0 : (_pkg$package2 = pkg.package) === null || _pkg$package2 === void 0 ? void 0 : _pkg$package2.name);
|
|
24
19
|
return true;
|
|
25
20
|
});
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
function mapManifestToSearchPackageBody(pkg, searchItem) {
|
|
29
23
|
const latest = _core.pkgUtils.getLatest(pkg);
|
|
30
|
-
|
|
31
24
|
const version = pkg.versions[latest];
|
|
32
25
|
const result = {
|
|
33
26
|
name: version.name,
|
|
@@ -49,11 +42,9 @@ function mapManifestToSearchPackageBody(pkg, searchItem) {
|
|
|
49
42
|
bugs: version.bugs
|
|
50
43
|
}
|
|
51
44
|
};
|
|
52
|
-
|
|
53
45
|
if (typeof searchItem.package.scoped === 'string') {
|
|
54
46
|
result.scope = searchItem.package.scoped;
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
return result;
|
|
58
49
|
}
|
|
59
50
|
//# sourceMappingURL=search-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-utils.js","names":["removeDuplicates","results","pkgNames","orderByResults","orderBy","filter","pkg","includes","package","name","push","mapManifestToSearchPackageBody","searchItem","latest","pkgUtils","getLatest","version","versions","result","scope","description","keywords","date","time","author","publisher","maintainers","links","npm","homepage","repository","bugs","scoped"],"sources":["../../src/lib/search-utils.ts"],"sourcesContent":["import { orderBy } from 'lodash';\n\nimport { pkgUtils, searchUtils } from '@verdaccio/core';\nimport { Manifest, Version } from '@verdaccio/types';\n\nexport function removeDuplicates(results: searchUtils.SearchPackageItem[]) {\n const pkgNames: any[] = [];\n const orderByResults = orderBy(results, ['verdaccioPrivate', 'asc']);\n return orderByResults.filter((pkg) => {\n if (pkgNames.includes(pkg?.package?.name)) {\n return false;\n }\n pkgNames.push(pkg?.package?.name);\n return true;\n });\n}\n\nexport function mapManifestToSearchPackageBody(\n pkg: Manifest,\n searchItem: searchUtils.SearchItem\n): searchUtils.SearchPackageBody {\n const latest = pkgUtils.getLatest(pkg);\n const version: Version = pkg.versions[latest];\n const result: searchUtils.SearchPackageBody = {\n name: version.name,\n scope: '',\n description: version.description,\n version: latest,\n keywords: version.keywords,\n date: pkg.time[latest],\n // FIXME: type\n author: version.author as any,\n // FIXME: not possible fill this out from a private package\n publisher: {},\n // FIXME: type\n maintainers: version.maintainers as any,\n links: {\n npm: '',\n homepage: version.homepage,\n repository: version.repository,\n bugs: version.bugs,\n },\n };\n\n if (typeof searchItem.package.scoped === 'string') {\n result.scope = searchItem.package.scoped;\n }\n\n return result;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"search-utils.js","names":["removeDuplicates","results","pkgNames","orderByResults","orderBy","filter","pkg","includes","package","name","push","mapManifestToSearchPackageBody","searchItem","latest","pkgUtils","getLatest","version","versions","result","scope","description","keywords","date","time","author","publisher","maintainers","links","npm","homepage","repository","bugs","scoped"],"sources":["../../src/lib/search-utils.ts"],"sourcesContent":["import { orderBy } from 'lodash';\n\nimport { pkgUtils, searchUtils } from '@verdaccio/core';\nimport { Manifest, Version } from '@verdaccio/types';\n\nexport function removeDuplicates(results: searchUtils.SearchPackageItem[]) {\n const pkgNames: any[] = [];\n const orderByResults = orderBy(results, ['verdaccioPrivate', 'asc']);\n return orderByResults.filter((pkg) => {\n if (pkgNames.includes(pkg?.package?.name)) {\n return false;\n }\n pkgNames.push(pkg?.package?.name);\n return true;\n });\n}\n\nexport function mapManifestToSearchPackageBody(\n pkg: Manifest,\n searchItem: searchUtils.SearchItem\n): searchUtils.SearchPackageBody {\n const latest = pkgUtils.getLatest(pkg);\n const version: Version = pkg.versions[latest];\n const result: searchUtils.SearchPackageBody = {\n name: version.name,\n scope: '',\n description: version.description,\n version: latest,\n keywords: version.keywords,\n date: pkg.time[latest],\n // FIXME: type\n author: version.author as any,\n // FIXME: not possible fill this out from a private package\n publisher: {},\n // FIXME: type\n maintainers: version.maintainers as any,\n links: {\n npm: '',\n homepage: version.homepage,\n repository: version.repository,\n bugs: version.bugs,\n },\n };\n\n if (typeof searchItem.package.scoped === 'string') {\n result.scope = searchItem.package.scoped;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;AAAA;AAEA;AAGO,SAASA,gBAAgB,CAACC,OAAwC,EAAE;EACzE,MAAMC,QAAe,GAAG,EAAE;EAC1B,MAAMC,cAAc,GAAG,IAAAC,eAAO,EAACH,OAAO,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;EACpE,OAAOE,cAAc,CAACE,MAAM,CAAEC,GAAG,IAAK;IAAA;IACpC,IAAIJ,QAAQ,CAACK,QAAQ,CAACD,GAAG,aAAHA,GAAG,uCAAHA,GAAG,CAAEE,OAAO,iDAAZ,aAAcC,IAAI,CAAC,EAAE;MACzC,OAAO,KAAK;IACd;IACAP,QAAQ,CAACQ,IAAI,CAACJ,GAAG,aAAHA,GAAG,wCAAHA,GAAG,CAAEE,OAAO,kDAAZ,cAAcC,IAAI,CAAC;IACjC,OAAO,IAAI;EACb,CAAC,CAAC;AACJ;AAEO,SAASE,8BAA8B,CAC5CL,GAAa,EACbM,UAAkC,EACH;EAC/B,MAAMC,MAAM,GAAGC,cAAQ,CAACC,SAAS,CAACT,GAAG,CAAC;EACtC,MAAMU,OAAgB,GAAGV,GAAG,CAACW,QAAQ,CAACJ,MAAM,CAAC;EAC7C,MAAMK,MAAqC,GAAG;IAC5CT,IAAI,EAAEO,OAAO,CAACP,IAAI;IAClBU,KAAK,EAAE,EAAE;IACTC,WAAW,EAAEJ,OAAO,CAACI,WAAW;IAChCJ,OAAO,EAAEH,MAAM;IACfQ,QAAQ,EAAEL,OAAO,CAACK,QAAQ;IAC1BC,IAAI,EAAEhB,GAAG,CAACiB,IAAI,CAACV,MAAM,CAAC;IACtB;IACAW,MAAM,EAAER,OAAO,CAACQ,MAAa;IAC7B;IACAC,SAAS,EAAE,CAAC,CAAC;IACb;IACAC,WAAW,EAAEV,OAAO,CAACU,WAAkB;IACvCC,KAAK,EAAE;MACLC,GAAG,EAAE,EAAE;MACPC,QAAQ,EAAEb,OAAO,CAACa,QAAQ;MAC1BC,UAAU,EAAEd,OAAO,CAACc,UAAU;MAC9BC,IAAI,EAAEf,OAAO,CAACe;IAChB;EACF,CAAC;EAED,IAAI,OAAOnB,UAAU,CAACJ,OAAO,CAACwB,MAAM,KAAK,QAAQ,EAAE;IACjDd,MAAM,CAACC,KAAK,GAAGP,UAAU,CAACJ,OAAO,CAACwB,MAAM;EAC1C;EAEA,OAAOd,MAAM;AACf"}
|
package/build/lib/star-utils.js
CHANGED
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isExecutingStarCommand = isExecutingStarCommand;
|
|
7
7
|
exports.isPublishablePackage = isPublishablePackage;
|
|
8
8
|
exports.isStarManifest = isStarManifest;
|
|
9
|
-
|
|
10
9
|
var _core = require("@verdaccio/core");
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* Check whether the package metadata has enough data to be published
|
|
14
12
|
* @param pkg metadata
|
|
@@ -18,6 +16,7 @@ function isPublishablePackage(pkg) {
|
|
|
18
16
|
const keys = Object.keys(pkg);
|
|
19
17
|
return keys.includes('versions');
|
|
20
18
|
}
|
|
19
|
+
|
|
21
20
|
/**
|
|
22
21
|
* Verify if the user is actually executing an action, to avoid unnecessary calls
|
|
23
22
|
* to the storage.
|
|
@@ -26,22 +25,20 @@ function isPublishablePackage(pkg) {
|
|
|
26
25
|
* @param userIsAddingStar whether user is removing or adding star
|
|
27
26
|
* @returns boolean
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
28
|
function isExecutingStarCommand(localUsers, username, userIsAddingStar) {
|
|
32
|
-
const isExist = typeof localUsers[username] !== 'undefined';
|
|
33
|
-
|
|
29
|
+
const isExist = typeof localUsers[username] !== 'undefined';
|
|
30
|
+
// fails if user already exist and us trying to add star.
|
|
34
31
|
if (userIsAddingStar && isExist && localUsers[username]) {
|
|
35
|
-
return false;
|
|
32
|
+
return false;
|
|
33
|
+
// if is not adding a start but user exists (removing star)
|
|
36
34
|
} else if (!userIsAddingStar && isExist) {
|
|
37
|
-
return true;
|
|
35
|
+
return true;
|
|
36
|
+
// fails if user does not exist and is not adding any star
|
|
38
37
|
} else if (!userIsAddingStar && !isExist) {
|
|
39
38
|
return false;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
return true;
|
|
43
41
|
}
|
|
44
|
-
|
|
45
42
|
function isStarManifest(manifest) {
|
|
46
43
|
return isPublishablePackage(manifest) === false && _core.validatioUtils.isObject(manifest.users);
|
|
47
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"star-utils.js","names":["isPublishablePackage","pkg","keys","Object","includes","isExecutingStarCommand","localUsers","username","userIsAddingStar","isExist","isStarManifest","manifest","validatioUtils","isObject","users"],"sources":["../../src/lib/star-utils.ts"],"sourcesContent":["import { validatioUtils } from '@verdaccio/core';\nimport { Manifest, PackageUsers } from '@verdaccio/types';\n\n/**\n * Check whether the package metadata has enough data to be published\n * @param pkg metadata\n */\nexport function isPublishablePackage(pkg: Manifest): boolean {\n // TODO: we can do better, no need get keys\n const keys: string[] = Object.keys(pkg);\n\n return keys.includes('versions');\n}\n\n/**\n * Verify if the user is actually executing an action, to avoid unnecessary calls\n * to the storage.\n * @param localUsers current state at cache\n * @param username user is executing the action\n * @param userIsAddingStar whether user is removing or adding star\n * @returns boolean\n */\nexport function isExecutingStarCommand(\n localUsers: PackageUsers,\n username: string,\n userIsAddingStar: boolean\n): boolean {\n const isExist = typeof localUsers[username] !== 'undefined';\n // fails if user already exist and us trying to add star.\n if (userIsAddingStar && isExist && localUsers[username]) {\n return false;\n // if is not adding a start but user exists (removing star)\n } else if (!userIsAddingStar && isExist) {\n return true;\n // fails if user does not exist and is not adding any star\n } else if (!userIsAddingStar && !isExist) {\n return false;\n }\n return true;\n}\n\nexport function isStarManifest(manifest: Manifest): boolean {\n return isPublishablePackage(manifest) === false && validatioUtils.isObject(manifest.users);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"star-utils.js","names":["isPublishablePackage","pkg","keys","Object","includes","isExecutingStarCommand","localUsers","username","userIsAddingStar","isExist","isStarManifest","manifest","validatioUtils","isObject","users"],"sources":["../../src/lib/star-utils.ts"],"sourcesContent":["import { validatioUtils } from '@verdaccio/core';\nimport { Manifest, PackageUsers } from '@verdaccio/types';\n\n/**\n * Check whether the package metadata has enough data to be published\n * @param pkg metadata\n */\nexport function isPublishablePackage(pkg: Manifest): boolean {\n // TODO: we can do better, no need get keys\n const keys: string[] = Object.keys(pkg);\n\n return keys.includes('versions');\n}\n\n/**\n * Verify if the user is actually executing an action, to avoid unnecessary calls\n * to the storage.\n * @param localUsers current state at cache\n * @param username user is executing the action\n * @param userIsAddingStar whether user is removing or adding star\n * @returns boolean\n */\nexport function isExecutingStarCommand(\n localUsers: PackageUsers,\n username: string,\n userIsAddingStar: boolean\n): boolean {\n const isExist = typeof localUsers[username] !== 'undefined';\n // fails if user already exist and us trying to add star.\n if (userIsAddingStar && isExist && localUsers[username]) {\n return false;\n // if is not adding a start but user exists (removing star)\n } else if (!userIsAddingStar && isExist) {\n return true;\n // fails if user does not exist and is not adding any star\n } else if (!userIsAddingStar && !isExist) {\n return false;\n }\n return true;\n}\n\nexport function isStarManifest(manifest: Manifest): boolean {\n return isPublishablePackage(manifest) === false && validatioUtils.isObject(manifest.users);\n}\n"],"mappings":";;;;;;;;AAAA;AAGA;AACA;AACA;AACA;AACO,SAASA,oBAAoB,CAACC,GAAa,EAAW;EAC3D;EACA,MAAMC,IAAc,GAAGC,MAAM,CAACD,IAAI,CAACD,GAAG,CAAC;EAEvC,OAAOC,IAAI,CAACE,QAAQ,CAAC,UAAU,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsB,CACpCC,UAAwB,EACxBC,QAAgB,EAChBC,gBAAyB,EAChB;EACT,MAAMC,OAAO,GAAG,OAAOH,UAAU,CAACC,QAAQ,CAAC,KAAK,WAAW;EAC3D;EACA,IAAIC,gBAAgB,IAAIC,OAAO,IAAIH,UAAU,CAACC,QAAQ,CAAC,EAAE;IACvD,OAAO,KAAK;IACZ;EACF,CAAC,MAAM,IAAI,CAACC,gBAAgB,IAAIC,OAAO,EAAE;IACvC,OAAO,IAAI;IACX;EACF,CAAC,MAAM,IAAI,CAACD,gBAAgB,IAAI,CAACC,OAAO,EAAE;IACxC,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb;AAEO,SAASC,cAAc,CAACC,QAAkB,EAAW;EAC1D,OAAOX,oBAAoB,CAACW,QAAQ,CAAC,KAAK,KAAK,IAAIC,oBAAc,CAACC,QAAQ,CAACF,QAAQ,CAACG,KAAK,CAAC;AAC5F"}
|
|
@@ -21,33 +21,25 @@ exports.normalizeDistTags = normalizeDistTags;
|
|
|
21
21
|
exports.normalizePackage = normalizePackage;
|
|
22
22
|
exports.prepareSearchPackage = prepareSearchPackage;
|
|
23
23
|
exports.updateUpLinkMetadata = updateUpLinkMetadata;
|
|
24
|
-
|
|
25
24
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
26
|
-
|
|
27
25
|
var _semver = _interopRequireDefault(require("semver"));
|
|
28
|
-
|
|
29
26
|
var _core = require("@verdaccio/core");
|
|
30
|
-
|
|
31
27
|
var _utils = require("@verdaccio/utils");
|
|
32
|
-
|
|
33
28
|
var _versionsUtils = require("./versions-utils");
|
|
34
|
-
|
|
35
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
-
|
|
37
30
|
const STORAGE = {
|
|
38
31
|
PACKAGE_FILE_NAME: 'package.json',
|
|
39
32
|
FILE_EXIST_ERROR: 'EEXISTS',
|
|
40
33
|
NO_SUCH_FILE_ERROR: 'ENOENT',
|
|
41
34
|
DEFAULT_REVISION: '0-0000000000000000'
|
|
42
35
|
};
|
|
36
|
+
|
|
43
37
|
/**
|
|
44
38
|
* Create a new package in the storage, return a boilerplate package
|
|
45
39
|
* @param name package name
|
|
46
40
|
* @returns {Manifest}
|
|
47
41
|
*/
|
|
48
|
-
|
|
49
42
|
exports.STORAGE = STORAGE;
|
|
50
|
-
|
|
51
43
|
function generatePackageTemplate(name) {
|
|
52
44
|
return {
|
|
53
45
|
// standard things
|
|
@@ -62,110 +54,93 @@ function generatePackageTemplate(name) {
|
|
|
62
54
|
_rev: ''
|
|
63
55
|
};
|
|
64
56
|
}
|
|
57
|
+
|
|
65
58
|
/**
|
|
66
59
|
* Normalize package properties, tags, revision id.
|
|
67
60
|
* @param {Object} pkg package reference.
|
|
68
61
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
62
|
function normalizePackage(pkg) {
|
|
72
63
|
const pkgProperties = ['versions', 'dist-tags', '_distfiles', '_attachments', '_uplinks', 'time'];
|
|
73
64
|
pkgProperties.forEach(key => {
|
|
74
65
|
const pkgProp = pkg[key];
|
|
75
|
-
|
|
76
66
|
if ((0, _utils.isNil)(pkgProp) || _core.validatioUtils.isObject(pkgProp) === false) {
|
|
77
67
|
pkg[key] = {};
|
|
78
68
|
}
|
|
79
69
|
});
|
|
80
|
-
|
|
81
70
|
if (typeof (pkg === null || pkg === void 0 ? void 0 : pkg._rev) !== 'string') {
|
|
82
71
|
pkg._rev = STORAGE.DEFAULT_REVISION;
|
|
83
72
|
}
|
|
84
|
-
|
|
85
73
|
if (typeof (pkg === null || pkg === void 0 ? void 0 : pkg._id) !== 'string') {
|
|
86
74
|
pkg._id = pkg.name;
|
|
87
|
-
}
|
|
88
|
-
|
|
75
|
+
}
|
|
89
76
|
|
|
77
|
+
// normalize dist-tags
|
|
90
78
|
return normalizeDistTags(pkg);
|
|
91
79
|
}
|
|
92
|
-
|
|
93
80
|
function generateRevision(rev) {
|
|
94
81
|
const _rev = rev.split('-');
|
|
95
|
-
|
|
96
82
|
return (+_rev[0] || 0) + 1 + '-' + (0, _utils.generateRandomHexString)();
|
|
97
83
|
}
|
|
98
|
-
|
|
99
84
|
function getLatestReadme(pkg) {
|
|
100
85
|
const versions = pkg['versions'] || {};
|
|
101
|
-
const distTags = pkg[_core.DIST_TAGS] || {};
|
|
102
|
-
|
|
86
|
+
const distTags = pkg[_core.DIST_TAGS] || {};
|
|
87
|
+
// FIXME: here is a bit tricky add the types
|
|
103
88
|
const latestVersion = distTags['latest'] ? versions[distTags['latest']] || {} : {};
|
|
104
|
-
|
|
105
89
|
let readme = _lodash.default.trim(pkg.readme || latestVersion.readme || '');
|
|
106
|
-
|
|
107
90
|
if (readme) {
|
|
108
91
|
return readme;
|
|
109
|
-
}
|
|
110
|
-
// 'next','beta','alpha','test','dev','canary'
|
|
111
|
-
|
|
92
|
+
}
|
|
112
93
|
|
|
94
|
+
// In case of empty readme - trying to get ANY readme in the following order:
|
|
95
|
+
// 'next','beta','alpha','test','dev','canary'
|
|
113
96
|
const readmeDistTagsPriority = ['next', 'beta', 'alpha', 'test', 'dev', 'canary'];
|
|
114
97
|
readmeDistTagsPriority.forEach(function (tag) {
|
|
115
98
|
if (readme) {
|
|
116
99
|
return readme;
|
|
117
100
|
}
|
|
118
|
-
|
|
119
101
|
const version = distTags[tag] ? versions[distTags[tag]] || {} : {};
|
|
120
102
|
readme = _lodash.default.trim(version.readme || readme);
|
|
121
103
|
});
|
|
122
104
|
return readme;
|
|
123
|
-
}
|
|
124
|
-
|
|
105
|
+
}
|
|
125
106
|
|
|
107
|
+
// FIXME: type any due this
|
|
126
108
|
function cleanUpReadme(version) {
|
|
127
109
|
if ((0, _utils.isNil)(version) === false) {
|
|
128
110
|
delete version.readme;
|
|
129
111
|
}
|
|
130
|
-
|
|
131
112
|
return version;
|
|
132
113
|
}
|
|
133
|
-
|
|
134
114
|
const WHITELIST = ['_rev', 'name', 'versions', 'dist-tags', 'readme', 'time', '_id', 'users'];
|
|
135
115
|
exports.WHITELIST = WHITELIST;
|
|
136
|
-
|
|
137
116
|
function cleanUpLinksRef(result, keepUpLinkData) {
|
|
138
117
|
const propertyToKeep = [...WHITELIST];
|
|
139
|
-
|
|
140
118
|
if (keepUpLinkData === true) {
|
|
141
119
|
propertyToKeep.push('_uplinks');
|
|
142
120
|
}
|
|
143
|
-
|
|
144
121
|
for (const i in result) {
|
|
145
122
|
if (propertyToKeep.indexOf(i) === -1) {
|
|
146
123
|
// Remove sections like '_uplinks' from response
|
|
147
124
|
delete result[i];
|
|
148
125
|
}
|
|
149
126
|
}
|
|
150
|
-
|
|
151
127
|
return result;
|
|
152
|
-
}
|
|
153
|
-
// @deprecated use abstract.storage.ts:checkPackageRemote
|
|
154
|
-
|
|
128
|
+
}
|
|
155
129
|
|
|
130
|
+
// TODO: move to abstract storage
|
|
131
|
+
// @deprecated use abstract.storage.ts:checkPackageRemote
|
|
156
132
|
function checkPackageRemote(name, isAllowPublishOffline, syncMetadata) {
|
|
157
133
|
return new Promise((resolve, reject) => {
|
|
158
134
|
syncMetadata(name, null, {}, (err, packageJsonLocal, upLinksErrors) => {
|
|
159
135
|
// something weird
|
|
160
136
|
if (err && err.status !== _core.HTTP_STATUS.NOT_FOUND) {
|
|
161
137
|
return reject(err);
|
|
162
|
-
}
|
|
163
|
-
|
|
138
|
+
}
|
|
164
139
|
|
|
140
|
+
// checking package exist already
|
|
165
141
|
if ((0, _utils.isNil)(packageJsonLocal) === false) {
|
|
166
142
|
return reject(_core.errorUtils.getConflict(_core.API_ERROR.PACKAGE_EXIST));
|
|
167
143
|
}
|
|
168
|
-
|
|
169
144
|
for (let errorItem = 0; errorItem < upLinksErrors.length; errorItem++) {
|
|
170
145
|
// checking error
|
|
171
146
|
// if uplink fails with a status other than 404, we report failure
|
|
@@ -174,54 +149,50 @@ function checkPackageRemote(name, isAllowPublishOffline, syncMetadata) {
|
|
|
174
149
|
if (isAllowPublishOffline) {
|
|
175
150
|
return resolve();
|
|
176
151
|
}
|
|
177
|
-
|
|
178
152
|
return reject(_core.errorUtils.getServiceUnavailable(_core.API_ERROR.UPLINK_OFFLINE_PUBLISH));
|
|
179
153
|
}
|
|
180
154
|
}
|
|
181
155
|
}
|
|
182
|
-
|
|
183
156
|
return resolve();
|
|
184
157
|
});
|
|
185
158
|
});
|
|
186
|
-
}
|
|
187
|
-
|
|
159
|
+
}
|
|
188
160
|
|
|
161
|
+
// @deprecated use export function mergeUplinkTimeIntoLocalNext
|
|
189
162
|
function mergeUplinkTimeIntoLocal(localMetadata, remoteMetadata) {
|
|
190
163
|
if ('time' in remoteMetadata) {
|
|
191
164
|
return Object.assign({}, localMetadata.time, remoteMetadata.time);
|
|
192
165
|
}
|
|
193
|
-
|
|
194
166
|
return localMetadata.time;
|
|
195
167
|
}
|
|
196
|
-
|
|
197
168
|
function mergeUplinkTimeIntoLocalNext(cacheManifest, remoteManifest) {
|
|
198
169
|
if ('time' in remoteManifest) {
|
|
199
170
|
// remote override cache time conflicts
|
|
200
|
-
return {
|
|
201
|
-
|
|
171
|
+
return {
|
|
172
|
+
...cacheManifest,
|
|
173
|
+
time: {
|
|
174
|
+
...cacheManifest.time,
|
|
202
175
|
...remoteManifest.time
|
|
203
176
|
}
|
|
204
177
|
};
|
|
205
178
|
}
|
|
206
|
-
|
|
207
179
|
return cacheManifest;
|
|
208
180
|
}
|
|
209
|
-
|
|
210
181
|
function updateUpLinkMetadata(uplinkId, manifest, etag) {
|
|
211
|
-
const _uplinks = {
|
|
182
|
+
const _uplinks = {
|
|
183
|
+
...manifest._uplinks,
|
|
212
184
|
[uplinkId]: {
|
|
213
185
|
etag,
|
|
214
186
|
fetched: Date.now()
|
|
215
187
|
}
|
|
216
188
|
};
|
|
217
|
-
return {
|
|
189
|
+
return {
|
|
190
|
+
...manifest,
|
|
218
191
|
_uplinks
|
|
219
192
|
};
|
|
220
193
|
}
|
|
221
|
-
|
|
222
194
|
function prepareSearchPackage(data) {
|
|
223
195
|
const latest = _core.pkgUtils.getLatest(data);
|
|
224
|
-
|
|
225
196
|
if (latest && data.versions[latest]) {
|
|
226
197
|
const version = data.versions[latest];
|
|
227
198
|
const versions = {
|
|
@@ -249,17 +220,15 @@ function prepareSearchPackage(data) {
|
|
|
249
220
|
return pkg;
|
|
250
221
|
}
|
|
251
222
|
}
|
|
252
|
-
|
|
253
223
|
function isDifferentThanOne(versions) {
|
|
254
224
|
return Object.keys(versions).length !== 1;
|
|
255
|
-
}
|
|
256
|
-
|
|
225
|
+
}
|
|
257
226
|
|
|
227
|
+
// @deprecated use validationUtils.validatePublishNewPackage
|
|
258
228
|
function hasInvalidPublishBody(manifest) {
|
|
259
229
|
if (!manifest) {
|
|
260
230
|
return false;
|
|
261
231
|
}
|
|
262
|
-
|
|
263
232
|
const {
|
|
264
233
|
_attachments,
|
|
265
234
|
versions
|
|
@@ -267,6 +236,7 @@ function hasInvalidPublishBody(manifest) {
|
|
|
267
236
|
const res = (0, _utils.isObject)(_attachments) === false || isDifferentThanOne(_attachments) || (0, _utils.isObject)(versions) === false || isDifferentThanOne(versions);
|
|
268
237
|
return res;
|
|
269
238
|
}
|
|
239
|
+
|
|
270
240
|
/**
|
|
271
241
|
* Function gets a local info and an info from uplinks and tries to merge it
|
|
272
242
|
exported for unit tests only.
|
|
@@ -274,47 +244,44 @@ function hasInvalidPublishBody(manifest) {
|
|
|
274
244
|
* @param {*} remoteManifest
|
|
275
245
|
* @param {*} config configuration file
|
|
276
246
|
*/
|
|
277
|
-
|
|
278
|
-
|
|
279
247
|
function mergeVersions(cacheManifest, remoteManifest) {
|
|
280
|
-
let _cacheManifest = {
|
|
248
|
+
let _cacheManifest = {
|
|
249
|
+
...cacheManifest
|
|
281
250
|
};
|
|
282
251
|
const {
|
|
283
252
|
versions,
|
|
284
253
|
time
|
|
285
|
-
} = remoteManifest;
|
|
254
|
+
} = remoteManifest;
|
|
255
|
+
// copy new versions to a cache
|
|
286
256
|
// NOTE: if a certain version was updated, we can't refresh it reliably
|
|
287
|
-
|
|
288
257
|
for (const i in versions) {
|
|
289
258
|
if (typeof cacheManifest.versions[i] === 'undefined') {
|
|
290
259
|
_cacheManifest.versions[i] = versions[i];
|
|
291
260
|
}
|
|
292
261
|
}
|
|
293
|
-
|
|
294
262
|
for (const i in time) {
|
|
295
263
|
if (typeof cacheManifest.time[i] === 'undefined') {
|
|
296
264
|
_cacheManifest.time[i] = time[i];
|
|
297
265
|
}
|
|
298
266
|
}
|
|
299
|
-
|
|
300
267
|
for (const distTag in remoteManifest[_core.DIST_TAGS]) {
|
|
301
268
|
if (_cacheManifest[_core.DIST_TAGS][distTag] !== remoteManifest[_core.DIST_TAGS][distTag]) {
|
|
302
269
|
if (!_cacheManifest[_core.DIST_TAGS][distTag] || _semver.default.lte(_cacheManifest[_core.DIST_TAGS][distTag], remoteManifest[_core.DIST_TAGS][distTag])) {
|
|
303
270
|
_cacheManifest[_core.DIST_TAGS][distTag] = remoteManifest[_core.DIST_TAGS][distTag];
|
|
304
271
|
}
|
|
305
|
-
|
|
306
272
|
if (distTag === 'latest' && _cacheManifest[_core.DIST_TAGS][distTag] === remoteManifest[_core.DIST_TAGS][distTag]) {
|
|
307
273
|
// NOTE: this override the latest publish readme from local cache with
|
|
308
274
|
// the remote one
|
|
309
|
-
cacheManifest = {
|
|
275
|
+
cacheManifest = {
|
|
276
|
+
..._cacheManifest,
|
|
310
277
|
readme: remoteManifest.readme
|
|
311
278
|
};
|
|
312
279
|
}
|
|
313
280
|
}
|
|
314
281
|
}
|
|
315
|
-
|
|
316
282
|
return cacheManifest;
|
|
317
283
|
}
|
|
284
|
+
|
|
318
285
|
/**
|
|
319
286
|
* Normalize dist-tags.
|
|
320
287
|
*
|
|
@@ -330,23 +297,18 @@ function mergeVersions(cacheManifest, remoteManifest) {
|
|
|
330
297
|
*
|
|
331
298
|
* @param {*} data
|
|
332
299
|
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
300
|
function normalizeDistTags(manifest) {
|
|
336
|
-
let sorted;
|
|
337
|
-
|
|
301
|
+
let sorted;
|
|
302
|
+
// handle missing latest dist-tag
|
|
338
303
|
if (!manifest[_core.DIST_TAGS].latest) {
|
|
339
304
|
var _sorted;
|
|
340
|
-
|
|
341
305
|
// if there is no latest tag, set the highest known version based on semver sort
|
|
342
306
|
sorted = (0, _versionsUtils.sortVersionsAndFilterInvalid)(Object.keys(manifest.versions));
|
|
343
|
-
|
|
344
307
|
if ((_sorted = sorted) !== null && _sorted !== void 0 && _sorted.length) {
|
|
345
308
|
// get the highest published version
|
|
346
309
|
manifest[_core.DIST_TAGS].latest = sorted.pop();
|
|
347
310
|
}
|
|
348
311
|
}
|
|
349
|
-
|
|
350
312
|
for (const tag in manifest[_core.DIST_TAGS]) {
|
|
351
313
|
// deprecated (will be removed un future majors)
|
|
352
314
|
// this should not happen, tags should be plain strings, legacy fallback
|
|
@@ -356,7 +318,6 @@ function normalizeDistTags(manifest) {
|
|
|
356
318
|
// FIXME: this is clearly wrong, we need to research why this is like this.
|
|
357
319
|
// @ts-ignore
|
|
358
320
|
sorted = (0, _versionsUtils.sortVersionsAndFilterInvalid)(manifest[_core.DIST_TAGS][tag]);
|
|
359
|
-
|
|
360
321
|
if (sorted.length) {
|
|
361
322
|
// use highest version based on semver sort
|
|
362
323
|
manifest[_core.DIST_TAGS][tag] = sorted.pop();
|
|
@@ -371,24 +332,19 @@ function normalizeDistTags(manifest) {
|
|
|
371
332
|
}
|
|
372
333
|
}
|
|
373
334
|
}
|
|
374
|
-
|
|
375
335
|
return manifest;
|
|
376
336
|
}
|
|
377
|
-
|
|
378
337
|
function hasDeprecatedVersions(pkgInfo) {
|
|
379
338
|
const {
|
|
380
339
|
versions
|
|
381
340
|
} = pkgInfo;
|
|
382
|
-
|
|
383
341
|
for (const version in versions) {
|
|
384
342
|
if (Object.prototype.hasOwnProperty.call(versions[version], 'deprecated')) {
|
|
385
343
|
return true;
|
|
386
344
|
}
|
|
387
345
|
}
|
|
388
|
-
|
|
389
346
|
return false;
|
|
390
347
|
}
|
|
391
|
-
|
|
392
348
|
function isDeprecatedManifest(manifest) {
|
|
393
349
|
return hasDeprecatedVersions(manifest) && Object.keys(manifest._attachments).length === 0;
|
|
394
350
|
}
|