@every-app/cli 0.0.6 → 0.0.8

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,b as s}from"./chunk-5APBZCRR.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,b as s}from"./chunk-3YK4AJ2B.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 l from"node:fs";import p from"node:os";import d from"node:path";function A(e){return{process:e,os:p,fs:l,path:d}}import{buildApplication as g,buildRouteMap as C}from"@stricli/core";import{buildInstallCommand as v,buildUninstallCommand as D}from"@stricli/auto-complete";var r="@every-app/cli";var n="Every CLI - Command line tool for deploying and managing Every applications";var a="0.0.6";import{buildCommand as o,buildRouteMap as m}from"@stricli/core";var c=o({loader:async()=>import("./create-HZ2EZA27.js"),parameters:{positional:{kind:"tuple",parameters:[]}},docs:{brief:"Create a new app from the starter template",fullDescription:["Copies the simple-todo starter template and configures your local development environment.","","The command will:"," 1. Prompt for app ID (kebab-case) and package manager"," 2. Copy the template to a new directory"," 3. Create Cloudflare D1 database and KV namespace"," 4. Configure wrangler.jsonc, package.json, and .env files"," 5. Install dependencies and run local migrations","","After creation, run 'npm run dev' to start developing."].join(`
2
- `)}}),u=o({loader:async()=>{let{deploy:e}=await import("./deploy-OFAXTS72.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
- `)}}),y=o({loader:async()=>{let{remoteD1Shell:e}=await import("./remoteD1Shell-EWWJQUWJ.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: every app remote-d1-shell -- npx drizzle-kit migrate"," - Opening Drizzle Studio: every app remote-d1-shell -- npx drizzle-kit studio"," - Pushing schema changes: every 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
- `)}}),s=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-CJAEI25G.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}}},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
- `)}}),i=b({routes:{deploy:h},docs:{brief:"Gateway management commands"}});var w=C({routes:{app:s,gateway:i,install:v("every",{bash:"__every_bash_complete"}),uninstall:D("every",{bash:!0})},docs:{brief:n,hideRoute:{install:!0,uninstall:!0}}}),G=g(w,{name:r,versionInfo:{currentVersion:a}});export{A as a,G as b};
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 v,buildUninstallCommand as D}from"@stricli/auto-complete";var r="@every-app/cli";var n="Every App CLI - Deploy and manage apps.";var a="0.0.8";import{buildCommand as o,buildRouteMap as m}from"@stricli/core";var c=o({loader:async()=>import("./create-FG6SVLJW.js"),parameters:{positional:{kind:"tuple",parameters:[]}},docs:{brief:"Create a new app from the starter template",fullDescription:["Copies the simple-todo starter template and configures your local development environment.","","The command will:"," 1. Prompt for app ID (kebab-case) and package manager"," 2. Copy the template to a new directory"," 3. Create Cloudflare D1 database and KV namespace"," 4. Configure wrangler.jsonc, package.json, and .env files"," 5. Install dependencies and run local migrations","","After creation, run 'npm run dev' to start developing."].join(`
2
+ `)}}),u=o({loader:async()=>{let{deploy:e}=await import("./deploy-5XDHWAUT.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
+ `)}}),y=o({loader:async()=>{let{remoteD1Shell:e}=await import("./remoteD1Shell-KTDD4RTN.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: every app remote-d1-shell -- npx drizzle-kit migrate"," - Opening Drizzle Studio: every app remote-d1-shell -- npx drizzle-kit studio"," - Pushing schema changes: every 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
+ `)}}),s=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-OU5FTS67.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}}},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
+ `)}}),i=b({routes:{deploy:h},docs:{brief:"Gateway management commands"}});var w=C({routes:{app:s,gateway:i,install:v("every",{bash:"__every_bash_complete"}),uninstall:D("every",{bash:!0})},docs:{brief:n,hideRoute:{install:!0,uninstall:!0}}}),G=g(w,{name:r,versionInfo:{currentVersion:a},scanner:{allowArgumentEscapeSequence:!0}});export{A as a,G as b};
@@ -1,7 +1,7 @@
1
- import p from"node:fs/promises";import d from"node:path";import f from"node:os";import*as g from"smol-toml";function w(){let r=f.homedir(),n=f.platform(),e;return n==="win32"?e=d.join(process.env.LOCALAPPDATA||d.join(r,"AppData","Local"),".wrangler"):n==="darwin"?e=d.join(r,"Library","Preferences",".wrangler"):e=d.join(r,".wrangler"),d.join(e,"config","default.toml")}async function h(){let r=w();try{let n=await p.readFile(r,"utf-8"),e=g.parse(n);if(!e.oauth_token||!e.refresh_token)throw new Error("OAuth tokens not found in wrangler config");return e}catch(n){throw n.code==="ENOENT"?new Error("Wrangler config not found. Please run 'npx wrangler login' first."):n}}function k(r){let n=new Date(r).getTime(),e=Date.now(),t=1*60*1e3;return n-e<t}async function b(r){let n=await fetch("https://dash.cloudflare.com/oauth2/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:r})});if(!n.ok)throw new Error(`Failed to refresh OAuth token: ${n.status} ${n.statusText}`);let e=await n.json();return{oauth_token:e.access_token,expiration_time:new Date(Date.now()+e.expires_in*1e3).toISOString(),refresh_token:e.refresh_token||r,scopes:e.scope?e.scope.split(" "):[]}}async function y(){let r=await h();return k(r.expiration_time)?(await b(r.refresh_token)).oauth_token:r.oauth_token}async function l(r,n={}){let e=await y(),t=await fetch(`https://api.cloudflare.com/client/v4${r}`,{...n,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",...n.headers}}),o=await t.json();if(!t.ok){let s=o.errors?o.errors.map(c=>`[${c.code}] ${c.message}`).join(", "):t.statusText;throw new Error(`Cloudflare API request failed: ${t.status} ${s}`)}if(!o.success){let s=o.errors.map(c=>`[${c.code}] ${c.message}`).join(", ");throw new Error(`Cloudflare API error: ${s}`)}return o.result}async function _(){let r=await l("/accounts");if(!r||r.length===0)throw new Error("No Cloudflare accounts found");let n=r[0];if(!n)throw new Error("No Cloudflare accounts found");return n.id}async function A(r){try{let n=await l(`/accounts/${r}/workers/subdomain`);if(!n||!n.subdomain)throw new Error("No workers.dev subdomain found for this account");return n.subdomain}catch(n){throw new Error(`Failed to get workers.dev subdomain: ${n instanceof Error?n.message:"Unknown error"}`)}}async function $(r,n){let e=n||await _(),t=await A(e);return`https://${r}.${t}.workers.dev`}import u from"node:fs/promises";import D from"node:path";import*as a from"jsonc-parser";function T(r,n,e){let t=[];return e.name&&t.push(...a.modify(r,["name"],e.name,{})),n.d1_databases&&e.d1DatabaseId&&n.d1_databases.forEach((o,s)=>{t.push(...a.modify(r,["d1_databases",s,"database_id"],e.d1DatabaseId,{})),e.d1DatabaseName&&t.push(...a.modify(r,["d1_databases",s,"database_name"],e.d1DatabaseName,{}))}),n.kv_namespaces&&e.kvNamespaceId&&n.kv_namespaces.forEach((o,s)=>{t.push(...a.modify(r,["kv_namespaces",s,"id"],e.kvNamespaceId,{}))}),t}async function v(r,n){let e=await u.readFile(r,"utf-8"),t=a.parse(e),o=T(e,t,n),s=a.applyEdits(e,o);await u.writeFile(r,s)}async function N(r){let n=await u.readFile(r,"utf-8"),e=a.parse(n);if(!e.name||typeof e.name!="string")throw new Error("Worker name not found in wrangler.jsonc");return e.name}async function F(r){let n=D.join(r,"wrangler.jsonc");try{let e=await u.readFile(n,"utf-8");return a.parse(e)}catch(e){throw e instanceof Error&&"code"in e&&e.code==="ENOENT"?new Error("wrangler.jsonc not found in current directory. Make sure you're running this command from your app's root directory."):e}}import{execa as m}from"execa";import i from"chalk";async function x(){let{stdout:r}=await m("npx",["wrangler","d1","list","--json"]);return JSON.parse(r)}async function C(r){let{stdout:n}=await m("npx",["wrangler","d1","create",r]),e=n.match(/"database_id":\s*"([^"]+)"/);if(!e||!e[1])throw new Error("Failed to parse database ID from wrangler output");return e[1]}async function M(r){console.log(i.bold(`Checking D1 database: ${r}
2
- `));try{let e=(await x()).find(o=>o.name===r);if(e)return console.log(i.green(`Linking to existing D1 database: ${r} (${e.uuid})
1
+ import p from"node:fs/promises";import d from"node:path";import f from"node:os";import*as g from"smol-toml";function w(){let r=f.homedir(),n=f.platform(),e;return n==="win32"?e=d.join(process.env.LOCALAPPDATA||d.join(r,"AppData","Local"),".wrangler"):n==="darwin"?e=d.join(r,"Library","Preferences",".wrangler"):e=d.join(r,".wrangler"),d.join(e,"config","default.toml")}async function h(){let r=w();try{let n=await p.readFile(r,"utf-8"),e=g.parse(n);if(!e.oauth_token||!e.refresh_token)throw new Error("OAuth tokens not found in wrangler config");return e}catch(n){throw n.code==="ENOENT"?new Error("Wrangler config not found. Please run 'npx wrangler login' first."):n}}function k(r){let n=new Date(r).getTime(),e=Date.now(),t=1*60*1e3;return n-e<t}async function b(r){let n=await fetch("https://dash.cloudflare.com/oauth2/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:r})});if(!n.ok)throw new Error(`Failed to refresh OAuth token: ${n.status} ${n.statusText}`);let e=await n.json();return{oauth_token:e.access_token,expiration_time:new Date(Date.now()+e.expires_in*1e3).toISOString(),refresh_token:e.refresh_token||r,scopes:e.scope?e.scope.split(" "):[]}}async function y(){let r=await h();return k(r.expiration_time)?(await b(r.refresh_token)).oauth_token:r.oauth_token}async function l(r,n={}){let e=await y(),t=await fetch(`https://api.cloudflare.com/client/v4${r}`,{...n,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",...n.headers}}),o=await t.json();if(!t.ok){let s=o.errors?o.errors.map(c=>`[${c.code}] ${c.message}`).join(", "):t.statusText;throw new Error(`Cloudflare API request failed: ${t.status} ${s}`)}if(!o.success){let s=o.errors.map(c=>`[${c.code}] ${c.message}`).join(", ");throw new Error(`Cloudflare API error: ${s}`)}return o.result}async function _(){let r=await l("/accounts");if(!r||r.length===0)throw new Error("No Cloudflare accounts found");let n=r[0];if(!n)throw new Error("No Cloudflare accounts found");return n.id}async function A(r){try{let n=await l(`/accounts/${r}/workers/subdomain`);if(!n||!n.subdomain)throw new Error("No workers.dev subdomain found for this account");return n.subdomain}catch(n){throw new Error(`Failed to get workers.dev subdomain: ${n instanceof Error?n.message:"Unknown error"}`)}}async function $(r,n){let e=n||await _(),t=await A(e);return`https://${r}.${t}.workers.dev`}import u from"node:fs/promises";import D from"node:path";import*as a from"jsonc-parser";function T(r,n,e){let t=[];return e.name&&t.push(...a.modify(r,["name"],e.name,{})),n.d1_databases&&e.d1DatabaseId&&n.d1_databases.forEach((o,s)=>{t.push(...a.modify(r,["d1_databases",s,"database_id"],e.d1DatabaseId,{})),e.d1DatabaseName&&t.push(...a.modify(r,["d1_databases",s,"database_name"],e.d1DatabaseName,{}))}),n.kv_namespaces&&e.kvNamespaceId&&n.kv_namespaces.forEach((o,s)=>{t.push(...a.modify(r,["kv_namespaces",s,"id"],e.kvNamespaceId,{}))}),t}async function v(r,n){let e=await u.readFile(r,"utf-8"),t=a.parse(e),o=T(e,t,n),s=a.applyEdits(e,o);await u.writeFile(r,s)}async function N(r){let n=await u.readFile(r,"utf-8"),e=a.parse(n);if(!e.name||typeof e.name!="string")throw new Error("Worker name not found in wrangler.jsonc");return e.name}async function F(r){let n=D.join(r,"wrangler.jsonc");try{let e=await u.readFile(n,"utf-8");return a.parse(e)}catch(e){throw e instanceof Error&&"code"in e&&e.code==="ENOENT"?new Error("wrangler.jsonc not found in current directory. Make sure you're running this command from your app's root directory."):e}}import{execa as m}from"execa";import i from"chalk";async function C(){let{stdout:r}=await m("npx",["wrangler","d1","list","--json"]);return JSON.parse(r)}async function E(r){let{stdout:n}=await m("npx",["wrangler","d1","create",r]),e=n.match(/"database_id":\s*"([^"]+)"/);if(!e||!e[1])throw new Error("Failed to parse database ID from wrangler output");return e[1]}async function M(r){console.log(i.bold(`Checking D1 database: ${r}
2
+ `));try{let e=(await C()).find(o=>o.name===r);if(e)return console.log(i.green(`Linking to existing D1 database: ${r} (${e.uuid})
3
3
  `)),e.uuid;console.log(i.bold(`Creating new D1 database: ${r}
4
- `));let t=await C(r);return console.log(i.green(`Created D1 database: ${r} (${t})
4
+ `));let t=await E(r);return console.log(i.green(`Created D1 database: ${r} (${t})
5
5
  `)),t}catch(n){throw console.error(i.red(`
6
6
  Failed to get or create D1 database: ${r}`),n instanceof Error?i.dim(`
7
- ${n.message}`):""),n}}export{y as a,_ as b,$ as c,v as d,N as e,F as f,x as g,M as h};
7
+ ${n.message}`):""),n}}export{y as a,_ as b,$ as c,v as d,N as e,F as f,C as g,M as h};
@@ -0,0 +1,13 @@
1
+ import{execa as f}from"execa";import c from"chalk";async function p(e,n,o={}){let{env:t,cwd:r,verbose:m=!1}=o;if(m){console.log(c.dim(` \u250C\u2500 Running: ${e} ${n.join(" ")}`));let s=f(e,n,{cwd:r,env:t,stdio:void 0,all:!0});s.stdout&&s.stdout.on("data",l=>{l.toString().split(`
2
+ `).forEach(a=>{a.trim()&&console.log(c.dim(` \u2502 ${a}`))})}),s.stderr&&s.stderr.on("data",l=>{l.toString().split(`
3
+ `).forEach(a=>{a.trim()&&console.error(c.dim(` \u2502 ${a}`))})});let w=await s;return console.log(c.dim(` \u2514\u2500 Complete
4
+ `)),w}else return console.log(`Running: ${e} ${n.join(" ")}`),await f(e,n,{cwd:r,env:t,stdio:"pipe"})}import u from"node:fs/promises";import g from"node:path";import d from"chalk";async function y(e,n,o=!1){try{if(e==="pnpm"){await p("npx",["pnpm","install"],{cwd:n,stdio:"inherit",verbose:o});return}await p(e,["install"],{cwd:n,stdio:"inherit",verbose:o})}catch(t){throw new Error(`Failed to install dependencies with ${e}: ${t instanceof Error?t.message:"Unknown error"}`)}}async function $(e){try{return(await u.stat(g.join(e,"node_modules"))).isDirectory()}catch{return!1}}async function C(e,n=!1){if(!await $(e)){console.log(d.bold(`Installing dependencies...
5
+ `));try{let t=await u.access(g.join(e,"pnpm-lock.yaml")).then(()=>!0).catch(()=>!1),r=await u.access(g.join(e,"package-lock.json")).then(()=>!0).catch(()=>!1);await y(t?"pnpm":r?"npm":"pnpm",e,n),console.log(d.green(`Dependencies installed
6
+ `))}catch(t){throw console.error(d.red(`
7
+ Failed to install dependencies`)),t}}}import{execa as h}from"execa";import i from"chalk";async function x(){let{stdout:e}=await h("npx",["wrangler","kv","namespace","list"]);return JSON.parse(e)}async function P(e){let{stdout:n}=await h("npx",["wrangler","kv","namespace","create",e]);return b(n)}function b(e){let n=e.match(/"id":\s*"([a-f0-9]+)"/);if(!n||!n[1])throw new Error("Failed to parse namespace ID from wrangler output");return n[1]}async function S(e){console.log(i.bold(`Checking KV namespace: ${e}
8
+ `));try{let o=(await x()).find(r=>r.title===e);if(o)return console.log(i.green(`Linking to existing KV namespace: ${e} (${o.id})
9
+ `)),o.id;console.log(i.bold(`Creating new KV namespace: ${e}
10
+ `));let t=await P(e);return console.log(i.green(`Created KV namespace: ${e} (${t})
11
+ `)),t}catch(n){throw console.error(i.red(`
12
+ Failed to get or create KV namespace: ${e}`),n instanceof Error?i.dim(`
13
+ ${n.message}`):""),n}}export{p as a,y as b,C as c,S as d};
@@ -1,4 +1,4 @@
1
- import{a as p}from"./chunk-SWDH4UHI.js";import{c as m}from"./chunk-LCSNH5IG.js";async function g(t,e,r=!1){try{await p("git",["clone",t,e],{stdio:"inherit",verbose:r})}catch(i){throw new Error(`Failed to clone repository from ${t}: ${i instanceof Error?i.message:"Unknown error"}`)}}import o from"node:fs/promises";import n from"node:path";import f from"node:os";import y from"chalk";async function u(t,e,r={}){let i=r.exclude||[];await o.mkdir(e,{recursive:!0});let s=await o.readdir(t,{withFileTypes:!0});for(let a of s){let c=n.join(t,a.name),l=n.join(e,a.name);i.some(d=>a.name===d)||(a.isDirectory()?await u(c,l,r):await o.copyFile(c,l))}}async function O(t){try{return(await o.stat(t)).isDirectory()}catch{return!1}}async function R(t,e){let r=await m("every-app-gateway"),i=`CORE_APP_URL=${r}
1
+ import{a as m}from"./chunk-HFR3IFIX.js";import{c as p}from"./chunk-CQBCTFZE.js";async function g(t,e,r=!1){try{await m("git",["clone",t,e],{stdio:"inherit",verbose:r})}catch(i){throw new Error(`Failed to clone repository from ${t}: ${i instanceof Error?i.message:"Unknown error"}`)}}import o from"node:fs/promises";import n from"node:path";import f from"node:os";import y from"chalk";async function u(t,e,r={}){let i=r.exclude||[];await o.mkdir(e,{recursive:!0});let s=await o.readdir(t,{withFileTypes:!0});for(let a of s){let c=n.join(t,a.name),l=n.join(e,a.name);i.some(d=>a.name===d)||(a.isDirectory()?await u(c,l,r):await o.copyFile(c,l))}}async function O(t){try{return(await o.stat(t)).isDirectory()}catch{return!1}}async function R(t,e){let r=await p("every-app-gateway"),i=`CORE_APP_URL=${r}
2
2
  `,s=`VITE_APP_ID=${e}
3
3
  VITE_PARENT_ORIGIN=${r}
4
4
  `;await Promise.all([o.writeFile(n.join(t,".dev.vars"),i),o.writeFile(n.join(t,".env.local"),s)])}async function j(t){return await o.mkdtemp(n.join(f.tmpdir(),t))}async function I(t,e=!1){try{await o.rm(t,{recursive:!0,force:!0}),e&&console.log(y.dim(` Removed: ${t}`))}catch{console.warn(y.yellow("\u26A0\uFE0F Warning: Failed to clean up temporary directory:"),t)}}export{g as a,u as b,O as c,R as d,j as e,I as f};
@@ -1,4 +1,4 @@
1
- import{a as c,b as g,c as m,d,e as u,f as y}from"./chunk-W5YMWENN.js";import{b as p,d as b}from"./chunk-SWDH4UHI.js";import{d as f,h as w}from"./chunk-LCSNH5IG.js";import h from"node:fs/promises";import i from"node:path";import k from"enquirer";import{execa as D}from"execa";import e from"chalk";var v="git@github.com:every-app/every-app.git",$="templates/simple-todo";function E(n){return!n||n.trim().length===0?"App ID cannot be empty":n.length>64?"App ID must be 64 characters or less":/^[a-z][a-z0-9-]*$/.test(n)?!0:"App ID must be in kebab-case format (lowercase letters, numbers, and hyphens only, starting with a letter)"}async function x(){return(await k.prompt({type:"input",name:"appId",message:"Enter your app ID (kebab-case format)",initial:"my-cool-app",validate:E})).appId}async function j(){return(await k.prompt({type:"select",name:"packageManager",message:"Select your package manager",choices:[{name:"pnpm",message:"pnpm (recommended)"},{name:"npm",message:"npm"}],initial:0})).packageManager}async function I(n,a){let o=i.join(n,"package.json"),t=JSON.parse(await h.readFile(o,"utf-8"));t.name=a,t.scripts["db:migrate:dev"]=`wrangler d1 migrations apply ${a} --local`,t.scripts["db:migrate:prod"]=`wrangler d1 migrations apply ${a} --remote`,await h.writeFile(o,JSON.stringify(t,null,2)+`
1
+ import{a as c,b as g,c as m,d,e as u,f as y}from"./chunk-MLX4WISN.js";import{b as p,d as b}from"./chunk-HFR3IFIX.js";import{d as f,h as w}from"./chunk-CQBCTFZE.js";import h from"node:fs/promises";import i from"node:path";import k from"enquirer";import{execa as D}from"execa";import e from"chalk";var v="git@github.com:every-app/every-app.git",$="templates/simple-todo";function E(n){return!n||n.trim().length===0?"App ID cannot be empty":n.length>64?"App ID must be 64 characters or less":/^[a-z][a-z0-9-]*$/.test(n)?!0:"App ID must be in kebab-case format (lowercase letters, numbers, and hyphens only, starting with a letter)"}async function x(){return(await k.prompt({type:"input",name:"appId",message:"Enter your app ID (kebab-case format)",initial:"my-cool-app",validate:E})).appId}async function j(){return(await k.prompt({type:"select",name:"packageManager",message:"Select your package manager",choices:[{name:"pnpm",message:"pnpm (recommended)"},{name:"npm",message:"npm"}],initial:0})).packageManager}async function I(n,a){let o=i.join(n,"package.json"),t=JSON.parse(await h.readFile(o,"utf-8"));t.name=a,t.scripts["db:migrate:dev"]=`wrangler d1 migrations apply ${a} --local`,t.scripts["db:migrate:prod"]=`wrangler d1 migrations apply ${a} --remote`,await h.writeFile(o,JSON.stringify(t,null,2)+`
2
2
  `,"utf-8")}async function A(n,a){try{await D("npx",["wrangler","d1","migrations","apply",a,"--local"],{cwd:n,input:`y
3
3
  `,stdio:["pipe","inherit","inherit"]}),console.log(e.green(`
4
4
  Local database migrations completed successfully
@@ -1,16 +1,16 @@
1
- import{a as R}from"./chunk-B6LAGOID.js";import{a as y,c as D,d as C}from"./chunk-SWDH4UHI.js";import{a as $,b as _,c as b,f as E,g as v,h as k}from"./chunk-LCSNH5IG.js";import n from"chalk";import U from"node:path";import h from"node:fs/promises";import{execa as I}from"execa";import*as g from"jsonc-parser";import{randomUUID as A}from"node:crypto";async function N(s,t){console.log(n.bold(`
1
+ import{a as R}from"./chunk-B6LAGOID.js";import{a as y,c as D,d as C}from"./chunk-HFR3IFIX.js";import{a as $,b as _,c as b,f as E,g as v,h as k}from"./chunk-CQBCTFZE.js";import n from"chalk";import U from"node:path";import h from"node:fs/promises";import{execa as N}from"execa";import*as g from"jsonc-parser";import{randomUUID as A}from"node:crypto";async function S(s,t){console.log(n.bold(`
2
2
  Setting up Cloudflare resources...
3
3
  `));let a=new Map,o=new Map;if(s.d1_databases&&s.d1_databases.length>0){console.log(n.bold(`Processing D1 databases...
4
4
  `));for(let e=0;e<s.d1_databases.length;e++){let r=s.d1_databases[e].database_name;if(!r){console.warn(n.yellow(`Skipping D1 database at index ${e}: no database_name specified
5
5
  `));continue}let c=await k(r);a.set(e,c)}}if(s.kv_namespaces&&s.kv_namespaces.length>0){console.log(n.bold(`Processing KV namespaces...
6
6
  `));for(let e=0;e<s.kv_namespaces.length;e++){if(!s.kv_namespaces[e].binding){console.warn(n.yellow(`Skipping KV namespace at index ${e}: no binding specified
7
- `));continue}let r=await C(t);o.set(e,r)}}return{d1Updates:a,kvUpdates:o}}async function S(s,t,a,o){console.log(n.bold(`Updating wrangler.jsonc with resource IDs...
7
+ `));continue}let r=await C(t);o.set(e,r)}}return{d1Updates:a,kvUpdates:o}}async function T(s,t,a,o){console.log(n.bold(`Updating wrangler.jsonc with resource IDs...
8
8
  `));let e=U.join(s,"wrangler.jsonc"),i=await h.readFile(e,"utf-8"),r=[];for(let[d,p]of t.entries())r.push(...g.modify(i,["d1_databases",d,"database_id"],p,{}));for(let[d,p]of a.entries())r.push(...g.modify(i,["kv_namespaces",d,"id"],p,{}));r.push(...g.modify(i,["vars","CORE_APP_URL"],o,{}));let c=g.applyEdits(i,r);await h.writeFile(e,c),console.log(n.green(`wrangler.jsonc updated successfully
9
- `))}async function T(s,t){if(!t.d1_databases||t.d1_databases.length===0){console.log(n.dim(`No D1 databases configured, skipping migrations
9
+ `))}async function x(s,t){if(!t.d1_databases||t.d1_databases.length===0){console.log(n.dim(`No D1 databases configured, skipping migrations
10
10
  `));return}console.log(n.bold(`Running database migrations...
11
11
  `));for(let a of t.d1_databases){let o=a.binding;if(!o){console.warn(n.yellow(`Skipping migration: no binding specified
12
12
  `));continue}try{console.log(n.dim(` Running migrations for ${o}...
13
- `)),await I("npx",["wrangler","d1","migrations","apply",o,"--remote"],{cwd:s,input:`y
13
+ `)),await N("npx",["wrangler","d1","migrations","apply",o,"--remote"],{cwd:s,input:`y
14
14
  `,stdio:["pipe","inherit","inherit"]}),console.log(n.green(`Migrations completed for ${o}
15
15
  `))}catch{console.warn(n.yellow(`Failed to run migrations for ${o}. You may need to run them manually.
16
16
  `))}}}async function j(s,t,a,o){console.log(n.bold(`Building and deploying to Cloudflare...
@@ -39,8 +39,8 @@ Reading project configuration...
39
39
  `));let o=await E(s);if(!o.name)throw new Error("Worker name not found in wrangler.jsonc. Please add a 'name' field.");let e=o.name;if(console.log(n.dim(`Project name: ${e}
40
40
  `)),!t&&!await R("Do you want to deploy this app to Cloudflare?")){console.log(n.red(`
41
41
  Deployment cancelled by user
42
- `));return}let{d1Updates:i,kvUpdates:r}=await N(o,e),c=await b("every-app-gateway");await S(s,i,r,c),await D(s,a),await T(s,o),await j(s,c,e,a);let d=await b(o.name),p,u;o.name==="every-todo-app"&&(p="Todos",u="Minimal todo list"),await M(o.name,d,p,u),console.log(n.bold.green(`\u{1F389} Deployment successful!
42
+ `));return}let{d1Updates:i,kvUpdates:r}=await S(o,e),c=await b("every-app-gateway");await T(s,i,r,c),await D(s,a),await x(s,o),await j(s,c,e,a);let d=await b(o.name),p,u;o.name==="every-todo-app"&&(p="Todos",u="Minimal todo list"),await M(o.name,d,p,u),console.log(n.bold.green(`\u{1F389} Deployment successful!
43
43
  `)),console.log(n.bold(`Your app is now live at: ${n.cyan(d)}
44
44
  `)),console.log(n.dim(`Try it out by visiting the URL above in your browser.
45
45
  `))}catch(o){throw console.error(n.red(`
46
- Deployment failed:`),o instanceof Error?o.message:o),o}}async function G(s){let t=process.cwd(),a=s.verbose||!1;await O(t,!1,a)}export{G as deploy,O as deployAppFromDirectory};
46
+ Deployment failed:`),o instanceof Error?o.message:o),o}}async function G(s){let t=process.cwd(),a=s.verbose||!1;await O(t,!1,a)}export{G as deploy};
@@ -1,4 +1,4 @@
1
- import{a as y,e as w,f as T}from"./chunk-W5YMWENN.js";import{a as x}from"./chunk-B6LAGOID.js";import{a as m,b as u,d as C}from"./chunk-SWDH4UHI.js";import{b as f,c as E,d as _,e as R,h as A}from"./chunk-LCSNH5IG.js";import c from"chalk";import O from"node:path";import k from"node:path";import W from"node:crypto";import l from"chalk";import{execa as b}from"execa";import U from"node:crypto";import t from"chalk";function K(){return U.randomBytes(32).toString("base64")}function L(){let{privateKey:o,publicKey:e}=U.generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:o,publicKey:e}}async function B(o){try{let{stdout:e}=await b("npx",["wrangler","secret","list","--format","json"],{cwd:o});return JSON.parse(e)}catch{return[]}}async function d(o,e){return(await B(e)).some(n=>n.name===o)}async function g(o,e,r){let n=b("npx",["wrangler","secret","put",o],{cwd:r});n.stdin&&(n.stdin.write(e),n.stdin.end()),await n}async function S(o,e){console.log(t.bold(`
1
+ import{a as y,e as w,f as T}from"./chunk-MLX4WISN.js";import{a as b}from"./chunk-B6LAGOID.js";import{a as m,b as u,d as C}from"./chunk-HFR3IFIX.js";import{b as f,c as E,d as _,e as R,h as A}from"./chunk-CQBCTFZE.js";import c from"chalk";import O from"node:path";import k from"node:path";import W from"node:crypto";import l from"chalk";import{execa as U}from"execa";import S from"node:crypto";import t from"chalk";function K(){return S.randomBytes(32).toString("base64")}function L(){let{privateKey:o,publicKey:e}=S.generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:o,publicKey:e}}async function B(o){try{let{stdout:e}=await U("npx",["wrangler","secret","list","--format","json"],{cwd:o});return JSON.parse(e)}catch{return[]}}async function d(o,e){return(await B(e)).some(n=>n.name===o)}async function g(o,e,r){let n=U("npx",["wrangler","secret","put",o],{cwd:r});n.stdin&&(n.stdin.write(e),n.stdin.end()),await n}async function P(o,e){console.log(t.bold(`
2
2
  Setting up secrets...
3
3
  `));try{if(console.log(t.bold(`Checking secret: CORE_APP_URL
4
4
  `)),await d("CORE_APP_URL",e)?console.log(t.dim(` Secret already exists
@@ -19,17 +19,17 @@ Setting up secrets...
19
19
  `))}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.green(`Secret setup complete!
20
20
  `))}catch(r){throw console.error(t.red(`
21
21
  Failed to setup secrets`),r instanceof Error?t.dim(`
22
- ${r.message}`):""),r}}var P="git@github.com:every-app/every-app.git",J="every-app-gateway",H="every-app-gateway",N="apps/every-app-gateway";async function v(){console.log(l.bold(`
22
+ ${r.message}`):""),r}}var x="git@github.com:every-app/every-app.git",J="every-app-gateway",H="every-app-gateway",N="apps/every-app-gateway";async function v(){console.log(l.bold(`
23
23
  Setting up Cloudflare resources...
24
- `));let o=await f(),e=await A(J),r=await C(H);return{d1DatabaseId:e,kvNamespaceId:r,accountId:o}}async function I(o,e=!1){console.log(l.bold("Cloning gateway repository...")),console.log(l.dim(` Repository: ${P}
25
- `));try{await y(P,o,e);let r=k.join(o,N);return console.log(l.bold(`Installing dependencies in apps/every-app-gateway...
24
+ `));let o=await f(),e=await A(J),r=await C(H);return{d1DatabaseId:e,kvNamespaceId:r,accountId:o}}async function I(o,e=!1){console.log(l.bold("Cloning gateway repository...")),console.log(l.dim(` Repository: ${x}
25
+ `));try{await y(x,o,e);let r=k.join(o,N);return console.log(l.bold(`Installing dependencies in apps/every-app-gateway...
26
26
  `)),await u("pnpm",r,e),console.log(l.green(`Installation complete!
27
27
  `)),r}catch(r){throw console.error(l.red(`
28
28
  Failed to clone repository or install dependencies`),r instanceof Error?l.dim(`
29
- ${r.message}`):""),r}}async function h(o,e,r,n=!1){try{let s=k.join(o,"wrangler.jsonc");await _(s,{d1DatabaseId:e.d1DatabaseId,kvNamespaceId:e.kvNamespaceId}),await S(r,o),console.log(l.bold(`Deploying to Cloudflare...
29
+ ${r.message}`):""),r}}async function h(o,e,r,n=!1){try{let s=k.join(o,"wrangler.jsonc");await _(s,{d1DatabaseId:e.d1DatabaseId,kvNamespaceId:e.kvNamespaceId}),await P(r,o),console.log(l.bold(`Deploying to Cloudflare...
30
30
  `));let i=W.randomUUID();await m("npm",["run","deploy"],{cwd:o,stdio:"inherit",env:{...process.env,BETTER_AUTH_SECRET:i},verbose:n})}catch(s){throw console.error(l.red(`
31
31
  Failed to update config or deploy`),s instanceof Error?l.dim(`
32
- ${s.message}`):""),s}}async function de(o){let e=o.verbose||!1;if(!await x("Do you want to deploy EveryApp Gateway into this Cloudflare account?")){console.log(c.red(`
32
+ ${s.message}`):""),s}}async function de(o){let e=o.verbose||!1;if(!await b("Do you want to deploy EveryApp Gateway into this Cloudflare account?")){console.log(c.red(`
33
33
  Deployment cancelled by user
34
34
  `));return}let n=await v(),s=await w("gateway-deploy-");console.log(c.dim(`
35
35
  Working directory: ${s}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as r,b as o}from"./chunk-5APBZCRR.js";import{run as i}from"@stricli/core";await i(o,process.argv.slice(2),r(process));
2
+ import{a as r,b as o}from"./chunk-3YK4AJ2B.js";import{run as i}from"@stricli/core";await i(o,process.argv.slice(2),r(process));
@@ -0,0 +1,6 @@
1
+ import{a as d,b as c,f as l,g}from"./chunk-CQBCTFZE.js";import t from"chalk";import{execa as h}from"execa";async function A(w,...e){let r=process.cwd();try{if(!e||e.length===0)throw new Error(`No command provided. Usage: every app remote-d1-shell -- <command>
2
+ Example: every app remote-d1-shell -- npx drizzle-kit migrate`);let[a,...s]=e;if(!a)throw new Error("Invalid command");let o=await l(r);if(!o.d1_databases||o.d1_databases.length===0)throw new Error("No D1 databases found in wrangler.jsonc. Please add a D1 database configuration.");let n=o.d1_databases[0].database_name;if(!n)throw new Error("No database_name found in D1 database configuration in wrangler.jsonc.");console.log("Retrieving shell info from Cloudflare...");let[f,m,b]=await Promise.all([c(),g(),d()]),i=m.find(p=>p.name===n);if(!i)throw new Error(`Database "${n}" not found in your Cloudflare account. Have you run \`every app deploy\` to create the database?`);let u=i.uuid;console.log(t.bold(`
3
+ Running: ${t.cyan([a,...s].join(" "))}
4
+ `)),await h(a,s,{cwd:r,stdio:"inherit",env:{...process.env,CLOUDFLARE_ACCOUNT_ID:f,CLOUDFLARE_DATABASE_ID:u,CLOUDFLARE_API_TOKEN:b}}),console.log(`
5
+ Command executed!`)}catch(a){throw console.error(t.red(`
6
+ Failed to generate shell configuration:`),a instanceof Error?a.message:a),a}}export{A as remoteD1Shell};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@every-app/cli",
3
3
  "author": "",
4
- "description": "Every CLI - Command line tool for deploying and managing Every applications",
4
+ "description": "Every App CLI - Deploy and manage apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.6",
7
+ "version": "0.0.8",
8
8
  "files": [
9
9
  "dist"
10
10
  ],
@@ -22,7 +22,8 @@
22
22
  "build": "tsup --silent",
23
23
  "build:prepublish": "pnpm install --ignore-scripts && npm run types:check && npm run build",
24
24
  "prepublishOnly": "npm run build:prepublish",
25
- "postinstall": "every install"
25
+ "postinstall": "every install",
26
+ "knip": "knip"
26
27
  },
27
28
  "tsup": {
28
29
  "entry": {
@@ -48,6 +49,7 @@
48
49
  },
49
50
  "devDependencies": {
50
51
  "@types/node": "^22.18.13",
52
+ "knip": "^5.66.4",
51
53
  "tsup": "^6.7.0",
52
54
  "typescript": "5.9.3"
53
55
  }
@@ -1,13 +0,0 @@
1
- import{execa as g}from"execa";import c from"chalk";async function p(e,n,o={}){let{env:t,cwd:r,verbose:f=!1}=o;if(f){console.log(c.dim(` \u250C\u2500 Running: ${e} ${n.join(" ")}`));let s=g(e,n,{cwd:r,env:t,stdio:void 0,all:!0});s.stdout&&s.stdout.on("data",l=>{l.toString().split(`
2
- `).forEach(i=>{i.trim()&&console.log(c.dim(` \u2502 ${i}`))})}),s.stderr&&s.stderr.on("data",l=>{l.toString().split(`
3
- `).forEach(i=>{i.trim()&&console.error(c.dim(` \u2502 ${i}`))})});let w=await s;return console.log(c.dim(` \u2514\u2500 Complete
4
- `)),w}else return console.log(`Running: ${e} ${n.join(" ")}`),await g(e,n,{cwd:r,env:t,stdio:"pipe"})}import u from"node:fs/promises";import m from"node:path";import d from"chalk";import{execa as k}from"execa";async function x(e){try{return await k("which",[e]),!0}catch{return!1}}async function P(e,n,o=!1){try{if(e==="pnpm"&&!await x("pnpm")){await p("npx",["pnpm","install"],{cwd:n,stdio:"inherit",verbose:o});return}await p(e,["install"],{cwd:n,stdio:"inherit",verbose:o})}catch(t){throw new Error(`Failed to install dependencies with ${e}: ${t instanceof Error?t.message:"Unknown error"}`)}}async function $(e){try{return(await u.stat(m.join(e,"node_modules"))).isDirectory()}catch{return!1}}async function O(e,n=!1){if(!await $(e)){console.log(d.bold(`Installing dependencies...
5
- `));try{let t=await u.access(m.join(e,"pnpm-lock.yaml")).then(()=>!0).catch(()=>!1),r=await u.access(m.join(e,"package-lock.json")).then(()=>!0).catch(()=>!1);await P(t?"pnpm":r?"npm":"pnpm",e,n),console.log(d.green(`Dependencies installed
6
- `))}catch(t){throw console.error(d.red(`
7
- Failed to install dependencies`)),t}}}import{execa as h}from"execa";import a from"chalk";async function b(){let{stdout:e}=await h("npx",["wrangler","kv","namespace","list"]);return JSON.parse(e)}async function v(e){let{stdout:n}=await h("npx",["wrangler","kv","namespace","create",e]);return K(n)}function K(e){let n=e.match(/"id":\s*"([a-f0-9]+)"/);if(!n||!n[1])throw new Error("Failed to parse namespace ID from wrangler output");return n[1]}async function N(e){console.log(a.bold(`Checking KV namespace: ${e}
8
- `));try{let o=(await b()).find(r=>r.title===e);if(o)return console.log(a.green(`Linking to existing KV namespace: ${e} (${o.id})
9
- `)),o.id;console.log(a.bold(`Creating new KV namespace: ${e}
10
- `));let t=await v(e);return console.log(a.green(`Created KV namespace: ${e} (${t})
11
- `)),t}catch(n){throw console.error(a.red(`
12
- Failed to get or create KV namespace: ${e}`),n instanceof Error?a.dim(`
13
- ${n.message}`):""),n}}export{p as a,P as b,O as c,N as d};
@@ -1,6 +0,0 @@
1
- import{a as c,b as l,f as m,g as f}from"./chunk-LCSNH5IG.js";import r from"chalk";import{execa as w}from"execa";async function x(D,...g){let i=process.cwd();try{let a=g.filter(t=>t!=="--");if(!a||a.length===0)throw new Error(`No command provided. Usage: every app remote-d1-shell -- <command>
2
- Example: every app remote-d1-shell -- npx drizzle-kit migrate`);let[e,...s]=a;if(!e)throw new Error("Invalid command");let o=await m(i);if(!o.d1_databases||o.d1_databases.length===0)throw new Error("No D1 databases found in wrangler.jsonc. Please add a D1 database configuration.");let n=o.d1_databases[0].database_name;if(!n)throw new Error("No database_name found in D1 database configuration in wrangler.jsonc.");console.log("Retrieving shell info from Cloudflare...");let[b,u,p]=await Promise.all([l(),f(),c()]),d=u.find(t=>t.name===n);if(!d)throw new Error(`Database "${n}" not found in your Cloudflare account. Have you run \`every app deploy\` to create the database?`);let h=d.uuid;console.log(r.bold(`
3
- Running: ${r.cyan([e,...s].join(" "))}
4
- `)),await w(e,s,{cwd:i,stdio:"inherit",env:{...process.env,CLOUDFLARE_ACCOUNT_ID:b,CLOUDFLARE_DATABASE_ID:h,CLOUDFLARE_API_TOKEN:p}}),console.log(`
5
- Command executed!`)}catch(a){throw console.error(r.red(`
6
- Failed to generate shell configuration:`),a instanceof Error?a.message:a),a}}export{x as remoteD1Shell};