How to add git hash to Vue.js Component












0















I want to create a vue.js component which will display the package.json version number and hash of most recent git commit. Here is the code so far:



<template>
<div class="versionLabel">Version: {{version}} (HASH)</div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { version } from '../../package.json';

@Component
export default class VersionLabel extends Vue {
get version() {
return version;
}
}
</script>

<style scoped lang="scss">
div {
background-color: rgb(60, 172, 60);
color: lightgray;
}
</style>


I am deploying to Heroku using the commands



"postinstall": "if test "$NODE_ENV" = "production" ; then npm run build ; fi ",
"start": "node server.js",


in package.json and this simple server:



const express = require('express');
const serveStatic = require("serve-static")

app = express();
app.use(serveStatic(__dirname + '/dist'));

const port = process.env.PORT || 5000;
app.listen(port);


The version number is working (Although suggestions for improvement are welcome) but how can I add the git hash in place of HASH?










share|improve this question


















  • 1





    Duplicates (?) stackoverflow.com/questions/34518389/…

    – joran
    Dec 28 '18 at 19:42











  • I don't think it is a duplicate. That is helpful but that would need to be run on the node server. How would I pass the result to the vue component?

    – user9540018
    Dec 28 '18 at 22:25











  • What are you using to build the Vue.js application? Is it a vue-cli project?

    – Lukas Knuth
    Dec 28 '18 at 23:12











  • Yes it is. The command is: vue-cli-service build

    – user9540018
    Dec 29 '18 at 0:01
















0















I want to create a vue.js component which will display the package.json version number and hash of most recent git commit. Here is the code so far:



<template>
<div class="versionLabel">Version: {{version}} (HASH)</div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { version } from '../../package.json';

@Component
export default class VersionLabel extends Vue {
get version() {
return version;
}
}
</script>

<style scoped lang="scss">
div {
background-color: rgb(60, 172, 60);
color: lightgray;
}
</style>


I am deploying to Heroku using the commands



"postinstall": "if test "$NODE_ENV" = "production" ; then npm run build ; fi ",
"start": "node server.js",


in package.json and this simple server:



const express = require('express');
const serveStatic = require("serve-static")

app = express();
app.use(serveStatic(__dirname + '/dist'));

const port = process.env.PORT || 5000;
app.listen(port);


The version number is working (Although suggestions for improvement are welcome) but how can I add the git hash in place of HASH?










share|improve this question


















  • 1





    Duplicates (?) stackoverflow.com/questions/34518389/…

    – joran
    Dec 28 '18 at 19:42











  • I don't think it is a duplicate. That is helpful but that would need to be run on the node server. How would I pass the result to the vue component?

    – user9540018
    Dec 28 '18 at 22:25











  • What are you using to build the Vue.js application? Is it a vue-cli project?

    – Lukas Knuth
    Dec 28 '18 at 23:12











  • Yes it is. The command is: vue-cli-service build

    – user9540018
    Dec 29 '18 at 0:01














0












0








0








I want to create a vue.js component which will display the package.json version number and hash of most recent git commit. Here is the code so far:



<template>
<div class="versionLabel">Version: {{version}} (HASH)</div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { version } from '../../package.json';

@Component
export default class VersionLabel extends Vue {
get version() {
return version;
}
}
</script>

<style scoped lang="scss">
div {
background-color: rgb(60, 172, 60);
color: lightgray;
}
</style>


I am deploying to Heroku using the commands



"postinstall": "if test "$NODE_ENV" = "production" ; then npm run build ; fi ",
"start": "node server.js",


in package.json and this simple server:



const express = require('express');
const serveStatic = require("serve-static")

app = express();
app.use(serveStatic(__dirname + '/dist'));

const port = process.env.PORT || 5000;
app.listen(port);


The version number is working (Although suggestions for improvement are welcome) but how can I add the git hash in place of HASH?










share|improve this question














I want to create a vue.js component which will display the package.json version number and hash of most recent git commit. Here is the code so far:



<template>
<div class="versionLabel">Version: {{version}} (HASH)</div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { version } from '../../package.json';

@Component
export default class VersionLabel extends Vue {
get version() {
return version;
}
}
</script>

<style scoped lang="scss">
div {
background-color: rgb(60, 172, 60);
color: lightgray;
}
</style>


I am deploying to Heroku using the commands



"postinstall": "if test "$NODE_ENV" = "production" ; then npm run build ; fi ",
"start": "node server.js",


in package.json and this simple server:



const express = require('express');
const serveStatic = require("serve-static")

app = express();
app.use(serveStatic(__dirname + '/dist'));

const port = process.env.PORT || 5000;
app.listen(port);


The version number is working (Although suggestions for improvement are welcome) but how can I add the git hash in place of HASH?







node.js git heroku vue.js vue-component






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 28 '18 at 18:05









user9540018user9540018

386




386








  • 1





    Duplicates (?) stackoverflow.com/questions/34518389/…

    – joran
    Dec 28 '18 at 19:42











  • I don't think it is a duplicate. That is helpful but that would need to be run on the node server. How would I pass the result to the vue component?

    – user9540018
    Dec 28 '18 at 22:25











  • What are you using to build the Vue.js application? Is it a vue-cli project?

    – Lukas Knuth
    Dec 28 '18 at 23:12











  • Yes it is. The command is: vue-cli-service build

    – user9540018
    Dec 29 '18 at 0:01














  • 1





    Duplicates (?) stackoverflow.com/questions/34518389/…

    – joran
    Dec 28 '18 at 19:42











  • I don't think it is a duplicate. That is helpful but that would need to be run on the node server. How would I pass the result to the vue component?

    – user9540018
    Dec 28 '18 at 22:25











  • What are you using to build the Vue.js application? Is it a vue-cli project?

    – Lukas Knuth
    Dec 28 '18 at 23:12











  • Yes it is. The command is: vue-cli-service build

    – user9540018
    Dec 29 '18 at 0:01








1




1





Duplicates (?) stackoverflow.com/questions/34518389/…

– joran
Dec 28 '18 at 19:42





Duplicates (?) stackoverflow.com/questions/34518389/…

– joran
Dec 28 '18 at 19:42













I don't think it is a duplicate. That is helpful but that would need to be run on the node server. How would I pass the result to the vue component?

– user9540018
Dec 28 '18 at 22:25





I don't think it is a duplicate. That is helpful but that would need to be run on the node server. How would I pass the result to the vue component?

– user9540018
Dec 28 '18 at 22:25













What are you using to build the Vue.js application? Is it a vue-cli project?

– Lukas Knuth
Dec 28 '18 at 23:12





What are you using to build the Vue.js application? Is it a vue-cli project?

– Lukas Knuth
Dec 28 '18 at 23:12













Yes it is. The command is: vue-cli-service build

– user9540018
Dec 29 '18 at 0:01





Yes it is. The command is: vue-cli-service build

– user9540018
Dec 29 '18 at 0:01












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53962583%2fhow-to-add-git-hash-to-vue-js-component%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53962583%2fhow-to-add-git-hash-to-vue-js-component%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas