@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,252 +0,0 @@
|
|
|
1
|
-
// import { API_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';
|
|
2
|
-
|
|
3
|
-
// import { addVersion, publishPackage, removeTarball, unPublishPackage } from '../../src/publish';
|
|
4
|
-
|
|
5
|
-
// const REVISION_MOCK = '15-e53a77096b0ee33e';
|
|
6
|
-
|
|
7
|
-
// require('@verdaccio/logger').setup([{ type: 'stdout', format: 'pretty', level: 'info' }]);
|
|
8
|
-
|
|
9
|
-
// describe('Publish endpoints - add a tag', () => {
|
|
10
|
-
// let req;
|
|
11
|
-
// let res;
|
|
12
|
-
// let next;
|
|
13
|
-
|
|
14
|
-
// beforeEach(() => {
|
|
15
|
-
// req = {
|
|
16
|
-
// params: {
|
|
17
|
-
// version: '1.0.0',
|
|
18
|
-
// tag: 'tag',
|
|
19
|
-
// package: 'verdaccio',
|
|
20
|
-
// },
|
|
21
|
-
// body: '',
|
|
22
|
-
// };
|
|
23
|
-
// res = {
|
|
24
|
-
// status: jest.fn(),
|
|
25
|
-
// };
|
|
26
|
-
|
|
27
|
-
// next = jest.fn();
|
|
28
|
-
// });
|
|
29
|
-
|
|
30
|
-
// test('should add a version', (done) => {
|
|
31
|
-
// const storage = {
|
|
32
|
-
// addVersion: (packageName, version, body, tag, cb) => {
|
|
33
|
-
// expect(packageName).toEqual(req.params.package);
|
|
34
|
-
// expect(version).toEqual(req.params.version);
|
|
35
|
-
// expect(body).toEqual(req.body);
|
|
36
|
-
// expect(tag).toEqual(req.params.tag);
|
|
37
|
-
// cb();
|
|
38
|
-
// done();
|
|
39
|
-
// },
|
|
40
|
-
// };
|
|
41
|
-
|
|
42
|
-
// // @ts-ignore
|
|
43
|
-
// addVersion(storage)(req, res, next);
|
|
44
|
-
|
|
45
|
-
// expect(res.status).toHaveBeenLastCalledWith(HTTP_STATUS.CREATED);
|
|
46
|
-
// expect(next).toHaveBeenLastCalledWith({ ok: 'package published' });
|
|
47
|
-
// });
|
|
48
|
-
|
|
49
|
-
// test('when failed to add a version', (done) => {
|
|
50
|
-
// const storage = {
|
|
51
|
-
// addVersion: (packageName, version, body, tag, cb) => {
|
|
52
|
-
// const error = {
|
|
53
|
-
// message: 'failure',
|
|
54
|
-
// };
|
|
55
|
-
// cb(error);
|
|
56
|
-
// done();
|
|
57
|
-
// },
|
|
58
|
-
// };
|
|
59
|
-
|
|
60
|
-
// // @ts-ignore
|
|
61
|
-
// addVersion(storage)(req, res, next);
|
|
62
|
-
|
|
63
|
-
// expect(next).toHaveBeenLastCalledWith({ message: 'failure' });
|
|
64
|
-
// });
|
|
65
|
-
// });
|
|
66
|
-
|
|
67
|
-
// /**
|
|
68
|
-
// * Delete tarball: '/:package/-/:filename/-rev/:revision'
|
|
69
|
-
// */
|
|
70
|
-
// describe('Publish endpoints - delete tarball', () => {
|
|
71
|
-
// let req;
|
|
72
|
-
// let res;
|
|
73
|
-
// let next;
|
|
74
|
-
|
|
75
|
-
// beforeEach(() => {
|
|
76
|
-
// req = {
|
|
77
|
-
// params: {
|
|
78
|
-
// filename: 'verdaccio.gzip',
|
|
79
|
-
// package: 'verdaccio',
|
|
80
|
-
// revision: REVISION_MOCK,
|
|
81
|
-
// },
|
|
82
|
-
// };
|
|
83
|
-
// res = { status: jest.fn() };
|
|
84
|
-
// next = jest.fn();
|
|
85
|
-
// });
|
|
86
|
-
|
|
87
|
-
// test('should delete tarball successfully', (done) => {
|
|
88
|
-
// const storage = {
|
|
89
|
-
// removeTarball(packageName, filename, revision, cb) {
|
|
90
|
-
// expect(packageName).toEqual(req.params.package);
|
|
91
|
-
// expect(filename).toEqual(req.params.filename);
|
|
92
|
-
// expect(revision).toEqual(req.params.revision);
|
|
93
|
-
// cb();
|
|
94
|
-
// done();
|
|
95
|
-
// },
|
|
96
|
-
// };
|
|
97
|
-
|
|
98
|
-
// // @ts-ignore
|
|
99
|
-
// removeTarball(storage)(req, res, next);
|
|
100
|
-
// expect(res.status).toHaveBeenCalledWith(HTTP_STATUS.CREATED);
|
|
101
|
-
// expect(next).toHaveBeenCalledWith({ ok: 'tarball removed' });
|
|
102
|
-
// });
|
|
103
|
-
|
|
104
|
-
// test('failed while deleting the tarball', (done) => {
|
|
105
|
-
// const error = {
|
|
106
|
-
// message: 'deletion failed',
|
|
107
|
-
// };
|
|
108
|
-
// const storage = {
|
|
109
|
-
// removeTarball(packageName, filename, revision, cb) {
|
|
110
|
-
// cb(error);
|
|
111
|
-
// done();
|
|
112
|
-
// },
|
|
113
|
-
// };
|
|
114
|
-
|
|
115
|
-
// // @ts-ignore
|
|
116
|
-
// removeTarball(storage)(req, res, next);
|
|
117
|
-
// expect(next).toHaveBeenCalledWith(error);
|
|
118
|
-
// });
|
|
119
|
-
// });
|
|
120
|
-
|
|
121
|
-
// /**
|
|
122
|
-
// * Un-publish package: '/:package/-rev/*'
|
|
123
|
-
// */
|
|
124
|
-
// describe('Publish endpoints - un-publish package', () => {
|
|
125
|
-
// let req;
|
|
126
|
-
// let res;
|
|
127
|
-
// let next;
|
|
128
|
-
|
|
129
|
-
// beforeEach(() => {
|
|
130
|
-
// req = {
|
|
131
|
-
// params: {
|
|
132
|
-
// package: 'verdaccio',
|
|
133
|
-
// },
|
|
134
|
-
// };
|
|
135
|
-
// res = { status: jest.fn() };
|
|
136
|
-
// next = jest.fn();
|
|
137
|
-
// });
|
|
138
|
-
|
|
139
|
-
// test('should un-publish package successfully', async () => {
|
|
140
|
-
// const storage = {
|
|
141
|
-
// removePackage(packageName) {
|
|
142
|
-
// expect(packageName).toEqual(req.params.package);
|
|
143
|
-
// return Promise.resolve();
|
|
144
|
-
// },
|
|
145
|
-
// };
|
|
146
|
-
|
|
147
|
-
// // @ts-ignore
|
|
148
|
-
// await unPublishPackage(storage)(req, res, next);
|
|
149
|
-
// expect(res.status).toHaveBeenCalledWith(HTTP_STATUS.CREATED);
|
|
150
|
-
// expect(next).toHaveBeenCalledWith({ ok: 'package removed' });
|
|
151
|
-
// });
|
|
152
|
-
|
|
153
|
-
// test('un-publish failed', async () => {
|
|
154
|
-
// const storage = {
|
|
155
|
-
// removePackage(packageName) {
|
|
156
|
-
// expect(packageName).toEqual(req.params.package);
|
|
157
|
-
// return Promise.reject(errorUtils.getInternalError());
|
|
158
|
-
// },
|
|
159
|
-
// };
|
|
160
|
-
|
|
161
|
-
// // @ts-ignore
|
|
162
|
-
// await unPublishPackage(storage)(req, res, next);
|
|
163
|
-
// expect(next).toHaveBeenCalledWith(errorUtils.getInternalError());
|
|
164
|
-
// });
|
|
165
|
-
// });
|
|
166
|
-
|
|
167
|
-
// /**
|
|
168
|
-
// * Publish package: '/:package/:_rev?/:revision?'
|
|
169
|
-
// */
|
|
170
|
-
// describe('Publish endpoints - publish package', () => {
|
|
171
|
-
// let req;
|
|
172
|
-
// let res;
|
|
173
|
-
// let next;
|
|
174
|
-
|
|
175
|
-
// beforeEach(() => {
|
|
176
|
-
// req = {
|
|
177
|
-
// body: {
|
|
178
|
-
// name: 'verdaccio',
|
|
179
|
-
// },
|
|
180
|
-
// params: {
|
|
181
|
-
// package: 'verdaccio',
|
|
182
|
-
// },
|
|
183
|
-
// };
|
|
184
|
-
// res = { status: jest.fn() };
|
|
185
|
-
// next = jest.fn();
|
|
186
|
-
// });
|
|
187
|
-
|
|
188
|
-
// test('should change the existing package', () => {
|
|
189
|
-
// const storage = {
|
|
190
|
-
// changePackage: jest.fn(),
|
|
191
|
-
// };
|
|
192
|
-
|
|
193
|
-
// req.params._rev = REVISION_MOCK;
|
|
194
|
-
|
|
195
|
-
// // @ts-ignore
|
|
196
|
-
// publishPackage(storage)(req, res, next);
|
|
197
|
-
// expect(storage.changePackage).toMatchSnapshot();
|
|
198
|
-
// });
|
|
199
|
-
|
|
200
|
-
// test('should publish a new a new package', () => {
|
|
201
|
-
// const storage = {
|
|
202
|
-
// addPackage: jest.fn(),
|
|
203
|
-
// };
|
|
204
|
-
|
|
205
|
-
// // @ts-ignore
|
|
206
|
-
// publishPackage(storage)(req, res, next);
|
|
207
|
-
// expect(storage.addPackage).toMatchSnapshot();
|
|
208
|
-
// });
|
|
209
|
-
|
|
210
|
-
// test('should throw an error while publishing package', () => {
|
|
211
|
-
// const storage = {
|
|
212
|
-
// addPackage() {
|
|
213
|
-
// throw new Error();
|
|
214
|
-
// },
|
|
215
|
-
// };
|
|
216
|
-
|
|
217
|
-
// // @ts-ignore
|
|
218
|
-
// publishPackage(storage)(req, res, next);
|
|
219
|
-
// expect(next).toHaveBeenCalledWith(new Error(API_ERROR.BAD_PACKAGE_DATA));
|
|
220
|
-
// });
|
|
221
|
-
|
|
222
|
-
// describe('test start', () => {
|
|
223
|
-
// test('should star a package', () => {
|
|
224
|
-
// const storage = {
|
|
225
|
-
// changePackage: jest.fn(),
|
|
226
|
-
// getPackage({ callback }) {
|
|
227
|
-
// callback(null, {
|
|
228
|
-
// users: {},
|
|
229
|
-
// });
|
|
230
|
-
// },
|
|
231
|
-
// };
|
|
232
|
-
// req = {
|
|
233
|
-
// params: {
|
|
234
|
-
// package: 'verdaccio',
|
|
235
|
-
// },
|
|
236
|
-
// body: {
|
|
237
|
-
// _rev: REVISION_MOCK,
|
|
238
|
-
// users: {
|
|
239
|
-
// verdaccio: true,
|
|
240
|
-
// },
|
|
241
|
-
// },
|
|
242
|
-
// remote_user: {
|
|
243
|
-
// name: 'verdaccio',
|
|
244
|
-
// },
|
|
245
|
-
// };
|
|
246
|
-
|
|
247
|
-
// // @ts-ignore
|
|
248
|
-
// publishPackage(storage)(req, res, next);
|
|
249
|
-
// expect(storage.changePackage).toMatchSnapshot();
|
|
250
|
-
// });
|
|
251
|
-
// });
|
|
252
|
-
// });
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* eslint-disable curly */
|
|
2
|
-
// ensure that all arguments are validated
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { describe, expect, test } from 'vitest';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Validate.
|
|
9
|
-
app.param('package', validate_pkg);
|
|
10
|
-
app.param('filename', validate_name);
|
|
11
|
-
app.param('tag', validate_name);
|
|
12
|
-
app.param('version', validate_name);
|
|
13
|
-
app.param('revision', validate_name);
|
|
14
|
-
app.param('token', validate_name);
|
|
15
|
-
*/
|
|
16
|
-
describe('api endpoint app.param()', () => {
|
|
17
|
-
let m;
|
|
18
|
-
const requirePath = path.normalize(path.join(__dirname, '../../src/index.ts'));
|
|
19
|
-
const source = fs.readFileSync(requirePath, 'utf8');
|
|
20
|
-
const very_scary_regexp = /\n\s*app\.(\w+)\s*\(\s*(("[^"]*")|('[^']*'))\s*,/g;
|
|
21
|
-
const appParams = {};
|
|
22
|
-
|
|
23
|
-
while ((m = very_scary_regexp.exec(source)) != null) {
|
|
24
|
-
if (m[1] === 'set') {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let inner = m[2].slice(1, m[2].length - 1);
|
|
29
|
-
let t;
|
|
30
|
-
|
|
31
|
-
inner.split('/').forEach(function (x) {
|
|
32
|
-
t = x.match(/^:([^?:]*)\??$/);
|
|
33
|
-
if (m[1] === 'param') {
|
|
34
|
-
appParams[x] = 'ok';
|
|
35
|
-
} else if (t) {
|
|
36
|
-
appParams[t[1]] = appParams[t[1]] || m[0].trim();
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
test.each(Object.keys(appParams))('should validate ":%s"', (param) => {
|
|
42
|
-
expect(appParams[param]).toEqual('ok');
|
|
43
|
-
});
|
|
44
|
-
});
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.reference.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./build"
|
|
6
|
-
},
|
|
7
|
-
"include": ["src/**/*.ts", "types/*.d.ts"],
|
|
8
|
-
"exclude": ["src/**/*.test.ts"],
|
|
9
|
-
"references": [
|
|
10
|
-
{
|
|
11
|
-
"path": "../auth"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"path": "../config"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"path": "../core/core"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"path": "../core/tarball"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"path": "../hooks"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"path": "../logger/logger"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"path": "../middleware"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"path": "../server/express"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"path": "../store"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"path": "../utils"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
package/types/custom.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
|
|
3
|
-
import { Logger, RemoteUser } from '@verdaccio/types';
|
|
4
|
-
|
|
5
|
-
export type $RequestExtend = Request & { remote_user?: any; log: Logger; query?: { key: string } };
|
|
6
|
-
export type $ResponseExtend = Response & { cookies?: any };
|
|
7
|
-
export type $NextFunctionVer = NextFunction & any;
|
|
8
|
-
|
|
9
|
-
declare global {
|
|
10
|
-
namespace Express {
|
|
11
|
-
export interface Request {
|
|
12
|
-
remote_user: RemoteUser;
|
|
13
|
-
log: Logger;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|