UNPKG

create-elysiajs

Version:

Scaffolding your Elysia project with the environment with easy!

89 lines (88 loc) 3.03 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.pmInstallFrozenLockfileProduction = exports.pmInstallFrozenLockfile = exports.pmLockFilesMap = exports.pmFilterMonorepoMap = exports.pmRunMap = exports.pmExecuteMap = exports.exec = exports.Preferences = void 0; exports.detectPackageManager = detectPackageManager; exports.createOrFindDir = createOrFindDir; const node_child_process_1 = __importDefault(require("node:child_process")); const node_crypto_1 = require("node:crypto"); const promises_1 = __importDefault(require("node:fs/promises")); const node_util_1 = require("node:util"); const nodeMajorVersion = process?.versions?.node?.split(".")[0]; if (nodeMajorVersion && Number(nodeMajorVersion) < 22) console.warn(`Node.js version ${process?.versions?.node} is not recommended for this template. Please upgrade to Node.js 22 or higher.`); function detectPackageManager() { const userAgent = process.env.npm_config_user_agent; if (!userAgent) throw new Error(`Package manager was not detected. Please specify template with "--pm bun"`); return userAgent.split(" ")[0].split("/")[0]; } async function createOrFindDir(path) { await promises_1.default.stat(path).catch(async () => promises_1.default.mkdir(path)); } class Preferences { projectName = ""; dir = ""; packageManager = "bun"; runtime = "Bun"; linter = "None"; orm = "None"; database = "PostgreSQL"; driver = "None"; git = true; others = []; plugins = []; // integration with create-gramio isMonorepo = false; docker = false; vscode = false; redis = false; locks = false; s3Client = "None"; meta = { databasePassword: (0, node_crypto_1.randomBytes)(12).toString("hex"), }; noInstall = false; mockWithPGLite = false; telegramRelated = false; } exports.Preferences = Preferences; exports.exec = (0, node_util_1.promisify)(node_child_process_1.default.exec); exports.pmExecuteMap = { npm: "npx", bun: "bun x", yarn: "yarn dlx", pnpm: "pnpm dlx", }; exports.pmRunMap = { npm: "npm run", bun: "bun", yarn: "yarn", pnpm: "pnpm", }; exports.pmFilterMonorepoMap = { npm: false, yarn: false, bun: "bun --filter 'apps/*'", pnpm: "pnpm --filter 'apps/*'", }; exports.pmLockFilesMap = { npm: "package.lock.json", bun: "bun.lock", yarn: "yarn.lock", pnpm: "pnpm-lock.yaml", }; exports.pmInstallFrozenLockfile = { npm: "npm ci", bun: "bun install --frozen-lockfile", yarn: "yarn install --frozen-lockfile", pnpm: "pnpm install --frozen-lockfile", }; exports.pmInstallFrozenLockfileProduction = { npm: "npm ci --production", bun: "bun install --frozen-lockfile --production", yarn: "yarn install --frozen-lockfile --production", pnpm: "pnpm install --frozen-lockfile --prod", };