@catladder/cli 3.34.2 → 3.36.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/dist/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +2 -2
- package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js +3 -11
- package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js.map +1 -1
- package/dist/cli/src/gcloud/cloudSql/parseConnectionString.d.ts +9 -0
- package/dist/cli/src/gcloud/cloudSql/parseConnectionString.js +22 -0
- package/dist/cli/src/gcloud/cloudSql/parseConnectionString.js.map +1 -0
- package/dist/pipeline/src/deploy/base/deploy.js +34 -30
- package/dist/pipeline/src/deploy/base/deploy.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts +3 -13
- package/src/gcloud/cloudSql/parseConnectionString.ts +28 -0
package/package.json
CHANGED
|
@@ -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 {
|
|
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
|
|
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
|
|
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
|
+
}
|