pre
Usage: modern pre [options] <enter|exit> [tag]
进入和退出预发布模式
Options:
-h, --help display help for command
可以使用 modern pre
命令在正式发布前预发布一个版本。
首先 modern pre enter <tag>
进入预发布模式:
$ npx modern pre enter next
🦋 success Entered pre mode with tag next
🦋 info Run `changeset version` to version packages with prerelease versions
✨ Done in 5.30s.
之后通过 modern change
命令添加 changeset:
$ npx modern change
🦋 What kind of change is this for module-example? (current version is 0.1.1) · patch
🦋 Please enter a summary for this change (this will be in the changelogs). Submit empty line to open external editor
🦋 Summary · test pre publish
🦋 === Releasing the following packages ===
🦋 [Patch]
🦋 module
🦋 Is this your desired changeset? (Y/n) · true
🦋 Changeset added! - you can now commit it
🦋
🦋 If you want to modify or expand on the changeset summary, you can find it here
🦋 info /xxxx/module-example/.changeset/old-spies-float.md
接着可以使用 modern bump
命令更新具体的版本号:
$ npx modern bump
🦋 warn ===============================IMPORTANT!===============================
🦋 warn You are in prerelease mode
🦋 warn If you meant to do a normal release you should revert these changes and run `changeset pre exit`
🦋 warn You can then run `changeset version` again to do a normal release
🦋 warn ----------------------------------------------------------------------
🦋 All files have been updated. Review them and commit at your leisure
可以看到 package.json
中版本号已经更新到 0.1.2-next.0
。
提示
Yarn 和 pnpm 调用命令时接收参数的方式不同,例如,在如下 package.json
配置中:
{
"scripts": {
"command": "modern command"
}
}
当需要执行 modern command --option
:
使用 Yarn 时,需要执行 yarn command --option
。
使用 pnpm 时,需要执行 pnpm run command -- --option
。
这是因为 pnpm 对于命令参数的处理与 Yarn 并不相同,但是与 npm 类似:在不加 --
字符串的时候,传递的是 pnpm 的参数;在使用 --
字符串的时候,传递的是执行脚本的参数。
在上述例子里参数 --option
传递给了 modern command
。如果执行 pnpm run command --option
,则参数 --option
将传递给 pnpm。
总结来说:
在使用 pnpm 时,如果传递的参数给 pnpm,不需要加 --
;如果传递的参数是给脚本使用,需要增加 --
字符串。