feat: add yarn.md cheatsheet.
				
					
				
			This commit is contained in:
		| @@ -53,6 +53,7 @@ Quick Reference | ||||
| [TypeScript](./docs/typescript.md)<!--rehype:style=background: rgb(49 120 198/var(\-\-bg\-opacity));--> | ||||
| [Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));--> | ||||
| [Vue 3 ](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing--> | ||||
| [Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));--> | ||||
| <!--rehype:class=home-card--> | ||||
|  | ||||
| ## Nodejs | ||||
|   | ||||
							
								
								
									
										193
									
								
								docs/yarn.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								docs/yarn.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,193 @@ | ||||
| Yarn 备忘清单 | ||||
| === | ||||
|  | ||||
| 这是一份 [`Yarn`](https://yarnpkg.com/) 软件包管理器备忘单,其中列出了 `Yarn` 常用命令使用清单 | ||||
|  | ||||
| 入门 | ||||
| --- | ||||
|  | ||||
| ### 与 npm 相同的命令 | ||||
| <!--rehype:wrap-class=col-span-2--> | ||||
|  | ||||
| | npm | yarn | | ||||
| | --- | ---- | | ||||
| | `npm init` | `yarn init` | | ||||
| | `npm install` | `yarn` | | ||||
| | `npm install gulp --save` | `yarn add gulp` | | ||||
| | `npm install gulp --save-dev --save-exact` | `yarn add gulp --dev --exact` | | ||||
| | `npm install -g gulp` | `yarn global add gulp` | | ||||
| | `npm update` | `yarn upgrade` | | ||||
| | `npm cache clean` | `yarn cache clean` | | ||||
| | `./node_modules/.bin/gulp` | `yarn run gulp` | | ||||
| <!--rehype:className=show-header left-align--> | ||||
|  | ||||
| npm _([备忘清单](./npm.md))_ 和 Yarn 有很多相似之处 | ||||
|  | ||||
| ### yarn install | ||||
|  | ||||
| ```shell | ||||
| --no-lockfile # 不要读取或生成 yarn.lock 锁定文件 | ||||
| --pure-lockfile | ||||
| --frozen-lockfile | ||||
| --silent | ||||
| --offline | ||||
| --update-checksums | ||||
| --check-files | ||||
| --flat | ||||
| --force | ||||
| --ignore-scripts | ||||
| --modules-folder <path> | ||||
| --production[=true|false] | ||||
| ``` | ||||
|  | ||||
| 这些选项可用于 `yarn install` | ||||
|  | ||||
| ### yarn add | ||||
| <!--rehype:wrap-class=row-span-2--> | ||||
|  | ||||
| 在 [devDependencies](./package.json.md#devdependencies) 中安装一个或多个包 | ||||
|  | ||||
| ```shell | ||||
| --dev, -D | ||||
| ``` | ||||
|  | ||||
| 在 [peerDependencies](./package.json.md#peerdependencies) 中安装一个或多个包 | ||||
|  | ||||
| ```shell | ||||
| --peer, -P | ||||
| ``` | ||||
|  | ||||
| 在 [optionalDependencies](./package.json.md#optionaldependencies) 中安装一个或多个包 | ||||
|  | ||||
| ```shell | ||||
| --optional, -O | ||||
| ``` | ||||
|  | ||||
| 更改包版本 | ||||
|  | ||||
| ```shell | ||||
| --exact, -E # 将包安装为精确版本 | ||||
| --tilde, -T # 安装有相同次要版本的包的最新版本 | ||||
| ``` | ||||
|  | ||||
| 这些选项可用于 `yarn add`. | ||||
|  | ||||
| ### Workspaces | ||||
| <!--rehype:wrap-class=row-span-2--> | ||||
|  | ||||
| 在 `package.json` 中 [workspaces](./package.json.md#workspaces) 配置: | ||||
|  | ||||
| ```json | ||||
| "workspaces": [ | ||||
|   "packages/*" | ||||
| ] | ||||
| ``` | ||||
|  | ||||
| ---- | ||||
|  | ||||
| ```bash | ||||
| jest/ | ||||
| ├─ package.json | ||||
| └─ packages/ | ||||
|    ├─ jest-matcher-utils/ | ||||
|    │  └─ package.json | ||||
|    └─ jest-diff/ | ||||
|       └─ package.json | ||||
| ``` | ||||
|  | ||||
| (1.0 新增)允许 monoreso 相互共享包。另见:[介绍工作空间](https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/) | ||||
|  | ||||
| ### 选择性版本解析 | ||||
|  | ||||
| 在 `package.json` 中 [`resolutions`](./package.json.md#resolutions) 配置: | ||||
|  | ||||
| ```json | ||||
| "resolutions": { | ||||
|   "**/sass-brunch/node-sass": "4.5.2" | ||||
| } | ||||
| ``` | ||||
|  | ||||
| 另见:[选择性版本解析](https://github.com/yarnpkg/yarn/pull/4105)。(1.0 新增)允许您指定子依赖项的版本 | ||||
|  | ||||
| ### Create | ||||
|  | ||||
| ```bash | ||||
| yarn create react-app hello | ||||
| ``` | ||||
|  | ||||
| 安装 `create react app` 并运行它 See: [yarn create](https://github.com/yarnpkg/rfcs/blob/master/implemented/0000-yarn-create.md) | ||||
|  | ||||
| 示例 | ||||
| --- | ||||
|  | ||||
| ### 安装包 | ||||
| <!--rehype:wrap-class=row-span-2--> | ||||
|  | ||||
| ```bash | ||||
| # 将包添加到“dependencies” | ||||
| $ yarn add <package> | ||||
| # 将包添加到“devDependencies” | ||||
| $ yarn add -D <package> | ||||
| # 将软件包添加为确切版本 | ||||
| $ yarn add -E <package> | ||||
| # 在您的操作系统上全局安装软件包 | ||||
| $ yarn global add <package> | ||||
| ``` | ||||
|  | ||||
| ### 移除包 | ||||
|  | ||||
| ```bash | ||||
| $ yarn remove <package> | ||||
| ``` | ||||
|  | ||||
| 从所有类型的依赖项中删除包 | ||||
|  | ||||
| ### 查看包 | ||||
| <!--rehype:wrap-class=row-span-2--> | ||||
|  | ||||
| ```bash | ||||
| # 列出已安装的软件包 | ||||
| $ yarn list | ||||
| # 列出顶级安装包 | ||||
| $ yarn list --depth=0 | ||||
| # 列出已安装的顶级全局包 | ||||
| $ yarn global list --depth=0 | ||||
| # 列出带有过滤字符串和深度级别的包 | ||||
| $ yarn list --pattern "gulp|grunt" --depth=1 | ||||
| ``` | ||||
|  | ||||
| ### 清除 | ||||
|  | ||||
| ```bash | ||||
| # 从包依赖项中清理并删除不必要的文件 | ||||
| $ yarn autoclean | ||||
| # 检查过时的包依赖项 | ||||
| $ yarn outdated | ||||
| ``` | ||||
|  | ||||
| ### 信息 | ||||
|  | ||||
| ```bash | ||||
| $ yarn why <query> | ||||
| $ yarn why jest | ||||
| ``` | ||||
|  | ||||
| 显示有关安装软件包的原因的信息 | ||||
|  | ||||
| ### 清理缓存 | ||||
|  | ||||
| 运行此命令将清除全局缓存。 下次运行 `yarn` 或 `yarn install` 时,它将再次填充 | ||||
|  | ||||
| ```bash | ||||
| $ yarn cache clean | ||||
| ``` | ||||
|  | ||||
| 此外,您可以指定一个或多个要清理的包 | ||||
|  | ||||
| 另见 | ||||
| --- | ||||
|  | ||||
| - [npm 备忘清单](./npm.md) | ||||
| - [Yarn 官方文档网站](https://yarnpkg.com/) | ||||
| - [Yarn 2 中文文档网站](https://www.yarnpkg.cn/) | ||||
| - [Yarn 1 中文文档网站](https://yarn.bootcss.com/) _(bootcss.com)_ | ||||
							
								
								
									
										3
									
								
								scripts/assets/yarn.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								scripts/assets/yarn.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em"> | ||||
|   <path d="M12 0C5.375 0 0 5.375 0 12s5.375 12 12 12 12-5.375 12-12S18.625 0 12 0zm.768 4.105c.183 0 .363.053.525.157.125.083.287.185.755 1.154.31-.088.468-.042.551-.019.204.056.366.19.463.375.477.917.542 2.553.334 3.605-.241 1.232-.755 2.029-1.131 2.576.324.329.778.899 1.117 1.825.278.774.31 1.478.273 2.015a5.51 5.51 0 0 0 .602-.329c.593-.366 1.487-.917 2.553-.931.714-.009 1.269.445 1.353 1.103a1.23 1.23 0 0 1-.945 1.362c-.649.158-.95.278-1.821.843-1.232.797-2.539 1.242-3.012 1.39a1.686 1.686 0 0 1-.704.343c-.737.181-3.266.315-3.466.315h-.046c-.783 0-1.214-.241-1.45-.491-.658.329-1.51.19-2.122-.134a1.078 1.078 0 0 1-.58-1.153 1.243 1.243 0 0 1-.153-.195c-.162-.25-.528-.936-.454-1.946.056-.723.556-1.367.88-1.71a5.522 5.522 0 0 1 .408-2.256c.306-.727.885-1.348 1.32-1.737-.32-.537-.644-1.367-.329-2.21.227-.602.412-.936.82-1.08h-.005c.199-.074.389-.153.486-.259a3.418 3.418 0 0 1 2.298-1.103c.037-.093.079-.185.125-.283.31-.658.639-1.029 1.024-1.168a.94.94 0 0 1 .328-.06zm.006.7c-.507.016-1.001 1.519-1.001 1.519s-1.27-.204-2.266.871c-.199.218-.468.334-.746.44-.079.028-.176.023-.417.672-.371.991.625 2.094.625 2.094s-1.186.839-1.626 1.881c-.486 1.144-.338 2.261-.338 2.261s-.843.732-.899 1.487c-.051.663.139 1.2.343 1.515.227.343.51.176.51.176s-.561.653-.037.931c.477.25 1.283.394 1.71-.037.31-.31.371-1.001.486-1.283.028-.065.12.111.209.199.097.093.264.195.264.195s-.755.324-.445 1.066c.102.246.468.403 1.066.398.222-.005 2.664-.139 3.313-.296.375-.088.505-.283.505-.283s1.566-.431 2.998-1.357c.917-.598 1.293-.76 2.034-.936.612-.148.57-1.098-.241-1.084-.839.009-1.575.44-2.196.825-1.163.718-1.742.672-1.742.672l-.018-.032c-.079-.13.371-1.293-.134-2.678-.547-1.515-1.413-1.881-1.344-1.997.297-.5 1.038-1.297 1.334-2.78.176-.899.13-2.377-.269-3.151-.074-.144-.732.241-.732.241s-.616-1.371-.788-1.483a.271.271 0 0 0-.157-.046z"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 1.9 KiB | 
| @@ -968,6 +968,11 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after { | ||||
|   word-break: break-all; | ||||
| } | ||||
|  | ||||
| .left-align, | ||||
| .left-align tr :is(td, th):last-child { | ||||
|   text-align: left; | ||||
| } | ||||
|  | ||||
| .tooltip { | ||||
|   position: relative; | ||||
|   display: inline-block; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jaywcjlove
					jaywcjlove