npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-versioniser

v1.0.2

Published

Automatically increment version numbers to file names.

Downloads

1

Readme

Gulp Env Modify

Add, edit, delete and read variables from a .env file. There is also functionality to help manage version named files.

Installation

npm i gulp-env-modify --save

Setup

const envmod = require('gulp-env-modify')
const env = envmod.getData()
console.log(env)

Data functions

Get File [string]

Get the .env file contents as a string

envmod.getFile()

First parameter can be the path to your .env file relative to the gulpfile.js


Get Data [object]

Get the .env file content with all the variables and values passed into an object

envmod.getData()

First parameter can be a direct request for a variable. Second parameter can be the path to your .env file relative to the gulpfile.js


Get & Set functions

Set Variable

Add a variable and value to the .env file. Variable will be created if it isn't found. It will be overwritten if it does exists.

envmod.setVariable(variable, value)


Get Variable [string]

Get variable from .env file.

envmod.getVariable(variable)


Versioning functions

There are a few options to manage variables that are suffixed with "_VERSION". The purpose for this (and the reason I built this plugin), is to increment a variable each time a certain gulp task is called. Allowing me to generate unique file names for concatenated files. Ultimately this helps avoid browsers from caching old files whilst avoiding the use of ugly and unreliable url parameters.

Get Version [int]

Get the version number of a variable

envmod.getVersion(variable)


Update Version [int]

Update the version number of a variable by incrementing the number by one. | Parameter | Type | Description | | - | - | - | | name | string | The name of the variable that prefixes the _VERSION variable | | force | int | By default this function will increment by one. However, you can update a variable to a specific number.|

envmod.updateVersion(variable)


Get Version Name

To modify the filename for your gulp task, you will need to generate a dynamic name to match your latest version. This gives you that new filename.

| Parameter | Type | Description | | - | - | - | | file | string | The original filename | | variable | string | To find the latest version number, define the variable name to look for in the .env file. You do not need to include the suffix '_VERSION' | | end | bool | Choose where the version number appears in the filename. This function looks for the FIRST full stop in the string, and prepends the version number to that. However there may be cases where there are multiple full stops in a string. Define true to explicitly prepend the version number to the LAST full stop in the string. This is true by default. |

modenv.getVersionName('main.min.js', 'js', true)

This will look for the JS_VERSION=12 in your .env file and return a string that looks like this

main.v12.min.js

If you set the end boolean to false, this would be returned instead:

main.min.v12.js


Update Version Name

This essentially does the exact same thing as getVersionName, only it will increment the version in the .env file before returning the name filename.


Delete Versions

Versioned files may start to get overwhelming and unnecessary. This lets you keep a set amount of versioned files.

| Parameter | Type | Description | | - | - | - | | directory | string | Relative to your gulpfile.js, point to where your versioned files are stored. | | original | string | Pass the original filename so the comparison can match files after the version number has be verified | | keep | int | Define how many versions of your versioned files you want to keep. By default this is set to 5.|

envmod.deleteVersions('assets/js/', 'main.min.js', 3)


Credit

Couldn't have built this without gulp-dotenv. Thank you.