π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π©Ή Semver fix for update checker
Alicia Sykesacbb069b2aa3
diff --git a/services/update-checker.js b/services/update-checker.jsindex b0ab287d..63f8094e 100644--- a/services/update-checker.js+++ b/services/update-checker.js@@ -8,25 +8,46 @@ const logToConsole = (msg) => {console.log(msg); // eslint-disable-line no-console};+const VERSION_RE = /^\d+(\.\d+)*$/;++const compareVersions = (a, b) => {+ const pa = a.split('.').map((n) => parseInt(n, 10));+ const pb = b.split('.').map((n) => parseInt(n, 10));+ const len = Math.max(pa.length, pb.length);+ for (let i = 0; i < len; i += 1) {+ const diff = (pa[i] || 0) - (pb[i] || 0);+ if (diff !== 0) return diff;+ }+ return 0;+};+const makeMsg = (latestVersion) => {- const parse = (version) => parseInt(version.replace(/\./g, ''), 10);- const difference = parse(latestVersion) - parse(currentVersion);- let msg = '';+ const difference = compareVersions(latestVersion, currentVersion);if (difference <= 0) {- msg = '\x1b[1m\x1b[32mβ Dashy is Up-to-Date\x1b[0m\n';- } else {- msg = `\x1b[103m\x1b[34m${new Array(27).fill('β').join('')}\x1b[0m\n`- + `\x1b[103m\x1b[34mβ οΈ Update Available: ${latestVersion} \x1b[0m\n`- + `\x1b[103m\x1b[34m${new Array(27).fill('β').join('')}\x1b[0m\n`;+ return '\x1b[1m\x1b[32mβ Dashy is Up-to-Date\x1b[0m\n';}- return msg;+ return `\x1b[103m\x1b[34m${new Array(27).fill('β').join('')}\x1b[0m\n`+ + `\x1b[103m\x1b[34mβ οΈ Update Available: ${latestVersion} \x1b[0m\n`+ + `\x1b[103m\x1b[34m${new Array(27).fill('β').join('')}\x1b[0m\n`;};-request.get(packageUrl).then((response) => {- if (response && response.data && response.data.version) {+const runCheck = async () => {+ if (typeof currentVersion !== 'string' || !VERSION_RE.test(currentVersion)) {+ logToConsole('Unable to check for updates: invalid local version');+ return;+ }+ try {+ const response = await request.get(packageUrl);+ const latest = response && response.data && response.data.version;+ if (typeof latest !== 'string' || !VERSION_RE.test(latest)) {+ logToConsole('Unable to check for updates: invalid response from upstream');+ return;+ }logToConsole(`\nUsing Dashy V-${currentVersion}. Update Check Complete`);- logToConsole(makeMsg(response.data.version));+ logToConsole(makeMsg(latest));+ } catch {+ logToConsole('Unable to check for updates');}-}).catch(() => {- logToConsole('Unable to check for updates');-});+};++runCheck().catch(() => { /* never propagate β module-load must not throw */ });diff --git a/src/assets/locales/en.json b/src/assets/locales/en.jsonindex f4bac6b9..c8f084c4 100644--- a/src/assets/locales/en.json+++ b/src/assets/locales/en.json@@ -145,7 +145,7 @@"options-tooltip": "Options"},"updates": {- "app-version-note": "Dashy version",+ "app-version-note": "Running Dashy version","up-to-date": "Up-to-Date","out-of-date": "Update Available","unsupported-version-l1": "You are using an unsupported version of Dashy",diff --git a/src/components/Configuration/AppVersion.vue b/src/components/Configuration/AppVersion.vueindex fd250500..66221960 100644--- a/src/components/Configuration/AppVersion.vue+++ b/src/components/Configuration/AppVersion.vue@@ -1,7 +1,7 @@<template><div class="app-version" v-if="isVersionValid()"><!-- Current Version -->- <p>+ <p class="current-version">{{ $t('updates.app-version-note') }} {{ appVersion }}</p><div v-if="checksEnabled">@@ -41,6 +41,9 @@ export default {return this.$store.getters.appConfig;},},+ props: {+ doUpdateCheck: { type: Boolean, required: false, default: true },+ },data() {return {appVersion: import.meta.env.VITE_APP_VERSION, // Current version, from package.json@@ -54,7 +57,7 @@ export default {};},mounted() {- if (!this.appVersion || (this.appConfig && this.appConfig.disableUpdateChecks)) {+ if (!this.doUpdateCheck || !this.appVersion || (this.appConfig && this.appConfig.disableUpdateChecks)) {// Either current version isn't found, or user disabled checksthis.checksEnabled = false;} else {@@ -67,27 +70,33 @@ export default {const packageUrl = 'https://raw.githubusercontent.com/Lissy93/dashy/master/package.json';this.progress.start();request.get(packageUrl).then((response) => {- if (response && response.data && response.data.version) {- this.latestVersion = response.data.version;- this.isUpToDate = this.checkIfUpToDate(this.appVersion, this.latestVersion);- this.finished = true;- this.progress.end();+ const latest = response && response.data && response.data.version;+ if (typeof latest !== 'string' || !/^\d+(\.\d+)*$/.test(latest)) {+ this.error = true;+ return;}+ this.latestVersion = latest;+ this.isUpToDate = this.checkIfUpToDate(this.appVersion, latest);+ this.finished = true;}).catch(() => {this.error = true;+ }).finally(() => {this.progress.end();});},/* Compares the current version, with the package.json version */checkIfUpToDate(currentVersion, latestVersion) {- const parse = (version) => parseInt(version.replaceAll('.', ''), 10);- const difference = parse(latestVersion) - parse(currentVersion);- if (difference > 5) this.veryOutOfDate = true;- return difference <= 0;+ const [curMaj = 0, curMin = 0, curPatch = 0] = currentVersion.split('.').map(Number);+ const [latMaj = 0, latMin = 0, latPatch = 0] = latestVersion.split('.').map(Number);+ if (latMaj > curMaj || latMin - curMin > 5) this.veryOutOfDate = true;+ if (latMaj !== curMaj) return latMaj < curMaj;+ if (latMin !== curMin) return latMin < curMin;+ return latPatch <= curPatch;},/* Checks that the input version is correctly parsed */isVersionValid() {- const isValid = !Number.isNaN(parseInt(this.appVersion.replaceAll('.', ''), 10));+ const isValid = typeof this.appVersion === 'string'+ && /^\d+(\.\d+)*$/.test(this.appVersion);if (!isValid) { // If invalid, then record an errorErrorHandler('Unable to check for updates, because current version is unavailible.'@@ -109,6 +118,9 @@ div.app-version {margin: 0.5rem auto;color: var(--transparent-white-50);cursor: default;+ &.current-version {+ margin: 0;+ }&.up-to-date {color: var(--success);font-weight: bold;diff --git a/src/components/Configuration/ConfigContainer.vue b/src/components/Configuration/ConfigContainer.vueindex 0d7a6b4a..7689ce54 100644--- a/src/components/Configuration/ConfigContainer.vue+++ b/src/components/Configuration/ConfigContainer.vue@@ -46,20 +46,23 @@<IconAbout class="button-icon" /></Button><!-- Display app version and language -->- <p class="language">{{ getLanguage() }}</p>- <!-- Display location of config file -->- <p class="config-location">- Using config from- <a :href="configPath">{{ configPath }}</a>- </p>- <AppVersion />+ <div class="instance-info">+ <p class="language-and-theme">+ {{ getLanguage() }}+ β’+ {{ currentTheme ? `π¨ ${currentTheme}` : '' }}+ </p>+ <!-- Display location of config file -->+ <p class="config-location">+ Using config from+ <a :href="configPath">{{ configPath }}</a>+ </p>+ <AppVersion :doUpdateCheck="false" />+ </div></div><!-- Display note if Config disabled, or if on mobile --><p v-if="!enableConfig" class="config-disabled-note">{{ $t('config.disabled-note') }}</p><p class="small-screen-note" style="display: none;">{{ $t('config.small-screen-note') }}</p>- <div class="config-note" @click="openExportConfigModal">- <span>{{ $t('config.backup-note') }}</span>- </div></div></TabItem><TabItem :name="$t('config.edit-config-tab')" v-if="enableConfig">@@ -136,6 +139,9 @@ export default {|| import.meta.env.VITE_APP_CONFIG_PATH|| '/conf.yml';},+ currentTheme() {+ return this.$store.getters.appConfig?.theme || '';+ }},components: {Tabs,@@ -197,7 +203,7 @@ export default {resetLocalSettings() {const msg = `${this.$t('config.reset-config-msg-l1')} `+ `${this.$t('config.reset-config-msg-l2')}\n\n${this.$t('config.reset-config-msg-l3')}`;- const isTheUserSure = confirm(msg);+ const isTheUserSure = confirm(msg);if (isTheUserSure) {clearScopedLocalConfig(this.$store.getters.pages);this.$toast(this.$t('config.data-cleared-msg'));@@ -264,15 +270,25 @@ a.hyperlink-wrapper {width: 100%;}-p.app-version, p.language, p.config-location {- margin: 0.5rem auto;- font-size: 1rem;- color: var(--config-settings-color);- cursor: default;- opacity: var(--dimming-factor);- a {- color: var(--config-settings-color);- }+.instance-info {+ margin-top: 0.5rem;+ display: flex;+ gap: 0.25rem;+ flex-direction: column;+ align-items: center;+ p.app-version, p.language-and-theme, p.config-location {+ margin: 0;+ font-size: 1rem;+ color: var(--config-settings-color);+ cursor: default;+ opacity: var(--dimming-factor);+ a {+ color: var(--config-settings-color);+ }+ }+ p.language-and-theme {+ text-transform: capitalize;+ }}div.code-container {diff --git a/src/components/Configuration/CustomCss.vue b/src/components/Configuration/CustomCss.vueindex 5faf5581..e578efbd 100644--- a/src/components/Configuration/CustomCss.vue+++ b/src/components/Configuration/CustomCss.vue@@ -81,7 +81,7 @@ export default {},/* Reload the page (only called if removing styles) */reloadPage() {- setTimeout(() => { location.reload(); }, 1500);+ setTimeout(() => { location.reload(); }, 1500);},/* Show success toast and lot update */showSuccessMsg() {@@ -99,6 +99,7 @@ div.css-editor-outer {padding-bottom: 1rem;display: flex;flex-direction: column;+ color: var(--foreground);.style-section {padding: 1rem;@@ -158,6 +159,7 @@ p.quick-note {// Base Theme Selector.base-theme-wrapper {+ margin: 0 auto;span.theme-label {display: none;}diff --git a/src/components/InteractiveEditor/ExportConfigMenu.vue b/src/components/InteractiveEditor/ExportConfigMenu.vueindex e071cf98..d574479d 100644--- a/src/components/InteractiveEditor/ExportConfigMenu.vue+++ b/src/components/InteractiveEditor/ExportConfigMenu.vue@@ -354,8 +354,16 @@ export default {max-width: 50rem;margin: 0 auto;width: 100%;- button { flex: 1 1 10rem; margin: 0; }- @include tablet-down { flex-direction: column; }+ button {+ flex: 1 1 10rem;+ margin: 0;+ }+ @include tablet-down {+ flex-direction: column;+ button {+ flex: none;+ }+ }}.collapsible-header {diff --git a/src/styles/color-palette.scss b/src/styles/color-palette.scssindex 771523cc..3e3a6f6c 100644--- a/src/styles/color-palette.scss+++ b/src/styles/color-palette.scss@@ -39,9 +39,9 @@/* Color variables for specific components* all variables are optional, since they inherit initial values from above** Using specific variables makes overriding for custom themes really easy */- --heading-text-color: var(--primary);+ --heading-text-color: var(--foreground);// Nav-bar links- --nav-link-text-color: var(--primary);+ --nav-link-text-color: var(--foreground);--nav-link-background-color: #607d8b33;--nav-link-text-color-hover: var(--primary);--nav-link-background-color-hover: #607d8b33;@@ -50,7 +50,7 @@--nav-link-shadow: 1px 1px 2px #232323;--nav-link-shadow-hover: 1px 1px 2px #232323;// Link items and sections- --item-text-color: var(--primary);+ --item-text-color: var(--foreground);--item-text-color-hover: var(--item-text-color);--item-group-outer-background: var(--primary);--item-group-heading-text-color: var(--item-group-background);@@ -59,14 +59,14 @@--settings-text-color: var(--primary);--settings-background: var(--background);// Config menu- --config-settings-color: var(--primary);+ --config-settings-color: var(--foreground);--config-settings-background: var(--background-darker);- --config-code-color: var(--background);+ --config-code-color: var(--black);--config-code-background: var(--white);--code-editor-color: var(--black);--code-editor-background: var(--white);// Widgets- --widget-text-color: var(--primary);+ --widget-text-color: var(--foreground);--widget-background-color: var(--background-darker);--widget-accent-color: var(--background);--widget-base-background: transparent;@@ -99,19 +99,19 @@// Minimal view--minimal-view-background-color: var(--background);--minimal-view-title-color: var(--primary);- --minimal-view-settings-color: var(--primary);- --minimal-view-section-heading-color: var(--primary);+ --minimal-view-settings-color: var(--foreground);+ --minimal-view-section-heading-color: var(--foreground);--minimal-view-section-heading-background: var(--background-darker);--minimal-view-search-background: var(--background-darker);- --minimal-view-search-color: var(--primary);- --minimal-view-group-color: var(--primary);+ --minimal-view-search-color: var(--foreground);+ --minimal-view-group-color: var(--foreground);--minimal-view-group-background: var(--background-darker);// Login page--login-form-color: var(--primary);--login-form-background: var(--background);--login-form-background-secondary: var(--background-darker);// About page- --about-page-color: var(--white);+ --about-page-color: var(--foreground);--about-page-background: var(--background);--about-page-accent: var(--primary);// Webpage colors, highlight, scrollbardiff --git a/src/styles/themes/_callisto.scss b/src/styles/themes/_callisto.scssindex e43d184f..0f2cd6db 100644--- a/src/styles/themes/_callisto.scss+++ b/src/styles/themes/_callisto.scss@@ -2,6 +2,7 @@ html[data-theme='callisto'] {--primary: #00CCB4;--background: #141b33;--background-darker: #060913;+ --foreground: #dedede;--item-group-background: #0b1021;--item-background: var(--background);--item-background-hover: var(--background-darker);@@ -9,4 +10,3 @@ html[data-theme='callisto'] {--font-body: 'Inconsolata', 'Georgia', sans-serif;--font-headings: 'PTMono', 'Courier New', monospace;}-diff --git a/src/styles/typography.scss b/src/styles/typography.scssindex d2d6a968..11d31956 100644--- a/src/styles/typography.scss+++ b/src/styles/typography.scss@@ -18,9 +18,8 @@html {--font-body: 'Raleway', 'Trebuchet MS', sans-serif;--font-headings: 'Inconsolata', 'Georgia', sans-serif;- --font-monospace: 'PTMono', ui-monospace, 'JetBrains Mono', 'Fira Code',- 'Cascadia Mono', 'SF Mono', Menlo, Monaco, Consolas,- 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;+ --font-monospace: 'PTMono', ui-monospace, Menlo, Monaco, Consolas,+ 'Courier New', monospace;font-size: 1rem;font-weight: normal;