@yunarch/config-web
Version:
Shared configurations for web projects.
7 lines (6 loc) • 1.45 kB
JavaScript
import{c as r}from"../chunk-PWSW557X.js";import{execSync as p}from"child_process";import{styleText as u}from"util";import{execSync as l}from"child_process";import a from"@inquirer/select";async function i(){let t=l("npx turbo ls",{encoding:"utf8",stdio:"pipe"}).split(`
`).slice(1).map(e=>e.trim()).filter(Boolean).map(e=>e.split(" ")[0]);return await a({message:"Select a package to run the script:",choices:t.map(e=>({name:e,value:e}))})}async function c(){return await a({message:"Select a mode to load different env files:",choices:[{name:"development",value:"development"},{name:"staging",value:"staging"},{name:"production",value:"production"}]})}r().name("turbo-select").description(`A CLI tool to filter and select a single package from the Turborepo package list and run a script command.
Additionally, allow to prompt environment mode (development, staging, production), for example, when using Vite.`).requiredOption("--run <script>","The package script command to execute (e.g., --run=dev).").option("--select-env","An environment mode (development, staging, production) If using for example vite.").action(async({run:n,selectEnv:t})=>{try{console.log(u("magenta",`
\u{1F680} Turbo-Select
`));let e=await i(),o=t?await c():void 0;p(`turbo run ${n} --ui stream ${e?`--filter=${e}`:""} ${o?`-- --mode ${o}`:""}`,{encoding:"utf8",stdio:"inherit"})}catch(e){console.error(e),process.exit(1)}}).parseAsync(process.argv);