sleepy-serv 0.20.0 → 0.21.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/README.md CHANGED
@@ -43,12 +43,15 @@ filesystem and generate static imports for every route at load time. This
43
43
  replaces the previous dynamic `import()` and `fs.readdirSync()` approach
44
44
  and enables compatibility with `bun build --compile --bytecode`.
45
45
 
46
- The plugin is loaded automatically by the CLI commands (`sleepy dev` and
47
- `sleepy build`). If you prefer to run your entrypoint directly, preload
46
+ The plugin is loaded automatically by the CLI commands (`sleepy dev`,
47
+ `sleepy prod`, and `sleepy build`). If you prefer to run your entrypoint directly, preload
48
48
  the plugin yourself:
49
49
 
50
50
  ```bash
51
- bun --preload sleepy-serv/plugin src/index.ts
51
+ sleepy init # creates a new project
52
+ sleepy dev # runs the app (watch mode)
53
+ sleepy prod # runs the app (NO watch mode)
54
+ sleepy build # for building a single-file bundle via `bun build` (recommended)
52
55
  ```
53
56
 
54
57
  ### Return Value
@@ -610,6 +613,24 @@ Equivalent to:
610
613
  bun --watch --preload sleepy-serv/plugin src/index.ts
611
614
  ```
612
615
 
616
+ ### `sleepy prod`
617
+
618
+ Starts the production server with the plugin preloaded (no watch mode):
619
+
620
+ ```bash
621
+ sleepy prod
622
+ ```
623
+
624
+ Equivalent to:
625
+
626
+ ```bash
627
+ bun --preload sleepy-serv/plugin src/index.ts
628
+ ```
629
+
630
+ Use this when `bun build --compile` is not an option (e.g. dynamic
631
+ imports, native dependencies like `pg`, or when a single-file
632
+ executable is not desired).
633
+
613
634
  ### `sleepy build`
614
635
 
615
636
  Produces a production build using `Bun.build()` with the plugin:
@@ -0,0 +1,3 @@
1
+ export declare function dev(): Promise<void>;
2
+ export declare function prod(): Promise<void>;
3
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AA4BA,wBAAsB,GAAG,IAAK,OAAO,CAAC,IAAI,CAAC,CAE1C;AAED,wBAAsB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC,CAE3C"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A more opinionated web server for building REST-ful applications",
4
4
  "author": "Travis J True",
5
5
  "license": "MIT",
6
- "version": "0.20.0",
6
+ "version": "0.21.0",
7
7
  "type": "module",
8
8
  "bin": {
9
9
  "sleepy": "./src/cli/index.ts"
package/src/cli/index.ts CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  import { parseArgs } from 'node:util'
4
4
  import { init } from './init'
5
- import { dev } from './dev'
6
5
  import { build } from './build'
6
+ import { dev, prod } from './run'
7
7
 
8
8
  const USAGE = `
9
9
  Usage: sleepy <command>
@@ -11,7 +11,8 @@ Usage: sleepy <command>
11
11
  Commands:
12
12
  init Create a new sleepy-serv project
13
13
  dev Start the dev server (watch mode)
14
- build Build for production
14
+ prod Start the production server
15
+ build Build for production (single-file executable)
15
16
 
16
17
  Options:
17
18
  --help Show this help message
@@ -43,6 +44,10 @@ switch (command) {
43
44
  await dev()
44
45
  break
45
46
 
47
+ case 'prod':
48
+ await prod()
49
+ break
50
+
46
51
  case 'build':
47
52
  await build()
48
53
  break
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs'
2
2
  import { loadConfig } from '../plugin/config'
3
3
 
4
- export async function dev (): Promise<void> {
4
+ async function run (watch: boolean): Promise<void> {
5
5
  const config = await loadConfig()
6
6
  const entrypoint = config.app?.entrypoint ?? './src/index.ts'
7
7
 
@@ -12,10 +12,10 @@ export async function dev (): Promise<void> {
12
12
  }
13
13
 
14
14
  const proc = Bun.spawn([
15
- 'bun', '--watch',
15
+ 'bun', watch ? '--watch' : '',
16
16
  '--preload', 'sleepy-serv/plugin',
17
17
  entrypoint,
18
- ], {
18
+ ].filter(Boolean), {
19
19
  stdout: 'inherit',
20
20
  stderr: 'inherit',
21
21
  stdin: 'inherit',
@@ -25,3 +25,11 @@ export async function dev (): Promise<void> {
25
25
 
26
26
  process.exit(code)
27
27
  }
28
+
29
+ export async function dev (): Promise<void> {
30
+ await run(true)
31
+ }
32
+
33
+ export async function prod (): Promise<void> {
34
+ await run(false)
35
+ }
package/dist/cli/dev.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function dev(): Promise<void>;
2
- //# sourceMappingURL=dev.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAGA,wBAAsB,GAAG,IAAK,OAAO,CAAC,IAAI,CAAC,CAuB1C"}