create-seiro 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +15 -4
- package/package.json +4 -1
- package/template/assets.d.ts +9 -0
- package/template/bunfig.toml +2 -0
- package/template/index.html +20 -22
- package/template/package.json +3 -1
- package/template/server.ts +5 -20
- package/template/styles.css +1 -0
- /package/template/{server.test.ts → server.test.ts.template} +0 -0
package/index.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { $ } from "bun";
|
|
3
3
|
import { cp, readFile, writeFile } from "fs/promises";
|
|
4
|
-
import { join, resolve } from "path";
|
|
4
|
+
import { basename, join, resolve } from "path";
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
6
|
+
const projectArg = process.argv[2];
|
|
7
|
+
if (!projectArg) {
|
|
8
8
|
console.error("Usage: bunx create-seiro <project-name>");
|
|
9
9
|
process.exit(1);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const targetDir = resolve(
|
|
12
|
+
const targetDir = resolve(projectArg);
|
|
13
|
+
const projectName = basename(targetDir);
|
|
13
14
|
const templateDir = join(import.meta.dir, "template");
|
|
14
15
|
|
|
15
16
|
console.log(`Creating ${projectName}...`);
|
|
@@ -23,6 +24,16 @@ const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
|
23
24
|
pkg.name = projectName;
|
|
24
25
|
await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
25
26
|
|
|
27
|
+
// Rename test file template
|
|
28
|
+
const testTemplatePath = join(targetDir, "server.test.ts.template");
|
|
29
|
+
const testPath = join(targetDir, "server.test.ts");
|
|
30
|
+
try {
|
|
31
|
+
await Bun.write(testPath, await Bun.file(testTemplatePath).text());
|
|
32
|
+
await Bun.file(testTemplatePath).unlink();
|
|
33
|
+
} catch {
|
|
34
|
+
// File might not exist
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
// Install dependencies
|
|
27
38
|
console.log("Installing dependencies...");
|
|
28
39
|
await $`cd ${targetDir} && bun install`.quiet();
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-seiro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Scaffold a new Seiro project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"create-seiro": "./index.ts"
|
|
8
8
|
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "bun test --ignore-pattern 'template/**/*'"
|
|
11
|
+
},
|
|
9
12
|
"files": [
|
|
10
13
|
"index.ts",
|
|
11
14
|
"template"
|
package/template/index.html
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
<!
|
|
2
|
-
<html
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
</
|
|
20
|
-
</
|
|
21
|
-
<script type="module" src="/app.js"></script>
|
|
22
|
-
</body>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Seiro App</title>
|
|
5
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
6
|
+
<script type="module" src="./app.ts"></script>
|
|
7
|
+
</head>
|
|
8
|
+
<body class="bg-zinc-900 text-zinc-100 min-h-screen">
|
|
9
|
+
<header class="border-b border-zinc-800 p-4">
|
|
10
|
+
<div class="max-w-6xl mx-auto flex items-center justify-between">
|
|
11
|
+
<h1 class="text-xl font-bold">Seiro App</h1>
|
|
12
|
+
<auth-form></auth-form>
|
|
13
|
+
</div>
|
|
14
|
+
</header>
|
|
15
|
+
<main class="max-w-6xl mx-auto p-4">
|
|
16
|
+
<div class="text-center py-12">
|
|
17
|
+
<p class="text-zinc-400">Loading...</p>
|
|
18
|
+
</div>
|
|
19
|
+
</main>
|
|
20
|
+
</body>
|
|
23
21
|
</html>
|
package/template/package.json
CHANGED
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
"test": "bun test server.test.ts"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"seiro": "^0.1.
|
|
13
|
+
"seiro": "^0.1.2",
|
|
14
14
|
"@preact/signals-core": "^1.12.2",
|
|
15
15
|
"postgres": "^3.4.8"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/bun": "latest",
|
|
19
|
+
"bun-plugin-tailwind": "^0.1.2",
|
|
20
|
+
"tailwindcss": "^4.1.18",
|
|
19
21
|
"typescript": "^5.9.3"
|
|
20
22
|
}
|
|
21
23
|
}
|
package/template/server.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import postgres from "postgres";
|
|
2
2
|
import { createServer } from "seiro/server";
|
|
3
|
-
import
|
|
3
|
+
import homepage from "./index.html";
|
|
4
4
|
import * as auth from "./auth/server";
|
|
5
5
|
|
|
6
6
|
const DATABASE_URL =
|
|
@@ -8,7 +8,7 @@ const DATABASE_URL =
|
|
|
8
8
|
|
|
9
9
|
const sql = postgres(DATABASE_URL);
|
|
10
10
|
|
|
11
|
-
const server = createServer
|
|
11
|
+
const server = createServer({
|
|
12
12
|
port: 3000,
|
|
13
13
|
auth: {
|
|
14
14
|
verify: auth.verifyToken,
|
|
@@ -23,22 +23,7 @@ const server = createServer<Commands, Queries, Events>({
|
|
|
23
23
|
// Register auth handlers
|
|
24
24
|
auth.register(server, sql);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
const indexHtml = await Bun.file("index.html").text();
|
|
26
|
+
const app = await server.start({ "/": homepage });
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
headers: { "Content-Type": "text/html" },
|
|
32
|
-
}),
|
|
33
|
-
"/app.js": async () => {
|
|
34
|
-
const result = await Bun.build({
|
|
35
|
-
entrypoints: ["./app.ts"],
|
|
36
|
-
minify: false,
|
|
37
|
-
});
|
|
38
|
-
return new Response(result.outputs[0], {
|
|
39
|
-
headers: { "Content-Type": "application/javascript" },
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
console.log("Server running on http://localhost:3000");
|
|
28
|
+
console.log(`Server running at ${app.url}`);
|
|
29
|
+
console.log(`WebSocket at ws://localhost:3000/ws`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
File without changes
|