tthr 0.3.11 → 0.3.14

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.
@@ -0,0 +1,8 @@
1
+ import {
2
+ generateCommand,
3
+ generateTypes
4
+ } from "./chunk-6PDXNJZH.js";
5
+ export {
6
+ generateCommand,
7
+ generateTypes
8
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ generateCommand,
3
+ generateTypes
4
+ } from "./chunk-2QPN6NDY.js";
5
+ export {
6
+ generateCommand,
7
+ generateTypes
8
+ };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- API_URL,
4
3
  clearCredentials,
5
4
  detectFramework,
6
5
  generateCommand,
7
6
  generateTypes,
7
+ getApiUrl,
8
8
  getCredentials,
9
9
  getFrameworkDevCommand,
10
10
  loadConfig,
@@ -12,7 +12,7 @@ import {
12
12
  resolveEnvironmentFromApiKey,
13
13
  resolvePath,
14
14
  saveCredentials
15
- } from "./chunk-QNUE3MEY.js";
15
+ } from "./chunk-6PDXNJZH.js";
16
16
 
17
17
  // src/index.ts
18
18
  import { Command } from "commander";
@@ -34,8 +34,6 @@ import ora from "ora";
34
34
  import fs from "fs-extra";
35
35
  import path from "path";
36
36
  import * as esbuild from "esbuild";
37
- var isDev = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
38
- var API_URL2 = isDev ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
39
37
  async function deployCommand(options) {
40
38
  const credentials = await requireAuth();
41
39
  const configPath = path.resolve(process.cwd(), "tether.config.ts");
@@ -60,10 +58,11 @@ async function deployCommand(options) {
60
58
  process.exit(1);
61
59
  }
62
60
  const environment = options.env || config.environment || await resolveEnvironmentFromApiKey() || "development";
61
+ const API_URL3 = `${getApiUrl(config)}/api/v1`;
63
62
  console.log(chalk.bold("\n\u26A1 Deploying to Tether\n"));
64
63
  console.log(chalk.dim(` Project: ${projectId}`));
65
64
  console.log(chalk.dim(` Environment: ${environment}`));
66
- console.log(chalk.dim(` API: ${API_URL2}
65
+ console.log(chalk.dim(` API: ${API_URL3}
67
66
  `));
68
67
  console.log(chalk.dim(" Generating types..."));
69
68
  try {
@@ -76,15 +75,16 @@ async function deployCommand(options) {
76
75
  const deployFunctions = options.functions || !options.schema && !options.functions;
77
76
  if (deploySchema) {
78
77
  const schemaPath = resolvePath(config.schema);
79
- await deploySchemaToServer(projectId, credentials.accessToken, schemaPath, environment, options.dryRun);
78
+ await deploySchemaToServer(projectId, credentials.accessToken, schemaPath, environment, options.dryRun, API_URL3);
80
79
  }
81
80
  if (deployFunctions) {
82
81
  const functionsDir = resolvePath(config.functions);
83
- await deployFunctionsToServer(projectId, credentials.accessToken, functionsDir, environment, options.dryRun);
82
+ await deployFunctionsToServer(projectId, credentials.accessToken, functionsDir, environment, options.dryRun, API_URL3);
84
83
  }
85
84
  console.log(chalk.green("\n\u2713 Deployment complete\n"));
86
85
  }
87
- async function deploySchemaToServer(projectId, token, schemaPath, environment, dryRun) {
86
+ async function deploySchemaToServer(projectId, token, schemaPath, environment, dryRun, apiUrl) {
87
+ const API_URL3 = apiUrl || `${getApiUrl()}/api/v1`;
88
88
  const spinner = ora("Reading schema...").start();
89
89
  try {
90
90
  if (!await fs.pathExists(schemaPath)) {
@@ -114,7 +114,7 @@ async function deploySchemaToServer(projectId, token, schemaPath, environment, d
114
114
  return;
115
115
  }
116
116
  spinner.text = "Deploying schema...";
117
- const schemaUrl = `${API_URL2}/projects/${projectId}/env/${environment}/deploy/schema`;
117
+ const schemaUrl = `${API_URL3}/projects/${projectId}/env/${environment}/deploy/schema`;
118
118
  console.log(chalk.dim(`
119
119
  URL: ${schemaUrl}`));
120
120
  const rlsConfigs = tables.filter((t) => t.rls).map((t) => ({
@@ -188,7 +188,8 @@ ${messages.join("\n")}`);
188
188
  }
189
189
  return result.outputFiles[0].text;
190
190
  }
191
- async function deployFunctionsToServer(projectId, token, functionsDir, environment, dryRun) {
191
+ async function deployFunctionsToServer(projectId, token, functionsDir, environment, dryRun, apiUrl) {
192
+ const API_URL3 = apiUrl || `${getApiUrl()}/api/v1`;
192
193
  const spinner = ora("Reading functions...").start();
193
194
  try {
194
195
  if (!await fs.pathExists(functionsDir)) {
@@ -245,7 +246,7 @@ ${helperSource}`;
245
246
  return;
246
247
  }
247
248
  spinner.text = "Deploying functions...";
248
- const functionsUrl = `${API_URL2}/projects/${projectId}/env/${environment}/deploy/functions`;
249
+ const functionsUrl = `${API_URL3}/projects/${projectId}/env/${environment}/deploy/functions`;
249
250
  console.log(chalk.dim(`
250
251
  URL: ${functionsUrl}`));
251
252
  const response = await fetch(functionsUrl, {
@@ -583,8 +584,7 @@ function parseFunctions(moduleName, source) {
583
584
  }
584
585
 
585
586
  // src/commands/init.ts
586
- var isDev2 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
587
- var API_URL3 = isDev2 ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
587
+ var API_URL = `${getApiUrl()}/api/v1`;
588
588
  async function getLatestVersion(packageName) {
589
589
  try {
590
590
  const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
@@ -686,7 +686,7 @@ ${packageManager} is not installed on your system.`));
686
686
  await scaffoldVanillaProject(projectName, projectPath, spinner);
687
687
  }
688
688
  spinner.text = "Creating project on Tether...";
689
- const response = await fetch(`${API_URL3}/projects`, {
689
+ const response = await fetch(`${API_URL}/projects`, {
690
690
  method: "POST",
691
691
  headers: {
692
692
  "Content-Type": "application/json",
@@ -865,7 +865,7 @@ async function scaffoldVanillaProject(projectName, projectPath, spinner) {
865
865
 
866
866
  const tether = createClient({
867
867
  projectId: process.env.TETHER_PROJECT_ID!,
868
- url: process.env.TETHER_URL || 'https://tether-api.strands.gg',
868
+ url: process.env.TETHER_URL || '${getApiUrl()}',
869
869
  });
870
870
 
871
871
  async function main() {
@@ -902,7 +902,7 @@ export default defineConfig({
902
902
  projectId: process.env.TETHER_PROJECT_ID,
903
903
 
904
904
  // API endpoint (defaults to Tether Cloud)
905
- url: process.env.TETHER_URL || 'https://tether-api.strands.gg',
905
+ url: process.env.TETHER_URL || '${getApiUrl()}',
906
906
  });
907
907
  `
908
908
  );
@@ -1134,7 +1134,7 @@ export default defineNuxtConfig({
1134
1134
 
1135
1135
  tether: {
1136
1136
  projectId: process.env.TETHER_PROJECT_ID,
1137
- url: process.env.TETHER_URL || 'https://tether-api.strands.gg',
1137
+ url: process.env.TETHER_URL || '${getApiUrl()}',
1138
1138
  },
1139
1139
  });
1140
1140
  `
@@ -1162,7 +1162,7 @@ export default defineNuxtConfig({
1162
1162
 
1163
1163
  tether: {
1164
1164
  projectId: process.env.TETHER_PROJECT_ID,
1165
- url: process.env.TETHER_URL || 'https://tether-api.strands.gg',
1165
+ url: process.env.TETHER_URL || '${getApiUrl()}',
1166
1166
  },
1167
1167
  });
1168
1168
  `
@@ -1182,7 +1182,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
1182
1182
  return (
1183
1183
  <TetherProvider
1184
1184
  projectId={process.env.NEXT_PUBLIC_TETHER_PROJECT_ID!}
1185
- url={process.env.NEXT_PUBLIC_TETHER_URL || 'https://tether-api.strands.gg'}
1185
+ url={process.env.NEXT_PUBLIC_TETHER_URL || '${getApiUrl()}'}
1186
1186
  >
1187
1187
  {children}
1188
1188
  </TetherProvider>
@@ -1228,7 +1228,7 @@ import { PUBLIC_TETHER_PROJECT_ID, PUBLIC_TETHER_URL } from '$env/static/public'
1228
1228
 
1229
1229
  export const tether = createClient({
1230
1230
  projectId: PUBLIC_TETHER_PROJECT_ID,
1231
- url: PUBLIC_TETHER_URL || 'https://tether-api.strands.gg',
1231
+ url: PUBLIC_TETHER_URL || '${getApiUrl()}',
1232
1232
  });
1233
1233
  `
1234
1234
  );
@@ -1243,8 +1243,8 @@ PUBLIC_TETHER_PROJECT_ID=\${TETHER_PROJECT_ID}
1243
1243
  }
1244
1244
  }
1245
1245
  }
1246
- function getInstallCommand(pm, isDev7 = false) {
1247
- const devFlag = isDev7 ? pm === "npm" ? "-D" : pm === "yarn" ? "-D" : pm === "pnpm" ? "-D" : "-d" : "";
1246
+ function getInstallCommand(pm, isDev2 = false) {
1247
+ const devFlag = isDev2 ? pm === "npm" ? "-D" : pm === "yarn" ? "-D" : pm === "pnpm" ? "-D" : "-d" : "";
1248
1248
  return `${pm} ${pm === "npm" ? "install" : "add"} ${devFlag}`.trim();
1249
1249
  }
1250
1250
  async function installTetherPackages(projectPath, template, packageManager) {
@@ -1689,8 +1689,6 @@ import fs3 from "fs-extra";
1689
1689
  import path3 from "path";
1690
1690
  import { spawn } from "child_process";
1691
1691
  import { watch } from "chokidar";
1692
- var isDev3 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
1693
- var API_BASE = isDev3 ? "http://localhost:3001" : "https://tether-api.strands.gg";
1694
1692
  var frameworkProcess = null;
1695
1693
  var schemaWatcher = null;
1696
1694
  var functionsWatcher = null;
@@ -1706,7 +1704,7 @@ async function runGenerate(spinner) {
1706
1704
  }
1707
1705
  isGenerating = true;
1708
1706
  try {
1709
- const { generateTypes: generateTypes2 } = await import("./generate-DYQ67MHG.js");
1707
+ const { generateTypes: generateTypes2 } = await import("./generate-7DINPVQ5.js");
1710
1708
  spinner.text = "Regenerating types...";
1711
1709
  await generateTypes2({ silent: true });
1712
1710
  spinner.succeed("Types regenerated");
@@ -1725,7 +1723,7 @@ async function runGenerate(spinner) {
1725
1723
  }
1726
1724
  }
1727
1725
  }
1728
- async function runDeploy(what, projectId, token, schemaPath, functionsDir, environment, spinner) {
1726
+ async function runDeploy(what, projectId, token, schemaPath, functionsDir, environment, spinner, apiUrl) {
1729
1727
  if (isDeploying) {
1730
1728
  if (pendingDeploy === null) pendingDeploy = what;
1731
1729
  else if (pendingDeploy !== what) pendingDeploy = "all";
@@ -1736,7 +1734,7 @@ async function runDeploy(what, projectId, token, schemaPath, functionsDir, envir
1736
1734
  if (what === "schema" || what === "all") {
1737
1735
  spinner.text = "Deploying schema to development...";
1738
1736
  try {
1739
- await deploySchemaToServer(projectId, token, schemaPath, environment);
1737
+ await deploySchemaToServer(projectId, token, schemaPath, environment, false, apiUrl);
1740
1738
  } catch (e) {
1741
1739
  console.log(chalk3.yellow(` Schema deploy failed: ${e instanceof Error ? e.message : e}`));
1742
1740
  }
@@ -1744,7 +1742,7 @@ async function runDeploy(what, projectId, token, schemaPath, functionsDir, envir
1744
1742
  if (what === "functions" || what === "all") {
1745
1743
  spinner.text = "Deploying functions to development...";
1746
1744
  try {
1747
- await deployFunctionsToServer(projectId, token, functionsDir, environment);
1745
+ await deployFunctionsToServer(projectId, token, functionsDir, environment, false, apiUrl);
1748
1746
  } catch (e) {
1749
1747
  console.log(chalk3.yellow(` Functions deploy failed: ${e instanceof Error ? e.message : e}`));
1750
1748
  }
@@ -1756,7 +1754,7 @@ async function runDeploy(what, projectId, token, schemaPath, functionsDir, envir
1756
1754
  if (pendingDeploy) {
1757
1755
  const next = pendingDeploy;
1758
1756
  pendingDeploy = null;
1759
- setTimeout(() => runDeploy(next, projectId, token, schemaPath, functionsDir, environment, spinner), 100);
1757
+ setTimeout(() => runDeploy(next, projectId, token, schemaPath, functionsDir, environment, spinner, apiUrl), 100);
1760
1758
  }
1761
1759
  }
1762
1760
  }
@@ -1813,8 +1811,9 @@ async function validateFunctions(functionsDir) {
1813
1811
  }
1814
1812
  return { valid: errors.length === 0, errors };
1815
1813
  }
1816
- function connectToEnvironment(projectId, environment, token, spinner) {
1817
- const wsBase = API_BASE.replace("https://", "wss://").replace("http://", "ws://");
1814
+ function connectToEnvironment(projectId, environment, token, spinner, apiBase) {
1815
+ const base = apiBase || getApiUrl();
1816
+ const wsBase = base.replace("https://", "wss://").replace("http://", "ws://");
1818
1817
  const wsUrl = environment && environment !== "production" ? `${wsBase}/ws/${projectId}/${environment}?token=${encodeURIComponent(token)}` : `${wsBase}/ws/${projectId}?token=${encodeURIComponent(token)}`;
1819
1818
  let reconnectAttempts = 0;
1820
1819
  const maxReconnectAttempts = 10;
@@ -1935,6 +1934,7 @@ async function devCommand(options) {
1935
1934
  const devCmd = config.dev?.command || getFrameworkDevCommand(framework);
1936
1935
  const environment = options.env || config.environment || "development";
1937
1936
  const isLocal = options.local ?? false;
1937
+ const apiUrl = `${getApiUrl(config)}/api/v1`;
1938
1938
  console.log(chalk3.bold("\n\u26A1 Starting Tether development server\n"));
1939
1939
  if (framework !== "unknown") {
1940
1940
  console.log(chalk3.dim(` Framework: ${framework}`));
@@ -1976,12 +1976,12 @@ async function devCommand(options) {
1976
1976
  }
1977
1977
  }
1978
1978
  spinner.text = "Generating types...";
1979
- const { generateTypes: generateTypes2 } = await import("./generate-DYQ67MHG.js");
1979
+ const { generateTypes: generateTypes2 } = await import("./generate-7DINPVQ5.js");
1980
1980
  await generateTypes2({ silent: true });
1981
1981
  spinner.succeed("Types generated");
1982
1982
  if (config.projectId) {
1983
1983
  spinner.start("Deploying to development environment...");
1984
- await runDeploy("all", config.projectId, credentials.accessToken, schemaPath, functionsDir, environment, spinner);
1984
+ await runDeploy("all", config.projectId, credentials.accessToken, schemaPath, functionsDir, environment, spinner, apiUrl);
1985
1985
  } else {
1986
1986
  spinner.warn("No project ID configured \u2014 skipping auto-deploy");
1987
1987
  }
@@ -2003,7 +2003,7 @@ async function devCommand(options) {
2003
2003
  }
2004
2004
  await runGenerate(spinner);
2005
2005
  if (config.projectId) {
2006
- await runDeploy("schema", config.projectId, credentials.accessToken, schemaPath, functionsDir, environment, spinner);
2006
+ await runDeploy("schema", config.projectId, credentials.accessToken, schemaPath, functionsDir, environment, spinner, apiUrl);
2007
2007
  }
2008
2008
  });
2009
2009
  }
@@ -2027,13 +2027,13 @@ async function devCommand(options) {
2027
2027
  }
2028
2028
  await runGenerate(spinner);
2029
2029
  if (config.projectId) {
2030
- await runDeploy("functions", config.projectId, credentials.accessToken, schemaPath, functionsDir, environment, spinner);
2030
+ await runDeploy("functions", config.projectId, credentials.accessToken, schemaPath, functionsDir, environment, spinner, apiUrl);
2031
2031
  }
2032
2032
  });
2033
2033
  }
2034
2034
  spinner.succeed("File watchers ready");
2035
2035
  if (config.projectId) {
2036
- connectToEnvironment(config.projectId, environment, credentials.accessToken, spinner);
2036
+ connectToEnvironment(config.projectId, environment, credentials.accessToken, spinner, getApiUrl(config));
2037
2037
  }
2038
2038
  if (devCmd && !options.skipFramework) {
2039
2039
  spinner.start(`Starting ${framework} dev server...`);
@@ -2061,9 +2061,9 @@ import ora4 from "ora";
2061
2061
  import os from "os";
2062
2062
  import { exec } from "child_process";
2063
2063
  import readline from "readline";
2064
- var isDev4 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
2065
- var API_URL4 = isDev4 ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
2066
- var AUTH_URL = isDev4 ? "http://localhost:3000/cli" : "https://tthr.io/cli";
2064
+ var isDev = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
2065
+ var API_URL2 = `${getApiUrl()}/api/v1`;
2066
+ var AUTH_URL = isDev ? "http://localhost:3000/cli" : "https://tthr.io/cli";
2067
2067
  async function loginCommand() {
2068
2068
  console.log(chalk4.bold("\u26A1 Login to Tether\n"));
2069
2069
  const existing = await getCredentials();
@@ -2152,7 +2152,7 @@ async function requestDeviceCode() {
2152
2152
  const userCode = generateUserCode();
2153
2153
  const deviceCode = crypto.randomUUID();
2154
2154
  const deviceName = os.hostname();
2155
- const response = await fetch(`${API_URL4}/auth/device`, {
2155
+ const response = await fetch(`${API_URL2}/auth/device`, {
2156
2156
  method: "POST",
2157
2157
  headers: { "Content-Type": "application/json" },
2158
2158
  body: JSON.stringify({ userCode, deviceCode, deviceName })
@@ -2186,7 +2186,7 @@ async function pollForApproval(deviceCode, interval, expiresIn) {
2186
2186
  while (Date.now() < expiresAt) {
2187
2187
  await sleep(interval * 1e3);
2188
2188
  spinner.text = `Checking... ${chalk4.dim(`(${Math.ceil((expiresAt - Date.now()) / 1e3)}s remaining)`)}`;
2189
- const response = await fetch(`${API_URL4}/auth/device/${deviceCode}`, {
2189
+ const response = await fetch(`${API_URL2}/auth/device/${deviceCode}`, {
2190
2190
  method: "GET"
2191
2191
  }).catch(() => null);
2192
2192
  updateCountdown();
@@ -2278,18 +2278,18 @@ function detectPackageManager() {
2278
2278
  }
2279
2279
  return "npm";
2280
2280
  }
2281
- function getInstallCommand2(pm, packages, isDev7) {
2281
+ function getInstallCommand2(pm, packages, isDev2) {
2282
2282
  const packagesStr = packages.join(" ");
2283
2283
  switch (pm) {
2284
2284
  case "bun":
2285
- return isDev7 ? `bun add -d ${packagesStr}` : `bun add ${packagesStr}`;
2285
+ return isDev2 ? `bun add -d ${packagesStr}` : `bun add ${packagesStr}`;
2286
2286
  case "pnpm":
2287
- return isDev7 ? `pnpm add -D ${packagesStr}` : `pnpm add ${packagesStr}`;
2287
+ return isDev2 ? `pnpm add -D ${packagesStr}` : `pnpm add ${packagesStr}`;
2288
2288
  case "yarn":
2289
- return isDev7 ? `yarn add -D ${packagesStr}` : `yarn add ${packagesStr}`;
2289
+ return isDev2 ? `yarn add -D ${packagesStr}` : `yarn add ${packagesStr}`;
2290
2290
  case "npm":
2291
2291
  default:
2292
- return isDev7 ? `npm install -D ${packagesStr}` : `npm install ${packagesStr}`;
2292
+ return isDev2 ? `npm install -D ${packagesStr}` : `npm install ${packagesStr}`;
2293
2293
  }
2294
2294
  }
2295
2295
  async function getLatestVersion2(packageName) {
@@ -2398,8 +2398,6 @@ import chalk6 from "chalk";
2398
2398
  import ora6 from "ora";
2399
2399
  import fs5 from "fs-extra";
2400
2400
  import path5 from "path";
2401
- var isDev5 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
2402
- var API_URL5 = isDev5 ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
2403
2401
  async function execCommand(sql) {
2404
2402
  if (!sql || sql.trim() === "") {
2405
2403
  console.log(chalk6.red("\nError: SQL query required"));
@@ -2419,9 +2417,11 @@ async function execCommand(sql) {
2419
2417
  console.log(chalk6.dim("Make sure TETHER_PROJECT_ID is set in your .env file\n"));
2420
2418
  process.exit(1);
2421
2419
  }
2420
+ const config = await loadConfig();
2421
+ const API_URL3 = `${getApiUrl(config)}/api/v1`;
2422
2422
  const spinner = ora6("Executing query...").start();
2423
2423
  try {
2424
- const response = await fetch(`${API_URL5}/projects/${projectId}/exec`, {
2424
+ const response = await fetch(`${API_URL3}/projects/${projectId}/exec`, {
2425
2425
  method: "POST",
2426
2426
  headers: {
2427
2427
  "Content-Type": "application/json",
@@ -2471,8 +2471,10 @@ import chalk7 from "chalk";
2471
2471
  import ora7 from "ora";
2472
2472
  import fs6 from "fs-extra";
2473
2473
  import path6 from "path";
2474
- var isDev6 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
2475
- var API_URL6 = isDev6 ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
2474
+ async function resolveApiUrl() {
2475
+ const config = await loadConfig();
2476
+ return `${getApiUrl(config)}/api/v1`;
2477
+ }
2476
2478
  async function getProjectId() {
2477
2479
  const envPath = path6.resolve(process.cwd(), ".env");
2478
2480
  let projectId;
@@ -2491,9 +2493,10 @@ async function getProjectId() {
2491
2493
  async function envListCommand() {
2492
2494
  const credentials = await requireAuth();
2493
2495
  const projectId = await getProjectId();
2496
+ const API_URL3 = await resolveApiUrl();
2494
2497
  const spinner = ora7("Fetching environments...").start();
2495
2498
  try {
2496
- const response = await fetch(`${API_URL6}/projects/${projectId}/environments`, {
2499
+ const response = await fetch(`${API_URL3}/projects/${projectId}/environments`, {
2497
2500
  headers: {
2498
2501
  "Authorization": `Bearer ${credentials.accessToken}`
2499
2502
  }
@@ -2523,6 +2526,7 @@ async function envListCommand() {
2523
2526
  async function envCreateCommand(name, options) {
2524
2527
  const credentials = await requireAuth();
2525
2528
  const projectId = await getProjectId();
2529
+ const API_URL3 = await resolveApiUrl();
2526
2530
  const normalizedName = name.toLowerCase();
2527
2531
  if (!/^[a-z][a-z0-9-_]*$/.test(normalizedName)) {
2528
2532
  console.log(chalk7.red("\nError: Invalid environment name"));
@@ -2536,7 +2540,7 @@ async function envCreateCommand(name, options) {
2536
2540
  body.cloneFrom = options.from;
2537
2541
  spinner.text = `Creating environment '${normalizedName}' from '${options.from}'...`;
2538
2542
  }
2539
- const response = await fetch(`${API_URL6}/projects/${projectId}/environments`, {
2543
+ const response = await fetch(`${API_URL3}/projects/${projectId}/environments`, {
2540
2544
  method: "POST",
2541
2545
  headers: {
2542
2546
  "Content-Type": "application/json",
@@ -2565,9 +2569,10 @@ async function envCreateCommand(name, options) {
2565
2569
  async function envDeleteCommand(name) {
2566
2570
  const credentials = await requireAuth();
2567
2571
  const projectId = await getProjectId();
2572
+ const API_URL3 = await resolveApiUrl();
2568
2573
  const spinner = ora7(`Deleting environment '${name}'...`).start();
2569
2574
  try {
2570
- const response = await fetch(`${API_URL6}/projects/${projectId}/environments/${name}`, {
2575
+ const response = await fetch(`${API_URL3}/projects/${projectId}/environments/${name}`, {
2571
2576
  method: "DELETE",
2572
2577
  headers: {
2573
2578
  "Authorization": `Bearer ${credentials.accessToken}`
@@ -2587,9 +2592,10 @@ async function envDeleteCommand(name) {
2587
2592
  async function envDefaultCommand(name) {
2588
2593
  const credentials = await requireAuth();
2589
2594
  const projectId = await getProjectId();
2595
+ const API_URL3 = await resolveApiUrl();
2590
2596
  const spinner = ora7(`Setting '${name}' as default environment...`).start();
2591
2597
  try {
2592
- const response = await fetch(`${API_URL6}/projects/${projectId}/environments/default`, {
2598
+ const response = await fetch(`${API_URL3}/projects/${projectId}/environments/default`, {
2593
2599
  method: "PATCH",
2594
2600
  headers: {
2595
2601
  "Content-Type": "application/json",
@@ -2654,7 +2660,9 @@ async function migrateSystemColumnsCommand(options) {
2654
2660
  `));
2655
2661
  const spinner = ora8("Analysing database tables...").start();
2656
2662
  try {
2657
- const baseUrl = `${API_URL}/projects/${projectId}/env/${environment}/migrate/system-columns`;
2663
+ const config = await loadConfig();
2664
+ const API_URL3 = `${getApiUrl(config)}/api/v1`;
2665
+ const baseUrl = `${API_URL3}/projects/${projectId}/env/${environment}/migrate/system-columns`;
2658
2666
  const dryRunResponse = await fetch(`${baseUrl}?dry_run=true`, {
2659
2667
  method: "POST",
2660
2668
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tthr",
3
- "version": "0.3.11",
3
+ "version": "0.3.14",
4
4
  "description": "Tether CLI - project scaffolding and deployment",
5
5
  "type": "module",
6
6
  "bin": {