@every-app/cli 0.0.18 → 0.0.20
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
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-E6IJFA5J.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.
|
|
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.20";import{buildCommand as o,buildRouteMap as m}from"@stricli/core";var c=o({loader:async()=>import("./create-H2GLJX47.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
2
|
`)}}),u=o({loader:async()=>{let{deploy:e}=await import("./deploy-OI3QF3EI.js");return e},parameters:{positional:{kind:"tuple",parameters:[]},flags:{verbose:{kind:"boolean",brief:"Show detailed output during deployment",optional:!0}}},docs:{brief:"Deploy an app to Cloudflare",fullDescription:["Deploys the current app to Cloudflare Workers from the current directory.","The deployment process:"," 1. Reads wrangler.jsonc to determine required resources"," 2. Creates or links D1 databases and KV namespaces"," 3. Updates wrangler.jsonc with resource IDs"," 4. Installs dependencies if needed"," 5. Runs database migrations against production D1"," 6. Builds and deploys using wrangler deploy"].join(`
|
|
3
3
|
`)}}),y=o({loader:async()=>{let{remoteD1Shell:e}=await import("./remoteD1Shell-D34XAC3H.js");return e},parameters:{flags:{},positional:{kind:"array",parameter:{brief:"Command and arguments to run with environment variables",parse:String}}},docs:{brief:"Run a command with Cloudflare D1 connection environment variables",fullDescription:["Sets environment variables needed to connect to remote Cloudflare D1 and runs any command that requires D1 access.","","The command will:"," 1. Get the Cloudflare account ID"," 2. Look up the database ID from the database name in wrangler.jsonc"," 3. Get a valid OAuth token"," 4. Run the provided command with CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_DATABASE_ID, CLOUDFLARE_API_TOKEN, and MIGRATE_REMOTE set","","Common use cases:"," - Running Drizzle migrations: every app remote-d1-shell -- npx drizzle-kit migrate"," - Opening Drizzle Studio: every app remote-d1-shell -- npx drizzle-kit studio"," - Pushing schema changes: every app remote-d1-shell -- npx drizzle-kit push","","This command is useful for any operation that needs direct access to your production D1 database."].join(`
|
|
4
|
-
`)}}),s=m({routes:{create:c,deploy:u,"remote-d1-shell":y},docs:{brief:"App management commands"}});import{buildCommand as f,buildRouteMap as b}from"@stricli/core";var h=f({loader:async()=>{let{deploy:e}=await import("./deploy-
|
|
4
|
+
`)}}),s=m({routes:{create:c,deploy:u,"remote-d1-shell":y},docs:{brief:"App management commands"}});import{buildCommand as f,buildRouteMap as b}from"@stricli/core";var h=f({loader:async()=>{let{deploy:e}=await import("./deploy-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
5
|
`)}}),i=b({routes:{deploy:h},docs:{brief:"Gateway management commands"}});var w=C({routes:{app:s,gateway:i,install:v("every",{bash:"__every_bash_complete"}),uninstall:D("every",{bash:!0})},docs:{brief:n,hideRoute:{install:!0,uninstall:!0}}}),G=g(w,{name:r,versionInfo:{currentVersion:a},scanner:{allowArgumentEscapeSequence:!0}});export{A as a,G as b};
|
|
@@ -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-E6IJFA5J.js";import{run as i}from"@stricli/core";await i(o,process.argv.slice(2),r(process));
|
package/package.json
CHANGED
package/dist/deploy-EMXFJLBC.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import{d as w,e as E}from"./chunk-GIXANRUK.js";import{a as k,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 _,j as h}from"./chunk-SWRTSPS4.js";import f from"chalk";import Q 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 b from"node:crypto";import W from"node:crypto";import d from"chalk";function Y(){return W.randomBytes(32).toString("base64")}function $(){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=Y();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(d.dim(` JWT key pair already exists
|
|
4
|
-
`));else if(!i&&!n){o&&console.log(d.dim(` Generating new JWT key pair...
|
|
5
|
-
`));let s=$();await c("JWT_PRIVATE_KEY",s.privateKey,e,o),await c("JWT_PUBLIC_KEY",s.publicKey,e,o),o&&console.log(d.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 C({configPath:t,d1DatabaseId:e.d1DatabaseId,kvNamespaceId:e.kvNamespaceId,verbose:r});let a=b.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 p from"chalk";async function P(t,e=!1){let o=await h(t);if(!o.d1_databases||o.d1_databases.length===0){e&&console.log(p.dim(`No D1 databases configured, skipping migrations
|
|
13
|
-
`));return}console.log(p.dim(`
|
|
14
|
-
Running database migrations...`));try{await x("npx",["drizzle-kit","migrate","--config=drizzle-prod.config.ts"],{cwd:t,verbose:e}),console.log(p.green(`Migrations completed!
|
|
15
|
-
`))}catch(r){console.warn(p.yellow(`Failed to run migrations. You may need to run them manually.
|
|
16
|
-
`)),e&&console.error(r)}}import U from"node:fs";import B from"node:path";import{Readable as v}from"node:stream";import{pipeline as M}from"node:stream/promises";import{createWriteStream as F}from"node:fs";import{spawn as z}from"node:child_process";import m from"chalk";var V="every-app",O="every-app",G="every-app-gateway-build.tar.gz";function H(){return`https://github.com/${V}/${O}/releases/download/gateway-latest/${G}`}async function j(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=v.fromWeb(o.body);await M(a,r)}async function q(t,e){return new Promise((o,r)=>{let a=z("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=H();console.log(m.dim("Downloading gateway release (latest)...")),e&&console.log(m.dim(`URL: ${o}`)),U.mkdirSync(t,{recursive:!0});let r=B.join(t,G);try{await j(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(m.dim(`Downloaded to: ${r}`)),console.log(m.dim("Extracting archive..."))),await q(r,t),U.unlinkSync(r),e&&console.log(m.dim("Extraction complete")),t}async function Ge(t){let e=t.verbose||!1;if(!await k("Do you want to deploy EveryApp Gateway into this Cloudflare account?")){console.log(`
|
|
17
|
-
Deployment cancelled by user
|
|
18
|
-
`);return}await R();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=Q.join(n,"wrangler.jsonc"),L=await _(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{Ge as deploy};
|