Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

🚨 Fixes ambiguous import warns from js-yaml

Alicia Sykes9198d9d7da0d
diff --git a/src/components/Configuration/JsonEditor.vue b/src/components/Configuration/JsonEditor.vue
index 547505ac..56d0a9d6 100644
--- a/src/components/Configuration/JsonEditor.vue
+++ b/src/components/Configuration/JsonEditor.vue
@@ -105,7 +105,7 @@
<script>
import { shallowRef, markRaw } from 'vue';
-import jsYaml from 'js-yaml';
+import { load as yamlLoad, dump as yamlDump } from 'js-yaml';
import { EditorView, keymap, lineNumbers, highlightActiveLine, highlightActiveLineGutter } from '@codemirror/view';
import { EditorState, Compartment } from '@codemirror/state';
import { yaml } from '@codemirror/lang-yaml';
@@ -219,7 +219,7 @@ export default {
// Root config always has a pageInfo; show a sensible default if missing.
// Sub-pages can legitimately have an empty pageInfo (they inherit from root).
if (!confId && !data.pageInfo) data.pageInfo = { title: 'Dashy' };
- return jsYaml.dump(data, DUMP_OPTS);
+ return yamlDump(data, DUMP_OPTS);
},
createEditor() {
try {
@@ -287,8 +287,8 @@ export default {
formatDocument() {
if (!this.view) return;
try {
- const data = jsYaml.load(this.view.state.doc.toString());
- const formatted = jsYaml.dump(data ?? {}, DUMP_OPTS);
+ const data = yamlLoad(this.view.state.doc.toString());
+ const formatted = yamlDump(data ?? {}, DUMP_OPTS);
this.view.dispatch({
changes: { from: 0, to: this.view.state.doc.length, insert: formatted },
});
@@ -310,7 +310,7 @@ export default {
},
parseCurrent() {
try {
- return jsYaml.load(this.currentText());
+ return yamlLoad(this.currentText());
} catch (e) {
this.$toast.error(this.$t('config-editor.parse-fail-msg', { message: e.message }));
return null;
@@ -359,7 +359,7 @@ export default {
});
}
if (inPreview) {
- const original = jsYaml.load(this.initialDoc);
+ const original = yamlLoad(this.initialDoc);
if (original) this.applyConfigToStore(original);
this.$store.commit(StoreKeys.SET_EDIT_MODE, false);
}
diff --git a/src/components/InteractiveEditor/ExportConfigMenu.vue b/src/components/InteractiveEditor/ExportConfigMenu.vue
index 339e154e..e071cf98 100644
--- a/src/components/InteractiveEditor/ExportConfigMenu.vue
+++ b/src/components/InteractiveEditor/ExportConfigMenu.vue
@@ -112,7 +112,7 @@
</template>
<script>
-import JsYaml from 'js-yaml';
+import { load as yamlLoad, dump as yamlDump } from 'js-yaml';
import Button from '@/components/FormElements/Button';
import StoreKeys from '@/utils/StoreMutations';
import { modalNames } from '@/utils/config/defaults';
@@ -169,7 +169,7 @@ export default {
return this.$store.getters.permissions.allowViewConfig;
},
currentConfigYaml() {
- return JsYaml.dump(this.config);
+ return yamlDump(this.config);
},
currentConfigPath() {
return this.$store.state.currentConfigInfo?.confPath
@@ -193,7 +193,7 @@ export default {
path: this.currentConfigPath,
isRoot: true,
});
- rootRow.yamlText = JsYaml.dump(root);
+ rootRow.yamlText = yamlDump(root);
this.applyValidation(rootRow, root);
const pageRows = (root.pages || []).map((page) => this.makeRow({
id: makePageName(page.name),
@@ -215,13 +215,13 @@ export default {
const res = await request.get(formatConfigPath(row.path));
let parsed;
try {
- parsed = JsYaml.load(res.data) || {};
+ parsed = yamlLoad(res.data) || {};
} catch (parseErr) {
row.status = 'error';
ErrorHandler(`Sub-config parse failed: ${row.path}`, parseErr);
return;
}
- row.yamlText = typeof res.data === 'string' ? res.data : JsYaml.dump(parsed);
+ row.yamlText = typeof res.data === 'string' ? res.data : yamlDump(parsed);
row.title = parsed.pageInfo?.title || row.title || row.path;
this.applyValidation(row, parsed);
} catch (fetchErr) {
diff --git a/src/mixins/ConfigSaving.js b/src/mixins/ConfigSaving.js
index 162794d4..0c862a85 100644
--- a/src/mixins/ConfigSaving.js
+++ b/src/mixins/ConfigSaving.js
@@ -1,4 +1,4 @@
-import jsYaml from 'js-yaml';
+import { dump as yamlDump } from 'js-yaml';
import { Progress } from 'rsup-progress';
import request from '@/utils/request';
import ErrorHandler, { InfoHandler } from '@/utils/logging/ErrorHandler';
@@ -35,7 +35,7 @@ export default {
...base,
sections: (base.sections || []).map(({ filteredItems: _filteredItems, ...s }) => s),
};
- const yaml = jsYaml.dump(JSON.parse(JSON.stringify(jsonConfig)));
+ const yaml = yamlDump(JSON.parse(JSON.stringify(jsonConfig)));
const baseUrl = import.meta.env.VITE_APP_DOMAIN || window.location.origin;
const endpoint = `${baseUrl}${serviceEndpoints.save}`;
const filename = isSubPag ? (state.currentConfigInfo.confPath || '') : '';
diff --git a/src/store.js b/src/store.js
index 76d58d9e..37ea2de1 100644
--- a/src/store.js
+++ b/src/store.js
@@ -1,6 +1,6 @@
import { createStore } from 'vuex';
-import yaml from 'js-yaml';
+import { load as yamlLoad } from 'js-yaml';
import request from '@/utils/request';
import Keys from '@/utils/StoreMutations';
import {
@@ -438,7 +438,7 @@ const store = createStore({
const response = await request.get(configFilePath, makeBasicAuthHeaders());
let data;
try {
- data = yaml.load(response.data);
+ data = yamlLoad(response.data);
} catch (parseError) {
commit(CRITICAL_ERROR_MSG, `Failed to parse YAML: ${parseError.message}`);
return { ...emptyConfig };
@@ -501,7 +501,7 @@ const store = createStore({
}
let subFile;
try {
- subFile = yaml.load(response.data) || {};
+ subFile = yamlLoad(response.data) || {};
} catch (parseError) {
commit(CRITICAL_ERROR_MSG, `Failed to parse sub-config YAML: ${parseError.message}`);
return { ...emptyConfig };
diff --git a/src/utils/InitServiceWorker.js b/src/utils/InitServiceWorker.js
index 40592754..ab322d2f 100644
--- a/src/utils/InitServiceWorker.js
+++ b/src/utils/InitServiceWorker.js
@@ -1,4 +1,4 @@
-import yaml from 'js-yaml';
+import { load as yamlLoad } from 'js-yaml';
import request from '@/utils/request';
import i18n from '@/utils/i18n';
import { statusMsg, statusErrorMsg } from '@/utils/logging/CoolConsole';
@@ -11,7 +11,7 @@ const UPDATE_CHECK_INTERVAL_MS = 60 * 60 * 1000; // hourly
const loadAppConfig = async () => {
try {
const { data } = await request.get('/conf.yml');
- return yaml.load(data) || null;
+ return yamlLoad(data) || null;
} catch (e) {
statusErrorMsg(SW_LABEL, 'Failed to load config for SW check', e);
return null;
diff --git a/src/utils/config/schemaLinter.js b/src/utils/config/schemaLinter.js
index bc3ea1fa..67269013 100644
--- a/src/utils/config/schemaLinter.js
+++ b/src/utils/config/schemaLinter.js
@@ -5,7 +5,7 @@
* 1. YAML syntax checker, vie js-yaml
* 2. Ajv schema validator using our ConfigSchema.json
*/
-import jsYaml from 'js-yaml';
+import { load as yamlLoad } from 'js-yaml';
import { parseDocument } from 'yaml';
import { compiledValidator as validate, formatIssue } from './validateConfig';
import { pointerToPath, yamlNodeAt, pairRange } from './schemaPath';
@@ -19,7 +19,7 @@ export function schemaLinter(view) {
let data;
try {
- data = jsYaml.load(text);
+ data = yamlLoad(text);
} catch (e) {
const line = e.mark?.line ?? 0;
const col = e.mark?.column ?? 0;
diff --git a/src/views/DownloadConfig.vue b/src/views/DownloadConfig.vue
index 6bb8f804..f51615a0 100644
--- a/src/views/DownloadConfig.vue
+++ b/src/views/DownloadConfig.vue
@@ -4,7 +4,7 @@
</template>
<script>
-import JsYaml from 'js-yaml';
+import { dump as yamlDump } from 'js-yaml';
import AccessError from '@/components/Configuration/AccessError';
export default {
@@ -17,7 +17,7 @@ export default {
return this.$store.state.configSource;
},
yamlConfig() {
- return JsYaml.dump(this.config);
+ return yamlDump(this.config);
},
allowViewConfig() {
return this.$store.getters.permissions.allowViewConfig;