2.1.1 • Published 6 years ago

hc-version-txt v2.1.1

Weekly downloads
100
License
MIT
Repository
github
Last release
6 years ago

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"
    }
}
2.1.1

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago