Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions packages/cli/src/web/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,28 @@ export function cmdWeb() {
);
if (instance) {
const url = new URL('/api/v1/config', instance.url);
const response = await fetch(url);
if (response.ok) {
const data: ConfigList = (await response.json()) as ConfigList;
data.items.map((config) => {
console.log(`export ${config.key.toUpperCase()}=${config.value}`);
});
const response = await fetch(url, {
headers: { Authorization: `Bearer ${token}` }
});
if (!response.ok) {
throw new Error(
`Failed to load config from '${configInstance}': HTTP ${response.status}`
);
}
const data: ConfigList = (await response.json()) as ConfigList;
data.items.map((config) => {
// Single-quote values to prevent shell expansion of special characters
const escaped = config.value.replace(/'/g, "'\\''");
console.log(`export ${config.key.toUpperCase()}='${escaped}'`);
});
} else {
throw new Error(
`Config service instance '${configInstance}' not found`
);
}
} catch (err) {
console.log((err as Error).message);
console.error((err as Error).message);
process.exit(1);
}
});
return web;
Expand Down