specli 0.0.3 → 0.0.4
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/package.json
CHANGED
package/src/cli/compile.ts
CHANGED
|
@@ -65,18 +65,23 @@ export async function compileCommand(
|
|
|
65
65
|
|
|
66
66
|
buildArgs.push("./src/compiled.ts");
|
|
67
67
|
|
|
68
|
+
// Only set env vars that have actual values - avoid empty strings
|
|
69
|
+
// because the macros will embed them and they will override defaults.
|
|
70
|
+
const buildEnv: Record<string, string> = {
|
|
71
|
+
...process.env,
|
|
72
|
+
SPECLI_SPEC: spec,
|
|
73
|
+
SPECLI_NAME: name,
|
|
74
|
+
};
|
|
75
|
+
if (options.server) buildEnv.SPECLI_SERVER = options.server;
|
|
76
|
+
if (options.serverVar?.length)
|
|
77
|
+
buildEnv.SPECLI_SERVER_VARS = options.serverVar.join(",");
|
|
78
|
+
if (options.auth) buildEnv.SPECLI_AUTH = options.auth;
|
|
79
|
+
|
|
68
80
|
const proc = Bun.spawn({
|
|
69
81
|
cmd: ["bun", ...buildArgs],
|
|
70
82
|
stdout: "pipe",
|
|
71
83
|
stderr: "pipe",
|
|
72
|
-
env:
|
|
73
|
-
...process.env,
|
|
74
|
-
SPECLI_SPEC: spec,
|
|
75
|
-
SPECLI_NAME: name,
|
|
76
|
-
SPECLI_SERVER: options.server ?? "",
|
|
77
|
-
SPECLI_SERVER_VARS: options.serverVar?.join(",") ?? "",
|
|
78
|
-
SPECLI_AUTH: options.auth ?? "",
|
|
79
|
-
},
|
|
84
|
+
env: buildEnv,
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
const output = await new Response(proc.stdout).text();
|
|
@@ -188,10 +188,12 @@ export async function buildRequest(
|
|
|
188
188
|
|
|
189
189
|
const path = applyTemplate(input.action.path, pathVars, { encode: true });
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
)
|
|
191
|
+
// Build the full URL by combining server URL and path.
|
|
192
|
+
// We need to handle the case where path starts with "/" carefully:
|
|
193
|
+
// URL constructor treats absolute paths as relative to origin, not base path.
|
|
194
|
+
const baseUrl = serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
|
|
195
|
+
const relativePath = path.startsWith("/") ? path.slice(1) : path;
|
|
196
|
+
const url = new URL(relativePath, baseUrl);
|
|
195
197
|
|
|
196
198
|
const headers = new Headers();
|
|
197
199
|
|
|
@@ -9,7 +9,8 @@ export type ResolveServerInput = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export function resolveServerUrl(input: ResolveServerInput): string {
|
|
12
|
-
|
|
12
|
+
// Treat empty string as undefined (serverOverride can come from env vars or profiles)
|
|
13
|
+
const base = input.serverOverride || input.servers[0]?.url;
|
|
13
14
|
if (!base) {
|
|
14
15
|
throw new Error(
|
|
15
16
|
"No server URL found. Provide --server <url> or define servers in the OpenAPI spec.",
|