Skip to content

Commit a27950e

Browse files
author
Ryan
committed
fix(cli): migrate legacy localhost API config on upgrade
Auto-upgrade persisted localhost apiUrl values to the bundled production default and release the CLI as 0.0.52 so login stops opening local URLs after upgrades. Made-with: Cursor
1 parent a05895b commit a27950e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ryantanen/dploy",
3-
"version": "0.0.51",
3+
"version": "0.0.52",
44
"description": "Vercel-style just-deploy-it CLI. Point dploy at a GitHub repo and get a live URL.",
55
"type": "module",
66
"license": "MIT",

cli/src/lib/config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ type Schema = {
1313
// 3. http://localhost:8000 (local-dev fallback when running `pnpm build` /
1414
// `pnpm dev` without the bundle config)
1515
const BAKED_DEFAULT_API_URL = process.env.DPLOY_DEFAULT_API_URL;
16+
const LEGACY_LOCAL_API_URL = "http://localhost:8000";
1617

1718
export const DEFAULT_API_URL = (
1819
process.env.DPLOY_API_URL ??
1920
BAKED_DEFAULT_API_URL ??
20-
"http://localhost:8000"
21+
LEGACY_LOCAL_API_URL
2122
).replace(/\/+$/, "");
2223

2324
const configDir = process.env.DPLOY_CONFIG_DIR;
@@ -27,3 +28,13 @@ export const config = new Conf<Schema>({
2728
cwd: configDir,
2829
defaults: { apiUrl: DEFAULT_API_URL },
2930
});
31+
32+
// Migration for old installs that persisted localhost from pre-bundled builds.
33+
// Only run when a baked production default exists and the user did not
34+
// explicitly override via DPLOY_API_URL.
35+
if (BAKED_DEFAULT_API_URL && !process.env.DPLOY_API_URL) {
36+
const stored = config.get("apiUrl")?.replace(/\/+$/, "");
37+
if (!stored || stored === LEGACY_LOCAL_API_URL) {
38+
config.set("apiUrl", DEFAULT_API_URL);
39+
}
40+
}

0 commit comments

Comments
 (0)