From 23336741ff39bc7c9f8a6f2150b3a1b1bb75e879 Mon Sep 17 00:00:00 2001 From: jzhangdev Date: Thu, 30 May 2024 17:41:47 +0800 Subject: [PATCH] feat: support filtering files --- ...-package-diff-16af13e9-22eb-4dab-b202-fabbd1bcb217.json | 7 +++++++ src/index.html | 3 ++- src/index.ts | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 change/@rightcapital-verdaccio-package-diff-16af13e9-22eb-4dab-b202-fabbd1bcb217.json diff --git a/change/@rightcapital-verdaccio-package-diff-16af13e9-22eb-4dab-b202-fabbd1bcb217.json b/change/@rightcapital-verdaccio-package-diff-16af13e9-22eb-4dab-b202-fabbd1bcb217.json new file mode 100644 index 0000000..61fba73 --- /dev/null +++ b/change/@rightcapital-verdaccio-package-diff-16af13e9-22eb-4dab-b202-fabbd1bcb217.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "feat: support filtering files", + "packageName": "@rightcapital/verdaccio-package-diff", + "email": "zhangjie9477@gmail.com", + "dependentChangeType": "patch" +} diff --git a/src/index.html b/src/index.html index 9db9db1..21ff7c6 100644 --- a/src/index.html +++ b/src/index.html @@ -38,9 +38,10 @@ const name = params.get('name'); const from = params.get('from'); const to = params.get('to'); + const filter = params.get('filter'); if (name && from && to) { - fetch(`/-/npm/package-diff/data?name=${name}&from=${from}&to=${to}`, { + fetch(`/-/npm/package-diff/data?name=${name}&from=${from}&to=${to}&filter=${filter}`, { headers: { Authorization: typeof token === 'string' && `Bearer ${token}`, }, diff --git a/src/index.ts b/src/index.ts index 3a129f7..7d3d16a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -79,7 +79,7 @@ export default class VerdaccioMiddlewarePlugin const router = Router(); router.get('/data', (req: Request, res: Response, next: NextFunction) => { - const { name, from, to } = req.query; + const { name, from, to, filter = '.' } = req.query; const authorizationToken = req.get('Authorization'); if (!name || !from || !to) { @@ -110,6 +110,7 @@ export default class VerdaccioMiddlewarePlugin 'npm', [ 'diff', + filter as string, `--diff=${name as string}@${from as string}`, `--diff=${name as string}@${to as string}`, ],