UNPKG

@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) 785 B
import{readFileSync as c}from"node:fs";import{join as v}from"node:path";import{DEV_VARS_FILE as i,parseDevVariableEntries as u}from"@lunora/config";const n="LUNORA_ADMIN_TOKEN",f=new Set(["127.0.0.1","::1","[::1]","localhost"]),a=e=>{if(e===void 0||e==="")return!0;try{return f.has(new URL(e).hostname)}catch{return!1}},d=e=>{let r;try{r=c(v(e,i),"utf8")}catch{return}const o=u(r).find(t=>t.key===n);return o?.value===""?void 0:o?.value},A=({cwd:e,token:r,url:o})=>{if(r!==void 0&&r!=="")return{source:"flag",token:r};const t=process.env[n];if(t!==void 0&&t!=="")return{source:"env",token:t};if(!a(o))return{};const s=d(e);return s===void 0?{}:{source:"dev-vars",token:s}},E=({prod:e,url:r})=>e===!0||r===""||!a(r),_=e=>e==="flag"?"--token":e==="env"?n:i;export{_ as d,A as r,E as t};