-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Minifront version footer * review updates
- Loading branch information
Showing
7 changed files
with
65 additions
and
1 deletion.
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,26 @@ | ||
import { format } from 'date-fns'; | ||
|
||
export const Footer = () => { | ||
const shortenedCommitHash = __COMMIT_HASH__.slice(0, 7); | ||
const dateObj = new Date(__COMMIT_DATE__); | ||
const formattedDate = format(dateObj, "MMM dd yyyy HH:mm:ss 'GMT'x"); | ||
|
||
return ( | ||
<div className='my-4 flex justify-center'> | ||
<div className='flex flex-col text-center text-stone-700'> | ||
<div className='font-bold'>Frontend app version</div> | ||
<div> | ||
<a | ||
target='_blank' | ||
className='underline' | ||
href={`${__GIT_ORIGIN_URL__}/commits/${__COMMIT_HASH__}`} | ||
rel='noreferrer' | ||
> | ||
{shortenedCommitHash} | ||
</a>{' '} | ||
- {formattedDate} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,28 @@ | ||
import { Plugin } from 'vite'; | ||
import { execSync } from 'child_process'; | ||
|
||
// Vite plugin used to inject the current commit hash + commit date + origin into React | ||
// so the user can be informed the version of minifront they are using | ||
export const commitInfoPlugin = (): Plugin => { | ||
const commitHash = execSync('git rev-parse HEAD').toString().trim(); | ||
const commitDate = execSync('git log -1 --format=%cI').toString().trim(); | ||
const gitOriginUrl = execSync('git remote get-url origin') | ||
.toString() | ||
.trim() | ||
.replace(/\.git$/, ''); // Origin urls often appended with .git | ||
|
||
return { | ||
name: 'vite-plugin-commit-info', | ||
enforce: 'pre', | ||
config() { | ||
return { | ||
// Inject the env variables into the code | ||
define: { | ||
__COMMIT_HASH__: JSON.stringify(commitHash), | ||
__COMMIT_DATE__: JSON.stringify(commitDate), | ||
__GIT_ORIGIN_URL__: JSON.stringify(gitOriginUrl), | ||
}, | ||
}; | ||
}, | ||
}; | ||
}; |
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 +1,4 @@ | ||
/// <reference types="vite/client" /> | ||
declare const __COMMIT_HASH__: string; | ||
declare const __COMMIT_DATE__: string; | ||
declare const __GIT_ORIGIN_URL__: string; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.