Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Added git related debug information. #448

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/DiagramFrame/Debug/Debug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
<circle cx="6" cy="18" r="3"></circle>
<path d="M18 9a9 9 0 0 1-9 9"></path>
</svg>
<span class="inline-block px-2">{{ gitBranch }}:{{ commitHash }}</span>
<span class="inline-block px-2">{{ gitBranch }} ({{ gitTag }}) {{ commitHash }}</span>
</div>
</div>
</div>
</template>

<script>
const commitHash = 'process.env.VUE_APP_GIT_HASH';
const gitBranch = 'process.env.VUE_APP_GIT_BRANCH';
const commitHash = import.meta.env.VITE_COMMIT_HASH;
const gitBranch = import.meta.env.VITE_GIT_BRANCH;
const gitTag = import.meta.env.VITE_GIT_TAG;
export default {
name: 'Debug',
data() {
return {
commitHash,
gitBranch,
gitTag,
};
},
computed: {
Expand Down
14 changes: 14 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ function getCypressHtmlFiles() {

const cypressHtmlFiles = getCypressHtmlFiles();
console.log(cypressHtmlFiles);

process.env.VITE_COMMIT_HASH = execSync('git rev-parse --short HEAD').toString().trim()
process.env.VITE_GIT_BRANCH = execSync('git branch --show-current').toString().trim()
// https://stackoverflow.com/a/45993185/529187
process.env.VITE_GIT_TAG = execSync('git describe --tags --always --abbrev=0').toString().trim()
console.log(`Building ${process.env.VITE_GIT_HASH} (${process.env.VITE_GIT_BRANCH}) on ${process.env.VITE_GIT_BRANCH}`)

process.env.VITE_SOME_KEY = 'process.env.VITE_SOME_KEY1';
process.env.SOME_KEY = 'process.env.VITE_SOME_KEY2';
export default defineConfig({
define: {
'import.meta.env': {
VITE_SOME_KEY: JSON.stringify('import.meta.env.VITE_SOME_KEY3'),
},
},
build: {
rollupOptions: {
input: ['index.html', 'embed.html', ...cypressHtmlFiles],
Expand Down