Using existing yaml package instead of js-yaml

This commit is contained in:
Isaiah 2023-11-29 14:04:10 -05:00
parent 5f92d640c9
commit 1e8dc931a9
4 changed files with 7 additions and 18 deletions

View file

@ -1,6 +1,6 @@
import { type MaybeRef, get } from '@vueuse/core';
import yaml from 'js-yaml';
import yaml from 'yaml';
export { formatYaml };
@ -13,10 +13,10 @@ function formatYaml({
sortKeys?: MaybeRef<boolean>
indentSize?: MaybeRef<number>
}) {
const parsedYaml = yaml.load(get(rawYaml));
const parsedYaml = yaml.parse(get(rawYaml));
const formattedYAML = yaml.dump(parsedYaml, {
sortKeys: get(sortKeys),
const formattedYAML = yaml.stringify(parsedYaml, {
sortMapEntries: get(sortKeys),
indent: get(indentSize),
});

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import yaml from 'js-yaml';
import yaml from 'yaml';
import { useStorage } from '@vueuse/core';
import { formatYaml } from './yaml-models';
import { withDefaultOnError } from '@/utils/defaults';
@ -18,7 +18,7 @@ const rawYamlValidation = useValidation({
source: rawYaml,
rules: [
{
validator: v => v === '' || yaml.load(v),
validator: v => v === '' || yaml.parse(v),
message: 'Provided YAML is not valid.',
},
],