Skip to content
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: umi cache #10730

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

feat: umi cache #10730

wants to merge 34 commits into from

Conversation

txp1035
Copy link
Member

@txp1035 txp1035 commented Mar 13, 2023

背景

#10716
除了issue描述的,我增加了配置显示层数默认两层,可以自定义显示

效果

image

体验和说明

umi cache clean:清理 node_modules/.cache文件夹
umi cache ls [--depth]:显示缓存文件夹信息,--depth表示层数可选,默认值为1层,cache层为第0层
切换到分支

pnpm i
cd example/umi-cache
npx umi cache clean
npx umi cache ls [--depth]

@PeachScript ok了看下

@vercel
Copy link

vercel bot commented Mar 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
umi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 19, 2023 9:49am

@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.15 ⚠️

Comparison is base (d408837) 29.25% compared to head (8ea3f9d) 29.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10730      +/-   ##
==========================================
- Coverage   29.25%   29.11%   -0.15%     
==========================================
  Files         478      479       +1     
  Lines       14342    14418      +76     
  Branches     3373     3397      +24     
==========================================
+ Hits         4196     4198       +2     
- Misses       9422     9488      +66     
- Partials      724      732       +8     
Impacted Files Coverage Δ
packages/preset-umi/src/commands/cache.ts 0.00% <0.00%> (ø)
packages/preset-umi/src/index.ts 0.00% <ø> (ø)

... and 5 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@txp1035 txp1035 changed the title [wip]feat: umi cache feat: umi cache Mar 13, 2023
@txp1035
Copy link
Member Author

txp1035 commented Mar 13, 2023

找了个包
image

@PeachScript
Copy link
Member

找了个包

有能用的吗,直接用上?

@txp1035
Copy link
Member Author

txp1035 commented Mar 13, 2023

找了个包

有能用的吗,直接用上?

image
image
五年bu'g'x不更新很稳定😄
用的这个下载量还挺高的

@txp1035
Copy link
Member Author

txp1035 commented Mar 13, 2023

尴尬,忘记push了,刚刚cr的时候才发现

packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/package.json Outdated Show resolved Hide resolved
@fz6m
Copy link
Contributor

fz6m commented Mar 13, 2023

  1. 感觉 umi cache clean 默认打印一层就行了,因为二层比如 .cache/{mfsu, babel-loader}/* 这下面文件太多了,正常人看不了,感觉 ls 这个功能不实用。

  2. 建议超过 1000 KB 用 M 表示单位 ,大致算一下就行,或者 KB 每三位加逗号,比如 271234KB 很难知道占了多少空间,此时 27.1 MB / 271,234KB 更好

@txp1035
Copy link
Member Author

txp1035 commented Mar 14, 2023

2可以我记得dumi也是kb来着,为啥用忘记了哈哈 @PeachScript 你来看看

@PeachScript
Copy link
Member

2可以我记得dumi也是kb来着,为啥用忘记了哈哈 @PeachScript 你来看看

dumi 没这个功能 👀 能换单位最好,应该也有库

@txp1035
Copy link
Member Author

txp1035 commented Apr 17, 2023

换算完成
image

@txp1035
Copy link
Member Author

txp1035 commented Apr 17, 2023

看一下,遇到需要用到的场景了,mf报错清了缓存就好了 @PeachScript

packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
packages/preset-umi/src/commands/cache.ts Outdated Show resolved Hide resolved
examples/umi-cache/package.json Outdated Show resolved Hide resolved
@txp1035
Copy link
Member Author

txp1035 commented Apr 18, 2023

@fz6m 这波CR必须点个赞

@fz6m
Copy link
Contributor

fz6m commented Apr 18, 2023

我没权限直接推,看下这个 commit MoeYc@14b2267 ,帮你优化了下日志。

另外 treeify 锁一下版本就 OK 了。

@txp1035
Copy link
Member Author

txp1035 commented Apr 19, 2023

我没权限直接推,看下这个 commit MoeYc@14b2267 ,帮你优化了下日志。

另外 treeify 锁一下版本就 OK 了。

习惯用fork了,下次直接在umi上创建分支应该更好协作~

@PeachScript
Copy link
Member

需要加个文档说明:https://umijs.org/docs/api/commands

Copy link
Contributor

@fz6m fz6m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

const position = relative(api.cwd, absCachePath);
if (fsExtra.existsSync(absCachePath)) {
if (args._[0] === 'clean') {
fsExtra.removeSync(absCachePath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里要不要顺便把 .umi 文件夹删除?临时文件严格来说也算是缓存文件?就顺便把 umi clean 命令做了?
@sorrycc cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants