hono-takibi 0.15.0 → 0.16.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/dist/cli.js +114 -152
- package/dist/core/docs/index.js +1 -1
- package/dist/core/hooks/index.d.ts +1 -2
- package/dist/core/hooks/index.js +1 -1
- package/dist/core/rpc/index.d.ts +1 -2
- package/dist/core/rpc/index.js +4 -3
- package/dist/core/type/index.d.ts +1 -1
- package/dist/core/type/index.js +2 -2
- package/dist/{core-BIzYFvM2.js → core-BTIn-SV7.js} +7 -8
- package/dist/docs-BUk6OQGb.js +1380 -0
- package/dist/{emit-B_3fXoto.js → emit-CSV6od97.js} +2 -2
- package/dist/file-BoSc__Bx.js +31 -0
- package/dist/{format-Bm9LZ_ki.js → format-CuHABcKC.js} +5 -12
- package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
- package/dist/{hooks-kkOg8Baa.js → hooks-BI33t89i.js} +4 -3
- package/dist/{index-6-_xlYFY.d.ts → index-D_gf3Xzx.d.ts} +7 -9
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -24
- package/dist/{openapi-CK1nn2RJ.js → openapi-BCxQyBJl.js} +6 -25
- package/dist/{rpc-CQFRTmcC.js → rpc-UzOYe2mc.js} +2 -14
- package/dist/{shared-DVLeJFoN.js → shared-C6tCzlhg.js} +62 -45
- package/dist/{utils-BtWoIX8v.js → utils-DNYSWwCh.js} +1 -5
- package/dist/vite-plugin/index.js +39 -27
- package/package.json +1 -1
- package/dist/docs-Bo4-6xBy.js +0 -782
- package/dist/file-CwKqigE9.js +0 -55
- package/dist/index-wD0wV6VQ.d.ts +0 -12
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
3
3
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
4
|
-
import { Console, Effect, FileSystem, Option, Ref, Result,
|
|
4
|
+
import { Console, Effect, FileSystem, Option, Ref, Result, Schema, Stream } from "effect";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { Argument, CliError, Command, Flag } from "effect/unstable/cli";
|
|
7
|
+
//#region package.json
|
|
8
|
+
var version = "0.16.0";
|
|
9
|
+
var description = "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi";
|
|
10
|
+
//#endregion
|
|
8
11
|
//#region src/cli/index.ts
|
|
9
12
|
const COMMAND_NAME = "hono-takibi";
|
|
10
|
-
/** Config file `hono-takibi` picks up from the working directory when `--config` is omitted. */
|
|
11
13
|
const DEFAULT_CONFIG_FILE = "hono-takibi.config.ts";
|
|
12
14
|
const DocumentPathSchema = Schema.String.pipe(Schema.refine(Schema.is(Schema.TemplateLiteral([Schema.String, Schema.Literals([
|
|
13
15
|
".yaml",
|
|
@@ -27,127 +29,152 @@ const TypeScriptPathSchema = Schema.String.pipe(Schema.refine(Schema.is(Schema.T
|
|
|
27
29
|
description: "TypeScript file the one-shot mode writes the generated routes to.",
|
|
28
30
|
examples: ["./src/routes.ts", "src/api/routes.ts"]
|
|
29
31
|
});
|
|
30
|
-
/**
|
|
31
|
-
* The command line itself: what `hono-takibi` accepts, what each piece means, and the
|
|
32
|
-
* schema every value is decoded through before {@link generate} ever sees it.
|
|
33
|
-
*/
|
|
34
32
|
const commandLine = {
|
|
35
33
|
input: Argument.File("input", { mustExist: true }).pipe(Argument.withSchema(DocumentPathSchema), Argument.withDescription("OpenAPI (.yaml, .json) or TypeSpec (.tsp) document to generate from"), Argument.withMetavar("input.{yaml,json,tsp}"), Argument.optional),
|
|
36
34
|
output: Flag.String("output").pipe(Flag.withAlias("o"), Flag.withSchema(TypeScriptPathSchema), Flag.withDescription("TypeScript file the generated routes are written to"), Flag.withMetavar("output.ts"), Flag.optional),
|
|
37
35
|
config: Flag.File("config", { mustExist: true }).pipe(Flag.withAlias("c"), Flag.withDescription(`Config file to run (default: ./${DEFAULT_CONFIG_FILE})`), Flag.withMetavar("file"), Flag.optional),
|
|
38
36
|
watch: Flag.Boolean("watch").pipe(Flag.withAlias("w"), Flag.withDescription("Rerun the config on every change to its documents or itself"), Flag.withDefault(false))
|
|
39
37
|
};
|
|
40
|
-
/** Extensions a change has to carry to be worth regenerating for. */
|
|
41
38
|
const INPUT_EXTENSIONS = [
|
|
42
39
|
".yaml",
|
|
43
40
|
".json",
|
|
44
41
|
".tsp"
|
|
45
42
|
];
|
|
46
|
-
|
|
47
|
-
* One pass over a config file: read it, parse the document it names, and run every
|
|
48
|
-
* generator it opts into.
|
|
49
|
-
*
|
|
50
|
-
* `reload` is for the passes after the first, where the config file may have been edited
|
|
51
|
-
* since it was imported.
|
|
52
|
-
*
|
|
53
|
-
* The generator pipeline pulls in the OpenAPI parser, the TypeSpec compiler and ts-morph.
|
|
54
|
-
* `--help`, `--version`, `--completions` and every rejected command line must not pay for
|
|
55
|
-
* that, so it is loaded here rather than at module scope. After the first pass the loader
|
|
56
|
-
* answers from cache, so a watch tick pays nothing.
|
|
57
|
-
*/
|
|
58
|
-
function runConfigPass(configPath, reload) {
|
|
43
|
+
function loadConfig(configPath, reload) {
|
|
59
44
|
return Effect.gen(function* () {
|
|
60
|
-
const
|
|
61
|
-
|
|
45
|
+
const { readConfig } = yield* Effect.promise(() => import("./index.js"));
|
|
46
|
+
return yield* readConfig(configPath, reload);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function runJobs(config) {
|
|
50
|
+
return Effect.gen(function* () {
|
|
51
|
+
const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob }] = yield* Effect.promise(() => Promise.all([
|
|
62
52
|
import("./openapi-DQRxq2_O.js").then((n) => n.t),
|
|
63
|
-
import("./format-
|
|
64
|
-
import("./shared-
|
|
53
|
+
import("./format-CuHABcKC.js").then((n) => n.r),
|
|
54
|
+
import("./shared-C6tCzlhg.js").then((n) => n.o)
|
|
65
55
|
]));
|
|
66
|
-
const config = yield* readConfig(configPath, reload);
|
|
67
56
|
const jobs = makeJob(yield* parseOpenAPI(config.input), config);
|
|
68
57
|
yield* cleanSplitOutputs(jobs.filter((job) => job.split).map((job) => job.output));
|
|
58
|
+
return (yield* Effect.all(jobs.map((job) => job.run(job.output)), { concurrency: "unbounded" }).pipe(Effect.provideService(FormatOptions, config.format ?? {}))).filter((message) => message !== "").join("\n");
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function runConfigPass(configPath, reload) {
|
|
62
|
+
return Effect.gen(function* () {
|
|
63
|
+
const config = yield* loadConfig(configPath, reload);
|
|
69
64
|
return {
|
|
70
65
|
config,
|
|
71
|
-
report:
|
|
66
|
+
report: yield* runJobs(config)
|
|
72
67
|
};
|
|
73
68
|
});
|
|
74
69
|
}
|
|
70
|
+
function isSameTarget(left, right) {
|
|
71
|
+
return left?.inputDirectory === right?.inputDirectory && left?.outside.join("\n") === right?.outside.join("\n");
|
|
72
|
+
}
|
|
75
73
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
74
|
+
* Runs one pass and answers what to watch for the documents.
|
|
75
|
+
*
|
|
76
|
+
* Two separate things happen to the document here. `runJobs` generates from it, reading
|
|
77
|
+
* it the way every other mode does. `outsideSources` then only asks which files it was
|
|
78
|
+
* read from, so that an edit to any of them brings the session back to this function;
|
|
79
|
+
* what it answers never reaches a generator.
|
|
78
80
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
+
* The directory comes from the config alone, so a pass that fails after the config was
|
|
82
|
+
* read — a document that does not parse, say — still names it. Otherwise the very edit
|
|
83
|
+
* that fixes the document would never be seen. The answer is `undefined` only when the
|
|
84
|
+
* config itself could not be read.
|
|
85
|
+
*
|
|
86
|
+
* The files outside the directory come from the document, and a broken document cannot
|
|
87
|
+
* list them. `previous` is what stands in then: the fix may well belong in one of the
|
|
88
|
+
* files the last readable version pointed at.
|
|
81
89
|
*/
|
|
82
|
-
function reportConfigPass(configPath, reload) {
|
|
90
|
+
function reportConfigPass(configPath, reload, previous) {
|
|
83
91
|
return Effect.gen(function* () {
|
|
84
|
-
const
|
|
85
|
-
if (Result.isFailure(
|
|
86
|
-
yield* Console.error(`❌ ${
|
|
92
|
+
const config = yield* Effect.result(loadConfig(configPath, reload));
|
|
93
|
+
if (Result.isFailure(config)) {
|
|
94
|
+
yield* Console.error(`❌ ${config.failure.message}`);
|
|
87
95
|
return;
|
|
88
96
|
}
|
|
89
|
-
yield*
|
|
90
|
-
|
|
97
|
+
const report = yield* Effect.result(runJobs(config.success));
|
|
98
|
+
if (Result.isSuccess(report)) yield* Console.log(report.success);
|
|
99
|
+
else yield* Console.error(`❌ ${report.failure.message}`);
|
|
100
|
+
const { outsideSources } = yield* Effect.promise(() => import("./shared-C6tCzlhg.js").then((n) => n.o));
|
|
101
|
+
const inputDirectory = path.dirname(path.resolve(process.cwd(), config.success.input));
|
|
102
|
+
return {
|
|
103
|
+
inputDirectory,
|
|
104
|
+
outside: yield* outsideSources(config.success.input).pipe(Effect.orElseSucceed(() => previous?.inputDirectory === inputDirectory ? previous.outside : []))
|
|
105
|
+
};
|
|
91
106
|
});
|
|
92
107
|
}
|
|
93
108
|
/**
|
|
94
|
-
*
|
|
95
|
-
* the answer changes — then hands the new directory back so {@link watchConfig} restarts.
|
|
109
|
+
* `directory`, or the closest directory above it that exists.
|
|
96
110
|
*
|
|
97
|
-
*
|
|
98
|
-
* returns `false`, and the directory it reported is in the `Ref` for the caller. The
|
|
99
|
-
* `Ref` is what carries a value out of a stream that otherwise only returns `void`.
|
|
111
|
+
* A directory that is not there cannot be watched, but the one it will appear in can.
|
|
100
112
|
*/
|
|
101
|
-
function
|
|
113
|
+
function nearestExisting(directory) {
|
|
102
114
|
return Effect.gen(function* () {
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const configEvents = fs.watch(path.dirname(configPath)).pipe(Stream.filter((event) => event.path === configFile));
|
|
107
|
-
yield* (inputDirectory === void 0 ? configEvents : Stream.merge(fs.watch(inputDirectory, { recursive: true }).pipe(Stream.filter((event) => INPUT_EXTENSIONS.some((extension) => event.path.endsWith(extension)))), configEvents)).pipe(Stream.debounce("200 millis"), Stream.runForEachWhile(() => reportConfigPass(configPath, true).pipe(Effect.tap((directory) => Ref.set(nextDirectory, directory ?? inputDirectory)), Effect.map((directory) => directory === void 0 || directory === inputDirectory))));
|
|
108
|
-
return yield* Ref.get(nextDirectory);
|
|
115
|
+
const exists = yield* (yield* FileSystem.FileSystem).exists(directory).pipe(Effect.orElseSucceed(() => false));
|
|
116
|
+
const parent = path.dirname(directory);
|
|
117
|
+
return exists || parent === directory ? directory : yield* nearestExisting(parent);
|
|
109
118
|
});
|
|
110
119
|
}
|
|
111
120
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* Two watchers, because two things can invalidate the output. The input document's
|
|
115
|
-
* directory is watched recursively — a TypeSpec entry imports its siblings and a `$ref`
|
|
116
|
-
* can point at one, so the file named by `input` is rarely the only one that matters. The
|
|
117
|
-
* config file is watched through its directory rather than directly, so an editor that
|
|
118
|
-
* saves by renaming does not take the watcher down with it.
|
|
119
|
-
*
|
|
120
|
-
* `WatchEvent.path` is relative to the directory it came from, which is why each stream
|
|
121
|
-
* is filtered before the merge rather than after.
|
|
122
|
-
*
|
|
123
|
-
* `debounce` collapses the burst an editor emits on save into one pass — a plain write
|
|
124
|
-
* already reports twice. Generated files are `.ts` and `.md`, so a pass cannot trigger
|
|
125
|
-
* the next one.
|
|
126
|
-
*
|
|
127
|
-
* `inputDirectory` is `undefined` until a pass has read a config far enough to name one;
|
|
128
|
-
* only the config is watched until then, which is what keeps a config that does not
|
|
129
|
-
* validate at startup from ending the command the caller asked to keep running.
|
|
121
|
+
* One pass inside a round; answers whether the round's watchers are still the right ones.
|
|
130
122
|
*/
|
|
131
|
-
function
|
|
123
|
+
function watchPass(configPath, target, watched, nextTarget) {
|
|
132
124
|
return Effect.gen(function* () {
|
|
133
|
-
yield*
|
|
134
|
-
|
|
125
|
+
const next = (yield* reportConfigPass(configPath, true, target)) ?? target;
|
|
126
|
+
yield* Ref.set(nextTarget, next);
|
|
127
|
+
if (!isSameTarget(next, target)) return false;
|
|
128
|
+
return next === void 0 || (yield* nearestExisting(next.inputDirectory)) === watched;
|
|
135
129
|
});
|
|
136
130
|
}
|
|
137
131
|
/**
|
|
138
|
-
*
|
|
132
|
+
* The edits to the files a document reads from outside its own directory.
|
|
139
133
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
134
|
+
* Each one is watched through the directory it sits in, which is how an editor's
|
|
135
|
+
* write-then-rename save is still seen. A directory that is not there is skipped rather
|
|
136
|
+
* than failed on: the pass that follows reports the missing file in its own words.
|
|
137
|
+
*/
|
|
138
|
+
function outsideEvents(outside) {
|
|
139
|
+
return Effect.gen(function* () {
|
|
140
|
+
const fs = yield* FileSystem.FileSystem;
|
|
141
|
+
const directories = [...new Set(outside.map((file) => path.dirname(file)))];
|
|
142
|
+
const present = yield* Effect.all(directories.map((directory) => fs.exists(directory).pipe(Effect.orElseSucceed(() => false))), { concurrency: "unbounded" });
|
|
143
|
+
return directories.filter((_, index) => present[index]).map((directory) => fs.watch(directory).pipe(Stream.filter((event) => outside.includes(path.join(directory, event.path)))));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Watches until what has to be watched changes, and answers the next target.
|
|
145
148
|
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
149
|
+
* `watched` is where the watcher for the input directory actually sits. It is that
|
|
150
|
+
* directory while it exists; once it is removed — or before it is created — it is the
|
|
151
|
+
* closest directory above, and the only event that matters there is the missing path
|
|
152
|
+
* coming into being. A watcher left on a removed directory reports nothing, even after
|
|
153
|
+
* the directory is back, so the round ends whenever `watched` stops being the right place.
|
|
150
154
|
*/
|
|
155
|
+
function watchRound(configPath, target, watched) {
|
|
156
|
+
return Effect.gen(function* () {
|
|
157
|
+
const fs = yield* FileSystem.FileSystem;
|
|
158
|
+
const configFile = path.basename(configPath);
|
|
159
|
+
const nextTarget = yield* Ref.make(target);
|
|
160
|
+
const configEvents = fs.watch(path.dirname(configPath)).pipe(Stream.filter((event) => event.path === configFile));
|
|
161
|
+
const inputEvents = target === void 0 || watched === void 0 ? [] : [watched === target.inputDirectory ? fs.watch(target.inputDirectory, { recursive: true }).pipe(Stream.filter((event) => INPUT_EXTENSIONS.some((extension) => event.path.endsWith(extension)))) : fs.watch(watched).pipe(Stream.filter((event) => event.path === path.relative(watched, target.inputDirectory).split(path.sep)[0]))];
|
|
162
|
+
yield* Stream.mergeAll([
|
|
163
|
+
configEvents,
|
|
164
|
+
...inputEvents,
|
|
165
|
+
...yield* outsideEvents(target?.outside ?? [])
|
|
166
|
+
], { concurrency: "unbounded" }).pipe(Stream.debounce("200 millis"), Stream.runForEachWhile(() => watchPass(configPath, target, watched, nextTarget)));
|
|
167
|
+
return yield* Ref.get(nextTarget);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function watchConfig(configPath, target) {
|
|
171
|
+
return Effect.gen(function* () {
|
|
172
|
+
const watched = target === void 0 ? void 0 : yield* nearestExisting(target.inputDirectory);
|
|
173
|
+
const documents = [target?.inputDirectory, ...target?.outside ?? []].filter((entry) => entry !== void 0).join(", ");
|
|
174
|
+
yield* Console.log(target === void 0 ? `\n👀 Watching ${configPath} — Ctrl-C to stop` : watched === target.inputDirectory ? `\n👀 Watching ${documents} and ${configPath} — Ctrl-C to stop` : `\n👀 Watching ${configPath}, waiting for ${target.inputDirectory} — Ctrl-C to stop`);
|
|
175
|
+
return yield* watchConfig(configPath, yield* watchRound(configPath, target, watched));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
151
178
|
function generate(args) {
|
|
152
179
|
return Effect.gen(function* () {
|
|
153
180
|
const input = Option.getOrUndefined(args.input);
|
|
@@ -167,11 +194,11 @@ function generate(args) {
|
|
|
167
194
|
})]
|
|
168
195
|
});
|
|
169
196
|
if (input !== void 0 && output !== void 0) {
|
|
170
|
-
const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-
|
|
197
|
+
const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-BTIn-SV7.js").then((n) => n.t)]));
|
|
171
198
|
return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output));
|
|
172
199
|
}
|
|
173
200
|
const resolvedConfig = configPath ?? DEFAULT_CONFIG_FILE;
|
|
174
|
-
if (args.watch) return yield* watchConfig(resolvedConfig, yield* reportConfigPass(resolvedConfig, false));
|
|
201
|
+
if (args.watch) return yield* watchConfig(resolvedConfig, yield* reportConfigPass(resolvedConfig, false, void 0));
|
|
175
202
|
const first = yield* runConfigPass(resolvedConfig, false).pipe(Effect.mapError((error) => configPath === void 0 && error._tag === "ConfigError" && error.notFound === true ? new CliError.ShowHelp({
|
|
176
203
|
commandPath: [COMMAND_NAME],
|
|
177
204
|
errors: [new CliError.UserError({
|
|
@@ -185,14 +212,7 @@ function generate(args) {
|
|
|
185
212
|
userMessage: error.message
|
|
186
213
|
})));
|
|
187
214
|
}
|
|
188
|
-
|
|
189
|
-
* The `hono-takibi` command: parsing, validation, `--help`, `--version` and shell
|
|
190
|
-
* completions are owned by `effect/unstable/cli`, {@link generate} is the rest.
|
|
191
|
-
*
|
|
192
|
-
* `description` is the manifest's, so the sentence `--help` prints and the one npm shows
|
|
193
|
-
* cannot drift apart — {@link honoTakibi} is already reading that file for `--version`.
|
|
194
|
-
*/
|
|
195
|
-
function makeCli(description) {
|
|
215
|
+
function makeCli() {
|
|
196
216
|
return Command.make(COMMAND_NAME, commandLine, generate).pipe(Command.withDescription(description), Command.withExamples([
|
|
197
217
|
{
|
|
198
218
|
command: "hono-takibi openapi.yaml -o src/routes.ts",
|
|
@@ -212,69 +232,11 @@ function makeCli(description) {
|
|
|
212
232
|
}
|
|
213
233
|
]));
|
|
214
234
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
* JSON, or carries no `version` / `description`. That is a broken install, not anything
|
|
218
|
-
* the caller typed.
|
|
219
|
-
*
|
|
220
|
-
* `Command.runWith` renders the errors raised inside the command, but this one is raised
|
|
221
|
-
* before it runs. So it is rendered here through the same formatter — the `ERROR` block
|
|
222
|
-
* every other failure prints — and marked as already reported, so `runMain` does not
|
|
223
|
-
* print it a second time in its own shape.
|
|
224
|
-
*/
|
|
225
|
-
function reportBrokenInstall(cause) {
|
|
226
|
-
return Effect.gen(function* () {
|
|
227
|
-
const error = new CliError.UserError({
|
|
228
|
-
cause,
|
|
229
|
-
userMessage: `Cannot read the version and description from package.json: ${cause.message}`
|
|
230
|
-
});
|
|
231
|
-
error[Runtime.errorReported] = false;
|
|
232
|
-
const formatter = yield* CliOutput.Formatter;
|
|
233
|
-
yield* Console.error(formatter.formatError(error));
|
|
234
|
-
return yield* error;
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Runs `hono-takibi` against an argument list.
|
|
239
|
-
*
|
|
240
|
-
* `entryUrl` is the `import.meta.url` of the executable, and both `--version` and the
|
|
241
|
-
* description `--help` prints are read from the `package.json` beside it. The entry has
|
|
242
|
-
* to supply that URL: it is the only module whose
|
|
243
|
-
* depth is the same in source and in the bundle (`src/index.ts` and the `dist/cli.js` it
|
|
244
|
-
* is packed into both sit one directory below the manifest), so a relative URL written
|
|
245
|
-
* anywhere else resolves to two different files.
|
|
246
|
-
*
|
|
247
|
-
* A manifest that is missing or malformed is a broken install, so it fails rather than
|
|
248
|
-
* reporting a placeholder version — but through the error channel, which prints a
|
|
249
|
-
* sentence instead of an unhandled `SchemaError` and its whole AST. One `Schema.Struct`
|
|
250
|
-
* is what says which fields have to be there for the command to describe itself.
|
|
251
|
-
*/
|
|
252
|
-
function honoTakibi(argv, entryUrl) {
|
|
253
|
-
return Effect.gen(function* () {
|
|
254
|
-
const manifestPath = fileURLToPath(new URL("../package.json", entryUrl));
|
|
255
|
-
const source = yield* (yield* FileSystem.FileSystem).readFileString(manifestPath);
|
|
256
|
-
const manifest = yield* Effect.try({
|
|
257
|
-
try: () => JSON.parse(source),
|
|
258
|
-
catch: (cause) => new Error(`${manifestPath} is not valid JSON`, { cause })
|
|
259
|
-
});
|
|
260
|
-
const { version, description } = yield* Schema.decodeUnknownEffect(Schema.Struct({
|
|
261
|
-
version: Schema.String.annotate({
|
|
262
|
-
description: "What `--version` prints.",
|
|
263
|
-
examples: ["1.2.3"]
|
|
264
|
-
}),
|
|
265
|
-
description: Schema.String.annotate({
|
|
266
|
-
description: "The sentence `--help` prints under DESCRIPTION.",
|
|
267
|
-
examples: ["Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi"]
|
|
268
|
-
})
|
|
269
|
-
}).annotate({
|
|
270
|
-
title: "Package manifest",
|
|
271
|
-
description: "The fields `hono-takibi` reads from the package.json beside its entry."
|
|
272
|
-
}))(manifest);
|
|
273
|
-
return yield* Command.runWith(makeCli(description), { version })(argv);
|
|
274
|
-
}).pipe(Effect.catchIf((error) => !CliError.isCliError(error), reportBrokenInstall));
|
|
235
|
+
function honoTakibi(argv) {
|
|
236
|
+
return Command.runWith(makeCli(), { version })(argv);
|
|
275
237
|
}
|
|
276
238
|
//#endregion
|
|
277
239
|
//#region src/index.ts
|
|
278
|
-
NodeRuntime.runMain(honoTakibi(process.argv.slice(2)
|
|
240
|
+
NodeRuntime.runMain(honoTakibi(process.argv.slice(2)).pipe(Effect.provide(NodeServices.layer)));
|
|
279
241
|
//#endregion
|
|
280
242
|
export {};
|
package/dist/core/docs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as docs } from "../../docs-
|
|
1
|
+
import { t as docs } from "../../docs-BUk6OQGb.js";
|
|
2
2
|
export { docs };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { t as OpenAPI } from "../../index-tsPqeV6H.js";
|
|
2
|
-
import { t as FormatError } from "../../index-
|
|
3
|
-
import { t as GenerateError } from "../../index-6-_xlYFY.js";
|
|
2
|
+
import { n as GenerateError, t as FormatError } from "../../index-D_gf3Xzx.js";
|
|
4
3
|
//#region src/core/hooks/index.d.ts
|
|
5
4
|
declare const HOOK_CONFIGS: {
|
|
6
5
|
readonly swr: {
|
package/dist/core/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as hooks } from "../../hooks-
|
|
1
|
+
import { t as hooks } from "../../hooks-BI33t89i.js";
|
|
2
2
|
export { hooks };
|
package/dist/core/rpc/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { t as OpenAPI } from "../../index-tsPqeV6H.js";
|
|
2
|
-
import { t as FormatError } from "../../index-
|
|
3
|
-
import { t as GenerateError } from "../../index-6-_xlYFY.js";
|
|
2
|
+
import { n as GenerateError, t as FormatError } from "../../index-D_gf3Xzx.js";
|
|
4
3
|
import { Effect } from "effect";
|
|
5
4
|
//#region src/core/rpc/index.d.ts
|
|
6
5
|
/**
|
package/dist/core/rpc/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { i as GenerateError } from "../../format-CuHABcKC.js";
|
|
2
|
+
import { A as isOperationLike, O as isOpenAPIPaths, R as isRecord, f as methodPath, l as makeInferRequestType } from "../../utils-DNYSWwCh.js";
|
|
3
|
+
import { t as emit } from "../../emit-CSV6od97.js";
|
|
4
|
+
import { a as parsePathItem, i as operationHasArgs, r as makeOperationDeps, t as formatPath } from "../../rpc-UzOYe2mc.js";
|
|
4
5
|
import { Effect } from "effect";
|
|
5
6
|
import { dirname } from "node:path";
|
|
6
7
|
//#region src/core/rpc/index.ts
|
package/dist/core/type/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as emit } from "../../emit-
|
|
1
|
+
import { D as isMediaWithSchema, M as isParameterArray, O as isOpenAPIPaths, T as isHttpMethod, U as isSchemaArray, V as isRequestBody, Y as isStringRef, g as statusCodeToNumber, j as isParameter, k as isOperation, u as makeSafeKey } from "../../utils-DNYSWwCh.js";
|
|
2
|
+
import { t as emit } from "../../emit-CSV6od97.js";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
//#region src/core/type/index.ts
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as emit } from "./emit-
|
|
6
|
-
import { o as
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as docs } from "./docs-Bo4-6xBy.js";
|
|
2
|
+
import { i as GenerateError, n as fmt } from "./format-CuHABcKC.js";
|
|
3
|
+
import { D as isMediaWithSchema, F as isPathItem, I as isPathItemEntry, K as isSecurityArray, L as isPathItemRef, P as isParameterRef, S as isContentBody, T as isHttpMethod, U as isSchemaArray, W as isSchemaObject, _ as toIdentifierPascalCase, b as zodToOpenAPISchema, c as makeBarrel, d as makeStringLiteral, f as methodPath, g as statusCodeToNumber, i as ensureSuffix, j as isParameter, k as isOperation, m as renderNamedImport, p as normalizeTypes, q as isSecurityScheme, r as cyclicNodes, u as makeSafeKey, v as uncapitalize, x as isCallbacks, y as uncapitalizeWord, z as isRefObject } from "./utils-DNYSWwCh.js";
|
|
4
|
+
import { a as writeFile, n as readFile, r as readdir, t as mkdir } from "./file-BoSc__Bx.js";
|
|
5
|
+
import { t as emit } from "./emit-CSV6od97.js";
|
|
6
|
+
import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-BCxQyBJl.js";
|
|
7
|
+
import { t as hooks } from "./hooks-BI33t89i.js";
|
|
8
|
+
import { t as docs } from "./docs-BUk6OQGb.js";
|
|
10
9
|
import { rpc } from "./core/rpc/index.js";
|
|
11
10
|
import { type } from "./core/type/index.js";
|
|
12
11
|
import { Effect } from "effect";
|