@lunora/cli
Version:
The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands
2 lines (1 loc) • 743 B
JavaScript
import{readFileSync as a}from"node:fs";import{join as c}from"node:path";import{DEV_VARS_FILE as s,parseDevVariableEntries as v}from"@lunora/config";const o="LUNORA_ADMIN_TOKEN",u=new Set(["127.0.0.1","::1","[::1]","localhost"]),f=e=>{if(e===void 0||e==="")return!0;try{return u.has(new URL(e).hostname)}catch{return!1}},d=e=>{let r;try{r=a(c(e,s),"utf8")}catch{return}const t=v(r).find(n=>n.key===o);return t?.value===""?void 0:t?.value},A=({cwd:e,token:r,url:t})=>{if(r!==void 0&&r!=="")return{source:"flag",token:r};const n=process.env[o];if(n!==void 0&&n!=="")return{source:"env",token:n};if(!f(t))return{};const i=d(e);return i===void 0?{}:{source:"dev-vars",token:i}},E=e=>e==="flag"?"--token":e==="env"?o:s;export{E as d,f as i,A as r};