@blitzjs/cli
Version:
Blitz.js CLI
40 lines (39 loc) • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Console = void 0;
const tslib_1 = require("tslib");
const command_1 = require("@oclif/command");
const projectRoot = require("pkg-dir").sync() || process.cwd();
const isTypeScript = require("fs").existsSync(require("path").join(projectRoot, "tsconfig.json"));
class Console extends command_1.Command {
run() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
process.env.CLI_COMMAND_CONSOLE = "true";
this.parse(Console);
const { log } = require("next/dist/server/lib/logging");
const chalk = require("chalk");
log.branded("You have entered the Blitz console");
console.log(chalk.yellow("Tips: - Exit by typing .exit or pressing Ctrl-D"));
console.log(chalk.yellow(" - Use your db like this: await db.project.findMany()"));
console.log(chalk.yellow(" - Use your queries/mutations like this: await getProjects({})"));
if (isTypeScript) {
require("../utils/setup-ts-node").setupTsnode();
}
require("next/dist/cli/next-console").runRepl(Console.replOptions);
});
}
}
exports.Console = Console;
Console.description = "Run the Blitz console REPL";
Console.aliases = ["c"];
Console.replOptions = {
prompt: "⚡️ > ",
useColors: true,
};
Console.flags = {
help: command_1.flags.help({ char: "h" }),
env: command_1.flags.string({
char: "e",
description: "Set app environment name",
}),
};