add solid-start support
This commit is contained in:
8
index.ts
8
index.ts
@@ -5,7 +5,7 @@ import { initRenderer } from '@gregorlohaus/tdir'
|
||||
import { z } from 'zod'
|
||||
import path from "node:path";
|
||||
|
||||
p.intro("create-glstack");
|
||||
p.intro(`create-glstack ${process.env.GLSTACK_DEV && 'isDev'}`);
|
||||
|
||||
const project = await p.group(
|
||||
{
|
||||
@@ -44,12 +44,14 @@ const project = await p.group(
|
||||
},
|
||||
}
|
||||
);
|
||||
const createRenderer = initRenderer(path.join(import.meta.dir, '..', 'template'))
|
||||
|
||||
const templateDir = (process.env.GLSTACK_DEV == 'true' ? './template' : path.join(import.meta.dir, '..', 'template'))
|
||||
const createRenderer = initRenderer(templateDir)
|
||||
const render = createRenderer(z.object({
|
||||
project: z.object({
|
||||
name: z.string(),
|
||||
goprefix: z.string(),
|
||||
frontend: z.literal("svelte-kit").or(z.literal("solid-start"))
|
||||
frontend: z.string(),
|
||||
})
|
||||
}))
|
||||
const destDir = path.join("./",project.name);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "create-glstack",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { Todo } from "@<@var(context.project.name)>/rpc";
|
||||
import type { ExtractPayload } from "$lib/utils"
|
||||
import type { Todo, ExtractPayload } from "@<@var(context.project.name)>/rpc";
|
||||
import Input from "$lib/components/ui/input/input.svelte";
|
||||
import Button from "$lib/components/ui/button/button.svelte"
|
||||
import * as Field from "$lib/components/ui/field/index"
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { type Todo } from "@<@var(context.project.name)>/rpc";
|
||||
import type { Todo, ExtractPayload } from "@<@var(context.project.name)>/rpc";
|
||||
import { getTodoCollection } from "$lib/todocollectionscontext";
|
||||
import * as Card from "../ui/card/index";
|
||||
import * as Field from "../ui/field/index";
|
||||
import Input from "../ui/input/input.svelte";
|
||||
import type { ExtractPayload } from "$lib/utils";
|
||||
import Checkbox from "../ui/checkbox/checkbox.svelte";
|
||||
import Button from "../ui/button/button.svelte";
|
||||
import { DeleteIcon } from "@lucide/svelte"
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import { setTodoCollection } from '$lib/todocollectionscontext';
|
||||
import { QueryClient,QueryClientProvider } from '@tanstack/svelte-query';
|
||||
import { type Todo } from '@<@var(context.project.name)>/rpc';
|
||||
import type { Todo, ExtractPayload } from '@<@var(context.project.name)>/rpc';
|
||||
import { browser } from '$app/environment';
|
||||
import { createCollection } from '@tanstack/svelte-db';
|
||||
import { queryCollectionOptions } from '@tanstack/query-db-collection';
|
||||
import { getRouter } from "$lib/getconnectrouter"
|
||||
import type { ExtractPayload } from '$lib/utils';
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
{
|
||||
packages = [
|
||||
pkgs.bun
|
||||
pkgs.nodejs_24
|
||||
pkgs.watchexec
|
||||
pkgs.sqlc
|
||||
pkgs.dbmate
|
||||
@@ -31,22 +32,27 @@
|
||||
air = {
|
||||
exec = "air";
|
||||
cwd = "./services/api";
|
||||
after = ["devenv:processes:postgres"];
|
||||
};
|
||||
protowatcher = {
|
||||
exec = "watchexec -r -e proto buf generate";
|
||||
cwd = "./packages/proto";
|
||||
after= ["devenv:processes:air@started"];
|
||||
};
|
||||
protojswatcher = {
|
||||
exec = "watchexec -e js,ts -w ./packages/rpc/src -r bun run ./scripts/gen-rpc-index.ts";
|
||||
cwd = "./";
|
||||
after= ["devenv:processes:protowatcher@started"];
|
||||
};
|
||||
sqlwatcher = {
|
||||
exec = "watchexec -w -r db -e sql sqlc generate";
|
||||
exec = "watchexec -w ./db/migrations -w ./db/query -r -e sql sqlc generate";
|
||||
cwd = "./services/api";
|
||||
after= ["devenv:processes:air@started"];
|
||||
};
|
||||
bundev = {
|
||||
exec = "bun dev";
|
||||
cwd = "./apps/web";
|
||||
after= ["devenv:processes:air@started"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ const isStringLiteral = (s: string | StringLiteral | undefined): s is StringLite
|
||||
return (s as StringLiteral).forEachChild != undefined;
|
||||
}
|
||||
|
||||
const serviceNameToRouterPropertyName = (n:string) : string => {
|
||||
return n.toLowerCase().replace('service','') + 's'
|
||||
const serviceNameToRouterPropertyName = (n: string): string => {
|
||||
return n.toLowerCase().replace('service', '') + 's'
|
||||
}
|
||||
|
||||
const exportDecl = (exp: Map<string, boolean>, typesOnly:boolean = false, from?: string | StringLiteral) => {
|
||||
const exportDecl = (exp: Map<string, boolean>, typesOnly: boolean = false, from?: string | StringLiteral) => {
|
||||
return factory.createExportDeclaration(
|
||||
undefined,
|
||||
typesOnly,
|
||||
@@ -145,6 +145,14 @@ for (const filePath of files) {
|
||||
"@connectrpc/connect"
|
||||
)
|
||||
)
|
||||
statements.push(
|
||||
importDecl(
|
||||
new Map<string, boolean>([
|
||||
["Message", true],
|
||||
]),
|
||||
"@bufbuild/protobuf"
|
||||
)
|
||||
)
|
||||
statements.push(
|
||||
importDecl(
|
||||
new Map<string, boolean>([
|
||||
@@ -308,10 +316,44 @@ statements.push(factory.createFunctionDeclaration(
|
||||
)
|
||||
))
|
||||
|
||||
statements.push(exportDecl(new Map<string,boolean>([
|
||||
|
||||
statements.push(exportDecl(new Map<string, boolean>([
|
||||
['createRouter', false]
|
||||
])))
|
||||
|
||||
statements.push(
|
||||
ts.factory.createTypeAliasDeclaration(
|
||||
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
||||
ts.factory.createIdentifier("ExtractPayload"),
|
||||
[
|
||||
ts.factory.createTypeParameterDeclaration(
|
||||
undefined,
|
||||
ts.factory.createIdentifier("T"),
|
||||
undefined,
|
||||
undefined
|
||||
),
|
||||
],
|
||||
ts.factory.createTypeReferenceNode(
|
||||
ts.factory.createIdentifier("Omit"),
|
||||
[
|
||||
// T
|
||||
ts.factory.createTypeReferenceNode("T", undefined),
|
||||
|
||||
// keyof Message<any>
|
||||
ts.factory.createTypeOperatorNode(
|
||||
ts.SyntaxKind.KeyOfKeyword,
|
||||
ts.factory.createTypeReferenceNode(
|
||||
ts.factory.createIdentifier("Message"),
|
||||
[
|
||||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
||||
]
|
||||
)
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
const outputFile = ts.createSourceFile(INDEX_FILE, "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
|
||||
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user