From ab6609ef7bfb104a4f4662c530f74983e55d5bca Mon Sep 17 00:00:00 2001 From: ShareVB Date: Mon, 30 Dec 2024 17:30:49 +0100 Subject: [PATCH] fix(yaml viewer): handle numbers as bigint to avoid conversion to exponent --- src/tools/yaml-viewer/composeverter.d.ts | 1 + src/tools/yaml-viewer/yaml-models.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/yaml-viewer/composeverter.d.ts b/src/tools/yaml-viewer/composeverter.d.ts index 44b6303e..eda6f43f 100644 --- a/src/tools/yaml-viewer/composeverter.d.ts +++ b/src/tools/yaml-viewer/composeverter.d.ts @@ -17,4 +17,5 @@ declare module 'composeverter' { export function migrateFromV2xToV3x(content: string, configuration?: Configuration = null): string; export function getDockerComposeSchemaWithoutFormats(): object; export function yamlParse(content: string): object; + export function yamlCheck(content: string): object; } \ No newline at end of file diff --git a/src/tools/yaml-viewer/yaml-models.ts b/src/tools/yaml-viewer/yaml-models.ts index 9167fd7a..83726815 100644 --- a/src/tools/yaml-viewer/yaml-models.ts +++ b/src/tools/yaml-viewer/yaml-models.ts @@ -1,5 +1,5 @@ import { type MaybeRef, get } from '@vueuse/core'; -import { yamlParse } from 'composeverter'; +import { yamlCheck } from 'composeverter'; import yaml from 'yaml'; export { formatYaml }; @@ -13,7 +13,9 @@ function formatYaml({ sortKeys?: MaybeRef indentSize?: MaybeRef }) { - const parsedYaml = yamlParse(get(rawYaml)); + const rawYamlString = get(rawYaml); + yamlCheck(rawYamlString); + const parsedYaml = yaml.parse(rawYamlString, { intAsBigInt: true }); const formattedYAML = yaml.stringify(parsedYaml, { sortMapEntries: get(sortKeys),