@catladder/cli 3.34.2 → 3.35.0

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
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.34.2",
56
+ "version": "3.35.0",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -7,7 +7,7 @@ import type { CloudSqlBackgroundProxy } from "../../../../../gcloud/cloudSql/sta
7
7
  import { startCloudSqlProxyInBackground } from "../../../../../gcloud/cloudSql/startProxy";
8
8
  import { envAndComponents } from "../utils/autocompletions";
9
9
 
10
- import { ConnectionStringParser } from "connection-string-parser";
10
+ import { parseConnectionString } from "../../../../../gcloud/cloudSql/parseConnectionString";
11
11
  import { spawnCopyDb } from "../../../../../gcloud/cloudSql/copyDb";
12
12
 
13
13
  export default async (vorpal: Vorpal) =>
@@ -60,12 +60,7 @@ export default async (vorpal: Vorpal) =>
60
60
  };
61
61
 
62
62
  if (sourceEnv === "local") {
63
- const parser = new ConnectionStringParser({
64
- scheme: "postgres",
65
- hosts: [],
66
- });
67
-
68
- const parsersResult = parser.parse(
63
+ const parsersResult = parseConnectionString(
69
64
  sourceEnvVars.DATABASE_URL.toString(),
70
65
  );
71
66
  sourcePort = parsersResult.hosts?.[0]?.port;
@@ -107,12 +102,7 @@ export default async (vorpal: Vorpal) =>
107
102
  );
108
103
 
109
104
  if (targetEnv === "local") {
110
- const parser = new ConnectionStringParser({
111
- scheme: "postgres",
112
- hosts: [],
113
- });
114
-
115
- const parsersResult = parser.parse(
105
+ const parsersResult = parseConnectionString(
116
106
  targetEnvVars.DATABASE_URL.toString(),
117
107
  );
118
108
 
@@ -0,0 +1,28 @@
1
+ import {
2
+ ConnectionStringParser,
3
+ type IConnectionStringParameters,
4
+ } from "connection-string-parser";
5
+
6
+ /**
7
+ * Parses a PostgreSQL connection string.
8
+ * Accepts both postgres:// and postgresql:// schemes and normalizes to postgresql://
9
+ *
10
+ * @param connectionString - The connection string to parse (e.g., "postgresql://user:pass@localhost:5432/dbname")
11
+ * @returns Parsed connection string parameters
12
+ */
13
+ export function parseConnectionString(
14
+ connectionString: string,
15
+ ): IConnectionStringParameters {
16
+ const parser = new ConnectionStringParser({
17
+ scheme: "postgresql",
18
+ hosts: [],
19
+ });
20
+
21
+ // Normalize postgres:// to postgresql:// (the official IANA scheme)
22
+ const normalizedConnectionString = connectionString.replace(
23
+ /^postgres:\/\//,
24
+ "postgresql://",
25
+ );
26
+
27
+ return parser.parse(normalizedConnectionString);
28
+ }