@reliverse/rse
Version:
@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power
60 lines (59 loc) • 1.99 kB
JavaScript
import { getOrCreateRseConfig } from "@reliverse/cfg";
import { ensuredir } from "@reliverse/relifso";
import fs from "@reliverse/relifso";
import { relinka } from "@reliverse/relinka";
import { defineCommand } from "@reliverse/rempts";
import { cliName, useLocalhost } from "../../libs/sdk/constants.js";
import { showStartPrompt } from "../../libs/sdk/init/use-template/cp-modules/cli-main-modules/modules/showStartEndPrompt.js";
import { authCheck } from "../../libs/sdk/login/login-impl.js";
import { getOrCreateReliverseMemory } from "../../libs/sdk/utils/reliverseMemory.js";
import { getCurrentWorkingDirectory } from "../../libs/sdk/utils/terminalHelpers.js";
import { app } from "./impl.js";
export default defineCommand({
meta: {
name: "cli",
description: `Runs the ${cliName}`
},
args: {
dev: {
type: "boolean",
description: "Runs the CLI in dev mode"
},
cwd: {
type: "string",
description: "The working directory to run the CLI in",
required: false
}
},
run: async ({ args }) => {
const isDev = args.dev;
await showStartPrompt(isDev, false);
if (!process.versions.bun) {
relinka.warn(
"Rse is currently optimized for Bun only. Unexpected behavior may occur with other runtimes."
);
relinka.warn(
"To avoid issues, it's strongly recommended to install Bun: https://bun.sh/get"
);
}
let cwd;
if (args.cwd) {
cwd = args.cwd;
if (!await fs.pathExists(cwd)) {
await ensuredir(cwd);
}
} else {
cwd = getCurrentWorkingDirectory();
}
const memory = await getOrCreateReliverseMemory();
const { config, mrse } = await getOrCreateRseConfig({
projectPath: cwd,
isDev,
overrides: {}
});
await authCheck(isDev, memory, useLocalhost);
const updatedMemory = await getOrCreateReliverseMemory();
await app({ cwd, isDev, config, memory: updatedMemory, mrse });
process.exit(0);
}
});