Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/excaliburjs/create-excalibur. A repo bootstrapping tool to get you started making your first games!
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156import * as child from "child_process";import * as fs from "fs";import * as os from "os";import { textMagenta, textYellow, terminal } from "./console.js";
// prompts transformersexport function transformerConfirm(value) { return value ? "Yes" : "No";}// prompts validatorsexport function validateProjectName(name) { if (name === "") return false; // if dir exists =>false return true;}// printsexport function printDocs() { terminal.listItem({ text: "Explore our Docs:", textRelevant: "https://excaliburjs.com/docs/", });}export function printProjectDirectory(projectDirectory) { terminal.listItem({ text: "Enter your directory:", textRelevant: `cd ./${projectDirectory}`, });}export function printDependencyStatus(status) { const text = "Dependencies:"; if (status) { terminal.listItem({ text, textRelevant: "Installed" }); } else { terminal.listItem({ text, textRelevant: "Not installed", colorRelevant: textYellow, }); }}export function printRepoStatus(status) { const text = "Git Repository:"; if (status) { terminal.listItem({ text, textRelevant: "Initialized", }); } else { terminal.listItem({ text, textRelevant: "Not initialized", colorRelevant: textYellow, }); }}//export function printDiscord() { terminal.listItem({ text: "Join our Discord:", textRelevant: "https://discord.com/invite/W6zUd4tTY3", colorRelevant: textMagenta, });}export function printSupport() { terminal.subtitle("If you find yourself stuck:"); printDiscord(); printDocs();}export function printActions(actions) { const { projectDirectory, dependencies } = actions; terminal.line(); terminal.warning(" Remember: "); terminal.blank(); terminal.listItem({ text: "You can find your project in:", textRelevant: `./${projectDirectory}`, }); if (dependencies) { terminal.listItem({ text: "Dependencies:", textRelevant: "Installed" }); } else { terminal.listItem({ text: "Dependencies:", textRelevant: "pending", colorRelevant: textYellow, }); } terminal.blank();}export function bye() { terminal.print("👋 See u soon."); terminal.line(); process.exit(1);}export function byeWithActions(actions) { printActions(actions); bye();}// Filesystemexport function isWindows() { return os.platform() === "win32";}export function runCommand(command, directory) { return new Promise((resolve, reject) => { child.exec(command, { cwd: directory }, (error, stdout, stderr) => { if (error) { reject(error); } resolve(); }); });}export function readFile(path, encoding = "utf-8") { return fs.readFileSync(path, encoding);}export function readDirectory(path) { return fs.readdirSync(path);}export function getResourceStats(path) { return fs.statSync(path);}export function writeFile(path, content, encoding = "utf-8") { fs.writeFileSync(path, content, encoding);}export function removeFile(path) { try { fs.unlinkSync(path); } catch (err) { console.error(err.message); }}export function removeFolder(path) { try { fs.rmSync(path, { recursive: true, force: true }); } catch (err) { console.error(err.message); }}
// formatterexport function slugify(str) { str = str.replace(/^\s+|\s+$/g, ""); str = str.toLowerCase(); str = str .replace(/[^a-z0-9 -]/g, "") .replace(/\s+/g, "-") .replace(/-+/g, "-"); return str;}
// arraysexport function sortByProp(a, b, prop) { if (a[prop] < b[prop]) return -1; if (a[prop] > b[prop]) return 1; return 0;}