mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-26 00:29:58 +00:00
Update scripts, update workspace, add launch.json
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ const { env } = require("process");
|
||||
const { execSync } = require("child_process");
|
||||
const { argv, stdout, exit } = require("process");
|
||||
|
||||
const { execIn, getLines, parts } = require("./utils");
|
||||
const { execIn, getLines } = require("./utils");
|
||||
|
||||
let npmi_extra_flags = "";
|
||||
|
||||
|
||||
+44
-47
@@ -4,62 +4,59 @@ const { env } = require("process");
|
||||
const { execSync } = require("child_process");
|
||||
const { argv, stdout, exit } = require("process");
|
||||
|
||||
const { execIn, getLines, parts } = require('./utils');
|
||||
const { execIn, getLines } = require('./utils');
|
||||
|
||||
const bundleRequired = ["@ovos-media/ts-transform-paths"];
|
||||
const removeModules = argv.includes("cleanup");
|
||||
|
||||
parts.forEach((part) => {
|
||||
console.log(`Installing all packages for ${part}...`);
|
||||
execIn("npm i", path.join(__dirname, "..", "..", part));
|
||||
});
|
||||
console.log(`Installing all packages...`);
|
||||
execIn("npm i", path.join(__dirname, ".."));
|
||||
|
||||
parts.forEach((part) => {
|
||||
let partDir = path.join(__dirname, "..", "..", part);
|
||||
let distDir = path.join(partDir, "dist");
|
||||
let start = 0;
|
||||
start = getLines(
|
||||
execIn("npm ls --parseable --package-lock-only -a", partDir)
|
||||
);
|
||||
if (fs.existsSync(distDir))
|
||||
fs.rmSync(distDir, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
let x = {
|
||||
dependencies: [],
|
||||
devDependencies: [],
|
||||
invalidDirs: [],
|
||||
invalidFiles: [],
|
||||
missing: [],
|
||||
using: [],
|
||||
};
|
||||
let dcproc = execIn("npx depcheck --json", partDir);
|
||||
if(dcproc.stdout) x = JSON.parse(dcproc.stdout);
|
||||
else x = JSON.parse(dcproc);
|
||||
let partDir = path.join(__dirname, "..");
|
||||
let distDir = path.join(partDir, "dist");
|
||||
let start = 0;
|
||||
start = getLines(
|
||||
execIn("npm ls --parseable --package-lock-only -a", partDir)
|
||||
);
|
||||
if (fs.existsSync(distDir))
|
||||
fs.rmSync(distDir, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
let x = {
|
||||
dependencies: [],
|
||||
devDependencies: [],
|
||||
invalidDirs: [],
|
||||
invalidFiles: [],
|
||||
missing: [],
|
||||
using: [],
|
||||
};
|
||||
let dcproc = execIn("npx depcheck --json", partDir);
|
||||
if(dcproc.stdout) x = JSON.parse(dcproc.stdout);
|
||||
else x = JSON.parse(dcproc);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, "..", `depclean.out.${part}.json`),
|
||||
JSON.stringify(x, null, "\t"),
|
||||
{ encoding: "utf8" }
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, "..", `depclean.out.json`),
|
||||
JSON.stringify(x, null, "\t"),
|
||||
{ encoding: "utf8" }
|
||||
);
|
||||
|
||||
let depsToRemove = x.dependencies.join(" ");
|
||||
if (depsToRemove) execIn(`npm r --save ${depsToRemove}`, partDir);
|
||||
let depsToRemove = x.dependencies.join(" ");
|
||||
if (depsToRemove) execIn(`npm r --save ${depsToRemove}`, partDir);
|
||||
|
||||
depsToRemove = x.devDependencies.join(" ");
|
||||
if (depsToRemove) execIn(`npm r --save --dev ${depsToRemove}`, partDir);
|
||||
depsToRemove = x.devDependencies.join(" ");
|
||||
if (depsToRemove) execIn(`npm r --save --dev ${depsToRemove}`, partDir);
|
||||
|
||||
if (removeModules && fs.existsSync(path.join(partDir, "node_modules")))
|
||||
fs.rmSync(path.join(partDir, "node_modules"), {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
let end = getLines(
|
||||
execIn("npm ls --parseable --package-lock-only -a", partDir)
|
||||
);
|
||||
console.log(`${part}: ${start} -> ${end} (diff: ${start - end})`);
|
||||
|
||||
if (removeModules && fs.existsSync(path.join(partDir, "node_modules")))
|
||||
fs.rmSync(path.join(partDir, "node_modules"), {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
let end = getLines(
|
||||
execIn("npm ls --parseable --package-lock-only -a", partDir)
|
||||
);
|
||||
console.log(`${part}: ${start} -> ${end} (diff: ${start - end})`);
|
||||
});
|
||||
console.log("Installing required packages for bundle...");
|
||||
|
||||
execIn(`npm i --save ${bundleRequired.join(" ")}`, path.join(__dirname, ".."));
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const parts = ["api", "util", "cdn", "gateway"];
|
||||
|
||||
const bundle = require("../package.json");
|
||||
|
||||
for (const part of parts) {
|
||||
const { devDependencies, dependencies } = require(path.join(
|
||||
"..",
|
||||
"..",
|
||||
part,
|
||||
"package.json"
|
||||
));
|
||||
bundle.devDependencies = { ...bundle.devDependencies, ...devDependencies };
|
||||
bundle.dependencies = { ...bundle.dependencies, ...dependencies };
|
||||
delete bundle.dependencies["@fosscord/util"];
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, "..", "package.json"),
|
||||
JSON.stringify(bundle, null, "\t"),
|
||||
{ encoding: "utf8" }
|
||||
);
|
||||
+1
-1
@@ -6,7 +6,7 @@ const { argv, stdout, exit } = require("process");
|
||||
|
||||
const { execIn, getLines, parts } = require("./utils");
|
||||
|
||||
let lines = fs.readFileSync(path.join(__dirname, "..", "..", "util", "src","util","Rights.ts")).toString()
|
||||
let lines = fs.readFileSync(path.join(__dirname, "..", "src", "util", "util","Rights.ts")).toString()
|
||||
let lines2 = lines.split("\n");
|
||||
let lines3 = lines2.filter(y=>y.includes(": BitFlag("));
|
||||
let lines4 = lines3.map(x=>x.split("//")[0].trim())
|
||||
|
||||
@@ -6,4 +6,4 @@ const { argv, stdout, exit } = require("process");
|
||||
|
||||
const { execIn, getLines, parts } = require("./utils");
|
||||
|
||||
execIn("node scripts/generate_schema.js", path.join("..", "api"));
|
||||
execIn("node scripts/generate_schema.js", path.join('.'));
|
||||
@@ -4,8 +4,6 @@ const { env } = require("process");
|
||||
const { execSync } = require("child_process");
|
||||
const { argv, stdout, exit } = require("process");
|
||||
|
||||
const parts = ["api", "util", "cdn", "gateway", "bundle"];
|
||||
|
||||
function copyRecursiveSync(src, dest) {
|
||||
//if (verbose) console.log(`cpsync: ${src} -> ${dest}`);
|
||||
let exists = fs.existsSync(src);
|
||||
|
||||
Reference in New Issue
Block a user