Skip to content

Commit 5e8711f

Browse files
authored
chore(deps): bump @bomb.sh/router to 0.8.0 and drop routes() (#95)
1 parent 5f22622 commit 5e8711f

9 files changed

Lines changed: 72 additions & 105 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"dependencies": {
1818
"@astrojs/starlight": "^0.37.1",
1919
"@bomb.sh/args": "^0.3.1",
20-
"@bomb.sh/router": "^0.7.1",
20+
"@bomb.sh/router": "^0.8.0",
2121
"@bomb.sh/tty": "^0.8.0",
2222
"@clack/core": "^1.5.1",
2323
"@clack/prompts": "^1.8.1",

‎pnpm-lock.yaml‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/content/docs/router/api/index.mdx‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: API reference
3-
description: Every export of @bomb.sh/router 0.7.1, grouped by what it does
3+
description: Every export of @bomb.sh/router 0.8.0, grouped by what it does
44
---
55

6-
This page lists every export of `@bomb.sh/router` 0.7.1. Signatures leave out generic parameters, because TypeScript infers them from your definitions.
6+
This page lists every export of `@bomb.sh/router` 0.8.0. Signatures leave out generic parameters, because TypeScript infers them from your definitions.
77

88
## Definitions
99

@@ -13,11 +13,7 @@ Declares a route that supports `help` and `execute`. Returns a route. Same as `r
1313

1414
### route(name, ...elements)
1515

16-
Declares a route that supports `help` only. Returns a route.
17-
18-
### routes(...children)
19-
20-
Attaches child routes to the route it is passed to.
16+
Declares a route that supports `help` only. Returns a route. Child routes are passed directly as elements of `route()` and `command()`.
2117

2218
### name(value)
2319

@@ -79,7 +75,7 @@ Attaches environment sources to a route.
7975

8076
### extend(...elements)
8177

82-
Bundles elements into one reusable element:
78+
Bundles elements, including child routes, into one reusable element:
8379

8480
```ts twoslash
8581
import {
@@ -127,7 +123,11 @@ const serve = command(
127123

128124
### checkpoint()
129125

130-
Pauses parsing so the application can load configuration before parsing continues. `parse()` returns a step whose `resume()` takes a `Result` with a list of value sources.
126+
Pauses parsing so the application can load configuration before parsing continues. `parse()` returns a step whose `resume()` takes the list of value sources to load.
127+
128+
### dynamic(schema, extension)
129+
130+
Pauses parsing until the application supplies a value. `resume()` takes that value, `schema` validates it, and `extension` receives the validated value and returns the elements to add, such as options or child routes. An invalid value fails with `unprocessable-content`.
131131

132132
## Running
133133

@@ -193,19 +193,16 @@ import {
193193
command,
194194
name,
195195
option,
196-
routes,
197196
schema,
198197
type ModelOf,
199198
} from "@bomb.sh/router";
200199
import * as z from "zod";
201200

202201
const app = command(
203202
name("simulacrum"),
204-
routes(
205-
command(
206-
name("serve"),
207-
option(name("port"), schema(z.number().default(4000))),
208-
),
203+
command(
204+
name("serve"),
205+
option(name("port"), schema(z.number().default(4000))),
209206
),
210207
);
211208

‎src/content/docs/router/basics/overview.mdx‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
name,
3131
option,
3232
parse,
33-
routes,
3433
schema,
3534
toggle,
3635
} from "@bomb.sh/router";
@@ -39,11 +38,9 @@ import * as z from "zod";
3938
const app = command(
4039
name("simulacrum"),
4140
toggle(name("verbose")),
42-
routes(
43-
command(
44-
name("serve"),
45-
option(name("port"), schema(z.number().default(4000))),
46-
),
41+
command(
42+
name("serve"),
43+
option(name("port"), schema(z.number().default(4000))),
4744
),
4845
);
4946

‎src/content/docs/router/basics/quickstart.mdx‎

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
name,
1919
option,
2020
route,
21-
routes,
2221
schema,
2322
toggle,
2423
version,
@@ -30,19 +29,15 @@ const app = command(
3029
description("Run and manage local service simulators."),
3130
version("1.0.0"),
3231
toggle(name("verbose")),
33-
routes(
32+
command(
33+
name("serve"),
34+
option(name("port"), schema(z.number().default(4000))),
35+
),
36+
route(
37+
name("database"),
3438
command(
35-
name("serve"),
36-
option(name("port"), schema(z.number().default(4000))),
37-
),
38-
route(
39-
name("database"),
40-
routes(
41-
command(
42-
name("clean"),
43-
toggle(name("dryRun")),
44-
),
45-
),
39+
name("clean"),
40+
toggle(name("dryRun")),
4641
),
4742
),
4843
);
@@ -72,7 +67,6 @@ import {
7267
name,
7368
option,
7469
route,
75-
routes,
7670
schema,
7771
toggle,
7872
version,
@@ -84,19 +78,15 @@ const app = command(
8478
description("Run and manage local service simulators."),
8579
version("1.0.0"),
8680
toggle(name("verbose")),
87-
routes(
81+
command(
82+
name("serve"),
83+
option(name("port"), schema(z.number().default(4000))),
84+
),
85+
route(
86+
name("database"),
8887
command(
89-
name("serve"),
90-
option(name("port"), schema(z.number().default(4000))),
91-
),
92-
route(
93-
name("database"),
94-
routes(
95-
command(
96-
name("clean"),
97-
toggle(name("dryRun")),
98-
),
99-
),
88+
name("clean"),
89+
toggle(name("dryRun")),
10090
),
10191
),
10292
);

‎src/content/docs/router/guides/help-version-and-errors.mdx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
printErrors,
2828
printHelp,
2929
printVersion,
30-
routes,
3130
toggle,
3231
version,
3332
} from "@bomb.sh/router";
@@ -37,9 +36,7 @@ const app = command(
3736
description("Run and manage local service simulators."),
3837
version("1.0.0"),
3938
toggle(name("verbose"), description("Print extra logs")),
40-
routes(
41-
command(name("serve"), description("Start the simulator server")),
42-
),
39+
command(name("serve"), description("Start the simulator server")),
4340
);
4441

4542
const result = parse(app, { argv: process.argv.slice(2) });

‎src/content/docs/router/guides/parameters.mdx‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,18 @@ import {
151151
name,
152152
option,
153153
parse,
154-
routes,
155154
schema,
156155
} from "@bomb.sh/router";
157156
import * as z from "zod";
158157

159158
const app = command(
160159
name("simulacrum"),
161-
routes(
162-
command(
163-
name("serve"),
164-
option(
165-
name("port"),
166-
env("PORT"),
167-
schema(z.number().default(4000)),
168-
),
160+
command(
161+
name("serve"),
162+
option(
163+
name("port"),
164+
env("PORT"),
165+
schema(z.number().default(4000)),
169166
),
170167
),
171168
);

‎src/content/docs/router/guides/routes-and-methods.mdx‎

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ A **route** is an address in your CLI, such as `/` or `/database/clean`. A **met
99

1010
## Declare routes
1111

12-
Three functions build the route tree:
12+
Two functions build the route tree:
1313

1414
- `route(name(...), ...)` declares an address that supports help only.
1515
- `command(name(...), ...)` declares an address that supports help and execute.
16-
- `routes(...)` attaches child routes to a parent.
16+
17+
A child route is passed straight to its parent, next to the parent's options and other elements. To reuse a group of routes, bundle them with [`extend()`](/docs/router/api/#extendelements). Before 0.8.0, child routes went inside a `routes()` wrapper, which no longer exists.
1718

1819
`command()` is exactly a `route()` with `executable()` added, so these two definitions are equivalent:
1920

@@ -33,7 +34,6 @@ import {
3334
name,
3435
option,
3536
route,
36-
routes,
3737
schema,
3838
version,
3939
} from "@bomb.sh/router";
@@ -42,31 +42,27 @@ import * as z from "zod";
4242
const app = command(
4343
name("simulacrum"),
4444
version("1.0.0"),
45-
routes(
46-
command(
47-
name("serve"),
48-
option(
49-
name("port"),
50-
schema(z.number().default(4000)),
51-
),
52-
),
53-
route(
54-
name("database"),
55-
routes(
56-
command(
57-
name("clean"),
58-
),
59-
),
60-
),
61-
route(
62-
name("cache"),
63-
executable(),
45+
command(
46+
name("serve"),
47+
option(
48+
name("port"),
49+
schema(z.number().default(4000)),
6450
),
51+
),
52+
route(
53+
name("database"),
6554
command(
66-
name("plugin"),
67-
version("2.3.0"),
55+
name("clean"),
6856
),
6957
),
58+
route(
59+
name("cache"),
60+
executable(),
61+
),
62+
command(
63+
name("plugin"),
64+
version("2.3.0"),
65+
),
7066
);
7167
```
7268

@@ -106,12 +102,11 @@ import {
106102
parse,
107103
printErrors,
108104
route,
109-
routes,
110105
} from "@bomb.sh/router";
111106

112107
const app = command(
113108
name("simulacrum"),
114-
routes(route(name("database"), routes(command(name("clean"))))),
109+
route(name("database"), command(name("clean"))),
115110
);
116111

117112
const result = parse(app, { argv: process.argv.slice(2) });

‎src/content/docs/router/guides/sources.mdx‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@ import {
1818
name,
1919
option,
2020
parse,
21-
routes,
2221
schema,
2322
} from "@bomb.sh/router";
2423
import * as z from "zod";
2524

2625
const app = command(
2726
name("simulacrum"),
28-
routes(
29-
command(
30-
name("serve"),
31-
option(name("port"), schema(z.number().default(4000))),
32-
),
27+
command(
28+
name("serve"),
29+
option(name("port"), schema(z.number().default(4000))),
3330
),
3431
);
3532

@@ -90,20 +87,17 @@ import {
9087
command,
9188
name,
9289
option,
93-
routes,
9490
schema,
9591
withValues,
9692
} from "@bomb.sh/router";
9793
import * as z from "zod";
9894

9995
const app = command(
10096
name("simulacrum"),
101-
routes(
102-
command(
103-
name("serve"),
104-
withValues([{ name: "defaults", value: { port: 4300 } }]),
105-
option(name("port"), schema(z.number().default(4000))),
106-
),
97+
command(
98+
name("serve"),
99+
withValues([{ name: "defaults", value: { port: 4300 } }]),
100+
option(name("port"), schema(z.number().default(4000))),
107101
),
108102
);
109103
```

0 commit comments

Comments
 (0)