feat: add pnpm install prompt for missing dependencies (#929)
* feat: add pnpm install prompt for missing dependencies * feat: use --frozen-lockfile * feat: remove ugly error on ctrl + c * feat: use pnpm list instead * feat: move dependencies checking to a seperate script * refactor: why have 2 lines when you can have 1 * refactor: remove redundant things * some changes I made that somehow work --------- Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
parent
de34a074c9
commit
992190be02
3 changed files with 42 additions and 7 deletions
|
|
@ -14,9 +14,9 @@
|
|||
"license": "GPL-3.0-or-later",
|
||||
"author": "Equicord",
|
||||
"scripts": {
|
||||
"build": "node --require=./scripts/suppressExperimentalWarnings.js scripts/build/build.mjs",
|
||||
"build": "pnpm depCheck && node --require=./scripts/suppressExperimentalWarnings.js scripts/build/build.mjs",
|
||||
"buildStandalone": "pnpm build --standalone",
|
||||
"buildWeb": "node --require=./scripts/suppressExperimentalWarnings.js scripts/build/buildWeb.mjs",
|
||||
"buildWeb": "pnpm depCheck && node --require=./scripts/suppressExperimentalWarnings.js scripts/build/buildWeb.mjs",
|
||||
"buildWebStandalone": "pnpm buildWeb --standalone",
|
||||
"buildReporter": "pnpm buildWebStandalone --reporter --skip-extension",
|
||||
"buildReporterDesktop": "pnpm build --reporter",
|
||||
|
|
@ -36,7 +36,8 @@
|
|||
"lint:fix": "pnpm lint --fix",
|
||||
"test": "pnpm buildStandalone && pnpm testTsc && pnpm lint:fix && pnpm lint-styles && pnpm generatePluginJson",
|
||||
"testWeb": "pnpm lint:fix && pnpm buildWeb && pnpm testTsc",
|
||||
"testTsc": "tsc --noEmit"
|
||||
"testTsc": "tsc --noEmit",
|
||||
"depCheck": "node scripts/depCheck.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ffmpeg/ffmpeg": "^0.12.10",
|
||||
|
|
@ -96,7 +97,7 @@
|
|||
"typescript-transform-paths": "^3.5.5",
|
||||
"zip-local": "^0.3.5"
|
||||
},
|
||||
"packageManager": "pnpm@10.32.1",
|
||||
"packageManager": "pnpm@10.33.0",
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@types/less@3.0.8": "patches/@types__less@3.0.8.patch"
|
||||
|
|
|
|||
|
|
@ -79,11 +79,12 @@ export async function buildOrWatchAll(buildConfigs) {
|
|||
context(cfg).then(ctx => ctx.watch())
|
||||
));
|
||||
} else {
|
||||
await Promise.all(buildConfigs.map(cfg => build(cfg)))
|
||||
.catch(error => {
|
||||
for (const cfg of buildConfigs) {
|
||||
await build(cfg).catch(error => {
|
||||
console.error(error.message);
|
||||
process.exit(1); // exit immediately to skip the rest of the builds
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
33
scripts/depCheck.mjs
Normal file
33
scripts/depCheck.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2026 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { execSync } from "child_process";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
import { createInterface } from "readline/promises";
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const PackageJSON = JSON.parse(readFileSync(join(root, "package.json"), "utf-8"));
|
||||
|
||||
const allDeps = { ...PackageJSON.dependencies, ...PackageJSON.devDependencies };
|
||||
const requiredDeps = Object.keys(allDeps);
|
||||
const missing = requiredDeps.filter(d => {
|
||||
const v = allDeps[d];
|
||||
return !v.startsWith("link:") && !v.startsWith("workspace:") && !existsSync(join(root, "node_modules", d, "package.json"));
|
||||
});
|
||||
|
||||
if (missing.length) {
|
||||
console.error(`\x1b[31mMissing ${missing.length} package(s): ${missing.join(", ")}\x1b[0m`);
|
||||
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
||||
rl.on("SIGINT", () => { rl.close(); process.exit(1); });
|
||||
try {
|
||||
const ans = await rl.question("\x1b[33mRun 'pnpm install'? [Y/n]: \x1b[0m");
|
||||
if (!ans || /^y/i.test(ans)) execSync("pnpm install --frozen-lockfile", { cwd: root, stdio: "inherit" });
|
||||
} finally { rl.close(); }
|
||||
} else {
|
||||
console.log("\x1b[32mAll dependencies are installed.\x1b[0m");
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue