ante-erp-cli 1.10.0 → 1.10.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ante-erp-cli",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Comprehensive CLI tool for managing ANTE ERP self-hosted installations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -153,41 +153,79 @@ export async function dumpDatabase(connectionInfo, outputDir) {
153
153
  // Convert to absolute path for Docker volume mount
154
154
  const absoluteOutputDir = resolve(outputDir);
155
155
 
156
- // Build mongodump arguments
157
- const dumpArgs = ['run', '--rm', '-v', `${absoluteOutputDir}:/backups`, 'mongo:latest', 'mongodump'];
158
-
159
- // Build connection URI
160
- let dumpHost = host;
156
+ // For localhost connections (CLI installations), use docker exec on existing container
161
157
  if (host === 'localhost' || host === '127.0.0.1') {
162
- dumpHost = 'host.docker.internal';
163
- dumpArgs.splice(1, 0, '--add-host=host.docker.internal:host-gateway');
164
- }
158
+ // Check if ante-mongodb container exists
159
+ try {
160
+ await execa('docker', ['inspect', 'ante-mongodb'], { reject: false });
161
+
162
+ // Dump inside the container to /tmp/mongodb-dump
163
+ const dumpArgs = ['exec', 'ante-mongodb', 'mongodump'];
164
+ if (user) dumpArgs.push('--username', user);
165
+ if (password) dumpArgs.push('--password', password);
166
+ if (authDatabase) dumpArgs.push('--authenticationDatabase', authDatabase);
167
+ dumpArgs.push('--db', database);
168
+ dumpArgs.push('--out', '/tmp/mongodb-dump');
169
+
170
+ await execa('docker', dumpArgs, {
171
+ timeout: 600000 // 10 minute timeout
172
+ });
165
173
 
166
- // Add connection parameters
167
- if (isSrv) {
168
- // For SRV connections, use --uri
169
- const protocol = 'mongodb+srv://';
170
- const auth = user && password ? `${user}:${password}@` : '';
171
- const authDbPart = authDatabase && authDatabase !== database ? `?authSource=${authDatabase}` : '';
172
- const uri = `${protocol}${auth}${dumpHost}/${database}${authDbPart}`;
173
- dumpArgs.push('--uri', uri);
174
+ // Copy dump from container to host
175
+ await execa('docker', [
176
+ 'cp',
177
+ `ante-mongodb:/tmp/mongodb-dump/${database}`,
178
+ join(outputDir, database)
179
+ ]);
180
+
181
+ // Clean up dump inside container
182
+ await execa('docker', [
183
+ 'exec',
184
+ 'ante-mongodb',
185
+ 'rm',
186
+ '-rf',
187
+ '/tmp/mongodb-dump'
188
+ ], { reject: false });
189
+
190
+ } catch (containerError) {
191
+ throw new Error('MongoDB container (ante-mongodb) not found or not running');
192
+ }
174
193
  } else {
175
- // For standard connections, use individual parameters
176
- dumpArgs.push('--host', dumpHost);
177
- if (port) dumpArgs.push('--port', port);
178
- if (user) dumpArgs.push('--username', user);
179
- if (password) dumpArgs.push('--password', password);
180
- if (authDatabase) dumpArgs.push('--authenticationDatabase', authDatabase);
181
- dumpArgs.push('--db', database);
182
- }
194
+ // For remote connections, use docker run with volume mount
195
+ const dumpArgs = ['run', '--rm', '-v', `${absoluteOutputDir}:/backups`, 'mongo:latest', 'mongodump'];
183
196
 
184
- // Output directory
185
- dumpArgs.push('--out', '/backups');
197
+ let dumpHost = host;
198
+ if (host === 'localhost' || host === '127.0.0.1') {
199
+ dumpHost = 'host.docker.internal';
200
+ dumpArgs.splice(1, 0, '--add-host=host.docker.internal:host-gateway');
201
+ }
186
202
 
187
- // Execute mongodump
188
- await execa('docker', dumpArgs, {
189
- timeout: 600000 // 10 minute timeout
190
- });
203
+ // Add connection parameters
204
+ if (isSrv) {
205
+ // For SRV connections, use --uri
206
+ const protocol = 'mongodb+srv://';
207
+ const auth = user && password ? `${user}:${password}@` : '';
208
+ const authDbPart = authDatabase && authDatabase !== database ? `?authSource=${authDatabase}` : '';
209
+ const uri = `${protocol}${auth}${dumpHost}/${database}${authDbPart}`;
210
+ dumpArgs.push('--uri', uri);
211
+ } else {
212
+ // For standard connections, use individual parameters
213
+ dumpArgs.push('--host', dumpHost);
214
+ if (port) dumpArgs.push('--port', port);
215
+ if (user) dumpArgs.push('--username', user);
216
+ if (password) dumpArgs.push('--password', password);
217
+ if (authDatabase) dumpArgs.push('--authenticationDatabase', authDatabase);
218
+ dumpArgs.push('--db', database);
219
+ }
220
+
221
+ // Output directory
222
+ dumpArgs.push('--out', '/backups');
223
+
224
+ // Execute mongodump
225
+ await execa('docker', dumpArgs, {
226
+ timeout: 600000 // 10 minute timeout
227
+ });
228
+ }
191
229
 
192
230
  // Verify dump directory was created and has content
193
231
  const dumpDbDir = join(outputDir, database);