diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-12 01:46:42 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-13 21:57:51 +0200 |
commit | 44859db499f080e3a341f3e7fa5e44611fc2f887 (patch) | |
tree | e1f5df7de00929797de517683ff152e5f712bd02 /bundle | |
parent | Make ConfigValue a directory, move defaults to those classes instead of a sep... (diff) | |
download | server-44859db499f080e3a341f3e7fa5e44611fc2f887.tar.xz |
Push local state...
Diffstat (limited to 'bundle')
-rwxr-xr-x | bundle/scripts/db_migrations.sh | 14 | ||||
-rw-r--r-- | bundle/scripts/gen_index.js | 34 | ||||
-rw-r--r-- | bundle/scripts/update_schemas.js | 9 | ||||
-rw-r--r-- | bundle/scripts/utils.js | 3 |
4 files changed, 56 insertions, 4 deletions
diff --git a/bundle/scripts/db_migrations.sh b/bundle/scripts/db_migrations.sh index b0e1131c..83f15a2b 100755 --- a/bundle/scripts/db_migrations.sh +++ b/bundle/scripts/db_migrations.sh @@ -1,5 +1,13 @@ #!/bin/sh -read -p "Enter migration filename: " FILENAME + +if [ ! -z "$1" ] +then + FILENAME="$1" + echo "Using filename: $FILENAME" +else + read -p "Enter migration filename: " FILENAME +fi + [ -f ".env" ] && ( mv .env .env.tmp source .env.tmp @@ -8,8 +16,8 @@ read -p "Enter migration filename: " FILENAME make_migration() { echo "Creating migrations for $2" mkdir "../util/src/migrations/$2" - npm run build clean logerrors pretty-errors - THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle +# npm run build clean logerrors pretty-errors +# THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle THREADS=1 DATABASE="$1" DB_MIGRATE=a npx typeorm-ts-node-commonjs migration:generate "../util/src/migrations/$2/$FILENAME" -d ../util/src/util/Database.ts -p npm run build clean logerrors pretty-errors THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle diff --git a/bundle/scripts/gen_index.js b/bundle/scripts/gen_index.js new file mode 100644 index 00000000..71c64a9f --- /dev/null +++ b/bundle/scripts/gen_index.js @@ -0,0 +1,34 @@ +const path = require("path"); +const fs = require("fs"); +const { execIn, getLines, parts } = require('./utils'); + +if (!process.argv[2] || !fs.existsSync(process.argv[2])) { + console.log("Please pass a directory that exists!"); + process.exit(1); +} +console.log(`// ${process.argv[2]}/index.ts`) +const recurse = process.argv.includes("--recursive") + +const files = fs.readdirSync(process.argv[2]).filter(x => x.endsWith('.ts') && x != 'index.ts'); + +let output = ''; + +files.forEach(x => output += `export * from "./${x.replaceAll('.ts','')}";\n`) + +const dirs = fs.readdirSync(process.argv[2]).filter(x => { + try { + fs.readdirSync(path.join(process.argv[2], x)); + return true; + } catch (e) { + return false; + } +}); +dirs.forEach(x => { + output += `export * from "./${x}/index";\n` +}) +console.log(output); +fs.writeFileSync(path.join(process.argv[2], "index.ts"), output) + +dirs.forEach(x => { + if(recurse) console.log(execIn([process.argv[0], process.argv[1], `"${path.join(process.argv[2], x)}"`, "--recursive"].join(' '), process.cwd())) +}) \ No newline at end of file diff --git a/bundle/scripts/update_schemas.js b/bundle/scripts/update_schemas.js new file mode 100644 index 00000000..516b9592 --- /dev/null +++ b/bundle/scripts/update_schemas.js @@ -0,0 +1,9 @@ +const path = require("path"); +const fs = require("fs"); +const { env } = require("process"); +const { execSync } = require("child_process"); +const { argv, stdout, exit } = require("process"); + +const { execIn, getLines, parts } = require("./utils"); + +execIn("node scripts/generate_schema.js", path.join("..", "..", "api")); \ No newline at end of file diff --git a/bundle/scripts/utils.js b/bundle/scripts/utils.js index bf960532..f4b1ad7f 100644 --- a/bundle/scripts/utils.js +++ b/bundle/scripts/utils.js @@ -28,13 +28,14 @@ function copyRecursiveSync(src, dest) { } } -function execIn(cmd, workdir) { +function execIn(cmd, workdir, opts) { try { return execSync(cmd, { cwd: workdir, shell: true, env: process.env, encoding: "utf-8", + ...opts }); } catch (error) { return error.stdout; |