@farbenmeer/bunny 0.3.4 → 0.3.5
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/README.md +60 -11
- package/boilerplate.tar.gz +0 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +9 -2
- package/dist/cli/init.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,28 +1,77 @@
|
|
|
1
1
|
# @farbenmeer/bunny
|
|
2
2
|
|
|
3
|
-
This is a web framework based on [
|
|
3
|
+
This is a web framework based on [Tapi](https://www.npmjs.com/package/@farbenmeer/tapi) and React.
|
|
4
4
|
|
|
5
5
|
## Start a project
|
|
6
6
|
|
|
7
7
|
To scaffold a new project run:
|
|
8
8
|
```bash
|
|
9
|
-
|
|
9
|
+
pnpx @farbenmeer/bunny@latest init my-cool-project
|
|
10
|
+
```
|
|
11
|
+
or if you prefer another package manager:
|
|
12
|
+
```bash
|
|
13
|
+
npx @farbenmeer/bunny@latest init my-cool-project
|
|
14
|
+
bunx @farbenmeer/bunny@latest init my-cool-project
|
|
15
|
+
```
|
|
16
|
+
or even explicitly specify the package manager:
|
|
17
|
+
```bash
|
|
18
|
+
npx @farbenmeer/bunny@latest init --use yarn my-cool-project
|
|
10
19
|
```
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
it will create a new directory called `my-cool-project` with a basic bunny setup.
|
|
13
22
|
|
|
14
|
-
##
|
|
15
|
-
|
|
16
|
-
* `
|
|
17
|
-
* `
|
|
18
|
-
* `
|
|
19
|
-
* `
|
|
23
|
+
## CLI
|
|
24
|
+
The bunny CLI provides the following commands:
|
|
25
|
+
* `bunny dev` to start the development server
|
|
26
|
+
* `bunny build` to build the project for production
|
|
27
|
+
* `bunny start` to start the production server after building
|
|
28
|
+
* `bunny build --standalone` to build a standalone version with all dependencies bundled
|
|
20
29
|
|
|
21
30
|
## Project Structure
|
|
22
31
|
|
|
23
32
|
The main entry points to the project are
|
|
24
33
|
* `src/index.html` for the client side application. Set up static tags for the favicon and the site title and optionally add some loading UI while the react bundle is being loaded.
|
|
25
|
-
* `src/index.tsx` as the react-entrypoint. This sets up the react application and renders it into the DOM.
|
|
34
|
+
* `src/index.tsx` as the react-entrypoint. This sets up the react application and renders it into the DOM. It imports the `App` component that contains the main frontend logic.
|
|
26
35
|
* `src/main.css` for global styles (mainly tailwindcss-setup)
|
|
27
36
|
* `src/api.ts` for the API entrypoint (using Tapi's `defineApi`). See [Tapi's documentation](https://www.npmjs.com/package/@farbenmeer/tapi) for more information.
|
|
28
|
-
|
|
37
|
+
|
|
38
|
+
## What is bunny?
|
|
39
|
+
Bunny is a minimalistic web framework. The idea is that the frontend is really just a classic react-SPA and the backend is basically just a REST API built on Node.js.
|
|
40
|
+
|
|
41
|
+
There are no directives, no server components or server actions, there is no custom compiler and no filesystem routing.
|
|
42
|
+
|
|
43
|
+
Instead, Bunny uses TApi to create a typed client for the API that is ergonomic to use with modern react. It relies on the Suspense and transition APIs for loading states and Error Boundaries for error handling.
|
|
44
|
+
|
|
45
|
+
## How does it work?
|
|
46
|
+
Bunny bundles the frontend with [Vite](https://vitejs.dev/) and you can directly extend the vite configuration with the `vite` option in `bunny.config.ts`:
|
|
47
|
+
```ts
|
|
48
|
+
import { defineConfig } from '@farbenmeer/bunny';
|
|
49
|
+
|
|
50
|
+
export default defineConfig({
|
|
51
|
+
vite: {
|
|
52
|
+
// Add your custom Vite configuration here
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
For the backend, you define your API routes with [TApi](https://www.npmjs.com/package/@farbenmeer/tapi). Bunny uses [connect](https://www.npmjs.com/package/connect) to chain middleware for the node server. Your backend code is bundled with [esbuild](https://esbuild.github.io/) and bunny implements basic hot reloading for the server-side code.
|
|
58
|
+
|
|
59
|
+
That is all there is to it. It really does nothing more.
|
|
60
|
+
|
|
61
|
+
## Packages
|
|
62
|
+
|
|
63
|
+
If you need additional functionality, the boilerplate (as generated by `bunny init`) includes a directory 'instructions' that has markdown documents with instructions on how to add various common packages. You can also find them [on GitHub](https://github.com/farbenmeer/tapi/tree/main/packages/4-bunny-boilerplate/instructions).
|
|
64
|
+
|
|
65
|
+
## Why the name?
|
|
66
|
+
|
|
67
|
+
Originally, bunny was intended to be built on [bun](https://bun.sh/). Bun makes it easy to run typescript code, it provides a convenient server that has routing and hot reloading built in and it automatically builds server-side _and_ client-side code. That seemed like a great starting point for building a framework on top.
|
|
68
|
+
|
|
69
|
+
While bun has a lot (probably a few too many) of cool features, it also has some rough edges that turned out to be deal-breakers along the way so I decided to go back to node and deal with its slightly dated APIs in exchange for stability instead.
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
If you feel like contributing to the project, you can find the source code on [GitHub](https://github.com/farbenmeer/tapi).
|
|
73
|
+
|
|
74
|
+
Feel free to open [issues](https://github.com/farbenmeer/tapi/issues), submit [pull requests](https://github.com/farbenmeer/tapi/pulls) or open a [discussion](https://github.com/farbenmeer/tapi/discussions).
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
This project is licensed under the MIT License.
|
|
Binary file
|
package/dist/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,eAAO,MAAM,IAAI,SAgFb,CAAC"}
|
package/dist/cli/init.js
CHANGED
|
@@ -10,7 +10,8 @@ export const init = new Command()
|
|
|
10
10
|
.name("init")
|
|
11
11
|
.description("Initialize a new project")
|
|
12
12
|
.argument("[name]", "Name of the project")
|
|
13
|
-
.
|
|
13
|
+
.option("--use <packageManager>", "Package manager to use")
|
|
14
|
+
.action(async (name, options) => {
|
|
14
15
|
console.info("Initializing project...");
|
|
15
16
|
if (name) {
|
|
16
17
|
const dirPath = path.join(process.cwd(), name);
|
|
@@ -45,12 +46,18 @@ export const init = new Command()
|
|
|
45
46
|
stripComponents: 1,
|
|
46
47
|
});
|
|
47
48
|
console.info("Extracted:", await readdir(process.cwd()));
|
|
48
|
-
const pm =
|
|
49
|
+
const pm = (options.use ||
|
|
50
|
+
process.env.npm_config_user_agent?.match(/^(pnpm|yarn|npm|bun)/)?.[1]) ??
|
|
49
51
|
"npm";
|
|
50
52
|
const packageJson = JSON.parse(await readFile(path.join(process.cwd(), "package.json"), "utf8"));
|
|
51
53
|
packageJson.name = path.basename(process.cwd());
|
|
52
54
|
packageJson.version = "0.1.0";
|
|
53
55
|
await writeFile(path.join(process.cwd(), "package.json"), JSON.stringify(packageJson, null, 2));
|
|
56
|
+
let dockerfile = await readFile(path.join(process.cwd(), "Dockerfile"), "utf8");
|
|
57
|
+
dockerfile = dockerfile
|
|
58
|
+
.replace(/\{\{INSTALL_COMMAND\}\}/g, pm === "npm" ? "npm ci" : `${pm} install --frozen-lockfile`)
|
|
59
|
+
.replace(/\{\{BUILD_COMMAND\}\}/g, `${pm} run build --standalone`);
|
|
60
|
+
await writeFile(path.join(process.cwd(), "Dockerfile"), dockerfile);
|
|
54
61
|
const result = await $(`${pm} install`);
|
|
55
62
|
console.log(result.stdout);
|
|
56
63
|
console.error(result.stderr);
|
package/dist/cli/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,S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SACA,OAAO,CAAC,wBAAwB,EAAE,GAAG,EAAE,yBAAyB,CAAC,CAAC;IAErE,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,EAAE,UAAU,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE7B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farbenmeer/bunny",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Michel Smola",
|
|
6
6
|
"email": "michel.smola@farbenmeer.de"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
|
-
"boilerplate"
|
|
19
|
+
"boilerplate.tar.gz"
|
|
20
20
|
],
|
|
21
21
|
"bin": {
|
|
22
22
|
"bunny": "./cli.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"tar": "^7.5.4",
|
|
45
45
|
"vite": "^7.3.0",
|
|
46
46
|
"vite-tsconfig-paths": "^6.0.3",
|
|
47
|
-
"@farbenmeer/tapi": "^0.7.0",
|
|
48
47
|
"@farbenmeer/react-tapi": "^6.0.0",
|
|
49
|
-
"@farbenmeer/router": "^0.6.0"
|
|
48
|
+
"@farbenmeer/router": "^0.6.0",
|
|
49
|
+
"@farbenmeer/tapi": "^0.7.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/connect": "^3.4.38",
|