npm version

碰撞一个包版本

概要

npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]

'npm [-v | --version]' to print npm version
'npm view <pkg> version' to view a package's published version
'npm ls' to inspect current package/dependency versions

描述

在包目录中运行此命令以提升版本并将新数据写回 package.jsonpackage-lock.jsonnpm-shrinkwrap.json(如果存在)。

newversion 参数应该是有效的 semver 字符串、semver.inc 的有效第二个参数(patchminormajorprepatchpreminorpremajorprerelease 之一)或 from-git。在第二种情况下,现有版本将在指定字段中增加 1。from-git 将尝试读取最新的 git 标签,并将其用作新的 npm 版本。

如果在 git repo 中运行,它还将创建一个版本提交和标签。此行为由 git-tag-version 控制(见下文),并且可以通过运行 npm --no-git-tag-version version 在命令行上禁用。如果工作目录不干净,它将失败,除非设置了 -f--force 标志。

如果提供了 -m--message 配置选项,npm 将在创建版本提交时将其用作提交消息。如果 message 配置包含 %s 那么它将被替换为生成的版本号。例如:

npm version patch -m "Upgrade to %s for reasons"

pdceTXAtzkwm0P1NtexRIP0zsrRQqD8iSbfC9pDsnxHpHu4HZNDQDZ3sdjFy/wUb/tQLTouHxxLS49PpVE9hksmdLcfu0rZfHN23fMYE0JFzlUgohQgNNNq7rrZDfWqf+m1u94+PK9ShsGRIGDIw3ChyBx+nYPamemynNtEkZ13HjM9RTXRuKZ2RWq1CzZt/S3qAwDVhtqES9Kw2ll8QML45aP6w9/+Q1qVllJnUSiOJsSxJGNcCQg1m4o3aHSjT0MTfkvS91Oy7vn7EfQdS8CG9ZjFaCqPCYF7jBF4N/B0=

$ npm config set sign-git-tag true
$ npm version patch

You need a passphrase to unlock the secret key for
user: "isaacs (http://blog.izs.me/) <i@izs.me>"
2048-bit RSA key, ID 6C481CF6, created 2010-08-31

Enter passphrase:

E8TVaYxnJNEwsxstGB1zeRVfDVuDqTuub75DZY6c54DqpgQtvTVaN6j/RRgB0dJwfZ5i/3/vR2UHqpPZopkbQ7qPedlLifRtJIdNZqH7wMUaYmgwVGnCOZ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hllLn4W3S6w7NjjnjoDfb+siU89XqXllZ2nXQkK/DEIRKCSYeoo51WLHtO0StgmvOJh836AJ6ieAfHUtSaxjBqV8W93Gp0oBMZqtkhk3VRHB2Tc4VU46Gl2scstvs16eQuNMdZDmz4Dy4+IMFM7x6LL+DvC0bGqJuWCxPk9ni42h4ncW+kBhrn1C+fUc7cGlmrxZ8HeeR6qYYqi/wrweZ/qnd+rT29GKB6QVEi4P7CBJY/8DNlqo0NKCs4++zre6dSJIVlKL0IQsG5+duMuhOu9pGx5aefoFXHZBlDdUnUMHjDoVPW8CHT7NT+4KlI14vRwlIQGJgShudRA2Gfuy2zy6Q6pw3hfftaOIbOMLpANaGRv4r9u9QYIzdZVeLXa8FW9QKSLGqG4sNEzxheYKzQQv2BPtFbtNrcNOETo2WpOEo5nR08Ne58jFUUcIcLAj/UyH8/JdsiVisGG/s92k4H07RyX7n36iBTOuWq/HKiu9iuqgzOQ==

LzACe7UbHneO32rksz2C8g==

    "scripts": {
      "preversion": "npm test",
      "version": "npm run build && git add -A dist",
      "postversion": "git push && git push --tags && rm -rf build/temp"
    }

dYvzILBwIASRNFWRGgOWdPDP++4a29QuZQhqUAZjAH5/6WZoH0Sm7me0XicFDk8CniimX/A0sZhz9CAg4htfjZjcWfiH07iqs23yYaXfoEX2bTaI1z9PEtJcS7pkiHFpsjvokr/Jaw7z2YQEeVfKgD8efbiOxGQEUpTLFw84kfI36D/LRbKROh2Tw1TbbcSkgWE69wtjiCCsbpciX0yPrn7EkJfehs+U2qhxLAt5eLN+t0Kzo4qQ5SoXKyb+otQaK4ddGLwf3zcx7gXzxBjW+YCj2pyDzbATyxeECcp2mfp/OEWj8Z9K+/P+22MievVRXuurS43PBcUbhbWZR/+sB+wE6DxZJNQecKwSx8dy2hoBJCxPo2zeqfAvSzsGF6XlZD4AJd+D4kMuPDMzzTTRcw==

配置

allow-same-version

    cpHcqTIrxEt4f28KOhZfPtN+1DnZvVBVAKYGUmWOIwWGrGLru+wlVoKtqRRY32EZnPsvqMSi6MrpxrMwdvnc+A==

eK5N1Ws6ms9xtNYT4RIaOzVVDCjUC/ocV201bshavb73QE6Fju4jsoa6+3cUQt6Uw9w41zGybR0JQBJNb+dDIT6ovEV82/PxqEPpbNhTR53JZI6htL/xZY12xUeADnwrRoAbsfZa9khbhoauTa4xTA==

git-tag-version

    cpHcqTIrxEt4f28KOhZfPkO0zLmYjUTFDL8JP5iAFTumKS0+8TtVbaOqA6c8BSfqpTTv+J/OldznbRcggUCKYg==

tINYTEn38BNRAVAOMed7WW4WEmyE1surY6/mWtmSlPo=

commit-hooks

    cpHcqTIrxEt4f28KOhZfPkO0zLmYjUTFDL8JP5iAFTumKS0+8TtVbaOqA6c8BSfqpTTv+J/OldznbRcggUCKYg==

Pm36E3/g6VRcZpDtu8RNkQokpIdSmMGhMPfxydswUUQZ2KOpwHGcd1Aoomq8QMXC

sign-git-tag

    cpHcqTIrxEt4f28KOhZfPtN+1DnZvVBVAKYGUmWOIwWGrGLru+wlVoKtqRRY32EZnPsvqMSi6MrpxrMwdvnc+A==

ZPWNSNyyV2rfLWL5uLSjNMk7KfBUgPVmZ4lQJFPrM2Xt3Rd9yWHzBktWkWMMb1IcPw8duEzzD3robRBTQ4GDSmedBEiLFyF8YjZLW4O7WJU=

dK0wgEJ9B2rj/a/5xwjnWqfeaFSHmn1cKVDytmA5GajkMT1rG3ISx2eoxO12sjFw54gmchoTbTH4o6OT4F8xHvKMRvAzyCJtbLrppagrvFTDVI04dgiYIgNtLZVStypx