@every-app/cli 0.0.19 → 0.0.21
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/dist/bash-complete.js +1 -1
- package/dist/{chunk-WCJ27GJM.js → chunk-O6WLFR4A.js} +5 -5
- package/dist/create-MHGKMSQN.js +26 -0
- package/dist/{deploy-OI3QF3EI.js → deploy-HXEM2VYK.js} +2 -1
- package/dist/deploy-XX6TZD4F.js +22 -0
- package/dist/index.js +1 -1
- package/dist/{remoteD1Shell-D34XAC3H.js → remoteD1Shell-OYYBCUFH.js} +2 -2
- package/package.json +1 -2
- package/dist/create-H2GLJX47.js +0 -27
- package/dist/deploy-QUYMMJE2.js +0 -23
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-O6WLFR4A.js";import{proposeCompletions as r}from"@stricli/core";var t=process.argv.slice(3);process.env.COMP_LINE?.endsWith(" ")&&t.push("");await r(s,t,o(process));try{for(let{completion:p}of await r(s,t,o(process)))process.stdout.write(`${p}
|
|
3
3
|
`)}catch{}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import p from"node:fs";import l from"node:os";import d from"node:path";function A(e){return{process:e,os:l,fs:p,path:d}}import{buildApplication as g,buildRouteMap as C}from"@stricli/core";import{buildInstallCommand as 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.
|
|
2
|
-
`)}}),u=o({loader:async()=>{let{deploy:e}=await import("./deploy-
|
|
3
|
-
`)}}),y=o({loader:async()=>{let{remoteD1Shell:e}=await import("./remoteD1Shell-
|
|
4
|
-
`)}}),
|
|
5
|
-
`)}}),
|
|
1
|
+
import p from"node:fs";import l from"node:os";import d from"node:path";function A(e){return{process:e,os:l,fs:p,path:d}}import{buildApplication as g,buildRouteMap as C}from"@stricli/core";import{buildInstallCommand as 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.21";import{buildCommand as o,buildRouteMap as m}from"@stricli/core";var c=o({loader:async()=>import("./create-MHGKMSQN.js"),parameters:{positional:{kind:"tuple",parameters:[]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during creation",optional:!0}}},docs:{brief:"Create a new app from the starter template",fullDescription:["Copies the simple-todo starter template 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-HXEM2VYK.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-OYYBCUFH.js");return e},parameters:{flags:{},positional:{kind:"array",parameter:{brief:"Command and arguments to run with environment variables",parse:String}}},docs:{brief:"Run a command with Cloudflare D1 connection environment variables",fullDescription:["Sets environment variables needed to connect to remote Cloudflare D1 and runs any command that requires D1 access.","","The command will:"," 1. Get the Cloudflare account ID"," 2. Look up the database ID from the database name in wrangler.jsonc"," 3. Get a valid OAuth token"," 4. Run the provided command with CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_DATABASE_ID, CLOUDFLARE_API_TOKEN, and MIGRATE_REMOTE set","","Common use cases:"," - Running Drizzle migrations: npx @every-app/cli app remote-d1-shell -- npx drizzle-kit migrate"," - Opening Drizzle Studio: npx @every-app/cli app remote-d1-shell -- npx drizzle-kit studio"," - Pushing schema changes: npx @every-app/cli app remote-d1-shell -- npx drizzle-kit push","","This command is useful for any operation that needs direct access to your production D1 database."].join(`
|
|
4
|
+
`)}}),i=m({routes:{create:c,deploy:u,"remote-d1-shell":y},docs:{brief:"App management commands"}});import{buildCommand as f,buildRouteMap as b}from"@stricli/core";var h=f({loader:async()=>{let{deploy:e}=await import("./deploy-XX6TZD4F.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
|
+
`)}}),s=b({routes:{deploy:h},docs:{brief:"Gateway management commands"}});var w=C({routes:{app:i,gateway:s,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};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{a as c}from"./chunk-E3UJA43H.js";import{a as m,b as g,c as d,d as f,e as u}from"./chunk-GIXANRUK.js";import{a as l,b as w}from"./chunk-EUEWNXPI.js";import{e as p,g as y,h}from"./chunk-SWRTSPS4.js";import M from"chalk";import C from"chalk";import{execa as L}from"execa";async function b(){try{await L("pnpm",["--version"],{stdio:"pipe"})}catch{console.error(C.red(`
|
|
2
|
+
Error: pnpm is required but not installed. Please install it first:`)),console.error(C.cyan(` npm i -g pnpm
|
|
3
|
+
`)),process.exit(1)}}import U from"enquirer";function J(e){return!e||e.trim().length===0?"App ID cannot be empty":e.length>64?"App ID must be 64 characters or less":/^[a-z][a-z0-9-]*$/.test(e)?!0:"App ID must be in kebab-case format (lowercase letters, numbers, and hyphens only, starting with a letter)"}async function k(){return console.log(`Project Configuration
|
|
4
|
+
`),{appId:(await U.prompt({type:"input",name:"appId",message:"Enter your app ID (kebab-case format)",validate:J})).appId}}import P from"node:path";import O from"chalk";async function x(e,o,n=!1){try{await l("git",["clone",e,o],{verbose:n,logCommandToConsole:!1})}catch(r){throw new Error(`Failed to clone repository from ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}var S="https://github.com/every-app/every-app.git",_="templates/simple-todo";async function D(e,o){o&&console.log(`Cloning template repository...
|
|
5
|
+
`);let n=await f("every-app-create-");await x(S,n,o),o&&console.log(`Extracting template...
|
|
6
|
+
`);let r=P.join(n,_),a=P.join(process.cwd(),e);if(await g(a))throw new Error(`Directory "${e}" already exists in the current location`);return await m(r,a,{exclude:["node_modules",".git","pnpm-lock.yaml","package-lock.json",".env.local",".env.production",".dev.vars","manual-steps.md"]}),o&&console.log(O.dim(` Template copied to ${a}
|
|
7
|
+
`)),{tempDir:n,targetDir:a}}import v from"chalk";async function E(e,o){console.log(`Creating Cloudflare resources...
|
|
8
|
+
`);let n=await y(e,o),r=await w(e,o);return o&&(console.log(`Cloudflare resources ready:
|
|
9
|
+
`),console.log(v.dim(` D1 Database: ${e} (${n})`)),console.log(v.dim(` KV Namespace: ${e} (${r})
|
|
10
|
+
`))),{d1DatabaseId:n,kvNamespaceId:r}}import $ from"node:fs/promises";import I from"node:path";import V from"chalk";async function W(e,o){let n=I.join(e,"package.json"),r=JSON.parse(await $.readFile(n,"utf-8"));r.name=o,await $.writeFile(n,JSON.stringify(r,null,2)+`
|
|
11
|
+
`,"utf-8")}async function A(e,o,n,r,a){a&&console.log(`Updating configuration files...
|
|
12
|
+
`);let i=I.join(e,"wrangler.jsonc");await h({configPath:i,name:o,d1DatabaseId:n,d1DatabaseName:o,kvNamespaceId:r,verbose:a}),await W(e,o),await d(e,o),a&&console.log(V.dim(" Configuration updated"))}import s from"chalk";async function T(e,o){try{o||console.log(`
|
|
13
|
+
Setting up Cloudflare for local dev...`),await l("pnpm",["run","cf-typegen"],{cwd:e,verbose:o,logCommandToConsole:!1}),await l("pnpm",["run","build"],{cwd:e,verbose:o,logCommandToConsole:!1}),o||console.log(s.dim(` Finished.
|
|
14
|
+
`)),await l("pnpm",["run","db:migrate:local"],{cwd:e,verbose:o}),console.log(`
|
|
15
|
+
Local database migrations complete.
|
|
16
|
+
`)}catch{console.warn(s.yellow(`
|
|
17
|
+
Failed to run local migrations. You can run them manually with:`)),console.warn(s.dim(` pnpm run db:migrate:local
|
|
18
|
+
`))}}import t from"chalk";function N(e,o,n){console.log(t.green(`\u{1F389} Project created successfully!
|
|
19
|
+
`)),console.log(t.dim(`Location: ${o}
|
|
20
|
+
`)),console.log(`Next steps:
|
|
21
|
+
`),console.log(t.dim(` 1. ${t.bold(t.italic(`cd ${e}`))}`)),console.log(t.dim(` 2. ${t.bold(t.italic("pnpm run dev"))}`)),console.log(t.dim(` 3. Click "Add App" in your gateway: ${t.reset(t.cyan(n))}`)),console.log(t.dim(" 4. Configure App")),console.log(t.dim(` - App ID: ${t.bold(t.italic(`${e}`))}`)),console.log(t.dim(` - App URL: ${t.bold(t.italic("http://localhost:3001"))} (or whatever your dev url is)`)),console.log(t.dim(` 5. Click the app in the gateway and start building
|
|
22
|
+
`)),console.log(`Deploy to production:
|
|
23
|
+
`),console.log(t.dim(t.bold(t.italic(" npx @every-app/cli app deploy"))))}async function Ao(e){let o=e.verbose||!1;await b(),console.log(`
|
|
24
|
+
Create a new Every App project
|
|
25
|
+
`);let n=null;try{let{appId:r}=await k(),{tempDir:a,targetDir:i}=await D(r,o);n=a;let{d1DatabaseId:j,kvNamespaceId:F}=await E(r,o);await A(i,r,j,F,o),console.log(),await c(i,"Installing dependencies for local dev...",o);let[,R]=await Promise.all([T(i,o),p("every-app-gateway")]);N(r,i,R)}catch(r){throw console.error(M.red(`
|
|
26
|
+
Failed to create project:`),r instanceof Error?r.message:"Unknown error"),r}finally{n&&await u(n)}}export{Ao as default};
|
|
@@ -7,7 +7,8 @@ Setting up Cloudflare your D1 Database and KV Store...
|
|
|
7
7
|
Migrations completed!
|
|
8
8
|
`))}catch{console.warn(y.yellow(`Failed to run migrations. You may need to run them manually:
|
|
9
9
|
npx drizzle-kit migrate --config=drizzle-prod.config.ts
|
|
10
|
-
`))}}import V from"chalk";async function W(r,a,e,o){let t={...process.env,VITE_GATEWAY_URL:a,VITE_APP_ID:e};try{await D("npx",["vite","build"],{cwd:r,description
|
|
10
|
+
`))}}import V from"chalk";async function W(r,a,e,o){let t={...process.env,VITE_GATEWAY_URL:a,VITE_APP_ID:e};try{await D("npx",["vite","build"],{cwd:r,description:`Building your application...
|
|
11
|
+
`,env:t,verbose:o}),await D("npx",["wrangler","deploy"],{cwd:r,description:`Deploying your application to Cloudflare workers...
|
|
11
12
|
|
|
12
13
|
This could take up to a minute.`,env:t,verbose:o})}catch(n){throw console.error(V.red(`
|
|
13
14
|
Failed to build or deploy`)),n}}import h from"chalk";import{randomUUID as j}from"node:crypto";import u from"chalk";async function w(r,a,e){try{let o=await E(),t=await fetch(`https://api.cloudflare.com/client/v4/accounts/${r}/d1/database/${a}/query`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({sql:e})}),n=await t.json();if(!t.ok||!n.success){let i=n.errors?n.errors.map(s=>`[${s.code}] ${s.message}`).join(", "):t.statusText;throw console.error(u.red(`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{d as w,e as E}from"./chunk-GIXANRUK.js";import{a as _,b as R,c as l,d as c}from"./chunk-UDDM3R6C.js";import{a as g,b as A}from"./chunk-EUEWNXPI.js";import{b as x}from"./chunk-QCM42KG3.js";import{c as y,e as u,g as T,h as C,i as h,j as k}from"./chunk-SWRTSPS4.js";import f from"chalk";import Z from"node:path";var J="every-app-gateway",N="every-app-gateway";async function S(t=!1){console.log(`
|
|
2
|
+
Setting up Cloudflare your D1 Database and KV Store...
|
|
3
|
+
`);let e=await y(),o=await T(J,t),r=await A(N,t);return{d1DatabaseId:o,kvNamespaceId:r,accountId:e}}import $ from"node:crypto";import B from"node:path";import W from"node:crypto";import m from"chalk";function b(){return W.randomBytes(32).toString("base64")}function v(){let{privateKey:t,publicKey:e}=W.generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:t,publicKey:e}}async function D(t,e,o=!1){console.log("Configuring Secrets...");try{if(await l("GATEWAY_URL",e,o)||await c("GATEWAY_URL",t,e,o,`Setting GATEWAY_URL to: ${t}`),!await l("BETTER_AUTH_SECRET",e,o)){let s=b();await c("BETTER_AUTH_SECRET",s,e,o,"Generating new Better Auth secret...")}let n=await l("JWT_PRIVATE_KEY",e,o),i=await l("JWT_PUBLIC_KEY",e,o);if(n&&i)o&&console.log(m.dim(` JWT key pair already exists
|
|
4
|
+
`));else if(!n&&!i){o&&console.log(m.dim(` Generating new JWT key pair...
|
|
5
|
+
`));let s=v();await c("JWT_PRIVATE_KEY",s.privateKey,e,o),await c("JWT_PUBLIC_KEY",s.publicKey,e,o),o&&console.log(m.green(`Created JWT key pair secrets
|
|
6
|
+
`))}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(o?`Secret setup complete!
|
|
7
|
+
`:` Finished.
|
|
8
|
+
`)}catch(r){throw console.error(`
|
|
9
|
+
Failed to setup secrets`,r instanceof Error?`
|
|
10
|
+
${r.message}`:""),r}}async function K(t,e,o,r=!1){let a=B.join(t,"dist","server","wrangler.json");await C({configPath:a,d1DatabaseId:e.d1DatabaseId,kvNamespaceId:e.kvNamespaceId,verbose:r});let n=$.randomUUID();console.log(),await g("npx",["wrangler","deploy"],{cwd:t,description:`Deploying your Gateway to Cloudflare workers...
|
|
11
|
+
|
|
12
|
+
This could take up to a minute.`,env:{...process.env,BETTER_AUTH_SECRET:n},verbose:r}),console.log(),await D(o,t,r)}import d from"chalk";import{execa as Y}from"execa";async function P(t,e=!1){let o=await k(t);if(!o.d1_databases||o.d1_databases.length===0){e&&console.log(d.dim(`No D1 databases configured, skipping migrations
|
|
13
|
+
`));return}console.log(d.dim("Running database migrations..."));try{await Y("npm",["install","--no-save","--legacy-peer-deps","drizzle-kit"],{cwd:t,stdio:e?"inherit":"pipe"}),await x("npx",["drizzle-kit","migrate","--config=drizzle-prod.config.ts"],{cwd:t,verbose:e}),console.log(d.green(`Migrations completed!
|
|
14
|
+
`))}catch(r){console.error(r)}}import U from"node:fs";import z from"node:path";import{Readable as M}from"node:stream";import{pipeline as F}from"node:stream/promises";import{createWriteStream as V}from"node:fs";import{spawn as O}from"node:child_process";import p from"chalk";var j="every-app",H="every-app",G="every-app-gateway-build.tar.gz";function q(){return`https://github.com/${j}/${H}/releases/download/gateway-latest/${G}`}async function Q(t,e){let o=await fetch(t,{redirect:"follow"});if(!o.ok)throw new Error(`Failed to download file: ${o.status} ${o.statusText}`);if(!o.body)throw new Error("Response body is null");let r=V(e),a=M.fromWeb(o.body);await F(a,r)}async function X(t,e){return new Promise((o,r)=>{let a=O("tar",["-xzf",t,"-C",e]);a.on("error",r),a.on("close",n=>{n===0?o():r(new Error(`tar extraction failed with code ${n}`))})})}async function I(t,e=!1){let o=q();console.log(`
|
|
15
|
+
Getting latest gateway release...`),e&&console.log(p.dim(`URL: ${o}`)),U.mkdirSync(t,{recursive:!0});let r=z.join(t,G);try{await Q(o,r)}catch(a){throw a instanceof Error&&a.message.includes("404")?new Error("Gateway release not found. Make sure a release has been published."):a}return e&&(console.log(p.dim(`Downloaded to: ${r}`)),console.log(p.dim("Extracting archive..."))),await X(r,t),U.unlinkSync(r),e&&console.log(p.dim("Extraction complete")),t}async function Ne(t){let e=t.verbose||!1;if(!await _("Do you want to deploy EveryApp Gateway into this Cloudflare account?")){console.log(`
|
|
16
|
+
Deployment cancelled by user
|
|
17
|
+
`);return}await R();let r=await S(e),a=await w("gateway-deploy-");e&&console.log(f.dim(`Working directory: ${a}
|
|
18
|
+
`));let n=null;try{let i=await I(a,e),s=Z.join(i,"wrangler.jsonc"),L=await h(s);n=await u(L),await K(i,r,n,e),await P(i,e)}catch(i){throw console.error(`
|
|
19
|
+
Deployment failed:`,i instanceof Error?i.message:i),i}finally{await E(a,e)}if(!n)throw new Error("Worker URL not set properly during deployment");console.log(f.green(`
|
|
20
|
+
Gateway deployment successful!
|
|
21
|
+
`)),console.log(`Your Gateway is now live at: ${f.cyan(n)}
|
|
22
|
+
`)}export{Ne as deploy};
|
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-
|
|
2
|
+
import{a as r,b as o}from"./chunk-O6WLFR4A.js";import{run as i}from"@stricli/core";await i(o,process.argv.slice(2),r(process));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as c}from"./chunk-QCM42KG3.js";import"./chunk-SWRTSPS4.js";import r from"chalk";import{execa as l}from"execa";async function p(
|
|
2
|
-
Example: every 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 i=await c(n);console.log(r.bold(`
|
|
1
|
+
import{a as c}from"./chunk-QCM42KG3.js";import"./chunk-SWRTSPS4.js";import r from"chalk";import{execa as l}from"execa";async function p(a,...o){let n=process.cwd();try{if(!o||o.length===0)throw new Error(`No command provided. Usage: npx @every-app/cli app remote-d1-shell -- <command>
|
|
2
|
+
Example: npx @every-app/cli 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 i=await c(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,...i}}),console.log(`
|
|
5
5
|
Command executed!`)}catch(e){throw console.error(r.red(`
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Every App CLI - Deploy and manage apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.21",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
@@ -22,7 +22,6 @@
|
|
|
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",
|
|
26
25
|
"knip": "knip"
|
|
27
26
|
},
|
|
28
27
|
"tsup": {
|
package/dist/create-H2GLJX47.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import{a as c}from"./chunk-E3UJA43H.js";import{a as m,b as g,c as d,d as f,e as u}from"./chunk-GIXANRUK.js";import{a as l,b as w}from"./chunk-EUEWNXPI.js";import{e as p,g as y,h}from"./chunk-SWRTSPS4.js";import Y from"chalk";import k from"chalk";import{execa as U}from"execa";async function C(){try{await U("pnpm",["--version"],{stdio:"pipe"})}catch{console.error(k.red(`
|
|
2
|
-
Error: pnpm is required but not installed. Please install it first:`)),console.error(k.cyan(` npm i -g pnpm
|
|
3
|
-
`)),process.exit(1)}}import b from"enquirer";function O(e){return!e||e.trim().length===0?"App ID cannot be empty":e.length>64?"App ID must be 64 characters or less":/^[a-z][a-z0-9-]*$/.test(e)?!0:"App ID must be in kebab-case format (lowercase letters, numbers, and hyphens only, starting with a letter)"}async function J(){let e=!1,o=null;for(;!e;)o=await b.prompt({type:"confirm",name:"acknowledged",message:o?`You must acknowledge this to proceed. Press y to continue.
|
|
4
|
-
`:"pnpm has been chosen as the package manager for Every App projects. Other package managers will not work with `every app deploy` currently.\n\n Press y to acknowledge this.",initial:!1}),o.acknowledged?e=!0:console.log()}async function P(){console.log(`Project Configuration
|
|
5
|
-
`);let e=await b.prompt({type:"input",name:"appId",message:"Enter your app ID (kebab-case format)",validate:O});return console.log(),await J(),{appId:e.appId}}import x from"node:path";import S from"chalk";async function v(e,o,r=!1){try{await l("git",["clone",e,o],{verbose:r,logCommandToConsole:!1})}catch(n){throw new Error(`Failed to clone repository from ${e}: ${n instanceof Error?n.message:"Unknown error"}`)}}var _="https://github.com/every-app/every-app.git",V="templates/simple-todo";async function D(e,o){o&&console.log(`Cloning template repository...
|
|
6
|
-
`);let r=await f("every-app-create-");await v(_,r,o),o&&console.log(`Extracting template...
|
|
7
|
-
`);let n=x.join(r,V),a=x.join(process.cwd(),e);if(await g(a))throw new Error(`Directory "${e}" already exists in the current location`);return await m(n,a,{exclude:["node_modules",".git","pnpm-lock.yaml","package-lock.json",".env.local",".env.production",".dev.vars","manual-steps.md"]}),o&&console.log(S.dim(` Template copied to ${a}
|
|
8
|
-
`)),{tempDir:r,targetDir:a}}import E from"chalk";async function A(e,o){console.log(`Creating Cloudflare resources...
|
|
9
|
-
`);let r=await y(e,o),n=await w(e,o);return o&&(console.log(`Cloudflare resources ready:
|
|
10
|
-
`),console.log(E.dim(` D1 Database: ${e} (${r})`)),console.log(E.dim(` KV Namespace: ${e} (${n})
|
|
11
|
-
`))),{d1DatabaseId:r,kvNamespaceId:n}}import I from"node:fs/promises";import $ from"node:path";import W from"chalk";async function M(e,o){let r=$.join(e,"package.json"),n=JSON.parse(await I.readFile(r,"utf-8"));n.name=o,await I.writeFile(r,JSON.stringify(n,null,2)+`
|
|
12
|
-
`,"utf-8")}async function T(e,o,r,n,a){a&&console.log(`Updating configuration files...
|
|
13
|
-
`);let i=$.join(e,"wrangler.jsonc");await h({configPath:i,name:o,d1DatabaseId:r,d1DatabaseName:o,kvNamespaceId:n,verbose:a}),await M(e,o),await d(e,o),a&&console.log(W.dim(" Configuration updated"))}import s from"chalk";async function j(e,o){try{o||console.log(`
|
|
14
|
-
Setting up Cloudflare for local dev...`),await l("pnpm",["run","cf-typegen"],{cwd:e,verbose:o,logCommandToConsole:!1}),await l("pnpm",["run","build"],{cwd:e,verbose:o,logCommandToConsole:!1}),o||console.log(s.dim(` Finished.
|
|
15
|
-
`)),await l("pnpm",["run","db:migrate:local"],{cwd:e,verbose:o}),console.log(`
|
|
16
|
-
Local database migrations complete.
|
|
17
|
-
`)}catch{console.warn(s.yellow(`
|
|
18
|
-
Failed to run local migrations. You can run them manually with:`)),console.warn(s.dim(` pnpm run db:migrate:local
|
|
19
|
-
`))}}import t from"chalk";function N(e,o,r){console.log(t.green(`\u{1F389} Project created successfully!
|
|
20
|
-
`)),console.log(t.dim(`Location: ${o}
|
|
21
|
-
`)),console.log(`Next steps:
|
|
22
|
-
`),console.log(t.dim(` 1. ${t.bold(t.italic(`cd ${e}`))}`)),console.log(t.dim(` 2. ${t.bold(t.italic("pnpm run dev"))}`)),console.log(t.dim(` 3. Click "Add App" in your gateway: ${t.reset(t.cyan(r))}`)),console.log(t.dim(" 4. Configure App")),console.log(t.dim(` - App ID: ${t.bold(t.italic(`${e}`))}`)),console.log(t.dim(` - App URL: ${t.bold(t.italic("http://localhost:3001"))} (or whatever your dev url is)`)),console.log(t.dim(` 5. Click the app in the gateway and start building
|
|
23
|
-
`)),console.log(`Deploy to production:
|
|
24
|
-
`),console.log(t.dim(t.bold(t.italic(" every app deploy # Deploys made easy using the Every App CLI"))))}async function To(e){let o=e.verbose||!1;await C(),console.log(`
|
|
25
|
-
Create a new Every App project
|
|
26
|
-
`);let r=null;try{let{appId:n}=await P(),{tempDir:a,targetDir:i}=await D(n,o);r=a;let{d1DatabaseId:F,kvNamespaceId:L}=await A(n,o);await T(i,n,F,L,o),console.log(),await c(i,"Installing dependencies for local dev...",o);let[,R]=await Promise.all([j(i,o),p("every-app-gateway")]);N(n,i,R)}catch(n){throw console.error(Y.red(`
|
|
27
|
-
Failed to create project:`),n instanceof Error?n.message:"Unknown error"),n}finally{r&&await u(r)}}export{To as default};
|
package/dist/deploy-QUYMMJE2.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import{d as w,e as E}from"./chunk-GIXANRUK.js";import{a as R,b as h,c as l,d as c}from"./chunk-UDDM3R6C.js";import{a as g,b as A}from"./chunk-EUEWNXPI.js";import{b as x}from"./chunk-QCM42KG3.js";import{c as y,e as u,g as T,h as k,i as C,j as _}from"./chunk-SWRTSPS4.js";import f from"chalk";import X from"node:path";var J="every-app-gateway",N="every-app-gateway";async function S(t=!1){console.log(`
|
|
2
|
-
Setting up Cloudflare your D1 Database and KV Store...
|
|
3
|
-
`);let e=await y(),o=await T(J,t),r=await A(N,t);return{d1DatabaseId:o,kvNamespaceId:r,accountId:e}}import v from"node:crypto";import W from"node:crypto";import m from"chalk";function $(){return W.randomBytes(32).toString("base64")}function b(){let{privateKey:t,publicKey:e}=W.generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:t,publicKey:e}}async function D(t,e,o=!1){console.log("Configuring Secrets...");try{if(await l("GATEWAY_URL",e,o)||await c("GATEWAY_URL",t,e,o,`Setting GATEWAY_URL to: ${t}`),!await l("BETTER_AUTH_SECRET",e,o)){let s=$();await c("BETTER_AUTH_SECRET",s,e,o,"Generating new Better Auth secret...")}let i=await l("JWT_PRIVATE_KEY",e,o),n=await l("JWT_PUBLIC_KEY",e,o);if(i&&n)o&&console.log(m.dim(` JWT key pair already exists
|
|
4
|
-
`));else if(!i&&!n){o&&console.log(m.dim(` Generating new JWT key pair...
|
|
5
|
-
`));let s=b();await c("JWT_PRIVATE_KEY",s.privateKey,e,o),await c("JWT_PUBLIC_KEY",s.publicKey,e,o),o&&console.log(m.green(`Created JWT key pair secrets
|
|
6
|
-
`))}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(o?`Secret setup complete!
|
|
7
|
-
`:` Finished.
|
|
8
|
-
`)}catch(r){throw console.error(`
|
|
9
|
-
Failed to setup secrets`,r instanceof Error?`
|
|
10
|
-
${r.message}`:""),r}}async function K(t,e,o,r=!1){await k({configPath:t,d1DatabaseId:e.d1DatabaseId,kvNamespaceId:e.kvNamespaceId,verbose:r});let a=v.randomUUID();console.log(),await g("npx",["wrangler","deploy"],{cwd:t,description:`Deploying your Gateway to Cloudflare workers...
|
|
11
|
-
|
|
12
|
-
This could take up to a minute.`,env:{...process.env,BETTER_AUTH_SECRET:a},verbose:r}),console.log(),await D(o,t,r)}import d from"chalk";import{execa as B}from"execa";async function P(t,e=!1){let o=await _(t);if(!o.d1_databases||o.d1_databases.length===0){e&&console.log(d.dim(`No D1 databases configured, skipping migrations
|
|
13
|
-
`));return}console.log(d.dim(`
|
|
14
|
-
Running database migrations...`));try{await B("npm",["install","--no-save","drizzle-kit"],{cwd:t,stdio:e?"inherit":"pipe"}),await x("npx",["drizzle-kit","migrate","--config=drizzle-prod.config.ts"],{cwd:t,verbose:e}),console.log(d.green(`Migrations completed!
|
|
15
|
-
`))}catch(r){console.error(r)}}import U from"node:fs";import Y from"node:path";import{Readable as z}from"node:stream";import{pipeline as M}from"node:stream/promises";import{createWriteStream as F}from"node:fs";import{spawn as V}from"node:child_process";import p from"chalk";var O="every-app",H="every-app",G="every-app-gateway-build.tar.gz";function j(){return`https://github.com/${O}/${H}/releases/download/gateway-latest/${G}`}async function q(t,e){let o=await fetch(t,{redirect:"follow"});if(!o.ok)throw new Error(`Failed to download file: ${o.status} ${o.statusText}`);if(!o.body)throw new Error("Response body is null");let r=F(e),a=z.fromWeb(o.body);await M(a,r)}async function Q(t,e){return new Promise((o,r)=>{let a=V("tar",["-xzf",t,"-C",e]);a.on("error",r),a.on("close",i=>{i===0?o():r(new Error(`tar extraction failed with code ${i}`))})})}async function I(t,e=!1){let o=j();console.log(`
|
|
16
|
-
Getting latest gateway release...`),e&&console.log(p.dim(`URL: ${o}`)),U.mkdirSync(t,{recursive:!0});let r=Y.join(t,G);try{await q(o,r)}catch(a){throw a instanceof Error&&a.message.includes("404")?new Error("Gateway release not found. Make sure a release has been published."):a}return e&&(console.log(p.dim(`Downloaded to: ${r}`)),console.log(p.dim("Extracting archive..."))),await Q(r,t),U.unlinkSync(r),e&&console.log(p.dim("Extraction complete")),t}async function Le(t){let e=t.verbose||!1;if(!await R("Do you want to deploy EveryApp Gateway into this Cloudflare account?")){console.log(`
|
|
17
|
-
Deployment cancelled by user
|
|
18
|
-
`);return}await h();let r=await S(e),a=await w("gateway-deploy-");e&&console.log(f.dim(`Working directory: ${a}
|
|
19
|
-
`));let i=null;try{let n=await I(a,e),s=X.join(n,"wrangler.jsonc"),L=await C(s);i=await u(L),await K(n,r,i,e),await P(n,e)}catch(n){throw console.error(`
|
|
20
|
-
Deployment failed:`,n instanceof Error?n.message:n),n}finally{await E(a,e)}if(!i)throw new Error("Worker URL not set properly during deployment");console.log(f.green(`
|
|
21
|
-
Gateway deployment successful!
|
|
22
|
-
`)),console.log(`Your Gateway is now live at: ${f.cyan(i)}
|
|
23
|
-
`)}export{Le as deploy};
|