-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app.vue, nuxt.config.ts, package.json): display build version in…
… UI and automate version generation Add a build version display to the app's UI to provide users with information about the current build. Introduce a new script to automatically generate a build version based on the current date and time, ensuring each build is uniquely identifiable. The build version is read from a JSON file and injected into the Nuxt runtime config, making it accessible in the application. This change enhances transparency and traceability of deployed versions, aiding in debugging and user support.
- Loading branch information
Showing
5 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": "2024-12-07T19:44:53.790Z" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
import { readFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
|
||
const buildVersion = JSON.parse( | ||
readFileSync(resolve(__dirname, 'build-version.json'), 'utf-8') | ||
).version; | ||
|
||
export default defineNuxtConfig({ | ||
compatibilityDate: '2024-11-01', | ||
devtools: { enabled: true } | ||
}) | ||
devtools: { enabled: true }, | ||
runtimeConfig: { | ||
public: { | ||
buildVersion, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { writeFileSync } from "fs"; | ||
import { resolve } from "path"; | ||
import { fileURLToPath } from "url"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = resolve(__filename, ".."); | ||
|
||
const version = new Date().toISOString(); | ||
const outputPath = resolve(__dirname, "../build-version.json"); | ||
|
||
writeFileSync(outputPath, JSON.stringify({ version }, null, 2)); | ||
|
||
console.log(`Build version generated: ${version}`); |