美文网首页
2021-09-09 Lerna

2021-09-09 Lerna

作者: FConfidence | 来源:发表于2021-09-09 15:13 被阅读0次

lerna bootstrap

默认是npm i,因为我们指定过yarn,so,run yarn install,会把所有包的依赖安装到根node_modules.

lerna list

列出所有的包,如果与你文夹里面的不符,进入那个包运行yarn init -y解决

lerna diff [package?]

列出所有或者软件包自上次发布以来的修改情况

lerna import <path-to-external-repository>

导入本地已经存在的包

lerna add packageName --scope=workspacePackageName

lerna add lodash --scope=my-component

lerna run

运行npm script,可以指定具体的package。

lerna run <script> -- [..args] # 运行所有包里面的有这个script的命令
$ lerna run --scope my-component test

$ lerna run <script> -- [..args] # 在所有包下运行指定

# 例如
$ lerna run test # 运行所有包的 test 命令
$ lerna run build # 运行所有包的 build 命令
$ lerna run --parallel watch # 观看所有包并在更改时发报,流式处理前缀输出

$ lerna run --scope my-component test # 运行 my-component 模块下的 test

lerna exec

运行任意命令在每个包

$ lerna exec -- < command > [..args] # runs the command in all packages
$ lerna exec -- rm -rf ./node_modules
$ lerna exec -- protractor conf.js
lerna exec --scope my-component -- ls -la

lerna link

项目包建立软链,类似npm link

lerna clean

删除所有包的node_modules目录

lerna changed

列出下次发版lerna publish 要更新的包。

原理:
需要先git add,git commit 提交。
然后内部会运行git diff --name-only v版本号 ,搜集改动的包,就是下次要发布的。并不是网上人说的所有包都是同一个版全发布。

如果forcePublish为true 那么所有的包都会change发布
 "command": {
    "version": {
      "forcePublish": true
    },
 }

lerna publish

会打tag,上传git,上传npm。
如果你的包名是带scope的例如:"name": "@gp0320/gpwebpack",
那需要在packages.json添加

"publishConfig": {
  "access": "public"
},

提交对项目的更新

运行该命令会执行如下的步骤:

  1. 运行lerna updated来决定哪一个包需要被publish
  2. 如果有必要,将会更新lerna.json中的version
  3. 将所有更新过的的包中的package.json的version字段更新
  4. 将所有更新过的包中的依赖更新
  5. 为新版本创建一个git commit或tag
  6. 将包publish到npm上
$ lerna publish  用于发布更新 
$ lerna publish --skip-git     # 不会创建git commit或tag 
$ lerna publish --skip-npm   # 不会把包publish到npm上 |

lerna ls

显示packages下的各个package的version

lerna publish 相关参数

lerna publish [--dist-tag=tag名]

image.png

如图所示,控制台会让用户选择要发版的版本号(最后一个可以自定义)

dist-tag选项可以发版一个其他分支的包,在测试时比较有用!

image.png

测试时可以发布一个beta版(--dist-tag=beta),通过手动@版本号安装(npm install 默认安装latest)

参考

http://www.sosout.com/2018/07/21/lerna-repo.html

https://www.bilibili.com/read/cv4948266

相关文章

  • 2021-09-09 Lerna

    lerna bootstrap 默认是npm i,因为我们指定过yarn,so,run yarn install,...

  • lerna

    关键字:lerna yarn workspace lerna lerna init 将一个仓库初始化为 lerna...

  • lerna使用攻略

    About Lerna[https://github.com/lerna/lerna]是一个工具,它优化了使用gi...

  • 基于 lerna 和 yarn workspace 的 mono

    基于 lerna 和 yarn workspace 的 monorepo 工作流 由于 yarn 和 lerna ...

  • Monorepo项目管理:lerna + workspaces

    这里主要介绍lerna、yarn workspaces的使用方法与职能界限。 lerna:项目管理与发版 work...

  • lerna 多包管理

    Lerna Lerna 是一个管理工具,用于管理包含多个软件包(package)的 JavaScript 项目。将...

  • lerna+ git + npm

    lerna 命令 git 命令 npm命令

  • lerna

    前言 Lerna是一个管理多个Node模块的工具,已经被很多著名模块使用:Babel,React,Jest等 Mo...

  • lerna

    前言 npm仓库管理工具的意义 为了方便代码的共享,就需要将代码拆分成多个包,存放在各自的npm仓库中。由于,各仓...

  • Lerna

    Lerna.json bootstrap ignore ignore 为 glob[https://github....

网友评论

      本文标题:2021-09-09 Lerna

      本文链接:https://www.haomeiwen.com/subject/xvgiwltx.html