trpc-gen-python 0.1.0 → 0.1.2
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/bin.d.ts +2 -0
- package/dist/bin.js +26 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -1
- package/dist/introspect.js +2 -13
- package/package.json +3 -3
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
// Resolve tsx loader path using Node's module resolution
|
|
9
|
+
// This works regardless of where npm installs dependencies
|
|
10
|
+
let tsxLoader;
|
|
11
|
+
try {
|
|
12
|
+
// Try to resolve tsx from this package's dependencies
|
|
13
|
+
tsxLoader = require.resolve("tsx/dist/loader.mjs");
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// Fallback: look in node_modules relative to this file
|
|
17
|
+
tsxLoader = join(__dirname, "..", "node_modules", "tsx", "dist", "loader.mjs");
|
|
18
|
+
}
|
|
19
|
+
const cliPath = join(__dirname, "cli.js");
|
|
20
|
+
const child = spawn(process.execPath, ["--import", tsxLoader, cliPath, ...process.argv.slice(2)], {
|
|
21
|
+
stdio: "inherit",
|
|
22
|
+
env: process.env,
|
|
23
|
+
});
|
|
24
|
+
child.on("exit", (code) => {
|
|
25
|
+
process.exit(code || 0);
|
|
26
|
+
});
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
package/dist/introspect.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { resolve
|
|
1
|
+
import { resolve } from "path";
|
|
2
2
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
3
|
import { inferOutputTypes } from "./infer-outputs.js";
|
|
4
4
|
export async function introspectRouter(config) {
|
|
5
5
|
const routerPath = resolve(process.cwd(), config.router.path);
|
|
6
|
-
//
|
|
7
|
-
const tsxPath = resolve(dirname(new URL(import.meta.url).pathname), "..", "node_modules", "tsx", "esm", "api.mjs");
|
|
8
|
-
// Register tsx so we can import .ts files
|
|
9
|
-
try {
|
|
10
|
-
const tsx = await import(tsxPath);
|
|
11
|
-
if (tsx.register) {
|
|
12
|
-
tsx.register();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
// tsx may already be registered if running via tsx
|
|
17
|
-
}
|
|
6
|
+
// Import the router file - tsx loader is registered globally in bin.ts
|
|
18
7
|
const routerModule = await import(routerPath);
|
|
19
8
|
const router = routerModule[config.router.export];
|
|
20
9
|
if (!router) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trpc-gen-python",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Generate Python (Pydantic + httpx) clients from tRPC routers",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
6
|
+
"main": "./dist/bin.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"trpc-gen-python": "./dist/
|
|
8
|
+
"trpc-gen-python": "./dist/bin.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|