Skip to content

Commit

Permalink
feat: support filtering files
Browse files Browse the repository at this point in the history
  • Loading branch information
jzhangdev committed May 30, 2024
1 parent 2067140 commit a20c4ae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: support filtering files",
"packageName": "@rightcapital/verdaccio-package-diff",
"email": "[email protected]",
"dependentChangeType": "patch"
}
12 changes: 8 additions & 4 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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}`,
],
Expand Down

0 comments on commit a20c4ae

Please sign in to comment.