finalize initial starters

This commit is contained in:
dswbx
2025-02-14 13:55:46 +01:00
parent 7d3c76d7c1
commit 3b487ade2a
8 changed files with 180 additions and 64 deletions

View File

@@ -4,6 +4,8 @@ import { uuid } from "core/utils";
import color from "picocolors";
import type { Template, TemplateSetupCtx } from ".";
const WRANGLER_FILE = "wrangler.json";
export const cloudflare = {
key: "cloudflare",
title: "Cloudflare Basic",
@@ -12,11 +14,12 @@ export const cloudflare = {
path: "gh:bknd-io/bknd/examples/cloudflare-worker",
ref: true,
setup: async (ctx) => {
// overwrite assets directory
// overwrite assets directory & name
await overrideJson(
"wrangler.json",
WRANGLER_FILE,
(json) => ({
...json,
name,
assets: {
directory: "node_modules/bknd/dist/static"
}
@@ -70,7 +73,7 @@ async function createD1(ctx: TemplateSetupCtx) {
}
await overrideJson(
"wrangler.json",
WRANGLER_FILE,
(json) => ({
...json,
d1_databases: [
@@ -90,7 +93,7 @@ async function createD1(ctx: TemplateSetupCtx) {
async function createLibsql(ctx: TemplateSetupCtx) {
await overrideJson(
"wrangler.json",
WRANGLER_FILE,
(json) => ({
...json,
vars: {

View File

@@ -3,10 +3,12 @@ import { cloudflare } from "./cloudflare";
export type TemplateSetupCtx = {
template: Template;
dir: string;
name: string;
};
export type Integration = "node" | "bun" | "cloudflare" | "nextjs" | "remix" | "astro" | "custom";
type TemplateScripts = "install" | "dev" | "build" | "start";
export type Template = {
/**
* unique key for the template
@@ -23,12 +25,13 @@ export type Template = {
* adds a ref "#{ref}" to the path. If "true", adds the current version of bknd
*/
ref?: true | string;
scripts?: Partial<Record<TemplateScripts, string>>;
preinstall?: (ctx: TemplateSetupCtx) => Promise<void>;
postinstall?: (ctx: TemplateSetupCtx) => Promise<void>;
setup?: (ctx: TemplateSetupCtx) => Promise<void>;
};
export const templates = [
export const templates: Template[] = [
{
key: "node",
title: "Node.js Basic",
@@ -45,5 +48,33 @@ export const templates = [
path: "gh:bknd-io/bknd/examples/bun",
ref: true
},
cloudflare
] as const satisfies Template[];
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",
integration: "astro",
description: "A basic bknd Astro starter",
path: "gh:bknd-io/bknd/examples/astro",
ref: true
}
];