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;
|