From 5d440e572b77c90f6ecb0cd46c66621f79287d14 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Tue, 20 May 2025 18:22:02 +0200 Subject: [PATCH] fix: revert memory check guard removal --- src/constants/deploy.constants.ts | 1 + src/services/deploy.services.ts | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/constants/deploy.constants.ts b/src/constants/deploy.constants.ts index 46103557..7244a390 100644 --- a/src/constants/deploy.constants.ts +++ b/src/constants/deploy.constants.ts @@ -1,3 +1,4 @@ +export const MEMORY_SIZE_ENDPOINT_VERSION = '0.0.14'; export const MEMORY_HEAP_WARNING = 900_000_000n; // Observed empirical value, the threshold might be higher, but at the time I wrote this, pagination there were a bit more than 700 files deployed on the Juno website without any issues. diff --git a/src/services/deploy.services.ts b/src/services/deploy.services.ts index a407bc6d..b1d8e84e 100644 --- a/src/services/deploy.services.ts +++ b/src/services/deploy.services.ts @@ -1,12 +1,18 @@ -import {satelliteMemorySize} from '@junobuild/admin'; +import {satelliteMemorySize, satelliteVersion} from '@junobuild/admin'; import type {Asset} from '@junobuild/core'; import {listAssets as listAssetsLib} from '@junobuild/core'; +import {yellow} from 'kleur'; +import {compare} from 'semver'; import {readJunoConfig} from '../configs/juno.config'; import {DAPP_COLLECTION} from '../constants/constants'; -import {DEPLOY_LIST_ASSETS_PAGINATION, MEMORY_HEAP_WARNING} from '../constants/deploy.constants'; +import { + DEPLOY_LIST_ASSETS_PAGINATION, + MEMORY_HEAP_WARNING, + MEMORY_SIZE_ENDPOINT_VERSION +} from '../constants/deploy.constants'; import type {SatelliteConfigEnv} from '../types/config'; import {configEnv} from '../utils/config.utils'; -import {confirmAndExit} from '../utils/prompt.utils'; +import {NEW_CMD_LINE, confirmAndExit} from '../utils/prompt.utils'; import {satelliteParameters} from '../utils/satellite.utils'; export const assertSatelliteMemorySize = async (args?: string[]) => { @@ -21,6 +27,19 @@ export const assertSatelliteMemorySize = async (args?: string[]) => { const satellite = await satelliteParameters({satellite: satelliteConfig, env}); + const currentVersion = await satelliteVersion({ + satellite + }); + + if (compare(currentVersion, MEMORY_SIZE_ENDPOINT_VERSION) < 0) { + console.log( + `Your satellite (${yellow( + `v${currentVersion}` + )}) is not up-to-date, and the memory size cannot be verified.${NEW_CMD_LINE}` + ); + return; + } + const maxMemorySize = assertions?.heapMemory !== undefined && typeof assertions.heapMemory !== 'boolean' ? BigInt(assertions.heapMemory)