@every-app/cli 0.0.32 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{a as o,c as s}from"./chunk-MPFJVWFO.js";import{proposeCompletions as r}from"@stricli/core";var t=process.argv.slice(3);process.env.COMP_LINE?.endsWith(" ")&&t.push("");await r(s,t,o(process));try{for(let{completion:p}of await r(s,t,o(process)))process.stdout.write(`${p}
2
+ import{a as o,c as s}from"./chunk-DHUHTMCZ.js";import{proposeCompletions as r}from"@stricli/core";var t=process.argv.slice(3);process.env.COMP_LINE?.endsWith(" ")&&t.push("");await r(s,t,o(process));try{for(let{completion:p}of await r(s,t,o(process)))process.stdout.write(`${p}
3
3
  `)}catch{}
@@ -1,5 +1,5 @@
1
- import p from"node:fs";import l from"node:os";import d from"node:path";function A(e){return{process:e,os:l,fs:p,path:d}}import{buildApplication as g,buildRouteMap as C}from"@stricli/core";import{buildInstallCommand as D,buildUninstallCommand as v}from"@stricli/auto-complete";var r="@every-app/cli";var n="Every App CLI - Deploy and manage apps.";var a="0.0.32";import{buildCommand as o,buildRouteMap as m}from"@stricli/core";var c=o({loader:async()=>import("./create-O3KRSXQT.js"),parameters:{positional:{kind:"tuple",parameters:[{brief:"App ID (kebab-case format)",parse:String,optional:!0}]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during creation",optional:!0}}},docs:{brief:"Create a new app from the starter template",fullDescription:["Copies the simple-todo starter template, deploys to Cloudflare, and configures local development.","","Usage: every app create [name]","","The command will:"," 1. Prompt for app ID (or use provided name)"," 2. Deploy to Cloudflare (D1 database, KV namespace, Worker)"," 3. Configure wrangler.jsonc, package.json, and .env files"," 4. Install dependencies and run local migrations","","After creation, run 'pnpm run dev' to start developing."].join(`
2
- `)}}),u=o({loader:async()=>{let{deploy:e}=await import("./deploy-24IDURFP.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during deployment",optional:!0}}},docs:{brief:"Deploy an app to Cloudflare",fullDescription:["Deploys the current app to Cloudflare Workers from the current directory.","The deployment process:"," 1. Reads wrangler.jsonc to determine required resources"," 2. Creates or links D1 databases and KV namespaces"," 3. Updates wrangler.jsonc with resource IDs"," 4. Installs dependencies if needed"," 5. Runs database migrations against production D1"," 6. Builds and deploys using wrangler deploy"].join(`
1
+ import p from"node:fs";import l from"node:os";import d from"node:path";function A(e){return{process:e,os:l,fs:p,path:d}}import{buildApplication as g,buildRouteMap as C}from"@stricli/core";import{buildInstallCommand as D,buildUninstallCommand as v}from"@stricli/auto-complete";var r="@every-app/cli";var n="Every App CLI - Deploy and manage apps.";var a="0.0.34";import{buildCommand as o,buildRouteMap as m}from"@stricli/core";var c=o({loader:async()=>import("./create-FZ45IJ4Y.js"),parameters:{positional:{kind:"tuple",parameters:[{brief:"App ID (kebab-case format)",parse:String,optional:!0}]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during creation",optional:!0}}},docs:{brief:"Create a new app from the starter template",fullDescription:["Copies the simple-todo starter template, deploys to Cloudflare, and configures local development.","","Usage: every app create [name]","","The command will:"," 1. Prompt for app ID (or use provided name)"," 2. Deploy to Cloudflare (D1 database, KV namespace, Worker)"," 3. Configure wrangler.jsonc, package.json, and .env files"," 4. Install dependencies and run local migrations","","After creation, run 'pnpm run dev' to start developing."].join(`
2
+ `)}}),u=o({loader:async()=>{let{deploy:e}=await import("./deploy-6KAI5EUZ.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during deployment",optional:!0}}},docs:{brief:"Deploy an app to Cloudflare",fullDescription:["Deploys the current app to Cloudflare Workers from the current directory.","The deployment process:"," 1. Reads wrangler.jsonc to determine required resources"," 2. Creates or links D1 databases and KV namespaces"," 3. Updates wrangler.jsonc with resource IDs"," 4. Installs dependencies if needed"," 5. Runs database migrations against production D1"," 6. Builds and deploys using wrangler deploy"].join(`
3
3
  `)}}),y=o({loader:async()=>{let{remoteD1Shell:e}=await import("./remoteD1Shell-L74YWFTK.js");return e},parameters:{flags:{},positional:{kind:"array",parameter:{brief:"Command and arguments to run with environment variables",parse:String}}},docs:{brief:"Run a command with Cloudflare D1 connection environment variables",fullDescription:["Sets environment variables needed to connect to remote Cloudflare D1 and runs any command that requires D1 access.","","The command will:"," 1. Get the Cloudflare account ID"," 2. Look up the database ID from the database name in wrangler.jsonc"," 3. Get a valid OAuth token"," 4. Run the provided command with CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_DATABASE_ID, CLOUDFLARE_API_TOKEN, and MIGRATE_REMOTE set","","Common use cases:"," - Running Drizzle migrations: npx @every-app/cli app remote-d1-shell -- npx drizzle-kit migrate"," - Opening Drizzle Studio: npx @every-app/cli app remote-d1-shell -- npx drizzle-kit studio"," - Pushing schema changes: npx @every-app/cli app remote-d1-shell -- npx drizzle-kit push","","This command is useful for any operation that needs direct access to your production D1 database."].join(`
4
- `)}}),i=m({routes:{create:c,deploy:u,"remote-d1-shell":y},docs:{brief:"App management commands"}});import{buildCommand as f,buildRouteMap as b}from"@stricli/core";var h=f({loader:async()=>{let{deploy:e}=await import("./deploy-ETXZH2KV.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{repo:{kind:"parsed",parse:String,brief:"Git repository URL to deploy",optional:!0},verbose:{kind:"boolean",brief:"Show detailed output during deployment",optional:!0},localGateway:{kind:"parsed",parse:String,brief:"Path to local gateway tarball (for testing)",optional:!0}}},docs:{brief:"Deploy the gateway application to Cloudflare",fullDescription:["Clones the gateway repository, installs dependencies, runs migrations, and deploys to Cloudflare Workers.","The deployment process:"," 1. Clones the repository to a temporary directory"," 2. Installs npm dependencies"," 3. Runs database migrations against production D1"," 4. Runs wrangler deploy"," 5. Cleans up temporary files"].join(`
4
+ `)}}),i=m({routes:{create:c,deploy:u,"remote-d1-shell":y},docs:{brief:"App management commands"}});import{buildCommand as f,buildRouteMap as b}from"@stricli/core";var h=f({loader:async()=>{let{deploy:e}=await import("./deploy-O47BNGCV.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{repo:{kind:"parsed",parse:String,brief:"Git repository URL to deploy",optional:!0},verbose:{kind:"boolean",brief:"Show detailed output during deployment",optional:!0},localGateway:{kind:"parsed",parse:String,brief:"Path to local gateway tarball (for testing)",optional:!0}}},docs:{brief:"Deploy the gateway application to Cloudflare",fullDescription:["Clones the gateway repository, installs dependencies, runs migrations, and deploys to Cloudflare Workers.","The deployment process:"," 1. Clones the repository to a temporary directory"," 2. Installs npm dependencies"," 3. Runs database migrations against production D1"," 4. Runs wrangler deploy"," 5. Cleans up temporary files"].join(`
5
5
  `)}}),s=b({routes:{deploy:h},docs:{brief:"Gateway management commands"}});var w=C({routes:{app:i,gateway:s,install:D("every",{bash:"__every_bash_complete"}),uninstall:v("every",{bash:!0})},docs:{brief:n,hideRoute:{install:!0,uninstall:!0}}}),M=g(w,{name:r,versionInfo:{currentVersion:a},scanner:{allowArgumentEscapeSequence:!0}});export{A as a,a as b,M as c};
@@ -0,0 +1,20 @@
1
+ import{d as m,e as p,f as h,g as x,m as O,n as b,o as C,r as I,u as k}from"./chunk-CKXY3PLB.js";import L from"enquirer";import A from"chalk";async function N(){if(process.env.CLOUDFLARE_API_TOKEN){let n=process.env.CLOUDFLARE_ACCOUNT_ID;return n||(console.log(A.yellow(`
2
+ CLOUDFLARE_ACCOUNT_ID is required when using CLOUDFLARE_API_TOKEN
3
+ `)),process.exit(1)),h(n)}let o=await O(),{account:e,otherAccounts:t}=C(o);return b(e,t),{id:e.account.id,name:e.account.name}}async function V(o="this"){let e=await N();process.env.CLOUDFLARE_API_TOKEN&&(console.log(A.dim(` ${e.name} (${e.id})`)),console.log());let{confirm:t}=await L.prompt({type:"confirm",name:"confirm",message:`Do you want to deploy ${o} to ${e.name}?`,initial:!1});return t}import u from"chalk";var D="every-app-gateway";async function X(o){try{return await fetch(o,{method:"HEAD",signal:AbortSignal.timeout(5e3)}),!0}catch(e){let t=e instanceof Error?e.message.toLowerCase():"",n=e instanceof Error&&"cause"in e&&e.cause?.code?.toLowerCase()||"";return!["ssl","tls","certificate","cert","cipher","handshake","secure"].some(i=>t.includes(i)||n.includes(i))}}async function W(o){try{let e=await fetch(`${o}/api/admin/has-owner`);return e.ok?(await e.json()).hasOwner:!1}catch{return!1}}async function _(){try{let o=await p();return await m(`/accounts/${o}/workers/scripts/${D}/settings`),!0}catch{return!1}}async function E(){return x(D)}async function G(){if(!await _())return{isDeployed:!1,hasOwner:!1,gatewayUrl:await E()};let e=await E();return{isDeployed:!0,hasOwner:await W(e),gatewayUrl:e}}async function Z(){let{isDeployed:o,hasOwner:e,gatewayUrl:t}=await G();if(o||(console.log(u.yellow(`
4
+ Gateway not deployed
5
+ `)),console.log(`You need to deploy the Every App Gateway before creating or deploying apps.
6
+ `),console.log(u.dim(` Run: npx @every-app/cli gateway deploy
7
+ `)),process.exit(1)),!e){let n=`${t}/sign-up`;console.log(u.yellow(`
8
+ Owner account required
9
+ `)),console.log(`You need to create an owner account on your Gateway before deploying apps.
10
+ `),console.log(` ${u.cyan(n)}
11
+ `),console.log(u.dim(` Visit the URL above to create your owner account, then run this command again.
12
+ `)),process.exit(1)}return t}import{execa as M}from"execa";import{execa as g}from"execa";import c from"chalk";async function d(o,e,t){let{env:n,cwd:s,verbose:r=!1,description:i,logCommandToConsole:l=!0}=t;return r?F(o,e,t):l?(console.log(`Running: ${o} ${e.join(" ")}`),i&&console.log(c.dim(` ${i}`)),await g(o,e,{cwd:s,env:n,stdio:"pipe"})):await g(o,e,{cwd:s,env:n,stdio:"pipe"})}async function F(o,e,{description:t,cwd:n,env:s}){console.log(c.dim(` \u250C\u2500 Running: ${o} ${e.join(" ")}`)),t&&console.log(c.dim(` \u2502 ${t}`));let r=g(o,e,{cwd:n,env:s,stdio:void 0,all:!0});r.stdout&&r.stdout.on("data",l=>{l.toString().split(`
13
+ `).forEach(a=>{a.trim()&&console.log(c.dim(` \u2502 ${a}`))})}),r.stderr&&r.stderr.on("data",l=>{l.toString().split(`
14
+ `).forEach(a=>{a.trim()&&console.error(c.dim(` \u2502 ${a}`))})});let i=await r;return console.log(c.dim(` \u2514\u2500 Complete
15
+ `)),i}async function T(){try{return await M("pnpm",["--version"],{stdio:"pipe"}),!0}catch{return!1}}async function ie({cwd:o,description:e,verbose:t=!1}){let n=await T();try{n?await d("pnpm",["install"],{cwd:o,verbose:t,description:e}):await d("npx",["pnpm","install"],{cwd:o,verbose:t,description:e})}catch(s){throw new Error(`Failed to install dependencies with pnpm: ${s instanceof Error?s.message:"Unknown error"}`)}}import P from"chalk";import S from"chalk";function le(o,e){o&&console.log(S.dim(e))}function $(o,...e){o&&e.forEach(t=>console.log(S.dim(t)))}var v="npx",R=["drizzle-kit","migrate","--config=drizzle-prod.config.ts"];async function ge({cwd:o,verbose:e=!1}){console.log(`
16
+ Running: ${v} ${R.join(" ")}`),console.log(P.dim(" Running database migrations...")),$(e," Running any pending migrations against your remote D1 Database..."),await k(v,R,{cwd:o,verbose:e}),console.log(P.dim(` Migrations completed.
17
+ `))}import f from"chalk";import z from"node:path";async function w(o){let e=await p(),t=z.join(o,"wrangler.jsonc"),n=await I(t);return{accountId:e,workerName:n}}async function U(o){return await m(`/accounts/${o.accountId}/workers/scripts/${o.workerName}/secrets`)}async function Oe({cwd:o}){let e=await w(o);return(await U(e)).map(n=>n.name)}async function be({secretName:o,cwd:e,verbose:t=!1}){t&&console.log(f.dim(` Checking secret: ${o}`));let n=await w(e),r=(await U(n)).some(i=>i.name===o);return r&&t&&console.log(f.dim(` Secret already exists
18
+ `)),r}async function Ce({secretName:o,secretValue:e,cwd:t,verbose:n=!1,description:s}){n&&s&&console.log(f.dim(` ${s}
19
+ `));let r=await w(t);await m(`/accounts/${r.accountId}/workers/scripts/${r.workerName}/secrets`,{method:"PUT",body:JSON.stringify({name:o,text:e,type:"secret_text"})}),n&&console.log(f.green(`Created secret: ${o}
20
+ `))}export{V as a,d as b,X as c,W as d,Z as e,ie as f,le as g,$ as h,ge as i,Oe as j,be as k,Ce as l};
@@ -1,4 +1,4 @@
1
- import{b as A,e as O,h as _,i as G,j as V}from"./chunk-UMTKYAFW.js";import{a as v,c as k,e as y,g as D,h as x,i as $,j as P,k as S,l as w,q as T,s as N}from"./chunk-CKXY3PLB.js";import j from"node:fs/promises";import B from"node:path";import*as L from"jsonc-parser";import{z as g}from"zod";var F="every-app.jsonc",Q=g.object({appId:g.string().min(1,"appId cannot be empty"),displayName:g.string().min(1,"displayName cannot be empty").optional(),description:g.string().optional()});async function C(t){let o=B.join(t,F);try{let e=await j.readFile(o,"utf-8"),r=L.parse(e);return Q.parse(r)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")throw new Error("every-app.jsonc not found. Make sure you're running this command from an Every App project directory.");if(e instanceof g.ZodError){let r=e.issues.map(n=>n.message).join(", ");throw new Error(`Invalid every-app.jsonc: ${r}`)}throw e}}function z(t){return t.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}async function ae(t,o){let e=B.join(t,F),r={...o,displayName:o.displayName??z(o.appId)},n=JSON.stringify(r,null,2)+`
1
+ import{b as A,f as O,i as _,k as G,l as V}from"./chunk-RLQ3UZVU.js";import{a as v,c as k,e as y,g as D,h as x,i as $,j as P,k as S,l as w,q as T,s as N}from"./chunk-CKXY3PLB.js";import j from"node:fs/promises";import B from"node:path";import*as L from"jsonc-parser";import{z as g}from"zod";var F="every-app.jsonc",Q=g.object({appId:g.string().min(1,"appId cannot be empty"),displayName:g.string().min(1,"displayName cannot be empty").optional(),description:g.string().optional()});async function C(t){let o=B.join(t,F);try{let e=await j.readFile(o,"utf-8"),r=L.parse(e);return Q.parse(r)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")throw new Error("every-app.jsonc not found. Make sure you're running this command from an Every App project directory.");if(e instanceof g.ZodError){let r=e.issues.map(n=>n.message).join(", ");throw new Error(`Invalid every-app.jsonc: ${r}`)}throw e}}function z(t){return t.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}async function ae(t,o){let e=B.join(t,F),r={...o,displayName:o.displayName??z(o.appId)},n=JSON.stringify(r,null,2)+`
2
2
  `;await j.writeFile(e,n)}async function ie(t){return(await C(t)).appId}import c from"chalk";async function K({appId:t,needsR2Bucket:o=!1,verbose:e=!1}){console.log(`
3
3
  Setting up your Cloudflare ${o?"D1 Database, KV Store, and R2 Bucket":"D1 Database and KV Store"}...
4
4
  `);let n=await y(),s=v(t),i;o&&(i=await H(s,n,e));let a=await Y(s,n,e),p=await J(s,n,e);return{d1DatabaseId:a,kvNamespaceId:p,r2BucketName:i,resourceName:s}}async function Y(t,o,e){e&&(console.log(c.bold(`Processing D1 database...
@@ -1,4 +1,4 @@
1
- import{a as k,c as v}from"./chunk-XEU3RC3D.js";import{a as f,b as u,c as y,d as w,e as h}from"./chunk-5HDAPJSF.js";import{a as C,b as a,d as x}from"./chunk-UMTKYAFW.js";import{b as g}from"./chunk-CKXY3PLB.js";import d from"chalk";async function P({url:o,targetDir:e,verbose:t=!1}){try{await a("git",["clone",o,e],{verbose:t,logCommandToConsole:!1})}catch(r){throw new Error(`Failed to clone repository from ${o}: ${r instanceof Error?r.message:"Unknown error"}`)}}async function b({targetDir:o,verbose:e=!1}){try{await a("git",["init"],{verbose:e,logCommandToConsole:!1,cwd:o}),await a("git",["add","."],{verbose:e,logCommandToConsole:!1,cwd:o}),await a("git",["commit","-m","Starter template"],{verbose:e,logCommandToConsole:!1,cwd:o})}catch(t){throw new Error(`Failed to initialize git repository: ${t instanceof Error?t.message:"Unknown error"}`)}}import N from"node:fs/promises";import S from"node:path";import c from"chalk";var J=["every-app.jsonc","every-app.json"];async function T(){let o=process.cwd();for(let e of J){let t=S.join(o,e);try{await N.access(t),console.log(c.yellow(`
1
+ import{a as k,c as v}from"./chunk-W4QHFDVZ.js";import{a as f,b as u,c as y,d as w,e as h}from"./chunk-5HDAPJSF.js";import{a as C,b as a,e as x}from"./chunk-RLQ3UZVU.js";import{b as g}from"./chunk-CKXY3PLB.js";import d from"chalk";async function P({url:o,targetDir:e,verbose:t=!1}){try{await a("git",["clone",o,e],{verbose:t,logCommandToConsole:!1})}catch(r){throw new Error(`Failed to clone repository from ${o}: ${r instanceof Error?r.message:"Unknown error"}`)}}async function b({targetDir:o,verbose:e=!1}){try{await a("git",["init"],{verbose:e,logCommandToConsole:!1,cwd:o}),await a("git",["add","."],{verbose:e,logCommandToConsole:!1,cwd:o}),await a("git",["commit","-m","Starter template"],{verbose:e,logCommandToConsole:!1,cwd:o})}catch(t){throw new Error(`Failed to initialize git repository: ${t instanceof Error?t.message:"Unknown error"}`)}}import N from"node:fs/promises";import S from"node:path";import c from"chalk";var J=["every-app.jsonc","every-app.json"];async function T(){let o=process.cwd();for(let e of J){let t=S.join(o,e);try{await N.access(t),console.log(c.yellow(`
2
2
  Already inside an Every App project`)),console.log(c.dim(` Found ${e}
3
3
  `)),console.log(`To create a new app, run app create from the directory where you store your projects.
4
4
  `),console.log("If you meant to deploy this app, run:"),console.log(c.dim(` npx @every-app/cli app deploy
@@ -0,0 +1,10 @@
1
+ import{b as s,c as i}from"./chunk-W4QHFDVZ.js";import{a,e as l}from"./chunk-RLQ3UZVU.js";import{b as p}from"./chunk-CKXY3PLB.js";import o from"chalk";import d from"node:fs/promises";import w from"node:path";import c from"chalk";var g=["every-app.jsonc","every-app.json"];async function m(){let r=process.cwd();for(let e of g){let t=w.join(r,e);try{await d.access(t);return}catch{}}console.log(c.yellow(`
2
+ Not inside an Every App project`)),console.log(c.dim(` No every-app.jsonc found
3
+ `)),console.log("To create a new app, run the below command from the directory where you store your projects:"),console.log(c.dim(` npx @every-app/cli app create
4
+ `)),process.exit(1)}async function F(r){await p(),await l();let e=process.cwd(),t=r.verbose||!1;await m();let n=await s(e);if(console.log(o.bold(`
5
+ Project: ${n}
6
+ `)),!await a("this app")){console.log(o.red(`
7
+ Deployment cancelled by user
8
+ `));return}let{workerUrl:f,gatewayUrl:y}=await i({cwd:e,appId:n,verbose:t});console.log(o.green(`
9
+ Deployment successful!`)),console.log(o.dim(` App URL: ${o.cyan(f)}`)),console.log(` Gateway: ${o.cyan(y)}
10
+ `)}export{F as deploy};
@@ -0,0 +1,41 @@
1
+ import{d as _,e as D}from"./chunk-5HDAPJSF.js";import{a as W,b as v,c as w,d as u,f as K,g as y,h as S,i as L,j as P,l as d}from"./chunk-RLQ3UZVU.js";import{b as C,e as T,g as b,i as A,j as R,l as k,p as x,q as G,r as $}from"./chunk-CKXY3PLB.js";import m from"chalk";import pe from"node:path";import c from"chalk";var H="every-app-gateway",z="every-app-gateway";async function U({verbose:e=!1}={}){console.log(`
2
+ Setting up your Cloudflare D1 Database and KV Store...
3
+ `);let t=await T(),a=await j(H,t,e),o=await q(z,t,e);return console.log(),{d1DatabaseId:a,kvNamespaceId:o,accountId:t}}async function j(e,t,a){a&&console.log(` Checking D1 database: ${e}`);let o=await A(e,t);return a?o.wasCreated?console.log(c.green(` Created D1 database: ${e} (${o.id})
4
+ `)):console.log(c.dim(` Linking to existing D1 database: ${e} (${o.id})
5
+ `)):o.wasCreated?console.log(c.green(` D1 successfully created.
6
+ `)):console.log(" D1 already set up."),o.id}async function q(e,t,a){a&&console.log(` Checking KV namespace: ${e}`);let o=await R(e,t);return a?o.wasCreated?console.log(c.green(` Created KV namespace: ${e} (${o.id})
7
+ `)):console.log(c.dim(` Linking to existing KV namespace: ${e} (${o.id})
8
+ `)):o.wasCreated?console.log(c.green(" KV successfully created.")):console.log(" KV already set up."),o.id}import Z from"node:crypto";import ee from"node:path";import I from"node:crypto";import p from"chalk";function Q(){return I.randomBytes(32).toString("base64")}function X(){let{privateKey:e,publicKey:t}=I.generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:e,publicKey:t}}async function O({gatewayUrl:e,gatewayPath:t,verbose:a=!1}){try{let o=new Set(await P({cwd:t})),n=o.has("GATEWAY_URL"),i=o.has("BETTER_AUTH_SECRET"),s=o.has("JWT_PRIVATE_KEY"),g=o.has("JWT_PUBLIC_KEY"),E=!i||!s||!g;if(E&&(console.log("Configuring secrets for the authentication service (Better Auth)..."),console.log(p.dim(" BETTER_AUTH_SECRET - Session signing and encryption")),console.log(p.dim(" JWT_PRIVATE_KEY - Signs JWTs issued to your apps")),console.log(p.dim(" JWT_PUBLIC_KEY - Apps use this to verify JWTs")),console.log()),n||await d({secretName:"GATEWAY_URL",secretValue:e,cwd:t,verbose:a,description:`Setting GATEWAY_URL to: ${e}`}),!i){let r=Q();await d({secretName:"BETTER_AUTH_SECRET",secretValue:r,cwd:t,verbose:a,description:"Generating new Better Auth secret..."})}if(s&&g)a&&console.log(p.dim(` JWT key pair already exists
9
+ `));else if(!s&&!g){a&&console.log(p.dim(` Generating new JWT key pair...
10
+ `));let r=X();await d({secretName:"JWT_PRIVATE_KEY",secretValue:r.privateKey,cwd:t,verbose:a}),await d({secretName:"JWT_PUBLIC_KEY",secretValue:r.publicKey,cwd:t,verbose:a}),a&&console.log(p.green(`Created JWT key pair secrets
11
+ `))}else throw new Error("JWT key pair is incomplete. Both JWT_PRIVATE_KEY and JWT_PUBLIC_KEY must exist together. Please delete the existing key and redeploy.");E&&console.log(a?`Secret setup complete!
12
+ `:` Finished.
13
+ `)}catch(o){throw console.error(`
14
+ Failed to setup secrets`,o instanceof Error?`
15
+ ${o.message}`:""),o}}async function J({gatewayPath:e,resources:t,workerUrl:a,verbose:o=!1}){let n=ee.join(e,"dist","server","wrangler.json");await G({configPath:n,d1DatabaseId:t.d1DatabaseId,kvNamespaceId:t.kvNamespaceId,verbose:o});let i=Z.randomUUID();console.log(),await v("npx",["wrangler","deploy"],{cwd:e,description:`Deploying your Gateway to Cloudflare workers...
16
+
17
+ This could take up to a minute.`,env:{...process.env,BETTER_AUTH_SECRET:i},verbose:o}),console.log(),await O({gatewayUrl:a,gatewayPath:e,verbose:o})}import h from"node:fs";import te from"node:path";import{Readable as oe}from"node:stream";import{pipeline as ae}from"node:stream/promises";import{createWriteStream as re}from"node:fs";import{spawn as ne}from"node:child_process";var ie="every-app",se="every-app",V="every-app-gateway-build.tar.gz";function le(){return`https://github.com/${ie}/${se}/releases/download/gateway-latest/${V}`}async function ce(e,t){let a=await fetch(e,{redirect:"follow"});if(!a.ok)throw new Error(`Failed to download file: ${a.status} ${a.statusText}`);if(!a.body)throw new Error("Response body is null");let o=re(t),n=oe.fromWeb(a.body);await ae(n,o)}async function Y(e,t){return new Promise((a,o)=>{let n=ne("tar",["-xzf",e,"-C",t]);n.on("error",o),n.on("close",i=>{i===0?a():o(new Error(`tar extraction failed with code ${i}`))})})}async function B(e,t=!1){console.log("Getting latest gateway release..."),h.mkdirSync(e,{recursive:!0});let a=le();y(t,`URL: ${a}`);let o=te.join(e,V);try{await ce(a,o)}catch(n){throw n instanceof Error&&n.message.includes("404")?new Error("Gateway release not found. Make sure a release has been published."):n}return S(t,`Downloaded to: ${o}`,"Extracting archive..."),await Y(o,e),h.unlinkSync(o),y(t,`Extraction complete
18
+ `),e}async function N(e,t,a=!1){if(console.log("Using local gateway tarball..."),!h.existsSync(e))throw new Error(`Local gateway tarball not found: ${e}`);return h.mkdirSync(t,{recursive:!0}),S(a,`Tarball: ${e}`,"Extracting archive..."),await Y(e,t),y(a,`Extraction complete
19
+ `),t}import l from"chalk";async function F({workerUrl:e,maxWaitMs:t=12e4,pollIntervalMs:a=3e3}){let o=`${e}/sign-up`;console.log(l.green(`
20
+ Gateway deployment successful!
21
+ `)),console.log(`Your Gateway will be available at: ${l.cyan(o)}
22
+ `),console.log(l.dim("Waiting for SSL certificate to be provisioned..."));let n=Date.now();for(;Date.now()-n<t;)if(await new Promise(i=>setTimeout(i,a)),await w(e)){console.log(l.green(`SSL certificate is ready!
23
+ `)),await u(e)?console.log(`Your Gateway is now live at: ${l.cyan(e)}
24
+ `):(console.log(`Your Gateway is now live at: ${l.cyan(o)}
25
+ `),console.log(l.dim(` Create an owner account to get started with your Gateway.
26
+ `)));return}console.log(l.yellow(`
27
+ SSL certificate is still being provisioned. This can take a few minutes.
28
+ `)),console.log(l.dim(` The URL above will be accessible once the SSL certificate is ready.
29
+ `)),console.log(l.dim(` Create an owner account to get started with your Gateway.
30
+ `))}async function je(e){await C();let t=e.verbose||!1,a=e.localGateway;if(console.log(m.bold(`
31
+ Every App Gateway
32
+ `)),!await W("the Gateway")){console.log(`
33
+ Deployment cancelled by user
34
+ `);return}await x();let n=await U({verbose:t}),i=await _("gateway-deploy-");t&&console.log(m.dim(`Working directory: ${i}
35
+ `));let s=null;try{let r=a?await N(a,i,t):await B(i,t),f=pe.join(r,"wrangler.jsonc"),M=await $(f);s=await b(M),await J({gatewayPath:r,resources:n,workerUrl:s,verbose:t}),await K({cwd:r,verbose:t,description:"Installing dependencies for migrations..."}),await L({cwd:r,verbose:t})}catch(r){let f=await k(r);throw f&&(console.log(f.formatted),process.exit(1)),console.error(`
36
+ Deployment failed:`,r instanceof Error?r.message:r),r}finally{await D({tmpDir:i,verbose:t})}if(!s)throw new Error("Worker URL not set properly during deployment");if(!await w(s)){await F({workerUrl:s});return}if(console.log(m.green(`
37
+ Gateway deployment successful!
38
+ `)),await u(s))console.log(`Your Gateway is now live at: ${m.cyan(s)}
39
+ `);else{let r=`${s}/sign-up`;console.log(`Your Gateway is now live at: ${m.cyan(r)}
40
+ `),console.log(m.dim(` Create an owner account to get started with your Gateway.
41
+ `))}}export{je as deploy};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as c,b as r,c as p}from"./chunk-MPFJVWFO.js";import{run as b}from"@stricli/core";import n from"chalk";var f="https://registry.npmjs.org/@every-app/cli?fields=dist-tags",g=2e3;async function d(){try{let t=new AbortController,s=setTimeout(()=>t.abort(),g),e=await fetch(f,{signal:t.signal});return clearTimeout(s),e.ok?(await e.json())["dist-tags"].latest:null}catch{return null}}function h(t,s){let e=t.split(".").map(Number),i=s.split(".").map(Number);for(let o=0;o<Math.max(e.length,i.length);o++){let a=e[o]??0,l=i[o]??0;if(a<l)return!0;if(a>l)return!1}return!1}function u(){return d().then(t=>t&&t!==r&&h(r,t)?{updateAvailable:!0,latestVersion:t,currentVersion:r}:{updateAvailable:!1,currentVersion:r})}function m(t){t.updateAvailable&&t.latestVersion&&(console.log(),console.log(n.yellow(` Update available: ${t.currentVersion} \u2192 ${t.latestVersion}`)),console.log(n.dim(` npx: ${n.cyan("npx @every-app/cli@latest")}`)),console.log(n.dim(` global: ${n.cyan("npm update -g @every-app/cli")}`)))}var v=u();await b(p,process.argv.slice(2),c(process));var C=await v;m(C);
2
+ import{a as c,b as r,c as p}from"./chunk-DHUHTMCZ.js";import{run as b}from"@stricli/core";import n from"chalk";var f="https://registry.npmjs.org/@every-app/cli?fields=dist-tags",g=2e3;async function d(){try{let t=new AbortController,s=setTimeout(()=>t.abort(),g),e=await fetch(f,{signal:t.signal});return clearTimeout(s),e.ok?(await e.json())["dist-tags"].latest:null}catch{return null}}function h(t,s){let e=t.split(".").map(Number),i=s.split(".").map(Number);for(let o=0;o<Math.max(e.length,i.length);o++){let a=e[o]??0,l=i[o]??0;if(a<l)return!0;if(a>l)return!1}return!1}function u(){return d().then(t=>t&&t!==r&&h(r,t)?{updateAvailable:!0,latestVersion:t,currentVersion:r}:{updateAvailable:!1,currentVersion:r})}function m(t){t.updateAvailable&&t.latestVersion&&(console.log(),console.log(n.yellow(` Update available: ${t.currentVersion} \u2192 ${t.latestVersion}`)),console.log(n.dim(` npx: ${n.cyan("npx @every-app/cli@latest")}`)),console.log(n.dim(` global: ${n.cyan("npm update -g @every-app/cli")}`)))}var v=u();await b(p,process.argv.slice(2),c(process));var C=await v;m(C);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "Every App CLI - Deploy and manage apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.32",
7
+ "version": "0.0.34",
8
8
  "files": [
9
9
  "dist"
10
10
  ],
@@ -1,20 +0,0 @@
1
- import{d as m,e as p,f as y,g as h,m as x,n as O,o as b,r as C,u as I}from"./chunk-CKXY3PLB.js";import S from"enquirer";import k from"chalk";async function L(){if(process.env.CLOUDFLARE_API_TOKEN){let t=process.env.CLOUDFLARE_ACCOUNT_ID;return t||(console.log(k.yellow(`
2
- CLOUDFLARE_ACCOUNT_ID is required when using CLOUDFLARE_API_TOKEN
3
- `)),process.exit(1)),y(t)}let o=await x(),{account:e,otherAccounts:n}=b(o);return O(e,n),{id:e.account.id,name:e.account.name}}async function V(o="this"){let e=await L();process.env.CLOUDFLARE_API_TOKEN&&(console.log(k.dim(` ${e.name} (${e.id})`)),console.log());let{confirm:n}=await S.prompt({type:"confirm",name:"confirm",message:`Do you want to deploy ${o} to ${e.name}?`,initial:!1});return n}import u from"chalk";var D="every-app-gateway";async function N(o){try{let e=await fetch(`${o}/api/admin/has-owner`);return e.ok?(await e.json()).hasOwner:!1}catch{return!1}}async function W(){try{let o=await p();return await m(`/accounts/${o}/workers/scripts/${D}/settings`),!0}catch{return!1}}async function A(){return h(D)}async function _(){if(!await W())return{isDeployed:!1,hasOwner:!1,gatewayUrl:await A()};let e=await A();return{isDeployed:!0,hasOwner:await N(e),gatewayUrl:e}}async function X(){let{isDeployed:o,hasOwner:e,gatewayUrl:n}=await _();if(o||(console.log(u.yellow(`
4
- Gateway not deployed
5
- `)),console.log(`You need to deploy the Every App Gateway before creating or deploying apps.
6
- `),console.log(u.dim(` Run: npx @every-app/cli gateway deploy
7
- `)),process.exit(1)),!e){let t=`${n}/sign-up`;console.log(u.yellow(`
8
- Owner account required
9
- `)),console.log(`You need to create an owner account on your Gateway before deploying apps.
10
- `),console.log(` ${u.cyan(t)}
11
- `),console.log(u.dim(` Visit the URL above to create your owner account, then run this command again.
12
- `)),process.exit(1)}return n}import{execa as F}from"execa";import{execa as g}from"execa";import c from"chalk";async function d(o,e,n){let{env:t,cwd:s,verbose:r=!1,description:i,logCommandToConsole:l=!0}=n;return r?G(o,e,n):l?(console.log(`Running: ${o} ${e.join(" ")}`),i&&console.log(c.dim(` ${i}`)),await g(o,e,{cwd:s,env:t,stdio:"pipe"})):await g(o,e,{cwd:s,env:t,stdio:"pipe"})}async function G(o,e,{description:n,cwd:t,env:s}){console.log(c.dim(` \u250C\u2500 Running: ${o} ${e.join(" ")}`)),n&&console.log(c.dim(` \u2502 ${n}`));let r=g(o,e,{cwd:t,env:s,stdio:void 0,all:!0});r.stdout&&r.stdout.on("data",l=>{l.toString().split(`
13
- `).forEach(a=>{a.trim()&&console.log(c.dim(` \u2502 ${a}`))})}),r.stderr&&r.stderr.on("data",l=>{l.toString().split(`
14
- `).forEach(a=>{a.trim()&&console.error(c.dim(` \u2502 ${a}`))})});let i=await r;return console.log(c.dim(` \u2514\u2500 Complete
15
- `)),i}async function M(){try{return await F("pnpm",["--version"],{stdio:"pipe"}),!0}catch{return!1}}async function se({cwd:o,description:e,verbose:n=!1}){let t=await M();try{t?await d("pnpm",["install"],{cwd:o,verbose:n,description:e}):await d("npx",["pnpm","install"],{cwd:o,verbose:n,description:e})}catch(s){throw new Error(`Failed to install dependencies with pnpm: ${s instanceof Error?s.message:"Unknown error"}`)}}import E from"chalk";import $ from"chalk";function ce(o,e){o&&console.log($.dim(e))}function v(o,...e){o&&e.forEach(n=>console.log($.dim(n)))}var P="npx",R=["drizzle-kit","migrate","--config=drizzle-prod.config.ts"];async function fe({cwd:o,verbose:e=!1}){console.log(`
16
- Running: ${P} ${R.join(" ")}`),console.log(E.dim(" Running database migrations...")),v(e," Running any pending migrations against your remote D1 Database..."),await I(P,R,{cwd:o,verbose:e}),console.log(E.dim(` Migrations completed.
17
- `))}import f from"chalk";import T from"node:path";async function U(o){let e=await p(),n=T.join(o,"wrangler.jsonc"),t=await C(n);return{accountId:e,workerName:t}}async function z(o){return await m(`/accounts/${o.accountId}/workers/scripts/${o.workerName}/secrets`)}async function xe({secretName:o,cwd:e,verbose:n=!1}){n&&console.log(f.dim(` Checking secret: ${o}`));let t=await U(e),r=(await z(t)).some(i=>i.name===o);return r&&n&&console.log(f.dim(` Secret already exists
18
- `)),r}async function Oe({secretName:o,secretValue:e,cwd:n,verbose:t=!1,description:s}){t&&s&&console.log(f.dim(` ${s}
19
- `));let r=await U(n);await m(`/accounts/${r.accountId}/workers/scripts/${r.workerName}/secrets`,{method:"PUT",body:JSON.stringify({name:o,text:e,type:"secret_text"})}),t&&console.log(f.green(`Created secret: ${o}
20
- `))}export{V as a,d as b,N as c,X as d,se as e,ce as f,v as g,fe as h,xe as i,Oe as j};
@@ -1,7 +0,0 @@
1
- import{b as a,c}from"./chunk-XEU3RC3D.js";import{a as n,d as l}from"./chunk-UMTKYAFW.js";import{b as r}from"./chunk-CKXY3PLB.js";import o from"chalk";async function C(p){await r(),await l();let e=process.cwd(),m=p.verbose||!1,t=await a(e);if(console.log(o.bold(`
2
- Project: ${t}
3
- `)),!await n("this app")){console.log(o.red(`
4
- Deployment cancelled by user
5
- `));return}let{workerUrl:s,gatewayUrl:i}=await c({cwd:e,appId:t,verbose:m});console.log(o.green(`
6
- Deployment successful!`)),console.log(o.dim(` App URL: ${o.cyan(s)}`)),console.log(` Gateway: ${o.cyan(i)}
7
- `)}export{C as deploy};
@@ -1,30 +0,0 @@
1
- import{d as _,e as k}from"./chunk-5HDAPJSF.js";import{a as R,b as D,c as K,e as U,f as u,g as y,h as $,i as d,j as g}from"./chunk-UMTKYAFW.js";import{b as E,e as T,g as h,i as C,j as A,l as S,p as x,q as b,r as W}from"./chunk-CKXY3PLB.js";import p from"chalk";import se from"node:path";import c from"chalk";var O="every-app-gateway",Y="every-app-gateway";async function G({verbose:o=!1}={}){console.log(`
2
- Setting up your Cloudflare D1 Database and KV Store...
3
- `);let e=await T(),t=await F(O,e,o),r=await M(Y,e,o);return console.log(),{d1DatabaseId:t,kvNamespaceId:r,accountId:e}}async function F(o,e,t){t&&console.log(` Checking D1 database: ${o}`);let r=await C(o,e);return t?r.wasCreated?console.log(c.green(` Created D1 database: ${o} (${r.id})
4
- `)):console.log(c.dim(` Linking to existing D1 database: ${o} (${r.id})
5
- `)):r.wasCreated?console.log(c.green(` D1 successfully created.
6
- `)):console.log(" D1 already set up."),r.id}async function M(o,e,t){t&&console.log(` Checking KV namespace: ${o}`);let r=await A(o,e);return t?r.wasCreated?console.log(c.green(` Created KV namespace: ${o} (${r.id})
7
- `)):console.log(c.dim(` Linking to existing KV namespace: ${o} (${r.id})
8
- `)):r.wasCreated?console.log(c.green(" KV successfully created.")):console.log(" KV already set up."),r.id}import j from"node:crypto";import q from"node:path";import L from"node:crypto";import l from"chalk";function z(){return L.randomBytes(32).toString("base64")}function H(){let{privateKey:o,publicKey:e}=L.generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:o,publicKey:e}}async function P({gatewayUrl:o,gatewayPath:e,verbose:t=!1}){console.log("Configuring secrets for the authentication service (Better Auth)..."),console.log(l.dim(" BETTER_AUTH_SECRET - Session signing and encryption")),console.log(l.dim(" JWT_PRIVATE_KEY - Signs JWTs issued to your apps")),console.log(l.dim(" JWT_PUBLIC_KEY - Apps use this to verify JWTs")),console.log();try{if(await d({secretName:"GATEWAY_URL",cwd:e,verbose:t})||await g({secretName:"GATEWAY_URL",secretValue:o,cwd:e,verbose:t,description:`Setting GATEWAY_URL to: ${o}`}),!await d({secretName:"BETTER_AUTH_SECRET",cwd:e,verbose:t})){let m=z();await g({secretName:"BETTER_AUTH_SECRET",secretValue:m,cwd:e,verbose:t,description:"Generating new Better Auth secret..."})}let n=await d({secretName:"JWT_PRIVATE_KEY",cwd:e,verbose:t}),i=await d({secretName:"JWT_PUBLIC_KEY",cwd:e,verbose:t});if(n&&i)t&&console.log(l.dim(` JWT key pair already exists
9
- `));else if(!n&&!i){t&&console.log(l.dim(` Generating new JWT key pair...
10
- `));let m=H();await g({secretName:"JWT_PRIVATE_KEY",secretValue:m.privateKey,cwd:e,verbose:t}),await g({secretName:"JWT_PUBLIC_KEY",secretValue:m.publicKey,cwd:e,verbose:t}),t&&console.log(l.green(`Created JWT key pair secrets
11
- `))}else throw new Error("JWT key pair is incomplete. Both JWT_PRIVATE_KEY and JWT_PUBLIC_KEY must exist together. Please delete the existing key and redeploy.");console.log(t?`Secret setup complete!
12
- `:` Finished.
13
- `)}catch(r){throw console.error(`
14
- Failed to setup secrets`,r instanceof Error?`
15
- ${r.message}`:""),r}}async function v({gatewayPath:o,resources:e,workerUrl:t,verbose:r=!1}){let a=q.join(o,"dist","server","wrangler.json");await b({configPath:a,d1DatabaseId:e.d1DatabaseId,kvNamespaceId:e.kvNamespaceId,verbose:r});let n=j.randomUUID();console.log(),await D("npx",["wrangler","deploy"],{cwd:o,description:`Deploying your Gateway to Cloudflare workers...
16
-
17
- This could take up to a minute.`,env:{...process.env,BETTER_AUTH_SECRET:n},verbose:r}),console.log(),await P({gatewayUrl:t,gatewayPath:o,verbose:r})}import w from"node:fs";import Q from"node:path";import{Readable as X}from"node:stream";import{pipeline as Z}from"node:stream/promises";import{createWriteStream as ee}from"node:fs";import{spawn as te}from"node:child_process";var oe="every-app",re="every-app",I="every-app-gateway-build.tar.gz";function ae(){return`https://github.com/${oe}/${re}/releases/download/gateway-latest/${I}`}async function ne(o,e){let t=await fetch(o,{redirect:"follow"});if(!t.ok)throw new Error(`Failed to download file: ${t.status} ${t.statusText}`);if(!t.body)throw new Error("Response body is null");let r=ee(e),a=X.fromWeb(t.body);await Z(a,r)}async function J(o,e){return new Promise((t,r)=>{let a=te("tar",["-xzf",o,"-C",e]);a.on("error",r),a.on("close",n=>{n===0?t():r(new Error(`tar extraction failed with code ${n}`))})})}async function V(o,e=!1){console.log("Getting latest gateway release..."),w.mkdirSync(o,{recursive:!0});let t=ae();u(e,`URL: ${t}`);let r=Q.join(o,I);try{await ne(t,r)}catch(a){throw a instanceof Error&&a.message.includes("404")?new Error("Gateway release not found. Make sure a release has been published."):a}return y(e,`Downloaded to: ${r}`,"Extracting archive..."),await J(r,o),w.unlinkSync(r),u(e,`Extraction complete
18
- `),o}async function N(o,e,t=!1){if(console.log("Using local gateway tarball..."),!w.existsSync(o))throw new Error(`Local gateway tarball not found: ${o}`);return w.mkdirSync(e,{recursive:!0}),y(t,`Tarball: ${o}`,"Extracting archive..."),await J(o,e),u(t,`Extraction complete
19
- `),e}async function Ne(o){await E();let e=o.verbose||!1,t=o.localGateway;if(console.log(p.bold(`
20
- Every App Gateway
21
- `)),!await R("the Gateway")){console.log(`
22
- Deployment cancelled by user
23
- `);return}await x();let a=await G({verbose:e}),n=await _("gateway-deploy-");e&&console.log(p.dim(`Working directory: ${n}
24
- `));let i=null;try{let s=t?await N(t,n,e):await V(n,e),f=se.join(s,"wrangler.jsonc"),B=await W(f);i=await h(B),await v({gatewayPath:s,resources:a,workerUrl:i,verbose:e}),await U({cwd:s,verbose:e,description:"Installing dependencies for migrations..."}),await $({cwd:s,verbose:e})}catch(s){let f=await S(s);throw f&&(console.log(f.formatted),process.exit(1)),console.error(`
25
- Deployment failed:`,s instanceof Error?s.message:s),s}finally{await k({tmpDir:n,verbose:e})}if(!i)throw new Error("Worker URL not set properly during deployment");if(console.log(p.green(`
26
- Gateway deployment successful!
27
- `)),await K(i))console.log(`Your Gateway is now live at: ${p.cyan(i)}
28
- `);else{let s=`${i}/sign-up`;console.log(`Your Gateway is now live at: ${p.cyan(s)}
29
- `),console.log(p.dim(` Create an owner account to get started with your Gateway.
30
- `))}}export{Ne as deploy};