-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 使用corepack管理PNM版本,锁定为[email protected],增加ci脚本支持快速下载依赖 #4237
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,10 @@ | |
"type": "git", | ||
"url": "https://github.com/midwayjs/midway.git" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">= 16.0.0" | ||
"node": ">= 16.0.0", | ||
"pnpm": "9.6.0" | ||
}, | ||
"license": "MIT", | ||
"collective": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
packages: | ||
- 'packages/*' | ||
- 'packages-serverless/*' | ||
- 'packages-resource/*' | ||
- 'packages-resource/*' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
## | ||
## 依赖安装脚本 | ||
## 使用: | ||
## ./scripts/ci | ||
## | ||
|
||
# NPM源 | ||
NPM_REGISTRY="https://mirrors.tencent.com/npm/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不允许使用三方源,避免同步问题 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我改成淘宝源可以嘛? 得考虑国内开发者下载速度吧,或者不指定我就删了吧 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不需要的,这里仅考虑 CI 标准环境,本地的可以自行配置 registry,或者 nrm 修改,方式有很多,也没法限制,不需要提交的。 |
||
|
||
## 获取所有参数 | ||
echo "运行命令: export COREPACK_NPM_REGISTRY=$NPM_REGISTRY && corepack enable pnpm && pnpm i --registry $NPM_REGISTRY --frozen-lockfile $*" | ||
|
||
# 导出corepack环境变量,安装pnpm版本 | ||
export COREPACK_NPM_REGISTRY=$NPM_REGISTRY && corepack enable pnpm | ||
|
||
# 安装项目依赖 | ||
pnpm i --registry $NPM_REGISTRY --frozen-lockfile "$@" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里其实不需要 --frozen-lockfile,因为 pnpm 在 github action ci 环境默认就是这个 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个脚本,可以直接用,免得在本地pnpm i 。 直接pnpm i,pnpm-lock不就会更新嘛? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果 lock 里没有,那 i 的时候更新也没问题的,pr 的时候会看的。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我是习惯于把环境配置好,争取做到开发者不因为环境导致问题,专注与业务上。 我经常在pnpm i时出现pnpm-lock变动,PR提交上来了。就得反复改。 如果觉得不太合适,我明天把这个PR 关掉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 恩,这个 pr 更多的是一些开发者习惯,目前看起来还不足以变成框架的规约。 pnpm i 在新增依赖,更新了 package.json 和 lock 文件,这是合理的,如果没有更新,纯粹只是安装,应该不会更新 pkg 和 lock。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pnpm i直接安装会更新pnpm-lock,但不更新pkg, 因为pkg里面的版本,很多有 "@types/node": "^2.10.2", 这种。 目前midway好像是写死版本号 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是的,每个三方包都会经由renovate 机器人提 pr 后人工 review + CI 完后合入。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么是这个版本呢,pnpm 应该没有出现过 minor 版本不兼容的情况吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为我本地使用的是9.6.0 那我改成9吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我理解 9 的 latest 就行了。如果 pnpm 有问题,由 CI + lock 来保证,我们最终确保的是框架 ci 没有问题,这个 lock 仅服务于框架本身,不会提供给用户的项目。