Skip to content

Commit

Permalink
fix: versions in configs (#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsartem committed Sep 16, 2024
1 parent fa332a3 commit d731360
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cli/src/lib/configs/project/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}"`}
Expand Down
9 changes: 6 additions & 3 deletions cli/src/lib/configs/project/providerArtifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
type FluenceEnv,
fluenceOldEnvToNewEnv,
} from "../../const.js";
import { numToStr } from "../../helpers/typesafeStringify.js";
import {
ensureProviderArtifactsConfigPath,
getFluenceDir,
Expand Down Expand Up @@ -205,11 +206,13 @@ const configSchemaV3 = {
required: ["version", "offers"],
} as const satisfies JSONSchemaType<ConfigV3>;

const latestSchema: JSONSchemaType<LatestConfig> = {
const latestSchemaObj = {
$id: `${TOP_LEVEL_SCHEMA_ID}/${PROVIDER_ARTIFACTS_CONFIG_FILE_NAME}`,
title: PROVIDER_ARTIFACTS_CONFIG_FULL_FILE_NAME,
...configSchemaV3,
};
} as const satisfies JSONSchemaType<ConfigV3>;

const latestSchema: JSONSchemaType<LatestConfig> = latestSchemaObj;

const validateConfigSchemaV0 = ajv.compile(configSchemaV0);
const validateConfigSchemaV1 = ajv.compile(configSchemaV1);
Expand Down Expand Up @@ -354,7 +357,7 @@ export async function initNewProviderArtifactsConfig() {

function getDefault() {
return `
version: 0
version: ${numToStr(latestSchemaObj.properties.version.const)}
offers: {}
`;
}
Expand Down
9 changes: 6 additions & 3 deletions cli/src/lib/configs/project/workers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -374,12 +375,14 @@ const configSchemaV2 = {
required: ["version"],
} as const satisfies JSONSchemaType<ConfigV2>;

const latestSchema: JSONSchemaType<ConfigV2> = {
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<LatestConfig>;

const latestSchema: JSONSchemaType<LatestConfig> = latestSchemaObj;

const validateConfigSchemaV0 = ajv.compile(configSchemaV0);
const validateConfigSchemaV1 = ajv.compile(configSchemaV1);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d731360

Please sign in to comment.