@catladder/cli 1.73.0 → 1.75.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
@@ -24,7 +24,7 @@
24
24
  "node": ">=12.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@catladder/pipeline": "1.73.0",
27
+ "@catladder/pipeline": "1.75.0",
28
28
  "@kubernetes/client-node": "^0.16.2",
29
29
  "@tsconfig/node14": "^1.0.1",
30
30
  "@types/common-tags": "^1.8.0",
@@ -57,5 +57,5 @@
57
57
  "typescript": "^4.5.4",
58
58
  "vorpal": "^1.12.0"
59
59
  },
60
- "version": "1.73.0"
60
+ "version": "1.75.0"
61
61
  }
@@ -36,16 +36,29 @@ export default async (vorpal: Vorpal) =>
36
36
  type: "input",
37
37
  name: "sourceInstance",
38
38
 
39
- message: "Source instance (connection string)? 🤔 ",
39
+ message: "Source instance (connection string or 'local')? 🤔 ",
40
40
  });
41
41
 
42
- const SOURCE_INSTANCE_PORT = 54399;
43
- const TARGET_INSTANCE_PORT = 54499;
42
+ let sourceProxy: { stop: () => void };
44
43
 
45
- const sourceProxy = await createProxy(
46
- sourceInstance,
47
- SOURCE_INSTANCE_PORT
48
- );
44
+ let targetProxy: { stop: () => void };
45
+
46
+ let sourcePort: number;
47
+ let targetPort: number;
48
+
49
+ if (sourceInstance === "local") {
50
+ const { sourceLocalPort } = await this.prompt({
51
+ type: "number",
52
+ name: "sourceLocalPort",
53
+ default: 5432,
54
+
55
+ message: "Local Port for source? 🤔 ",
56
+ });
57
+ sourcePort = sourceLocalPort;
58
+ } else {
59
+ sourcePort = 54399;
60
+ sourceProxy = await createProxy(sourceInstance, sourcePort);
61
+ }
49
62
 
50
63
  const { sourcePassword } = await this.prompt({
51
64
  type: "input",
@@ -65,13 +78,22 @@ export default async (vorpal: Vorpal) =>
65
78
  type: "input",
66
79
  name: "targetInstance",
67
80
 
68
- message: "Targe INSTANCE (connection string)? 🤔 ",
81
+ message: "Targe INSTANCE (connection string or 'local')? 🤔 ",
69
82
  });
70
83
 
71
- const targetProxy = await createProxy(
72
- targetInstance,
73
- TARGET_INSTANCE_PORT
74
- );
84
+ if (targetInstance === "local") {
85
+ const { targetLocalPort } = await this.prompt({
86
+ type: "number",
87
+ name: "targetLocalPort",
88
+ default: 5432,
89
+
90
+ message: "Local Port for target? 🤔 ",
91
+ });
92
+ targetPort = targetLocalPort;
93
+ } else {
94
+ targetPort = 54499;
95
+ targetProxy = await createProxy(targetInstance, targetPort);
96
+ }
75
97
 
76
98
  const { targetPassword } = await this.prompt({
77
99
  type: "input",
@@ -98,7 +120,7 @@ export default async (vorpal: Vorpal) =>
98
120
  }
99
121
 
100
122
  const targetPSQL = (command: string) =>
101
- `PGPASSWORD=${targetPassword} psql -p ${TARGET_INSTANCE_PORT} --host=localhost --user=postgres -q ${command}`;
123
+ `PGPASSWORD=${targetPassword} psql -p ${targetPort} --host=localhost --user=postgres -q ${command}`;
102
124
 
103
125
  const copyDBScript = `
104
126
  set -e
@@ -108,7 +130,7 @@ export default async (vorpal: Vorpal) =>
108
130
  dumptmp=$(mktemp /tmp/dump.XXXXXX)
109
131
 
110
132
  echo "Dumping file to $dumptmp"
111
- pg_dump --dbname=postgres://postgres:${sourcePassword}@localhost:${SOURCE_INSTANCE_PORT}/${sourceDbName} --no-owner --no-privileges > $dumptmp
133
+ pg_dump --dbname=postgres://postgres:${sourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges > $dumptmp
112
134
  echo "dump done"
113
135
  ${targetPSQL(
114
136
  `-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`
@@ -126,7 +148,7 @@ export default async (vorpal: Vorpal) =>
126
148
  try {
127
149
  await spawn(copyDBScript, [], { shell: "bash", stdio: "inherit" });
128
150
  } finally {
129
- sourceProxy.stop();
130
- targetProxy.stop();
151
+ sourceProxy?.stop();
152
+ targetProxy?.stop();
131
153
  }
132
154
  });