version-everything
Use npm to version all kinds of projects, not just javascript.
Last updated 8 months ago by joemaller .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install version-everything 
SYNC missed versions from official npm registry.

version-everything

Version: 0.2.3

Use npm to version all kinds of projects, not just JavaScript

Build Status Coverage Status npm styled with prettier
dependencies Status devDependencies Status

Synchronize the version string from package.json into a set of additional text or structured data files. When called from npm's version script, all versioned files in a project will be updated and committed with a single command.

    npm install --save version-everything

How to version everything

There are several ways version-everything can be used, the only requirement is an array of files to synchronize versions into. The files can be text (php, css, markdown, whatever) or structured data (JSON, yaml or xml).

The file list is an array specified in one of the following forms, in order of precedence:

  1. Command line arguments
  2. files key in a .version-everything.js file
  3. version_files key in the parent project's package.json file

npm lifecycle script in package.json

The simplest way to use version-everything is to hook into npm's version event. Once set up, a single npm command will update, commit and tag all versioned files in a project.

Add something like the following to your project's package.json file:

{
    "version": "1.3.6",
    "scripts": {
        "version": "version-everything && git add -u"
    },
    "version_files": [
        "README.md",
        "example_wordpress_plugin.php",
        "styles.css",
        "manifest.json",
        "sadness.xml"
    ]
}

Then run a command like npm version minor to bump the version in all the files. It's that easy.

Note that structured data files will be formatted using default settings.

.version-everything.js dotfile

Following the lead of projects like Webpack and ESLint, version-everything can also be configured using a JavaScript dotfile. While this introduces another file to the project, it offers additional configuration options, can be documented in place and keeps package.json cleaner.

A project's .version-everything.js file should be a sibling of the project's package.json file.

The basic schema of the config file should look something like this:

module.exports = {
    files: [
        "README.md",
        "example_wordpress_plugin.php",
        "styles.css"
    ],
    json: { /* optional json config object, keys pass directly to JSON.stringify */ },
    yaml: { /* optional yaml config object, passes directly to js-yaml */ },
    xml: { /* optional xml config object, passes directly to xml2js */ }
}

Calling the version-everything binary prefers this file over settings in package.json.

CommonJS module requires

Version-everything can also be used like any other Node module. The version string will be pulled from package.json and should be treated as a global constant or envvar.

const version = require('version-everything');

version(["README.md", "manifest.json"], { json: {space: 4} });

Command Line Interface

When run from the command line, all arguments following the command are assumed to be file paths. This command would sync versions into readme.md and manifest.json:

$ version-everything readme.md manifest.json

Recognized File Extensions

Files with the following extensions will be recognized as structured text and parsed accordingly.

  • JSON - .json
  • XML - .xml, .plist
  • YAML - .yml, .yaml

API

versionEverything(files, [options])

files

Type: array

An array containing the files which will be versioned.

options

Type: object All keys are optional.

json

Type: object Three keys from the json object will be passed directly to JSON.parse or JSON.stringify: space which sets indentation from an integer or string, a reviver function and a replacer function/array. See the JSON docs for more info.

xml

Type: object Passed directly to the xml2js Builder class. See xml2js docs for available options.

yaml

Type: object Passed directly to the js-yaml safeDump method. See js-yaml docs for available options.

Notes

npm may fail to commit/tag files when package.json is nested below the git repository root. Ref: npm#18795

While this module strongly encourages the use of true SemVer versions, these are not enforced. Just about any wacky version string without a whitespace character should work.

phpDocumentor @version tag vcs-prefixes and version-descriptions will be dropped.

Current Tags

  • 0.2.3                                ...           latest (8 months ago)

10 Versions

  • 0.2.3                                ...           8 months ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
  • 0.1.5                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 1
Last Week 2
Last Month 21
Dependencies (8)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |