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-version-number

v0.2.4

Published

Add version number to css/js/image... in HTML file.

Downloads

6,013

Readme

gulp-version-number

Add version number to js/css/image in HTML

NPM version

usage

var version = require('gulp-version-number');

gulp.src('src/*.html')
    .pipe(version({
		... configuration ...
    }))
    .pipe(gulp.dest('build'));

configuration

config

{

    /**
     * Global version value
     * default: %MDS%
     */
    'value' : '%MDS%',

    /**
     * MODE: REPLACE
     * eg:
     *    'keyword'
     *    /regexp/ig
     *    ['keyword']
     *    [/regexp/ig, '%MD5%']]
     */
    'replaces' : [
    
        /**
         * {String|Regexp} Replace Keyword/Rules to global value (config.value)
         */
        '#{VERSION_REPlACE}#',
        
        /**
         * {Array}
         * Replace keyword to custom value
         * if just have keyword, the value will use the global value (config.value).
         */    
        [/#{VERSION_REPlACE}#/g, '%TS%']
    ],
    
    
    /**
     * MODE: APPEND
     * Can coexist and replace, after execution to replace
     */
    'append' : {
    
        /**
         * Parameter
         */
        'key' : '_v',
        
        /**
         * Whether to overwrite the existing parameters
         * default: 0 (don't overwrite)
         * If the parameter already exists, as a "custom", covering not executed.
         * If you need to cover, please set to 1
         */
        'cover' : 0,
        
        /**
         * Appended to the position (specify type)
         * {String|Array|Object}
         * If you set to 'all', will apply to all type, rules will use the global setting.
         * If an array or object, will use your custom rules.
         * others will passing.
         * 
         * eg:
         *     'js'
         *     ['js']
         *     {type:'js'}
         *     ['css', '%DATE%']
         */
        'to' : [
        
            /**
             * {String} Specify type, the value is the global value
             */
            'css',
            
            /**
             * {Array}
             * Specify type, keyword and cover rules will use the global 
             * setting, If you need more details, please use the object 
             * configure.
             *
             * argument 0 necessary, otherwise passing.
             * argument 1 optional, the value will use the global value
             */
              ['image', '%TS%'],
              
            /**
             * {Object}
             * Use detailed custom rules to replace, missing items will 
             * be taken in setting the global completion
             
             * type is necessary, otherwise passing.
             */
            {
                'type'  : 'js',
                'attr'  : ['src', 'custom-src'] // String or Array, undefined this will use default. css: "href", js: ...
                'key'   : '_v',
                'value' : '%DATE%',
                'cover' : 1,
                'files': ['build.js', /dependency.js/] // Array [{String|Regex}] of explicit files to append to
            }
        ]
    },
 
    /**
     * Output to config file
     */
    'output' : {
        'file' : 'version.json'
    }
}

Priority - Covering relations

  • {Object}config.append.to[x].type == {Array}config.append.to[x][0] == {String}config.append.to[x]
  • config.append.to[x].key > config.append.key
  • config.append.to[x].cover > config.append.cover
  • config.append.to[x].value == config.append.to[x][1] [ (IF cover is TRUE) > (ELSE) == config.replace[x][1] ] > config.value

Options

Version types

  • %DATE% date [YYYYMMDD]
  • %DT% date + time [YYYYMMDDHHIISS]
  • %TS% timestamp [INT10]
  • %TSM% timestamp(millisecond) [INT13]
  • %MD5% MD5(timestamp) [STRING32]
  • %MDS% MD5(MD5(timestamp) + salt) [STRING32]
  • {STRING} In addition to the above keywords, considered custom

Change log

= 0.2.0 =
  • Add a configure prop to "Object" model at "options.append.to", set the attribute what you want to match
append : {
 to : [
   '???': {
     ...,
     'attr': [...] // string or array
     ...
   },
   ...
 ]
}
= 0.1.4 =
  • Detailed description comment and readme.
  • Change salt to length 8
= 0.1.3 =
  • BUGFIX: css rules
= 0.1.2 =
  • Output function mounting, the version output to a file.
= 0.1.1 =
  • BUGFIX: regexp
= 0.1.0 =

I was born