ante-erp-cli 1.11.0 → 1.11.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.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "Comprehensive CLI tool for managing ANTE ERP self-hosted installations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,24 +31,44 @@ function readMongoDbUri(installDir) {
31
31
 
32
32
  const envContent = readFileSync(envFile, 'utf-8');
33
33
 
34
- // Try to find MONGODB_URI or MONGODB_URL
34
+ // Try to find MONGODB_URI first (development environment)
35
35
  let match = envContent.match(/^MONGODB_URI=(.+)$/m);
36
- if (!match) {
37
- match = envContent.match(/^MONGODB_URL=(.+)$/m);
36
+ if (match) {
37
+ const mongoUri = match[1].trim();
38
+
39
+ // Validate it looks like a MongoDB URI
40
+ if (!mongoUri.startsWith('mongodb://') && !mongoUri.startsWith('mongodb+srv://')) {
41
+ throw new Error('Invalid MongoDB URI format in .env file');
42
+ }
43
+
44
+ return mongoUri;
38
45
  }
39
46
 
40
- if (!match) {
41
- throw new Error('MONGODB_URI or MONGODB_URL not found in .env file');
47
+ // Try MONGODB_URL as alternate (development environment)
48
+ match = envContent.match(/^MONGODB_URL=(.+)$/m);
49
+ if (match) {
50
+ const mongoUri = match[1].trim();
51
+
52
+ // Validate it looks like a MongoDB URI
53
+ if (!mongoUri.startsWith('mongodb://') && !mongoUri.startsWith('mongodb+srv://')) {
54
+ throw new Error('Invalid MongoDB URI format in .env file');
55
+ }
56
+
57
+ return mongoUri;
42
58
  }
43
59
 
44
- const mongoUri = match[1].trim();
60
+ // CLI installation environment - construct URI from MONGO_PASSWORD
61
+ const mongoPasswordMatch = envContent.match(/^MONGO_PASSWORD=(.+)$/m);
45
62
 
46
- // Validate it looks like a MongoDB URI
47
- if (!mongoUri.startsWith('mongodb://') && !mongoUri.startsWith('mongodb+srv://')) {
48
- throw new Error('Invalid MongoDB URI format in .env file');
63
+ if (!mongoPasswordMatch) {
64
+ throw new Error('MONGO_PASSWORD not found in .env file');
49
65
  }
50
66
 
51
- return mongoUri;
67
+ const mongoPassword = mongoPasswordMatch[1].trim();
68
+
69
+ // Construct MongoDB URI for CLI installation
70
+ // Format: mongodb://ante:password@localhost:27017/ante?authSource=admin
71
+ return `mongodb://ante:${mongoPassword}@localhost:27017/ante?authSource=admin`;
52
72
  }
53
73
 
54
74
  /**
@@ -206,6 +226,7 @@ export async function cloneMongodb(sourceUrl, options = {}) {
206
226
  dumpDirectory = join(backupDir, `clone-backup-${timestamp}`);
207
227
 
208
228
  const dumpSpinner = ora('Creating database dump...').start();
229
+ const dumpStartTime = Date.now();
209
230
  const dumpResult = await dumpDatabase(sourceInfo, dumpDirectory);
210
231
 
211
232
  if (!dumpResult.success) {
@@ -213,7 +234,8 @@ export async function cloneMongodb(sourceUrl, options = {}) {
213
234
  throw new Error(dumpResult.error);
214
235
  }
215
236
 
216
- dumpSpinner.succeed(chalk.green('Database dump completed'));
237
+ const dumpDuration = ((Date.now() - dumpStartTime) / 1000).toFixed(1);
238
+ dumpSpinner.succeed(chalk.green(`Database dump completed (${dumpDuration}s)`));
217
239
  console.log(chalk.gray(` Directory: ${dumpResult.dir}`));
218
240
  console.log(chalk.gray(` Collections: ${dumpResult.collections}`));
219
241
  console.log(chalk.gray(` Size: ${dumpResult.size}`));
@@ -226,6 +248,7 @@ export async function cloneMongodb(sourceUrl, options = {}) {
226
248
  console.log('');
227
249
 
228
250
  const restoreSpinner = ora('Restoring database (collections will be dropped and recreated)...').start();
251
+ const restoreStartTime = Date.now();
229
252
  const restoreResult = await restoreDatabase(dumpDirectory, localInfo, true, composeFile);
230
253
 
231
254
  if (!restoreResult.success) {
@@ -233,7 +256,8 @@ export async function cloneMongodb(sourceUrl, options = {}) {
233
256
  throw new Error(restoreResult.error);
234
257
  }
235
258
 
236
- restoreSpinner.succeed(chalk.green('Database restore completed'));
259
+ const restoreDuration = ((Date.now() - restoreStartTime) / 1000).toFixed(1);
260
+ restoreSpinner.succeed(chalk.green(`Database restore completed (${restoreDuration}s)`));
237
261
  console.log('');
238
262
 
239
263
  // Step 6A: Verify data was restored