ante-erp-cli 1.3.2 → 1.4.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.3.2",
3
+ "version": "1.4.1",
4
4
  "description": "Comprehensive CLI tool for managing ANTE ERP self-hosted installations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,7 +5,6 @@ import { readdirSync } from 'fs';
5
5
  import { execa } from 'execa';
6
6
  import Table from 'cli-table3';
7
7
  import { getInstallDir } from '../utils/config.js';
8
- import { execInContainer } from '../utils/docker.js';
9
8
 
10
9
  /**
11
10
  * Create backup of ANTE ERP
@@ -3,7 +3,7 @@ import inquirer from 'inquirer';
3
3
  import { Listr } from 'listr2';
4
4
  import { join } from 'path';
5
5
  import { getInstallDir } from '../utils/config.js';
6
- import { pullImages, stopServices, startServices } from '../utils/docker.js';
6
+ import { pullImages, stopServices, startServices, waitForServiceHealthy, runMigrations } from '../utils/docker.js';
7
7
  import { backup } from './backup.js';
8
8
 
9
9
  /**
@@ -66,6 +66,30 @@ export async function update(options) {
66
66
  task: async () => {
67
67
  await startServices(composeFile);
68
68
  }
69
+ },
70
+ {
71
+ title: 'Waiting for backend to be healthy',
72
+ task: async () => {
73
+ const healthy = await waitForServiceHealthy(composeFile, 'backend', 120);
74
+ if (!healthy) {
75
+ throw new Error('Backend did not become healthy within 120 seconds');
76
+ }
77
+ }
78
+ },
79
+ {
80
+ title: 'Running database migrations',
81
+ task: async (ctx, task) => {
82
+ const result = await runMigrations(composeFile);
83
+
84
+ if (!result.success) {
85
+ throw new Error(`Migration failed:\n${result.output}`);
86
+ }
87
+
88
+ // Show migration output if there were migrations run
89
+ if (result.output && result.output.trim()) {
90
+ task.output = result.output;
91
+ }
92
+ }
69
93
  }
70
94
  ]);
71
95
 
@@ -83,6 +83,12 @@ LOG_LEVEL=info
83
83
  LOG_FORMAT=json
84
84
  AUDIT_LOG_ENABLED=true
85
85
 
86
+ # ------------------------------------------------------------------------------
87
+ # MIGRATIONS
88
+ # ------------------------------------------------------------------------------
89
+ RUN_MIGRATIONS_ON_STARTUP=true
90
+ AUTO_MIGRATE=false
91
+
86
92
  # ==============================================================================
87
93
  `;
88
94
  }
@@ -224,3 +224,35 @@ export async function pruneDocker() {
224
224
  });
225
225
  }
226
226
 
227
+ /**
228
+ * Run Prisma migrations in backend container
229
+ * @param {string} composeFile - Path to docker-compose.yml
230
+ * @returns {Promise<{success: boolean, output: string}>}
231
+ */
232
+ export async function runMigrations(composeFile) {
233
+ try {
234
+ const { stdout, stderr } = await execa('docker', [
235
+ 'compose',
236
+ '-f',
237
+ composeFile,
238
+ 'exec',
239
+ '-T',
240
+ 'backend',
241
+ 'npx',
242
+ 'prisma',
243
+ 'migrate',
244
+ 'deploy'
245
+ ]);
246
+
247
+ return {
248
+ success: true,
249
+ output: stdout || stderr
250
+ };
251
+ } catch (error) {
252
+ return {
253
+ success: false,
254
+ output: error.stdout || error.stderr || error.message
255
+ };
256
+ }
257
+ }
258
+