@verdaccio/store 6.0.0-6-next.21 → 6.0.0-6-next.24

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/build/index.d.ts +5 -4
  3. package/build/index.js +31 -15
  4. package/build/index.js.map +1 -1
  5. package/build/lib/TransFormResults.d.ts +15 -0
  6. package/build/lib/TransFormResults.js +61 -0
  7. package/build/lib/TransFormResults.js.map +1 -0
  8. package/build/lib/search-utils.d.ts +4 -0
  9. package/build/lib/search-utils.js +59 -0
  10. package/build/lib/search-utils.js.map +1 -0
  11. package/build/lib/star-utils.d.ts +14 -0
  12. package/build/{star-utils.js → lib/star-utils.js} +16 -2
  13. package/build/lib/star-utils.js.map +1 -0
  14. package/build/lib/storage-utils.d.ts +82 -0
  15. package/build/{storage-utils.js → lib/storage-utils.js} +173 -60
  16. package/build/lib/storage-utils.js.map +1 -0
  17. package/build/lib/uplink-util.d.ts +10 -0
  18. package/build/lib/uplink-util.js +49 -0
  19. package/build/lib/uplink-util.js.map +1 -0
  20. package/build/lib/versions-utils.d.ts +28 -0
  21. package/build/lib/versions-utils.js +104 -0
  22. package/build/lib/versions-utils.js.map +1 -0
  23. package/build/local-storage.d.ts +3 -165
  24. package/build/local-storage.js +6 -1166
  25. package/build/local-storage.js.map +1 -1
  26. package/build/storage.d.ts +242 -86
  27. package/build/storage.js +1681 -548
  28. package/build/storage.js.map +1 -1
  29. package/build/type.d.ts +42 -19
  30. package/build/type.js.map +1 -1
  31. package/jest.config.js +8 -2
  32. package/package.json +71 -71
  33. package/src/index.ts +5 -4
  34. package/src/lib/TransFormResults.ts +42 -0
  35. package/src/lib/search-utils.ts +50 -0
  36. package/src/{star-utils.ts → lib/star-utils.ts} +16 -5
  37. package/src/lib/storage-utils.ts +362 -0
  38. package/src/lib/uplink-util.ts +41 -0
  39. package/src/lib/versions-utils.ts +87 -0
  40. package/src/local-storage.ts +7 -1217
  41. package/src/storage.ts +1683 -635
  42. package/src/type.ts +47 -21
  43. package/test/fixtures/config/getTarballNext-getupstream.yaml +17 -0
  44. package/test/fixtures/config/syncDoubleUplinksMetadata.yaml +25 -0
  45. package/test/fixtures/config/syncNoUplinksMetadata.yaml +17 -0
  46. package/test/fixtures/config/syncSingleUplinksMetadata.yaml +21 -0
  47. package/test/fixtures/config/updateManifest-1.yaml +16 -0
  48. package/test/fixtures/manifests/foo-npmjs.json +253 -0
  49. package/test/fixtures/manifests/foo-verdaccio.json +253 -0
  50. package/test/fixtures/tarball.tgz +0 -0
  51. package/test/helpers.ts +22 -0
  52. package/test/local-store.__disabled__.ts +553 -0
  53. package/test/search.spec.ts +4 -5
  54. package/test/star.spec.ts +31 -0
  55. package/test/storage-utils.spec.ts +129 -42
  56. package/test/storage.spec.ts +943 -33
  57. package/test/versions.spec.ts +109 -0
  58. package/tsconfig.json +6 -3
  59. package/build/search.d.ts +0 -35
  60. package/build/search.js +0 -198
  61. package/build/search.js.map +0 -1
  62. package/build/star-utils.d.ts +0 -9
  63. package/build/star-utils.js.map +0 -1
  64. package/build/storage-utils.d.ts +0 -39
  65. package/build/storage-utils.js.map +0 -1
  66. package/build/uplink-util.d.ts +0 -7
  67. package/build/uplink-util.js +0 -38
  68. package/build/uplink-util.js.map +0 -1
  69. package/src/search.ts +0 -175
  70. package/src/storage-utils.ts +0 -263
  71. package/src/uplink-util.ts +0 -32
  72. package/test/local-storage.spec.ts +0 -583
@@ -0,0 +1,41 @@
1
+ import { IProxy, ProxyStorage } from '@verdaccio/proxy';
2
+ import { Config, Manifest } from '@verdaccio/types';
3
+
4
+ export interface ProxyInstanceList {
5
+ [key: string]: IProxy;
6
+ }
7
+
8
+ /**
9
+ * Set up the Up Storage for each link.
10
+ */
11
+ export function setupUpLinks(config: Config): ProxyInstanceList {
12
+ const uplinks: ProxyInstanceList = {};
13
+
14
+ for (const uplinkName in config.uplinks) {
15
+ if (Object.prototype.hasOwnProperty.call(config.uplinks, uplinkName)) {
16
+ // instance for each up-link definition
17
+ const proxy: IProxy = new ProxyStorage(config.uplinks[uplinkName], config);
18
+ // TODO: review this can be inside ProxyStorage
19
+ proxy.upname = uplinkName;
20
+
21
+ uplinks[uplinkName] = proxy;
22
+ }
23
+ }
24
+
25
+ return uplinks;
26
+ }
27
+
28
+ export function updateVersionsHiddenUpLinkNext(manifest: Manifest, upLink: IProxy): Manifest {
29
+ const { versions } = manifest;
30
+ const versionsList = Object.keys(versions);
31
+ if (versionsList.length === 0) {
32
+ return manifest;
33
+ }
34
+
35
+ for (const version of versionsList) {
36
+ // holds a "hidden" value to be used by the package storage.
37
+ versions[version][Symbol.for('__verdaccio_uplink')] = upLink.upname;
38
+ }
39
+
40
+ return { ...manifest, versions: versions };
41
+ }
@@ -0,0 +1,87 @@
1
+ import _ from 'lodash';
2
+ import semver, { SemVer } from 'semver';
3
+
4
+ import { DIST_TAGS } from '@verdaccio/core';
5
+ import { Manifest, StringValue, Version, Versions } from '@verdaccio/types';
6
+
7
+ /**
8
+ * Gets version from a package object taking into account semver weirdness.
9
+ * @return {String} return the semantic version of a package
10
+ */
11
+ export function getVersion(versions: Versions, version: string): Version | undefined {
12
+ if (!versions) {
13
+ return;
14
+ }
15
+
16
+ // this condition must allow cast
17
+ if (_.isNil(versions[version]) === false) {
18
+ return versions[version];
19
+ }
20
+
21
+ const versionSemver: SemVer | null = semver.parse(version, true);
22
+ if (versionSemver === null) {
23
+ return;
24
+ }
25
+
26
+ for (const versionItem in versions) {
27
+ if (Object.prototype.hasOwnProperty.call(versions, versionItem)) {
28
+ // @ts-ignore
29
+ if (versionSemver.compare(semver.parse(versionItem, true)) === 0) {
30
+ return versions[versionItem];
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Function filters out bad semver versions and sorts the array.
38
+ * @return {Array} sorted Array
39
+ */
40
+ export function sortVersionsAndFilterInvalid(listVersions: string[] /* logger */): string[] {
41
+ return (
42
+ listVersions
43
+ .filter(function (version): boolean {
44
+ if (!semver.parse(version, true)) {
45
+ return false;
46
+ }
47
+ return true;
48
+ })
49
+ // FIXME: it seems the @types/semver do not handle a legitimate method named 'compareLoose'
50
+ // @ts-ignore
51
+ .sort(semver.compareLoose)
52
+ .map(String)
53
+ );
54
+ }
55
+
56
+ /**
57
+ * Create a tag for a package
58
+ * @param {*} data
59
+ * @param {*} version
60
+ * @param {*} tag
61
+ * @return {Boolean} whether a package has been tagged
62
+ * @deprecated
63
+ */
64
+ export function tagVersion(data: Manifest, version: string, tag: StringValue): boolean {
65
+ if (tag && data[DIST_TAGS][tag] !== version && semver.parse(version, true)) {
66
+ // valid version - store
67
+ data[DIST_TAGS][tag] = version;
68
+ return true;
69
+ }
70
+ return false;
71
+ }
72
+
73
+ /**
74
+ *
75
+ * @param manifest
76
+ * @param version
77
+ * @param tag
78
+ * @returns
79
+ */
80
+ export function tagVersionNext(manifest: Manifest, version: string, tag: StringValue): Manifest {
81
+ const data = { ...manifest };
82
+ if (tag && data[DIST_TAGS][tag] !== version && semver.parse(version, true)) {
83
+ // valid version - store
84
+ data[DIST_TAGS][tag] = version;
85
+ }
86
+ return data;
87
+ }