@verdaccio/api 8.1.0-next-8.12 → 8.1.0-next-8.13
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/README.md +17 -10
- package/package.json +16 -12
- package/.babelrc +0 -3
- package/.eslintrc +0 -5
- package/CHANGELOG.md +0 -2152
- package/src/dist-tags.ts +0 -106
- package/src/index.ts +0 -65
- package/src/package.ts +0 -117
- package/src/ping.ts +0 -14
- package/src/publish.ts +0 -262
- package/src/search.ts +0 -12
- package/src/stars.ts +0 -37
- package/src/user.ts +0 -179
- package/src/v1/profile.ts +0 -113
- package/src/v1/search.ts +0 -85
- package/src/v1/token.ts +0 -157
- package/src/whoami.ts +0 -26
- package/test/.eslintrc +0 -8
- package/test/integration/_helper.ts +0 -198
- package/test/integration/config/distTag.yaml +0 -25
- package/test/integration/config/owner.yaml +0 -24
- package/test/integration/config/package.yaml +0 -25
- package/test/integration/config/ping.yaml +0 -26
- package/test/integration/config/profile.yaml +0 -27
- package/test/integration/config/publish-proxy.yaml +0 -26
- package/test/integration/config/publish.yaml +0 -24
- package/test/integration/config/search.yaml +0 -29
- package/test/integration/config/star.yaml +0 -26
- package/test/integration/config/token.jwt.yaml +0 -27
- package/test/integration/config/token.yaml +0 -19
- package/test/integration/config/user.jwt.yaml +0 -37
- package/test/integration/config/user.yaml +0 -30
- package/test/integration/config/whoami.yaml +0 -29
- package/test/integration/distTag.spec.ts +0 -80
- package/test/integration/owner.spec.ts +0 -119
- package/test/integration/package.spec.ts +0 -107
- package/test/integration/ping.spec.ts +0 -18
- package/test/integration/profile.spec.ts +0 -112
- package/test/integration/publish.spec.ts +0 -232
- package/test/integration/search.spec.ts +0 -139
- package/test/integration/star.spec.ts +0 -74
- package/test/integration/token.spec.ts +0 -125
- package/test/integration/user.spec.ts +0 -222
- package/test/integration/whoami.spec.ts +0 -36
- package/test/unit/publish.disabled.ts +0 -252
- package/test/unit/validate.api.params.middleware.spec.ts +0 -44
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -41
- package/types/custom.d.ts +0 -16
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { Application } from 'express';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import supertest from 'supertest';
|
|
5
|
-
import { expect } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { parseConfigFile } from '@verdaccio/config';
|
|
8
|
-
import { HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '@verdaccio/core';
|
|
9
|
-
import { setup } from '@verdaccio/logger';
|
|
10
|
-
import { Storage } from '@verdaccio/store';
|
|
11
|
-
import {
|
|
12
|
-
generatePackageMetadata,
|
|
13
|
-
initializeServer as initializeServerHelper,
|
|
14
|
-
} from '@verdaccio/test-helper';
|
|
15
|
-
import { Author, GenericBody, PackageUsers } from '@verdaccio/types';
|
|
16
|
-
import { buildToken, generateRandomHexString } from '@verdaccio/utils';
|
|
17
|
-
|
|
18
|
-
import apiMiddleware from '../../src';
|
|
19
|
-
|
|
20
|
-
setup({});
|
|
21
|
-
|
|
22
|
-
export const getConf = (conf) => {
|
|
23
|
-
const configPath = path.join(__dirname, 'config', conf);
|
|
24
|
-
const config = parseConfigFile(configPath);
|
|
25
|
-
// custom config to avoid conflict with other tests
|
|
26
|
-
config.auth.htpasswd.file = `${config.auth.htpasswd.file}-${generateRandomHexString()}`;
|
|
27
|
-
return config;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export async function initializeServer(configName): Promise<Application> {
|
|
31
|
-
const config = getConf(configName);
|
|
32
|
-
return initializeServerHelper(config, [apiMiddleware], Storage);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createUser(app, name: string, password: string): supertest.Test {
|
|
36
|
-
return supertest(app)
|
|
37
|
-
.put(`/-/user/org.couchdb.user:${name}`)
|
|
38
|
-
.send({
|
|
39
|
-
name: name,
|
|
40
|
-
password: password,
|
|
41
|
-
})
|
|
42
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
43
|
-
.expect(HEADERS.CACHE_CONTROL, 'no-cache, no-store')
|
|
44
|
-
.expect(HTTP_STATUS.CREATED);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export async function getNewToken(app: any, credentials: any): Promise<string> {
|
|
48
|
-
const response = await createUser(app, credentials.name, credentials.password);
|
|
49
|
-
const { token, ok } = response.body;
|
|
50
|
-
expect(ok).toBeDefined();
|
|
51
|
-
expect(token).toBeDefined();
|
|
52
|
-
expect(typeof token).toBe('string');
|
|
53
|
-
return token;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export async function generateTokenCLI(app, token, payload): Promise<any> {
|
|
57
|
-
return supertest(app)
|
|
58
|
-
.post('/-/npm/v1/tokens')
|
|
59
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
60
|
-
.send(JSON.stringify(payload))
|
|
61
|
-
.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token))
|
|
62
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export async function deleteTokenCLI(app, token, tokenToDelete): Promise<any> {
|
|
66
|
-
return supertest(app)
|
|
67
|
-
.delete(`/-/npm/v1/tokens/token/${tokenToDelete}`)
|
|
68
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
69
|
-
.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token))
|
|
70
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
71
|
-
.expect(HTTP_STATUS.OK);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function publishVersionWithToken(
|
|
75
|
-
app,
|
|
76
|
-
pkgName: string,
|
|
77
|
-
version: string,
|
|
78
|
-
token: string,
|
|
79
|
-
distTags?: GenericBody
|
|
80
|
-
): supertest.Test {
|
|
81
|
-
const pkgMetadata = generatePackageMetadata(pkgName, version, distTags);
|
|
82
|
-
|
|
83
|
-
return supertest(app)
|
|
84
|
-
.put(`/${encodeURIComponent(pkgName)}`)
|
|
85
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
86
|
-
.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token))
|
|
87
|
-
.send(JSON.stringify(pkgMetadata))
|
|
88
|
-
.set('accept', HEADERS.GZIP)
|
|
89
|
-
.set(HEADER_TYPE.ACCEPT_ENCODING, HEADERS.JSON);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function publishVersion(
|
|
93
|
-
app,
|
|
94
|
-
pkgName: string,
|
|
95
|
-
version: string,
|
|
96
|
-
distTags?: GenericBody,
|
|
97
|
-
token?: string
|
|
98
|
-
): supertest.Test {
|
|
99
|
-
const pkgMetadata = generatePackageMetadata(pkgName, version, distTags);
|
|
100
|
-
|
|
101
|
-
const test = supertest(app)
|
|
102
|
-
.put(`/${encodeURIComponent(pkgName)}`)
|
|
103
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
104
|
-
.send(JSON.stringify(pkgMetadata))
|
|
105
|
-
.set('accept', HEADERS.GZIP)
|
|
106
|
-
.set(HEADER_TYPE.ACCEPT_ENCODING, HEADERS.JSON);
|
|
107
|
-
|
|
108
|
-
if (typeof token === 'string') {
|
|
109
|
-
test.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return test;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function starPackage(
|
|
116
|
-
app,
|
|
117
|
-
options: {
|
|
118
|
-
users: PackageUsers;
|
|
119
|
-
name: string;
|
|
120
|
-
_rev: string;
|
|
121
|
-
_id?: string;
|
|
122
|
-
},
|
|
123
|
-
token?: string
|
|
124
|
-
): supertest.Test {
|
|
125
|
-
const { _rev, _id, users } = options;
|
|
126
|
-
const starManifest = {
|
|
127
|
-
_rev,
|
|
128
|
-
_id,
|
|
129
|
-
users,
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const test = supertest(app)
|
|
133
|
-
.put(`/${encodeURIComponent(options.name)}`)
|
|
134
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
135
|
-
.send(JSON.stringify(starManifest))
|
|
136
|
-
.set('accept', HEADERS.GZIP)
|
|
137
|
-
.set(HEADER_TYPE.ACCEPT_ENCODING, HEADERS.JSON);
|
|
138
|
-
|
|
139
|
-
if (typeof token === 'string') {
|
|
140
|
-
test.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return test;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function changeOwners(
|
|
147
|
-
app,
|
|
148
|
-
options: {
|
|
149
|
-
maintainers: Author[];
|
|
150
|
-
name: string;
|
|
151
|
-
_rev: string;
|
|
152
|
-
_id?: string;
|
|
153
|
-
},
|
|
154
|
-
token?: string
|
|
155
|
-
): supertest.Test {
|
|
156
|
-
const { _rev, _id, maintainers } = options;
|
|
157
|
-
const ownerManifest = {
|
|
158
|
-
_rev,
|
|
159
|
-
_id,
|
|
160
|
-
maintainers,
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const test = supertest(app)
|
|
164
|
-
.put(`/${encodeURIComponent(options.name)}`)
|
|
165
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
166
|
-
.send(JSON.stringify(ownerManifest))
|
|
167
|
-
.set('accept', HEADERS.GZIP)
|
|
168
|
-
.set(HEADER_TYPE.ACCEPT_ENCODING, HEADERS.JSON);
|
|
169
|
-
|
|
170
|
-
if (typeof token === 'string') {
|
|
171
|
-
test.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return test;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export function getDisTags(app, pkgName) {
|
|
178
|
-
return supertest(app)
|
|
179
|
-
.get(`/-/package/${encodeURIComponent(pkgName)}/dist-tags`)
|
|
180
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
181
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
182
|
-
.expect(HTTP_STATUS.OK);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function getPackage(
|
|
186
|
-
app: any,
|
|
187
|
-
token: string,
|
|
188
|
-
pkgName: string,
|
|
189
|
-
statusCode: number = HTTP_STATUS.OK
|
|
190
|
-
): supertest.Test {
|
|
191
|
-
const test = supertest(app).get(`/${pkgName}`);
|
|
192
|
-
|
|
193
|
-
if (_.isNil(token) === false || _.isEmpty(token) === false) {
|
|
194
|
-
test.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return test.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET).expect(statusCode);
|
|
198
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
storage: ./storage
|
|
2
|
-
|
|
3
|
-
auth:
|
|
4
|
-
htpasswd:
|
|
5
|
-
file: ./htpasswd-distTag
|
|
6
|
-
|
|
7
|
-
web:
|
|
8
|
-
enable: true
|
|
9
|
-
title: verdaccio
|
|
10
|
-
|
|
11
|
-
publish:
|
|
12
|
-
allow_offline: false
|
|
13
|
-
|
|
14
|
-
uplinks:
|
|
15
|
-
|
|
16
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
17
|
-
|
|
18
|
-
packages:
|
|
19
|
-
'@*/*':
|
|
20
|
-
access: $anonymous
|
|
21
|
-
publish: $anonymous
|
|
22
|
-
'**':
|
|
23
|
-
access: $anonymous
|
|
24
|
-
publish: $anonymous
|
|
25
|
-
_debug: true
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
storage: ./storage
|
|
2
|
-
|
|
3
|
-
auth:
|
|
4
|
-
htpasswd:
|
|
5
|
-
file: ./htpasswd-owner
|
|
6
|
-
|
|
7
|
-
web:
|
|
8
|
-
enable: true
|
|
9
|
-
title: verdaccio
|
|
10
|
-
|
|
11
|
-
log: { type: stdout, format: pretty, level: info }
|
|
12
|
-
|
|
13
|
-
# TODO: Add test case for $owner access
|
|
14
|
-
packages:
|
|
15
|
-
'@*/*':
|
|
16
|
-
access: $all
|
|
17
|
-
publish: $authenticated
|
|
18
|
-
unpublish: $authenticated
|
|
19
|
-
'**':
|
|
20
|
-
access: $all
|
|
21
|
-
publish: $authenticated
|
|
22
|
-
unpublish: $authenticated
|
|
23
|
-
|
|
24
|
-
_debug: true
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
storage: ./storage
|
|
2
|
-
|
|
3
|
-
auth:
|
|
4
|
-
htpasswd:
|
|
5
|
-
file: ./htpasswd-package
|
|
6
|
-
|
|
7
|
-
web:
|
|
8
|
-
enable: true
|
|
9
|
-
title: verdaccio
|
|
10
|
-
|
|
11
|
-
publish:
|
|
12
|
-
allow_offline: false
|
|
13
|
-
|
|
14
|
-
uplinks:
|
|
15
|
-
|
|
16
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
17
|
-
|
|
18
|
-
packages:
|
|
19
|
-
'@*/*':
|
|
20
|
-
access: $anonymous
|
|
21
|
-
publish: $anonymous
|
|
22
|
-
'**':
|
|
23
|
-
access: $anonymous
|
|
24
|
-
publish: $anonymous
|
|
25
|
-
_debug: true
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
auth:
|
|
2
|
-
htpasswd:
|
|
3
|
-
file: ./htpasswd-ping
|
|
4
|
-
web:
|
|
5
|
-
enable: true
|
|
6
|
-
title: verdaccio
|
|
7
|
-
|
|
8
|
-
uplinks:
|
|
9
|
-
|
|
10
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
11
|
-
|
|
12
|
-
packages:
|
|
13
|
-
'@*/*':
|
|
14
|
-
access: $all
|
|
15
|
-
publish: $all
|
|
16
|
-
unpublish: $all
|
|
17
|
-
proxy: npmjs
|
|
18
|
-
'verdaccio':
|
|
19
|
-
access: $all
|
|
20
|
-
publish: $all
|
|
21
|
-
'**':
|
|
22
|
-
access: $all
|
|
23
|
-
publish: $all
|
|
24
|
-
unpublish: $all
|
|
25
|
-
proxy: npmjs
|
|
26
|
-
_debug: true
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
auth:
|
|
2
|
-
htpasswd:
|
|
3
|
-
file: ./htpasswd-profile
|
|
4
|
-
web:
|
|
5
|
-
enable: true
|
|
6
|
-
title: verdaccio
|
|
7
|
-
|
|
8
|
-
uplinks:
|
|
9
|
-
|
|
10
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
11
|
-
|
|
12
|
-
packages:
|
|
13
|
-
'@*/*':
|
|
14
|
-
access: $all
|
|
15
|
-
publish: $all
|
|
16
|
-
unpublish: $all
|
|
17
|
-
proxy: npmjs
|
|
18
|
-
'verdaccio':
|
|
19
|
-
access: $all
|
|
20
|
-
publish: $all
|
|
21
|
-
'**':
|
|
22
|
-
access: $all
|
|
23
|
-
publish: $all
|
|
24
|
-
unpublish: $all
|
|
25
|
-
proxy: npmjs
|
|
26
|
-
|
|
27
|
-
_debug: true
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
auth:
|
|
2
|
-
htpasswd:
|
|
3
|
-
file: ./htpasswd-publish-proxy
|
|
4
|
-
web:
|
|
5
|
-
enable: true
|
|
6
|
-
title: verdaccio
|
|
7
|
-
|
|
8
|
-
uplinks:
|
|
9
|
-
npmjs:
|
|
10
|
-
url: https://registry.npmjs.org/
|
|
11
|
-
|
|
12
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
13
|
-
|
|
14
|
-
packages:
|
|
15
|
-
'@*/*':
|
|
16
|
-
access: $all
|
|
17
|
-
publish: $anonymous
|
|
18
|
-
unpublish: $anonymous
|
|
19
|
-
proxy: npmjs
|
|
20
|
-
'**':
|
|
21
|
-
access: $all
|
|
22
|
-
publish: $anonymous
|
|
23
|
-
unpublish: $anonymous
|
|
24
|
-
proxy: npmjs
|
|
25
|
-
|
|
26
|
-
_debug: true
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
auth:
|
|
2
|
-
htpasswd:
|
|
3
|
-
file: ./htpasswd-publish
|
|
4
|
-
web:
|
|
5
|
-
enable: true
|
|
6
|
-
title: verdaccio
|
|
7
|
-
|
|
8
|
-
publish:
|
|
9
|
-
allow_offline: false
|
|
10
|
-
|
|
11
|
-
uplinks:
|
|
12
|
-
|
|
13
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
14
|
-
|
|
15
|
-
packages:
|
|
16
|
-
'@*/*':
|
|
17
|
-
access: $anonymous
|
|
18
|
-
publish: $anonymous
|
|
19
|
-
unpublish: $anonymous
|
|
20
|
-
'**':
|
|
21
|
-
access: $anonymous
|
|
22
|
-
publish: $anonymous
|
|
23
|
-
unpublish: $anonymous
|
|
24
|
-
_debug: true
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
storage: ./storage
|
|
2
|
-
|
|
3
|
-
auth:
|
|
4
|
-
htpasswd:
|
|
5
|
-
file: ./htpasswd-search
|
|
6
|
-
|
|
7
|
-
web:
|
|
8
|
-
enable: true
|
|
9
|
-
title: verdaccio
|
|
10
|
-
|
|
11
|
-
uplinks:
|
|
12
|
-
|
|
13
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
14
|
-
|
|
15
|
-
packages:
|
|
16
|
-
'private-*':
|
|
17
|
-
access: $all
|
|
18
|
-
publish: jota
|
|
19
|
-
'@private/*':
|
|
20
|
-
access: $all
|
|
21
|
-
publish: jota
|
|
22
|
-
'@*/*':
|
|
23
|
-
access: $all
|
|
24
|
-
publish: $authenticated
|
|
25
|
-
'**':
|
|
26
|
-
access: $all
|
|
27
|
-
publish: $authenticated
|
|
28
|
-
|
|
29
|
-
_debug: true
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
auth:
|
|
2
|
-
htpasswd:
|
|
3
|
-
file: ./htpasswd-star
|
|
4
|
-
web:
|
|
5
|
-
enable: true
|
|
6
|
-
title: verdaccio
|
|
7
|
-
|
|
8
|
-
uplinks:
|
|
9
|
-
npmjs:
|
|
10
|
-
url: https://registry.npmjs.org/
|
|
11
|
-
|
|
12
|
-
log: { type: stdout, format: pretty, level: info }
|
|
13
|
-
|
|
14
|
-
packages:
|
|
15
|
-
'@*/*':
|
|
16
|
-
access: $all
|
|
17
|
-
publish: $authenticated
|
|
18
|
-
unpublish: $authenticated
|
|
19
|
-
proxy: npmjs
|
|
20
|
-
'**':
|
|
21
|
-
access: $all
|
|
22
|
-
publish: $authenticated
|
|
23
|
-
unpublish: $authenticated
|
|
24
|
-
proxy: npmjs
|
|
25
|
-
|
|
26
|
-
_debug: true
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
security:
|
|
2
|
-
api:
|
|
3
|
-
jwt:
|
|
4
|
-
sign:
|
|
5
|
-
expiresIn: 5m
|
|
6
|
-
# to avoid invalid verification token, more info on JWT page
|
|
7
|
-
notBefore: 0
|
|
8
|
-
|
|
9
|
-
storage: ./storage
|
|
10
|
-
|
|
11
|
-
auth:
|
|
12
|
-
htpasswd:
|
|
13
|
-
file: ./htpasswd
|
|
14
|
-
|
|
15
|
-
packages:
|
|
16
|
-
'@token/*':
|
|
17
|
-
access: $authenticated
|
|
18
|
-
publish: $authenticated
|
|
19
|
-
'only-you-can-publish':
|
|
20
|
-
access: $authenticated
|
|
21
|
-
publish: $authenticated
|
|
22
|
-
|
|
23
|
-
log: { type: stdout, format: pretty, level: debug }
|
|
24
|
-
|
|
25
|
-
## enable token for testing
|
|
26
|
-
flags:
|
|
27
|
-
token: true
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
storage: ./storage
|
|
2
|
-
|
|
3
|
-
auth:
|
|
4
|
-
htpasswd:
|
|
5
|
-
file: ./htpasswd
|
|
6
|
-
|
|
7
|
-
packages:
|
|
8
|
-
'@token/*':
|
|
9
|
-
access: $authenticated
|
|
10
|
-
publish: $authenticated
|
|
11
|
-
'only-you-can-publish':
|
|
12
|
-
access: $authenticated
|
|
13
|
-
publish: $authenticated
|
|
14
|
-
|
|
15
|
-
log: { type: stdout, format: pretty, level: debug }
|
|
16
|
-
|
|
17
|
-
## enable token for testing
|
|
18
|
-
flags:
|
|
19
|
-
token: true
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
storage: ./storage
|
|
2
|
-
plugins: ./plugins
|
|
3
|
-
|
|
4
|
-
web:
|
|
5
|
-
title: Verdaccio
|
|
6
|
-
|
|
7
|
-
auth:
|
|
8
|
-
htpasswd:
|
|
9
|
-
file: ./htpasswd
|
|
10
|
-
|
|
11
|
-
uplinks:
|
|
12
|
-
ver:
|
|
13
|
-
url: https://registry.npmjs.org
|
|
14
|
-
|
|
15
|
-
security:
|
|
16
|
-
api:
|
|
17
|
-
jwt:
|
|
18
|
-
sign:
|
|
19
|
-
expiresIn: 10m
|
|
20
|
-
notBefore: 0
|
|
21
|
-
packages:
|
|
22
|
-
'@*/*':
|
|
23
|
-
access: $all
|
|
24
|
-
publish: $authenticated
|
|
25
|
-
'vue':
|
|
26
|
-
access: $authenticated
|
|
27
|
-
publish: $authenticated
|
|
28
|
-
proxy: ver
|
|
29
|
-
'**':
|
|
30
|
-
access: $all
|
|
31
|
-
publish: $authenticated
|
|
32
|
-
|
|
33
|
-
middlewares:
|
|
34
|
-
audit:
|
|
35
|
-
enabled: true
|
|
36
|
-
|
|
37
|
-
log: { type: stdout, format: pretty, level: info }
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
auth:
|
|
2
|
-
htpasswd:
|
|
3
|
-
file: ./htpasswd-user
|
|
4
|
-
web:
|
|
5
|
-
enable: true
|
|
6
|
-
title: verdaccio
|
|
7
|
-
|
|
8
|
-
uplinks:
|
|
9
|
-
ver:
|
|
10
|
-
url: https://registry.npmjs.org
|
|
11
|
-
|
|
12
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
13
|
-
|
|
14
|
-
packages:
|
|
15
|
-
'@*/*':
|
|
16
|
-
access: $all
|
|
17
|
-
publish: $all
|
|
18
|
-
unpublish: $all
|
|
19
|
-
'verdaccio':
|
|
20
|
-
access: $all
|
|
21
|
-
publish: $all
|
|
22
|
-
'vue':
|
|
23
|
-
access: $authenticated
|
|
24
|
-
publish: $authenticated
|
|
25
|
-
proxy: ver
|
|
26
|
-
'**':
|
|
27
|
-
access: $all
|
|
28
|
-
publish: $all
|
|
29
|
-
unpublish: $all
|
|
30
|
-
_debug: true
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
web:
|
|
2
|
-
enable: true
|
|
3
|
-
title: verdaccio
|
|
4
|
-
|
|
5
|
-
uplinks:
|
|
6
|
-
npmjs:
|
|
7
|
-
url: https://registry.npmjs.org/
|
|
8
|
-
|
|
9
|
-
log: { type: stdout, format: pretty, level: trace }
|
|
10
|
-
|
|
11
|
-
auth:
|
|
12
|
-
htpasswd:
|
|
13
|
-
file: ./htpasswd-whoami
|
|
14
|
-
|
|
15
|
-
packages:
|
|
16
|
-
'@*/*':
|
|
17
|
-
access: $all
|
|
18
|
-
publish: $all
|
|
19
|
-
unpublish: $all
|
|
20
|
-
proxy: npmjs
|
|
21
|
-
'verdaccio':
|
|
22
|
-
access: $all
|
|
23
|
-
publish: $all
|
|
24
|
-
'**':
|
|
25
|
-
access: $all
|
|
26
|
-
publish: $all
|
|
27
|
-
unpublish: $all
|
|
28
|
-
proxy: npmjs
|
|
29
|
-
_debug: true
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import supertest from 'supertest';
|
|
2
|
-
import { beforeEach, describe, expect, test } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { API_MESSAGE, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
5
|
-
import { setup } from '@verdaccio/logger';
|
|
6
|
-
|
|
7
|
-
import { getDisTags, initializeServer, publishVersion } from './_helper';
|
|
8
|
-
|
|
9
|
-
setup({});
|
|
10
|
-
|
|
11
|
-
describe('package', () => {
|
|
12
|
-
let app;
|
|
13
|
-
beforeEach(async () => {
|
|
14
|
-
app = await initializeServer('distTag.yaml');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test.each([['foo'], ['@scope/foo']])('should display dist-tag (npm dist-tag ls)', async (pkg) => {
|
|
18
|
-
await publishVersion(app, pkg, '1.0.0');
|
|
19
|
-
await publishVersion(app, pkg, '1.0.1');
|
|
20
|
-
const response = await getDisTags(app, pkg);
|
|
21
|
-
expect(response.body).toEqual({ latest: '1.0.1' });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('should add a version to a tag (npm dist-tag add)', async () => {
|
|
25
|
-
await publishVersion(app, encodeURIComponent('foo'), '1.0.0');
|
|
26
|
-
await publishVersion(app, encodeURIComponent('foo'), '1.0.1');
|
|
27
|
-
|
|
28
|
-
const response = await supertest(app)
|
|
29
|
-
.put(`/${encodeURIComponent('foo')}/test`)
|
|
30
|
-
.set(HEADERS.ACCEPT, HEADERS.GZIP)
|
|
31
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
32
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
33
|
-
.send(JSON.stringify('1.0.1'))
|
|
34
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
35
|
-
.expect(HTTP_STATUS.CREATED);
|
|
36
|
-
expect(response.body.ok).toEqual(API_MESSAGE.TAG_ADDED);
|
|
37
|
-
const response2 = await getDisTags(app, 'foo');
|
|
38
|
-
expect(response2.body).toEqual({ latest: '1.0.1', test: '1.0.1' });
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('should fails if a version is missing (npm dist-tag add)', async () => {
|
|
42
|
-
await publishVersion(app, encodeURIComponent('foo'), '1.0.0');
|
|
43
|
-
await publishVersion(app, encodeURIComponent('foo'), '1.0.1');
|
|
44
|
-
|
|
45
|
-
await supertest(app)
|
|
46
|
-
.put(`/${encodeURIComponent('foo')}/test`)
|
|
47
|
-
.set(HEADERS.ACCEPT, HEADERS.GZIP)
|
|
48
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
49
|
-
.send(JSON.stringify({}))
|
|
50
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
51
|
-
.expect(HTTP_STATUS.BAD_REQUEST);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('should delete a previous added tag (npm dist-tag rm)', async () => {
|
|
55
|
-
await publishVersion(app, encodeURIComponent('foo'), '1.0.0');
|
|
56
|
-
await publishVersion(app, encodeURIComponent('foo'), '1.0.1');
|
|
57
|
-
|
|
58
|
-
const response = await supertest(app)
|
|
59
|
-
.put(`/${encodeURIComponent('foo')}/beta`)
|
|
60
|
-
.set(HEADERS.ACCEPT, HEADERS.GZIP)
|
|
61
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
62
|
-
.send(JSON.stringify('1.0.1'))
|
|
63
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
64
|
-
.expect(HTTP_STATUS.CREATED);
|
|
65
|
-
expect(response.body.ok).toEqual(API_MESSAGE.TAG_ADDED);
|
|
66
|
-
|
|
67
|
-
const response2 = await getDisTags(app, 'foo');
|
|
68
|
-
expect(response2.body).toEqual({ latest: '1.0.1', beta: '1.0.1' });
|
|
69
|
-
|
|
70
|
-
const response3 = await supertest(app)
|
|
71
|
-
.delete(`/-/package/${encodeURIComponent('foo')}/dist-tags/beta`)
|
|
72
|
-
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
73
|
-
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
74
|
-
.expect(HTTP_STATUS.CREATED);
|
|
75
|
-
expect(response3.body.ok).toEqual(API_MESSAGE.TAG_REMOVED);
|
|
76
|
-
|
|
77
|
-
const response4 = await getDisTags(app, 'foo');
|
|
78
|
-
expect(response4.body).toEqual({ latest: '1.0.1' });
|
|
79
|
-
});
|
|
80
|
-
});
|