Merge pull request #28682 from Pike/sanitize-dependencies

Remove unused dependencies from backend-app-api and backend-defaults.
This commit is contained in:
Fredrik Adelöw
2025-03-16 16:06:21 +01:00
committed by GitHub
12 changed files with 29 additions and 325 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/config-loader': patch
---
Added `@types/minimist` to `devDependencies`
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-defaults': patch
---
Remove unused dependencies
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-app-api': patch
---
Remove unused dependencies
+1 -42
View File
@@ -1,49 +1,8 @@
# Knip report
## Unused dependencies (27)
| Name | Location | Severity |
| :-------------------------------- | :----------- | :------- |
| @backstage/plugin-permission-node | package.json | error |
| @backstage/plugin-auth-node | package.json | error |
| @backstage/config-loader | package.json | error |
| @backstage/cli-common | package.json | error |
| @manypkg/get-packages | package.json | error |
| @backstage/config | package.json | error |
| winston-transport | package.json | error |
| @backstage/types | package.json | error |
| path-to-regexp | package.json | error |
| compression | package.json | error |
| triple-beam | package.json | error |
| node-forge | package.json | error |
| selfsigned | package.json | error |
| minimatch | package.json | error |
| stoppable | package.json | error |
| minimist | package.json | error |
| logform | package.json | error |
| winston | package.json | error |
| cookie | package.json | error |
| helmet | package.json | error |
| lodash | package.json | error |
| morgan | package.json | error |
| luxon | package.json | error |
| cors | package.json | error |
| jose | package.json | error |
| knex | package.json | error |
| uuid | package.json | error |
## Unused devDependencies (10)
## Unused devDependencies (1)
| Name | Location | Severity |
| :-------------------------- | :----------- | :------- |
| @backstage/backend-defaults | package.json | error |
| @types/compression | package.json | error |
| @types/http-errors | package.json | error |
| @types/node-forge | package.json | error |
| @types/stoppable | package.json | error |
| @types/minimist | package.json | error |
| @types/morgan | package.json | error |
| http-errors | package.json | error |
| supertest | package.json | error |
| msw | package.json | error |
+2 -38
View File
@@ -47,48 +47,12 @@
},
"dependencies": {
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/cli-common": "workspace:^",
"@backstage/config": "workspace:^",
"@backstage/config-loader": "workspace:^",
"@backstage/errors": "workspace:^",
"@backstage/plugin-auth-node": "workspace:^",
"@backstage/plugin-permission-node": "workspace:^",
"@backstage/types": "workspace:^",
"@manypkg/get-packages": "^1.1.3",
"compression": "^1.7.4",
"cookie": "^0.7.0",
"cors": "^2.8.5",
"helmet": "^6.0.0",
"jose": "^5.0.0",
"knex": "^3.0.0",
"lodash": "^4.17.21",
"logform": "^2.3.2",
"luxon": "^3.0.0",
"minimatch": "^9.0.0",
"minimist": "^1.2.5",
"morgan": "^1.10.0",
"node-forge": "^1.3.1",
"path-to-regexp": "^8.0.0",
"selfsigned": "^2.0.0",
"stoppable": "^1.1.0",
"triple-beam": "^1.4.1",
"uuid": "^11.0.0",
"winston": "^3.2.1",
"winston-transport": "^4.5.0"
"@backstage/errors": "workspace:^"
},
"devDependencies": {
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@types/compression": "^1.7.0",
"@types/http-errors": "^2.0.0",
"@types/minimist": "^1.2.0",
"@types/morgan": "^1.9.0",
"@types/node-forge": "^1.3.0",
"@types/stoppable": "^1.1.0",
"http-errors": "^2.0.0",
"msw": "^1.0.0",
"supertest": "^7.0.0"
"@backstage/cli": "workspace:^"
},
"configSchema": "config.d.ts"
}
+5 -15
View File
@@ -1,21 +1,11 @@
# Knip report
## Unused dependencies (6)
## Unused dependencies (2)
| Name | Location | Severity |
| :-------------------- | :----------- | :------- |
| @backstage/cli-common | package.json | error |
| @azure/identity | package.json | error |
| better-sqlite3 | package.json | error |
| isomorphic-git | package.json | error |
| minimist | package.json | error |
| mysql2 | package.json | error |
## Unused devDependencies (1)
| Name | Location | Severity |
| :--------------- | :----------- | :------- |
| @types/stoppable | package.json | error |
| Name | Location | Severity |
| :------------- | :----------- | :------- |
| better-sqlite3 | package.json | error |
| mysql2 | package.json | error |
## Referenced optional peerDependencies (1)
+1 -5
View File
@@ -127,12 +127,10 @@
"@aws-sdk/client-s3": "^3.350.0",
"@aws-sdk/credential-providers": "^3.350.0",
"@aws-sdk/types": "^3.347.0",
"@azure/identity": "^4.0.0",
"@azure/storage-blob": "^12.5.0",
"@backstage/backend-app-api": "workspace:^",
"@backstage/backend-dev-utils": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/cli-common": "workspace:^",
"@backstage/cli-node": "workspace:^",
"@backstage/config": "workspace:^",
"@backstage/config-loader": "workspace:^",
@@ -164,7 +162,6 @@
"fs-extra": "^11.2.0",
"git-url-parse": "^15.0.0",
"helmet": "^6.0.0",
"isomorphic-git": "^1.23.0",
"jose": "^5.0.0",
"keyv": "^5.2.1",
"knex": "^3.0.0",
@@ -172,7 +169,6 @@
"logform": "^2.3.2",
"luxon": "^3.0.0",
"minimatch": "^9.0.0",
"minimist": "^1.2.5",
"mysql2": "^3.0.0",
"node-fetch": "^2.7.0",
"node-forge": "^1.3.1",
@@ -201,11 +197,11 @@
"@google-cloud/cloud-sql-connector": "^1.4.0",
"@types/archiver": "^6.0.0",
"@types/base64-stream": "^1.0.2",
"@types/compression": "^1.7.5",
"@types/concat-stream": "^2.0.0",
"@types/http-errors": "^2.0.0",
"@types/node-forge": "^1.3.0",
"@types/pg-format": "^1.0.5",
"@types/stoppable": "^1.1.0",
"@types/yauzl": "^2.10.0",
"aws-sdk-client-mock": "^4.0.0",
"http-errors": "^2.0.0",
@@ -35,14 +35,6 @@ const treeResponseFactory = DefaultReadTreeResponseFactory.create({
config: new ConfigReader({}),
});
jest.mock('./git', () => ({
Git: {
fromAuth: () => ({
clone: jest.fn(() => Promise.resolve({})),
}),
},
}));
const giteaProcessor = new GiteaUrlReader(
new GiteaIntegration(
readGiteaConfig(
@@ -35,14 +35,6 @@ const treeResponseFactory = DefaultReadTreeResponseFactory.create({
config: new ConfigReader({}),
});
jest.mock('./git', () => ({
Git: {
fromAuth: () => ({
clone: jest.fn(() => Promise.resolve({})),
}),
},
}));
const harnessProcessor = new HarnessUrlReader(
new HarnessIntegration(
readHarnessConfig(
@@ -1,148 +0,0 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs-extra';
import isomorphicGit, { ProgressCallback, AuthCallback } from 'isomorphic-git';
import http from 'isomorphic-git/http/node';
import { LoggerService } from '@backstage/backend-plugin-api';
/**
* Configure static credential for authentication
*
* @public
*/
export type StaticAuthOptions = {
username?: string;
password?: string;
token?: string;
logger?: LoggerService;
};
/**
* Configure an authentication callback that can provide credentials on demand
*
* @public
*/
export type AuthCallbackOptions = {
onAuth: AuthCallback;
logger?: LoggerService;
};
function isAuthCallbackOptions(
options: StaticAuthOptions | AuthCallbackOptions,
): options is AuthCallbackOptions {
return 'onAuth' in options;
}
/*
provider username password
Azure 'notempty' token
Bitbucket Cloud 'x-token-auth' token
Bitbucket Server username password or token
GitHub 'x-access-token' token
GitLab 'oauth2' token
From : https://isomorphic-git.org/docs/en/onAuth with fix for GitHub
Or token provided as `token` for Bearer auth header
instead of Basic Auth (e.g., Bitbucket Server).
*/
/**
* A convenience wrapper around the `isomorphic-git` library.
*
* @public
*/
export class Git {
private readonly headers: {
[x: string]: string;
};
private constructor(
private readonly config: {
onAuth: AuthCallback;
token?: string;
logger?: LoggerService;
},
) {
this.onAuth = config.onAuth;
this.headers = {
'user-agent': 'git/@isomorphic-git',
...(config.token ? { Authorization: `Bearer ${config.token}` } : {}),
};
}
/** https://isomorphic-git.org/docs/en/clone */
async clone(options: {
url: string;
dir: string;
ref?: string;
depth?: number;
noCheckout?: boolean;
}): Promise<void> {
const { url, dir, ref, depth, noCheckout } = options;
this.config.logger?.info(`Cloning repo {dir=${dir},url=${url}}`);
try {
return await isomorphicGit.clone({
fs,
http,
url,
dir,
ref,
singleBranch: true,
depth: depth ?? 1,
noCheckout,
onProgress: this.onProgressHandler(),
headers: this.headers,
onAuth: this.onAuth,
});
} catch (ex) {
this.config.logger?.error(`Failed to clone repo {dir=${dir},url=${url}}`);
if (ex.data) {
throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);
}
throw ex;
}
}
private onAuth: AuthCallback;
private onProgressHandler = (): ProgressCallback => {
let currentPhase = '';
return event => {
if (currentPhase !== event.phase) {
currentPhase = event.phase;
this.config.logger?.info(event.phase);
}
const total = event.total
? `${Math.round((event.loaded / event.total) * 100)}%`
: event.loaded;
this.config.logger?.debug(`status={${event.phase},total={${total}}}`);
};
};
static fromAuth = (options: StaticAuthOptions | AuthCallbackOptions) => {
if (isAuthCallbackOptions(options)) {
const { onAuth, logger } = options;
return new Git({ onAuth, logger });
}
const { username, password, token, logger } = options;
return new Git({ onAuth: () => ({ username, password }), token, logger });
};
}
+1
View File
@@ -56,6 +56,7 @@
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@types/json-schema-merge-allof": "^0.6.0",
"@types/minimist": "^1.2.5",
"msw": "^1.0.0",
"zen-observable": "^0.10.0"
}
+4 -61
View File
@@ -3464,43 +3464,7 @@ __metadata:
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/cli-common": "workspace:^"
"@backstage/config": "workspace:^"
"@backstage/config-loader": "workspace:^"
"@backstage/errors": "workspace:^"
"@backstage/plugin-auth-node": "workspace:^"
"@backstage/plugin-permission-node": "workspace:^"
"@backstage/types": "workspace:^"
"@manypkg/get-packages": ^1.1.3
"@types/compression": ^1.7.0
"@types/http-errors": ^2.0.0
"@types/minimist": ^1.2.0
"@types/morgan": ^1.9.0
"@types/node-forge": ^1.3.0
"@types/stoppable": ^1.1.0
compression: ^1.7.4
cookie: ^0.7.0
cors: ^2.8.5
helmet: ^6.0.0
http-errors: ^2.0.0
jose: ^5.0.0
knex: ^3.0.0
lodash: ^4.17.21
logform: ^2.3.2
luxon: ^3.0.0
minimatch: ^9.0.0
minimist: ^1.2.5
morgan: ^1.10.0
msw: ^1.0.0
node-forge: ^1.3.1
path-to-regexp: ^8.0.0
selfsigned: ^2.0.0
stoppable: ^1.1.0
supertest: ^7.0.0
triple-beam: ^1.4.1
uuid: ^11.0.0
winston: ^3.2.1
winston-transport: ^4.5.0
languageName: unknown
linkType: soft
@@ -3591,14 +3555,12 @@ __metadata:
"@aws-sdk/credential-providers": ^3.350.0
"@aws-sdk/types": ^3.347.0
"@aws-sdk/util-stream-node": ^3.350.0
"@azure/identity": ^4.0.0
"@azure/storage-blob": ^12.5.0
"@backstage/backend-app-api": "workspace:^"
"@backstage/backend-dev-utils": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/cli-common": "workspace:^"
"@backstage/cli-node": "workspace:^"
"@backstage/config": "workspace:^"
"@backstage/config-loader": "workspace:^"
@@ -3618,13 +3580,13 @@ __metadata:
"@opentelemetry/api": ^1.9.0
"@types/archiver": ^6.0.0
"@types/base64-stream": ^1.0.2
"@types/compression": ^1.7.5
"@types/concat-stream": ^2.0.0
"@types/cors": ^2.8.6
"@types/express": ^4.17.6
"@types/http-errors": ^2.0.0
"@types/node-forge": ^1.3.0
"@types/pg-format": ^1.0.5
"@types/stoppable": ^1.1.0
"@types/yauzl": ^2.10.0
archiver: ^7.0.0
aws-sdk-client-mock: ^4.0.0
@@ -3641,7 +3603,6 @@ __metadata:
git-url-parse: ^15.0.0
helmet: ^6.0.0
http-errors: ^2.0.0
isomorphic-git: ^1.23.0
jose: ^5.0.0
keyv: ^5.2.1
knex: ^3.0.0
@@ -3649,7 +3610,6 @@ __metadata:
logform: ^2.3.2
luxon: ^3.0.0
minimatch: ^9.0.0
minimist: ^1.2.5
msw: ^1.0.0
mysql2: ^3.0.0
node-fetch: ^2.7.0
@@ -4150,6 +4110,7 @@ __metadata:
"@backstage/types": "workspace:^"
"@types/json-schema": ^7.0.6
"@types/json-schema-merge-allof": ^0.6.0
"@types/minimist": ^1.2.5
ajv: ^8.10.0
chokidar: ^3.5.2
fs-extra: ^11.2.0
@@ -19535,7 +19496,7 @@ __metadata:
languageName: node
linkType: hard
"@types/compression@npm:^1.7.0":
"@types/compression@npm:^1.7.5":
version: 1.7.5
resolution: "@types/compression@npm:1.7.5"
dependencies:
@@ -20253,22 +20214,13 @@ __metadata:
languageName: node
linkType: hard
"@types/minimist@npm:^1.2.0":
"@types/minimist@npm:^1.2.5":
version: 1.2.5
resolution: "@types/minimist@npm:1.2.5"
checksum: 477047b606005058ab0263c4f58097136268007f320003c348794f74adedc3166ffc47c80ec3e94687787f2ab7f4e72c468223946e79892cf0fd9e25e9970a90
languageName: node
linkType: hard
"@types/morgan@npm:^1.9.0":
version: 1.9.9
resolution: "@types/morgan@npm:1.9.9"
dependencies:
"@types/node": "*"
checksum: 54bcb432f6ddb82b94bc1970204bedb3465a9afdcced6c2c6b481cf5f276266663ba3edc2b728b0118aa9720bfe5d8561c0259daaad6b027017e35936b107db0
languageName: node
linkType: hard
"@types/ms@npm:*":
version: 0.7.31
resolution: "@types/ms@npm:0.7.31"
@@ -20920,15 +20872,6 @@ __metadata:
languageName: node
linkType: hard
"@types/stoppable@npm:^1.1.0":
version: 1.1.3
resolution: "@types/stoppable@npm:1.1.3"
dependencies:
"@types/node": "*"
checksum: 53cbe08da33d2babb4ee98fe123c1e08bc5a26f547a2eaeac7c279743bbee5f9b49c0772db6a106471a07092916deb9bb7e0632fd502585d45d9c398f036938d
languageName: node
linkType: hard
"@types/stream-buffers@npm:^3.0.3":
version: 3.0.7
resolution: "@types/stream-buffers@npm:3.0.7"