@verdaccio/proxy 7.0.0-next-7.19 → 7.0.0-next-8.21
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 +19 -0
- package/package.json +9 -9
- package/test/headers.auth.spec.ts +7 -5
- package/test/noProxy.spec.ts +2 -0
- package/test/proxy-utils.spec.ts +1 -0
- package/test/proxy.metadata.spec.ts +10 -23
- package/test/proxy.search.spec.ts +6 -5
- package/test/proxy.tarball.spec.ts +41 -37
- package/jest.config.js +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @verdaccio/proxy
|
|
2
2
|
|
|
3
|
+
## 7.0.0-next-8.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8c10a3e]
|
|
8
|
+
- Updated dependencies [a05a7d8]
|
|
9
|
+
- Updated dependencies [7c9f3cf]
|
|
10
|
+
- @verdaccio/config@7.0.0-next-8.21
|
|
11
|
+
- @verdaccio/core@7.0.0-next-8.21
|
|
12
|
+
- @verdaccio/utils@7.0.0-next-8.21
|
|
13
|
+
|
|
14
|
+
## 7.0.0-next-7.20
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- @verdaccio/core@7.0.0-next-7.20
|
|
19
|
+
- @verdaccio/config@7.0.0-next-7.20
|
|
20
|
+
- @verdaccio/utils@7.0.0-next-7.20
|
|
21
|
+
|
|
3
22
|
## 7.0.0-next-7.19
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/proxy",
|
|
3
|
-
"version": "7.0.0-next-
|
|
3
|
+
"version": "7.0.0-next-8.21",
|
|
4
4
|
"description": "verdaccio proxy fetcher",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,26 +26,26 @@
|
|
|
26
26
|
"verdaccio"
|
|
27
27
|
],
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
29
|
+
"node": ">=14"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/config": "7.0.0-next-
|
|
33
|
-
"@verdaccio/core": "7.0.0-next-
|
|
34
|
-
"@verdaccio/utils": "7.0.0-next-
|
|
32
|
+
"@verdaccio/config": "7.0.0-next-8.21",
|
|
33
|
+
"@verdaccio/core": "7.0.0-next-8.21",
|
|
34
|
+
"@verdaccio/utils": "7.0.0-next-8.21",
|
|
35
35
|
"JSONStream": "1.3.5",
|
|
36
|
-
"debug": "4.3.
|
|
36
|
+
"debug": "4.3.6",
|
|
37
37
|
"got-cjs": "12.5.4",
|
|
38
38
|
"hpagent": "1.2.0",
|
|
39
39
|
"lodash": "4.17.21"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@verdaccio/logger": "7.0.0-next-
|
|
42
|
+
"@verdaccio/logger": "7.0.0-next-8.21",
|
|
43
43
|
"@verdaccio/types": "12.0.0-next-7.5",
|
|
44
44
|
"get-stream": "^6.0.1",
|
|
45
45
|
"nock": "13.5.1",
|
|
46
46
|
"node-mocks-http": "1.14.1",
|
|
47
47
|
"p-cancelable": "2.1.1",
|
|
48
|
-
"semver": "7.6.
|
|
48
|
+
"semver": "7.6.3"
|
|
49
49
|
},
|
|
50
50
|
"funding": {
|
|
51
51
|
"type": "opencollective",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"clean": "rimraf ./build",
|
|
56
|
-
"test": "
|
|
56
|
+
"test": "vitest run",
|
|
57
57
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
58
58
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
59
59
|
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
2
|
+
|
|
1
3
|
import { DEFAULT_REGISTRY } from '@verdaccio/config';
|
|
2
4
|
import { HEADERS, TOKEN_BASIC, TOKEN_BEARER, constants } from '@verdaccio/core';
|
|
3
5
|
import { Logger } from '@verdaccio/types';
|
|
@@ -5,11 +7,11 @@ import { buildToken } from '@verdaccio/utils';
|
|
|
5
7
|
|
|
6
8
|
import { ProxyStorage } from '../src';
|
|
7
9
|
|
|
8
|
-
const mockDebug =
|
|
9
|
-
const mockInfo =
|
|
10
|
-
const mockHttp =
|
|
11
|
-
const mockError =
|
|
12
|
-
const mockWarn =
|
|
10
|
+
const mockDebug = vi.fn();
|
|
11
|
+
const mockInfo = vi.fn();
|
|
12
|
+
const mockHttp = vi.fn();
|
|
13
|
+
const mockError = vi.fn();
|
|
14
|
+
const mockWarn = vi.fn();
|
|
13
15
|
|
|
14
16
|
const logger = {
|
|
15
17
|
debug: mockDebug,
|
package/test/noProxy.spec.ts
CHANGED
package/test/proxy-utils.spec.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nock from 'nock';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { setTimeout } from 'timers/promises';
|
|
4
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
4
5
|
|
|
5
6
|
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
6
7
|
import { API_ERROR, errorUtils } from '@verdaccio/core';
|
|
@@ -10,11 +11,11 @@ import { ProxyStorage } from '../src';
|
|
|
10
11
|
|
|
11
12
|
const getConf = (name) => path.join(__dirname, '/conf', name);
|
|
12
13
|
|
|
13
|
-
const mockDebug =
|
|
14
|
-
const mockInfo =
|
|
15
|
-
const mockHttp =
|
|
16
|
-
const mockError =
|
|
17
|
-
const mockWarn =
|
|
14
|
+
const mockDebug = vi.fn();
|
|
15
|
+
const mockInfo = vi.fn();
|
|
16
|
+
const mockHttp = vi.fn();
|
|
17
|
+
const mockError = vi.fn();
|
|
18
|
+
const mockWarn = vi.fn();
|
|
18
19
|
|
|
19
20
|
const logger = {
|
|
20
21
|
debug: mockDebug,
|
|
@@ -24,39 +25,25 @@ const logger = {
|
|
|
24
25
|
warn: mockWarn,
|
|
25
26
|
} as unknown as Logger;
|
|
26
27
|
|
|
27
|
-
// mock to get the headers fixed value
|
|
28
|
-
jest.mock('crypto', () => {
|
|
29
|
-
return {
|
|
30
|
-
randomBytes: (): { toString: () => string } => {
|
|
31
|
-
return {
|
|
32
|
-
toString: (): string => 'foo-random-bytes',
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
pseudoRandomBytes: (): { toString: () => string } => {
|
|
36
|
-
return {
|
|
37
|
-
toString: (): string => 'foo-phseudo-bytes',
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
|
|
43
28
|
const domain = 'https://registry.npmjs.org';
|
|
44
29
|
|
|
45
30
|
describe('proxy', () => {
|
|
46
31
|
beforeEach(() => {
|
|
47
32
|
nock.cleanAll();
|
|
48
33
|
});
|
|
34
|
+
|
|
49
35
|
const defaultRequestOptions = {
|
|
50
|
-
url:
|
|
36
|
+
url: domain,
|
|
51
37
|
};
|
|
52
38
|
const proxyPath = getConf('proxy1.yaml');
|
|
53
39
|
const conf = new Config(parseConfigFile(proxyPath));
|
|
40
|
+
conf.server_id = 'foo-phseudo-bytes';
|
|
54
41
|
|
|
55
42
|
describe('getRemoteMetadata', () => {
|
|
56
43
|
beforeEach(() => {
|
|
57
44
|
nock.cleanAll();
|
|
58
45
|
nock.abortPendingRequests();
|
|
59
|
-
|
|
46
|
+
vi.clearAllMocks();
|
|
60
47
|
});
|
|
61
48
|
describe('basic requests', () => {
|
|
62
49
|
test('success call to remote', async () => {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import getStream from 'get-stream';
|
|
5
5
|
import nock from 'nock';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
7
8
|
|
|
8
9
|
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
9
10
|
import { streamUtils } from '@verdaccio/core';
|
|
@@ -13,11 +14,11 @@ import { ProxyStorage } from '../src';
|
|
|
13
14
|
|
|
14
15
|
const getConf = (name) => path.join(__dirname, '/conf', name);
|
|
15
16
|
|
|
16
|
-
const mockDebug =
|
|
17
|
-
const mockInfo =
|
|
18
|
-
const mockHttp =
|
|
19
|
-
const mockError =
|
|
20
|
-
const mockWarn =
|
|
17
|
+
const mockDebug = vi.fn();
|
|
18
|
+
const mockInfo = vi.fn();
|
|
19
|
+
const mockHttp = vi.fn();
|
|
20
|
+
const mockError = vi.fn();
|
|
21
|
+
const mockWarn = vi.fn();
|
|
21
22
|
|
|
22
23
|
const logger = {
|
|
23
24
|
debug: mockDebug,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import nock from 'nock';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { beforeEach, describe, test, vi } from 'vitest';
|
|
3
4
|
|
|
4
5
|
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
5
6
|
import { logger, setup } from '@verdaccio/logger';
|
|
6
7
|
|
|
7
8
|
import { ProxyStorage } from '../src';
|
|
8
9
|
|
|
9
|
-
setup();
|
|
10
|
+
setup({});
|
|
10
11
|
|
|
11
12
|
const getConf = (name) => path.join(__dirname, '/conf', name);
|
|
12
13
|
|
|
13
14
|
// // mock to get the headers fixed value
|
|
14
|
-
|
|
15
|
+
vi.mock('crypto', () => {
|
|
15
16
|
return {
|
|
16
17
|
randomBytes: (): { toString: () => string } => {
|
|
17
18
|
return {
|
|
@@ -30,7 +31,7 @@ describe('tarball proxy', () => {
|
|
|
30
31
|
beforeEach(() => {
|
|
31
32
|
nock.cleanAll();
|
|
32
33
|
nock.abortPendingRequests();
|
|
33
|
-
|
|
34
|
+
vi.clearAllMocks();
|
|
34
35
|
});
|
|
35
36
|
const defaultRequestOptions = {
|
|
36
37
|
url: 'https://registry.verdaccio.org',
|
|
@@ -40,41 +41,44 @@ describe('tarball proxy', () => {
|
|
|
40
41
|
const conf = new Config(parseConfigFile(proxyPath));
|
|
41
42
|
|
|
42
43
|
describe('fetchTarball', () => {
|
|
43
|
-
test('get file tarball fetch', (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
test('get file tarball fetch', () =>
|
|
45
|
+
new Promise((done) => {
|
|
46
|
+
nock('https://registry.verdaccio.org')
|
|
47
|
+
.get('/jquery/-/jquery-0.0.1.tgz')
|
|
48
|
+
.replyWithFile(201, path.join(__dirname, 'partials/jquery-0.0.1.tgz'));
|
|
49
|
+
const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
|
|
50
|
+
const stream = prox1.fetchTarball(
|
|
51
|
+
'https://registry.verdaccio.org/jquery/-/jquery-0.0.1.tgz',
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
{}
|
|
54
|
+
);
|
|
55
|
+
stream.on('response', () => {
|
|
56
|
+
done(true);
|
|
57
|
+
});
|
|
58
|
+
stream.on('error', (err) => {
|
|
59
|
+
done(err);
|
|
60
|
+
});
|
|
61
|
+
}));
|
|
59
62
|
|
|
60
|
-
test.skip('get file tarball handle retries', (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
test.skip('get file tarball handle retries', () =>
|
|
64
|
+
new Promise((done) => {
|
|
65
|
+
nock('https://registry.verdaccio.org')
|
|
66
|
+
.get('/jquery/-/jquery-0.0.1.tgz')
|
|
67
|
+
.twice()
|
|
68
|
+
.reply(500, 'some-text')
|
|
69
|
+
.get('/jquery/-/jquery-0.0.1.tgz')
|
|
70
|
+
.once()
|
|
71
|
+
.replyWithFile(201, path.join(__dirname, 'partials/jquery-0.0.1.tgz'));
|
|
72
|
+
const prox1 = new ProxyStorage(defaultRequestOptions, conf);
|
|
73
|
+
const stream = prox1.fetchTarball(
|
|
74
|
+
'https://registry.verdaccio.org/jquery/-/jquery-0.0.1.tgz',
|
|
75
|
+
{ retry: { limit: 2 } }
|
|
76
|
+
);
|
|
77
|
+
stream.on('error', () => {
|
|
78
|
+
// FIXME: stream should have handle 2 retry
|
|
79
|
+
done();
|
|
80
|
+
});
|
|
81
|
+
}));
|
|
78
82
|
});
|
|
79
83
|
});
|
|
80
84
|
// test('get file tarball correct content-length', (done) => {
|