diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6041f6e0..f4a641b3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -20,4 +20,5 @@ - [ ] There are no (new) build warnings or errors - [ ] _(If a new config option is added)_ Attribute is outlined in the schema and documented - [ ] _(If a new dependency is added)_ Package is essential, and has been checked out for security or performance +- [ ] Bumps version, if new feature added diff --git a/docs/configuring.md b/docs/configuring.md index f577197d..4e1ca038 100644 --- a/docs/configuring.md +++ b/docs/configuring.md @@ -71,6 +71,7 @@ To disallow any changes from being written to disk via the UI config editor, set **`customCss`** | `string` | _Optional_ | Raw CSS that will be applied to the page. This can also be set from the UI. Please minify it first. **`hideComponents`** | `object` | _Optional_ | A list of key page components (header, footer, search, settings, etc) that are present by default, but can be removed using this option. See [`appConfig.hideComponents`](#appconfighideComponents-optional) **`allowConfigEdit`** | `boolean` | _Optional_ | Should prevent / allow the user to write configuration changes to the conf.yml from the UI. When set to `false`, the user can only apply changes locally using the config editor within the app, whereas if set to `true` then changes can be written to disk directly through the UI. Defaults to `true`. Note that if authentication is enabled, the user must be of type `admin` in order to apply changes globally. +**`disableUpdateChecks`** | `boolean` | _Optional_ | If set to true, Dashy will not check for updates. Defaults to `false`. **`disableServiceWorker`** | `boolean` | _Optional_ | Service workers cache web applications to improve load times and offer basic offline functionality, and are enabled by default in Dashy. The service worker can sometimes cause older content to be cached, requiring the app to be hard-refreshed. If you do not want SW functionality, or are having issues with caching, set this property to `true` to disable all service workers. **`disableContextMenu`** | `boolean` | _Optional_ | If set to `true`, the custom right-click context menu will be disabled. Defaults to `false`. diff --git a/package.json b/package.json index d1196a42..a7c219ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Dashy", - "version": "1.4.2", + "version": "1.4.4", "license": "MIT", "main": "server", "scripts": { @@ -11,7 +11,7 @@ "pm2-start": "npx pm2 start server.js", "build-watch": "vue-cli-service build --watch --mode production", "build-and-start": "npm-run-all --parallel build-watch start", - "validate-config": "node src/utils/ConfigValidator", + "validate-config": "node services/config-validator", "health-check": "node services/healthcheck" }, "dependencies": { diff --git a/server.js b/server.js index 102cbb25..ee74ea37 100644 --- a/server.js +++ b/server.js @@ -13,12 +13,15 @@ const dns = require('dns'); const os = require('os'); const bodyParser = require('body-parser'); +/* Kick of some basic checks */ +require('./services/update-checker'); // Checks if there are any updates available, prints message +require('./services/config-validator'); // Include and kicks off the config file validation script + /* Include helper functions and route handlers */ const pingUrl = require('./services/ping'); // Used by the status check feature, to ping services const saveConfig = require('./services/save-config'); // Saves users new conf.yml to file-system const printMessage = require('./services/print-message'); // Function to print welcome msg on start const rebuild = require('./services/rebuild-app'); // A script to programmatically trigger a build -require('./src/utils/ConfigValidator'); // Include and kicks off the config file validation script /* Checks if app is running within a container, from env var */ const isDocker = !!process.env.IS_DOCKER; diff --git a/src/utils/ConfigValidator.js b/services/config-validator.js similarity index 89% rename from src/utils/ConfigValidator.js rename to services/config-validator.js index 5f9bfdb6..bc6545e3 100644 --- a/src/utils/ConfigValidator.js +++ b/services/config-validator.js @@ -4,14 +4,16 @@ const Ajv = require('ajv'); const yaml = require('js-yaml'); const fs = require('fs'); -const schema = require('./ConfigSchema.json'); +const schema = require('../src/utils/ConfigSchema.json'); +/* Tell AJV to use strict mode, and report all errors */ const validatorOptions = { strict: true, allowUnionTypes: true, allErrors: true, }; +/* Initiate AJV validator */ const ajv = new Ajv(validatorOptions); /* Message printed when validation was successful */ @@ -58,13 +60,13 @@ const validate = (config) => { try { const config = yaml.load(fs.readFileSync('./public/conf.yml', 'utf8')); validate(config); -} catch (e) { +} catch (e) { // Something went very wrong... setIsValidVariable(false); console.log(bigError()); console.log('Please ensure that your config file is present, ' + 'has the correct access rights and is parsable. ' + 'If this warning persists, it may be an issue with the ' + 'validator function. Please raise an issue, and include the following stack trace:\n'); - console.warn('\x1b[33mStack Trace for ConfigValidators.js:\x1b[0m\n', e); + console.warn('\x1b[33mStack Trace for config-validator.js:\x1b[0m\n', e); console.log('\n\n'); } diff --git a/services/update-checker.js b/services/update-checker.js new file mode 100644 index 00000000..c55492fd --- /dev/null +++ b/services/update-checker.js @@ -0,0 +1,28 @@ +const axios = require('axios').default; + +const currentVersion = require('../package.json').version; + +const packageUrl = 'https://raw.githubusercontent.com/Lissy93/dashy/master/package.json'; + +const makeMsg = (latestVersion) => { + const parse = (version) => parseInt(version.replaceAll('.', ''), 10); + const difference = parse(latestVersion) - parse(currentVersion); + let msg = ''; + 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 msg; +}; + +axios.get(packageUrl).then((response) => { + if (response && response.data && response.data.version) { + console.log(`\nUsing Dashy V-${currentVersion}. Update Check Complete`); + console.log(makeMsg(response.data.version)); + } +}).catch(() => { + console.log('Unable to check for updates'); +}); diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 9b69980b..eb638c34 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -34,7 +34,6 @@ "change-language-button": "Change App Language", "reset-settings-button": "Reset Local Settings", "app-info-button": "App Info", - "app-version-note": "Dashy version", "backup-note": "It is recommend to make a backup of your configuration before making changes.", "reset-config-msg-l1": "This will remove all user settings from local storage, but won't effect your 'conf.yml' file.", "reset-config-msg-l2": "You should first backup any changes you've made locally, if you want to use them in the future.", @@ -62,6 +61,13 @@ "item-size-large": "Large", "config-launcher-label": "Config" }, + "updates": { + "app-version-note": "Dashy version", + "up-to-date": "Up-to-Date", + "out-of-date": "Update Available", + "unsupported-version-l1": "You are using an unsupported version of Dashy", + "unsupported-version-l2": "For the best experience, and recent security patches, please update to" + }, "language-switcher": { "title": "Change Application Language", "dropdown-label": "Select a Language", diff --git a/src/components/Configuration/AppInfoModal.vue b/src/components/Configuration/AppInfoModal.vue index ab136e0b..8fc237eb 100644 --- a/src/components/Configuration/AppInfoModal.vue +++ b/src/components/Configuration/AppInfoModal.vue @@ -2,8 +2,9 @@
-

Dashy V{{ appVersion }}

+

Dashy

+

Service Worker Status

{{ serviceWorkerInfo }}
@@ -39,10 +40,14 @@ + + diff --git a/src/components/Configuration/ConfigContainer.vue b/src/components/Configuration/ConfigContainer.vue index 720e6111..4f6eefc0 100644 --- a/src/components/Configuration/ConfigContainer.vue +++ b/src/components/Configuration/ConfigContainer.vue @@ -40,8 +40,8 @@ -

{{ $t('config.app-version-note') }} {{ appVersion }}

{{ getLanguage() }}

+
{{ $t('config.backup-note') }}
@@ -74,7 +74,6 @@