ante-erp-cli 1.11.14 → 1.11.16
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 +1 -1
- package/src/commands/update.js +41 -34
package/package.json
CHANGED
package/src/commands/update.js
CHANGED
|
@@ -270,12 +270,26 @@ export async function update(options) {
|
|
|
270
270
|
if (hasPosApp || missingServices.posApp) totalSteps++; // POS App health check
|
|
271
271
|
if (!options.skipCleanup) totalSteps++; // Cleanup step
|
|
272
272
|
|
|
273
|
+
// Pre-calculate step numbers for each task (fixes step numbering bug)
|
|
273
274
|
let currentStep = 0;
|
|
275
|
+
const stepBackup = !options.skipBackup ? ++currentStep : null;
|
|
276
|
+
const stepCheckServices = ++currentStep;
|
|
277
|
+
const stepInstallServices = hasNewServices ? ++currentStep : null;
|
|
278
|
+
const stepPull = ++currentStep;
|
|
279
|
+
const stepStop = ++currentStep;
|
|
280
|
+
const stepStart = ++currentStep;
|
|
281
|
+
const stepBackendHealth = ++currentStep;
|
|
282
|
+
const stepGateHealth = (hasGateApp || missingServices.gateApp) ? ++currentStep : null;
|
|
283
|
+
const stepGuardianHealth = (hasGuardianApp || missingServices.guardianApp) ? ++currentStep : null;
|
|
284
|
+
const stepFacialHealth = (hasFacialWeb || missingServices.facialWeb) ? ++currentStep : null;
|
|
285
|
+
const stepPosHealth = (hasPosApp || missingServices.posApp) ? ++currentStep : null;
|
|
286
|
+
const stepMigrations = ++currentStep;
|
|
287
|
+
const stepCleanup = !options.skipCleanup ? ++currentStep : null;
|
|
274
288
|
|
|
275
289
|
const tasks = new Listr([
|
|
276
290
|
{
|
|
277
|
-
title: formatStepTitle(
|
|
278
|
-
skip: () =>
|
|
291
|
+
title: stepBackup ? formatStepTitle(stepBackup, totalSteps, 'Creating backup') : '',
|
|
292
|
+
skip: () => !stepBackup ? 'Backup skipped' : false,
|
|
279
293
|
task: async () => {
|
|
280
294
|
const timestamp = new Date().toISOString().split('.')[0].replace(/:/g, '-').replace('T', '_');
|
|
281
295
|
await backup({
|
|
@@ -285,12 +299,10 @@ export async function update(options) {
|
|
|
285
299
|
}
|
|
286
300
|
},
|
|
287
301
|
{
|
|
288
|
-
title: formatStepTitle(
|
|
302
|
+
title: formatStepTitle(stepCheckServices, totalSteps, 'Checking for available new services'),
|
|
289
303
|
task: async (ctx, task) => {
|
|
290
|
-
const stepNumber = currentStep; // Capture current step number
|
|
291
|
-
|
|
292
304
|
if (!hasNewServices) {
|
|
293
|
-
task.title = formatStepTitle(
|
|
305
|
+
task.title = formatStepTitle(stepCheckServices, totalSteps, 'Checking for available new services (none found)');
|
|
294
306
|
ctx.missingServices = null;
|
|
295
307
|
return;
|
|
296
308
|
}
|
|
@@ -304,16 +316,14 @@ export async function update(options) {
|
|
|
304
316
|
if (missingServices.facialWeb) availableServices.push('Facial Web');
|
|
305
317
|
if (missingServices.posApp) availableServices.push('POS App');
|
|
306
318
|
|
|
307
|
-
task.title = formatStepTitle(
|
|
319
|
+
task.title = formatStepTitle(stepCheckServices, totalSteps, `Found new services: ${availableServices.join(', ')}`);
|
|
308
320
|
ctx.missingServices = missingServices;
|
|
309
321
|
}
|
|
310
322
|
},
|
|
311
323
|
{
|
|
312
|
-
title: formatStepTitle(
|
|
313
|
-
skip: () => !
|
|
324
|
+
title: stepInstallServices ? formatStepTitle(stepInstallServices, totalSteps, 'Installing new services') : '',
|
|
325
|
+
skip: () => !stepInstallServices ? 'No new services to install' : false,
|
|
314
326
|
task: async (ctx, task) => {
|
|
315
|
-
const stepNumber = currentStep; // Capture current step number
|
|
316
|
-
|
|
317
327
|
const servicesAdded = [];
|
|
318
328
|
if (servicesToInstall.gateApp) servicesAdded.push('Gate App');
|
|
319
329
|
if (servicesToInstall.guardianApp) servicesAdded.push('Guardian App');
|
|
@@ -326,29 +336,29 @@ export async function update(options) {
|
|
|
326
336
|
// Update .env file with new app configuration
|
|
327
337
|
updateEnvFile(envFile, servicesToInstall);
|
|
328
338
|
|
|
329
|
-
task.title = formatStepTitle(
|
|
339
|
+
task.title = formatStepTitle(stepInstallServices, totalSteps, `Installed: ${servicesAdded.join(', ')}`);
|
|
330
340
|
}
|
|
331
341
|
},
|
|
332
342
|
{
|
|
333
|
-
title: formatStepTitle(
|
|
343
|
+
title: formatStepTitle(stepPull, totalSteps, 'Pulling latest Docker images'),
|
|
334
344
|
task: async () => {
|
|
335
345
|
await pullImagesSilent(composeFile);
|
|
336
346
|
}
|
|
337
347
|
},
|
|
338
348
|
{
|
|
339
|
-
title: formatStepTitle(
|
|
349
|
+
title: formatStepTitle(stepStop, totalSteps, 'Stopping services'),
|
|
340
350
|
task: async () => {
|
|
341
351
|
await stopServicesSilent(composeFile);
|
|
342
352
|
}
|
|
343
353
|
},
|
|
344
354
|
{
|
|
345
|
-
title: formatStepTitle(
|
|
355
|
+
title: formatStepTitle(stepStart, totalSteps, 'Starting with new images'),
|
|
346
356
|
task: async () => {
|
|
347
357
|
await startServicesSilent(composeFile);
|
|
348
358
|
}
|
|
349
359
|
},
|
|
350
360
|
{
|
|
351
|
-
title: formatStepTitle(
|
|
361
|
+
title: formatStepTitle(stepBackendHealth, totalSteps, 'Waiting for backend to be healthy'),
|
|
352
362
|
task: async () => {
|
|
353
363
|
const healthy = await waitForServiceHealthy(composeFile, 'backend', 120);
|
|
354
364
|
if (!healthy) {
|
|
@@ -357,8 +367,8 @@ export async function update(options) {
|
|
|
357
367
|
}
|
|
358
368
|
},
|
|
359
369
|
{
|
|
360
|
-
title: formatStepTitle(
|
|
361
|
-
skip: () => !
|
|
370
|
+
title: stepGateHealth ? formatStepTitle(stepGateHealth, totalSteps, 'Waiting for Gate App to be healthy') : '',
|
|
371
|
+
skip: () => !stepGateHealth ? 'Gate App not installed' : false,
|
|
362
372
|
task: async () => {
|
|
363
373
|
const healthy = await waitForServiceHealthy(composeFile, 'gate-app', 60);
|
|
364
374
|
if (!healthy) {
|
|
@@ -367,8 +377,8 @@ export async function update(options) {
|
|
|
367
377
|
}
|
|
368
378
|
},
|
|
369
379
|
{
|
|
370
|
-
title: formatStepTitle(
|
|
371
|
-
skip: () => !
|
|
380
|
+
title: stepGuardianHealth ? formatStepTitle(stepGuardianHealth, totalSteps, 'Waiting for Guardian App to be healthy') : '',
|
|
381
|
+
skip: () => !stepGuardianHealth ? 'Guardian App not installed' : false,
|
|
372
382
|
task: async () => {
|
|
373
383
|
const healthy = await waitForServiceHealthy(composeFile, 'guardian-app', 60);
|
|
374
384
|
if (!healthy) {
|
|
@@ -377,8 +387,8 @@ export async function update(options) {
|
|
|
377
387
|
}
|
|
378
388
|
},
|
|
379
389
|
{
|
|
380
|
-
title: formatStepTitle(
|
|
381
|
-
skip: () => !
|
|
390
|
+
title: stepFacialHealth ? formatStepTitle(stepFacialHealth, totalSteps, 'Waiting for Facial Web to be healthy') : '',
|
|
391
|
+
skip: () => !stepFacialHealth ? 'Facial Web not installed' : false,
|
|
382
392
|
task: async () => {
|
|
383
393
|
const healthy = await waitForServiceHealthy(composeFile, 'facial-web', 60);
|
|
384
394
|
if (!healthy) {
|
|
@@ -387,19 +397,18 @@ export async function update(options) {
|
|
|
387
397
|
}
|
|
388
398
|
},
|
|
389
399
|
{
|
|
390
|
-
title: formatStepTitle(
|
|
391
|
-
skip: () => !
|
|
400
|
+
title: stepPosHealth ? formatStepTitle(stepPosHealth, totalSteps, 'Waiting for POS App to be healthy') : '',
|
|
401
|
+
skip: () => !stepPosHealth ? 'POS App not installed' : false,
|
|
392
402
|
task: async () => {
|
|
393
|
-
const healthy = await waitForServiceHealthy(composeFile, 'pos
|
|
403
|
+
const healthy = await waitForServiceHealthy(composeFile, 'ante-pos', 60);
|
|
394
404
|
if (!healthy) {
|
|
395
405
|
throw new Error('POS App did not become healthy within 60 seconds');
|
|
396
406
|
}
|
|
397
407
|
}
|
|
398
408
|
},
|
|
399
409
|
{
|
|
400
|
-
title: formatStepTitle(
|
|
410
|
+
title: formatStepTitle(stepMigrations, totalSteps, 'Running database migrations'),
|
|
401
411
|
task: async (ctx, task) => {
|
|
402
|
-
const stepNumber = currentStep; // Capture current step number
|
|
403
412
|
const result = await runMigrations(composeFile);
|
|
404
413
|
|
|
405
414
|
if (!result.success) {
|
|
@@ -408,24 +417,22 @@ export async function update(options) {
|
|
|
408
417
|
|
|
409
418
|
// Update title if migrations were applied
|
|
410
419
|
if (result.output && result.output.includes('Applied')) {
|
|
411
|
-
task.title = formatStepTitle(
|
|
420
|
+
task.title = formatStepTitle(stepMigrations, totalSteps, 'Database migrations applied');
|
|
412
421
|
} else {
|
|
413
|
-
task.title = formatStepTitle(
|
|
422
|
+
task.title = formatStepTitle(stepMigrations, totalSteps, 'Database migrations (up to date)');
|
|
414
423
|
}
|
|
415
424
|
}
|
|
416
425
|
},
|
|
417
426
|
{
|
|
418
|
-
title: formatStepTitle(
|
|
419
|
-
skip: () =>
|
|
427
|
+
title: stepCleanup ? formatStepTitle(stepCleanup, totalSteps, 'Cleaning up unused Docker resources') : '',
|
|
428
|
+
skip: () => !stepCleanup ? 'Cleanup skipped' : false,
|
|
420
429
|
task: async (ctx, task) => {
|
|
421
|
-
const stepNumber = currentStep; // Capture current step number
|
|
422
430
|
try {
|
|
423
431
|
await pruneDockerSilent();
|
|
424
|
-
task.title = formatStepTitle(
|
|
432
|
+
task.title = formatStepTitle(stepCleanup, totalSteps, 'Cleaned up unused Docker resources');
|
|
425
433
|
} catch (error) {
|
|
426
434
|
// Non-critical error - don't fail the update
|
|
427
435
|
task.skip(`Cleanup failed: ${error.message}`);
|
|
428
|
-
currentStep--;
|
|
429
436
|
}
|
|
430
437
|
}
|
|
431
438
|
}
|