@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
42 lines (41 loc) • 1.38 kB
JavaScript
import { relinka } from "@reliverse/relinka";
import { defineCommand } from "@reliverse/rempts";
import { useLocalhost } from "../../libs/sdk/constants.js";
import { showAnykeyPrompt } from "../../libs/sdk/init/use-template/cp-modules/cli-main-modules/modules/showAnykeyPrompt.js";
import { auth } from "../../libs/sdk/login/login-impl.js";
import { getOrCreateReliverseMemory } from "../../libs/sdk/utils/reliverseMemory.js";
export default defineCommand({
meta: {
name: "login",
description: "Authenticate your device",
hidden: true
},
args: {
dev: {
type: "boolean",
description: "Run the CLI in dev mode"
}
},
run: async ({ args }) => {
const isDev = args.dev;
const memory = await getOrCreateReliverseMemory();
const isAuthenticated = memory.code && memory.key;
if (isAuthenticated) {
relinka("success", "You're already logged in.");
if (isDev) {
relinka("info", "Try `bun dev:logout` cmd.");
} else {
relinka("info", "Try `rse logout` cmd.");
}
process.exit(0);
}
await showAnykeyPrompt();
await auth({ isDev, useLocalhost });
if (isDev) {
relinka("success", "You can run `bun dev` now! Happy Reliversing! \u{1F389}");
} else {
relinka("success", "You can run `rse cli` now! Happy Reliversing! \u{1F389}");
}
process.exit(0);
}
});