From 02235067f9f5761ced76dfb5320889b508a5d044 Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Tue, 21 Dec 2021 11:56:33 +0100 Subject: Repo cleanup, remove fs-extras --- bundle/src/start.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bundle/src/start.ts') diff --git a/bundle/src/start.ts b/bundle/src/start.ts index 8725ba61..1b21659e 100644 --- a/bundle/src/start.ts +++ b/bundle/src/start.ts @@ -31,7 +31,7 @@ if (cluster.isMaster) { ╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ fosscord-server | ${yellow( - `Pre-relase (${ + `Pre-release (${ commit !== null ? commit.slice(0, 7) : "Unknown (Git cannot be found)" -- cgit 1.5.1 From a12c372f0476e9026fbcf648cc7bbbc9d67b6d6f Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Tue, 21 Dec 2021 20:49:58 +0000 Subject: Improve build scripts, strip more fs-extras --- bundle/scripts/build.js | 9 ++++++--- bundle/src/start.ts | 2 +- cdn/tests/cdn_endpoints.test.js | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'bundle/src/start.ts') diff --git a/bundle/scripts/build.js b/bundle/scripts/build.js index 4f56694c..f73fb11a 100644 --- a/bundle/scripts/build.js +++ b/bundle/scripts/build.js @@ -1,10 +1,12 @@ const { execSync } = require("child_process"); const path = require("path"); -const fse = require("fs-extra"); const fs = require("fs"); const { getSystemErrorMap } = require("util"); const { argv } = require("process"); +var steps = 2, i = 0; +if (argv.includes("clean")) steps++; +if (argv.includes("copyonly")) steps--; const dirs = ["api", "util", "cdn", "gateway", "bundle"]; const verbose = argv.includes("verbose") || argv.includes("v"); @@ -30,6 +32,7 @@ var copyRecursiveSync = function(src, dest) { }; if (argv.includes("clean")) { + console.log(`[${++i}/${steps}] Cleaning...`); dirs.forEach((a) => { var d = "../" + a + "/dist"; if (fs.existsSync(d)) { @@ -39,6 +42,7 @@ if (argv.includes("clean")) { }); } +console.log(`[${++i}/${steps}] Copying src files...`); copyRecursiveSync(path.join(__dirname, "..", "..", "api", "assets"), path.join(__dirname, "..", "dist", "api", "assets")); copyRecursiveSync(path.join(__dirname, "..", "..", "api", "client_test"), path.join(__dirname, "..", "dist", "api", "client_test")); copyRecursiveSync(path.join(__dirname, "..", "..", "api", "locales"), path.join(__dirname, "..", "dist", "api", "locales")); @@ -47,9 +51,8 @@ dirs.forEach((a) => { if (verbose) console.log(`Copied ${"../" + a + "/dist"} -> ${"dist/" + a + "/src"}!`); }); -console.log("[1/2] Copying src files done"); if (!argv.includes("copyonly")) { - console.log("[2/2] Compiling src files ..."); + console.log(`[${++i}/${steps}] Compiling src files ...`); console.log( execSync( diff --git a/bundle/src/start.ts b/bundle/src/start.ts index 1b21659e..d2707f4d 100644 --- a/bundle/src/start.ts +++ b/bundle/src/start.ts @@ -43,7 +43,7 @@ Commit Hash: ${ ? `${cyan(commit)} (${yellow(commit.slice(0, 7))})` : "Unknown (Git cannot be found)" } -Cores: ${cyan(cores)} +Cores: ${cyan(os.cpus().length)} (Using ${cores} thread(s).) `) ); diff --git a/cdn/tests/cdn_endpoints.test.js b/cdn/tests/cdn_endpoints.test.js index 8cf16748..5a543e54 100644 --- a/cdn/tests/cdn_endpoints.test.js +++ b/cdn/tests/cdn_endpoints.test.js @@ -1,6 +1,6 @@ const dotenv = require("dotenv"); const path = require("path"); -const fse = require("fs-extra"); +const fs = require("fs"); dotenv.config(); // TODO: write unittest to check if FileStorage.ts is working @@ -21,7 +21,7 @@ if (process.env.STORAGE_PROVIDER === "file") { } else { process.env.STORAGE_LOCATION = path.join(__dirname, "..", "files", "/"); } - fse.ensureDirSync(process.env.STORAGE_LOCATION); + if(!fs.existsSync(process.env.STORAGE_LOCATION)) fs.mkdirSync(process.env.STORAGE_LOCATION, {recursive:true}); } const { CDNServer } = require("../dist/Server"); const { Config } = require("@fosscord/util"); -- cgit 1.5.1 From e042db33b6ee7aba69275d6f5e7cb901bcc0758d Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Sat, 25 Dec 2021 11:09:48 +0000 Subject: Replace nanocolors with picocolors --- api/package.json | 2 +- api/src/Server.ts | 2 +- bundle/package.json | 2 +- bundle/src/Server.ts | 4 ++-- bundle/src/start.ts | 2 +- bundle/src/stats.ts | 2 +- cdn/package.json | 2 +- cdn/src/util/Storage.ts | 2 +- util/package.json | 2 +- util/src/util/Database.ts | 5 ++++- 10 files changed, 14 insertions(+), 11 deletions(-) (limited to 'bundle/src/start.ts') diff --git a/api/package.json b/api/package.json index ab41b675..303d5871 100644 --- a/api/package.json +++ b/api/package.json @@ -86,9 +86,9 @@ "missing-native-js-functions": "^1.2.18", "morgan": "^1.10.0", "multer": "^1.4.2", - "nanocolors": "^0.2.13", "node-fetch": "^2.6.1", "patch-package": "^6.4.7", + "picocolors": "^1.0.0", "proxy-agent": "^5.0.0", "supertest": "^6.1.6", "typeorm": "^0.2.37" diff --git a/api/src/Server.ts b/api/src/Server.ts index 259c2a6b..b0683dfc 100644 --- a/api/src/Server.ts +++ b/api/src/Server.ts @@ -12,7 +12,7 @@ import { initTranslation } from "./middlewares/Translation"; import morgan from "morgan"; import { initInstance } from "./util/Instance"; import { registerRoutes } from "@fosscord/util"; -import { red } from "nanocolors" +import { red } from "picocolors" export interface FosscordServerOptions extends ServerOptions {} diff --git a/bundle/package.json b/bundle/package.json index 97066bd8..2961e8a3 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -92,11 +92,11 @@ "missing-native-js-functions": "^1.2.18", "morgan": "^1.10.0", "multer": "^1.4.2", - "nanocolors": "^0.2.12", "node-fetch": "^2.6.1", "node-os-utils": "^1.3.5", "patch-package": "^6.4.7", "pg": "^8.7.1", + "picocolors": "^1.0.0", "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", "sqlite3": "^5.0.2", diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts index d07a6ce0..0d5e3d1f 100644 --- a/bundle/src/Server.ts +++ b/bundle/src/Server.ts @@ -6,7 +6,7 @@ import * as Api from "@fosscord/api"; import * as Gateway from "@fosscord/gateway"; import { CDNServer } from "@fosscord/cdn"; import express from "express"; -import { green, bold } from "nanocolors"; +import { green, bold, yellow } from "picocolors"; import { Config, initDatabase } from "@fosscord/util"; import * as Sentry from "@sentry/node"; import * as Tracing from "@sentry/tracing"; @@ -61,7 +61,7 @@ async function main() { //Sentry if (Config.get().sentry.enabled) { console.log( - "[Bundle] You are using Sentry! This may slightly impact performance on large loads!" + `[Bundle] ${yellow("You are using Sentry! This may slightly impact performance on large loads!")}` ); Sentry.init({ dsn: Config.get().sentry.endpoint, diff --git a/bundle/src/start.ts b/bundle/src/start.ts index d2707f4d..7660b296 100644 --- a/bundle/src/start.ts +++ b/bundle/src/start.ts @@ -2,7 +2,7 @@ import "reflect-metadata"; import cluster, { Worker } from "cluster"; import os from "os"; -import { red, bold, yellow, cyan } from "nanocolors"; +import { red, bold, yellow, cyan } from "picocolors"; import { initStats } from "./stats"; import { config } from "dotenv"; config(); diff --git a/bundle/src/stats.ts b/bundle/src/stats.ts index 8d87f9d9..3c5163c3 100644 --- a/bundle/src/stats.ts +++ b/bundle/src/stats.ts @@ -1,6 +1,6 @@ import os from "os"; import osu from "node-os-utils"; -import { red } from "nanocolors"; +import { red } from "picocolors"; export function initStats() { console.log(`[Path] running in ${__dirname}`); diff --git a/cdn/package.json b/cdn/package.json index fec43785..c029ffbf 100644 --- a/cdn/package.json +++ b/cdn/package.json @@ -53,7 +53,7 @@ "lambert-server": "^1.2.12", "missing-native-js-functions": "^1.2.17", "multer": "^1.4.2", - "nanocolors": "^0.2.12", + "picocolors": "^1.0.0", "node-fetch": "^2.6.1", "supertest": "^6.1.6", "typescript": "^4.1.2" diff --git a/cdn/src/util/Storage.ts b/cdn/src/util/Storage.ts index f45fe44a..89dd5634 100644 --- a/cdn/src/util/Storage.ts +++ b/cdn/src/util/Storage.ts @@ -1,7 +1,7 @@ import { FileStorage } from "./FileStorage"; import path from "path"; import fse from "fs-extra"; -import { bgCyan, black } from "nanocolors"; +import { bgCyan, black } from "picocolors"; import { S3 } from "@aws-sdk/client-s3"; import { S3Storage } from "./S3Storage"; process.cwd(); diff --git a/util/package.json b/util/package.json index e93eeab4..aef5dcfc 100644 --- a/util/package.json +++ b/util/package.json @@ -44,10 +44,10 @@ "lambert-server": "^1.2.12", "missing-native-js-functions": "^1.2.18", "multer": "^1.4.3", - "nanocolors": "^0.2.12", "node-fetch": "^2.6.1", "patch-package": "^6.4.7", "pg": "^8.7.1", + "picocolors": "^1.0.0", "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", "typeorm": "^0.2.38", diff --git a/util/src/util/Database.ts b/util/src/util/Database.ts index 6124ffab..e8177093 100644 --- a/util/src/util/Database.ts +++ b/util/src/util/Database.ts @@ -3,7 +3,7 @@ import "reflect-metadata"; import { Connection, createConnection } from "typeorm"; import * as Models from "../entities"; import { Migration } from "../entities/Migration"; -import { yellow, green } from "nanocolors"; +import { yellow, green, red } from "picocolors"; // UUID extension option is only supported with postgres // We want to generate all id's with Snowflakes that's why we have our own BaseEntity class @@ -19,6 +19,9 @@ export function initDatabase(): Promise { const isSqlite = type.includes("sqlite"); console.log(`[Database] ${yellow(`connecting to ${type} db`)}`); + if(isSqlite) { + console.log(`[Database] ${red(`You are running sqlite! Please keep in mind that we recommend setting up a dedicated database!`)}`); + } // @ts-ignore promise = createConnection({ type, -- cgit 1.5.1