@cruxgarden/cli 0.0.12 → 0.0.13
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/lib/commands.js +36 -19
- package/package.json +1 -1
package/lib/commands.js
CHANGED
|
@@ -469,17 +469,23 @@ export async function purgeNursery() {
|
|
|
469
469
|
export async function updateNursery() {
|
|
470
470
|
ensureDockerRunning();
|
|
471
471
|
const spinner = ora(
|
|
472
|
-
"Checking for latest Crux Garden
|
|
472
|
+
"Checking for latest Crux Garden images from ghcr.io...",
|
|
473
473
|
).start();
|
|
474
474
|
const envFileFlag = getEnvFileFlag();
|
|
475
475
|
|
|
476
476
|
try {
|
|
477
|
-
// Get the current local image
|
|
478
|
-
const
|
|
477
|
+
// Get the current local image digests before pulling
|
|
478
|
+
const apiBeforeResult = await runCommandAsync(
|
|
479
479
|
"docker images --digests --format '{{.Digest}}' ghcr.io/cruxgarden/api:latest",
|
|
480
480
|
{ silent: true, ignoreError: true }
|
|
481
481
|
);
|
|
482
|
-
const
|
|
482
|
+
const apiDigestBefore = apiBeforeResult?.combined?.trim() || apiBeforeResult?.stdout?.trim() || "";
|
|
483
|
+
|
|
484
|
+
const appBeforeResult = await runCommandAsync(
|
|
485
|
+
"docker images --digests --format '{{.Digest}}' ghcr.io/cruxgarden/app:latest",
|
|
486
|
+
{ silent: true, ignoreError: true }
|
|
487
|
+
);
|
|
488
|
+
const appDigestBefore = appBeforeResult?.combined?.trim() || appBeforeResult?.stdout?.trim() || "";
|
|
483
489
|
|
|
484
490
|
// Pull latest images
|
|
485
491
|
spinner.text = "Pulling latest images...";
|
|
@@ -487,32 +493,43 @@ export async function updateNursery() {
|
|
|
487
493
|
silent: true,
|
|
488
494
|
});
|
|
489
495
|
|
|
490
|
-
// Get the image
|
|
491
|
-
const
|
|
496
|
+
// Get the image digests after pulling
|
|
497
|
+
const apiAfterResult = await runCommandAsync(
|
|
492
498
|
"docker images --digests --format '{{.Digest}}' ghcr.io/cruxgarden/api:latest",
|
|
493
499
|
{ silent: true, ignoreError: true }
|
|
494
500
|
);
|
|
495
|
-
const
|
|
501
|
+
const apiDigestAfter = apiAfterResult?.combined?.trim() || apiAfterResult?.stdout?.trim() || "";
|
|
502
|
+
|
|
503
|
+
const appAfterResult = await runCommandAsync(
|
|
504
|
+
"docker images --digests --format '{{.Digest}}' ghcr.io/cruxgarden/app:latest",
|
|
505
|
+
{ silent: true, ignoreError: true }
|
|
506
|
+
);
|
|
507
|
+
const appDigestAfter = appAfterResult?.combined?.trim() || appAfterResult?.stdout?.trim() || "";
|
|
496
508
|
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
|
|
509
|
+
// Check which images were updated
|
|
510
|
+
const apiUpdated = apiDigestBefore && apiDigestAfter && apiDigestBefore !== apiDigestAfter;
|
|
511
|
+
const appUpdated = appDigestBefore && appDigestAfter && appDigestBefore !== appDigestAfter;
|
|
512
|
+
|
|
513
|
+
if (!apiUpdated && !appUpdated && apiDigestAfter && appDigestAfter) {
|
|
514
|
+
spinner.succeed("Nursery images are already up-to-date!");
|
|
500
515
|
console.log(
|
|
501
516
|
chalk.gray("\nYou're running the latest version."),
|
|
502
517
|
);
|
|
503
|
-
} else if (digestAfter) {
|
|
504
|
-
spinner.succeed("Latest nursery image downloaded!");
|
|
505
|
-
console.log(
|
|
506
|
-
chalk.gray("\nRun"),
|
|
507
|
-
chalk.cyan("crux nursery restart"),
|
|
508
|
-
chalk.gray("to use the new image."),
|
|
509
|
-
);
|
|
510
518
|
} else {
|
|
511
|
-
|
|
519
|
+
const updatedImages = [];
|
|
520
|
+
if (apiUpdated) updatedImages.push("API");
|
|
521
|
+
if (appUpdated) updatedImages.push("App");
|
|
522
|
+
|
|
523
|
+
if (updatedImages.length > 0) {
|
|
524
|
+
spinner.succeed(`Latest nursery images downloaded! (${updatedImages.join(", ")} updated)`);
|
|
525
|
+
} else {
|
|
526
|
+
spinner.succeed("Images pulled successfully!");
|
|
527
|
+
}
|
|
528
|
+
|
|
512
529
|
console.log(
|
|
513
530
|
chalk.gray("\nRun"),
|
|
514
531
|
chalk.cyan("crux nursery restart"),
|
|
515
|
-
chalk.gray("to use the
|
|
532
|
+
chalk.gray("to use the new images."),
|
|
516
533
|
);
|
|
517
534
|
}
|
|
518
535
|
} catch (error) {
|