Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
grunt-auto-version
Advanced tools
Readme
This is a grunt plugin and can automate the versioning of any file (be it .html/.css/.js/.scss/.php etc type) and backs-up the current modified files. This has hard dependency on Git. So if you are using Git as your SCM tool, it is good to use to automate file versioning. It is very useful in case of static files (e.g .css/ .js /.scss) where files are versioned very frequently with every release, because it ensures a unique version of a modified file goes to the production environment which in turn ensures caching issues of those modified files on CDN servers will be minimized.
Before you get start with grunt-auto-version, be sure to check the Getting Started guide of Grunt. Once you are well familiar with process, you may install this plugin with below mentioned command.
npm install grunt-auto-version --save-dev
After installation of the plugin, you need to write below line of code in your GruntFile.
grunt.file.expand('./../node_modules/grunt-*/tasks').forEach(grunt.loadTasks);
OR
grunt.loadNpmTasks('grunt-auto-version');
Above lines of code will include the autoversioning plugin's tasks in your gruntfile. This plugin completes with set of three tasks. Before we go ahead with the tasks, let's know how this plugin works:
While creating a branch from release or master branch of your Git repository, we create a filetable(a file database) where information reagrding the files are stored. e.g file's name, file's versionable attribute(true/false), file's latest version etc.
Once you modify a file in your repository, it's state is tracked through Git and plugin gets it's version from the filetable(file database) and creates a new file with next version and reverts the current modified file.
When merging your release branch to the current branch, it is ensured that our filetable(file database) is updated such that latest version of a conflicted file is updated into the filetable and it's versionable attribute is made true so that it can be versioned further after plugin's autoversioning job is run.And this way, only a unique version of a file goes to the live environment.
Now the tasks accompanied with the steps described above are as following:
this task is to be run while creating a branch from master or release branch of your project repository on Git.
Before running this task include following task code in the gruntfile. Description of the task parameters is given below.
create:{
options:{
fileExts:['.js','.css','.scss']
},
src:[
'src/jass',
'src/sass',
'src/j',
'src/c'
]
}
Description of the task parameters:
Type: Array
Default: ['.js','.css','.scss']
Description: this is array of different file extension type which can be versioned
Type: Array
Default: []
Description: this is array of different directories where auto versioning is to be implemented
Now run this task with the command
grunt create --bn=YourBranchName
this command will basically create a branch specified by you along with a fileTable(file database, which keeps track of files, their latetest version, a flag that indicates whether the file can be versioned further or not). If you need to recreate your fileTable due to some reasons(like file database is not in sync with repository), you need to run below command:
grunt create --recreate=true
You directly need to go and make changes in a file without caring of it's backup. Once you are done with the changes,run the auto version task command which is given below.It will create the new versions of file which are modified and back-up the existing file as well.
Before running this task include following task code in the gruntfile. Description of the task parameters is given below.
av:{
options:{
blackListedFiles:['Gruntfile.js','fileTable.json']
},
src:[
'src/jass',
'src/sass',
'src/j',
'src/c'
]
}
Description of the task parameters:
Type: Array
Default: ['Gruntfile.js','fileTable.json']
Description: this is the array of files which must not version at all.
Type: Array
Default: []
Description: this is array of different directories where auto versioning is to be implemented
Now run this task with the command
grunt av
This task is to be run when merging release or master branch into your current branch. Before running this task include following task code in the gruntfile. description of the task parameters is given below.
merge:{
src:[
'src/jass',
'src/sass',
'src/j',
'src/c'
]
}
Description of the task parameters:
Type: Array
Default: []
Description: this is array of different directories where auto versioning is to be implemented. It has to be same that of the 'create' task.
Now run this task with the command
grunt merge --bn=BranchNameToBeMerged
grunt-auto-version is open source. Help us by submitting merge requests, forking and playing around with the codebase :-)
Get in touch with me to share suggestions, thoughts and queries at: hsd.1989@gmail.com
Please see LICENSE.md for details.
FAQs
this grunt plugin automates versioning of modified files and backs-up the files as well.This is integrated with Git and quite helpful for the versioning of static resources which needs to versioned to remove caching on CDN servers.
We found that grunt-auto-version demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).