@workerstack/clients 1.0.0-rc.28 → 1.0.0-rc.30

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.
Files changed (368) hide show
  1. package/README.md +403 -21
  2. package/assets/installers/examples/github.config.ts +17 -19
  3. package/assets/installers/examples/goreleaser.config.ts +16 -18
  4. package/assets/installers/examples/raw.config.ts +13 -15
  5. package/bin/clients.js +87 -66
  6. package/bin/installgen.js +19 -10
  7. package/dist/cli.d.ts +4 -4
  8. package/dist/cli.js +18 -12
  9. package/dist/emit/cli/channels.d.ts +2 -2
  10. package/dist/emit/cli/channels.js +18 -13
  11. package/dist/emit/cli/commands.d.ts +1 -1
  12. package/dist/emit/cli/commands.js +39 -13
  13. package/dist/emit/cli/discovery.d.ts +0 -6
  14. package/dist/emit/cli/discovery.js +9 -7
  15. package/dist/emit/cli/flags.d.ts +1 -3
  16. package/dist/emit/cli/flags.js +18 -8
  17. package/dist/emit/cli/install.d.ts +0 -8
  18. package/dist/emit/cli/install.js +3 -3
  19. package/dist/emit/cli/layout.d.ts +1 -1
  20. package/dist/emit/cli/layout.js +13 -10
  21. package/dist/emit/cli/module.d.ts +6 -6
  22. package/dist/emit/cli/module.js +10 -10
  23. package/dist/emit/cli/release.d.ts +0 -11
  24. package/dist/emit/cli/release.js +4 -4
  25. package/dist/emit/cli/skills.js +8 -4
  26. package/dist/emit/csharp/errors.js +4 -4
  27. package/dist/emit/csharp/json.js +8 -8
  28. package/dist/emit/csharp/realtime.d.ts +1 -8
  29. package/dist/emit/csharp/realtime.js +26 -26
  30. package/dist/emit/csharp/sdk-answer.d.ts +10 -2
  31. package/dist/emit/csharp/sdk-answer.js +4 -4
  32. package/dist/emit/csharp/sdk-body.js +8 -6
  33. package/dist/emit/csharp/sdk-client.d.ts +3 -3
  34. package/dist/emit/csharp/sdk-client.js +2 -2
  35. package/dist/emit/csharp/sdk-csproj.d.ts +7 -9
  36. package/dist/emit/csharp/sdk-csproj.js +10 -10
  37. package/dist/emit/csharp/sdk-doc.js +1 -1
  38. package/dist/emit/csharp/sdk-method.d.ts +0 -1
  39. package/dist/emit/csharp/sdk-method.js +19 -8
  40. package/dist/emit/csharp/sdk-plan.js +0 -1
  41. package/dist/emit/csharp/sdk.js +3 -3
  42. package/dist/emit/csharp/sse.d.ts +0 -13
  43. package/dist/emit/csharp/sse.js +92 -11
  44. package/dist/emit/csharp/transport.js +9 -9
  45. package/dist/emit/csharp/types-enum.js +3 -1
  46. package/dist/emit/csharp/types-messages.d.ts +47 -0
  47. package/dist/emit/csharp/types-messages.js +172 -0
  48. package/dist/emit/csharp/types-names.js +13 -14
  49. package/dist/emit/csharp/types-record.js +3 -3
  50. package/dist/emit/csharp/types-union.d.ts +1 -1
  51. package/dist/emit/csharp/types.d.ts +0 -1
  52. package/dist/emit/csharp/types.js +3 -3
  53. package/dist/emit/csharp/ws.d.ts +0 -15
  54. package/dist/emit/csharp/ws.js +26 -5
  55. package/dist/emit/go/errors.js +1 -1
  56. package/dist/emit/go/http.js +2 -2
  57. package/dist/emit/go/module-path.js +2 -2
  58. package/dist/emit/go/sdk-answer.d.ts +24 -1
  59. package/dist/emit/go/sdk-answer.js +1 -1
  60. package/dist/emit/go/sdk-body.js +11 -7
  61. package/dist/emit/go/sdk-client.js +1 -1
  62. package/dist/emit/go/sdk-method.d.ts +3 -0
  63. package/dist/emit/go/sdk-method.js +18 -12
  64. package/dist/emit/go/sdk-mirror.js +2 -2
  65. package/dist/emit/go/sdk-opts.d.ts +0 -2
  66. package/dist/emit/go/sdk-opts.js +3 -3
  67. package/dist/emit/go/sdk.d.ts +1 -1
  68. package/dist/emit/go/sdk.js +9 -9
  69. package/dist/emit/go/sse.d.ts +2 -10
  70. package/dist/emit/go/sse.js +88 -13
  71. package/dist/emit/go/types-names.js +5 -0
  72. package/dist/emit/go/types-struct.d.ts +2 -1
  73. package/dist/emit/go/types-struct.js +1 -1
  74. package/dist/emit/go/types-union.d.ts +3 -2
  75. package/dist/emit/go/types-union.js +2 -0
  76. package/dist/emit/go/types.d.ts +6 -0
  77. package/dist/emit/go/types.js +20 -9
  78. package/dist/emit/go/ws.d.ts +4 -11
  79. package/dist/emit/go/ws.js +215 -59
  80. package/dist/emit/java/gradle.d.ts +7 -9
  81. package/dist/emit/java/gradle.js +8 -8
  82. package/dist/emit/java/json.d.ts +3 -0
  83. package/dist/emit/java/json.js +1 -1
  84. package/dist/emit/java/layout-ast.d.ts +4 -1
  85. package/dist/emit/java/layout-ast.js +1 -1
  86. package/dist/emit/java/layout-decl.js +5 -4
  87. package/dist/emit/java/layout-doc.js +13 -7
  88. package/dist/emit/java/layout-dot.js +1 -1
  89. package/dist/emit/java/layout-strings.js +4 -5
  90. package/dist/emit/java/layout-types.js +7 -5
  91. package/dist/emit/java/layout-visitor.js +4 -3
  92. package/dist/emit/java/layout.js +5 -4
  93. package/dist/emit/java/models-names.d.ts +2 -0
  94. package/dist/emit/java/models-names.js +6 -4
  95. package/dist/emit/java/models-record.d.ts +0 -1
  96. package/dist/emit/java/models-record.js +3 -3
  97. package/dist/emit/java/models-union.d.ts +13 -2
  98. package/dist/emit/java/models-union.js +12 -6
  99. package/dist/emit/java/models.d.ts +5 -1
  100. package/dist/emit/java/models.js +44 -20
  101. package/dist/emit/java/realtime.d.ts +34 -26
  102. package/dist/emit/java/realtime.js +45 -10
  103. package/dist/emit/java/sdk-client.d.ts +6 -6
  104. package/dist/emit/java/sdk-client.js +1 -1
  105. package/dist/emit/java/sdk-decl.js +2 -2
  106. package/dist/emit/java/sdk-errors.js +1 -1
  107. package/dist/emit/java/sdk-headers.js +2 -2
  108. package/dist/emit/java/sdk-mirror.js +7 -6
  109. package/dist/emit/java/sdk-models.d.ts +1 -1
  110. package/dist/emit/java/sdk-models.js +7 -7
  111. package/dist/emit/java/sdk-op.d.ts +1 -10
  112. package/dist/emit/java/sdk-op.js +9 -9
  113. package/dist/emit/java/sdk-params.d.ts +5 -5
  114. package/dist/emit/java/sdk-params.js +3 -2
  115. package/dist/emit/java/sdk-plan.js +0 -1
  116. package/dist/emit/java/sdk.d.ts +1 -1
  117. package/dist/emit/java/sdk.js +14 -13
  118. package/dist/emit/java/sse.d.ts +12 -13
  119. package/dist/emit/java/sse.js +105 -6
  120. package/dist/emit/java/ws.d.ts +48 -9
  121. package/dist/emit/java/ws.js +88 -4
  122. package/dist/emit/mcp/annotations.js +8 -4
  123. package/dist/emit/mcp/files.js +9 -9
  124. package/dist/emit/mcp/mounted.js +2 -2
  125. package/dist/emit/mcp/output-schema.d.ts +4 -2
  126. package/dist/emit/mcp/output-schema.js +58 -14
  127. package/dist/emit/mcp/registry.d.ts +0 -2
  128. package/dist/emit/mcp/registry.js +5 -4
  129. package/dist/emit/mcp/runtime.js +2 -2
  130. package/dist/emit/mcp/schema.js +22 -11
  131. package/dist/emit/mcp/server.d.ts +7 -7
  132. package/dist/emit/mcp/server.js +7 -6
  133. package/dist/emit/mcp/tools.js +7 -6
  134. package/dist/emit/python/errors.js +3 -3
  135. package/dist/emit/python/realtime.d.ts +9 -6
  136. package/dist/emit/python/realtime.js +22 -20
  137. package/dist/emit/python/sdk-answer.d.ts +8 -8
  138. package/dist/emit/python/sdk-answer.js +2 -2
  139. package/dist/emit/python/sdk-body.js +4 -5
  140. package/dist/emit/python/sdk-client.js +5 -5
  141. package/dist/emit/python/sdk-doc.js +2 -2
  142. package/dist/emit/python/sdk-method.d.ts +1 -1
  143. package/dist/emit/python/sdk-method.js +38 -11
  144. package/dist/emit/python/sdk-plan.js +0 -1
  145. package/dist/emit/python/sdk-pyproject.d.ts +0 -2
  146. package/dist/emit/python/sdk-pyproject.js +8 -8
  147. package/dist/emit/python/sdk.d.ts +1 -1
  148. package/dist/emit/python/sdk.js +28 -8
  149. package/dist/emit/python/sse.d.ts +0 -7
  150. package/dist/emit/python/sse.js +36 -6
  151. package/dist/emit/python/transport.js +4 -4
  152. package/dist/emit/python/types-dict.d.ts +2 -2
  153. package/dist/emit/python/types-dict.js +1 -1
  154. package/dist/emit/python/types-names.js +2 -2
  155. package/dist/emit/python/types-union.js +1 -1
  156. package/dist/emit/python/types.d.ts +7 -0
  157. package/dist/emit/python/types.js +23 -6
  158. package/dist/emit/python/ws.d.ts +21 -10
  159. package/dist/emit/python/ws.js +69 -3
  160. package/dist/emit/rust/errors.js +3 -3
  161. package/dist/emit/rust/http.js +4 -4
  162. package/dist/emit/rust/realtime.d.ts +7 -5
  163. package/dist/emit/rust/realtime.js +15 -18
  164. package/dist/emit/rust/sdk-body.js +8 -5
  165. package/dist/emit/rust/sdk-cargo.d.ts +16 -18
  166. package/dist/emit/rust/sdk-cargo.js +12 -12
  167. package/dist/emit/rust/sdk-client.d.ts +1 -1
  168. package/dist/emit/rust/sdk-client.js +3 -3
  169. package/dist/emit/rust/sdk-method.js +3 -3
  170. package/dist/emit/rust/sdk-opts.d.ts +2 -1
  171. package/dist/emit/rust/sdk-opts.js +2 -2
  172. package/dist/emit/rust/sdk-plan.js +0 -1
  173. package/dist/emit/rust/sdk.d.ts +1 -1
  174. package/dist/emit/rust/sdk.js +5 -5
  175. package/dist/emit/rust/sse.d.ts +11 -12
  176. package/dist/emit/rust/sse.js +54 -8
  177. package/dist/emit/rust/types-names.js +3 -3
  178. package/dist/emit/rust/types-struct.js +1 -1
  179. package/dist/emit/rust/types-union.d.ts +10 -2
  180. package/dist/emit/rust/types-union.js +4 -0
  181. package/dist/emit/rust/types.d.ts +9 -0
  182. package/dist/emit/rust/types.js +20 -12
  183. package/dist/emit/rust/ws.d.ts +22 -15
  184. package/dist/emit/rust/ws.js +60 -10
  185. package/dist/emit/shared/escape.js +17 -17
  186. package/dist/emit/shared/format.js +1 -1
  187. package/dist/emit/shared/gofmt.js +1 -1
  188. package/dist/emit/shared/lang.js +10 -10
  189. package/dist/emit/shared/literals.d.ts +5 -0
  190. package/dist/emit/shared/literals.js +8 -0
  191. package/dist/emit/shared/metadata.d.ts +0 -6
  192. package/dist/emit/shared/metadata.js +8 -7
  193. package/dist/emit/shared/ruff.js +1 -1
  194. package/dist/emit/shared/rustfmt.js +1 -1
  195. package/dist/emit/shared/type-emitter.js +37 -20
  196. package/dist/emit/shared/unknown-type.constants.d.ts +2 -0
  197. package/dist/emit/shared/unknown-type.constants.js +2 -0
  198. package/dist/emit/ts/http.d.ts +0 -2
  199. package/dist/emit/ts/http.js +4 -4
  200. package/dist/emit/ts/package.d.ts +14 -12
  201. package/dist/emit/ts/package.js +9 -8
  202. package/dist/emit/ts/route-tree.js +2 -2
  203. package/dist/emit/ts/sdk-types-preamble.d.ts +1 -1
  204. package/dist/emit/ts/sdk-types-preamble.js +6 -2
  205. package/dist/emit/ts/sdk-types.js +59 -20
  206. package/dist/emit/ts/sdk.js +6 -6
  207. package/dist/emit/ts/service-map.d.ts +10 -3
  208. package/dist/emit/ts/service-map.js +30 -2
  209. package/dist/emit/ts/tanstack-query.js +6 -6
  210. package/dist/emit/ts/type-gen.js +36 -21
  211. package/dist/emit/ts/webhooks.d.ts +0 -2
  212. package/dist/emit/ts/webhooks.js +3 -3
  213. package/dist/extract/chain.js +5 -4
  214. package/dist/extract/extract.js +5 -5
  215. package/dist/extract/serialize.d.ts +0 -2
  216. package/dist/extract/serialize.js +14 -15
  217. package/dist/extract/walk.js +15 -12
  218. package/dist/gen/args.js +9 -5
  219. package/dist/gen/formatters.js +5 -3
  220. package/dist/gen/shipped.js +2 -2
  221. package/dist/gen/targets.d.ts +2 -4
  222. package/dist/gen/targets.js +8 -4
  223. package/dist/gen/write.js +4 -2
  224. package/dist/index.js +2 -2
  225. package/dist/installers/cli.d.ts +4 -4
  226. package/dist/installers/cli.js +24 -24
  227. package/dist/installers/commands/build.d.ts +4 -4
  228. package/dist/installers/commands/build.js +2 -3
  229. package/dist/installers/commands/check.d.ts +2 -2
  230. package/dist/installers/commands/check.js +11 -10
  231. package/dist/installers/commands/init.d.ts +2 -2
  232. package/dist/installers/commands/init.js +1 -2
  233. package/dist/installers/config/define-config.d.ts +16 -16
  234. package/dist/installers/config/define-config.js +1 -1
  235. package/dist/installers/config/hooks/bun.d.ts +6 -6
  236. package/dist/installers/config/hooks/node.js +1 -1
  237. package/dist/installers/config/load.d.ts +6 -8
  238. package/dist/installers/config/load.js +7 -8
  239. package/dist/installers/config/resolve.d.ts +1 -2
  240. package/dist/installers/config/resolve.js +28 -33
  241. package/dist/installers/config/types.d.ts +6 -6
  242. package/dist/installers/config/types.js +0 -1
  243. package/dist/installers/render/quote.js +3 -5
  244. package/dist/installers/render/render.d.ts +6 -6
  245. package/dist/installers/render/render.js +26 -26
  246. package/dist/installers/ui.d.ts +4 -4
  247. package/dist/installers/ui.js +3 -3
  248. package/dist/ir/build.d.ts +3 -3
  249. package/dist/ir/build.js +12 -5
  250. package/dist/ir/load.js +9 -10
  251. package/dist/ir/model.d.ts +16 -1
  252. package/dist/ir/model.js +0 -1
  253. package/dist/ir/resolve-refs.js +2 -2
  254. package/dist/ir/resource-tree.js +2 -1
  255. package/dist/ir/route-tree-intern.js +1 -1
  256. package/dist/ir/schema.js +3 -3
  257. package/dist/ir/sdk-model.d.ts +25 -1
  258. package/dist/ir/sdk-model.js +38 -8
  259. package/dist/ir/slots.d.ts +1 -1
  260. package/dist/ir/slots.js +22 -11
  261. package/dist/ir/streams.d.ts +16 -0
  262. package/dist/ir/streams.js +40 -0
  263. package/dist/release/bootstrap.d.ts +3 -3
  264. package/dist/release/bootstrap.js +7 -7
  265. package/dist/release/bump-args.js +4 -4
  266. package/dist/release/bump-command.d.ts +1 -1
  267. package/dist/release/bump-command.js +9 -10
  268. package/dist/release/bump.d.ts +5 -4
  269. package/dist/release/bump.js +2 -2
  270. package/dist/release/cli.d.ts +4 -4
  271. package/dist/release/cli.js +4 -4
  272. package/dist/release/codegen.js +1 -1
  273. package/dist/release/digest.js +5 -7
  274. package/dist/release/git.js +5 -8
  275. package/dist/release/load.js +3 -3
  276. package/dist/release/manifest.js +9 -10
  277. package/dist/release/oasdiff.d.ts +10 -15
  278. package/dist/release/oasdiff.js +5 -6
  279. package/dist/release/registries.d.ts +0 -11
  280. package/dist/release/registries.js +17 -17
  281. package/dist/release/release-state.d.ts +16 -13
  282. package/dist/release/release-workflow.js +5 -7
  283. package/dist/release/repo-settings.d.ts +2 -1
  284. package/dist/release/spec-gate.d.ts +0 -2
  285. package/dist/release/spec-gate.js +6 -10
  286. package/dist/release/sync-command.d.ts +2 -2
  287. package/dist/release/sync-command.js +1 -1
  288. package/dist/release/sync-tree.js +9 -13
  289. package/dist/release/sync.d.ts +6 -6
  290. package/dist/release/sync.js +12 -13
  291. package/dist/release/types.d.ts +22 -22
  292. package/dist/release/types.js +0 -1
  293. package/dist/release/version-files.d.ts +3 -4
  294. package/dist/release/version-files.js +4 -5
  295. package/dist/runtime/.oxfmtrc.jsonc +8 -0
  296. package/dist/runtime/cli/socket.go +107 -13
  297. package/dist/runtime/cli/stream.go +18 -11
  298. package/dist/runtime/csharp/Adapters.cs +12 -11
  299. package/dist/runtime/csharp/Events.cs +22 -17
  300. package/dist/runtime/csharp/Realtime.cs +50 -23
  301. package/dist/runtime/csharp/RealtimeLoop.cs +1 -1
  302. package/dist/runtime/csharp/TransportSse.cs +3 -3
  303. package/dist/runtime/csharp/Ws.cs +1 -1
  304. package/dist/runtime/csharp/WsDial.cs +19 -1
  305. package/dist/runtime/csharp/WsTyped.cs +109 -0
  306. package/dist/runtime/go/realtime.go +125 -41
  307. package/dist/runtime/go/realtime_loop.go +21 -18
  308. package/dist/runtime/go/result.go +2 -1
  309. package/dist/runtime/go/sse.go +11 -0
  310. package/dist/runtime/go/stream.go +29 -13
  311. package/dist/runtime/go/transport.go +15 -21
  312. package/dist/runtime/go/transport_longpoll.go +3 -4
  313. package/dist/runtime/go/transport_sse.go +6 -6
  314. package/dist/runtime/go/ws.go +157 -61
  315. package/dist/runtime/java/EventStream.java +47 -29
  316. package/dist/runtime/java/Exchange.java +5 -5
  317. package/dist/runtime/java/Flight.java +3 -3
  318. package/dist/runtime/java/Realtime.java +45 -11
  319. package/dist/runtime/java/ResumableConnection.java +77 -32
  320. package/dist/runtime/java/Socket.java +8 -4
  321. package/dist/runtime/java/SseAdapter.java +1 -1
  322. package/dist/runtime/java/TypedWebSocket.java +81 -24
  323. package/dist/runtime/java/WsAdapter.java +4 -2
  324. package/dist/runtime/java/WsDial.java +12 -5
  325. package/dist/runtime/mcp/files.ts +1 -1
  326. package/dist/runtime/mcp/http.ts +6 -2
  327. package/dist/runtime/mcp/listen.ts +1 -1
  328. package/dist/runtime/mcp/mount.ts +2 -2
  329. package/dist/runtime/mcp/protocol.ts +1 -1
  330. package/dist/runtime/python/events.py +25 -11
  331. package/dist/runtime/python/operation.py +6 -1
  332. package/dist/runtime/python/realtime.py +47 -33
  333. package/dist/runtime/python/send_async.py +1 -0
  334. package/dist/runtime/python/transport_sse.py +2 -2
  335. package/dist/runtime/python/transport_ws.py +1 -1
  336. package/dist/runtime/python/ws.py +100 -39
  337. package/dist/runtime/rust/events.rs +64 -41
  338. package/dist/runtime/rust/realtime.rs +80 -34
  339. package/dist/runtime/rust/realtime_loop.rs +37 -12
  340. package/dist/runtime/rust/sse.rs +3 -2
  341. package/dist/runtime/rust/transport_sse.rs +1 -1
  342. package/dist/runtime/rust/transport_ws.rs +3 -2
  343. package/dist/runtime/rust/ws.rs +122 -50
  344. package/dist/runtime/ts/realtime-connection.ts +22 -0
  345. package/dist/runtime/ts/realtime-transports.ts +13 -4
  346. package/dist/runtime/ts/realtime.ts +27 -3
  347. package/dist/runtime/ts/sdk-realtime.ts +1 -1
  348. package/dist/runtime/ts/sdk-sse.ts +31 -14
  349. package/dist/runtime/ts/sdk-ws.ts +2 -1
  350. package/dist/runtime/ts/sdk.ts +9 -2
  351. package/dist/runtime/ts/sse.ts +8 -0
  352. package/dist/runtime/ts/ws.ts +88 -50
  353. package/dist/runtime/ts-tanstack-query/query.ts +0 -2
  354. package/package.json +12 -40
  355. package/dist/emit/cli/index.d.ts +0 -1
  356. package/dist/emit/cli/index.js +0 -1
  357. package/dist/emit/csharp/index.d.ts +0 -1
  358. package/dist/emit/csharp/index.js +0 -1
  359. package/dist/emit/go/index.d.ts +0 -1
  360. package/dist/emit/go/index.js +0 -1
  361. package/dist/emit/java/index.d.ts +0 -2
  362. package/dist/emit/java/index.js +0 -2
  363. package/dist/emit/mcp/index.d.ts +0 -3
  364. package/dist/emit/mcp/index.js +0 -3
  365. package/dist/emit/python/index.d.ts +0 -1
  366. package/dist/emit/python/index.js +0 -1
  367. package/dist/emit/rust/index.d.ts +0 -1
  368. package/dist/emit/rust/index.js +0 -1
@@ -1,7 +1,7 @@
1
- import { quoteKey } from "../emit/shared/literals.js";
1
+ import { optionalType, quoteKey } from "../emit/shared/literals.js";
2
2
  import { arrayOf, intersectionOf, unionOf } from "../emit/shared/type-emitter.js";
3
3
  /** Lib types every program has in scope: written by name, never imported. */
4
- export function isLibFile(fileName) {
4
+ function isLibFile(fileName) {
5
5
  return /(?:^|[\\/])lib\.[\w.-]*\.d\.ts$/.test(fileName) || /[\\/]typescript[\\/]lib[\\/]/.test(fileName);
6
6
  }
7
7
  /** Whether a declaring module exports `sym` (a declaration file's types are always reachable). */
@@ -15,7 +15,7 @@ function isExported(sym, file, checker) {
15
15
  function isScript(file) {
16
16
  return file.externalModuleIndicator === undefined;
17
17
  }
18
- /* checked in order: `boolean` is a union of its literals, so it is named before unions are split */
18
+ // checked in order: `boolean` is a union of its literals, so it is named before unions are split
19
19
  const KEYWORDS = [
20
20
  ["String", "string"],
21
21
  ["Number", "number"],
@@ -30,7 +30,7 @@ const KEYWORDS = [
30
30
  ["Unknown", "unknown"],
31
31
  ["Any", "unknown"],
32
32
  ["NonPrimitive", "object"],
33
- /* deferred generic forms (`T extends U ? X : Y`, `T[K]`, `keyof T`) are written as their bound */
33
+ // deferred generic forms (`T extends U ? X : Y`, `T[K]`, `keyof T`) are written as their bound
34
34
  ["StringMapping", "string"],
35
35
  ["Conditional", "unknown"],
36
36
  ["Substitution", "unknown"],
@@ -41,7 +41,7 @@ export class Serializer {
41
41
  checker;
42
42
  compiler;
43
43
  #active = new Set();
44
- /* type parameters of the signatures being written: inside them a parameter keeps its name */
44
+ // type parameters of the signatures being written: inside them a parameter keeps its name
45
45
  #bound = new Set();
46
46
  constructor(checker, compiler) {
47
47
  this.checker = checker;
@@ -57,9 +57,8 @@ export class Serializer {
57
57
  while (sym !== undefined && sym.flags & compiler.SymbolFlags.Alias)
58
58
  sym = checker.getAliasedSymbol(sym);
59
59
  const file = sym?.declarations?.[0]?.getSourceFile();
60
- if (sym === undefined || file === undefined || isLibFile(file.fileName) || !isExported(sym, file, checker)) {
60
+ if (sym === undefined || file === undefined || isLibFile(file.fileName) || !isExported(sym, file, checker))
61
61
  return undefined;
62
- }
63
62
  const args = (typeRef.typeArguments ?? []).map((a) => this.text(checker.getTypeFromTypeNode(a)));
64
63
  return `import("${file.fileName}").${sym.getName()}${args.length > 0 ? `<${args.join(", ")}>` : ""}`;
65
64
  }
@@ -79,7 +78,7 @@ export class Serializer {
79
78
  const globalName = this.#globalName(sym, decl);
80
79
  if (globalName !== null)
81
80
  return this.#withArgs(globalName, type, decl);
82
- /* an ambient module's member has no import() path here, and import() of an unexported type is `any` */
81
+ // an ambient module's member has no import() path here, and import() of an unexported type is `any`
83
82
  if (isScript(file) || !isExported(sym, file, this.checker))
84
83
  return null;
85
84
  return this.#withArgs(`import("${file.fileName}").${sym.getName()}`, type, decl);
@@ -108,7 +107,7 @@ export class Serializer {
108
107
  if (compiler.isSourceFile(n))
109
108
  global = isScript(n);
110
109
  }
111
- /* a `declare global` member is qualified as `global.Name`; in scope it is `Name` */
110
+ // a `declare global` member is qualified as `global.Name`; in scope it is `Name`
112
111
  const name = this.checker.getFullyQualifiedName(sym).replace(/^global\./, "");
113
112
  return global && /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(name) ? name : null;
114
113
  }
@@ -126,7 +125,7 @@ export class Serializer {
126
125
  }
127
126
  #serialize(type) {
128
127
  const { compiler } = this;
129
- /* an enum is nominal: its name when it can be referenced */
128
+ // an enum is nominal: its name when it can be referenced
130
129
  const enumRef = (type.getSymbol()?.flags ?? 0) & compiler.SymbolFlags.Enum ? this.asRef(type) : null;
131
130
  return (enumRef ??
132
131
  this.#keyword(type) ??
@@ -157,7 +156,7 @@ export class Serializer {
157
156
  /** A template literal type as written: its text escaped where a template would read it, each hole serialized. */
158
157
  #template(type) {
159
158
  const holes = type.types.map((hole) => `\${${this.serialize(hole)}}`);
160
- const texts = type.texts.map((text) => text.replace(/[`\\]|\$(?=\{)/g, (c) => `\\${c}`));
159
+ const texts = type.texts.map((text) => text.replaceAll(/[`\\]|\$(?=\{)/g, (c) => `\\${c}`));
161
160
  return `\`${texts.map((text, i) => text + (holes[i] ?? "")).join("")}\``;
162
161
  }
163
162
  /** By name inside the signature that declares it, else its constraint, else unknown. */
@@ -218,20 +217,20 @@ export class Serializer {
218
217
  const { checker, compiler } = this;
219
218
  const index = type.getStringIndexType();
220
219
  const props = type.getProperties().filter((p) => isPublicName(p.getName()));
221
- if (index !== undefined && props.length === 0 && type.getCallSignatures().length === 0) {
220
+ if (index !== undefined && props.length === 0 && type.getCallSignatures().length === 0)
222
221
  return `Record<string, ${this.serialize(index)}>`;
223
- }
224
222
  const M = compiler.ModifierFlags;
225
223
  const entries = [];
226
224
  for (const p of props) {
227
- /* a mapped type's prop has no declaration */
225
+ // a mapped type's prop has no declaration
228
226
  const decls = p.getDeclarations() ?? [];
229
227
  if (decls.some((d) => compiler.getCombinedModifierFlags(d) & (M.Private | M.Protected)))
230
228
  continue;
231
229
  const readonly = decls.some((d) => compiler.getCombinedModifierFlags(d) & M.Readonly);
232
230
  const optional = (p.flags & compiler.SymbolFlags.Optional) !== 0;
233
231
  const member = checker.getTypeOfSymbol(p);
234
- const value = optional ? this.optional(member) : this.serialize(member);
232
+ // `| undefined` said out loud: under exactOptionalPropertyTypes a bare `k?: T` refuses the undefined zod infers
233
+ const value = optional ? optionalType(this.optional(member)) : this.serialize(member);
235
234
  entries.push(`${readonly ? "readonly " : ""}${quoteKey(p.getName())}${optional ? "?" : ""}: ${value}`);
236
235
  }
237
236
  if (index !== undefined)
@@ -8,9 +8,9 @@
8
8
  import { existsSync } from "node:fs";
9
9
  import { dirname, resolve } from "node:path";
10
10
  import { compareCodeUnits } from "../emit/shared/lang.js";
11
- /* the type-only members every route builder carries */
11
+ // the type-only members every route builder carries
12
12
  const BUILDER_MEMBERS = ["$ctx", "$method", "$path"];
13
- /* the type-only members every app carries */
13
+ // the type-only members every app carries
14
14
  const APP_MEMBERS = ["$ctx", "$env"];
15
15
  /**
16
16
  * The tsconfig that governs `fromPath`: the nearest one walking up, but never past the project root
@@ -32,7 +32,10 @@ export function findTsConfig(fromPath) {
32
32
  */
33
33
  export function loadEntry(tsMorph, options) {
34
34
  const tsConfigFilePath = options.tsconfigPath ?? findTsConfig(options.entryPath);
35
- const project = new tsMorph.Project({ skipAddingFilesFromTsConfig: true, tsConfigFilePath });
35
+ const project = new tsMorph.Project({
36
+ skipAddingFilesFromTsConfig: true,
37
+ ...(tsConfigFilePath === undefined ? {} : { tsConfigFilePath }),
38
+ });
36
39
  project.addSourceFilesAtPaths(options.entryPath);
37
40
  if (tsConfigFilePath !== undefined) {
38
41
  const { ts } = tsMorph;
@@ -48,7 +51,7 @@ export function loadEntry(tsMorph, options) {
48
51
  if (decl === undefined)
49
52
  throw new Error(`Export "${options.exportName}" not found in ${options.entryPath}`);
50
53
  const checker = project.getTypeChecker().compilerObject;
51
- /* for `export default <expr>` the declaration is the expression itself */
54
+ // for `export default <expr>` the declaration is the expression itself
52
55
  return {
53
56
  appNode: decl.compilerNode,
54
57
  appType: checker.getTypeAtLocation(decl.compilerNode),
@@ -116,7 +119,7 @@ function appOrigins(entry) {
116
119
  const known = memo.get(expr);
117
120
  if (known !== undefined)
118
121
  return known;
119
- /* a binding that reads itself ends at the expression */
122
+ // a binding that reads itself ends at the expression
120
123
  memo.set(expr, expr);
121
124
  const found = step(expr);
122
125
  memo.set(expr, found);
@@ -127,7 +130,7 @@ function appOrigins(entry) {
127
130
  /** The receiver's base path: its `HttpApp` type argument `TBasePath`, when that is one literal. */
128
131
  function basePathOf(entry, app) {
129
132
  const { checker, compiler } = entry;
130
- /* a class's instance type is a reference to it: its type arguments are the app's */
133
+ // a class's instance type is a reference to it: its type arguments are the app's
131
134
  const decl = app.getSymbol()?.declarations?.find((d) => compiler.isClassDeclaration(d));
132
135
  const index = decl?.typeParameters?.findIndex((p) => p.name.text === "TBasePath") ?? -1;
133
136
  const arg = index < 0 ? undefined : checker.getTypeArguments(app)[index];
@@ -143,8 +146,8 @@ function mountOf(entry, call, origin, report) {
143
146
  const sub = call.arguments.at(-1);
144
147
  if (sub === undefined || call.arguments.length > 2 || APP_MEMBERS.some((m) => app.getProperty(m) === undefined))
145
148
  return null;
146
- /* core mounts nothing when the sub is the receiver's own app (`register.ts` `mount`): the groups that share one
147
- app keep their own ids */
149
+ // core mounts nothing when the sub is the receiver's own app (`register.ts` `mount`): the groups that share one
150
+ // app keep their own ids
148
151
  const [into, from] = [origin(receiver), origin(sub)];
149
152
  if (into === from)
150
153
  return null;
@@ -193,13 +196,13 @@ function registrationOf(entry, call) {
193
196
  if (phantoms.includes(undefined))
194
197
  return null;
195
198
  const [ctx, method, path] = phantoms;
196
- /* the handler callback's ctx parameter carries `input`, which the builder's `$ctx` phantom leaves out */
199
+ // the handler callback's ctx parameter carries `input`, which the builder's `$ctx` phantom leaves out
197
200
  const handler = checker.getResolvedSignature(call)?.parameters[0];
198
201
  const param = handler && checker.getTypeOfSymbol(handler).getCallSignatures()[0]?.parameters[0];
199
202
  const input = param && checker.getTypeOfSymbol(param).getProperty("input");
200
203
  const params = param && checker.getTypeOfSymbol(param).getProperty("params");
201
204
  const paramsType = params && checker.getTypeOfSymbol(params);
202
- /* a param schema shows as a key that is not a string: only then does the path's own typing fall short */
205
+ // a param schema shows as a key that is not a string: only then does the path's own typing fall short
203
206
  const typed = paramsType
204
207
  ?.getProperties()
205
208
  .some((key) => !(checker.getTypeOfSymbol(key).flags & compiler.TypeFlags.String));
@@ -209,7 +212,7 @@ function registrationOf(entry, call) {
209
212
  ctx: ctx,
210
213
  input: input ? checker.getTypeOfSymbol(input) : null,
211
214
  params: typed === true ? paramsType : null,
212
- /* `.on()`'s methods are literals by its signature; a path is one only as a single literal */
215
+ // `.on()`'s methods are literals by its signature; a path is one only as a single literal
213
216
  methods: literals(method),
214
217
  path: literalOf(path),
215
218
  };
@@ -241,7 +244,7 @@ export function registrations(entry, report) {
241
244
  .sort((a, b) => compareCodeUnits(a.fileName, b.fileName));
242
245
  for (const file of files)
243
246
  visit(file);
244
- /* the export resolves as any binding of it does: through its name, or as the default export's expression */
247
+ // the export resolves as any binding of it does: through its name, or as the default export's expression
245
248
  const prefixes = servedPrefixes(mounts, origin(compiler.isVariableDeclaration(appNode) ? appNode.name : appNode));
246
249
  return found.map(({ builder, path, ...registration }) => ({
247
250
  ...registration,
package/dist/gen/args.js CHANGED
@@ -44,7 +44,7 @@ Nothing outside <out>/<target> is written or deleted, and no symlink is followed
44
44
  export class UsageError extends Error {
45
45
  }
46
46
  function kebab(key) {
47
- return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
47
+ return key.replaceAll(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
48
48
  }
49
49
  /** The `--<target>-<option>` flag `flag` names: its target and its option's name; none for another flag. */
50
50
  function optionFlag(flag) {
@@ -72,14 +72,18 @@ function booleanOf(flag, inline) {
72
72
  /** One flag of `generate` into `into`. */
73
73
  function takeFlag(arg, rest, into) {
74
74
  const [flag, inline] = arg.slice(2).split(/=(.*)/s, 2);
75
- if (flag === "spec")
75
+ if (flag === "spec") {
76
76
  into.spec = valueOf(flag, inline, rest);
77
- else if (flag === "app")
77
+ }
78
+ else if (flag === "app") {
78
79
  into.app = valueOf(flag, inline, rest);
79
- else if (flag === "out")
80
+ }
81
+ else if (flag === "out") {
80
82
  into.out = valueOf(flag, inline, rest);
81
- else if (flag === "watch")
83
+ }
84
+ else if (flag === "watch") {
82
85
  into.watch = booleanOf(flag, inline);
86
+ }
83
87
  else if (flag === "target") {
84
88
  const target = valueOf(flag, inline, rest);
85
89
  if (!TARGETS.includes(target))
@@ -121,10 +121,12 @@ export async function formatterFor(target, where) {
121
121
  const rustfmt = findRustfmt(env);
122
122
  return rustfmt === undefined ? undefined : rustfmtFormatter(rustfmt);
123
123
  }
124
- case "ts":
124
+ case "ts": {
125
125
  return await loadOxfmt(oxfmt);
126
- default:
126
+ }
127
+ default: {
127
128
  return undefined;
129
+ }
128
130
  }
129
131
  }
130
132
  /**
@@ -138,7 +140,7 @@ export async function formatterFor(target, where) {
138
140
  */
139
141
  export function missingFormatter(target, pass, env, report) {
140
142
  const said = `${pass.tool} was not found, so the ${target} output is not formatted (${pass.install})`;
141
- /* an explicit demand is honoured for every target, quiet or not: the caller asked to be stopped */
143
+ // an explicit demand is honoured for every target, quiet or not: the caller asked to be stopped
142
144
  if (env.CLIENTS_REQUIRE_FORMATTERS === "1")
143
145
  throw new Error(said);
144
146
  if (pass.quiet !== true)
@@ -8,9 +8,9 @@
8
8
  import { iconName, LICENSE, README } from "../emit/shared/metadata.js";
9
9
  // per-process-constant: text-codec
10
10
  const UTF8 = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: true });
11
- /* NuGet's cap on a package icon */
11
+ // NuGet's cap on a package icon
12
12
  const ICON_BYTES = 1024 * 1024;
13
- /* the signature each image format opens with, by the extensions that name it */
13
+ // the signature each image format opens with, by the extensions that name it
14
14
  const PNG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
15
15
  const JPEG = [0xff, 0xd8, 0xff];
16
16
  /** The bytes of the file `metadata[field]` names, or a refusal naming the field. */
@@ -45,14 +45,14 @@ export type TargetOptions<T extends Target> = {
45
45
  /** Any target's options by name, as the CLI parses and each generator reads them. */
46
46
  export type Options = Readonly<Record<string, string>>;
47
47
  /** One problem a schema found: what is wrong, and the option it is about. */
48
- export type OptionsIssue = {
48
+ type OptionsIssue = {
49
49
  /** What is wrong, naming the target and the option. */
50
50
  readonly message: string;
51
51
  /** The option's name, as the only segment; absent when the value is not an object at all. */
52
52
  readonly path?: readonly PropertyKey[];
53
53
  };
54
54
  /** What `validate` answers: the options it accepted, or every issue it found. */
55
- export type OptionsResult<T extends Target> = {
55
+ type OptionsResult<T extends Target> = {
56
56
  /** The options, as given. */
57
57
  readonly value: TargetOptions<T>;
58
58
  /** Absent: no issue was found. */
@@ -86,8 +86,6 @@ export declare function isBooleanOption(target: Target, key: string): boolean;
86
86
  export declare const targetOptionSchemas: {
87
87
  readonly [T in Target]: TargetOptionsSchema<T>;
88
88
  };
89
- /** `value` as `target`'s options, or an error naming every problem its schema found. */
90
- export declare function checkedOptions(target: Target, value: unknown): Options;
91
89
  /** `target`'s options: those `metadata` fills, under the ones the run gives the target itself, checked. */
92
90
  export declare function optionsFor(target: Target, metadata: Metadata, options: unknown): Options;
93
91
  export {};
@@ -81,7 +81,10 @@ export const TARGET_OPTIONS = {
81
81
  * the repo's README test (`tests/docs/readmes.test.ts`) reads to hold every flag to its README row; this table only
82
82
  * says how one is read. Bare is `true` and an inline `true`/`false` is read, exactly as `--watch` is.
83
83
  */
84
- const BOOLEAN_OPTIONS = { cli: ["aur"], ts: ["tanstackQuery"] };
84
+ const BOOLEAN_OPTIONS = {
85
+ cli: ["aur"],
86
+ ts: ["tanstackQuery"],
87
+ };
85
88
  /** Whether `target`'s option `key` takes no value. */
86
89
  export function isBooleanOption(target, key) {
87
90
  const keys = BOOLEAN_OPTIONS[target] ?? [];
@@ -92,10 +95,11 @@ function issueOf(target, key, value) {
92
95
  const keys = TARGET_OPTIONS[target];
93
96
  if (!keys.includes(key))
94
97
  return { message: `unknown ${target} option ${JSON.stringify(key)}: want one of ${keys.join(", ")}`, path: [key] };
95
- if (isBooleanOption(target, key))
98
+ if (isBooleanOption(target, key)) {
96
99
  return value === "true" || value === "false"
97
100
  ? undefined
98
101
  : { message: `${target} option ${key}: want "true" or "false"`, path: [key] };
102
+ }
99
103
  return typeof value === "string" && value !== ""
100
104
  ? undefined
101
105
  : { message: `${target} option ${key}: want a non-empty string`, path: [key] };
@@ -106,7 +110,7 @@ function schemaOf(target) {
106
110
  validate(value) {
107
111
  if (typeof value !== "object" || value === null || Array.isArray(value))
108
112
  return { issues: [{ message: `${target} options: want an object of option names to strings` }] };
109
- /* an option given as undefined is not given: a caller's optional field, never a value */
113
+ // an option given as undefined is not given: a caller's optional field, never a value
110
114
  const given = Object.entries(value).filter(([, option]) => option !== undefined);
111
115
  const issues = given.flatMap(([key, option]) => issueOf(target, key, option) ?? []);
112
116
  return issues.length > 0 ? { issues } : { value: Object.fromEntries(given) };
@@ -122,7 +126,7 @@ function schemasOf() {
122
126
  return Object.fromEntries(TARGETS.map((target) => [target, schemaOf(target)]));
123
127
  }
124
128
  /** `value` as `target`'s options, or an error naming every problem its schema found. */
125
- export function checkedOptions(target, value) {
129
+ function checkedOptions(target, value) {
126
130
  const result = targetOptionSchemas[target]["~standard"].validate(value);
127
131
  if (result.issues !== undefined)
128
132
  throw new Error(result.issues.map((issue) => issue.message).join("; "));
package/dist/gen/write.js CHANGED
@@ -61,7 +61,9 @@ export function writeFileIfChanged(path, content) {
61
61
  function listed(dir) {
62
62
  try {
63
63
  const files = JSON.parse(readFileSync(join(dir, MANIFEST), "utf8")).files;
64
- return typeof files === "object" && files !== null && !Array.isArray(files) ? files : {};
64
+ return typeof files === "object" && files !== null && !Array.isArray(files)
65
+ ? files
66
+ : {};
65
67
  }
66
68
  catch {
67
69
  return {};
@@ -98,7 +100,7 @@ export function writeTarget(dir, files, packages) {
98
100
  kept.push(rel);
99
101
  continue;
100
102
  }
101
- /* a deleted file or directory is already gone (R7) */
103
+ // a deleted file or directory is already gone (R7)
102
104
  if (!existsSync(path))
103
105
  continue;
104
106
  if (!lstatSync(path).isFile() || sha256(readFileSync(path)) !== hash) {
package/dist/index.js CHANGED
@@ -10,6 +10,6 @@ export { generateRouteTree } from "./emit/ts/route-tree.js";
10
10
  export { generateTypes } from "./emit/ts/type-gen.js";
11
11
  export { generated, writeGenerated, } from "./cli.js";
12
12
  export { TARGETS, targetOptionSchemas, } from "./gen/targets.js";
13
- /* `writeTarget` writes one target's files into a directory the caller picks, keeping `MANIFEST` there: for a caller
14
- that lays out `generated`'s files itself rather than as `writeGenerated`'s `<out>/<target>` */
13
+ // `writeTarget` writes one target's files into a directory the caller picks, keeping `MANIFEST` there: for a caller
14
+ // that lays out `generated`'s files itself rather than as `writeGenerated`'s `<out>/<target>`
15
15
  export { MANIFEST, writeFileIfChanged, writeTarget } from "./gen/write.js";
@@ -1,14 +1,14 @@
1
1
  import { type RuntimeInfo } from "./config/load.ts";
2
2
  import { type UiIo } from "./ui.ts";
3
- export interface Io extends UiIo {
3
+ export type Io = UiIo & {
4
4
  cwd: string;
5
5
  runtime?: RuntimeInfo;
6
6
  fetch?: typeof fetch;
7
- }
7
+ };
8
8
  /** The whole CLI, in-process: every effect goes through `io`, so tests run it without spawning. Returns the exit code. */
9
9
  export declare function run(argv: readonly string[], io: Io): Promise<number>;
10
10
  /** The slice of `process` that `start` touches. */
11
- export interface Proc {
11
+ export type Proc = {
12
12
  stdout: NodeJS.WritableStream & {
13
13
  isTTY?: boolean;
14
14
  };
@@ -17,5 +17,5 @@ export interface Proc {
17
17
  env: Record<string, string | undefined>;
18
18
  exitCode?: number | string | null | undefined;
19
19
  exit(code?: number): void;
20
- }
20
+ };
21
21
  export declare function start(argv?: readonly string[], proc?: Proc): Promise<void>;
@@ -21,35 +21,35 @@ Options:
21
21
  Run \`installgen <command> --help\` for a command's options.
22
22
  `;
23
23
  const COMMANDS = {
24
- init: {
25
- usage: `Usage: installgen init [--preset ${ /* @__PURE__ */PRESETS.join("|")}] [--force]
26
-
27
- --preset <name> the example to start from (default: raw)
28
- --force overwrite an existing config
29
- `,
30
- options: { preset: { type: "string" }, force: { type: "boolean" } },
31
- },
32
24
  build: {
25
+ options: { config: { short: "c", type: "string" }, "default-version": { type: "string" }, out: { type: "string" } },
33
26
  usage: `Usage: installgen build [-c <path>] [--out <dir>] [--default-version <version>]
34
27
 
35
28
  -c, --config <path> the config (default: installgen.config.{ts,mts,js,mjs} in this directory)
36
29
  --out <dir> where to write the scripts (default: the config's outDir, installers)
37
30
  --default-version <version> install this version when the user names none (default: the latest file)
38
31
  `,
39
- options: { config: { type: "string", short: "c" }, out: { type: "string" }, "default-version": { type: "string" } },
40
32
  },
41
33
  check: {
34
+ options: {
35
+ config: { short: "c", type: "string" },
36
+ "default-version": { type: "string" },
37
+ list: { type: "boolean" },
38
+ },
42
39
  usage: `Usage: installgen check [-c <path>] [--default-version <version>] [--list]
43
40
 
44
41
  -c, --config <path> the config (default: installgen.config.{ts,mts,js,mjs} in this directory)
45
42
  --default-version <version> check this version (default: read the latest file)
46
43
  --list print the URLs the installers fetch, without fetching
47
44
  `,
48
- options: {
49
- config: { type: "string", short: "c" },
50
- "default-version": { type: "string" },
51
- list: { type: "boolean" },
52
- },
45
+ },
46
+ init: {
47
+ options: { force: { type: "boolean" }, preset: { type: "string" } },
48
+ usage: `Usage: installgen init [--preset ${ /* @__PURE__ */PRESETS.join("|")}] [--force]
49
+
50
+ --preset <name> the example to start from (default: raw)
51
+ --force overwrite an existing config
52
+ `,
53
53
  },
54
54
  };
55
55
  class UsageError extends Error {
@@ -74,10 +74,10 @@ function topLevel(command, io) {
74
74
  function parse(command, rest) {
75
75
  try {
76
76
  return parseArgs({
77
+ allowPositionals: false,
77
78
  args: [...rest],
78
- options: { ...COMMANDS[command].options, help: { type: "boolean", short: "h" } },
79
+ options: { ...COMMANDS[command].options, help: { short: "h", type: "boolean" } },
79
80
  strict: true,
80
- allowPositionals: false,
81
81
  }).values;
82
82
  }
83
83
  catch (error) {
@@ -96,19 +96,19 @@ async function dispatch(command, values, io, ui) {
96
96
  const configPath = values.config;
97
97
  const defaultVersion = values["default-version"];
98
98
  if (command === "init") {
99
- init({ cwd: io.cwd, preset: presetOf(values), force: values.force === true }, ui);
99
+ init({ cwd: io.cwd, force: values.force === true, preset: presetOf(values) }, ui);
100
100
  return 0;
101
101
  }
102
102
  if (command === "build") {
103
- await build({ cwd: io.cwd, configPath, runtime, out: values.out, defaultVersion }, ui);
103
+ await build({ configPath, cwd: io.cwd, defaultVersion, out: values.out, runtime }, ui);
104
104
  return 0;
105
105
  }
106
106
  const problems = await check({
107
- cwd: io.cwd,
108
107
  configPath,
109
- runtime,
108
+ cwd: io.cwd,
110
109
  defaultVersion,
111
110
  list: values.list === true,
111
+ runtime,
112
112
  ...(io.fetch ? { fetch: io.fetch } : {}),
113
113
  }, ui);
114
114
  return problems === 0 ? 0 : 1;
@@ -145,9 +145,9 @@ export async function run(argv, io) {
145
145
  }
146
146
  }
147
147
  export async function start(argv = process.argv.slice(2), proc = process) {
148
- /* a reader that closes early (`| head`, `| grep -q`) is done listening: stop writing and leave quietly */
148
+ // a reader that closes early (`| head`, `| grep -q`) is done listening: stop writing and leave quietly
149
149
  let closed = false;
150
- /* EPIPE, or EOF where Windows reports a closed pipe that way */
150
+ // EPIPE, or EOF where Windows reports a closed pipe that way
151
151
  const onError = (error) => {
152
152
  if (error.code !== "EPIPE" && error.code !== "EOF")
153
153
  throw error;
@@ -163,8 +163,8 @@ export async function start(argv = process.argv.slice(2), proc = process) {
163
163
  proc.exitCode = await run(argv, {
164
164
  cwd: proc.cwd(),
165
165
  env: proc.env,
166
- stdout: write(proc.stdout),
167
- stderr: write(proc.stderr),
168
166
  isTTY: proc.stdout.isTTY === true,
167
+ stderr: write(proc.stderr),
168
+ stdout: write(proc.stdout),
169
169
  });
170
170
  }
@@ -1,15 +1,15 @@
1
1
  import { type RuntimeInfo } from "../config/load.ts";
2
2
  import type { ResolvedConfig } from "../config/types.ts";
3
3
  import type { Ui } from "../ui.ts";
4
- export interface ConfigOptions {
4
+ export type ConfigOptions = {
5
5
  cwd: string;
6
6
  configPath: string | undefined;
7
7
  runtime: RuntimeInfo;
8
- }
8
+ };
9
9
  export declare function loadResolved(options: ConfigOptions): Promise<ResolvedConfig>;
10
10
  export declare function warnUnverified(resolved: ResolvedConfig, ui: Ui): void;
11
- export interface BuildOptions extends ConfigOptions {
11
+ export type BuildOptions = ConfigOptions & {
12
12
  out: string | undefined;
13
13
  defaultVersion: string | undefined;
14
- }
14
+ };
15
15
  export declare function build(options: BuildOptions, ui: Ui): Promise<void>;
@@ -4,13 +4,12 @@ import { loadConfig } from "../config/load.js";
4
4
  import { resolveConfig } from "../config/resolve.js";
5
5
  import { render } from "../render/render.js";
6
6
  export async function loadResolved(options) {
7
- const { config } = await loadConfig({ cwd: options.cwd, configPath: options.configPath, runtime: options.runtime });
7
+ const { config } = await loadConfig({ configPath: options.configPath, cwd: options.cwd, runtime: options.runtime });
8
8
  return resolveConfig(config);
9
9
  }
10
10
  export function warnUnverified(resolved, ui) {
11
- if (resolved.platforms.every((p) => p.checksums === undefined)) {
11
+ if (resolved.platforms.every((p) => p.checksums === undefined))
12
12
  ui.warn("no checksumsPath; the installers will not verify downloads (they show a warning row instead)");
13
- }
14
13
  }
15
14
  export async function build(options, ui) {
16
15
  const resolved = await loadResolved(options);
@@ -1,10 +1,10 @@
1
1
  import type { Ui } from "../ui.ts";
2
2
  import { type ConfigOptions } from "./build.ts";
3
- export interface CheckOptions extends ConfigOptions {
3
+ export type CheckOptions = ConfigOptions & {
4
4
  defaultVersion: string | undefined;
5
5
  list: boolean;
6
6
  fetch?: typeof fetch;
7
- }
7
+ };
8
8
  /** `hash file`, `hash *file`, BSD `SHA256 (file) = hash`, or a file holding one bare hash. */
9
9
  export declare function findChecksum(text: string, file: string): string | undefined;
10
10
  export declare function check(options: CheckOptions, ui: Ui): Promise<number>;
@@ -1,6 +1,6 @@
1
1
  import { InstallgenError } from "../errors.js";
2
2
  import { loadResolved, warnUnverified } from "./build.js";
3
- /* the same rules the scripts apply at install time */
3
+ // the same rules the scripts apply at install time
4
4
  const VERSION = /^[A-Za-z0-9._+-]+$/;
5
5
  const TIMEOUT_MS = 15_000;
6
6
  function expand(segments, version, tag) {
@@ -19,7 +19,7 @@ export function findChecksum(text, file) {
19
19
  const only = lines.length === 1 ? lines[0]?.trim().split(/\s+/) : undefined;
20
20
  return only?.length === 1 ? only[0] : undefined;
21
21
  }
22
- /* fetch rejects with a TypeError whose cause says why (ECONNREFUSED, a timeout) */
22
+ // fetch rejects with a TypeError whose cause says why (ECONNREFUSED, a timeout)
23
23
  function failure(error) {
24
24
  const e = error;
25
25
  return e.cause instanceof Error ? `${e.message}: ${e.cause.message}` : e.message;
@@ -36,12 +36,12 @@ function normalize(raw, tagPrefix, what) {
36
36
  function probesFor(get) {
37
37
  const sums = new Map();
38
38
  return {
39
- /* HEAD first; hosts that refuse it get a one-byte ranged GET */
39
+ // HEAD first; hosts that refuse it get a one-byte ranged GET
40
40
  async exists(url) {
41
41
  try {
42
42
  const head = await get(url, { method: "HEAD" });
43
43
  if (head.ok)
44
- return undefined;
44
+ return;
45
45
  const ranged = await get(url, { headers: { range: "bytes=0-0" } });
46
46
  await ranged.arrayBuffer();
47
47
  return ranged.ok ? undefined : `missing ${url} (${ranged.status})`;
@@ -53,7 +53,7 @@ function probesFor(get) {
53
53
  checksums(url) {
54
54
  let probe = sums.get(url);
55
55
  if (probe === undefined) {
56
- probe = get(url).then(async (res) => res.ok ? { ok: true, body: await res.text() } : { ok: false, reason: `missing ${url} (${res.status})` }, (error) => ({ ok: false, reason: `unreachable ${url}: ${failure(error)}` }));
56
+ probe = get(url).then(async (res) => res.ok ? { body: await res.text(), ok: true } : { ok: false, reason: `missing ${url} (${res.status})` }, (error) => ({ ok: false, reason: `unreachable ${url}: ${failure(error)}` }));
57
57
  sums.set(url, probe);
58
58
  }
59
59
  return probe;
@@ -82,8 +82,9 @@ async function checkPlatform(p, run) {
82
82
  const found = [];
83
83
  let problems = 0;
84
84
  const missing = await probes.exists(assetUrl);
85
- if (missing === undefined)
85
+ if (missing === undefined) {
86
86
  found.push(assetUrl);
87
+ }
87
88
  else {
88
89
  problems++;
89
90
  ui.bad(p.platform, missing);
@@ -97,8 +98,9 @@ async function checkPlatform(p, run) {
97
98
  }
98
99
  if (p.signature !== undefined) {
99
100
  const missingBundle = await probes.exists(`${resolved.baseUrl}/${expand(p.signature.bundle, version, tag)}`);
100
- if (missingBundle === undefined)
101
+ if (missingBundle === undefined) {
101
102
  found.push("signature bundle");
103
+ }
102
104
  else {
103
105
  problems++;
104
106
  ui.bad(p.platform, missingBundle);
@@ -119,7 +121,7 @@ export async function check(options, ui) {
119
121
  }
120
122
  warnUnverified(resolved, ui);
121
123
  const version = await resolveVersion(resolved, options.defaultVersion, get, ui);
122
- const run = { resolved, version, tag: resolved.tagPrefix + version, probes: probesFor(get), ui };
124
+ const run = { probes: probesFor(get), resolved, tag: resolved.tagPrefix + version, ui, version };
123
125
  let problems = 0;
124
126
  for (const p of resolved.platforms)
125
127
  problems += await checkPlatform(p, run);
@@ -154,8 +156,7 @@ function list(resolved, defaultVersion, ui) {
154
156
  ui.info(`${p.platform} ${resolved.baseUrl}/${expand(p.asset, version, tag)}`);
155
157
  if (p.checksums !== undefined)
156
158
  ui.info(`${p.platform} ${resolved.baseUrl}/${expand(p.checksums, version, tag)}`);
157
- if (p.signature !== undefined) {
159
+ if (p.signature !== undefined)
158
160
  ui.info(`${p.platform} ${resolved.baseUrl}/${expand(p.signature.bundle, version, tag)}`);
159
- }
160
161
  }
161
162
  }