create-backan
Version:
Quickly create a backan application to get started
82 lines (81 loc) • 2.18 kB
JavaScript
import { style, prompt, Creatium } from "creatium";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const name$1 = "backan";
const version$1 = "0.2.8";
const description = "All in one web API builder. Create endpoints with type validations and OpenApi documentation, safely and quickly.";
const homepage = "https://backan.pigeonposse.com";
const name = "create-backan";
const version = "0.2.8";
const {
color,
table
} = style;
const {
log,
box,
intro,
outro,
cancel
} = prompt;
const currentDir = join(dirname(fileURLToPath(import.meta.url)));
const dataDir = join(currentDir, "..", "data");
const templatesDir = join(dataDir, "templates");
const TEMPLATE = {
DEMO: "demo",
DEMO_TS: "demo-ts",
SKELETON: "skeleton",
SKELETON_TS: "skeleton-ts"
};
const setTable = (v) => table(v, {
drawHorizontalLine: () => false,
drawVerticalLine: () => false
});
const core = new Creatium({
name,
version,
consts: { version: version$1 },
onCancel: () => {
log.step("");
cancel(color.red("Process closed 💔"));
process.exit(0);
},
templates: {
[TEMPLATE.DEMO]: {
input: join(templatesDir, TEMPLATE.DEMO),
name: "Backan demo with JavaScript"
},
[TEMPLATE.DEMO_TS]: {
input: join(templatesDir, TEMPLATE.DEMO_TS),
name: "Backan demo with TypeScript"
},
[TEMPLATE.SKELETON]: {
input: join(templatesDir, TEMPLATE.SKELETON),
name: "Backan skeleton with JavaScript"
},
[TEMPLATE.SKELETON_TS]: {
input: join(templatesDir, TEMPLATE.SKELETON_TS),
name: "Backan skeleton with TypeScript"
}
},
intro: () => {
console.log();
intro(color.cyan.inverse(` ${name$1} `) + " 🔥");
log.step("");
const value = `${setTable([[description]])}
${setTable([["Package version", color.green(version$1)], ["Documentation", color.blue.italic.underline(homepage)]])}`;
box({
value: color.dim(value),
opts: {
padding: 0,
borderStyle: "none",
dimBorder: true
}
});
},
outro: () => outro(`Let's work with ${style.color.green(name$1)} 🔥`)
});
export {
TEMPLATE as T,
core as c
};