cli create: updated templates, reworked examples to be standalone

This commit is contained in:
dswbx
2025-02-14 14:56:35 +01:00
parent b412da836c
commit 4bd201d454
18 changed files with 85 additions and 106 deletions

View File

@@ -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;
}>;

View File

@@ -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"
}
}));

View File

@@ -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",

View 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;

View 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;