From d7313603c9b3438548f13f8c3582f2fce9951806 Mon Sep 17 00:00:00 2001 From: shamsartem Date: Mon, 16 Sep 2024 20:03:59 +0200 Subject: [PATCH] fix: versions in configs (#1040) --- cli/src/lib/configs/project/env.ts | 3 ++- cli/src/lib/configs/project/providerArtifacts.ts | 9 ++++++--- cli/src/lib/configs/project/workers.ts | 9 ++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cli/src/lib/configs/project/env.ts b/cli/src/lib/configs/project/env.ts index 140d7d956..e49eadd36 100644 --- a/cli/src/lib/configs/project/env.ts +++ b/cli/src/lib/configs/project/env.ts @@ -29,6 +29,7 @@ import { type FluenceEnv, type FluenceEnvOld, } from "../../const.js"; +import { numToStr } from "../../helpers/typesafeStringify.js"; import { getFluenceDir } from "../../paths.js"; import { getConfigInitFunction, @@ -99,7 +100,7 @@ const getDefault = (fluenceEnv: FluenceEnv | undefined): GetDefaultConfig => { return () => { return `# Defines project preferences # config version -version: 0 +version: ${numToStr(latestSchemaObj.properties.version.const)} # Fluence environment to connect to ${fluenceEnv === undefined ? `# fluenceEnv: ${DEFAULT_PUBLIC_FLUENCE_ENV}` : `fluenceEnv: "${fluenceEnv}"`} diff --git a/cli/src/lib/configs/project/providerArtifacts.ts b/cli/src/lib/configs/project/providerArtifacts.ts index f7cca975b..4f49081a6 100644 --- a/cli/src/lib/configs/project/providerArtifacts.ts +++ b/cli/src/lib/configs/project/providerArtifacts.ts @@ -29,6 +29,7 @@ import { type FluenceEnv, fluenceOldEnvToNewEnv, } from "../../const.js"; +import { numToStr } from "../../helpers/typesafeStringify.js"; import { ensureProviderArtifactsConfigPath, getFluenceDir, @@ -205,11 +206,13 @@ const configSchemaV3 = { required: ["version", "offers"], } as const satisfies JSONSchemaType; -const latestSchema: JSONSchemaType = { +const latestSchemaObj = { $id: `${TOP_LEVEL_SCHEMA_ID}/${PROVIDER_ARTIFACTS_CONFIG_FILE_NAME}`, title: PROVIDER_ARTIFACTS_CONFIG_FULL_FILE_NAME, ...configSchemaV3, -}; +} as const satisfies JSONSchemaType; + +const latestSchema: JSONSchemaType = latestSchemaObj; const validateConfigSchemaV0 = ajv.compile(configSchemaV0); const validateConfigSchemaV1 = ajv.compile(configSchemaV1); @@ -354,7 +357,7 @@ export async function initNewProviderArtifactsConfig() { function getDefault() { return ` -version: 0 +version: ${numToStr(latestSchemaObj.properties.version.const)} offers: {} `; } diff --git a/cli/src/lib/configs/project/workers.ts b/cli/src/lib/configs/project/workers.ts index 84a8c225a..b6edbde75 100644 --- a/cli/src/lib/configs/project/workers.ts +++ b/cli/src/lib/configs/project/workers.ts @@ -39,6 +39,7 @@ import { type FluenceEnvOld, type FluenceEnv, } from "../../const.js"; +import { numToStr } from "../../helpers/typesafeStringify.js"; import { getFluenceDir } from "../../paths.js"; import { fluenceEnvOldPrompt } from "../../resolveFluenceEnv.js"; import { @@ -374,12 +375,14 @@ const configSchemaV2 = { required: ["version"], } as const satisfies JSONSchemaType; -const latestSchema: JSONSchemaType = { +const latestSchemaObj = { $id: `${TOP_LEVEL_SCHEMA_ID}/${WORKERS_CONFIG_FULL_FILE_NAME}`, title: WORKERS_CONFIG_FULL_FILE_NAME, description: `A result of app deployment. This file is created automatically after successful deployment using \`${CLI_NAME} workers deploy\` command`, ...configSchemaV2, -}; +} as const satisfies JSONSchemaType; + +const latestSchema: JSONSchemaType = latestSchemaObj; const validateConfigSchemaV0 = ajv.compile(configSchemaV0); const validateConfigSchemaV1 = ajv.compile(configSchemaV1); @@ -503,7 +506,7 @@ const getDefault: GetDefaultConfig = () => { # This file is updated automatically after successful deployment using \`fluence workers deploy\` command # config version -version: 0 +version: ${numToStr(latestSchemaObj.properties.version.const)} # deals: # # A map of created deals