Giter Club home page Giter Club logo

standard-version's Introduction

Standard Version

standard-version is deprecated. If you're a GitHub user, I recommend release-please as an alternative. If you're unable to use GitHub Actions, or if you need to stick with standard-version for some other reason, you can use the commit-and-tag-version fork of standard-version.

A utility for versioning using semver and CHANGELOG generation powered by Conventional Commits.

ci NPM version codecov Conventional Commits Community slack

Having problems? Want to contribute? Join us on the node-tooling community Slack.

How It Works:

  1. Follow the Conventional Commits Specification in your repository.
  2. When you're ready to release, run standard-version.

standard-version will then do the following:

  1. Retrieve the current version of your repository by looking at packageFiles[1], falling back to the last git tag.
  2. bump the version in bumpFiles[1] based on your commits.
  3. Generates a changelog based on your commits (uses conventional-changelog under the hood).
  4. Creates a new commit including your bumpFiles[1] and updated CHANGELOG.
  5. Creates a new tag with the new version number.

bumpFiles, packageFiles and updaters

standard-version uses a few key concepts for handling version bumping in your project.

  • packageFiles – User-defined files where versions can be read from and be "bumped".
    • Examples: package.json, manifest.json
    • In most cases (including the default), packageFiles are a subset of bumpFiles.
  • bumpFiles – User-defined files where versions should be "bumped", but not explicitly read from.
    • Examples: package-lock.json, npm-shrinkwrap.json
  • updaters – Simple modules used for reading packageFiles and writing to bumpFiles.

By default, standard-version assumes you're working in a NodeJS based project... because of this, for the majority of projects you might never need to interact with these options.

That said, if you find your self asking How can I use standard-version for additional metadata files, languages or version files? – these configuration options will help!

Installing standard-version

As a local npm run script

Install and add to devDependencies:

npm i --save-dev standard-version

Add an npm run script to your package.json:

{
  "scripts": {
    "release": "standard-version"
  }
}

Now you can use npm run release in place of npm version.

This has the benefit of making your repo/package more portable, so that other developers can cut releases without having to globally install standard-version on their machine.

As global bin

Install globally (add to your PATH):

npm i -g standard-version

Now you can use standard-version in place of npm version.

This has the benefit of allowing you to use standard-version on any repo/package without adding a dev dependency to each one.

Using npx

As of [email protected], npx is installed alongside npm. Using npx you can use standard-version without having to keep a package.json file by running: npx standard-version.

This method is especially useful when using standard-version in non-JavaScript projects.

Configuration

You can configure standard-version either by:

  1. Placing a standard-version stanza in your package.json (assuming your project is JavaScript).
  2. Creating a .versionrc, .versionrc.json or .versionrc.js.
  • If you are using a .versionrc.js your default export must be a configuration object, or a function returning a configuration object.

Any of the command line parameters accepted by standard-version can instead be provided via configuration. Please refer to the conventional-changelog-config-spec for details on available configuration options.

Customizing CHANGELOG Generation

By default (as of 6.0.0), standard-version uses the conventionalcommits preset.

This preset:

  • Adheres closely to the conventionalcommits.org specification.
  • Is highly configurable, following the configuration specification maintained here.
    • We've documented these config settings as a recommendation to other tooling makers.

There are a variety of dials and knobs you can turn related to CHANGELOG generation.

As an example, suppose you're using GitLab, rather than GitHub, you might modify the following variables:

  • commitUrlFormat: the URL format of commit SHAs detected in commit messages.
  • compareUrlFormat: the URL format used to compare two tags.
  • issueUrlFormat: the URL format used to link to issues.

Making these URLs match GitLab's format, rather than GitHub's.

CLI Usage

NOTE: To pass nested configurations to the CLI without defining them in the package.json use dot notation as the parameters e.g. --skip.changelog.

First Release

To generate your changelog for your first release, simply do:

# npm run script
npm run release -- --first-release
# global bin
standard-version --first-release
# npx
npx standard-version --first-release

This will tag a release without bumping the version bumpFiles1.

When you are ready, push the git tag and npm publish your first release. \o/

Cutting Releases

If you typically use npm version to cut a new release, do this instead:

# npm run script
npm run release
# or global bin
standard-version

As long as your git commit messages are conventional and accurate, you no longer need to specify the semver type - and you get CHANGELOG generation for free! \o/

After you cut a release, you can push the new git tag and npm publish (or npm publish --tag next) when you're ready.

Release as a Pre-Release

Use the flag --prerelease to generate pre-releases:

Suppose the last version of your code is 1.0.0, and your code to be committed has patched changes. Run:

# npm run script
npm run release -- --prerelease

This will tag your version as: 1.0.1-0.

If you want to name the pre-release, you specify the name via --prerelease <name>.

For example, suppose your pre-release should contain the alpha prefix:

# npm run script
npm run release -- --prerelease alpha

This will tag the version as: 1.0.1-alpha.0

Release as a Target Type Imperatively (npm version-like)

To forgo the automated version bump use --release-as with the argument major, minor or patch.

Suppose the last version of your code is 1.0.0, you've only landed fix: commits, but you would like your next release to be a minor. Simply run the following:

# npm run script
npm run release -- --release-as minor
# Or
npm run release -- --release-as 1.1.0

You will get version 1.1.0 rather than what would be the auto-generated version 1.0.1.

NOTE: you can combine --release-as and --prerelease to generate a release. This is useful when publishing experimental feature(s).

Prevent Git Hooks

If you use git hooks, like pre-commit, to test your code before committing, you can prevent hooks from being verified during the commit step by passing the --no-verify option:

# npm run script
npm run release -- --no-verify
# or global bin
standard-version --no-verify

Signing Commits and Tags

If you have your GPG key set up, add the --sign or -s flag to your standard-version command.

Lifecycle Scripts

standard-version supports lifecycle scripts. These allow you to execute your own supplementary commands during the release. The following hooks are available and execute in the order documented:

  • prerelease: executed before anything happens. If the prerelease script returns a non-zero exit code, versioning will be aborted, but it has no other effect on the process.
  • prebump/postbump: executed before and after the version is bumped. If the prebump script returns a version #, it will be used rather than the version calculated by standard-version.
  • prechangelog/postchangelog: executes before and after the CHANGELOG is generated.
  • precommit/postcommit: called before and after the commit step.
  • pretag/posttag: called before and after the tagging step.

Simply add the following to your package.json to configure lifecycle scripts:

{
  "standard-version": {
    "scripts": {
      "prebump": "echo 9.9.9"
    }
  }
}

As an example to change from using GitHub to track your items to using your projects Jira use a postchangelog script to replace the url fragment containing 'https://github.com/`myproject`/issues/' with a link to your Jira - assuming you have already installed replace

{
  "standard-version": {
    "scripts": {
      "postchangelog": "replace 'https://github.com/myproject/issues/' 'https://myjira/browse/' CHANGELOG.md"
    }
  }
}

Skipping Lifecycle Steps

You can skip any of the lifecycle steps (bump, changelog, commit, tag), by adding the following to your package.json:

{
  "standard-version": {
    "skip": {
      "changelog": true
    }
  }
}

Committing Generated Artifacts in the Release Commit

If you want to commit generated artifacts in the release commit, you can use the --commit-all or -a flag. You will need to stage the artifacts you want to commit, so your release command could look like this:

{
  "standard-version": {
    "scripts": {
      "prerelease": "webpack -p --bail && git add <file(s) to commit>"
    }
  }
}
{
  "scripts": {
    "release": "standard-version -a"
  }
}

Dry Run Mode

running standard-version with the flag --dry-run allows you to see what commands would be run, without committing to git or updating files.

# npm run script
npm run release -- --dry-run
# or global bin
standard-version --dry-run

Prefix Tags

Tags are prefixed with v by default. If you would like to prefix your tags with something else, you can do so with the -t flag.

standard-version -t @scope/package\@

This will prefix your tags to look something like @scope/[email protected]

If you do not want to have any tag prefix you can use the -t flag and provide it with an empty string as value.

Note: simply -t or --tag-prefix without any value will fallback to the default 'v'

CLI Help

# npm run script
npm run release -- --help
# or global bin
standard-version --help

Code Usage

const standardVersion = require('standard-version')

// Options are the same as command line, except camelCase
// standardVersion returns a Promise
standardVersion({
  noVerify: true,
  infile: 'docs/CHANGELOG.md',
  silent: true
}).then(() => {
  // standard-version is done
}).catch(err => {
    console.error(`standard-version failed with message: ${err.message}`)
})

TIP: Use the silent option to prevent standard-version from printing to the console.

FAQ

How is standard-version different from semantic-release?

semantic-release is described as:

semantic-release automates the whole package release workflow including: determining the next version number, generating the release notes and publishing the package.

While both are based on the same foundation of structured commit messages, standard-version takes a different approach by handling versioning, changelog generation, and git tagging for you without automatic pushing (to GitHub) or publishing (to an npm registry). Use of standard-version only affects your local git repo - it doesn't affect remote resources at all. After you run standard-version, you can review your release state, correct mistakes and follow the release strategy that makes the most sense for your codebase.

We think they are both fantastic tools, and we encourage folks to use semantic-release instead of standard-version if it makes sense for their use-case.

Should I always squash commits when merging PRs?

The instructions to squash commits when merging pull requests assumes that one PR equals, at most, one feature or fix.

If you have multiple features or fixes landing in a single PR and each commit uses a structured message, then you can do a standard merge when accepting the PR. This will preserve the commit history from your branch after the merge.

Although this will allow each commit to be included as separate entries in your CHANGELOG, the entries will not be able to reference the PR that pulled the changes in because the preserved commit messages do not include the PR number.

For this reason, we recommend keeping the scope of each PR to one general feature or fix. In practice, this allows you to use unstructured commit messages when committing each little change and then squash them into a single commit with a structured message (referencing the PR number) once they have been reviewed and accepted.

Can I use standard-version for additional metadata files, languages or version files?

As of version 7.1.0 you can configure multiple bumpFiles and packageFiles.

  1. Specify a custom bumpFile "filename", this is the path to the file you want to "bump"
  2. Specify the bumpFile "updater", this is how the file will be bumped. a. If you're using a common type, you can use one of standard-version's built-in updaters by specifying a type. b. If your using an less-common version file, you can create your own updater.
// .versionrc
{
  "bumpFiles": [
    {
      "filename": "MY_VERSION_TRACKER.txt",
      // The `plain-text` updater assumes the file contents represents the version.
      "type": "plain-text"
    },
    {
      "filename": "a/deep/package/dot/json/file/package.json",
      // The `json` updater assumes the version is available under a `version` key in the provided JSON document.
      "type": "json"
    },
    {
      "filename": "VERSION_TRACKER.json",
      //  See "Custom `updater`s" for more details.
      "updater": "standard-version-updater.js"
    }
  ]
}

If using .versionrc.js as your configuration file, the updater may also be set as an object, rather than a path:

// .versionrc.js
const tracker = {
  filename: 'VERSION_TRACKER.json',
  updater: require('./path/to/custom-version-updater')
}

module.exports = {
  bumpFiles: [tracker],
  packageFiles: [tracker]
}

Custom updaters

An updater is expected to be a Javascript module with atleast two methods exposed: readVersion and writeVersion.

readVersion(contents = string): string

This method is used to read the version from the provided file contents.

The return value is expected to be a semantic version string.

writeVersion(contents = string, version: string): string

This method is used to write the version to the provided contents.

The return value will be written directly (overwrite) to the provided file.


Let's assume our VERSION_TRACKER.json has the following contents:

{
  "tracker": {
    "package": {
      "version": "1.0.0"
    }
  }
}

An acceptable standard-version-updater.js would be:

// standard-version-updater.js
const stringifyPackage = require('stringify-package')
const detectIndent = require('detect-indent')
const detectNewline = require('detect-newline')

module.exports.readVersion = function (contents) {
  return JSON.parse(contents).tracker.package.version;
}

module.exports.writeVersion = function (contents, version) {
  const json = JSON.parse(contents)
  let indent = detectIndent(contents).indent
  let newline = detectNewline(contents)
  json.tracker.package.version = version
  return stringifyPackage(json, indent, newline)
}

License

ISC

standard-version's People

Contributors

aldoreno avatar bcoe avatar djaler avatar dsole avatar e-cloud avatar eemeli avatar github-actions[bot] avatar greenkeeperio-bot avatar jakxz avatar jbottigliero avatar karunalakshman avatar medikoo avatar merceyz avatar micaelmbagira avatar minigod avatar mvayngrib avatar nexdrew avatar noahrc avatar noreiller avatar pioluk avatar pvgnd avatar release-please[bot] avatar renovate[bot] avatar revelt avatar rjmohammad avatar roschaefer avatar stevemao avatar tapppi avatar tomchentw avatar tommywo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

standard-version's Issues

Support pre release

I have been using standard-version now for a few weeks, and I realised that there is no support for pre-releases such as 1.0.0-alpha-1, 2.0.0-beta-1 (AFAIK).

Is there any plan to support them?

non-formatted tag annotation

Hi!

I noted the presence of %s in the annotation of the tag generated by standard-version.
I'm preparing a PR to fix it (including a non-regression test).

I'll propose this PR as soon as the PR about tag signing will be pulled.

doens't handle git commit callback properly

I have a git hook to check code style before commit(using eslint). If my code has error style, commit will not continue. If only have warnings, they will be shown, but commit can continue.

now standard-version will perform a release commit, which will also trigger the git hook.

However, it treat all stderr as illegal and just exit without continuing to perform git tag.

see the code

i think it should either prevent the git hooks when committing or improve the error handler

Add EOL when overwriting package.json

Otherwise changes to package.json b/w releases can end up flip-flopping the last line since editors like Atom will automatically add it but standard-version strips it off - just becomes annoying, unnecessary changes in history and in PRs.

I think we just need to change this line:

fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf-8')

to something like this:

fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + require('os').EOL, 'utf-8')

Package appears to be failing on windows 7

I am running standard-version on windows 7, Node 6.4,0 NPM 3.10.7.
I am using it behind GitHub Enterprise but it works fine when run from Linux.

Any ideas on what may be going on here? It generates CHANGELOG just fine but then fails.

I have added the debug info. I had to remove some company and user names from paths. Apologies.

Review before commit

It would be very nice if there was a way to review

  • the suggested version and
  • the changelog that was generated
    during the workflow and adjust them if needed. Currently I have to go back and squash fix commits or redo to whole thing.

I imagine for the version it could be a nice interactive prompt telling you the version it will use and ask for either confirmation or a different version to be entered.

For the changelog it could work like git commit works, in that it opens the default $EDITOR and as soon as the file there is saved and closed it drops back into continuing the work.

Fix windows tests (CI)

Ok, not sure how I managed to miss this before. Tests with mocked git don't work on windows due to mock-git and its dep mock-bin:

  • mock-bin creates an executable script with a shebang, which windows does not support, PR: (stevemao/mock-bin#3)
  • mock-git doesn't escape slashes, PR: (stevemao/mock-git#3)
  • mock-git has no version range in its mock-bin dependency thus not getting the windows fix when it lands, issue: (stevemao/mock-git#5)

Both of these packages will need updates to make the mock tests work. I have created PRs in the respective repos and verified that standard-version tests are fixed with them. This issue is to track the progress of those fixes.

End of line warnings on windows stop commit

Using git config option core.autocrlf=true ends up never committing.

This is because:

  • Git warns to stderr about the LF line endings possibly being replaced by CRLF when the files are read from object storage
  • The cli aborts on stderr having been printed to

Workaround is to use core.autocrlf=input (which I suggest always using along with core.eol=lf anyway..). Not sure what should be done about this though...

Generate wip changelogs

I'd love to have a way to generate a master/upcoming chnages changelog, so even if there was no release the changelog would show the data from issues snce the latest release

Question: configuring different issue URL?

I've tried quite a few approaches and searched around and still can't seem to get this working, I was wondering if you could help please as I'm sure I must be doing something wrong.

I have a project which is hosted on a private GitLab and use Jira for issues which is hosted elsewhere. Regardless of what I've tried, the issue tracker link is always set to eg. http://[email protected]:group/project/issues/1234 – a strange hybrid of repository.url.

The notable parts of my package.json are below;

{
  "bugs": {
    "url": "https://foo.jira.com/browse-3/"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    },
    "ghooks": {
      "commit-msg": "validate-commit-msg"
    }
  },
  "devDependencies": {
    "cz-conventional-changelog": "1.1.6",
    "validate-commit-msg": "2.6.1",
    "standard-version": "2.3.0"
  },
  "issue": "https://foo.jira.com/browse-1/",
  "issues": "https://foo.jira.com/browse-2/",
  "repository": {
    "type": "git",
    "url": "[email protected]:group/project.git"
  },
  "scripts": {
    "release": "standard-version"
  }
}

allow any added files to be committed

currently npm version will do a commit which includes any staged files. This is useful in our scenario where we have additional files that our build needs to commit, in addition to the changelog and package.json. It would be nice if standard-version worked this way and/or allowed us to do the commit ourselves.

How to specify a range?

It is not clear how to specific a range when making a release, e.g. 8476abdb3851...5c9a2f048f9f. I would like to use Travis $TRAVIS_COMMIT_RANGE variable to control this setting.

Promises in tests are not waited for

Mock-git returns promises, but they aren't returned except in one of the test cases, causing a race condition between the .then() chained to the promise and the afterEach hook. This leads to possible corruption of root package.json and CHANGELOG.md.

Support for tag signing

Hi! Very nice project!

I'm currently signing my tags (git tag -s).
It could be nice to add an option to enforce tag signing.
Similar to the npm's option sign-git-tag.

Should it create the latest tag?

I wonder if standard-version should also set the latest tag when it defines the new tag.

Maybe with a specific option?

semantic-release sets the tag so I was expecting standard-version to do the same.

warn about dropping 0.10 support

@Tapppi @stevemao standard has also dropped < 4 support, but they've added this clever line to their CLI:

#!/usr/bin/env node

if (process.version.match(/v(\d+)\./)[1] < 4) {
  console.error('standard: Node v4 or greater is required. `standard` did not run.')
} else {
  var opts = require('../options')
  require('standard-engine').cli(opts)
}

explain the relationship to semantic-release

@stevemao recommends adding a section to the document describing the relationship between conventional-changelog and semantic-release:

  • conventional-changelog: is a loose standard for annotating your pull requests, and generating a version bump and changelog.
  • semantic-release: fully automates your release process, using the conventional-changelog format.
  • conventional-recommended-workflow: is a replacement for npm version, implementing a workflow recommended by @stevemao.

@boennemann have any thoughts you'd like to add, I see this tool as useful for engineering teams like npm, who want to start adding more structure to our commits but aren't quite ready for a fully automated release process.

add a releaseAs option?

Just realize we can't do standard-version patch here. Would be good to support this. Thoughts?

CHANGELOG entries added multiple times

I continue to occasionally create a scenario where changes are added to the CHANGELOG multiple times, across multiple releases:

1727ea8

I think we should dig into the root cause of this, and make it harder to cause. My hunch is that it's related to releasing a candidate release off of a branch; once that branch is merged, I would expect the history to be properly resolved without duplicates.

CC: @Tapppi, @stevemao

Exit only on error code?

So I have a post-commit hook which actually undo a commit if the history is not fully linear. Basically, it seems like any output that is made thru a commit hook, will end up on stderr. Since the code checks against that, it never gets to the tagging.

support for GitHub links

It would be cool if GitHub username and issue shorthands were supported by the standard-version CHANGELOG generation, e.g., @bcoe, #133

Incorrect behavior in case when several project major versions maintained

Hello. Thanks for the amazing library.

I have a small issue when standard-version bumps my versions incorrectly. After some investigation I've noticed that current version of https://github.com/stevemao/git-latest-semver-tag looks through all the tags in the project sorted by time to find the latest. This is incorrect, because of possible backports of fixes to the older versions.

This behaviour is already changed in the master branch of https://github.com/stevemao/git-latest-semver-tag, but the version is not published 😢

@stevemao could you please publish it and bump standard-version?

Feature/add preid param for semver

Issue to discuss #83

The idea is to allow adding identifiers to certain tags upon release such as beta, dev, rc, etc.

The proposed command would be:

standard-version -p --tag="<identifier>"

So that running standard-version -p --tag="special-release" would result in a tag something like 2.0.0-special-release.0. Using the prelease command -p repeatedly on the same semver version results in an increment to the last number in the series. So running that previous command again would result in 2.0.0-special-release.1

Allow config param

Is there a reason to not accept the "config" param aside with the "preset"?

I am working with a completely custom commit format.

Define process of adding supported meta-information files

#76 opened the discussion on supporting config.xml for cordova versioning. The process for extending the support of standard-version for different meta-information files/formats has not really been had as far as I know. In my opinion the cordova support is fine, and it would be cool to support different meta-information files, since the possibility of drawbacks (e.g. some other build system using a config.xml with a different format) seem slim.

/CC @bcoe @stevemao @nexdrew @tomchentw

Don't commit if package.json is dirty

Basically if I have unstaged/uncommited changes to my package.json this module will commit those changes and I might never know until a bug is filed.

standard-version should fail if one of the files it needs to modify is dirty, with a nice message.

Is it comaptibile with commitizen?

Hi,
I'm trying to use commitizen with standard version but i'm not getting a correct format of CHANGELOG.md. Is Standard-version compatibile with commitizen commit formats? If not which alternative can i use to ensure best practise for commits ?

Thank you

Ability to add other artifacts to the release commit

ATM, I'm amending because I want the produced artifacts to be part of the chore(release): x.x.x commit.

"prerelease": "webpack -p --bail", //produces some bundle artifacts that I want to commit
"release": "standard-version -s",
"postrelease": "git commit -a --amend --no-edit"

However, because of the way git works this creates a new commit object since the original commit is tagged before the amend happens. What would be nice is if my postrelease script was really a poststandard-version script (i.e. a "lifecycle-style" hook like the npm run script itself).

cc @stevemao @bcoe

Include AppVeyor CI config for windows test

As was pointed out by @bcoe in #55 it would be great to have AppVeyor run windows tests. Merging TravisCI and AppVeyor coverage is not so simple though (see lemurheavy/coveralls-public/issues/613).
Suggested base config was https://github.com/yargs/yargs-parser/blob/master/appveyor.yml.

Some modifications:

  • Added core.autocrlf true to enforce CRLF line endings for the test.
  • Added nodejs_version: '0.10' as it is present in travis.yml as well.
  • Switched v5 to v6 as its the latest, is there some real need to include v5?
  • Any need for shallow_clone: true and clone_depth: 1? Removed them for now.

So that leaves us with:

# Fix line endings on Windows
init:
  - git config --global core.autocrlf true
environment:
  matrix:
    - nodejs_version: '6'
    - nodejs_version: '4'
    - nodejs_version: '0.12'
    - nodejs_version: '0.10'
install:
  - ps: Install-Product node $env:nodejs_version
  - set CI=true
  - npm -g install npm@latest
  - set PATH=%APPDATA%\npm;%PATH%
  - npm install
matrix:
  fast_finish: true
build: off
version: '{build}'
test_script:
  - node --version
  - npm --version
  - npm test

On a related note, the travis.yml should probably include node version 4 as well as the latest (v6)?

Fails on windows: error: unknown switch `m'

When I run on windows (cygwin shell, cmd and a few types of other shells), the release fails due to an unknown switch being passed to git add.

After a short skimp through the source, I suspect the problem lies in the fact that both git add and git commit are executed at the same time and the ';' separator does not work in the windows cmd, thus the git commit -m flag being passed to add. In true windows style the exec calls cmd regardless of whether I execute standard-release in bash or cmd.. Output and debug log below.

My current workaround is to just add and commit myself.

Output

$ npm run release

@1.0.0 release
standard-version

√ bumping version in package.json from 1.0.0 to 1.1.0
√ outputting changes to CHANGELOG.md
√ committing package.json and CHANGELOG.md
error: unknown switch `m'
usage: git add [options] [--] ...

-n, --dry-run         dry run
-v, --verbose         be verbose

-i, --interactive     interactive picking
-p, --patch           select hunks interactively
-e, --edit            edit current diff and apply
-f, --force           allow adding otherwise ignored files
-u, --update          update tracked files
-N, --intent-to-add   record only the fact that the path will be added later
-A, --all             add changes from all tracked and untracked files
--ignore-removal      ignore paths removed in the working tree (same as --no-all)
--refresh             don't add, only refresh the index
--ignore-errors       just skip files which cannot be added because of errors
--ignore-missing      check if - even missing - files are ignored in dry run

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\Tapppi\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "release"
npm ERR! node v4.4.3
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! @1.0.0 release: standard-version
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @1.0.0 release script 'standard-version'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! standard-version
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! \npm-debug.log

debug-log

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files (x86)\nodejs\node.exe',
1 verbose cli 'C:\Users\Tapppi\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'release' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prerelease', 'release', 'postrelease' ]
5 info lifecycle @1.1.0prerelease: @1.1.0
6 silly lifecycle @1.1.0
prerelease: no script for prerelease, continuing
7 info lifecycle @1.1.0release: @1.1.0
8 verbose lifecycle @1.1.0
release: unsafe-perm in lifecycle true
9 verbose lifecycle @1.1.0release: PATH:
10 verbose lifecycle @1.1.0
release: CWD: C:\dev
11 silly lifecycle @1.1.0release: Args: [ '/d /s /c', 'standard-version' ]
12 silly lifecycle @1.1.0
release: Returned: code: 1 signal: null
13 info lifecycle @1.1.0~release: Failed to exec release script
14 verbose stack Error: @1.1.0 release: standard-version
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (C:\Users\Tapppi\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:245:16)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at EventEmitter.emit (events.js:172:7)
14 verbose stack at ChildProcess. (C:\Users\Tapppi\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:24:14)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at ChildProcess.emit (events.js:172:7)
14 verbose stack at maybeClose (internal/child_process.js:827:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid @1.1.0
16 verbose cwd C:\dev
17 error Windows_NT 6.1.7601
18 error argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\Tapppi\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "release"
19 error node v4.4.3
20 error npm v3.9.5
21 error code ELIFECYCLE
22 error @1.1.0 release: standard-version
22 error Exit status 1
23 error Failed at the @1.1.0 release script 'standard-version'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error standard-version
23 error You can get information on how to open an issue for this project with:
23 error npm bugs
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Sorry about the silly redactions, just playing on the safe side with company stuff :)

Use listr?

listr looks like a good package to use for our task list. We should look into it :)

Write tests for signed tags

Signed tags should be easy, tag errors seem to already be addressed with mock-git.

This should push code coverage to a whopping 100%?

Should not suggest `npm publish` if the package is private

Hello! I'm using standard-version in my private package, and the private package never is published. So my request is if the package.json has private:true, then the result doesn't display the npm publish.

$ standard-version patch
✔ bumping version in package.json from 1.0.4 to 1.0.5
✔ outputting changes to CHANGELOG.md
✔ committing package.json and CHANGELOG.md
✔ tagging release 1.0.5
++ ℹ Run `git push --follow-tags origin master` to publish
-- ℹ Run `git push --follow-tags origin master; npm publish` to publish

Thanks.

Named versions

It's pretty common to have named version bumps (like 2.2.0-RC or 15.0.0-some-obscure-pop-culture-reference). Is there a way to easily add a suffix to the version bumps? Or get a suggested release # and then run a release with my own custom version name?

RC Support

Hi,

i thought about it and i think that there is a need to define an RC release,
so for example, after the next version calculation, it will append -rc.1 to it,
if rc.1 exists it will incremeant the number.
and then once standard-version is run without the --rc keyword it will release the real version that suppose to to be released.

thoughts?

Publish GitHub release notes?

I'm not sure if this is even possible via the GitHub API but it would be cool if each tag / release automatically got the part of the changelog that pertains to it.

I'll try to look into this at some point unless someone else has the jump on me :)

detect breaking changes anywhere

currently the docs are a bit misleading. They say if there are any "BREAKING CHANGES" it will appear in the change log (and thus bump the major version).

image

This verbiage is confusing as people on our team are making their commit messages something like BREAKING CHANGE: removed deprecated component expecting it to bump the major version etc when the commit is part of a squash. The problem is that the squash is adding an asterisk at the beginning of that message and standard-version isn't picking it up.

It seems to me that if the pattern BREAKING CHANGE: is found anywhere in the commit message it should trigger a major version bump and change log update....

Unknown failure

There is an error that is happening on this project AND semantic-release

It occurs right after the changelog is generated.

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\pmichalina\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'ttt',
1 verbose cli   '--',
1 verbose cli   'pre' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prettt', 'ttt', 'postttt' ]
5 info lifecycle @SecretOrg/[email protected]~prettt: @SecretOrg/[email protected]
6 silly lifecycle @SecretOrg/[email protected]~prettt: no script for prettt, continuing
7 info lifecycle @SecretOrg/[email protected]~ttt: @SecretOrg/[email protected]
8 verbose lifecycle @SecretOrg/[email protected]~ttt: unsafe-perm in lifecycle true
9 verbose lifecycle @SecretOrg/[email protected]~ttt: PATH: C:\Users\pmichalina\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\Users\pmichalina\Source\Repos\pjmichalina\kick-ass-project\node_modules\.bin;C:\Users\pmichalina\AppData\Local\GitHub\PortableGit_284a859b0e6deba86edc624fef1e4db2aa8241a9\cmd;C:\Users\pmichalina\AppData\Local\GitHub\PortableGit_284a859b0e6deba86edc624fef1e4db2aa8241a9\usr\bin;C:\Users\pmichalina\AppData\Local\GitHub\PortableGit_284a859b0e6deba86edc624fef1e4db2aa8241a9\usr\share\git-tfs;C:\Users\pmichalina\AppData\Local\Apps\2.0\3MO5QPB8.1JA\K5RPAZTJ.3E9\gith..tion_317444273a93ac29_0003.0003_92b520eb113e6614;C:\Users\pmichalina\AppData\Local\GitHub\lfs-amd64_1.3.1;C:\Users\pmichalina\AppData\Local\Apps\2.0\3MO5QPB8.1JA\K5RPAZTJ.3E9\gith..tion_317444273a93ac29_0003.0003_92b520eb113e6614\NativeBinaries\x86;C:\Program Files\Haskell\bin;C:\Program Files\Haskell Platform\7.10.3\lib\extralibs\bin;C:\Program Files\Haskell Platform\7.10.3\bin;C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Haskell Platform\7.10.3\mingw\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\ProgramData\chocolatey\bin;C:\Program Files\dotnet\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\Sennheiser\SoftphoneSDK\;C:\Users\pmichalina\AppData\Roaming\cabal\bin;C:\Ruby23-x64\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\pmichalina\AppData\Roaming\npm;C:\Program Files (x86)\MSBuild\14.0\bin\;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64
10 verbose lifecycle @SecretOrg/[email protected]~ttt: CWD: C:\Users\pmichalina\Source\Repos\pjmichalina\kick-ass-project
11 silly lifecycle @SecretOrg/[email protected]~ttt: Args: [ '/d /s /c', 'semantic-release "pre"' ]
12 silly lifecycle @SecretOrg/[email protected]~ttt: Returned: code: 1  signal: null
13 info lifecycle @SecretOrg/[email protected]~ttt: Failed to exec ttt script
14 verbose stack Error: @SecretOrg/[email protected] ttt: `semantic-release "pre"`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (C:\Users\pmichalina\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Users\pmichalina\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:852:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid @SecretOrg/[email protected]
16 verbose cwd C:\Users\pmichalina\Source\Repos\pjmichalina\kick-ass-project
17 error Windows_NT 10.0.10586
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\pmichalina\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "ttt" "--" "pre"
19 error node v6.3.1
20 error npm  v3.10.8
21 error code ELIFECYCLE
22 error @SecretOrg/[email protected] ttt: `semantic-release "pre"`
22 error Exit status 1
23 error Failed at the @SecretOrg/[email protected] ttt script 'semantic-release "pre"'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the @SecretOrg/kick-ass-project package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     semantic-release "pre"
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs @SecretOrg/kick-ass-project
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls @SecretOrg/kick-ass-project
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Preserve formatting of package.json

See discussion in #38, which was originally meant to address #37 but ended up in a slippery slope of scope creep.

Basically, we overwrite package.json using JSON.stringify(pkg, null, 2) + '\n' but this may be too intrusive for folks using Windows line endings (\r\n instead of \n) or different indentation (tabs instead of spaces, or more than 2 spaces).

Here are a couple ways we could address this:

  1. Detect and preserve newline chars and indentation via detect-newline and detect-indent (similar to #38)
  2. Read package.json as string (instead of require()ing it) and just replace the "version" value, ignoring/preserving all other content/formatting

I think I'd prefer option 2.

I also think our CHANGELOG writing logic should not be affected by this.

github pull request

I'm trying to use standard-version with a pull request. We do PRs from a branch back to master on the same repo. When I do this I choose squash commits, enter a 'standard-version- style commit message as the title, but I end up with a commit message that looks like this:

image

As a result, the change log never gets the features (other than the main one I typed in) that I added as part of the branch / PR. Am I doing something wrong?

For reference I've created a simple repo to demonstrate what I'm talking about:
https://github.com/benmonro/stv-ex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.