@lunora/cli
Version:
The Lunora CLI: init, dev, deploy, codegen, run, reset, and migrate commands
42 lines (39 loc) • 1.51 kB
JavaScript
import { existsSync, rmSync } from 'node:fs';
import { join } from '@visulima/path';
import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
import { b as tuiConfirm } from '../packem_shared/tui-prompts-BjEN8XgP.mjs';
const runResetCommand = async (options) => {
const cwd = options.cwd ?? process.cwd();
const targets = [join(cwd, ".wrangler", "state")];
if (options.all) {
targets.push(join(cwd, ".lunora-cache"));
}
if (!options.yes) {
const isTty = process.stdin.isTTY;
if (!isTty && options.confirm === void 0) {
options.logger.error("reset: stdin is not a TTY — re-run with --yes to confirm deleting .wrangler/state");
return { code: 1, removed: [] };
}
const confirmer = options.confirm ?? tuiConfirm;
const confirmed = await confirmer("This will delete .wrangler/state. Continue?");
if (!confirmed) {
options.logger.info("reset: aborted");
return { code: 1, removed: [] };
}
}
const removed = [];
for (const target of targets) {
if (existsSync(target)) {
rmSync(target, { force: true, recursive: true });
removed.push(target);
options.logger.success(`removed ${target}`);
} else {
options.logger.info(`skipped (not present): ${target}`);
}
}
return { code: 0, removed };
};
const execute = defineHandler(
({ cwd, logger, options }) => runResetCommand({ all: options.all === true, cwd, logger, yes: options.yes === true })
);
export { execute, runResetCommand };