From a20c4aeeae27007c01e47a7235c1017e8ced0d6d Mon Sep 17 00:00:00 2001 From: jzhangdev Date: Thu, 30 May 2024 17:41:47 +0800 Subject: [PATCH] feat: support filtering files --- ...ge-diff-16af13e9-22eb-4dab-b202-fabbd1bcb217.json | 7 +++++++ src/index.html | 12 ++++++++---- src/index.ts | 3 ++- 3 files changed, 17 insertions(+), 5 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..d56c9d8 100644 --- a/src/index.html +++ b/src/index.html @@ -38,13 +38,17 @@ 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}`, { - headers: { - Authorization: typeof token === 'string' && `Bearer ${token}`, + fetch( + `/-/npm/package-diff/data?name=${name}&from=${from}&to=${to}&filter=${filter}`, + { + headers: { + Authorization: typeof token === 'string' && `Bearer ${token}`, + }, }, - }).then(async (response) => { + ).then(async (response) => { if (response.status === 401) { const fragment = document.createDocumentFragment(); const linkElement = document.createElement('a'); 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}`, ],