@0x-lerna-fork/bootstrap
连接本地软件包并安装剩余软件包依赖性
安装 莱娜 进入 lerna CLI(英语:CLI).
使用量
$ lerna bootstrap
将套件装入当前 Lerna Repo 中 . 安装其所有依赖关系,并链接任何交叉依赖关系.
运行时, 此命令将 :
npm install每个软件包的所有外部依赖.- 将所有莱娜连在一起
packages互相依赖. npm run prepublish在所有靴子套件中(除非--ignore-prepublish”).npm run prepare在所有的靴子包.
lerna bootstrap 尊重 --ignore, (中文(简体) ), --scope 财务报告和审定财务报表 --include-filtered-dependencies 旗帜(参见 过滤旗) (中文(简体) ).
通过在 npm 客户端后放置将额外参数传递到 --数字 :
$ lerna bootstrap -- --production --no-optional
也可能配置在 lerna.json数字 :
{
...
"npmClient": "yarn",
"npmClientArgs": ["--production", "--no-optional"]
}
- 欢呼 [glob]
安装外部依赖性匹配 glob 在雷波根,所以他们是
可供所有软件包使用。 任何来自这些依赖的二进制将是
链接到依赖软件包 node_modules/.bin/ 书目所以
npm 脚本可用 。 如果有选项, 则无 glob 给出
默认为 ** (兴奋的一切)。 此选项只影响
bootstrap 命令.
$ lerna bootstrap --hoist
背景介绍 --hoist,参见 升起文档。 。 。 .
注:如果软件包依赖于不同的软件包 版本 外部依赖者, 最常用的版本将升起,并发出警告.
--限制
当与升起相配合使用时,会在发布版本警告后抛出出错误并停止拖曳. 如果你不升起,或者没有版本警告, 没有任何效果.
$ lerna bootstrap --hoist --strict
- 无名主义者 [glob]
执行 没有 安装外部依赖关系匹配 glob 在雷波根。 这个
可用于选择退出某些依附物的升起.
$ lerna bootstrap --hoist --nohoist=babel-*
- 丑闻
$ lerna bootstrap --ignore component-*
这个 --ignore 旗帜,与 bootstrap 命令,也可以设置在 lerna.json 下划线 command.bootstrap.ignore 键。 命令行旗将优先于此选项.
示例
{
"version": "0.0.0",
"command": {
"bootstrap": {
"ignore": "component-*"
}
}
}
提示: glob 匹配到定义的软件包名称
package.json, (中文(简体) ), 不包含该软件包的目录名称.
选项
--ignore-prepublish
跳过默认在靴子套件中运行的预推出生命周期脚本 . 注意,这个生命周期是 已贬值, (中文(简体) ), 并且很可能在下个主要版本的"勒纳"中被删除.
$ lerna bootstrap --ignore-prepublish
--ignore-scripts
跳过任何正常运行的生命周期脚本( S)prepare等)在靴子套件中.
$ lerna bootstrap --ignore-scripts
--registry <url>
当使用此旗帜运行时, 转发 npm 命令会使用指定的注册符来保存您的软件包 .
如果您不想明确设置您的注册簿, 则此选项将有所帮助 在您的所有软件包中进行配置。 json 文件在使用时 私人登记.
--npm-client <client>
必须是知道如何安装 npm 包依赖的可执行文件 .
默认 --npm-client 实值 npm。 。 。 .
$ lerna bootstrap --npm-client=yarn
也可能配置在 lerna.json数字 :
{
...
"npmClient": "yarn"
}
--use-workspaces
允许与 Yarn 工作空间 (自纱线起提供).
数组中的值是 Lerna 将操作委托给 Yarn 的命令( 目前仅是拖曳) .
若为 --use-workspaces 是真的吗 packages 将被来自 package.json/workspaces.
也可能配置在 lerna.json数字 :
{
...
"npmClient": "yarn",
"useWorkspaces": true
}
根级软件包 workspaces 数组 :
{
"private": true,
"devDependencies": {
"lerna": "^2.2.0"
},
"workspaces": ["packages/*"]
}
此列表大致类似于 lerna 的 packages 配置(将目录与软件包相匹配的词汇列表),
但它不支持递归性光泽("**",a.k.a. "巨星").
--no-ci
使用默认时 --npm-client, (中文(简体) ), lerna bootstrap 将会呼叫 npm ci 改为 npm install 在CI环境中.
要禁用此行为, 请通过 --no-ci数字 :
$ lerna bootstrap --no-ci
改为: 部队 在本地安装( 无法自动启用) 时通过 --ci数字 :
$ lerna bootstrap --ci
这可用于"干净"再安装,或新克隆后的初步安装.
--force-local
$ lerna bootstrap --force-local
当通过时,这面旗帜导致 bootstrap 命令总是将本地依赖关系链接起来,而不论匹配的版本范围.
如何运作
我们用吧 babel 作为例子.
babel-generator财务报告和审定财务报表source-map(等等)的依赖关系babel-core。 。 。 .babel-core是因为package.json在dependencies页:1.
// babel-core package.json
{
"name": "babel-core",
...
"dependencies": {
...
"babel-generator": "^6.9.0",
...
"source-map": "^0.5.0"
}
}
- Lerna检查每个依赖是否也是Lerna repo的一部分.
- 在这个例子中,
babel-generator可以是内部依赖,而source-map总是外部依赖. - 该版本
babel-generator输入package.json联 合 国babel-core满足于packages/babel-generator,通过内部依赖. source-map实值npm install页:1yarn就像平常一样.
- 在这个例子中,
packages/babel-core/node_modules/babel-generator符号链接到packages/babel-generator- 允许嵌入目录导入
页:1
- 当一个软件包中的依赖性版本不满足于repo中同名软件包时,它将会是
npm install页:1yarn就像平常一样. - 分别的,像
latest,不满足 铸造 范围. - 循环依赖导致循环连结 可能 影响编辑器/IDE.
网络风暴 当圆相链接存在时, 锁起 。 为了防止这种情况,添加 node_modules 中被忽略的文件和文件夹列表 Preferences | Editor | File Types | Ignored files and folders。 。 。 .