diff --git a/.gitignore b/.gitignore index 4eb9ce0..522c81e 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,7 @@ dist # Typescript output build +tsconfig.tsbuildinfo # vuepress build output .vuepress/dist diff --git a/client/components/Modal/Changelog.vue b/client/components/Modal/Changelog.vue new file mode 100644 index 0000000..a4a1f0c --- /dev/null +++ b/client/components/Modal/Changelog.vue @@ -0,0 +1,117 @@ + + + + + + \ No newline at end of file diff --git a/client/components/Modal/Wrapper.vue b/client/components/Modal/Wrapper.vue index 093a5ff..94f9bde 100644 --- a/client/components/Modal/Wrapper.vue +++ b/client/components/Modal/Wrapper.vue @@ -9,6 +9,7 @@ + diff --git a/client/layouts/sidebar.vue b/client/layouts/sidebar.vue index edc5610..4fe70c7 100644 --- a/client/layouts/sidebar.vue +++ b/client/layouts/sidebar.vue @@ -34,7 +34,11 @@ export default { created() { this.isPublic = this.$route.path.includes('public') - this.$store.dispatch('GET_CONFIG') + this.$store.dispatch('GET_CONFIG').then((config) => { + if (config && config.didUpdate) { + this.$modal.show('changelog') + } + }) if (!this.isPublic) { this.loadingCrates = true diff --git a/client/plugins/api.js b/client/plugins/api.js index a6b6688..bb4f477 100644 --- a/client/plugins/api.js +++ b/client/plugins/api.js @@ -17,6 +17,26 @@ class API { return res.data } + async sawConfig() { + if (this.publicMode) return undefined + + const { data: res } = await this.http.get(`/config/saw-update`) + + return res.data + } + + async getGitHubRelease(version) { + const { data: release } = await this.axios.get(`https://api.github.com/repos/WebCrateApp/webcrate/releases/tags/${ version }`) + + const body = release.body.split('.tar.gz))')[1] + + const { data: html } = await this.axios.post(`https://api.github.com/markdown`, { + text: body + }) + + return { ...release, body, html } + } + async setConfig(config) { if (this.publicMode) return undefined diff --git a/client/plugins/helpers.js b/client/plugins/helpers.js index ee771ce..723a6d5 100644 --- a/client/plugins/helpers.js +++ b/client/plugins/helpers.js @@ -84,4 +84,7 @@ export default ({ env, store, app }, inject) => { app.router.push(newPath) }) + + console.log('Looks like you are pretty curious, check out the code here: https://github.com/WebCrateApp/webcrate') + console.log('Have a great day! 👨‍💻🦄') } \ No newline at end of file diff --git a/client/store/index.js b/client/store/index.js index ee8c9c2..e20555c 100644 --- a/client/store/index.js +++ b/client/store/index.js @@ -106,6 +106,8 @@ export const actions = { const config = await this.$api.getConfig() commit('SET_CONFIG', config) + + return config }, async ADD_LINK({ commit }, { url, crate }) { const link = await this.$api.addLinkToCrate(url, crate) diff --git a/client/store/modal.js b/client/store/modal.js index 8c8184b..b7c4e6e 100644 --- a/client/store/modal.js +++ b/client/store/modal.js @@ -1,4 +1,4 @@ -const modals = [ 'search', 'addLink', 'addCrate', 'addExternalCrate', 'linkDetails', 'confirm', 'copyOutput', 'changeName', 'shareLink', 'bookmarklet' ] +const modals = [ 'search', 'addLink', 'addCrate', 'addExternalCrate', 'linkDetails', 'confirm', 'copyOutput', 'changeName', 'shareLink', 'bookmarklet', 'changelog' ] export const state = () => ({ show: undefined, diff --git a/server/models/config.ts b/server/models/config.ts index 90c4cc1..35d522b 100644 --- a/server/models/config.ts +++ b/server/models/config.ts @@ -1,12 +1,19 @@ import db from '../service/db' +import pkg from '../../package.json' const Base = db.Base('config') const get = async () => { const name = await Base.get('name') + const configVersion = await Base.get('version') + + const version = pkg.version + const storedVersion = configVersion?.value return { - name: name?.value + name: name?.value, + version: version, + didUpdate: storedVersion !== version } } diff --git a/server/router/api/config.ts b/server/router/api/config.ts index 26065b7..fcd565f 100644 --- a/server/router/api/config.ts +++ b/server/router/api/config.ts @@ -34,4 +34,18 @@ router.get('/', async (_req: express.Request, res: express.Response, next: expre } }) +router.get('/saw-update', async (_req: express.Request, res: express.Response, next: express.NextFunction) => { + try { + const config = await Config.get() + + // Update stored version with current one + await Config.set({ version: config.version }) + + log.debug(config.version) + res.ok() + } catch (err) { + return next(err) + } +}) + export default router \ No newline at end of file diff --git a/server/tsconfig.json b/server/tsconfig.json index 1d2561d..6d73a6e 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -12,5 +12,8 @@ "strict": true, /* Enable all strict type-checking options. */ "resolveJsonModule": true, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - } + }, + "references": [ // this is how we declare a dependency from + { "path": "../" } // this project to the one at the root dir` + ] } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index c26c9fe..2fd4ec3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,6 @@ "allowJs": true, "sourceMap": true, "strict": true, - "noEmit": true, "experimentalDecorators": true, "baseUrl": ".", "paths": { @@ -27,11 +26,17 @@ "@nuxt/types", "@nuxtjs/axios", "@types/node" - ] + ], + "resolveJsonModule": true, + "composite": true }, "exclude": [ "node_modules", ".nuxt", "dist" + ], + "files": [ + "src/**/*.ts", + "package.json" ] }