diff --git a/package.json b/package.json index 04a0f3a4..2d57cec7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "digitalconsumer.iss", - "version": "0.1.0", + "version": "1.1.0", "private": true, "eslintConfig": { "env": { diff --git a/public/index.html b/public/index.html index 5e2434b9..6fe17575 100644 --- a/public/index.html +++ b/public/index.html @@ -46,6 +46,7 @@
+ + - \ No newline at end of file diff --git a/src/helpers/logger.js b/src/helpers/logger.js index e583f7c1..b07013f9 100644 --- a/src/helpers/logger.js +++ b/src/helpers/logger.js @@ -51,6 +51,8 @@ export class Logger { return [ `Application: ${applicationConfig.APPLICATION_NAME}`, + `Build Version: ${store.issConfig?.buildInfo?.versionString}`, + `Build Time: ${store.issConfig?.buildInfo?.buildTimeLocal}`, `ClientTag: ${store.issConfig?.clientTag}`, `ParentAccountNumber: ${store.issConfig?.parentAccountNumber}`, `ClientName: ${store.issConfig?.clientName}`, diff --git a/src/store/index.js b/src/store/index.js index 98f09213..6e4b4d07 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -269,6 +269,7 @@ export const getDefaultState = () => ({ policyZipCode: null, dateOfLoss: null }, + buildInfo: (typeof __BUILD_INFO__ !== 'undefined') ? __BUILD_INFO__ : null, // Contains the build info for the website, set during the build process. Version, Time, Git info etc.... siteType: null, // SiteType / SubType the site is set to (Essential/Advanced). enableNoCompQuote: false } @@ -2260,6 +2261,8 @@ export const useMainStore = defineStore({ this.issConfig.siteType = null; this.issConfig.enableNoCompQuote = false; this.issConfig.billToAccountNumber = null; + + // NOTE: Do not wipe out build info. }, disableKeyFields() { diff --git a/vue.config.js b/vue.config.js index d9d97c60..4d556775 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,3 +1,6 @@ +const { execSync } = require('child_process'); +const pkg = require('./package.json'); + process.env.VUE_APP_CONSUMER_CF_DISTRO = 'https://digitalapi.dev.safelite.io'; process.env.VUE_APP_CURRENT_ENVIRONMENT = 'Localhost'; process.env.VUE_APP_CUSTOMER_PORTAL_URL = 'https://myaccountdev.safelite.com/'; @@ -15,6 +18,37 @@ process.env.VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC = process.env.VUE_APP_GOOGLE_MAPS_API_SCRIPT = "(g=>{var h,a,k,p='The Google Maps JavaScript API',c='google',l='importLibrary',q='__ib__',m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement('script'));e.set('libraries',[...r]+'');for(k in g)e.set(k.replace(/[A-Z]/g,t=>'_'+t[0].toLowerCase()),g[k]);e.set('callback',c+'.maps.'+q);a.src=`https://maps.googleapis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+' could not load.'));a.nonce=m.querySelector('script[nonce]')?.nonce||'';m.head.append(a)}));d[l]?console.warn(p+' only loads once. Ignoring:',g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({key: 'AIzaSyCuLhQcDdZTTb4JzpUFms1OCch2dk5lHF0', v: 'weekly'});"; +function safeExec(cmd, fallback = 'unknown') { + try { + return execSync(cmd).toString().trim(); + } catch { + return fallback; + } +} + +const gitInfo = { + commit: safeExec('git rev-parse --short HEAD', 'dev'), + branch: safeExec('git rev-parse --abbrev-ref HEAD', 'unknown') +}; + +const buildTimes = { + buildTime: new Date().toISOString(), + buildTimeLocal: new Date().toLocaleString(), + buildTimeStamp: Math.floor(Date.now() / 1000) +} + +const buildInfo = { + version: pkg.version, + buildTime: buildTimes.buildTime, + buildTimeLocal: buildTimes.buildTimeLocal, + buildTimeStamp: buildTimes.buildTimeStamp, + ...gitInfo, + versionString: `${pkg.version}-${gitInfo.commit}-${buildTimes.buildTimeStamp}-${gitInfo.branch}` +}; + +// This will be replaced by the actual build info during the build process via webpack.DefinePlugin in this config file. +__BUILD_INFO__ = buildInfo; + module.exports = { publicPath: '/', css: { @@ -32,7 +66,12 @@ module.exports = { } } }, - configureWebpack: { - devtool: 'source-map' + configureWebpack: { + devtool: 'source-map', + plugins: [ + new (require('webpack')).DefinePlugin({ + __BUILD_INFO__: JSON.stringify(buildInfo) + }) + ] } };