diff --git a/api/bin/cli.js b/api/bin/cli.js index 75239a3ae..fccb2e043 100755 --- a/api/bin/cli.js +++ b/api/bin/cli.js @@ -6,22 +6,31 @@ import path from "node:path"; const args = process.argv.slice(2); const script = args[0]; +// HACK - if no script is specified, migrate then open studio +const scripts = !script ? ["migrate", "studio"] : [script]; + const validScripts = { migrate: "dist/migrate.js", studio: "dist/src/index.node.js", }; -if (!validScripts[script]) { - console.error( - `Invalid script "${script}". Valid scripts are: ${Object.keys(validScripts).join(", ")}`, - ); - process.exit(1); -} +scripts.forEach(runScript); + +function runScript(scriptName) { + const scriptPath = validScripts[scriptName]; + if (!scriptPath) { + console.error( + `Invalid script "${scriptName}". Valid scripts are: ${Object.keys(validScripts).join(", ")}`, + ); + process.exit(1); + } -// Get the root directory of this script's project -const scriptDir = path.resolve(__dirname, "../"); + // Get the root directory of this script's project + const scriptDir = path.resolve(__dirname, "../"); -// Construct the command to run the appropriate script in the `dist` folder -const command = `node ${path.join(scriptDir, validScripts[script])}`; + // Construct the command to run the appropriate script in the `dist` folder + const command = `node ${path.join(scriptDir, scriptPath)}`; + + execSync(command, { stdio: "inherit" }); +} -execSync(command, { stdio: "inherit" });