hc-version-txt

Version txt file generator

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
hc-version-txt
2.1.14 years ago5 years agoMinified + gzip package size for hc-version-txt in KB

Readme

npm node Unit tests
Version txt/json
A node module which generates a txt/json file in your distribution directory which in turn gets deployed to your server and could then be viewed e.g yourdomain.com/version.txt or yourdomain.com/version.json this will then allow you to verify your deployment onto a server.
Prerequisites
  • node version >= 8.0.0
Install
npm install hc-version-txt --save
Configuration
In the root of your project add a '.version-txt.json' file and insert the following:
  • projectName is required (can be defined in the config or passed in through buildFile function)
  • distDirectory is required (can be defined in the config or passed in through buildFile function)
  • distFilename is required
  • distFiletypes is required (can be the following values "json", "txt" || "json" || "txt"

{
    "$schema": "./node_modules/hc-version-txt/assets/schema.json",
    "projectName": "hc-digilab",
    "distDirectory": "dist",
    "distFilename": "version",
    "distFiletypes": ["json", "txt"]
}
Gulpfile task
Add the following to your gulpfile.js:
const hcVersionTxt = require('hc-version-txt');

gulp.task('hcVersionTxt', function() {
    
    // picks up the projectName from the config file 
    hcVersionTxt.buildFile();

    // pass in the projectName as a parameter
    // pass in the distDirectory as a parameter
    hcVersionTxt.buildFile({ 
        projectName: 'example',
        distDirectory: 'dist/example'
    });
});
Node script
Add the following to your node script
const hcVersionTxt = require('hc-version-txt');

 // picks up the projectName from the config file 
hcVersionTxt.buildFile();

// pass in the projectName as a parameter
// pass in the distDirectory as a parameter
hcVersionTxt.buildFile({ 
    projectName: 'example' ,
    distDirectory: 'dist/example'
});
Example txt output
Site: hc-digilab

Deployment
Date: 28/05/2018 17:48PM
Branch: develop
Hash: ef13c39
Example json output
{
    "site": "hc-digilab",
    "deployment": {
        "date": "28/05/2018 17:48PM",
        "branch": "develop",
        "hash": "ef13c39"
    }
}