From 2b4ef15119692a861c810b6dae3ed8e894395331 Mon Sep 17 00:00:00 2001 From: Robbe Van Petegem Date: Sat, 31 Aug 2024 14:07:38 +0200 Subject: [PATCH 1/4] Define a global `APPLICATION_VERSION` --- src/version.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/version.js diff --git a/src/version.js b/src/version.js new file mode 100644 index 00000000..ebbe83d4 --- /dev/null +++ b/src/version.js @@ -0,0 +1 @@ +export const APPLICATION_VERSION = `WEB v${require("../package.json").version}`; From faf35257aacd9374dcfeedd85c57a4656140baaf Mon Sep 17 00:00:00 2001 From: Robbe Van Petegem Date: Sat, 31 Aug 2024 14:08:04 +0200 Subject: [PATCH 2/4] Add `application` to auth token params --- src/store/auth.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/store/auth.js b/src/store/auth.js index 56fba4df..53503a36 100644 --- a/src/store/auth.js +++ b/src/store/auth.js @@ -1,6 +1,7 @@ import Vue from "vue"; import api from "@/api"; import { fetchAll } from "./actions"; +import { APPLICATION_VERSION } from "../version"; export default { namespaced: true, @@ -56,7 +57,10 @@ export default { actions: { async login({ commit }, data) { try { - const result = await api.auth_tokens.create(data); + const result = await api.auth_tokens.create({ + auth_token: { application: APPLICATION_VERSION }, + ...data, + }); commit("login", result); return true; } catch (error) { From 7e611e77def1d2cc515f60432da207e2112dab1c Mon Sep 17 00:00:00 2001 From: Robbe Van Petegem Date: Thu, 5 Sep 2024 20:03:28 +0200 Subject: [PATCH 3/4] Update version to `accentor/api-client-js` --- package.json | 2 +- yarn.lock | 8 ++++---- yarn.nix | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index b69a0e01..1818419f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'" }, "dependencies": { - "@accentor/api-client-js": "^0.20.1", + "@accentor/api-client-js": "^0.21.0", "@mdi/font": "^7.4.47", "@mdi/svg": "^7.4.47", "fetch-retry": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index 50a1b375..ea8f1a22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,10 +7,10 @@ resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== -"@accentor/api-client-js@^0.20.1": - version "0.20.1" - resolved "https://registry.yarnpkg.com/@accentor/api-client-js/-/api-client-js-0.20.1.tgz#1fddf9e6e999f78f597930464b6abf474da6a2fc" - integrity sha512-rZRbCZuJjFfN4d+PVctQFK9t38LJabLndGNxOGgbeGUkkliHvLNYWhC1BIqrxLDcstED6LO6h0huhq0Pw83QLA== +"@accentor/api-client-js@^0.21.0": + version "0.21.0" + resolved "https://registry.yarnpkg.com/@accentor/api-client-js/-/api-client-js-0.21.0.tgz#e7270eb867d91708bc81202fc8aa0ba1c339a4f1" + integrity sha512-UsDbjHznV6bdqmkSILHrz5fH79WCVzvxa2oFQHoTU4NbOW9SCmcsCSmZXOXo7AN14TCrVPbgBYCJaAoaZgqQFQ== dependencies: fetch-retry "^6.0.0" diff --git a/yarn.nix b/yarn.nix index 5d10d4de..052f7e83 100644 --- a/yarn.nix +++ b/yarn.nix @@ -10,11 +10,11 @@ }; } { - name = "_accentor_api_client_js___api_client_js_0.20.1.tgz"; + name = "_accentor_api_client_js___api_client_js_0.21.0.tgz"; path = fetchurl { - name = "_accentor_api_client_js___api_client_js_0.20.1.tgz"; - url = "https://registry.yarnpkg.com/@accentor/api-client-js/-/api-client-js-0.20.1.tgz"; - sha512 = "rZRbCZuJjFfN4d+PVctQFK9t38LJabLndGNxOGgbeGUkkliHvLNYWhC1BIqrxLDcstED6LO6h0huhq0Pw83QLA=="; + name = "_accentor_api_client_js___api_client_js_0.21.0.tgz"; + url = "https://registry.yarnpkg.com/@accentor/api-client-js/-/api-client-js-0.21.0.tgz"; + sha512 = "UsDbjHznV6bdqmkSILHrz5fH79WCVzvxa2oFQHoTU4NbOW9SCmcsCSmZXOXo7AN14TCrVPbgBYCJaAoaZgqQFQ=="; }; } { From c179273e149a03dba08c5264fad24dd83168ff13 Mon Sep 17 00:00:00 2001 From: Robbe Van Petegem Date: Thu, 5 Sep 2024 20:16:01 +0200 Subject: [PATCH 4/4] Set version through `process.env` --- src/store/auth.js | 5 +++-- src/version.js | 1 - vue.config.js | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) delete mode 100644 src/version.js diff --git a/src/store/auth.js b/src/store/auth.js index 53503a36..035faca1 100644 --- a/src/store/auth.js +++ b/src/store/auth.js @@ -1,7 +1,6 @@ import Vue from "vue"; import api from "@/api"; import { fetchAll } from "./actions"; -import { APPLICATION_VERSION } from "../version"; export default { namespaced: true, @@ -58,7 +57,9 @@ export default { async login({ commit }, data) { try { const result = await api.auth_tokens.create({ - auth_token: { application: APPLICATION_VERSION }, + auth_token: { + application: process.env.APPLICATION_VERSION, + }, ...data, }); commit("login", result); diff --git a/src/version.js b/src/version.js deleted file mode 100644 index ebbe83d4..00000000 --- a/src/version.js +++ /dev/null @@ -1 +0,0 @@ -export const APPLICATION_VERSION = `WEB v${require("../package.json").version}`; diff --git a/vue.config.js b/vue.config.js index 9014242b..d4ae216a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,3 +1,6 @@ +const version = require("./package.json").version; +const webpack = require("webpack"); + module.exports = { pluginOptions: { i18n: { @@ -16,6 +19,14 @@ module.exports = { }, configureWebpack: (config) => { config.cache = process.env.SKIP_CACHE !== "true"; + config.plugins.push( + new webpack.DefinePlugin({ + "process.env": { + // When building, this value will just be printed without quotes, so we add them explicitly + APPLICATION_VERSION: `"Accentor Web v${version}"`, + }, + }), + ); }, chainWebpack: (config) => { config.module