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