• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Shell
  • License
    Do What The F*ck ...
  • Created over 10 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Publish npm packages with fewer screw-ups

xyz

xyz simplifies the publishing of npm packages by replacing several manual steps with a single command:

$ xyz
Current version is 0.6.0. Press [enter] to publish [email protected].โ–Œ

Several things will happen if one elects to continue:

npm prune
npm test
env VERSION=0.6.1 node -e '
  var pkg = require("./package.json");
  pkg.version = process.env.VERSION;
  fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n");
'
git add package.json
git commit --message 'Version 0.6.1'
git tag --annotate v0.6.1 --message 'Version 0.6.1'
git push --atomic origin refs/heads/master refs/tags/v0.6.1
env VERSION=0.6.1 PREVIOUS_VERSION=0.6.0 bash -c 'npm publish'

macOS Mojave, released in 2018, provides a version of Bash from 2007. xyz uses a feature added in Bash 4, released in 2009. macOS users should run brew install bash to install a compatible Bash version.

Usage

Usage: xyz [options]

Publish a new version of the npm package in the current working directory.
This involves updating the version number in package.json, committing this
change (along with any staged changes), tagging the commit, pushing to the
remote git repository, and finally publishing to the public npm registry.

Options:

-b --branch <name>
        Specify the branch from which new versions must be published.
        xyz aborts if run from any other branch to prevent accidental
        publication of feature branches. 'master' is assumed if this
        option is omitted.

-e --edit
        Allow the commit message to be edited before the commit is made.

-i --increment <level>
        Specify the level of the current version number to increment.
        Valid levels: 'major', 'minor', 'patch', 'premajor', 'preminor',
        'prepatch', and 'prerelease'. 'patch' is assumed if this option
        is omitted. Choosing one of the pre-releases causes the npm dist-tag
        to be set according to --prerelease-label.

-m --message <template>
        Specify the format of the commit (and tag) message.
        'X.Y.Z' acts as a placeholder for the version number.
        'Version X.Y.Z' is assumed if this option is omitted.

   --prerelease-label <label>
        Specify the label to be used in the version number when publishing
        a pre-release version (e.g. 'beta' is the label in '2.0.0-beta.0').
        'rc' is assumed if this option is omitted. If the release is a
        pre-release, as indicated by --increment, the --prerelease-label will
        be used to create an npm dist-tag for the release.

   --publish-command <command>
        Specify the command to be run to publish the package. It may refer
        to the VERSION and PREVIOUS_VERSION environment variables. A no-op
        command (':' or 'true') prevents the package from being published
        to a registry. 'npm publish' is assumed if this option is omitted.
        If this option is provided, the --prerelease-label will not be used
        to create an npm dist-tag for the release.

-r --repo <repository>
        Specify the remote repository to which to 'git push'.
        The value must be either a URL or the name of a remote.
        The latter is not recommended: it relies on local state.
        'origin' is assumed if this option is omitted.

-s --script <path>
        Specify a script to be run after the confirmation prompt.
        It is passed VERSION and PREVIOUS_VERSION as environment
        variables. xyz aborts if the script's exit code is not 0.

-t --tag <template>
        Specify the format of the tag name. As with --message,
        'X.Y.Z' acts as a placeholder for the version number.
        'vX.Y.Z' is assumed if this option is omitted.

   --dry-run
        Print the commands without evaluating them.

-v --version
        Print xyz's version number and exit.

Integration

Installing xyz globally is okay, but it's good practice to add it as a dev dependency.

npm

  "scripts": {
    "release": "xyz --repo [email protected]:owner/repo.git --increment",
  }
$ npm run release minor

Make

XYZ = node_modules/.bin/xyz --repo [email protected]:owner/repo.git

.PHONY: release-major release-minor release-patch
release-major release-minor release-patch:
	@$(XYZ) --increment $(@:release-%=%)
$ make release-minor

More Repositories

1

Base64.js

Polyfill for browsers that don't provide window.btoa and window.atob
JavaScript
489
star
2

string-format

JavaScript string formatting inspired by Pythonโ€™s `str.format()`
JavaScript
332
star
3

doctest

Doctests for JavaScript (and CoffeeScript)
JavaScript
165
star
4

tutor

JavaScript interface for the Gatherer card database
CoffeeScript
149
star
5

transcribe

๐Ÿ“ Generate Markdown documentation from code comments
JavaScript
79
star
6

an.hour.ago

A small utility which enables wonderfully expressive date and time manipulation in JavaScript
CoffeeScript
69
star
7

nucleotides

The building blocks of JavaScript programs
JavaScript
32
star
8

airwaves

Broadcast on a dedicated frequency
CoffeeScript
25
star
9

mathmethods

A tiny script which makes methods of the `Math` object available to numbers by adding properties to `Number.prototype`
CoffeeScript
17
star
10

orthogonal

DSL for describing simple vector graphics
CoffeeScript
14
star
11

CANON

Canonical object notation
JavaScript
12
star
12

jQuery.localize

โŒš jQuery plugin for localizing dates and times via the `datetime` attribute of the HTML5 `<time>` element
JavaScript
8
star
13

hex2xterm

๐ŸŒˆ Convert hexadecimal colour codes to xterm colour codes
JavaScript
3
star
14

fp-workshop

FP workshop presented at HolidayCheck in Munich on 2016-12-14
JavaScript
3
star
15

remember-bower

๐Ÿฆ Never forget to update dependencies in bower.json again
JavaScript
2
star
16

cube

Magic: The Gathering Cube
HTML
2
star
17

deedpoll

๐Ÿ“„ Flag incorrectly named identifiers in JavaScript programs
Shell
2
star
18

contenteditable

A jQuery utility which adds useful behaviour to `contenteditable` text
CoffeeScript
2
star
19

rich

JavaScriptโ€™s missing stdlib
1
star
20

davidchambersdesign.com

1
star
21

Homelands-Constructed

Lists from a terrific Homelands Constructed tournament held in Auckland on 27/12/2011
1
star
22

got-lambda

Repository used during Got.ฮป presentation on 1 September 2016
JavaScript
1
star