version-everything
Use npm to version all kinds of projects, not just javascript.
Last updated 3 days 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.5.4

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

Travis Build Status codecov Coveralls github Code Climate maintainability
npm dependencies Status styled with prettier

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 or yaml).

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.config.js file
  3. version-everything.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"
  },
  "versionFiles": [
    "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.

Replacing version strings

In text files, the following version strings will be updated.

  • Version: 1.2.34
  • ### Version: 2.34.5 (Markdown headings)
  • * @version 4.5.67
  • `some arbitrary text v0.5.4

Notes: Colons are optional. Simple v-prefixed, git-tag style version strings must appear at the end of a line.

version-everything config files

This project uses the cosmiconfig library to load config files.the file-key should be version-everything, so files like .version-everythingrc or .version-everythingrc.js will work.

The file should export a simple JS object and 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

Conflicting arguments

If a package.json is specified, it will be loaded first, then any subsequent args will be applied on top. So if package.json were to contain a version-everything.files array, that array would be overwritten by any list of files provided to the command line.

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.5.4                                ...           latest (3 days ago)

15 Versions

  • 0.5.4                                ...           3 days ago
  • 0.5.0                                ...           7 days ago
  • 0.4.0                                ...           a month ago
  • 0.3.1                                ...           a month ago
  • 0.3.0                                ...           a month ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           2 years 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                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 1
This Week 18
This Month 47
Last Day 0
Last Week 29
Last Month 65
Dependencies (9)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |