mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
add deno to the cli starters
This commit is contained in:
@@ -20,6 +20,7 @@ const config = {
|
|||||||
node: "Node.js",
|
node: "Node.js",
|
||||||
bun: "Bun",
|
bun: "Bun",
|
||||||
cloudflare: "Cloudflare",
|
cloudflare: "Cloudflare",
|
||||||
|
deno: "Deno",
|
||||||
aws: "AWS Lambda",
|
aws: "AWS Lambda",
|
||||||
},
|
},
|
||||||
framework: {
|
framework: {
|
||||||
@@ -269,7 +270,7 @@ async function action(options: {
|
|||||||
);
|
);
|
||||||
$p.log.success(`Updated package name to ${color.cyan(ctx.name)}`);
|
$p.log.success(`Updated package name to ${color.cyan(ctx.name)}`);
|
||||||
|
|
||||||
{
|
if (template.installDeps !== false) {
|
||||||
const install =
|
const install =
|
||||||
options.yes ??
|
options.yes ??
|
||||||
(await $p.confirm({
|
(await $p.confirm({
|
||||||
|
|||||||
21
app/src/cli/commands/create/templates/deno.ts
Normal file
21
app/src/cli/commands/create/templates/deno.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { overrideJson } from "cli/commands/create/npm";
|
||||||
|
import type { Template } from "cli/commands/create/templates";
|
||||||
|
import { getVersion } from "cli/utils/sys";
|
||||||
|
|
||||||
|
export const deno = {
|
||||||
|
key: "deno",
|
||||||
|
title: "Deno Basic",
|
||||||
|
integration: "deno",
|
||||||
|
description: "A basic bknd Deno server with static assets",
|
||||||
|
path: "gh:bknd-io/bknd/examples/deno",
|
||||||
|
installDeps: false,
|
||||||
|
ref: true,
|
||||||
|
setup: async (ctx) => {
|
||||||
|
const version = await getVersion();
|
||||||
|
await overrideJson(
|
||||||
|
"deno.json",
|
||||||
|
(json) => ({ ...json, links: undefined, imports: { bknd: `npm:bknd@${version}` } }),
|
||||||
|
{ dir: ctx.dir },
|
||||||
|
);
|
||||||
|
},
|
||||||
|
} satisfies Template;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { deno } from "cli/commands/create/templates/deno";
|
||||||
import { cloudflare } from "./cloudflare";
|
import { cloudflare } from "./cloudflare";
|
||||||
|
|
||||||
export type TemplateSetupCtx = {
|
export type TemplateSetupCtx = {
|
||||||
@@ -15,6 +16,7 @@ export type Integration =
|
|||||||
| "react-router"
|
| "react-router"
|
||||||
| "astro"
|
| "astro"
|
||||||
| "aws"
|
| "aws"
|
||||||
|
| "deno"
|
||||||
| "custom";
|
| "custom";
|
||||||
|
|
||||||
type TemplateScripts = "install" | "dev" | "build" | "start";
|
type TemplateScripts = "install" | "dev" | "build" | "start";
|
||||||
@@ -34,6 +36,11 @@ export type Template = {
|
|||||||
* adds a ref "#{ref}" to the path. If "true", adds the current version of bknd
|
* adds a ref "#{ref}" to the path. If "true", adds the current version of bknd
|
||||||
*/
|
*/
|
||||||
ref?: true | string;
|
ref?: true | string;
|
||||||
|
/**
|
||||||
|
* control whether to install dependencies automatically
|
||||||
|
* e.g. on deno, this is not needed
|
||||||
|
*/
|
||||||
|
installDeps?: boolean;
|
||||||
scripts?: Partial<Record<TemplateScripts, string>>;
|
scripts?: Partial<Record<TemplateScripts, string>>;
|
||||||
preinstall?: (ctx: TemplateSetupCtx) => Promise<void>;
|
preinstall?: (ctx: TemplateSetupCtx) => Promise<void>;
|
||||||
postinstall?: (ctx: TemplateSetupCtx) => Promise<void>;
|
postinstall?: (ctx: TemplateSetupCtx) => Promise<void>;
|
||||||
@@ -90,4 +97,5 @@ export const templates: Template[] = [
|
|||||||
path: "gh:bknd-io/bknd/examples/aws-lambda",
|
path: "gh:bknd-io/bknd/examples/aws-lambda",
|
||||||
ref: true,
|
ref: true,
|
||||||
},
|
},
|
||||||
|
deno,
|
||||||
];
|
];
|
||||||
|
|||||||
5
examples/.gitignore
vendored
5
examples/.gitignore
vendored
@@ -1,2 +1,5 @@
|
|||||||
*/package-lock.json
|
*/package-lock.json
|
||||||
*/bun.lock
|
*/bun.lock
|
||||||
|
*/deno.lock
|
||||||
|
*/node_modules
|
||||||
|
*/*.db
|
||||||
8
examples/deno/deno.json
Normal file
8
examples/deno/deno.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"nodeModulesDir": "auto",
|
||||||
|
"imports": {
|
||||||
|
"bknd": "npm:bknd@0.19.0-rc.1"
|
||||||
|
},
|
||||||
|
"links": ["../../app/"],
|
||||||
|
"unstable": ["raw-imports"]
|
||||||
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
import { createRuntimeApp } from "bknd/adapter";
|
import { createRuntimeApp, serveStaticViaImport } from "bknd/adapter";
|
||||||
|
|
||||||
const app = await createRuntimeApp({
|
const app = await createRuntimeApp({
|
||||||
connection: {
|
connection: {
|
||||||
url: "file:./data.db",
|
url: "file:./data.db",
|
||||||
},
|
},
|
||||||
adminOptions: {
|
serveStatic: serveStaticViaImport(),
|
||||||
// currently needs a hosted version of the static assets
|
|
||||||
assetsPath: "https://cdn.bknd.io/bknd/static/0.15.0-rc.9/",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
export default {
|
||||||
Deno.serve(app.fetch);
|
fetch: app.fetch,
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "bknd-deno-example",
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"bknd": "file:../../app"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user