everyapp 0.2.0 → 0.2.2
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.
- package/README.md +12 -12
- package/dist/bash-complete.js +1 -1
- package/dist/{chunk-FX3COD5Z.js → chunk-7BOQJFI5.js} +1 -1
- package/dist/{chunk-UGQQTUTQ.js → chunk-7YVJFS4A.js} +1 -1
- package/dist/{chunk-RUQ6WEWY.js → chunk-DLGPLHBH.js} +16 -16
- package/dist/{chunk-H4JYEFV2.js → chunk-FD6K2YA7.js} +1 -1
- package/dist/chunk-GAJEQYJH.js +39 -0
- package/dist/{chunk-CEOIDQLQ.js → chunk-O2KDOP5R.js} +1 -1
- package/dist/{chunk-KZH54DDZ.js → chunk-OI2MBGBG.js} +1 -1
- package/dist/{chunk-MTESAO7S.js → chunk-POSDLD3G.js} +7 -7
- package/dist/{chunk-DHWAR5AE.js → chunk-RB5D2R45.js} +1 -1
- package/dist/{chunk-7EBQPYFG.js → chunk-U4LIQ5VR.js} +1 -1
- package/dist/{chunk-F3HDGVHB.js → chunk-VP6SKW44.js} +1 -1
- package/dist/{chunk-L3RGZX6J.js → chunk-XTO2VTPY.js} +1 -1
- package/dist/{create-GG6PN3HY.js → create-DYQ3NBWJ.js} +1 -1
- package/dist/{deploy-SERRD75Z.js → deploy-PYTCMDGV.js} +1 -1
- package/dist/{deploy-7OPEPS4F.js → deploy-RMAHOA4Z.js} +2 -2
- package/dist/{dev-FLIUBC52.js → dev-SAE237FS.js} +0 -0
- package/dist/index.js +1 -1
- package/dist/{login-5YTO7Z67.js → login-B6EF3SMX.js} +1 -1
- package/dist/{logout-ZOK6ABBB.js → logout-XMKZBLNV.js} +1 -1
- package/dist/{remoteD1Shell-ZNASWJ4Q.js → remoteD1Shell-A67JMO3H.js} +1 -1
- package/dist/{setupLocal-UDMQQEBD.js → setupLocal-TZJUW5ES.js} +1 -1
- package/gateway/every-app-gateway-build.tar.gz +0 -0
- package/package.json +1 -1
- package/dist/chunk-SUM3EFB4.js +0 -39
package/README.md
CHANGED
|
@@ -5,11 +5,8 @@ CLI for [Every App](https://everyapp.dev) - deploy and manage self-hosted apps o
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# Run directly with npx
|
|
9
|
-
npx everyapp <command>
|
|
10
|
-
|
|
11
|
-
# Or install globally
|
|
12
|
-
npm install -g everyapp
|
|
8
|
+
# Run the latest CLI directly with npx
|
|
9
|
+
npx -y everyapp@latest <command>
|
|
13
10
|
```
|
|
14
11
|
|
|
15
12
|
## Commands
|
|
@@ -19,7 +16,7 @@ npm install -g everyapp
|
|
|
19
16
|
Deploy the Every App Gateway to your Cloudflare account:
|
|
20
17
|
|
|
21
18
|
```bash
|
|
22
|
-
npx everyapp gateway deploy
|
|
19
|
+
npx -y everyapp@latest gateway deploy
|
|
23
20
|
```
|
|
24
21
|
|
|
25
22
|
### Create a new app
|
|
@@ -27,10 +24,11 @@ npx everyapp gateway deploy
|
|
|
27
24
|
Create a new app from the starter template:
|
|
28
25
|
|
|
29
26
|
```bash
|
|
30
|
-
npx everyapp app create [name]
|
|
27
|
+
npx -y everyapp@latest app create [name]
|
|
31
28
|
```
|
|
32
29
|
|
|
33
30
|
This will:
|
|
31
|
+
|
|
34
32
|
1. Prompt for an app ID (or use the provided name)
|
|
35
33
|
2. Deploy to Cloudflare (D1 database, KV namespace, Worker)
|
|
36
34
|
3. Configure wrangler.jsonc, package.json, and .env files
|
|
@@ -41,7 +39,7 @@ This will:
|
|
|
41
39
|
Deploy your app to Cloudflare:
|
|
42
40
|
|
|
43
41
|
```bash
|
|
44
|
-
npx everyapp app deploy
|
|
42
|
+
npx -y everyapp@latest app deploy
|
|
45
43
|
```
|
|
46
44
|
|
|
47
45
|
Run this from your app directory to build and deploy updates.
|
|
@@ -51,10 +49,11 @@ Run this from your app directory to build and deploy updates.
|
|
|
51
49
|
Set up local development for an existing Every App app (for example, after cloning a repo):
|
|
52
50
|
|
|
53
51
|
```bash
|
|
54
|
-
npx everyapp app setup-local
|
|
52
|
+
npx -y everyapp@latest app setup-local
|
|
55
53
|
```
|
|
56
54
|
|
|
57
55
|
This will:
|
|
56
|
+
|
|
58
57
|
1. Verify Cloudflare and gateway setup
|
|
59
58
|
2. Install dependencies
|
|
60
59
|
3. Create or refresh `.env.local`
|
|
@@ -65,16 +64,17 @@ This will:
|
|
|
65
64
|
Run commands with access to your production D1 database:
|
|
66
65
|
|
|
67
66
|
```bash
|
|
68
|
-
npx everyapp app remote-d1-shell -- <command>
|
|
67
|
+
npx -y everyapp@latest app remote-d1-shell -- <command>
|
|
69
68
|
```
|
|
70
69
|
|
|
71
70
|
Examples:
|
|
71
|
+
|
|
72
72
|
```bash
|
|
73
73
|
# Run migrations
|
|
74
|
-
npx everyapp app remote-d1-shell -- npx drizzle-kit migrate
|
|
74
|
+
npx -y everyapp@latest app remote-d1-shell -- npx drizzle-kit migrate
|
|
75
75
|
|
|
76
76
|
# Open Drizzle Studio
|
|
77
|
-
npx everyapp app remote-d1-shell -- npx drizzle-kit studio
|
|
77
|
+
npx -y everyapp@latest app remote-d1-shell -- npx drizzle-kit studio
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
## Documentation
|
package/dist/bash-complete.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as o,b as s}from"./chunk-
|
|
2
|
+
import{a as o,b as s}from"./chunk-POSDLD3G.js";import"./chunk-RB5D2R45.js";import"./chunk-YJ2DKIZS.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,4 +1,4 @@
|
|
|
1
|
-
import{c as l,d as m,e as f,m as g,n as w,o as y}from"./chunk-
|
|
1
|
+
import{c as l,d as m,e as f,m as g,n as w,o as y}from"./chunk-DLGPLHBH.js";import{c as d}from"./chunk-U4LIQ5VR.js";import{c as h,d as k}from"./chunk-WO3NE7ZU.js";import I from"enquirer";import p from"chalk";async function x(){if(process.env.CLOUDFLARE_API_TOKEN){let r=process.env.CLOUDFLARE_ACCOUNT_ID;return r?f(r):(console.log(p.yellow(`
|
|
2
2
|
CLOUDFLARE_ACCOUNT_ID is required when using CLOUDFLARE_API_TOKEN
|
|
3
3
|
`)),d(1))}let e=await g(),{account:t,otherAccounts:o}=await y(e);return w(t,o),{id:t.account.id,name:t.account.name}}async function C(e="this",t=!1){let o=await x();if(process.env.CLOUDFLARE_API_TOKEN&&(console.log(p.dim(` ${o.name} (${o.id})`)),console.log()),t)return console.log(p.dim(`Skipping deployment confirmation due to -y flag.
|
|
4
4
|
`)),!0;let{confirm:r}=await I.prompt({type:"confirm",name:"confirm",message:`Do you want to deploy ${e} to ${o.name}?`,initial:!1});return r}function v({domain:e,accountId:t,mode:o,hostname:r}){let n=t?`https://dash.cloudflare.com/${t}/${e}/dns/records`:`https://dash.cloudflare.com -> ${e} -> DNS`,i=r??`todo.${e}`,s=o==="app-blocking"?[`Each app you deploy will live at [app].${e} - this app at`,`${i} - but that address does not resolve yet. To support`,"this, you must add the DNS record below:"]:[`Each app you deploy will live at [app].${e} - for example`,`todo.${e}. To support this, you must add the DNS record`,"below (the login this CLI uses isn't allowed to add it for you):"],a=o==="app-blocking"?["After DNS propagates, re-run everyapp app deploy.","If you know DNS is ready and this check is blocked locally, re-run with --skip-dns-check."]:["Continuing the deploy - once you add that record, apps at",`*.${e} will work properly. You only do this once.`];return["",...s,"",` Add record at: ${n}`," Type: CNAME"," Name: *",` Target: ${e}`," Proxy: ON (orange cloud)","","Here are the docs explaining how this works:"," https://developers.cloudflare.com/workers/configuration/routing/routes/"," https://github.com/cloudflare/workers-sdk/issues/5568","",...a,""].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as i,d,g as D}from"./chunk-
|
|
1
|
+
import{b as i,d,g as D}from"./chunk-DLGPLHBH.js";import{f}from"./chunk-WO3NE7ZU.js";import{execa as A}from"execa";async function E(s){let{config:t}=await f(s);if(!t.d1_databases||t.d1_databases.length===0)throw new Error("No D1 databases found in everyapp.config.ts. Please add a D1 resource declaration.");let a=t.d1_databases[0];if(!a)throw new Error("No D1 database configuration found.");let e=a.database_name;if(!e)throw new Error("No database_name found in generated D1 database configuration.");let[n,r]=await Promise.all([d(),i()]),o=(await D(n)).find(u=>u.name===e);if(!o)throw new Error(`Database "${e}" not found in your Cloudflare account. Have you run deployment to create the database?`);return{CLOUDFLARE_ACCOUNT_ID:n,CLOUDFLARE_DATABASE_ID:o.uuid,CLOUDFLARE_API_TOKEN:r}}async function O(s,t,a){let{cwd:e,env:n={},verbose:r=!1}=a,c=a.d1DatabaseId?{CLOUDFLARE_ACCOUNT_ID:await d(),CLOUDFLARE_DATABASE_ID:a.d1DatabaseId,CLOUDFLARE_API_TOKEN:await i()}:await E(e),o={cwd:e,stdio:r?"inherit":"pipe",env:{...process.env,...n,...c}};await A(s,t,o)}export{E as a,O as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as y}from"./chunk-
|
|
1
|
+
import{c as y}from"./chunk-U4LIQ5VR.js";import R from"node:fs/promises";import g from"node:path";import _ from"node:os";import*as A from"smol-toml";import c from"chalk";var l=class extends Error{status;codes;endpoint;constructor({message:t,status:n,codes:r,endpoint:o}){super(t),this.name="CloudflareAPIError",this.status=n,this.codes=r,this.endpoint=o}};function C(e){return e instanceof l&&(e.status===401||e.status===403||e.codes.includes(1e4))}function x(){let e=_.homedir(),t=_.platform(),n;return t==="win32"?n=g.join(process.env.LOCALAPPDATA||g.join(e,"AppData","Local"),".wrangler"):t==="darwin"?n=g.join(e,"Library","Preferences",".wrangler"):n=g.join(e,".wrangler"),g.join(n,"config","default.toml")}async function B(){let e=x();try{let t=await R.readFile(e,"utf-8"),n=A.parse(t);if(!n.oauth_token||!n.refresh_token)throw new Error("OAuth tokens not found in wrangler config");return n}catch(t){throw t.code==="ENOENT"?new Error("Wrangler config not found. Please run 'npx wrangler login' first."):t}}async function F(e){let t=x(),n=g.dirname(t);await R.mkdir(n,{recursive:!0});let r=A.stringify(e);await R.writeFile(t,r,"utf-8")}function M(e){let t=new Date(e).getTime(),n=Date.now(),r=1*60*1e3;return t-n<r}async function W(e){let t=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:e,client_id:"54d11594-84e4-41aa-b438-e81b8fa78ee7"})});if(!t.ok)throw new Error(`Failed to refresh OAuth token: ${t.status} ${t.statusText}`);let n=await t.json();return{oauth_token:n.access_token,expiration_time:new Date(Date.now()+n.expires_in*1e3).toISOString(),refresh_token:n.refresh_token||e,scopes:n.scope?n.scope.split(" "):[]}}async function q(e={}){let{showNewUserHelp:t=!1}=e,n=!!process.env.CLOUDFLARE_API_TOKEN,r=!!process.env.CLOUDFLARE_ACCOUNT_ID;if(n&&!r&&(console.log(c.yellow(`
|
|
2
2
|
Missing CLOUDFLARE_ACCOUNT_ID
|
|
3
3
|
`)),console.log(`When using CLOUDFLARE_API_TOKEN, you must also set CLOUDFLARE_ACCOUNT_ID.
|
|
4
4
|
`),console.log(c.dim(` export CLOUDFLARE_ACCOUNT_ID=<your_account_id>
|
|
@@ -15,33 +15,33 @@ Please log in to Cloudflare.
|
|
|
15
15
|
`)),console.log(c.dim(` 2. Check your email to verify your email address
|
|
16
16
|
`)),console.log(c.dim(" 3. Log in to Cloudflare via the CLI:")),console.log(c.cyan(` npx wrangler login
|
|
17
17
|
`)),console.log(c.dim(" - Learn more: ")+c.cyan(`https://developers.cloudflare.com/workers/wrangler/commands/#login
|
|
18
|
-
`))),await y(1)}}async function I(){let e=process.env.CLOUDFLARE_API_TOKEN;if(e)return e;let t=await B();if(M(t.expiration_time)){let n=await W(t.refresh_token);return await F(n),n.oauth_token}return t.oauth_token}async function i(e,t={}){let n=await I(),r=typeof FormData<"u"&&t.body instanceof FormData,o=await fetch(`https://api.cloudflare.com/client/v4${e}`,{...t,headers:{Authorization:`Bearer ${n}`,...r?{}:{"Content-Type":"application/json"},...t.headers}}),a;try{a=await o.json()}catch(
|
|
18
|
+
`))),await y(1)}}async function I(){let e=process.env.CLOUDFLARE_API_TOKEN;if(e)return e;let t=await B();if(M(t.expiration_time)){let n=await W(t.refresh_token);return await F(n),n.oauth_token}return t.oauth_token}async function i(e,t={}){let n=await I(),r=typeof FormData<"u"&&t.body instanceof FormData,o=await fetch(`https://api.cloudflare.com/client/v4${e}`,{...t,headers:{Authorization:`Bearer ${n}`,...r?{}:{"Content-Type":"application/json"},...t.headers}}),a;try{a=await o.json()}catch(f){throw o.ok?f:new l({message:`Cloudflare API request failed: ${o.status} ${o.statusText||"Invalid JSON response"}`,status:o.status,codes:[],endpoint:e})}let s=Array.isArray(a.errors)?a.errors:[],m=s.map(f=>f.code).filter(f=>typeof f=="number");if(!o.ok){let f=s.length?s.map(w=>`[${w.code}] ${w.message}`).join(", "):o.statusText;throw new l({message:`Cloudflare API request failed: ${o.status} ${f}`,status:o.status,codes:m,endpoint:e})}if(!a.success){let f=s.map(w=>`[${w.code}] ${w.message}`).join(", ");throw new l({message:`Cloudflare API error: ${f}`,status:o.status,codes:m,endpoint:e})}return a.result}async function u(){let e=process.env.CLOUDFLARE_ACCOUNT_ID;if(e)return e;let t=await i("/accounts");if(!t||t.length===0)throw new Error("No Cloudflare accounts found");let n=t[0];if(!n)throw new Error("No Cloudflare accounts found");return n.id}async function V(e){let t=await i(`/accounts/${e}`);if(!t||!t.id)throw new Error(`Account ${e} not found`);return t}async function E(e){try{let t=await i(`/accounts/${e}/workers/subdomain`);if(!t||!t.subdomain)throw new Error("No workers.dev subdomain found for this account");return t.subdomain}catch(t){throw new Error(`Failed to get workers.dev subdomain: ${t instanceof Error?t.message:"Unknown error"}`)}}async function P(e,t){let n=t||await u(),r=await E(n);return`https://${e}.${r}.workers.dev`}var v="every-app-gateway";async function K(e){let t=e||await u();try{let o=(await i(`/accounts/${t}/workers/domains?service=${encodeURIComponent(v)}&per_page=100`)).filter(a=>a.service===v&&typeof a.hostname=="string"&&a.hostname.length>0).map(a=>a.hostname).sort((a,s)=>a.length-s.length||a.localeCompare(s))[0];if(o)return`https://${o}`}catch(n){if(!C(n))throw n}return P(v,t)}import k from"chalk";var T={EMAIL_NOT_VERIFIED:10034,R2_NOT_ENABLED:10042},G={[T.EMAIL_NOT_VERIFIED]:{userMessage:"Almost there! Your Cloudflare account email needs to be verified first.",action:`To verify your email address:
|
|
19
19
|
|
|
20
20
|
1. Check your inbox for a verification email from Cloudflare
|
|
21
21
|
2. Click the verification link in the email
|
|
22
|
-
3. Or visit ${
|
|
22
|
+
3. Or visit ${k.cyan("https://dash.cloudflare.com/profile")} to resend the verification email
|
|
23
23
|
|
|
24
24
|
Then run this command again.`},[T.R2_NOT_ENABLED]:{userMessage:"R2 not enabled",action:`R2 is Cloudflare's file storage service, used for storing images and files.
|
|
25
25
|
|
|
26
|
-
${
|
|
26
|
+
${k.cyan("https://dash.cloudflare.com/{accountId}/r2/plans")}
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${k.dim(" Visit the URL above to enable R2, then run this command again.")}`}};function z(e){let t=e.match(/\[code:\s*(\d+)\]/);if(t?.[1])return parseInt(t[1],10);let n=e.match(/"code"\s*:\s*(\d+)/);if(n?.[1])return parseInt(n[1],10);let r=e.match(/\[(\d{5})\]/);if(r?.[1])return parseInt(r[1],10)}function $(e){let t=G[e];if(t)return{code:e,...t}}function j(e){let t="";return e instanceof Error?(t=e.message,"stdout"in e&&typeof e.stdout=="string"&&(t+=`
|
|
29
29
|
`+e.stdout),"stderr"in e&&typeof e.stderr=="string"&&(t+=`
|
|
30
30
|
`+e.stderr),"all"in e&&typeof e.all=="string"&&(t+=`
|
|
31
31
|
`+e.all)):typeof e=="string"&&(t=e),t}async function H(e,t){let n=e.action,r=t.accountId;if(!r&&n.includes("{accountId}"))try{r=await u()}catch{}return r&&(n=n.replace(/{accountId}/g,r)),`
|
|
32
|
-
${
|
|
32
|
+
${k.yellow(e.userMessage)}
|
|
33
33
|
|
|
34
34
|
${n}
|
|
35
|
-
`}async function J(e,t={}){let n=j(e),r=e instanceof
|
|
36
|
-
`)),console.log(
|
|
37
|
-
`)),console.log(
|
|
38
|
-
`));let t=await Q();console.log(
|
|
35
|
+
`}async function J(e,t={}){let n=j(e),r=e instanceof l?e.codes.find(s=>$(s)):z(n);if(r===void 0)return;let o=$(r);return o?{formatted:await H(o,t),code:r}:void 0}import d from"chalk";import Z from"enquirer";async function Y(e,t){try{let n=t?{subdomain:t}:{},r=await i(`/accounts/${e}/workers/subdomain`,{method:"PUT",body:JSON.stringify(n)});if(!r||!r.subdomain)throw new Error("Failed to initialize workers.dev subdomain");return r.subdomain}catch(n){throw new Error(`Failed to initialize workers.dev subdomain: ${n instanceof Error?n.message:"Unknown error"}`)}}async function Q(){return(await Z.prompt({type:"input",name:"subdomain",message:" Choose a subdomain name:",validate:t=>!t||t.trim()===""?"Subdomain cannot be empty":/^[a-z0-9-]+$/.test(t)?t.startsWith("-")||t.endsWith("-")?"Subdomain cannot start or end with a hyphen":!0:"Subdomain must contain only lowercase letters, numbers, and hyphens"})).subdomain.trim()}async function X(){let e=await u();try{return await E(e)}catch{console.log(),console.log(d.yellow(` Cloudflare Workers needs an account subdomain.
|
|
36
|
+
`)),console.log(d.dim(" Cloudflare requires this one-time account setup before its first Worker upload.")),console.log(d.dim(" Every App keeps private app workers.dev routes disabled; your apps still use")),console.log(d.dim(` the Gateway's custom domain.
|
|
37
|
+
`)),console.log(d.dim(" Choose a unique account subdomain, such as your name.")),console.log(d.dim(` Example: "janedoe.workers.dev"
|
|
38
|
+
`));let t=await Q();console.log(d.dim(`
|
|
39
39
|
Creating subdomain: ${t}...
|
|
40
|
-
`));try{let n=await Y(e,t);return console.log(
|
|
41
|
-
`)),n}catch(n){throw console.error(
|
|
42
|
-
Failed to create subdomain`),
|
|
43
|
-
${n instanceof Error?n.message:"Unknown error"}`)),n}}}import{z as p}from"zod";var ee=p.object({uuid:p.string(),name:p.string(),created_at:p.string().optional(),version:p.string().optional()}),S=p.array(ee);async function
|
|
40
|
+
`));try{let n=await Y(e,t);return console.log(d.green(` Successfully created subdomain: ${d.cyan(n)}
|
|
41
|
+
`)),n}catch(n){throw console.error(d.red(`
|
|
42
|
+
Failed to create subdomain`),d.dim(`
|
|
43
|
+
${n instanceof Error?n.message:"Unknown error"}`)),n}}}import{z as p}from"zod";var ee=p.object({uuid:p.string(),name:p.string(),created_at:p.string().optional(),version:p.string().optional()}),S=p.array(ee);async function b(e){let t=await i(`/accounts/${e}/d1/database?per_page=1000`);return S.parse(t)}async function te(e,t){let n=await i(`/accounts/${t}/d1/database`,{method:"POST",body:JSON.stringify({name:e})});if(!n||!n.uuid)throw new Error("Failed to create D1 database: no UUID returned");return n.uuid}async function ne(e,t){let r=(await b(t)).find(a=>a.name===e);return r?{id:r.uuid,name:e,wasCreated:!1}:{id:await te(e,t),name:e,wasCreated:!0}}var N="every-app-gateway",re="every-app-gateway",D="APP__";async function L(e){let t=e??await u(),r=(await b(t)).find(s=>s.name===re);if(!r)return[];let o;try{o=await ce(t,r.uuid)}catch(s){let m=s instanceof Error?s.message:String(s);if(s instanceof l&&(m.includes("no such table")||m.includes("no such column")||m.includes("D1_ERROR")))return[];throw s}let a=o.map(s=>s.worker_name).filter(s=>typeof s=="string"&&s.length>0);return[...new Set(a)].sort().map(s=>({binding:`${D}${s}`,service:s}))}async function oe(e){let t=e??await u(),r=(await se(t)).flatMap(s=>(ie(s),s.type==="service"&&s.name.startsWith(D)?[]:[{type:"inherit",name:s.name}])),o=await L(t),a=[...r,...o.map(s=>({type:"service",name:s.binding,service:s.service}))];return await ae(t,a),o}async function se(e){return(await i(`/accounts/${e}/workers/scripts/${N}/settings`)).bindings??[]}async function ae(e,t){let n=new FormData;n.set("settings",JSON.stringify({bindings:t})),await i(`/accounts/${e}/workers/scripts/${N}/settings`,{method:"PATCH",body:n})}function ie(e){if(e.name.startsWith(D)&&e.type!=="service")throw new Error(`Gateway binding "${e.name}" uses the reserved ${D} namespace but is not a service binding.`)}async function ce(e,t){let n=await i(`/accounts/${e}/d1/database/${t}/query`,{method:"POST",body:JSON.stringify({sql:"SELECT worker_name FROM apps WHERE status = 'active' AND worker_name IS NOT NULL AND hostname IS NOT NULL"})}),r=Array.isArray(n)?n[0]:n;return r?.results??r?.result??[]}import ue from"chalk";async function de({accountId:e,domain:t}){let r=(await i(`/zones?name=${encodeURIComponent(t)}&account.id=${encodeURIComponent(e)}&per_page=50`)).find(o=>o.name===t);if(!r)throw new Error(`Cloudflare zone "${t}" was not found on the authenticated account. Add the zone to this account or pass a different --domain.`);return r}async function le({zoneId:e,domain:t}){let n=`*.${t}`;try{return(await i(`/zones/${e}/dns_records?name=${encodeURIComponent(n)}&per_page=100`)).find(a=>a.name===n&&["A","AAAA","CNAME"].includes(a.type)&&a.proxied===!0)?"exists":(await i(`/zones/${e}/dns_records`,{method:"POST",body:JSON.stringify({type:"CNAME",name:"*",content:t,proxied:!0,ttl:1})}),"created")}catch(r){if(C(r))return await U(`everyapp-wildcard-check.${t}`)?"exists":"unauthorized";throw r}}async function U(e){let t=new URL("https://cloudflare-dns.com/dns-query");t.searchParams.set("name",e),t.searchParams.set("type","A");try{let n=await fetch(t,{headers:{accept:"application/dns-json"}});if(!n.ok)throw new Error(`Cloudflare DoH returned HTTP ${n.status}`);let r=await n.json();return r.Status===0&&Array.isArray(r.Answer)&&r.Answer.length>0}catch(n){return console.log(ue.dim(` Could not verify DNS through Cloudflare DoH (${n instanceof Error?n.message:String(n)}).`)),!1}}async function fe(e){return(await i(`/accounts/${e}/storage/kv/namespaces?per_page=1000`)).map(n=>({id:n.id,title:n.title}))}async function me(e,t){let n=await i(`/accounts/${t}/storage/kv/namespaces`,{method:"POST",body:JSON.stringify({title:e})});if(!n||!n.id)throw new Error("Failed to create KV namespace: no ID returned");return n.id}async function ge(e,t){let r=(await fe(t)).find(a=>a.title===e);return r?{id:r.id,name:e,wasCreated:!1}:{id:await me(e,t),name:e,wasCreated:!0}}async function pe(e){return(await i(`/accounts/${e}/r2/buckets?per_page=1000`)).buckets.map(n=>({name:n.name,creation_date:n.creation_date}))}async function he(e,t){let n=await i(`/accounts/${t}/r2/buckets`,{method:"POST",body:JSON.stringify({name:e})});if(!n||!n.name)throw new Error("Failed to create R2 bucket: no name returned");return n.name}async function we(e,t){return(await pe(t)).find(o=>o.name===e)?{name:e,wasCreated:!1}:(await he(e,t),{name:e,wasCreated:!0})}import h from"chalk";async function ye(){return await i("/memberships")}function O(e){return e.status==="pending"?" (pending)":""}function Ae(e,t){let n=O(e);console.log(h.dim(` ${e.account.name} (${e.account.id})${n}`)),t.length>0&&(console.log(),console.log(h.dim(" Other accounts (set CLOUDFLARE_ACCOUNT_ID to switch):")),t.forEach(r=>{let o=O(r);console.log(h.dim(` - ${r.account.name}: ${r.account.id}${o}`))})),console.log()}async function Ce(e){return console.log(h.yellow(`Multiple Cloudflare accounts found.
|
|
44
44
|
`)),console.log(`Please set the CLOUDFLARE_ACCOUNT_ID environment variable:
|
|
45
|
-
`),e.forEach(t=>{let n=
|
|
45
|
+
`),e.forEach(t=>{let n=O(t);console.log(h.dim(` ${t.account.name}: ${t.account.id}${n}`))}),console.log(h.dim(`
|
|
46
46
|
export CLOUDFLARE_ACCOUNT_ID=<account_id>
|
|
47
|
-
`)),y(1)}async function
|
|
47
|
+
`)),y(1)}async function ke(e){if(e.length===0)throw new Error("No Cloudflare accounts found");let t=process.env.CLOUDFLARE_ACCOUNT_ID;!t&&e.length>1&&await Ce(e);let n=t?e.find(o=>o.account.id===t):e[0];if(!n)throw new Error(`Account ${t} not found in your Cloudflare memberships`);let r=e.filter(o=>o.account.id!==n.account.id);return{account:n,otherAccounts:r}}export{q as a,I as b,i as c,u as d,V as e,P as f,b as g,ne as h,ge as i,we as j,K as k,J as l,ye as m,Ae as n,ke as o,X as p,L as q,oe as r,de as s,le as t,U as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{k as g}from"./chunk-
|
|
1
|
+
import{k as g}from"./chunk-DLGPLHBH.js";import a from"node:fs/promises";import p from"node:path";import h from"node:os";import y from"chalk";async function C(t,e,o={}){let n=o.exclude||[];await a.mkdir(e,{recursive:!0});let i=await a.readdir(t,{withFileTypes:!0});for(let s of i){let r=p.join(t,s.name),c=p.join(e,s.name);n.some(l=>s.name===l)||(s.isDirectory()?await C(r,c,o):await a.copyFile(r,c))}}async function T(t){try{return(await a.stat(t)).isDirectory()}catch{return!1}}async function D({targetDir:t,appId:e,gatewayUrl:o}){let n=o??await g(),i=`# Vite client-side secrets
|
|
2
2
|
VITE_APP_ID=${e}
|
|
3
3
|
VITE_GATEWAY_URL=${n}
|
|
4
4
|
# Set Cloudflare secrets locally
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{c as I,d as k,e as M}from"./chunk-7BOQJFI5.js";import{c as j,d as F}from"./chunk-XTO2VTPY.js";import{f as Y}from"./chunk-O2KDOP5R.js";import{f as v}from"./chunk-FD6K2YA7.js";import{a as B,b as U,c as O,d as w}from"./chunk-BIXKPCDH.js";import{d as h,h as N,i as $,j as _,k as x,l as A,p as V,r as W,u as T}from"./chunk-DLGPLHBH.js";import{c as d}from"./chunk-U4LIQ5VR.js";import{c as K,d as z,e as E,f as L}from"./chunk-WO3NE7ZU.js";import u from"chalk";import p from"chalk";async function H({appId:e,d1Bindings:o=["DB"],kvBindings:t=["KV"],needsR2Bucket:n=!1,verbose:i=!1}){let a=[o.length>0?"D1 Database":null,t.length>0?"KV Store":null,n?"R2 Bucket":null].filter(Boolean);a.length>0&&console.log(`
|
|
2
|
+
Setting up your Cloudflare ${a.join(", ")}...
|
|
3
|
+
`);let s=await h(),l=E(e),r;n&&(r=await ge(l,s,i));let g={};for(let c of o){let y=E(e,c);g[c]=await le(y,s,i)}let m={};for(let c of t){let y=E(e,c);m[c]=await ce(y,s,i)}return{d1DatabaseId:g.DB,kvNamespaceId:m.KV,d1DatabaseIds:g,kvNamespaceIds:m,r2BucketName:r,resourceName:l}}async function le(e,o,t){t&&(console.log(p.bold(`Processing D1 database...
|
|
4
|
+
`)),console.log(` Checking D1 database: ${e}`));let n=await N(e,o);return t?n.wasCreated?console.log(p.green(` Created D1 database: ${e} (${n.id})
|
|
5
|
+
`)):console.log(p.dim(` Linking to existing D1 database: ${e} (${n.id})
|
|
6
|
+
`)):n.wasCreated?console.log(p.green(" D1 successfully created.")):console.log(" D1 already set up."),n.id}async function ce(e,o,t){t&&(console.log(p.bold(`Processing KV namespace...
|
|
7
|
+
`)),console.log(` Checking KV namespace: ${e}`));let n=await $(e,o);return t?n.wasCreated?console.log(p.green(` Created KV namespace: ${e} (${n.id})
|
|
8
|
+
`)):console.log(p.dim(` Linking to existing KV namespace: ${e} (${n.id})
|
|
9
|
+
`)):n.wasCreated?console.log(p.green(" KV successfully created.")):console.log(" KV already set up."),n.id}async function ge(e,o,t){t&&(console.log(p.bold(`Processing R2 bucket...
|
|
10
|
+
`)),console.log(` Checking R2 bucket: ${e}`));let n;try{n=await _(e,o)}catch(i){let a=await A(i,{accountId:o});throw a&&(console.log(a.formatted),await d(1)),i}return t?n.wasCreated?console.log(p.green(` Created R2 bucket: ${e}
|
|
11
|
+
`)):console.log(p.dim(` Linking to existing R2 bucket: ${e}
|
|
12
|
+
`)):n.wasCreated?console.log(p.green(" R2 successfully created.")):console.log(" R2 already set up."),n.name}import D from"chalk";import R from"node:fs/promises";import b from"node:path";import{parse as pe}from"jsonc-parser";async function q({cwd:e,buildCommand:o,gatewayUrl:t,appId:n,generatedWranglerConfigPath:i,verbose:a}){let s={...process.env,VITE_GATEWAY_URL:t,VITE_APP_ID:n,EVERYAPP_GATEWAY_URL:t,EVERYAPP_APP_ID:n};try{await ue(e),o?await v(o,[],{cwd:e,description:`Building your application...
|
|
13
|
+
`,env:s,shell:!0,verbose:a}):await me(e)?await v("npx",["vite","build"],{cwd:e,description:`Building your application...
|
|
14
|
+
`,env:s,verbose:a}):a&&console.log(D.dim("No Vite config found; deploying generated worker config."));let l=await de({cwd:e,generatedWranglerConfigPath:i,verbose:a}),{command:r,argsPrefix:g}=await j(e,"wrangler","wrangler");await v(r,[...g,"deploy","-c",l],{cwd:e,description:`Deploying your private application worker to Cloudflare...
|
|
15
|
+
|
|
16
|
+
This could take up to a minute.`,env:s,verbose:a})}catch(l){let r=await A(l);throw r&&(console.log(r.formatted),await d(1)),console.error(D.red(`
|
|
17
|
+
Failed to build or deploy`)),l}}async function de({cwd:e,generatedWranglerConfigPath:o,verbose:t}){let n=b.join(e,"dist","server","wrangler.json");return await Q(n)?(await fe(n,o),t&&console.log(D.dim(`Using Vite-built deploy config: ${b.relative(e,n)}`)),n):(t&&console.log(D.dim("No Vite-built wrangler config found; using generated wrangler config.")),o)}async function fe(e,o){let t=await J(e),n=await J(o);delete t.configPath,delete t.userConfigPath,delete t.routes,delete t.route;let i=n.name;if(typeof i!="string"||i.length===0)throw new Error(`Generated config ${o} has no worker name; aborting deploy.`);let a=n.vars;for(let l of["EVERYAPP_IDENTITY_PUBLIC_KEYS","EVERYAPP_IDENTITY_ISSUER"]){let r=a?.[l];if(typeof r!="string"||r.length===0)throw new Error(`Generated config ${o} is missing ${l}; aborting deploy.`)}t.name=i,"topLevelName"in t&&(t.topLevelName=i),t.workers_dev=!1,t.preview_urls=!1,t.vars={...t.vars,...a};let s=n.services;if(Array.isArray(s)&&s.length>0){let l=new Set(s.map(g=>g.binding)),r=Array.isArray(t.services)?t.services:[];t.services=[...r.filter(g=>!l.has(g.binding)),...s]}await R.writeFile(e,JSON.stringify(t,null,2)+`
|
|
18
|
+
`,"utf-8")}async function J(e){let o=await R.readFile(e,"utf-8"),t=[],n=pe(o,t,{allowTrailingComma:!0});if(t.length>0||n===void 0)throw new Error(`Failed to parse ${e} as JSONC.`);return n}async function ue(e){await R.rm(b.join(e,"dist","server","wrangler.json"),{force:!0})}async function Q(e){try{return await R.access(e),!0}catch(o){if(o instanceof Error&&"code"in o&&o.code==="ENOENT")return!1;throw o}}async function me(e){let o=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs","vite.config.cjs","vite.config.cts"];return(await Promise.all(o.map(n=>Q(b.join(e,n))))).some(Boolean)}import f from"chalk";async function X(e){return new w({gatewayUrl:e}).getIdentityKeys()}async function Z(e){try{let t=await new w({gatewayUrl:e}).whoami();return t.capabilities?.appGateway===!0?{organizationId:t.organizationId,gatewayBinding:{organizationId:t.organizationId}}:(console.log(f.yellow("Upgrade your gateway to enable the AI proxy binding: npx everyapp gateway deploy")),{organizationId:t.organizationId})}catch(o){throw await te(o),o}}async function ee(e){let{appId:o,workerName:t,manifest:n,gatewayUrl:i,verbose:a=!1,appName:s,appDescription:l}=e;try{console.log(""),a&&console.log("Registering app with gateway control plane...");let r=new w({gatewayUrl:i}),g=s||o,m=l||o,c=await r.registerApp({appId:o,name:g,description:m,workerName:t,manifest:n});return a&&(console.log(f.dim(` Gateway app: ${c.appSlug} (${c.existingApp?"updated":"created"})`)),console.log(f.dim(` Default access: ${c.defaultAccess?"enabled":"disabled"}`)),console.log(f.dim(` Access granted to ${c.grantedUserCount} users
|
|
19
|
+
`))),{hostname:c.hostname}}catch(r){throw await te(r),r}}async function te(e){B(e)&&(console.log(f.yellow(`
|
|
20
|
+
Gateway out of date
|
|
21
|
+
`)),console.log(f.dim(" Run: `npx everyapp gateway deploy` to update.\n")),await d(1)),O(e)&&(console.log(f.yellow(`
|
|
22
|
+
Gateway authorization failed
|
|
23
|
+
`)),console.log(f.dim(`${e.message}
|
|
24
|
+
`)),await d(1)),U(e)&&(console.log(f.yellow(`
|
|
25
|
+
Gateway internal APIs are disabled
|
|
26
|
+
`)),console.log(f.dim(` This gateway is running in hosted mode (or has invalid deployment mode config), so /api/deploy/* is intentionally unavailable.
|
|
27
|
+
`)),await d(1)),console.error(f.red(`
|
|
28
|
+
Failed to register app with gateway`),e instanceof Error?`
|
|
29
|
+
${e.message}
|
|
30
|
+
`:"")}var ne="GATEWAY_URL",oe="EVERY_APP_ORG_ID";async function ie({gatewayUrl:e,appPath:o,workerName:t,verbose:n=!1}){n&&console.log("Configuring Secrets...");try{if(await I({secretName:ne,cwd:o,workerName:t,verbose:n})||await k({secretName:ne,secretValue:e,cwd:o,workerName:t,verbose:n,description:`Setting GATEWAY_URL to: ${e}`}),!await I({secretName:oe,cwd:o,workerName:t,verbose:n})){let l=await new w({gatewayUrl:e}).whoami();await k({secretName:oe,secretValue:l.organizationId,cwd:o,workerName:t,verbose:n,description:`Setting EVERY_APP_ORG_ID to: ${l.organizationId}`})}n&&console.log(`Secret setup complete!
|
|
31
|
+
`)}catch(i){throw console.error(`
|
|
32
|
+
Failed to setup secrets`,i instanceof Error?`
|
|
33
|
+
${i.message}`:""),i}}async function Qe(e){let{cwd:o,verbose:t}=e,n=e.manifest??await z(o),i=n.id,a=K(i),s=n.resources?.d1??[],l=n.resources?.kv??[],r=await x(),g=await Z(r),{organizationId:m}=g,c=await X(r),y=c.issuer??"",C=we(i,c.issuer);C&&await ye({...C,skipDnsCheck:e.skipDnsCheck??!1}),await V();let{d1DatabaseIds:P,kvNamespaceIds:ae}=await H({appId:i,d1Bindings:s,kvBindings:l,verbose:t});console.log(),await Y({cwd:o,description:"Installing dependencies for Cloudflare deployment...",install:n.install,verbose:t}),s.length>0?await F({cwd:o,workerName:a,d1Bindings:s,d1DatabaseIds:P,migrations:n.migrations,verbose:t}):t&&console.log(u.dim(`No D1 resources declared; skipping migrations.
|
|
34
|
+
`));let{configPath:re}=await L(o,{manifest:n,d1DatabaseIds:P,kvNamespaceIds:ae,identityPublicKeys:c.keys,vars:{EVERYAPP_IDENTITY_ISSUER:y},gatewayBinding:g.gatewayBinding});await q({cwd:o,buildCommand:n.build,gatewayUrl:r,appId:i,generatedWranglerConfigPath:re,verbose:t});let{hostname:S}=await ee({appId:i,workerName:a,manifest:n,gatewayUrl:r,verbose:t,appName:n.name,appDescription:n.description});await ie({gatewayUrl:r,appPath:o,workerName:a,verbose:t});let se=await h(),G=await W(se);return t&&console.log(u.dim(` Reconciled ${G.length} gateway app service binding${G.length===1?"":"s"}`)),{liveUrl:`https://${S}`,gatewayUrl:r,organizationId:m,hostname:S}}function we(e,o){if(!o)return null;let t=new URL(o).hostname;return{hostname:`${e}.${t}`,apex:t,issuerHost:t,isWorkersDev:t.endsWith(".workers.dev")}}async function ye({hostname:e,apex:o,issuerHost:t,isWorkersDev:n,skipDnsCheck:i}){if(n&&(console.log(u.red(`
|
|
35
|
+
Gateway custom domain required
|
|
36
|
+
`)),console.log([` The gateway is currently configured at ${u.cyan(t)}.`," App subdomains cannot work on workers.dev domains.","",` Run ${u.cyan("everyapp gateway deploy --domain <apex-domain>")} first, then deploy the app again.`,""].join(`
|
|
37
|
+
`)),await d(1)),i||await T(e))return;console.log(u.red(`
|
|
38
|
+
App subdomain DNS is not ready
|
|
39
|
+
`));let a=await h().catch(()=>null);console.log(u.yellow(M({domain:o,accountId:a,mode:"app-blocking",hostname:u.cyan(e)}))),await d(1)}export{Qe as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as u}from"./chunk-
|
|
1
|
+
import{f as u}from"./chunk-FD6K2YA7.js";import{d}from"./chunk-BIXKPCDH.js";import{c as y,d as f,k as w}from"./chunk-DLGPLHBH.js";import{c as i}from"./chunk-U4LIQ5VR.js";import t from"chalk";var P="every-app-gateway",o=class extends Error{url;cause;constructor(n,a){super(`Could not reach your Gateway at ${n} (${k(a)})`),this.name="GatewayUnreachableError",this.url=n,this.cause=a}};function b(e){return`Could not reach your Gateway at ${e.url} (${k(e.cause)})`}async function R(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)}),!0}catch(n){let a=n instanceof Error?n.message.toLowerCase():"",r=n instanceof Error&&"cause"in n&&n.cause?.code?.toLowerCase()||"";if(["ssl","tls","certificate","cert","cipher","handshake","secure"].some(s=>a.includes(s)||r.includes(s)))return!1;throw new o(e,n)}}async function G(e){let n=new d({gatewayUrl:e,getAuthToken:async()=>""});try{return await n.hasOwner()}catch(a){throw new o(e,a)}}async function x(){try{let e=await f();return await y(`/accounts/${e}/workers/scripts/${P}/settings`),!0}catch{return!1}}async function h(){return w()}async function U(){if(!await x())return{isDeployed:!1,hasOwner:!1,gatewayUrl:await h()};let n=await h(),a;try{a=await G(n)}catch(r){throw r instanceof o&&(console.log(t.yellow(`
|
|
2
2
|
Gateway unreachable
|
|
3
3
|
`)),console.log(b(r)),console.log(t.dim(` Confirm the gateway URL is correct and reachable, then run this command again.
|
|
4
4
|
`)),await i(1)),r}return{isDeployed:!0,hasOwner:a,gatewayUrl:n}}async function W(){let{isDeployed:e,hasOwner:n,gatewayUrl:a}=await U();if(e||(console.log(t.yellow(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e}from"./chunk-
|
|
1
|
+
import{c as e}from"./chunk-U4LIQ5VR.js";import n from"node:fs/promises";import p from"node:path";import o from"chalk";var i=["everyapp.config.ts"];async function l(){let t=process.cwd();for(let c of i){let r=p.join(t,c);try{await n.access(r);return}catch{}}console.log(o.yellow(`
|
|
2
2
|
Not inside an Every App project`)),console.log(o.dim(` No everyapp.config.ts found
|
|
3
3
|
`)),console.log("To create a new app, run the below command from the directory where you store your projects:"),console.log(o.dim(` npx everyapp app create
|
|
4
4
|
`)),await e(1)}export{l as a};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as t,b as a,c as r}from"./chunk-
|
|
2
|
-
`)}}),f=o({loader:async()=>{let{deploy:e}=await import("./deploy-
|
|
1
|
+
import{a as t,b as a,c as r}from"./chunk-RB5D2R45.js";import l from"node:fs";import d from"node:os";import u from"node:path";function O(e){return{process:e,os:d,fs:l,path:u}}import{buildApplication as D,buildCommand as p,buildRouteMap as R}from"@stricli/core";import{buildInstallCommand as S,buildUninstallCommand as x}from"@stricli/auto-complete";import{buildCommand as o,buildRouteMap as m}from"@stricli/core";var c=o({loader:async()=>import("./create-DYQ3NBWJ.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},yes:{kind:"boolean",brief:"Skip deployment confirmation",optional:!0}},aliases:{y:"yes"}},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 a private Cloudflare Worker from everyapp.config.ts"," 3. Configure package.json and local .env files"," 4. Install dependencies and run local migrations for the starter app","","After creation, run 'pnpm run dev' to start developing."].join(`
|
|
2
|
+
`)}}),f=o({loader:async()=>{let{deploy:e}=await import("./deploy-PYTCMDGV.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during deployment",optional:!0},yes:{kind:"boolean",brief:"Skip deployment confirmation",optional:!0},"skip-dns-check":{kind:"boolean",brief:"Skip app subdomain DNS preflight check",optional:!0},domain:{kind:"parsed",parse:String,brief:"Not for this command; configure the gateway domain instead",optional:!0,hidden:!0}},aliases:{y:"yes"}},docs:{brief:"Deploy an app to Cloudflare",fullDescription:["Deploys the current app as a private Cloudflare Worker from everyapp.config.ts.","The deployment process:"," 1. Loads and validates everyapp.config.ts"," 2. Verifies the app subdomain can resolve through Cloudflare DNS"," 3. Ensures the Cloudflare Workers account is initialized"," 4. Creates or links declared D1 databases and KV namespaces"," 5. Generates .everyapp/wrangler.json"," 6. Installs dependencies using the manifest install setting or package-manager auto-detection"," 7. Runs the configured database migration strategy against production D1"," 8. Runs the configured build, deploys, registers with the gateway, and ensures the service binding"].join(`
|
|
3
3
|
`)}}),g=o({loader:async()=>{let{generateConfig:e}=await import("./generateConfig-46Z3ERF3.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{verbose:{kind:"boolean",brief:"Show generated config details",optional:!0}}},docs:{brief:"Generate .everyapp/wrangler.json from everyapp.config.ts",fullDescription:["Loads everyapp.config.ts, validates it, and writes the generated Wrangler config consumed by Vite and Wrangler.","","Run this before invoking vite directly."].join(`
|
|
4
|
-
`)}}),y=o({loader:async()=>{let{setupLocal:e}=await import("./setupLocal-
|
|
5
|
-
`)}}),h=o({loader:async()=>{let{remoteD1Shell:e}=await import("./remoteD1Shell-
|
|
6
|
-
`)}}),n=
|
|
7
|
-
`)}}),i=v({routes:{deploy:w},docs:{brief:"Gateway management commands"}});import{buildCommand as C}from"@stricli/core";import{numberParser as k}from"@stricli/core";var s=C({loader:async()=>import("./dev-
|
|
8
|
-
`)}});var A=p({loader:async()=>{let{login:e}=await import("./login-
|
|
4
|
+
`)}}),y=o({loader:async()=>{let{setupLocal:e}=await import("./setupLocal-TZJUW5ES.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during local setup",optional:!0}}},docs:{brief:"Set up local development in an existing app",fullDescription:["Configures local development for an existing Every App project in the current directory.","","Usage: every app setup-local","","The command will:"," 1. Verify the current directory is an Every App project"," 2. Verify Cloudflare and gateway setup"," 3. Install dependencies using package-manager auto-detection"," 4. Create or refresh .env.local"," 5. Run local setup scripts for template-style apps","","This is useful after cloning an existing Every App repository."].join(`
|
|
5
|
+
`)}}),h=o({loader:async()=>{let{remoteD1Shell:e}=await import("./remoteD1Shell-A67JMO3H.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 generated Wrangler database name"," 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 everyapp app remote-d1-shell -- npx drizzle-kit migrate"," - Opening Drizzle Studio: npx everyapp app remote-d1-shell -- npx drizzle-kit studio"," - Pushing schema changes: npx everyapp 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(`
|
|
6
|
+
`)}}),n=m({routes:{create:c,deploy:f,"generate-config":g,"setup-local":y,"remote-d1-shell":h},docs:{brief:"App management commands"}});import{buildCommand as b,buildRouteMap as v}from"@stricli/core";var w=b({loader:async()=>{let{deploy:e}=await import("./deploy-RMAHOA4Z.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{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},domain:{kind:"parsed",parse:String,brief:"Custom apex domain for the gateway and app subdomains",optional:!0},yes:{kind:"boolean",brief:"Skip deployment confirmation",optional:!0}},aliases:{y:"yes"}},docs:{brief:"Deploy the gateway application to Cloudflare",fullDescription:["Downloads the gateway release, links Cloudflare resources, reconstructs app service bindings, and deploys to Cloudflare Workers.","The deployment process:"," 1. Downloads the gateway release to a temporary directory"," 2. Creates or links gateway D1/KV resources"," 3. Reconstructs service bindings from the registry"," 4. Optionally configures custom-domain routes with --domain"," 5. Runs wrangler deploy"," 6. Runs database migrations against production D1"," 7. Cleans up temporary files"].join(`
|
|
7
|
+
`)}}),i=v({routes:{deploy:w},docs:{brief:"Gateway management commands"}});import{buildCommand as C}from"@stricli/core";import{numberParser as k}from"@stricli/core";var s=C({loader:async()=>import("./dev-SAE237FS.js"),parameters:{flags:{port:{kind:"parsed",parse:k,brief:"Gateway port (defaults to $PORT, then 8787)",optional:!0},mode:{kind:"parsed",parse:String,brief:"stub (seeded dev user, default) | mirror (real login via local gateway)",optional:!0},gateway:{kind:"parsed",parse:String,brief:"mirror mode: URL of the separately-run local gateway (default http://localhost:3000)",optional:!0},baseHost:{kind:"parsed",parse:String,brief:"mirror mode: two-label base host for cookie scope (default everyapp.localhost)",optional:!0},"skip-migrations":{kind:"boolean",brief:"Start without applying local database migrations",optional:!0}}},docs:{brief:"Run the app behind a local gateway with the real perimeter",fullDescription:["Runs the app's configured dev server on an internal port and a gateway-lite","in front of it on $PORT (default 8787) \u2014 the REAL perimeter: public-route","policy, header strip/inject, a real RS256 identity JWT, and a seeded dev","user. Open http://<app-id>.localhost:8787 \u2014 the first Host label selects","the app, so portless per-worktree hosts work with no configuration.","","--mode stub (default): seeded dev user, zero setup.","--mode mirror: authenticate against a SEPARATELY-running local gateway"," (run `pnpm dev` in apps/every-app-gateway first). Real login/launcher"," are forwarded to it. Requires a two-label base host (e.g."," everyapp.localhost) so the session cookie crosses the subdomain"," boundary; the CLI prints setup guidance if the host is unusable."," Also settable via EVERYAPP_DEV_MODE; the flag wins."].join(`
|
|
8
|
+
`)}});var A=p({loader:async()=>{let{login:e}=await import("./login-B6EF3SMX.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{}},docs:{brief:"Store a gateway deploy token"}}),E=p({loader:async()=>{let{logout:e}=await import("./logout-XMKZBLNV.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{}},docs:{brief:"Remove a stored gateway deploy token"}}),L=R({routes:{app:n,dev:s,gateway:i,login:A,logout:E,install:S("everyapp",{bash:"__everyapp_bash_complete"}),uninstall:x("everyapp",{bash:!0})},docs:{brief:a,hideRoute:{install:!0,uninstall:!0}}}),Y=D(L,{name:t,versionInfo:{currentVersion:r},scanner:{allowArgumentEscapeSequence:!0}});export{O as a,Y as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s="everyapp";var t="Every App CLI - Deploy and manage apps.";var i="0.2.
|
|
1
|
+
var s="everyapp";var t="Every App CLI - Deploy and manage apps.";var i="0.2.2";export{s as a,t as b,i as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as n}from"./chunk-
|
|
1
|
+
import{c as n}from"./chunk-RB5D2R45.js";import a from"chalk";var p="https://registry.npmjs.org/everyapp?fields=dist-tags",f=2e3,i=null;function y(){i||(i=d().then(t=>t&&t!==n&&g(n,t)?{updateAvailable:!0,latestVersion:t,currentVersion:n}:{updateAvailable:!1,currentVersion:n}))}var u=!1;async function m(){if(u||!i)return;u=!0;let t=await i;h(t)}async function V(t){await m(),process.exit(t)}async function d(){try{let t=new AbortController,o=setTimeout(()=>t.abort(),f),e=await fetch(p,{signal:t.signal});return clearTimeout(o),e.ok?(await e.json())["dist-tags"].latest:null}catch{return null}}function g(t,o){let e=t.split(".").map(Number),s=o.split(".").map(Number);for(let r=0;r<Math.max(e.length,s.length);r++){let l=e[r]??0,c=s[r]??0;if(l<c)return!0;if(l>c)return!1}return!1}function h(t){t.updateAvailable&&t.latestVersion&&(console.log(),console.log(a.yellow(` Update available: ${t.currentVersion} \u2192 ${t.latestVersion}`)),console.log(a.dim(` Run latest: ${a.cyan("npx -y everyapp@latest")}`)))}export{y as a,m as b,V as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as r}from"./chunk-
|
|
1
|
+
import{f as r}from"./chunk-O2KDOP5R.js";import{c as l,f as i}from"./chunk-FD6K2YA7.js";import c from"chalk";import a from"chalk";async function s({targetDir:n,verbose:o=!1}){try{o||console.log(`
|
|
2
2
|
Setting up Cloudflare for local dev...`),await i("pnpm",["run","cf-typegen"],{cwd:n,verbose:o,logCommandToConsole:!1}),await i("pnpm",["run","build"],{cwd:n,verbose:o,logCommandToConsole:!1}),o||console.log(a.dim(` Finished.
|
|
3
3
|
`)),await i("pnpm",["run","db:migrate:local"],{cwd:n,verbose:o}),console.log(`
|
|
4
4
|
Local database migrations complete.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as u,d as w,e as y,f as p}from"./chunk-
|
|
1
|
+
import{b as u,d as w,e as y,f as p}from"./chunk-FD6K2YA7.js";import{b}from"./chunk-7YVJFS4A.js";import z from"node:fs/promises";import m from"node:path";import l from"chalk";import h from"chalk";function O(n,i){n&&console.log(h.dim(i))}function v(n,...i){n&&i.forEach(r=>console.log(h.dim(r)))}import{execFileSync as j}from"node:child_process";import P from"node:fs/promises";import{createRequire as k}from"node:module";import c from"node:path";async function d(n,i,r){let t=c.resolve(n),e=M();try{let o=await x(t,i),a=JSON.parse(await P.readFile(o,"utf-8")),s=typeof a.bin=="string"?a.bin:a.bin?.[r];if(!s)throw new Error(`Package does not declare the "${r}" binary.`);return{command:e,argsPrefix:[c.resolve(c.dirname(o),s)]}}catch(o){throw new Error(`Could not resolve the project-local "${r}" binary from project root "${t}". Install the project's declared ${i} dependency and try again. (If the install skipped devDependencies, include them; Yarn Plug'n'Play projects are not supported \u2014 use nodeLinker: node-modules.)`,{cause:o})}}function M(){if(!process.versions.bun)return process.execPath;try{return j("node",["--version"],{stdio:"ignore"}),"node"}catch{throw new Error("Every App CLI must run project binaries under Node.js because Wrangler deploys silently no-op under Bun. Install Node.js and ensure `node` is available on PATH.")}}async function x(n,i){let r=n;for(;;){let e=c.join(r,"node_modules",...i.split("/"),"package.json");try{return await P.realpath(e)}catch{}let o=c.dirname(r);if(o===r)break;r=o}return k(c.join(n,"package.json")).resolve(`${i}/package.json`)}var D=["migrate","--config=drizzle-prod.config.ts"],E="drizzle";function R(n,i){let r=i?.binding??n[0];if(!n.includes(r))throw new Error(`Manifest migrations binding "${r}" is not declared in resources.d1.`);return r}async function Q({cwd:n,workerName:i,d1Bindings:r,d1DatabaseIds:t,migrations:e,verbose:o=!1}){if(r.length===0){o&&console.log(l.dim(`No D1 resources declared; skipping migrations.
|
|
2
2
|
`));return}let a=R(r,e),s=t[a];if(!s)throw new Error(`No provisioned D1 database ID found for binding "${a}".`);if(!e||e.engine==="drizzle"){await L({cwd:n,d1DatabaseId:s,verbose:o});return}if(!e.dir)throw new Error('migrations.dir is required when migrations.engine is "d1-sql".');await A({cwd:n,binding:a,databaseName:C(i,a),databaseId:s,migrationsDir:m.resolve(n,e.dir),verbose:o})}async function L({cwd:n,d1DatabaseId:i,verbose:r=!1}){let{command:t,argsPrefix:e}=await d(n,"drizzle-kit","drizzle-kit");console.log(`
|
|
3
3
|
Running: project-local drizzle-kit ${D.join(" ")}`),console.log(l.dim(" Running database migrations...")),v(r," Running any pending migrations against your remote D1 Database..."),await b(t,[...e,...D],{cwd:n,d1DatabaseId:i,verbose:r}),console.log(l.dim(` Migrations completed.
|
|
4
4
|
`))}async function V({cwd:n,d1Bindings:i,migrations:r,configPath:t,verbose:e=!1}){if(i.length===0)return;let o=R(i,r),a=m.resolve(n,r?.dir??E);if(!await u(a))return;if(console.log(l.dim(" Applying local database migrations...")),r?.engine==="d1-sql"){let{command:g,argsPrefix:f}=await d(n,"wrangler","wrangler");await p(g,[...f,"d1","migrations","apply",o,"--local","--persist-to",m.join(n,".wrangler","state"),"-c",t],{cwd:n,verbose:e,logCommandToConsole:!1}),console.log(l.dim(" Local migrations applied."));return}if(!await I(m.join(n,".wrangler","state","v3","d1"))){let g=await d(n,"wrangler","wrangler");await p(g.command,[...g.argsPrefix,"d1","execute",o,"--local","--persist-to",m.join(n,".wrangler","state"),"-c",t,"--command","SELECT 1;"],{cwd:n,verbose:e,logCommandToConsole:!1})}let s=await d(n,"drizzle-kit","drizzle-kit");await p(s.command,[...s.argsPrefix,"migrate"],{cwd:n,verbose:e,logCommandToConsole:!1}),console.log(l.dim(" Local migrations applied."))}async function A({cwd:n,binding:i,databaseName:r,databaseId:t,migrationsDir:e,verbose:o=!1}){let{command:a,argsPrefix:s}=await d(n,"wrangler","wrangler");console.log(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as x}from"./chunk-
|
|
1
|
+
import{a as x}from"./chunk-GAJEQYJH.js";import{a as C}from"./chunk-VP6SKW44.js";import{a as P}from"./chunk-7BOQJFI5.js";import"./chunk-XTO2VTPY.js";import{e as k}from"./chunk-O2KDOP5R.js";import{a as w,b as h,d as v,e as b,f as c}from"./chunk-FD6K2YA7.js";import"./chunk-BIXKPCDH.js";import"./chunk-VEYSNPDH.js";import"./chunk-7YVJFS4A.js";import{a as u}from"./chunk-DLGPLHBH.js";import{c as l}from"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import"./chunk-WO3NE7ZU.js";import"./chunk-YJ2DKIZS.js";import g from"chalk";async function E({url:e,targetDir:o,verbose:t=!1}){try{await c("git",["clone",e,o],{verbose:t,logCommandToConsole:!1})}catch(r){throw new Error(`Failed to clone repository from ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}async function I({targetDir:e,verbose:o=!1}){try{await c("git",["init"],{verbose:o,logCommandToConsole:!1,cwd:e}),await c("git",["add","."],{verbose:o,logCommandToConsole:!1,cwd:e}),await c("git",["commit","-m","Starter template"],{verbose:o,logCommandToConsole:!1,cwd:e})}catch(t){throw new Error(`Failed to initialize git repository: ${t instanceof Error?t.message:"Unknown error"}`)}}import J from"node:fs/promises";import L from"node:path";import f from"chalk";var _=["everyapp.config.ts"];async function T(){let e=process.cwd();for(let o of _){let t=L.join(e,o);try{await J.access(t),console.log(f.yellow(`
|
|
2
2
|
Already inside an Every App project`)),console.log(f.dim(` Found ${o}
|
|
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(f.dim(` npx everyapp app deploy
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as c}from"./chunk-
|
|
1
|
+
import{a as c}from"./chunk-GAJEQYJH.js";import{a as p}from"./chunk-OI2MBGBG.js";import{a as r}from"./chunk-7BOQJFI5.js";import"./chunk-XTO2VTPY.js";import{e as i}from"./chunk-O2KDOP5R.js";import"./chunk-FD6K2YA7.js";import"./chunk-BIXKPCDH.js";import"./chunk-VEYSNPDH.js";import"./chunk-7YVJFS4A.js";import{a}from"./chunk-DLGPLHBH.js";import"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import{d as s}from"./chunk-WO3NE7ZU.js";import"./chunk-YJ2DKIZS.js";import o from"chalk";async function x(e){if(e.domain!==void 0)throw new Error("apps derive their address from the gateway's domain automatically; configure the domain with `everyapp gateway deploy --domain <apex-domain>`.");await a(),await i();let n=process.cwd(),l=e.verbose||!1,m=e.yes||!1,d=e["skip-dns-check"]||!1;await p();let t=await s(n),y=t.id;if(console.log(o.bold(`
|
|
2
2
|
Project: ${y}
|
|
3
3
|
`)),!await r("this app",m)){console.log(o.red(`
|
|
4
4
|
Deployment cancelled by user
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as J,b as Z,d as h,e as Q}from"./chunk-
|
|
1
|
+
import{a as J,b as Z,d as h,e as Q}from"./chunk-7BOQJFI5.js";import{a as S,b as A,c as z,e as q}from"./chunk-XTO2VTPY.js";import{a as C,b as v,c as T,d as D,f as H}from"./chunk-O2KDOP5R.js";import{d as Y,e as F,f as M}from"./chunk-FD6K2YA7.js";import"./chunk-BIXKPCDH.js";import"./chunk-VEYSNPDH.js";import"./chunk-7YVJFS4A.js";import{a as G,d as L,f as $,h as P,i as N,l as O,p as K,q as j,s as B,t as V}from"./chunk-DLGPLHBH.js";import{c as R}from"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import"./chunk-WO3NE7ZU.js";import"./chunk-YJ2DKIZS.js";import g from"chalk";import Te from"node:path";import _ from"chalk";var de="every-app-gateway",ge={KV:"every-app-gateway",OAUTH_KV:"every-app-gateway-OAUTH_KV"};async function X({verbose:e=!1}={}){console.log(`
|
|
2
2
|
Setting up your Cloudflare D1 Database and KV Store...
|
|
3
3
|
`);let a=await L(),o=await fe(de,a,e),t={};for(let[n,i]of Object.entries(ge))t[n]=await me(i,a,e);return console.log(),{d1DatabaseId:o,kvNamespaceIds:t,accountId:a}}async function fe(e,a,o){o&&console.log(` Checking D1 database: ${e}`);let t=await P(e,a);return o?t.wasCreated?console.log(_.green(` Created D1 database: ${e} (${t.id})
|
|
4
4
|
`)):console.log(_.dim(` Linking to existing D1 database: ${e} (${t.id})
|
|
@@ -39,7 +39,7 @@ SSL certificate is still being provisioned. This can take a few minutes.
|
|
|
39
39
|
Every App Gateway
|
|
40
40
|
`)),!await J("the Gateway",n)){console.log(`
|
|
41
41
|
Deployment cancelled by user
|
|
42
|
-
`);return}
|
|
42
|
+
`);return}await K();let r=await X({verbose:a});if(t){console.log(g.dim(`Verifying Cloudflare zone for ${t}...`));let s=await B({accountId:r.accountId,domain:t}),u=await V({zoneId:s.id,domain:t});u==="unauthorized"?console.log(g.yellow(Q({domain:t,accountId:r.accountId,mode:"gateway-warning"}))):a&&console.log(g.dim(u==="created"?` Created proxied wildcard DNS record for *.${t}`:` Proxied wildcard DNS record already exists for *.${t}`))}else console.log(g.yellow("Warning: app subdomains require a custom domain. Redeploy the gateway with --domain <apex-domain> before deployed apps are routable."));let f=await j(r.accountId);a&&console.log(g.dim(`Reconstructed ${f.length} gateway service binding${f.length===1?"":"s"} from the registry.`));let l=await Y("gateway-deploy-");a&&console.log(g.dim(`Working directory: ${l}
|
|
43
43
|
`));let c=null;try{let s;o?s=await ce(o,l,a):(s=await se(l,a),s??=await ie(l,process.cwd(),a)),await H({cwd:s,verbose:a,description:"Installing gateway dependencies..."});let u=Te.join(s,"wrangler.jsonc"),E=await W(u),U=t?`https://${t}`:await $(E);c=t?`https://${t}`:U,await oe({gatewayPath:s,resources:r,workerUrl:U,domain:t,serviceBindings:f,verbose:a}),await q({cwd:s,d1DatabaseId:r.d1DatabaseId,verbose:a})}catch(s){let u=await O(s);throw u&&(console.log(u.formatted),await R(1)),console.error(`
|
|
44
44
|
Deployment failed:`,s instanceof Error?s.message:s),s}finally{await F({tmpDir:l,verbose:a})}if(!c)throw new Error("Worker URL not set properly during deployment");let p;try{p=await T(c)}catch(s){if(s instanceof C){console.log(g.yellow(`
|
|
45
45
|
Gateway unreachable
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as i,b as t}from"./chunk-
|
|
2
|
+
import{a as i,b as t}from"./chunk-POSDLD3G.js";import{a as r,b as o}from"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import"./chunk-YJ2DKIZS.js";import{run as e}from"@stricli/core";r();await e(t,process.argv.slice(2),i(process));await o();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as l}from"./chunk-BIXKPCDH.js";import{a as r,d as n}from"./chunk-VEYSNPDH.js";import{k as i}from"./chunk-
|
|
1
|
+
import{d as l}from"./chunk-BIXKPCDH.js";import{a as r,d as n}from"./chunk-VEYSNPDH.js";import{k as i}from"./chunk-DLGPLHBH.js";import"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import"./chunk-YJ2DKIZS.js";import g from"chalk";import m from"enquirer";async function c(){try{return await i()}catch{return""}}async function k(){let s=await c(),{gatewayUrl:w}=await m.prompt({type:"input",name:"gatewayUrl",message:"Gateway URL",initial:s,validate:e=>{try{return r(e.trim()),!0}catch{return"Enter a valid gateway URL"}}}),t=r(w.trim()),{token:o}=await m.prompt({type:"password",name:"token",message:"Deploy token",validate:e=>e.trim().startsWith("eak_")?!0:"Deploy tokens start with eak_"}),a=await new l({gatewayUrl:t,getAuthToken:async()=>o.trim()}).whoami();await n({gatewayUrl:t,token:o.trim(),organizationId:a.organizationId}),console.log(g.green(`Logged in to ${t} for ${a.organizationName} (${a.organizationId}).`))}export{k as login};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,e as r}from"./chunk-VEYSNPDH.js";import{k as a}from"./chunk-
|
|
1
|
+
import{a as e,e as r}from"./chunk-VEYSNPDH.js";import{k as a}from"./chunk-DLGPLHBH.js";import"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import"./chunk-YJ2DKIZS.js";import o from"chalk";import m from"enquirer";async function y(){try{return await a()}catch{return""}}async function f(){let i=await y(),{gatewayUrl:n}=await m.prompt({type:"input",name:"gatewayUrl",message:"Gateway URL",initial:i,validate:c=>{try{return e(c.trim()),!0}catch{return"Enter a valid gateway URL"}}}),t=e(n.trim()),l=await r(t);console.log(l?o.green(`Logged out of ${t}.`):o.yellow(`No stored credential found for ${t}.`))}export{f as logout};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-7YVJFS4A.js";import{a as i}from"./chunk-DLGPLHBH.js";import"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import"./chunk-WO3NE7ZU.js";import"./chunk-YJ2DKIZS.js";import r from"chalk";import{execa as l}from"execa";async function g(m,...o){await i();let n=process.cwd();try{if(!o||o.length===0)throw new Error(`No command provided. Usage: npx everyapp app remote-d1-shell -- <command>
|
|
2
2
|
Example: npx everyapp app remote-d1-shell -- npx drizzle-kit migrate`);let[e,...t]=o;if(!e)throw new Error("Invalid command");console.log("Retrieving shell info from Cloudflare...");let c=await a(n);console.log(r.bold(`
|
|
3
3
|
Running: ${r.cyan([e,...t].join(" "))}
|
|
4
4
|
`)),await l(e,t,{cwd:n,stdio:"inherit",env:{...process.env,...c}}),console.log(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as l}from"./chunk-
|
|
1
|
+
import{a as l}from"./chunk-VP6SKW44.js";import{a as c}from"./chunk-OI2MBGBG.js";import{e as r}from"./chunk-O2KDOP5R.js";import"./chunk-FD6K2YA7.js";import"./chunk-BIXKPCDH.js";import"./chunk-VEYSNPDH.js";import{a as n}from"./chunk-DLGPLHBH.js";import"./chunk-U4LIQ5VR.js";import"./chunk-RB5D2R45.js";import{d as i,f as s}from"./chunk-WO3NE7ZU.js";import"./chunk-YJ2DKIZS.js";import o from"chalk";async function L(p){let e=process.cwd(),m=p.verbose||!1;await c(),await n();let u=await r(),t=await i(e),a=t.id;await s(e,{manifest:t}),console.log(o.bold(`
|
|
2
2
|
Setting up local environment for ${a}
|
|
3
3
|
`)),await l({targetDir:e,appId:a,gatewayUrl:u,verbose:m,installDeps:!0,migrations:t.migrations}),console.log(o.green(`Local setup complete!
|
|
4
4
|
`)),console.log(`Run the app locally:
|
|
Binary file
|
package/package.json
CHANGED
package/dist/chunk-SUM3EFB4.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{c as I,d as k,e as F}from"./chunk-FX3COD5Z.js";import{c as L,d as j}from"./chunk-L3RGZX6J.js";import{f as O}from"./chunk-CEOIDQLQ.js";import{f as v}from"./chunk-H4JYEFV2.js";import{a as W,b as B,c as U,d as w}from"./chunk-BIXKPCDH.js";import{d as h,h as S,i as $,j as _,k as x,l as A,r as V,u as T}from"./chunk-RUQ6WEWY.js";import{c as d}from"./chunk-7EBQPYFG.js";import{c as Y,d as K,e as E,f as z}from"./chunk-WO3NE7ZU.js";import u from"chalk";import p from"chalk";async function M({appId:e,d1Bindings:o=["DB"],kvBindings:t=["KV"],needsR2Bucket:n=!1,verbose:i=!1}){let a=[o.length>0?"D1 Database":null,t.length>0?"KV Store":null,n?"R2 Bucket":null].filter(Boolean);a.length>0&&console.log(`
|
|
2
|
-
Setting up your Cloudflare ${a.join(", ")}...
|
|
3
|
-
`);let s=await h(),l=E(e),r;n&&(r=await ce(l,s,i));let g={};for(let c of o){let y=E(e,c);g[c]=await se(y,s,i)}let m={};for(let c of t){let y=E(e,c);m[c]=await le(y,s,i)}return{d1DatabaseId:g.DB,kvNamespaceId:m.KV,d1DatabaseIds:g,kvNamespaceIds:m,r2BucketName:r,resourceName:l}}async function se(e,o,t){t&&(console.log(p.bold(`Processing D1 database...
|
|
4
|
-
`)),console.log(` Checking D1 database: ${e}`));let n=await S(e,o);return t?n.wasCreated?console.log(p.green(` Created D1 database: ${e} (${n.id})
|
|
5
|
-
`)):console.log(p.dim(` Linking to existing D1 database: ${e} (${n.id})
|
|
6
|
-
`)):n.wasCreated?console.log(p.green(" D1 successfully created.")):console.log(" D1 already set up."),n.id}async function le(e,o,t){t&&(console.log(p.bold(`Processing KV namespace...
|
|
7
|
-
`)),console.log(` Checking KV namespace: ${e}`));let n=await $(e,o);return t?n.wasCreated?console.log(p.green(` Created KV namespace: ${e} (${n.id})
|
|
8
|
-
`)):console.log(p.dim(` Linking to existing KV namespace: ${e} (${n.id})
|
|
9
|
-
`)):n.wasCreated?console.log(p.green(" KV successfully created.")):console.log(" KV already set up."),n.id}async function ce(e,o,t){t&&(console.log(p.bold(`Processing R2 bucket...
|
|
10
|
-
`)),console.log(` Checking R2 bucket: ${e}`));let n;try{n=await _(e,o)}catch(i){let a=await A(i,{accountId:o});throw a&&(console.log(a.formatted),await d(1)),i}return t?n.wasCreated?console.log(p.green(` Created R2 bucket: ${e}
|
|
11
|
-
`)):console.log(p.dim(` Linking to existing R2 bucket: ${e}
|
|
12
|
-
`)):n.wasCreated?console.log(p.green(" R2 successfully created.")):console.log(" R2 already set up."),n.name}import D from"chalk";import R from"node:fs/promises";import b from"node:path";import{parse as ge}from"jsonc-parser";async function J({cwd:e,buildCommand:o,gatewayUrl:t,appId:n,generatedWranglerConfigPath:i,verbose:a}){let s={...process.env,VITE_GATEWAY_URL:t,VITE_APP_ID:n,EVERYAPP_GATEWAY_URL:t,EVERYAPP_APP_ID:n};try{await fe(e),o?await v(o,[],{cwd:e,description:`Building your application...
|
|
13
|
-
`,env:s,shell:!0,verbose:a}):await ue(e)?await v("npx",["vite","build"],{cwd:e,description:`Building your application...
|
|
14
|
-
`,env:s,verbose:a}):a&&console.log(D.dim("No Vite config found; deploying generated worker config."));let l=await pe({cwd:e,generatedWranglerConfigPath:i,verbose:a}),{command:r,argsPrefix:g}=await L(e,"wrangler","wrangler");await v(r,[...g,"deploy","-c",l],{cwd:e,description:`Deploying your private application worker to Cloudflare...
|
|
15
|
-
|
|
16
|
-
This could take up to a minute.`,env:s,verbose:a})}catch(l){let r=await A(l);throw r&&(console.log(r.formatted),await d(1)),console.error(D.red(`
|
|
17
|
-
Failed to build or deploy`)),l}}async function pe({cwd:e,generatedWranglerConfigPath:o,verbose:t}){let n=b.join(e,"dist","server","wrangler.json");return await q(n)?(await de(n,o),t&&console.log(D.dim(`Using Vite-built deploy config: ${b.relative(e,n)}`)),n):(t&&console.log(D.dim("No Vite-built wrangler config found; using generated wrangler config.")),o)}async function de(e,o){let t=await H(e),n=await H(o);delete t.configPath,delete t.userConfigPath,delete t.routes,delete t.route;let i=n.name;if(typeof i!="string"||i.length===0)throw new Error(`Generated config ${o} has no worker name; aborting deploy.`);let a=n.vars;for(let l of["EVERYAPP_IDENTITY_PUBLIC_KEYS","EVERYAPP_IDENTITY_ISSUER"]){let r=a?.[l];if(typeof r!="string"||r.length===0)throw new Error(`Generated config ${o} is missing ${l}; aborting deploy.`)}t.name=i,"topLevelName"in t&&(t.topLevelName=i),t.workers_dev=!1,t.preview_urls=!1,t.vars={...t.vars,...a};let s=n.services;if(Array.isArray(s)&&s.length>0){let l=new Set(s.map(g=>g.binding)),r=Array.isArray(t.services)?t.services:[];t.services=[...r.filter(g=>!l.has(g.binding)),...s]}await R.writeFile(e,JSON.stringify(t,null,2)+`
|
|
18
|
-
`,"utf-8")}async function H(e){let o=await R.readFile(e,"utf-8"),t=[],n=ge(o,t,{allowTrailingComma:!0});if(t.length>0||n===void 0)throw new Error(`Failed to parse ${e} as JSONC.`);return n}async function fe(e){await R.rm(b.join(e,"dist","server","wrangler.json"),{force:!0})}async function q(e){try{return await R.access(e),!0}catch(o){if(o instanceof Error&&"code"in o&&o.code==="ENOENT")return!1;throw o}}async function ue(e){let o=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs","vite.config.cjs","vite.config.cts"];return(await Promise.all(o.map(n=>q(b.join(e,n))))).some(Boolean)}import f from"chalk";async function Q(e){return new w({gatewayUrl:e}).getIdentityKeys()}async function X(e){try{let t=await new w({gatewayUrl:e}).whoami();return t.capabilities?.appGateway===!0?{organizationId:t.organizationId,gatewayBinding:{organizationId:t.organizationId}}:(console.log(f.yellow("Upgrade your gateway to enable the AI proxy binding: npx everyapp gateway deploy")),{organizationId:t.organizationId})}catch(o){throw await ee(o),o}}async function Z(e){let{appId:o,workerName:t,manifest:n,gatewayUrl:i,verbose:a=!1,appName:s,appDescription:l}=e;try{console.log(""),a&&console.log("Registering app with gateway control plane...");let r=new w({gatewayUrl:i}),g=s||o,m=l||o,c=await r.registerApp({appId:o,name:g,description:m,workerName:t,manifest:n});return a&&(console.log(f.dim(` Gateway app: ${c.appSlug} (${c.existingApp?"updated":"created"})`)),console.log(f.dim(` Default access: ${c.defaultAccess?"enabled":"disabled"}`)),console.log(f.dim(` Access granted to ${c.grantedUserCount} users
|
|
19
|
-
`))),{hostname:c.hostname}}catch(r){throw await ee(r),r}}async function ee(e){W(e)&&(console.log(f.yellow(`
|
|
20
|
-
Gateway out of date
|
|
21
|
-
`)),console.log(f.dim(" Run: `npx everyapp gateway deploy` to update.\n")),await d(1)),U(e)&&(console.log(f.yellow(`
|
|
22
|
-
Gateway authorization failed
|
|
23
|
-
`)),console.log(f.dim(`${e.message}
|
|
24
|
-
`)),await d(1)),B(e)&&(console.log(f.yellow(`
|
|
25
|
-
Gateway internal APIs are disabled
|
|
26
|
-
`)),console.log(f.dim(` This gateway is running in hosted mode (or has invalid deployment mode config), so /api/deploy/* is intentionally unavailable.
|
|
27
|
-
`)),await d(1)),console.error(f.red(`
|
|
28
|
-
Failed to register app with gateway`),e instanceof Error?`
|
|
29
|
-
${e.message}
|
|
30
|
-
`:"")}var te="GATEWAY_URL",ne="EVERY_APP_ORG_ID";async function oe({gatewayUrl:e,appPath:o,workerName:t,verbose:n=!1}){n&&console.log("Configuring Secrets...");try{if(await I({secretName:te,cwd:o,workerName:t,verbose:n})||await k({secretName:te,secretValue:e,cwd:o,workerName:t,verbose:n,description:`Setting GATEWAY_URL to: ${e}`}),!await I({secretName:ne,cwd:o,workerName:t,verbose:n})){let l=await new w({gatewayUrl:e}).whoami();await k({secretName:ne,secretValue:l.organizationId,cwd:o,workerName:t,verbose:n,description:`Setting EVERY_APP_ORG_ID to: ${l.organizationId}`})}n&&console.log(`Secret setup complete!
|
|
31
|
-
`)}catch(i){throw console.error(`
|
|
32
|
-
Failed to setup secrets`,i instanceof Error?`
|
|
33
|
-
${i.message}`:""),i}}async function qe(e){let{cwd:o,verbose:t}=e,n=e.manifest??await K(o),i=n.id,a=Y(i),s=n.resources?.d1??[],l=n.resources?.kv??[],r=await x(),g=await X(r),{organizationId:m}=g,c=await Q(r),y=c.issuer??"",C=me(i,c.issuer);C&&await we({...C,skipDnsCheck:e.skipDnsCheck??!1});let{d1DatabaseIds:P,kvNamespaceIds:ie}=await M({appId:i,d1Bindings:s,kvBindings:l,verbose:t});console.log(),await O({cwd:o,description:"Installing dependencies for Cloudflare deployment...",install:n.install,verbose:t}),s.length>0?await j({cwd:o,workerName:a,d1Bindings:s,d1DatabaseIds:P,migrations:n.migrations,verbose:t}):t&&console.log(u.dim(`No D1 resources declared; skipping migrations.
|
|
34
|
-
`));let{configPath:ae}=await z(o,{manifest:n,d1DatabaseIds:P,kvNamespaceIds:ie,identityPublicKeys:c.keys,vars:{EVERYAPP_IDENTITY_ISSUER:y},gatewayBinding:g.gatewayBinding});await J({cwd:o,buildCommand:n.build,gatewayUrl:r,appId:i,generatedWranglerConfigPath:ae,verbose:t});let{hostname:G}=await Z({appId:i,workerName:a,manifest:n,gatewayUrl:r,verbose:t,appName:n.name,appDescription:n.description});await oe({gatewayUrl:r,appPath:o,workerName:a,verbose:t});let re=await h(),N=await V(re);return t&&console.log(u.dim(` Reconciled ${N.length} gateway app service binding${N.length===1?"":"s"}`)),{liveUrl:`https://${G}`,gatewayUrl:r,organizationId:m,hostname:G}}function me(e,o){if(!o)return null;let t=new URL(o).hostname;return{hostname:`${e}.${t}`,apex:t,issuerHost:t,isWorkersDev:t.endsWith(".workers.dev")}}async function we({hostname:e,apex:o,issuerHost:t,isWorkersDev:n,skipDnsCheck:i}){if(n&&(console.log(u.red(`
|
|
35
|
-
Gateway custom domain required
|
|
36
|
-
`)),console.log([` The gateway is currently configured at ${u.cyan(t)}.`," App subdomains cannot work on workers.dev domains.","",` Run ${u.cyan("everyapp gateway deploy --domain <apex-domain>")} first, then deploy the app again.`,""].join(`
|
|
37
|
-
`)),await d(1)),i||await T(e))return;console.log(u.red(`
|
|
38
|
-
App subdomain DNS is not ready
|
|
39
|
-
`));let a=await h().catch(()=>null);console.log(u.yellow(F({domain:o,accountId:a,mode:"app-blocking",hostname:u.cyan(e)}))),await d(1)}export{qe as a};
|