mirror of
https://github.com/bitwarden/clients.git
synced 2026-01-11 20:07:18 +00:00
chore(deps): Include Cargo dependencies in dep-ownership lint check
* Added Cardo dep ownership. * Fixed file paths. * Moved aes-gcm from KM to Tools.
This commit is contained in:
parent
966f9a0c52
commit
528f59875e
2 changed files with 63 additions and 6 deletions
12
.github/renovate.json5
vendored
12
.github/renovate.json5
vendored
|
|
@ -132,6 +132,7 @@
|
|||
"@yao-pkg/pkg",
|
||||
"anyhow",
|
||||
"arboard",
|
||||
"ashpd",
|
||||
"babel-loader",
|
||||
"base64-loader",
|
||||
"base64",
|
||||
|
|
@ -142,6 +143,7 @@
|
|||
"core-foundation",
|
||||
"copy-webpack-plugin",
|
||||
"css-loader",
|
||||
"ctor",
|
||||
"dirs",
|
||||
"electron",
|
||||
"electron-builder",
|
||||
|
|
@ -179,6 +181,7 @@
|
|||
"sass",
|
||||
"sass-loader",
|
||||
"scopeguard",
|
||||
"secmem-proc",
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"semver",
|
||||
|
|
@ -187,6 +190,7 @@
|
|||
"simplelog",
|
||||
"style-loader",
|
||||
"sysinfo",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
|
|
@ -210,6 +214,7 @@
|
|||
"windows-registry",
|
||||
"zbus",
|
||||
"zbus_polkit",
|
||||
"zeroizing-alloc",
|
||||
],
|
||||
description: "Platform owned dependencies",
|
||||
commitMessagePrefix: "[deps] Platform:",
|
||||
|
|
@ -285,6 +290,7 @@
|
|||
"@types/jsdom",
|
||||
"@types/papaparse",
|
||||
"@types/zxcvbn",
|
||||
"aes-gcm",
|
||||
"async-trait",
|
||||
"clap",
|
||||
"jsdom",
|
||||
|
|
@ -337,6 +343,7 @@
|
|||
"aes",
|
||||
"big-integer",
|
||||
"cbc",
|
||||
"chacha20poly1305",
|
||||
"linux-keyutils",
|
||||
"memsec",
|
||||
"node-forge",
|
||||
|
|
@ -445,6 +452,7 @@
|
|||
matchPackageNames: [
|
||||
"anyhow",
|
||||
"arboard",
|
||||
"ashpd",
|
||||
"babel-loader",
|
||||
"base64-loader",
|
||||
"base64",
|
||||
|
|
@ -454,6 +462,7 @@
|
|||
"core-foundation",
|
||||
"copy-webpack-plugin",
|
||||
"css-loader",
|
||||
"ctor",
|
||||
"dirs",
|
||||
"electron-builder",
|
||||
"electron-log",
|
||||
|
|
@ -488,6 +497,7 @@
|
|||
"sass",
|
||||
"sass-loader",
|
||||
"scopeguard",
|
||||
"secmem-proc",
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"semver",
|
||||
|
|
@ -496,6 +506,7 @@
|
|||
"simplelog",
|
||||
"style-loader",
|
||||
"sysinfo",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
|
|
@ -517,6 +528,7 @@
|
|||
"windows-registry",
|
||||
"zbus",
|
||||
"zbus_polkit",
|
||||
"zeroizing-alloc",
|
||||
],
|
||||
matchUpdateTypes: ["minor", "patch"],
|
||||
dependencyDashboardApproval: true,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable no-console */
|
||||
|
||||
/// Ensure that all dependencies in package.json have an owner in the renovate.json file.
|
||||
/// Ensure that all dependencies in package.json and Cargo.toml have an owner in the renovate.json5 file.
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
|
@ -11,22 +11,67 @@ const renovateConfig = JSON5.parse(
|
|||
fs.readFileSync(path.join(__dirname, "..", "..", ".github", "renovate.json5"), "utf8"),
|
||||
);
|
||||
|
||||
// Extract all packages with owners from renovate config
|
||||
const packagesWithOwners = renovateConfig.packageRules
|
||||
.flatMap((rule: any) => rule.matchPackageNames)
|
||||
.filter((packageName: string) => packageName != null);
|
||||
|
||||
function hasOwner(packageName: string): boolean {
|
||||
return packagesWithOwners.includes(packageName);
|
||||
}
|
||||
|
||||
// Collect npm dependencies
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, "..", "..", "package.json"), "utf8"),
|
||||
);
|
||||
const dependencies = Object.keys(packageJson.dependencies).concat(
|
||||
Object.keys(packageJson.devDependencies),
|
||||
const npmDependencies = [
|
||||
...Object.keys(packageJson.dependencies || {}),
|
||||
...Object.keys(packageJson.devDependencies || {}),
|
||||
];
|
||||
|
||||
// Collect Cargo dependencies from workspace Cargo.toml
|
||||
const cargoTomlPath = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
"apps",
|
||||
"desktop",
|
||||
"desktop_native",
|
||||
"Cargo.toml",
|
||||
);
|
||||
const cargoTomlContent = fs.existsSync(cargoTomlPath) ? fs.readFileSync(cargoTomlPath, "utf8") : "";
|
||||
|
||||
const missingOwners = dependencies.filter((dep) => !packagesWithOwners.includes(dep));
|
||||
const cargoDependencies = new Set<string>();
|
||||
|
||||
if (missingOwners.length > 0) {
|
||||
// Extract dependency names from [workspace.dependencies] section by
|
||||
// extracting everything between [workspace.dependencies] and the next section start
|
||||
// (indicated by a "\n[").
|
||||
const workspaceSection =
|
||||
cargoTomlContent.split("[workspace.dependencies]")[1]?.split(/\n\[/)[0] ?? "";
|
||||
|
||||
// Process each line to extract dependency names
|
||||
workspaceSection
|
||||
.split("\n") // Process each line
|
||||
.map((line) => line.match(/^([a-zA-Z0-9_-]+)\s*=/)?.[1]) // Find the dependency name
|
||||
.filter((depName): depName is string => depName != null && !depName.startsWith("bitwarden")) // Make sure it's not an empty line or a Bitwarden dependency
|
||||
.forEach((depName) => cargoDependencies.add(depName));
|
||||
|
||||
// Check for missing owners
|
||||
const missingNpmOwners = npmDependencies.filter((dep) => !hasOwner(dep));
|
||||
const missingCargoOwners = Array.from(cargoDependencies).filter((dep) => !hasOwner(dep));
|
||||
|
||||
const allMissing = [...missingNpmOwners, ...missingCargoOwners];
|
||||
|
||||
if (allMissing.length > 0) {
|
||||
console.error("Missing owners for the following dependencies:");
|
||||
console.error(missingOwners.join("\n"));
|
||||
if (missingNpmOwners.length > 0) {
|
||||
console.error("\nNPM dependencies:");
|
||||
console.error(missingNpmOwners.join("\n"));
|
||||
}
|
||||
if (missingCargoOwners.length > 0) {
|
||||
console.error("\nCargo dependencies:");
|
||||
console.error(missingCargoOwners.join("\n"));
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue