mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
cli create: updated templates, reworked examples to be standalone
This commit is contained in:
@@ -7,9 +7,9 @@ export type TPackageJson = Partial<{
|
||||
main: string;
|
||||
version: string;
|
||||
scripts: Record<string, string>;
|
||||
dependencies: Record<string, string>;
|
||||
devDependencies: Record<string, string>;
|
||||
optionalDependencies: Record<string, string>;
|
||||
dependencies: Record<string, string | undefined>;
|
||||
devDependencies: Record<string, string | undefined>;
|
||||
optionalDependencies: Record<string, string | undefined>;
|
||||
[key: string]: any;
|
||||
}>;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ async function createLibsql(ctx: TemplateSetupCtx) {
|
||||
...pkg,
|
||||
scripts: {
|
||||
...pkg.scripts,
|
||||
db: "turso db",
|
||||
db: "turso dev",
|
||||
dev: "npm run db && wrangler dev"
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { cloudflare } from "./cloudflare";
|
||||
import { nextjs } from "./nextjs";
|
||||
import { remix } from "./remix";
|
||||
|
||||
export type TemplateSetupCtx = {
|
||||
template: Template;
|
||||
@@ -32,6 +34,9 @@ export type Template = {
|
||||
};
|
||||
|
||||
export const templates: Template[] = [
|
||||
cloudflare,
|
||||
nextjs,
|
||||
remix,
|
||||
{
|
||||
key: "node",
|
||||
title: "Node.js Basic",
|
||||
@@ -48,27 +53,6 @@ export const templates: Template[] = [
|
||||
path: "gh:bknd-io/bknd/examples/bun",
|
||||
ref: true
|
||||
},
|
||||
cloudflare,
|
||||
{
|
||||
key: "remix",
|
||||
title: "Remix Basic",
|
||||
integration: "remix",
|
||||
description: "A basic bknd Remix starter",
|
||||
path: "gh:bknd-io/bknd/examples/remix",
|
||||
ref: true
|
||||
},
|
||||
{
|
||||
// @todo: add `concurrently`?
|
||||
key: "nextjs",
|
||||
title: "Next.js Basic",
|
||||
integration: "nextjs",
|
||||
description: "A basic bknd Next.js starter",
|
||||
path: "gh:bknd-io/bknd/examples/nextjs",
|
||||
scripts: {
|
||||
install: "npm install --force"
|
||||
},
|
||||
ref: true
|
||||
},
|
||||
{
|
||||
key: "astro",
|
||||
title: "Astro Basic",
|
||||
|
||||
29
app/src/cli/commands/create/templates/nextjs.ts
Normal file
29
app/src/cli/commands/create/templates/nextjs.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { overridePackageJson } from "cli/commands/create/npm";
|
||||
import type { Template } from ".";
|
||||
|
||||
// @todo: add `concurrently`?
|
||||
export const nextjs = {
|
||||
key: "nextjs",
|
||||
title: "Next.js Basic",
|
||||
integration: "nextjs",
|
||||
description: "A basic bknd Next.js starter",
|
||||
path: "gh:bknd-io/bknd/examples/nextjs",
|
||||
scripts: {
|
||||
install: "npm install --force"
|
||||
},
|
||||
ref: true,
|
||||
preinstall: async (ctx) => {
|
||||
// locally it's required to overwrite react, here it is not
|
||||
await overridePackageJson(
|
||||
(pkg) => ({
|
||||
...pkg,
|
||||
dependencies: {
|
||||
...pkg.dependencies,
|
||||
react: undefined,
|
||||
"react-dom": undefined
|
||||
}
|
||||
}),
|
||||
{ dir: ctx.dir }
|
||||
);
|
||||
}
|
||||
} as const satisfies Template;
|
||||
25
app/src/cli/commands/create/templates/remix.ts
Normal file
25
app/src/cli/commands/create/templates/remix.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { overridePackageJson } from "cli/commands/create/npm";
|
||||
import type { Template } from ".";
|
||||
|
||||
export const remix = {
|
||||
key: "remix",
|
||||
title: "Remix Basic",
|
||||
integration: "remix",
|
||||
description: "A basic bknd Remix starter",
|
||||
path: "gh:bknd-io/bknd/examples/remix",
|
||||
ref: true,
|
||||
preinstall: async (ctx) => {
|
||||
// locally it's required to overwrite react
|
||||
await overridePackageJson(
|
||||
(pkg) => ({
|
||||
...pkg,
|
||||
dependencies: {
|
||||
...pkg.dependencies,
|
||||
react: "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
}
|
||||
}),
|
||||
{ dir: ctx.dir }
|
||||
);
|
||||
}
|
||||
} as const satisfies Template;
|
||||
1
examples/.gitignore
vendored
Normal file
1
examples/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*/package-lock.json
|
||||
@@ -7,8 +7,6 @@
|
||||
"start": "astro dev",
|
||||
"build": "astro check && astro build",
|
||||
"preview": "astro preview",
|
||||
"db": "turso dev --db-file test.db",
|
||||
"db:check": "sqlite3 test.db \"PRAGMA wal_checkpoint(FULL);\"",
|
||||
"astro": "astro"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -17,7 +15,7 @@
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"astro": "^4.16.16",
|
||||
"bknd": "workspace:*",
|
||||
"bknd": "file:../../app",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"typescript": "^5.7.2"
|
||||
|
||||
@@ -8,10 +8,7 @@ import { type BunBkndConfig, serve } from "bknd/adapter/bun";
|
||||
const config: BunBkndConfig = {
|
||||
connection: {
|
||||
url: ":memory:"
|
||||
},
|
||||
// this is only required to run inside the same workspace
|
||||
// leave blank if you're running this from a different project
|
||||
distPath: "../../app/dist"
|
||||
}
|
||||
};
|
||||
|
||||
serve(config);
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "bun run --hot index.ts"
|
||||
"dev": "bun run --hot index.ts",
|
||||
"start": "bun run index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"bknd": "workspace:*"
|
||||
"bknd": "file:../../app"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest"
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { $ } from "bun";
|
||||
//import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
|
||||
import esbuild from "esbuild";
|
||||
|
||||
const result = await esbuild.build({
|
||||
//plugins: [NodeModulesPolyfillPlugin()],
|
||||
platform: "browser",
|
||||
conditions: ["worker", "browser"],
|
||||
entryPoints: ["./src/index.ts"],
|
||||
outdir: "dist",
|
||||
external: ["__STATIC_CONTENT_MANIFEST", "cloudflare:workers"],
|
||||
format: "esm",
|
||||
target: "es2022",
|
||||
keepNames: true,
|
||||
bundle: true,
|
||||
metafile: true,
|
||||
minify: true,
|
||||
loader: {
|
||||
".html": "copy"
|
||||
},
|
||||
define: {
|
||||
IS_CLOUDFLARE_WORKER: "true"
|
||||
}
|
||||
});
|
||||
|
||||
await Bun.write("dist/meta.json", JSON.stringify(result.metafile));
|
||||
await $`gzip dist/index.js -c > dist/index.js.gz`;
|
||||
@@ -4,19 +4,17 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"deploy": "wrangler deploy",
|
||||
"db": "turso dev",
|
||||
"dev": "wrangler dev",
|
||||
"start": "wrangler dev",
|
||||
"test": "vitest",
|
||||
"cf-typegen": "wrangler types"
|
||||
},
|
||||
"dependencies": {
|
||||
"bknd": "workspace:*",
|
||||
"bknd": "file:../../app",
|
||||
"kysely-d1": "^0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20241106.0",
|
||||
"typescript": "^5.5.2",
|
||||
"wrangler": "^3.86.0"
|
||||
"@cloudflare/workers-types": "^4.20240620.0",
|
||||
"typescript": "^5.5.3",
|
||||
"wrangler": "^3.108.1"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#:schema node_modules/wrangler/config-schema.json
|
||||
name = "bknd-cf-worker-example"
|
||||
main = "src/index.ts"
|
||||
compatibility_date = "2025-02-04"
|
||||
compatibility_flags = ["nodejs_compat"]
|
||||
workers_dev = true
|
||||
minify = true
|
||||
assets = { directory = "../../app/dist/static" }
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "DB"
|
||||
database_name = "bknd-cf-example"
|
||||
database_id = "7ad67953-2bbf-47fc-8696-f4517dbfe674"
|
||||
|
||||
[[r2_buckets]]
|
||||
binding = "BUCKET"
|
||||
bucket_name = "bknd-cf-example"
|
||||
@@ -3,20 +3,17 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"dev": "npm run db & next dev",
|
||||
"db": "turso dev --db-file test.db",
|
||||
"db:check": "sqlite3 test.db \"PRAGMA wal_checkpoint(FULL);\"",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"start": "npm run db & next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"bknd": "workspace:*",
|
||||
"next": "15.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
"bknd": "file:../../app",
|
||||
"next": "15.0.2",
|
||||
"react": "file:../../node_modules/react",
|
||||
"react-dom": "file:../../node_modules/react-dom"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
|
||||
@@ -8,10 +8,7 @@ import { serve } from "bknd/adapter/node";
|
||||
const config = {
|
||||
connection: {
|
||||
url: ":memory:"
|
||||
},
|
||||
// this is only required to run inside the same workspace
|
||||
// leave blank if you're running this from a different project
|
||||
distPath: "../../app/dist"
|
||||
}
|
||||
};
|
||||
|
||||
serve(config);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"dev": "tsx --watch index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"bknd": "workspace:*",
|
||||
"bknd": "file:../../app",
|
||||
"@hono/node-server": "^1.13.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
"@remix-run/node": "^2.15.2",
|
||||
"@remix-run/react": "^2.15.2",
|
||||
"@remix-run/serve": "^2.15.2",
|
||||
"bknd": "workspace:*",
|
||||
"bknd": "file:../../app",
|
||||
"isbot": "^5.1.18",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react": "file:../../node_modules/react",
|
||||
"react-dom": "file:../../node_modules/react-dom",
|
||||
"remix-utils": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
"workspaces": [
|
||||
"app",
|
||||
"docs",
|
||||
"packages/*",
|
||||
"examples/*"
|
||||
"packages/*"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user