Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@credenceanalytics/inject-vue-app-version

Package Overview
Dependencies
Maintainers
11
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@credenceanalytics/inject-vue-app-version

Adds app version into a environment variable and in a file, version text consits a cureent time date and time and git branch name

latest
npmnpm
Version
1.0.10
Version published
Maintainers
11
Created
Source

Installation

npm i -D @credenceanalytics/inject-vue-app-version

How to inject a app version in vue application ?

  • Install @credenceanalytics/inject-vue-app-version package from npm repository.
  • Create version.txt file in your app your_app > current_app_version > version.txt
  • Now import @credenceanalytics/inject-vue-app-version package in your vue.config.js file at line no.1.
    // vue.config.js
    require("@credenceanalytics/inject-vue-app-version");
    ...
  • This package injects a VUE_APP_VERSION in to environment variables.
  • VUE_APP_VERSION consists a build time (current date and time) and git branch name (current branch name).
  • version.txt will get updated with VUE_APP_VERSION version value.
  • To print app version in browser, add this line console.log("%c" + process.env.VUE_APP_VERSION, "color:blue;font-size: 14px;font-weight: 700") in mounted or created hook of your entry vue file.
    // App.vue
    export default {
        name: 'app',
        components: {
            ...
        },
        created() {
            console.log("%c" + process.env.VUE_APP_VERSION, "color:blue;font-size: 14px;font-weight: 700")
        },
        mounted (){
            ...
        }
    }

Example

  • First create a directory current_app_version in your root project with empty version.txt file.
  • Now in your vue.config.js require this library.
    // vue.config.js
    require("@credenceanalytics/inject-vue-app-version");
    ...
  • Print the version in your entry component file i.e in src/App.vue.
    // App.vue
    <template>
        ...
    </template>

    <script>
        export default {
            name: "app",
            ...,
            created() {
                ...
                console.log("%c" + process.env.VUE_APP_VERSION, "color:blue;font-size: 14px;font-weight: 700")
            }
        }
    </script>

FAQs

Package last updated on 27 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts