client/utils/scripts/update-packages.ts
Alex 2a55c87df1
Some checks failed
Dependency builds / Build web (pull_request) Has been skipped
Dependency builds / Build desktop (pull_request) Has been skipped
Dependency builds / Test native MTP (pull_request) Has been skipped
Dependency builds / Build mobile (pull_request) Has been skipped
/ build-web (push) Failing after 3m32s
/ build-desktop (linux) (push) Failing after 2m47s
/ build-mobile (push) Failing after 5m29s
/ release (push) Has been skipped
[Updt] Mtp 0.3.0
2026-08-20 17:05:53 +02:00

52 lines
1.3 KiB
TypeScript

import { existsSync, readdirSync, statSync } from "fs";
import { join } from "path";
import { execSync } from "child_process";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";
const _dirname = dirname(fileURLToPath(import.meta.url));
const packagesDir = join(_dirname, "..", "..", "packages");
function getPackageDirs(dir: string): string[] {
const entries = readdirSync(dir);
const dirs: string[] = [];
for (const entry of entries) {
const fullPath = join(dir, entry);
if (entry === "node_modules" || entry.startsWith(".")) continue;
let stats;
try {
stats = statSync(fullPath);
} catch {
continue;
}
if (!stats.isDirectory()) continue;
if (existsSync(join(fullPath, "package.json"))) {
dirs.push(fullPath);
continue;
}
dirs.push(...getPackageDirs(fullPath));
}
return dirs;
}
const packageDirs = getPackageDirs(packagesDir);
for (const fullPath of packageDirs) {
const entry = fullPath.replace(packagesDir + "/", "");
console.log(`Updating ${entry}...`);
try {
execSync("pnpm update --interactive", { cwd: fullPath, stdio: "inherit" });
console.log(`${entry} updated successfully.`);
} catch {
console.error(`Failed to update ${entry}.`);
process.exit(1);
}
}
console.log("Done!");