@grupodiariodaregiao/bunstone 0.0.28 → 0.1.0
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/bin/cli.ts +59 -1
- package/package.json +11 -3
package/bin/cli.ts
CHANGED
|
@@ -34,24 +34,31 @@ async function scaffold() {
|
|
|
34
34
|
await mkdir(join(projectPath, "src"), { recursive: true });
|
|
35
35
|
await mkdir(join(projectPath, "src/controllers"), { recursive: true });
|
|
36
36
|
await mkdir(join(projectPath, "src/services"), { recursive: true });
|
|
37
|
+
await mkdir(join(projectPath, "src/views"), { recursive: true });
|
|
37
38
|
|
|
38
39
|
// package.json
|
|
39
40
|
const pkg = {
|
|
40
41
|
name: projectName,
|
|
41
42
|
version: "1.0.0",
|
|
42
43
|
main: "src/main.ts",
|
|
44
|
+
type: "module",
|
|
43
45
|
scripts: {
|
|
44
46
|
start: "bun run src/main.ts",
|
|
45
47
|
dev: "bun --watch src/main.ts",
|
|
46
48
|
test: "bun test",
|
|
47
49
|
},
|
|
48
50
|
dependencies: {
|
|
51
|
+
"@elysiajs/html": "^1.4.0",
|
|
49
52
|
"@grupodiariodaregiao/bunstone": "latest",
|
|
50
53
|
"reflect-metadata": "^0.2.2",
|
|
54
|
+
react: "^19.0.0",
|
|
55
|
+
"react-dom": "^19.0.0",
|
|
51
56
|
zod: "^4.3.2",
|
|
52
57
|
},
|
|
53
58
|
devDependencies: {
|
|
54
59
|
"@types/bun": "latest",
|
|
60
|
+
"@types/react": "^19.0.0",
|
|
61
|
+
"@types/react-dom": "^19.0.0",
|
|
55
62
|
},
|
|
56
63
|
};
|
|
57
64
|
|
|
@@ -75,6 +82,7 @@ async function scaffold() {
|
|
|
75
82
|
downlevelIteration: true,
|
|
76
83
|
skipLibCheck: true,
|
|
77
84
|
jsx: "react-jsx",
|
|
85
|
+
jsxImportSource: "react",
|
|
78
86
|
allowSyntheticDefaultImports: true,
|
|
79
87
|
forceConsistentCasingInFileNames: true,
|
|
80
88
|
allowJs: true,
|
|
@@ -123,12 +131,14 @@ export class AppModule {}
|
|
|
123
131
|
// src/controllers/app.controller.ts
|
|
124
132
|
const controllerTs = `import { Controller, Get } from "@grupodiariodaregiao/bunstone";
|
|
125
133
|
import { AppService } from "@/services/app.service";
|
|
134
|
+
import { Welcome } from "@/views/Welcome";
|
|
126
135
|
|
|
127
136
|
@Controller()
|
|
128
137
|
export class AppController {
|
|
129
138
|
constructor(private readonly appService: AppService) {}
|
|
130
139
|
|
|
131
140
|
@Get()
|
|
141
|
+
@Render(Welcome)
|
|
132
142
|
getHello() {
|
|
133
143
|
return this.appService.getHello();
|
|
134
144
|
}
|
|
@@ -159,10 +169,58 @@ export class AppService {
|
|
|
159
169
|
serviceTs
|
|
160
170
|
);
|
|
161
171
|
|
|
172
|
+
// src/main.ts
|
|
173
|
+
const mainTsContent = `import "reflect-metadata";
|
|
174
|
+
import { AppStartup } from "@diariodaregiao/bunstone";
|
|
175
|
+
import { AppModule } from "@/app.module";
|
|
176
|
+
|
|
177
|
+
const app = AppStartup.create(AppModule, {
|
|
178
|
+
viewsDir: "src/views"
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
app.listen(3000);
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
await writeFile(join(projectPath, "src/main.ts"), mainTsContent);
|
|
185
|
+
|
|
186
|
+
// src/views/Welcome.tsx
|
|
187
|
+
const welcomeTsx = `import React, { useState } from "react";
|
|
188
|
+
|
|
189
|
+
export const Welcome = ({ message, timestamp }: { message: string, timestamp: string }) => {
|
|
190
|
+
const [count, setCount] = useState(0);
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<div className="max-w-md mx-auto mt-10 p-6 bg-white rounded-xl shadow-md border border-gray-200 text-center">
|
|
194
|
+
<h1 className="text-3xl font-bold text-indigo-600 mb-2">Bunstone MVC</h1>
|
|
195
|
+
<p className="text-gray-600 mb-6">{message}</p>
|
|
196
|
+
|
|
197
|
+
<div className="bg-indigo-50 p-4 rounded-lg mb-6">
|
|
198
|
+
<p className="text-sm text-indigo-400 mb-2 font-mono">Interactive Hooks Example</p>
|
|
199
|
+
<div className="flex items-center justify-center gap-4">
|
|
200
|
+
<button
|
|
201
|
+
onClick={() => setCount(count - 1)}
|
|
202
|
+
className="bg-white border border-indigo-200 px-3 py-1 rounded shadow-sm hover:bg-indigo-100"
|
|
203
|
+
>-</button>
|
|
204
|
+
<span className="text-2xl font-mono font-bold text-indigo-700 min-w-[2ch]">{count}</span>
|
|
205
|
+
<button
|
|
206
|
+
onClick={() => setCount(count + 1)}
|
|
207
|
+
className="bg-white border border-indigo-200 px-3 py-1 rounded shadow-sm hover:bg-indigo-100"
|
|
208
|
+
>+</button>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
<p className="text-gray-400 text-xs italic">Server time: {timestamp}</p>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
`;
|
|
217
|
+
|
|
218
|
+
await writeFile(join(projectPath, "src/views/Welcome.tsx"), welcomeTsx);
|
|
219
|
+
|
|
162
220
|
// .gitignore
|
|
163
221
|
await writeFile(
|
|
164
222
|
join(projectPath, ".gitignore"),
|
|
165
|
-
"node_modules\n.DS_Store\ndist\n.env\n"
|
|
223
|
+
"node_modules\n.DS_Store\ndist\n.env\n.bunstone\n"
|
|
166
224
|
);
|
|
167
225
|
|
|
168
226
|
console.log("📦 Installing dependencies...");
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "./dist/index.js",
|
|
4
4
|
"module": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
|
-
"version": "0.0
|
|
6
|
+
"version": "0.1.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
9
|
"bunstone": "./bin/cli.ts"
|
|
@@ -15,23 +15,31 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "bun test",
|
|
18
|
-
"build": "rm -rf dist && bun build ./index.ts --outdir ./dist --target bun && tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
18
|
+
"build": "rm -rf dist && bun build ./index.ts --outdir ./dist --target bun --external react --external react-dom --external elysia --external @elysiajs/* && tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
19
19
|
"docs:dev": "vitepress dev docs",
|
|
20
20
|
"docs:build": "vitepress build docs",
|
|
21
21
|
"docs:preview": "vitepress preview docs"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/bun": "latest",
|
|
25
|
+
"@types/react": "^19.2.8",
|
|
26
|
+
"@types/react-dom": "^19.2.3",
|
|
27
|
+
"react": "^19.2.3",
|
|
28
|
+
"react-dom": "^19.2.3",
|
|
25
29
|
"vitepress": "^1.6.4"
|
|
26
30
|
},
|
|
27
31
|
"peerDependencies": {
|
|
32
|
+
"react": ">=19",
|
|
33
|
+
"react-dom": ">=19",
|
|
28
34
|
"typescript": "^5"
|
|
29
35
|
},
|
|
30
36
|
"dependencies": {
|
|
31
37
|
"@elysiajs/cors": "^1.4.1",
|
|
38
|
+
"@elysiajs/html": "^1.4.0",
|
|
32
39
|
"@elysiajs/jwt": "^1.4.0",
|
|
40
|
+
"@elysiajs/static": "^1.4.7",
|
|
33
41
|
"@elysiajs/swagger": "^1.3.1",
|
|
34
|
-
"elysia": "^1.4.
|
|
42
|
+
"elysia": "^1.4.21",
|
|
35
43
|
"node-cron": "^4.2.1",
|
|
36
44
|
"reflect-metadata": "^0.2.2",
|
|
37
45
|
"zod": "^4.3.2"
|