{"id":10020591,"date":"2025-01-06T22:09:25","date_gmt":"2025-01-06T14:09:25","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020591"},"modified":"2025-01-06T22:09:25","modified_gmt":"2025-01-06T14:09:25","slug":"taro-%e6%ba%90%e7%a0%81%e6%8f%ad%e7%a7%98%ef%bc%9a1-%e6%8f%ad%e5%bc%80%e6%95%b4%e4%b8%aa%e6%9e%b6%e6%9e%84%e7%9a%84%e5%85%a5%e5%8f%a3-cli-taro-init-%e5%88%9d%e5%a7%8b%e5%8c%96%e9%a1%b9%e7%9b%ae","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020591","title":{"rendered":"Taro \u6e90\u7801\u63ed\u79d8\uff1a1. \u63ed\u5f00\u6574\u4e2a\u67b6\u6784\u7684\u5165\u53e3 CLI =&gt; taro init \u521d\u59cb\u5316\u9879\u76ee\u7684\u79d8\u5bc6"},"content":{"rendered":"<h2>1. \u524d\u8a00<\/h2>\n<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f<a href=\"https:\/\/link.segmentfault.com\/?enc=jZDwpwWBcGaXfFrngCqrng%3D%3D.2uidFJyG8pKAXjQV1KkG4fJpqT03v2QemfhRdqFotmxtE5yVzTJEPjTwdeJs6q8S\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u82e5\u5ddd<\/a>\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684<a href=\"https:\/\/link.segmentfault.com\/?enc=HzHE8ZSIyULmQ6cUjazZyA%3D%3D.llUDQWJhnw4uFC%2B379%2Bp8jw1eHjZH%2FLd2CRBMGlGqDKwjhKEakHiJ4Y4UekVA7IPnAjL%2BSwZ0p35D2%2Bld%2FTE2w%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u516c\u4f17\u53f7\uff1a\u82e5\u5ddd\u89c6\u91ce<\/a>\u3002\u6211\u503e\u529b\u6301\u7eed\u7ec4\u7ec7\u4e86 3 \u5e74\u591a<a href=\"https:\/\/link.segmentfault.com\/?enc=1npx2IlC6YGI%2BiSevbRajQ%3D%3D.tZlqNf2t28pTZlLGH3m%2B2T4YbhATcLc6jlIz8KUdg9uOpUDoK33VRVmEldWoBqVe\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u6bcf\u5468\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60 200 \u884c\u5de6\u53f3\u7684\u6e90\u7801\u5171\u8bfb\u6d3b\u52a8<\/a>\uff0c\u611f\u5174\u8da3\u7684\u53ef\u4ee5<a href=\"https:\/\/link.segmentfault.com\/?enc=GnYqRL9%2BcLHiIT9FobHlTA%3D%3D.AZPN0iwfj2awjzuTepmX59gz%2BFeto%2FGyR9IAyEI9mgqVnXFrRlK1qJLGXdBsJ3OC\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u70b9\u6b64\u626b\u7801\u52a0\u6211\u5fae\u4fe1 <code>ruochuan02<\/code> \u53c2\u4e0e<\/a>\u3002\u53e6\u5916\uff0c\u60f3\u5b66\u6e90\u7801\uff0c\u6781\u529b\u63a8\u8350\u5173\u6ce8\u6211\u5199\u7684\u4e13\u680f<a href=\"https:\/\/link.segmentfault.com\/?enc=CgJCvOu8Nn5sTUhMDOf9tA%3D%3D.9BJXj%2BpXQNEM1ldiluN5LGmSle2cSwHsmU1Yb1bhlGdDwlX8%2FfYeaVY1lEDIN%2FO%2F\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u300a\u5b66\u4e60\u6e90\u7801\u6574\u4f53\u67b6\u6784\u7cfb\u5217\u300b<\/a>\uff0c\u76ee\u524d\u662f\u6398\u91d1\u5173\u6ce8\u4eba\u6570\uff086k+\u4eba\uff09\u7b2c\u4e00\u7684\u4e13\u680f\uff0c\u5199\u6709\u51e0\u5341\u7bc7\u6e90\u7801\u6587\u7ae0\u3002<\/p>\n<p>\u622a\u81f3\u76ee\u524d\uff08<code>2024-07-17<\/code>\uff09\uff0c<code>taro<\/code> \u6b63\u5f0f\u7248\u662f <code>3.6.34<\/code>\uff0c<a href=\"https:\/\/link.segmentfault.com\/?enc=d3PaL5GY3bRrUpeBKDGVkg%3D%3D.udWp%2Bbn0dOia4svhiaW7dWKLkkd%2F5ku%2FKCvdy6%2BzNhdgYulZwuAsSLwzDIKoMnyf\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Taro 4.0 Beta \u53d1\u5e03\uff1a\u652f\u6301\u5f00\u53d1\u9e3f\u8499\u5e94\u7528\u3001\u5c0f\u7a0b\u5e8f\u7f16\u8bd1\u6a21\u5f0f\u3001Vite \u7f16\u8bd1\u7b49<\/a>\u3002\u6587\u7ae0\u63d0\u5230\u5c06\u4e8e 2024 \u5e74\u7b2c\u4e8c\u5b63\u5ea6\uff0c\u53d1\u5e03 <code>4.x<\/code>\u3002\u76ee\u524d\u5df2\u7ecf\u53d1\u5e03 <code>4.x<\/code>\u3002\u6240\u4ee5\u6211\u4eec\u76f4\u63a5\u5b66\u4e60 <code>main<\/code> \u5206\u652f\u6700\u65b0\u7248\u672c\u662f <code>4.0.2<\/code>\u3002<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=gYBLWwuh4MMxq0CZ1lFcDQ%3D%3D.V9TVYFm1cx%2BM3NPN0yLFb1UmTTFOs7%2F8dFpONeToC7LqueFrI8ZXu0JKUxc44%2F5E\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u591a\u7f16\u8bd1\u5185\u6838\u751f\u6001\u4e0b\u7684\u6781\u901f\u7814\u53d1\u4f53\u9a8c<\/a> \u5b98\u65b9\u535a\u5ba2\u6709\u5982\u4e0b\u56fe\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912574\" alt=\"\u591a\u7f16\u8bd1\u5185\u6838\u67b6\u6784\" title=\"\u591a\u7f16\u8bd1\u5185\u6838\u67b6\u6784\"><\/p>\n<p>\u8ba1\u5212\u5199\u4e00\u4e2a Taro \u6e90\u7801\u63ed\u79d8\u7cfb\u5217\uff0c\u535a\u5ba2\u5730\u5740\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=LlVDWDVoiNqr6TT%2BGP02Rg%3D%3D.Lh9QeTKNQYWtBovoZiWE%2BNdeiLK5UM2m7x6DdFAoJM4KZOn3n96ZPq7N2Dbms2SK\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/ruochuan12.github.io\/taro<\/a> \u53ef\u4ee5\u52a0\u5165\u4e66\u7b7e\uff0c\u6301\u7eed\u5173\u6ce8<a href=\"https:\/\/link.segmentfault.com\/?enc=pNTksLyN77Ku8PVj1KdtkA%3D%3D.7fhlDRnL1Rh%2BKdA1BnQFwfa%2B0X2XHX8tXbu8wpLmhoksD3KVu4dzGYkeEHgWs57P\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u82e5\u5ddd<\/a>\u3002<\/p>\n<ul>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=5oDxZ337M%2B56LlDx%2Fm1vDg%3D%3D.CcvYj9pJ8S8eRY4l2IkAvRtMD7GYbF8fZo5OXpVbdBLK6%2Bl9QsLhG319TiSH5T84\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">1. \u63ed\u5f00\u6574\u4e2a\u67b6\u6784\u7684\u5165\u53e3 CLI =&gt; taro init \u521d\u59cb\u5316\u9879\u76ee\u7684\u79d8\u5bc6<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=wHYsOyMGFiEHk%2BV%2FPS6RWg%3D%3D.TBGj8s283TJfJlOOs%2BpVeFPaZicyLY6De%2Bo0aqTivW3fTriRJC%2FSGFB3E7QVnwuM\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">2. \u63ed\u5f00\u6574\u4e2a\u67b6\u6784\u7684\u63d2\u4ef6\u7cfb\u7edf\u7684\u79d8\u5bc6<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=2NjatsWAszLnAjwGh0VKqA%3D%3D.qOYvZaCJaG0tvgrXFgQlel5c1y5NppmviUEEIA2TDJkJ9SL7%2B62CJQ74BNTvjTCC\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">3. \u6bcf\u6b21\u521b\u5efa\u65b0\u7684 taro \u9879\u76ee\uff08taro init\uff09\u7684\u80cc\u540e\u539f\u7406\u662f\u4ec0\u4e48<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=oJP8xC55n%2FqPoaupGBRiqQ%3D%3D.lbiiGOaYDgfHgZbnO%2F4urGrI9bI25y1wCjsPggqwWLRdqw6PkxEt%2FPeoWz7%2F5Dyc\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">4. \u6bcf\u6b21 npm run dev:weapp \u5f00\u53d1\u5c0f\u7a0b\u5e8f\uff0cbuild \u7f16\u8bd1\u6253\u5305\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=0VHnm0mJab462sA93Hz3FQ%3D%3D.3JrsYdiFakCmpd4FmLa%2BPUxqJLxdjoXU9SO7ZjlwuVwpaG8Xwk9CbPXvEtLDrJR3\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">5. \u9ad8\u624b\u90fd\u5728\u7528\u7684\u53d1\u5e03\u8ba2\u9605\u673a\u5236 Events \u5728 Taro \u4e2d\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=C27Tf7T0A%2By1f6AzWGCKug%3D%3D.QbncY%2Flk%2FB8fL3Of5oAarhKAWh8sEWiS%2FYrCGteukaAUL2jQXhFMqze0hxUo7Dul\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">6. \u4e3a\u4ec0\u4e48\u901a\u8fc7 Taro.xxx \u80fd\u8c03\u7528\u5404\u4e2a\u5c0f\u7a0b\u5e8f\u5e73\u53f0\u7684 API\uff0c\u5982\u4f55\u8bbe\u8ba1\u5b9e\u73b0\u7684?<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=xCTxQX%2FlVjYVwa048eakDg%3D%3D.TUslRAhBpwyhbItT5A4wrsWfRu0F6XWq%2BW7M3iIZDFO%2FpkqxWgNrv0M8toyo75Nb\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">7. Taro.request \u548c\u8bf7\u6c42\u54cd\u5e94\u62e6\u622a\u5668\u662f\u5982\u4f55\u5b9e\u73b0\u7684<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=JDXx9rpLj7Wwdi3BKrIQ0A%3D%3D.mwL5KYV8MkqsmX8J7XnJ1ZIbS6M0YI0rUbDU53KMZZW9D9OTC%2FBDtcJfou1PEHGs\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">8. Taro \u662f\u5982\u4f55\u4f7f\u7528 webpack \u6253\u5305\u6784\u5efa\u5c0f\u7a0b\u5e8f\u7684\uff1f<\/a><\/li>\n<li>[x] <a href=\"https:\/\/link.segmentfault.com\/?enc=3Zz%2Fx2qKxf%2BvS8c62NZrCA%3D%3D.XTDB%2BoyVqPxM2Vrf8QlTR%2BM7tpEBegThy%2BuydJHnDxSyVGl%2BFUb%2Bmy0lPUoumhn9\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">9. Taro \u662f\u5982\u4f55\u751f\u6210 webpack \u914d\u7f6e\u8fdb\u884c\u6784\u5efa\u5c0f\u7a0b\u5e8f\u7684\uff1f<\/a><\/li>\n<li>[ ] \u7b49\u7b49<\/li>\n<\/ul>\n<p>\u5b66\u5b8c\u672c\u6587\uff0c\u4f60\u5c06\u5b66\u5230\uff1a<\/p>\n<pre><code class=\"bash\">1. \u5b66\u4f1a\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u8c03\u8bd5 taro \u6e90\u7801\n2. \u5b66\u4f1a\u5165\u53e3 taro-cli \u5177\u4f53\u5b9e\u73b0\u65b9\u5f0f\n3. \u5b66\u4f1a cli init \u547d\u4ee4\u5b9e\u73b0\u539f\u7406\uff0c\u8bfb\u53d6\u7528\u6237\u9879\u76ee\u914d\u7f6e\u6587\u4ef6\u548c\u7528\u6237\u5168\u5c40\u914d\u7f6e\u6587\u4ef6\n4. \u5b66\u4f1a taro-service kernal \uff08\u5185\u6838\uff09\u89e3\u8026\u5b9e\u73b0\n5. \u521d\u6b65\u5b66\u4f1a taro \u63d2\u4ef6\u67b6\u6784\uff0c\u5b66\u4f1a\u5982\u4f55\u7f16\u5199\u4e00\u4e2a taro \u63d2\u4ef6<\/code><\/pre>\n<h2>2. \u51c6\u5907\u5de5\u4f5c<\/h2>\n<pre><code class=\"bash\"># \u514b\u9686\u9879\u76ee\ngit clone https:\/\/github.com\/NervJS\/taro.git\n# \u5207\u6362\u5230\u5206\u652f main\ngit checkout main\n# \u5199\u6587\u7ae0\u65f6\uff0c\u9879\u76ee\u5f53\u524d hash\ngit checkout f53250b68f007310bf098e77c6113e2012983e82\n# Merge branch 'main' into 4.x\n# \u5199\u6587\u7ae0\u65f6\uff0c\u5f53\u524d\u7248\u672c\n# 4.0.2<\/code><\/pre>\n<p>\u770b\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u7b2c\u4e00\u6b65\u5e94\u8be5\u662f\u5148\u770b <a href=\"https:\/\/link.segmentfault.com\/?enc=ln7C9G9zvnu3FoJ5Uo26Hw%3D%3D.oG7Ziz%2F2Ap4aFGeZhZefDx3WHNq5MJTBBXdQnr9cFUfL%2Foa3Ly15QS48EicNfJA4\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">README.md<\/a> \u518d\u770b <a href=\"https:\/\/link.segmentfault.com\/?enc=i7NpxHe7Cyhpx622djcqAA%3D%3D.PDQd2k%2BUR8Cz4qqh7Jjf2W2ijPZs1EJZqT8OIl%2FslyHhPgK1gMI8I9Kc3r0ge030XI4T0ZJjgDwAkjuJlFUbaw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u8d21\u732e\u6587\u6863<\/a> \u548c <code>package.json<\/code>\u3002<\/p>\n<p>\u73af\u5883\u51c6\u5907<\/p>\n<blockquote><p>\u9700\u8981\u5b89\u88c5 <a href=\"https:\/\/link.segmentfault.com\/?enc=lm4pOtbwQpq%2BbibpwZiAJg%3D%3D.Z%2F8bZGhdac0vxnAPJ%2Bwj506WzbxIK16tKEB%2Bty1n%2F10%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Node.js 16<\/a>\uff08\u5efa\u8bae\u5b89\u88c5 <code>16.20.0<\/code> \u53ca\u4ee5\u4e0a\u7248\u672c\uff09\u53ca <a href=\"https:\/\/link.segmentfault.com\/?enc=BW9EpOgAGJrUVN4pRbXtcg%3D%3D.jfORecDN7l8CUxaFA%2FSEFzIRQbJZrymyij9SO7oCvK4%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">pnpm 7<\/a><\/p><\/blockquote>\n<p>\u6211\u4f7f\u7528\u7684\u73af\u5883\uff1a<code>mac<\/code>\uff0c\u5f53\u7136 <code>Windows<\/code> \u4e00\u6837\u53ef\u4ee5\u3002<\/p>\n<p>\u4e00\u822c\u7528 <a href=\"https:\/\/link.segmentfault.com\/?enc=wb4ooM56RohYMs%2BAkTE7mw%3D%3D.yb45jFNKR7tsmoNqnBy1xR8htV2xFs006Qw6Iaza%2B%2BI%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">nvm<\/a> \u7ba1\u7406 <code>node<\/code> \u7248\u672c\u3002<\/p>\n<pre><code class=\"zsh\">nvm install 18\nnvm use 18\n# \u53ef\u4ee5\u628a node \u9ed8\u8ba4\u7248\u672c\u8bbe\u7f6e\u4e3a 18\uff0c\u8c03\u8bd5\u65f6\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u7248\u672c\nnvm alias default 18\n\npnpm -v\n# 9.1.1\nnode -v\n# v18.20.2\n\ncd taro\n# \u5b89\u88c5\u4f9d\u8d56\npnpm i\n# \u5982\u679c\u7f51\u7edc\u4e0d\u597d\uff0c\u4e00\u76f4\u5b89\u88c5\u4e0d\u4e0a\u53ef\u4ee5\u6307\u5b9a\u56fd\u5185\u955c\u50cf\u7ad9\uff0c\u901f\u5ea6\u6bd4\u8f83\u5feb\npnpm i --registry=https:\/\/registry.npmmirror.com\n# \u7f16\u8bd1\u6784\u5efa\npnpm build<\/code><\/pre>\n<pre><code class=\"bash\"># \u5220\u9664\u6839\u76ee\u5f55\u7684 node_modules \u548c\u6240\u6709 workspace \u91cc\u7684 node_modules\n$ pnpm run clear-all\n# \u5bf9\u5e94\u7684\u662f\uff1arimraf **\/node_modules\n# mac \u4e0b\u53ef\u4ee5\u7528 rm -rf **\/node_modules<\/code><\/pre>\n<p>\u5b89\u88c5\u4f9d\u8d56\u53ef\u80fd\u4f1a\u62a5\u9519\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912575\" alt=\"pnpm-i-error.png\" title=\"pnpm-i-error.png\" loading=\"lazy\"><\/p>\n<pre><code class=\"bash\">Failed to set up Chromium r1108766! Set &quot;PUPPETEER_SKIP_DOWNLOAD&quot; env variable to skip download.<\/code><\/pre>\n<p>\u901a\u8fc7\u8c37\u6b4c\u7b49\u641c\u7d22\u5f15\u64ce\u53ef\u4ee5\u627e\u5230\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=i4WpBDLLiDb%2Bp0OrubARiA%3D%3D.A2pLmM7KRRqDQ024ps0E355AAmUTPPJ2zZ7ekq5KQn%2BXYLRws8Fg5r6TjEn2F2%2FxOyRsFwyGHF3z0ZY%2FaQfQ8M%2BWRbD5e5Mpb%2BAF8eKVt5BUDSpO7j20X60anRG5ZjJaHHmKkccDDkplvPIiAyxdUx%2Btoxb0ZwlNGEeEdmo25Cs%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">stackoverflow<\/a><\/p>\n<p>Mac : <code>export PUPPETEER_SKIP_DOWNLOAD='true'<\/code><br \/>Windows: <code>SET PUPPETEER_SKIP_DOWNLOAD='true'<\/code><\/p>\n<p>pnpm build \u5b8c\u6210\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912576\" alt=\"pnpm-build.png\" title=\"pnpm-build.png\" loading=\"lazy\"><\/p>\n<h2>3. \u8c03\u8bd5<\/h2>\n<p>package.json<\/p>\n<pre><code class=\"json\">\/\/ packages\/taro-cli\/package.json\n{\n    &quot;name&quot;: &quot;@tarojs\/cli&quot;,\n    &quot;version&quot;: &quot;4.0.0&quot;,\n    &quot;description&quot;: &quot;cli tool for taro&quot;,\n    &quot;main&quot;: &quot;index.js&quot;,\n    &quot;types&quot;: &quot;dist\/index.d.ts&quot;,\n    &quot;bin&quot;: {\n        &quot;taro&quot;: &quot;bin\/taro&quot;\n    }\n}<\/code><\/pre>\n<h3>3.1 \u5165\u53e3\u6587\u4ef6 packages\/taro-cli\/bin\/taro<\/h3>\n<pre><code class=\"js\">\/\/ packages\/taro-cli\/bin\/taro\n\n#! \/usr\/bin\/env node\n\nrequire(&quot;..\/dist\/util&quot;).printPkgVersion();\n\nconst CLI = require(&quot;..\/dist\/cli&quot;).default;\n\nnew CLI().run();<\/code><\/pre>\n<h3>3.2 \u8c03\u8bd5\u65b9\u6cd5 1 JavaScript Debug Terminal<\/h3>\n<p>\u53ef\u53c2\u8003\u6211\u7684\u6587\u7ae0<a href=\"https:\/\/link.segmentfault.com\/?enc=6YkrvPkYHCu38mT2lVCN8g%3D%3D.wjhLIlHR24DBAuLlK5jDVIXZx2xVD9l48DAUzPzowna7jShfcYTGSzv%2B7MmCS%2BJu\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u65b0\u624b\u5411\uff1a\u524d\u7aef\u7a0b\u5e8f\u5458\u5fc5\u5b66\u57fa\u672c\u6280\u80fd\u2014\u2014\u8c03\u8bd5 JS \u4ee3\u7801<\/a>\uff0c\u6216\u8005<a href=\"https:\/\/link.segmentfault.com\/?enc=HPNT8ABDZPchqNJbDQzXNQ%3D%3D.hJkgW1jM%2BG%2FMtSdJMEUfmzJNDu6N9g6HGJa5K%2BJn4MXAM97C9b4QjHfBdTPN%2FeDd\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u636e\u8bf4 90%\u7684\u4eba\u4e0d\u77e5\u9053\u53ef\u4ee5\u7528\u6d4b\u8bd5\u7528\u4f8b(Vitest)\u8c03\u8bd5\u5f00\u6e90\u9879\u76ee(Vue3) \u6e90\u7801<\/a><\/p>\n<p>\u7b80\u800c\u8a00\u4e4b\u5c31\u662f\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<pre><code class=\"bash\">1. \u627e\u5230\u5165\u53e3\u6587\u4ef6\u8bbe\u7f6e\u65ad\u70b9\n2. ctrl + `\/`` (\u53cd\u5f15\u53f7) \u6253\u5f00\u7ec8\u7aef\uff0c\u914d\u7f6e`JavaScript\u8c03\u8bd5\u7ec8\u7aef`\n3. \u5728\u7ec8\u7aef\u8f93\u5165 `node` \u76f8\u5173\u547d\u4ee4\uff0c\u8fd9\u91cc\u7528 `init` \u4e3e\u4f8b\n4. \u5c3d\u60c5\u8c03\u8bd5\u6e90\u7801<\/code><\/pre>\n<pre><code class=\"bash\">node .\/packages\/taro-cli\/bin\/taro init taro-init-debug<\/code><\/pre>\n<p>\u672c\u6587\u5c06\u90fd\u662f\u4f7f\u7528 <code>init<\/code> \u547d\u4ee4\u4f5c\u4e3a\u793a\u4f8b\u3002<\/p>\n<p>\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912577\" alt=\"vscode \u8c03\u8bd5\u6e90\u7801\" title=\"vscode \u8c03\u8bd5\u6e90\u7801\" loading=\"lazy\"><\/p>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528\u9879\u76ee\u4e2d\u63d0\u4f9b\u7684\u6d4b\u8bd5\u7528\u4f8b <code>packages\/taro-cli\/src\/__tests__\/cli.spec.ts<\/code> \u63d0\u524d\u6253\u65ad\u70b9\u8c03\u8bd5\u6e90\u7801\u3002<a href=\"https:\/\/link.segmentfault.com\/?enc=3DHxtMvEwX0QGazFCEJ%2Fgw%3D%3D.nwDZue5rm0hFXiQ8%2F19QybmnVBYH6S5ys8yL%2BfMzcRd276A4bmOyHm%2Fupsc%2FXFn9YpSPI5MeaTG9VRKe2AxTSXRSczu9T8aHharglbfa9yoHVb7H5KsAn54umb8YaM4z\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u8d21\u732e\u6587\u6863-\u5355\u5143\u6d4b\u8bd5<\/a>\u4e2d\u6709\u63d0\u5230\uff1a<\/p>\n<blockquote><p><code>package.json<\/code> \u4e2d\u8bbe\u7f6e\u4e86 <code>test:ci<\/code> \u547d\u4ee4\u7684\u5b50\u5305\u90fd\u914d\u5907\u4e86\u5355\u5143\u6d4b\u8bd5\u3002<br \/>\u5f00\u53d1\u8005\u5728\u4fee\u6539\u8fd9\u4e9b\u5305\u540e\uff0c\u8bf7\u8fd0\u884c <code>pnpm --filter [package-name] run test:ci<\/code>\uff0c\u68c0\u67e5\u6d4b\u8bd5\u7528\u4f8b\u662f\u5426\u90fd\u80fd\u901a\u8fc7\u3002<\/p><\/blockquote>\n<pre><code class=\"bash\"># JavaScript Debug Terminal\npnpm --filter @tarojs\/cli run test:ci<\/code><\/pre>\n<p>\u8c03\u8bd5\u548c\u4e0a\u56fe\u7c7b\u4f3c\uff0c\u5c31\u4e0d\u622a\u8c03\u8bd5\u56fe\u4e86\u3002<\/p>\n<p>\u8c03\u8bd5\u65f6\u5e94\u8be5\u4f1a\u62a5\u9519 <code>binding<\/code> <code>taro.[os-platform].node<\/code>\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912578\" alt=\"binding-error.png\" title=\"binding-error.png\" loading=\"lazy\"><\/p>\n<p>\u8fd0\u884c\u7b49\u8fc7\u7a0b\u62a5\u9519\uff0c\u4e0d\u8981\u614c\u3002\u53ef\u80fd\u662f\u6211\u4eec\u9057\u6f0f\u4e86\u4e00\u4e9b\u7ec6\u8282\uff0c\u8d21\u732e\u6587\u6863\u7b49\u5e94\u8be5\u4f1a\u7ed9\u51fa\u7b54\u6848\u3002\u6240\u4ee5\u518d\u6765\u770b\u4e0b <a href=\"https:\/\/link.segmentfault.com\/?enc=cFClzsrtSCCtfKyfiGcGdA%3D%3D.ePJ6QZibqo%2F05D3Js1diM9I3LGlo%2BR1K%2F8PnPFB4C56Y7%2Fae5yLAW8%2BxB%2BeL18BGFkFDmaYpgK2DZtNWh2cVdyYKMffzL%2F3YRnCRItBinnA2fGWsQy82b0sx6P2KnJGY\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u8d21\u732e\u6587\u6863-10-rust-\u90e8\u5206<\/a><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912579\" alt=\"binding-rust.png\" title=\"binding-rust.png\" loading=\"lazy\"><\/p>\n<p>\u901a\u8fc7 <a href=\"https:\/\/link.segmentfault.com\/?enc=TOQzo3NOP8pQ%2BTnHkURwog%3D%3D.ucGK%2FsizMBl1OsdQPPvzwnj%2B2KBLvy5B7HdSxwVX%2FwA%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">rustup<\/a> \u627e\u5230\u5b89\u88c5\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"bash\">curl --proto '=https' --tlsv1.2 -sSf https:\/\/sh.rustup.rs | sh<\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6267\u884c <code>pnpm run build:binding:debug<\/code> \u6216 <code>pnpm run binding:release<\/code> \u7f16\u8bd1\u51fa\u6587\u4ef6\uff1a<code>crates\/native_binding\/taro.darwin-arm64.node<\/code>\u3002<\/p>\n<p>\u5c31\u5b8c\u7f8e\u89e3\u51b3\u4e86\uff0c\u8c03\u8bd5\u65f6\u4e0d\u4f1a\u62a5\u9519\u4e86\u3002<\/p>\n<h3>3.3 \u8c03\u8bd5\u65b9\u5f0f 2 \u914d\u7f6e .vscode\/launch.json<\/h3>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=%2B4pCQBYDRioMNKOntV4GYQ%3D%3D.OTDkHDXlr9foDGppCc%2Bf%2BTpFR5soeD1n%2FP9hJIbXvVrtJNrqGU74fXu7qlTDG6Wh\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">taro \u6587\u6863 &#8211; \u5355\u6b65\u8c03\u6d4b\u914d\u7f6e<\/a><br \/>\u5199\u7684\u633a\u597d\u7684\uff0c\u901a\u8fc7\u914d\u7f6e <code>launch.json<\/code> \u6765\u8c03\u8bd5\uff0c\u5728\u6b64\u5c31\u4e0d\u518d\u8d58\u8ff0\u4e86\u3002<\/p>\n<p>\u4e0d\u8fc7\u8865\u5145\u4e00\u6761\uff1a<code>launch.json<\/code> \u6587\u4ef6\u53ef\u4ee5\u6dfb\u52a0\u4e00\u6761 <code>&quot;console&quot;: &quot;integratedTerminal&quot;<\/code>\uff08\u96c6\u6210\u7ec8\u7aef\uff09\u914d\u7f6e\uff0c\u5c31\u53ef\u4ee5\u5728\u8c03\u8bd5\u7ec8\u7aef\u8f93\u5165\u5185\u5bb9\u3002<code>args<\/code> \u53c2\u6570\u6dfb\u52a0 <code>init<\/code> \u548c\u6307\u5b9a\u8981\u521d\u59cb\u5316\u9879\u76ee\u7684\u6587\u4ef6\u5939\u3002\u5f53\u7136\u8c03\u8bd5\u5176\u4ed6\u7684\u65f6\u5019\u4e5f\u53ef\u4ee5\u4fee\u6539\u4e3a\u5176\u4ed6\u53c2\u6570\u3002\u6bd4\u5982<code>args: [&quot;build&quot;, &quot;--type&quot;, &quot;weapp&quot;, &quot;--watch&quot;]<\/code>\u3002<\/p>\n<pre><code class=\"json\">{\n    &quot;version&quot;: &quot;0.2.0&quot;,\n    &quot;configurations&quot;: [\n        {\n            &quot;type&quot;: &quot;node&quot;,\n            &quot;request&quot;: &quot;launch&quot;,\n            &quot;name&quot;: &quot;CLI debug&quot;,\n            &quot;program&quot;: &quot;${workspaceFolder}\/packages\/taro-cli\/bin\/taro&quot;,\n            \/\/ &quot;cwd&quot;: &quot;${project absolute path}&quot;,\n            &quot;args&quot;: [\n                &quot;init&quot;,\n                &quot;taro-init-debug&quot;,\n            ],\n            &quot;skipFiles&quot;: [&quot;&lt;node_internals&gt;\/**&quot;],\n            &quot;console&quot;: &quot;integratedTerminal&quot;\n        }\n    ]\n}<\/code><\/pre>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=YkYxvrrfhi%2FIdy%2BuSBr5Qw%3D%3D.Vy5%2BMgeGZGDzfMGvVPTX9zfPAVw1PQYQ8BayHM4F3MuPlzaa4L8sHA2Mant0TMfayfnPw8BE%2B4B%2FotabMDa3Bm%2FpsOgJJrgsUI1Cfw4kRWE%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">vscode nodejs \u8c03\u8bd5<\/a><\/p>\n<p><code>console- \u542f\u52a8\u7a0b\u5e8f\u7684\u63a7\u5236\u53f0\uff08internalConsole\uff0cintegratedTerminal\uff0cexternalTerminal\uff09\u3002<\/code><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912580\" alt=\"vscode-console.png\" title=\"vscode-console.png\" loading=\"lazy\"><\/p>\n<pre><code class=\"js\">\/\/ packages\/taro-cli\/bin\/taro\n\n#! \/usr\/bin\/env node\n\nrequire(&quot;..\/dist\/util&quot;).printPkgVersion();\n\nconst CLI = require(&quot;..\/dist\/cli&quot;).default;\n\nnew CLI().run();<\/code><\/pre>\n<p>\u6211\u4eec\u8ddf\u7740\u65ad\u70b9\u8fdb\u5165\uff0c\u5165\u53e3\u6587\u4ef6\u4e2d\u7684\u7b2c\u4e00\u53e5<code>require(&quot;..\/dist\/util&quot;).printPkgVersion();<\/code> <code>printPkgVersion<\/code> \u51fd\u6570\u3002<\/p>\n<h2>4. taro-cli\/src\/utils\/index.ts<\/h2>\n<p>\u5de5\u5177\u51fd\u6570<\/p>\n<pre><code class=\"js\">\/\/ packages\/taro-cli\/src\/util\/index.ts\nimport * as path from &quot;path&quot;;\n\nexport function getRootPath(): string {\n    return path.resolve(__dirname, &quot;..\/..\/&quot;);\n}\n\nexport function getPkgVersion(): string {\n    return require(path.join(getRootPath(), &quot;package.json&quot;)).version;\n}\n\nexport function printPkgVersion() {\n    console.log(`\ud83d\udc7d Taro v${getPkgVersion()}`);\n    console.log();\n}<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u51fa\u8fd9\u53e5\u8f93\u51fa\u7684\u662f <code>taro\/packages\/taro-cli\/package.json<\/code> \u7684\u7248\u672c\u53f7\u3002<\/p>\n<pre><code class=\"js\">\ud83d\udc7d Taro v4.0.0<\/code><\/pre>\n<p>\u6211\u4eec\u7ee7\u7eed\u8ddf\u7740\u65ad\u70b9\uff0c\u8fdb\u5165\u7b2c\u4e8c\u7b2c\u4e09\u53e5\uff0c\u53ef\u4ee5\u8fdb\u5165\u5230 <code>packages\/taro-cli\/src\/cli.ts<\/code> \u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n<h2>5. CLI \u6574\u4f53\u7ed3\u6784<\/h2>\n<p><code>taro-cli<\/code> \u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\u662f\uff1a<\/p>\n<blockquote><p>packages\/taro-cli\/src\/cli.ts<\/p><\/blockquote>\n<p>\u6211\u4eec\u5148\u6765\u770b\u4e0b\u8fd9\u4e2a\u6587\u4ef6\u7684\u6574\u4f53\u7ed3\u6784\u3002<code>class CLI<\/code> \u4e00\u4e2a appPath \u5c5e\u6027\uff08\u4e00\u822c\u6307 <code>taro<\/code> \u5de5\u4f5c\u76ee\u5f55\uff09\uff0c\u4e24\u4e2a\u51fd\u6570 <code>run<\/code> \u548c <code>parseArgs<\/code>\u3002<\/p>\n<pre><code class=\"js\">\/\/ packages\/taro-cli\/src\/cli.ts\nexport default class CLI {\n    appPath: string;\n    constructor(appPath) {\n        this.appPath = appPath || process.cwd();\n    }\n\n    run() {\n        return this.parseArgs();\n    }\n\n    async parseArgs() {\n        const args = minimist(process.argv.slice(2), {\n            alias: {\n                \/\/ \u7701\u7565\u4e00\u4e9b\u522b\u540d\u8bbe\u7f6e ...\n            },\n            boolean: [&quot;version&quot;, &quot;help&quot;, &quot;disable-global-config&quot;],\n            default: {\n                build: true,\n            },\n        });\n        const _ = args._;\n        \/\/ init\u3001build \u7b49\n        const command = _[0];\n        if (command) {\n            \/\/ \u7701\u7565\u82e5\u5e72\u4ee3\u7801\n        } else {\n            if (args.h) {\n                \/\/ \u8f93\u51fa\u5e2e\u52a9\u4fe1\u606f\n                \/\/ \u7701\u7565\u4ee3\u7801\n            } else if (args.v) {\n                \/\/ \u8f93\u51fa\u7248\u672c\u53f7\n                console.log(getPkgVersion());\n            }\n        }\n    }\n}<\/code><\/pre>\n<p>\u4f7f\u7528\u4e86<a href=\"https:\/\/link.segmentfault.com\/?enc=XHBA3k%2B1snILfFiAY1pPHQ%3D%3D.kyiA5Zu4%2FY91kRnoEYCHyHSNqvLb%2BgwsUhyum%2Bu1x4o0vEa2GDL9gLc4Bd8LPelb\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">minimist<\/a>\uff0c\u53c2\u6570\u89e3\u6790\u5de5\u5177\u3002<\/p>\n<p>\u540c\u7c7b\u5de5\u5177\u8fd8\u6709\uff1a<br \/><a href=\"https:\/\/link.segmentfault.com\/?enc=tU0h6P0kddnMdSs1Qq3%2F5Q%3D%3D.a1CJgP8BX4V1fd3ZD9n3nIQ1hWoamS4tdPy245BcedgGT0Iz4spXeA96Rv1tpvRe\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">commander<\/a>\uff0c\u547d\u4ee4\u884c\u5de5\u5177\u3002\u529f\u80fd\u9f50\u5168\u7684\u6846\u67b6\uff0c\u63d0\u4f9b\u7c7b\u4f3c git \u7684\u5b50\u547d\u4ee4\u7cfb\u7edf\uff0c\u81ea\u52a8\u751f\u6210\u5e2e\u52a9\u4fe1\u606f\u7b49\u3002\u6709\u5f88\u591a\u77e5\u540d\u7684 <code>cli<\/code> \u90fd\u662f\u7528\u7684\u8fd9\u4e2a<a href=\"https:\/\/link.segmentfault.com\/?enc=e8tGYUXbzeKOGTN9cmmBPQ%3D%3D.irZLv3MpHDF6LyPEAPt16UM5FqnMkUcmot6Cxpd4%2FpEL6E%2FmPBU66vUhuYlVObFR\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">commander<\/a>\u3002\u6bd4\u5982\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=mIZcK7SpRJV0hZxDrxVI6Q%3D%3D.Zi9RutSqLAyFFMSJjIyTMBF2bF%2B4QRrd2RqWkcSNbim41n%2BTopgo%2FrjHYA8TW4IBFypHmedDA4heYIgix%2BOLVWXcRpu2FGubjdY%2Fxx6853g%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><code>vue-cli<\/code><\/a>\u3001<a href=\"https:\/\/link.segmentfault.com\/?enc=GCYokVY4KcHxDFO8xWA1lg%3D%3D.eO2rcnqUlzfBlXDw42f%2FMTdR%2B5ViK55eVALNQgg4%2FFM1%2FntG7zQSeuFyBO%2BNbfBpCDTkAPKn8PtTZA9LHKKWWNzVxCPWWgAVS55FICWxd9P8KKtWcxY37I21a8%2Fl2b8Z\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><code>webpack-cli<\/code><\/a> \u548c <a href=\"https:\/\/link.segmentfault.com\/?enc=uvllg%2FRQGyrJA1NkQFwbTA%3D%3D.%2FQv26LaR0qMHTCXSTBi%2BjnSXsU4huWoe3Ueosb1fyZEzOsUvgga3gepG97BvoPj5zSLcr4bNsHrKYYeKfBk%2F8eFe5TqMwnmWVQ3q0t%2FBO6vG6IfFXv0mLf8iJk68oydHmsOJ%2Bl5EXpJyYwtA9gHssw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><code>create-react-app<\/code><\/a> \u7528\u7684\u662f\u8fd9\u4e2a\u3002<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=Am1%2F%2FCkhvmhLCrFdkq8sOA%3D%3D.daO2EWsSgnC1bIyIL1cEkbUEtdrCUOiLjSvbFaN4J9g%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">cac<\/a>\uff0c\u7c7b\u4f3c <code>Commander.js<\/code> \u4f46\u66f4\u8f7b\u5de7\u3001\u73b0\u4ee3\uff0c\u652f\u6301\u63d2\u4ef6\u3002\u4e5f\u6709\u5f88\u591a\u4f7f\u7528\u8fd9\u4e2a<a href=\"https:\/\/link.segmentfault.com\/?enc=nbr1SNLxw7C4jfW3f5Dw9g%3D%3D.pkqLgBgwHgSXqvwxvJgjNMd43vabLIvSm4tj9JM7RIuSjWrDkulEpeXr4jS7AGAOwg7KbgUusgvn9PDqyPUYCw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">cac npm<\/a>\uff0c\u6bd4\u5982<a href=\"https:\/\/link.segmentfault.com\/?enc=tuJwcCIYYdDzsP2x4gmBMg%3D%3D.Px%2Fy6BvzEPFJCwTVelJiFArj7HC3I%2BehUazqnLAhc3SfoJ%2FmekQdGbH9s7sog5pYLnUeSM6GZcp8z9Tbcuzsvw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><code>vite<\/code><\/a> \u4f7f\u7528\u7684\u662f\u8fd9\u4e2a\u3002<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=0ZsMwrhH25z3XCrfuBBTbA%3D%3D.mnUqzyEVZRzP0aVtY4dw6bIVLzikKa%2B%2BxwfCxFxMp0g%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">yargs<\/a>\uff0c\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\u5de5\u5177\u3002\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6\uff0c\u4f46\u663e\u5f97\u8fc7\u4e8e\u81c3\u80bf\u3002<\/p>\n<p><code>cli.run<\/code> \u51fd\u6570\u6700\u7ec8\u8c03\u7528\u7684\u662f <code>cli.parseArgs<\/code> \u51fd\u6570\u3002\u6211\u4eec\u63a5\u7740\u6765\u770b <code>parseArgs<\/code> \u51fd\u6570\u3002<\/p>\n<h2>6. cli parseArgs<\/h2>\n<h3>6.1 presets \u9884\u8bbe\u63d2\u4ef6\u96c6\u5408<\/h3>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912581\" alt=\"parseArgs-1.png\" title=\"parseArgs-1.png\" loading=\"lazy\"><\/p>\n<p><code>presets<\/code> \u5bf9\u5e94\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912582\" alt=\"presets.png\" title=\"presets.png\" loading=\"lazy\"><\/p>\n<h3>6.2 Config<\/h3>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912583\" alt=\"parseArgs-2.png\" title=\"parseArgs-2.png\" loading=\"lazy\"><\/p>\n<p><code>64-78<\/code> \u884c\u4ee3\u7801\uff0c\u4ee3\u7801\u91cf\u76f8\u5bf9\u8f83\u5c11\uff0c\u5c31\u622a\u56fe\u540c\u65f6\u987a\u4fbf\u76f4\u63a5\u653e\u4ee3\u7801\u4e86\u3002<\/p>\n<pre><code class=\"js\">\/\/ packages\/taro-cli\/src\/cli.ts\n\/\/ \u8fd9\u91cc\u89e3\u6790 dotenv \u4ee5\u4fbf\u4e8e config \u89e3\u6790\u65f6\u80fd\u83b7\u53d6 dotenv \u914d\u7f6e\u4fe1\u606f\nconst expandEnv = dotenvParse(appPath, args.envPrefix, mode);\n\nconst disableGlobalConfig = !!(\n    args[&quot;disable-global-config&quot;] ||\n    DISABLE_GLOBAL_CONFIG_COMMANDS.includes(command)\n);\n\nconst configEnv = {\n    mode,\n    command,\n};\nconst config = new Config({\n    appPath: this.appPath,\n    disableGlobalConfig: disableGlobalConfig,\n});\nawait config.init(configEnv);<\/code><\/pre>\n<p><code>dotenvParse<\/code> \u51fd\u6570\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u901a\u8fc7 <a href=\"https:\/\/link.segmentfault.com\/?enc=HhNelfq0GDxNFfCX9fUcNQ%3D%3D.r%2FmhI9sCEvhJ%2FDQTxrNQ2jjKTEKUNXt3I7rWEqywdoftUBz8dA9fCx2stYBt5NNs\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">dotenv<\/a> \u548c <a href=\"https:\/\/link.segmentfault.com\/?enc=YH8x4nDovFtTxd8hXTgKDQ%3D%3D.3J4KL5y7n7L5HpA1u38HsrVVa5RnMTjk%2BF44QHK%2ByjOv6A9rLJktBBl72%2FeUFC0L\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">dotenv-expand<\/a> \u89e3\u6790 <code>.env<\/code>\u3001<code>.env.development<\/code>\u3001<code>.env.production<\/code> \u7b49\u6587\u4ef6\u548c\u53d8\u91cf\u7684\u3002<\/p>\n<blockquote><p><code>dotenv<\/code> \u662f\u4e00\u4e2a\u96f6\u4f9d\u8d56\u6a21\u5757\uff0c\u53ef\u5c06 <code>.env<\/code> \u6587\u4ef6\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u52a0\u8f7d\u5230 <code>process.env<\/code> \u4e2d\u3002<\/p><\/blockquote>\n<p>\u6211\u4e4b\u524d\u5199\u8fc7\u4e00\u7bc7 <a href=\"https:\/\/link.segmentfault.com\/?enc=dvxqf9xP9wijzpNDCbcKZw%3D%3D.gRG2uAlPutuCFBEP3TOBMcB3DszhE81HRlHnjGsN6zOTw6U6XXNqS%2BST8qrKmR0m\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u9762\u8bd5\u5b98\uff1a\u9879\u76ee\u4e2d\u5e38\u7528\u7684 .env \u6587\u4ef6\u539f\u7406\u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u5b9e\u73b0\uff1f<\/a><\/p>\n<p>\u63a5\u7740\u6211\u4eec\u6765\u770b <code>Config<\/code> \u7c7b\u3002<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Config.ts\nexport default class Config {\n    appPath: string;\n    configPath: string;\n    initialConfig: IProjectConfig;\n    initialGlobalConfig: IProjectConfig;\n    isInitSuccess: boolean;\n    disableGlobalConfig: boolean;\n\n    constructor(opts: IConfigOptions) {\n        this.appPath = opts.appPath;\n        this.disableGlobalConfig = !!opts?.disableGlobalConfig;\n    }\n    async init(configEnv: { mode: string; command: string }) {\n        \/\/ \u4ee3\u7801\u7701\u7565\n    }\n    initGlobalConfig() {\n        \/\/ \u4ee3\u7801\u7701\u7565\n    }\n    getConfigWithNamed(platform, configName) {\n        \/\/ \u4ee3\u7801\u7701\u7565\n    }\n}<\/code><\/pre>\n<p><code>Config<\/code> \u6784\u9020\u51fd\u6570\u6709\u4e24\u4e2a\u5c5e\u6027\u3002<br \/><code>appPath<\/code> \u662f <code>taro<\/code> \u9879\u76ee\u8def\u5f84\u3002<br \/><code>disableGlobalConfig<\/code> \u662f\u7981\u7528\u5168\u5c40\u914d\u7f6e\u3002<\/p>\n<p>\u63a5\u7740\u6211\u4eec\u6765\u770b <code>Config<\/code> \u7c7b\u7684\u5b9e\u4f8b\u4e0a\u7684 <code>init<\/code> \u65b9\u6cd5\u3002<\/p>\n<h4>6.2.1 config.init \u521d\u59cb\u5316\u914d\u7f6e<\/h4>\n<p>\u8bfb\u53d6\u7684\u662f <code>config\/index<\/code> <code>.ts<\/code> \u6216\u8005 <code>.js<\/code> \u540e\u7f00\u3002<br \/>\u5224\u65ad\u662f\u5426\u7981\u7528 <code>disableGlobalConfig<\/code> \u5168\u5c40\u914d\u7f6e\u3002\u4e0d\u7981\u7528\u5219\u8bfb\u53d6\u5168\u5c40\u914d\u7f6e <code>~\/.taro-global-config\/index.json<\/code>\u3002<\/p>\n<pre><code class=\"ts\">async init (configEnv: {\n    mode: string\n    command: string\n  }) {\n    this.initialConfig = {}\n    this.initialGlobalConfig = {}\n    this.isInitSuccess = false\n    this.configPath = resolveScriptPath(path.join(this.appPath, CONFIG_DIR_NAME, DEFAULT_CONFIG_FILE))\n    if (!fs.existsSync(this.configPath)) {\n      if (this.disableGlobalConfig) return\n      this.initGlobalConfig()\n    } else {\n      createSwcRegister({\n        only: [\n          filePath =&gt; filePath.indexOf(path.join(this.appPath, CONFIG_DIR_NAME)) &gt;= 0\n        ]\n      })\n      try {\n        const userExport = getModuleDefaultExport(require(this.configPath))\n        this.initialConfig = typeof userExport === 'function' ? await userExport(merge, configEnv) : userExport\n        this.isInitSuccess = true\n      } catch (err) {\n        console.log(err)\n      }\n    }\n  }<\/code><\/pre>\n<p>\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912584\" alt=\"createSwcRegister.png\" title=\"createSwcRegister.png\" loading=\"lazy\"><\/p>\n<p><code>createSwcRegister<\/code> \u4f7f\u7528\u4e86 <a href=\"https:\/\/link.segmentfault.com\/?enc=qFbHr5ixKBynFT3c1wYrkw%3D%3D.rRbjv%2FabiNx4iIES7pXMb8pCzChT9Mj92qsShE67UDSvtx%2B4OFsFT77Tc6xHvAqv\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><code>@swc\/register<\/code><\/a> \u6765\u7f16\u8bd1 <code>ts<\/code> \u7b49\u8f6c\u6362\u6210 <code>commonjs<\/code>\u3002\u53ef\u4ee5\u76f4\u63a5\u7528 <code>require<\/code>\u3002<\/p>\n<blockquote><p>\u4f7f\u7528 swc \u7684\u65b9\u6cd5\u4e4b\u4e00\u662f\u901a\u8fc7 <code>require<\/code> \u94a9\u5b50\u3002<code>require<\/code> \u94a9\u5b50\u4f1a\u5c06\u81ea\u8eab\u7ed1\u5b9a\u5230 <code>node<\/code> \u7684 <code>require<\/code> \u5e76\u81ea\u52a8\u52a8\u6001\u7f16\u8bd1\u6587\u4ef6\u3002\u4e0d\u8fc7\u73b0\u5728\u66f4\u63a8\u8350 <a href=\"https:\/\/link.segmentfault.com\/?enc=aiq1Emth9JQjPVA4g4zQHg%3D%3D.29kzC6rU8de1OJUCocsyt4OllaH%2FSv7n68vr98YOyZn%2BV55LY%2BC%2FXLjaxdx2BjCpTJT5Mv8Kp4sWAEpa%2B07e%2Fw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@swc-node\/register<\/a>\u3002<\/p><\/blockquote>\n<pre><code class=\"ts\">export const getModuleDefaultExport = (exports) =&gt;\n    exports.__esModule ? exports.default : exports;<\/code><\/pre>\n<p><code>this.initialConfig = typeof userExport === 'function' ? await userExport(merge, configEnv) : userExport<\/code>\u3002\u8fd9\u53e5\u5c31\u662f <code>config\/index.ts<\/code> \u652f\u6301\u51fd\u6570\u4e5f\u652f\u6301\u5bf9\u8c61\u7684\u5b9e\u73b0\u3002<\/p>\n<p>\u63a5\u7740\u6211\u4eec\u6765\u770b <code>Config<\/code> \u7c7b\u7684\u5b9e\u4f8b\u4e0a\u7684 <code>initGlobalConfig<\/code> \u65b9\u6cd5\u3002<\/p>\n<h4>6.2.2 config.initGlobalConfig \u521d\u59cb\u5316\u5168\u5c40\u914d\u7f6e<\/h4>\n<p>\u8bfb\u53d6\u914d\u7f6e <code>~\/.taro-global-config\/index.json<\/code>\u3002<\/p>\n<pre><code class=\"json\">{\n    &quot;plugins&quot;: [],\n    &quot;presets&quot;: []\n}<\/code><\/pre>\n<pre><code class=\"ts\">initGlobalConfig () {\n    const homedir = getUserHomeDir()\n    if (!homedir) return console.error('\u83b7\u53d6\u4e0d\u5230\u7528\u6237 home \u8def\u5f84')\n    const globalPluginConfigPath = path.join(getUserHomeDir(), TARO_GLOBAL_CONFIG_DIR, TARO_GLOBAL_CONFIG_FILE)\n    if (!fs.existsSync(globalPluginConfigPath)) return\n    const spinner = ora(`\u5f00\u59cb\u83b7\u53d6 taro \u5168\u5c40\u914d\u7f6e\u6587\u4ef6\uff1a ${globalPluginConfigPath}`).start()\n    try {\n      this.initialGlobalConfig = fs.readJSONSync(globalPluginConfigPath) || {}\n      spinner.succeed('\u83b7\u53d6 taro \u5168\u5c40\u914d\u7f6e\u6210\u529f')\n    } catch (e) {\n      spinner.stop()\n      console.warn(`\u83b7\u53d6\u5168\u5c40\u914d\u7f6e\u5931\u8d25\uff0c\u5982\u679c\u9700\u8981\u542f\u7528\u5168\u5c40\u63d2\u4ef6\u8bf7\u67e5\u770b\u914d\u7f6e\u6587\u4ef6: ${globalPluginConfigPath} `)\n    }\n  }<\/code><\/pre>\n<p><code>getUserHomeDir<\/code> \u51fd\u6570\u4e3b\u8981\u662f\u83b7\u53d6\u7528\u6237\u7684\u4e3b\u9875\u8def\u5f84\u3002\u6bd4\u5982 <code>mac<\/code> \u4e2d\u662f <code>\/Users\/\u7528\u6237\u540d\/<\/code>\u3002<br \/>\u5982\u679c\u652f\u6301 <code>os.homedir()<\/code> \u76f4\u63a5\u83b7\u53d6\u8fd4\u56de\uff0c\u5982\u679c\u4e0d\u652f\u6301\u5219\u6839\u636e\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u548c\u73af\u5883\u53d8\u91cf\u5224\u65ad\u83b7\u53d6\u3002<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=EtiZlg0vpybJd9q%2BqgtGlQ%3D%3D.41ekMmR2OgcZ8%2BEme6%2FhKTPe%2FZPpkc4yuequlT0eaoGnokYPiP1lXm46GXuqgyvo\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">ora<\/a> \u662f\u63a7\u5236\u53f0\u7684 loading \u5c0f\u52a8\u753b\u3002<\/p>\n<blockquote><p>\u4f18\u96c5\u7684\u7ec8\u7aef\u65cb\u8f6c\u5668<\/p><\/blockquote>\n<p>\u8fd9\u91cc\u7684\u662f <code>fs<\/code> \u662f <code>@tarojs\/helper<\/code> \u3002<\/p>\n<blockquote><p>Taro \u7f16\u8bd1\u65f6\u5de5\u5177\u5e93\uff0c\u4e3b\u8981\u4f9b CLI\u3001\u7f16\u8bd1\u5668\u63d2\u4ef6\u4f7f\u7528\u3002<\/p><\/blockquote>\n<p>\u5bfc\u51fa\u7684 <a href=\"https:\/\/link.segmentfault.com\/?enc=Uarmtsqjtd0RuLmZNXNh5Q%3D%3D.W%2Bq1MvcBSo8C753EL2v0YkFBFVYyZNe6DcBk7Y1XXoRSZbNGRlI9fpftRNOXSQLl\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">fs-extra<\/a>\u3002<\/p>\n<blockquote><p>fs-extra \u6dfb\u52a0\u672c\u673a\u6a21\u5757\u4e2d\u672a\u5305\u542b\u7684\u6587\u4ef6\u7cfb\u7edf\u65b9\u6cd5 fs\uff0c\u5e76\u4e3a\u8fd9\u4e9b\u65b9\u6cd5\u6dfb\u52a0\u627f\u8bfa\u652f\u6301 fs\u3002\u5b83\u8fd8\u7528\u4e8e graceful-fs \u9632\u6b62 EMFILE \u9519\u8bef\u3002\u5b83\u5e94\u8be5\u662f \u7684\u66ff\u4ee3\u54c1 fs\u3002<\/p><\/blockquote>\n<p>\u4f7f\u7528 <a href=\"https:\/\/link.segmentfault.com\/?enc=LaZ%2FFwtHnchIkDFRgtV8UA%3D%3D.Qut5a4kbOsmVAZFIrVInFdI9gN9ZNOH59zhj78m8DfX0M0RrUX5Uw2EkY9F93wTz40V%2Bapn2xNsIepvP8TzB6Cu535uqDbMcTAQ%2F%2Bl2NDSQ%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">fs.readJSONSync<\/a> \u540c\u6b65\u8bfb\u53d6 <code>json<\/code> \u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u6587\u6863\u4e2d\u4e5f\u6709\u5bf9\u8fd9\u4e2a\u5168\u5c40\u53c2\u6570\u7684\u63cf\u8ff0\u3002<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=V5ePvzMs4dT2Gn8KanFe%2FQ%3D%3D.4%2FVeb5Kh70rKitgTyZ9NW4Cy6edtseH%2FL7qdPS5vLD%2BACrC%2BfrHFea2L4acdewdr0kY9f8XYY8qyUy7Nou8pPefHk9q%2FZXuwC%2ByG%2FGKcesZKDD%2BUAmBDSWkxlEviRAnt6lcK%2F7ug1UvI1TxNJJZz0y0JYhfz5JRhCnysFPr9nU1NkHucjZGxxkFOfbL7yGIT\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u5168\u5c40\u63d2\u4ef6\u6216\u63d2\u4ef6\u96c6\u914d\u7f6e<\/a><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912585\" alt=\"global-config.png\" title=\"global-config.png\" loading=\"lazy\"><\/p>\n<p><code>Config<\/code> \u90e8\u5206\u6211\u4eec\u57fa\u672c\u5206\u6790\u5b8c\u6210\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u5b66\u4e60 <code>Kernel<\/code> \uff08\u5185\u6838\uff09\u90e8\u5206\u3002<\/p>\n<h2>7. Kernel \uff08\u5185\u6838\uff09<\/h2>\n<pre><code class=\"ts\">\/\/ packages\/taro-cli\/src\/cli.ts\n\n\/\/ \u7701\u7565\u82e5\u5e72\u4ee3\u7801\nconst kernel = new Kernel({\n    appPath,\n    presets: [path.resolve(__dirname, &quot;.&quot;, &quot;presets&quot;, &quot;index.js&quot;)],\n    config,\n    plugins: [],\n});\nkernel.optsPlugins ||= [];<\/code><\/pre>\n<p>\u63a5\u7740\u6211\u4eec\u6765\u770b <code>Kernel<\/code> \u7c7b\uff0c <code>Kernel<\/code> \u7c7b\u7ee7\u627f\u81ea <code>Nodejs<\/code> \u7684\u4e8b\u4ef6\u6a21\u5757<code>EventEmitter<\/code>\u3002<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\nexport default class Kernel extends EventEmitter {\n    constructor(options: IKernelOptions) {\n        super();\n        this.debugger =\n            process.env.DEBUG === &quot;Taro:Kernel&quot;\n                ? helper.createDebug(&quot;Taro:Kernel&quot;)\n                : function () {};\n        \/\/ taro \u9879\u76ee\u8def\u5f84\n        this.appPath = options.appPath || process.cwd();\n        \/\/ \u9884\u8bbe\u63d2\u4ef6\u96c6\u5408\n        this.optsPresets = options.presets;\n        \/\/ \u63d2\u4ef6\n        this.optsPlugins = options.plugins;\n        \/\/ \u914d\u7f6e\n        this.config = options.config;\n        \/\/ \u94a9\u5b50\uff0cMap \u5b58\u50a8\n        this.hooks = new Map();\n        \/\/ \u5b58\u50a8\u65b9\u6cd5\n        this.methods = new Map();\n        \/\/ \u5b58\u50a8\u547d\u4ee4\n        this.commands = new Map();\n        \/\/ \u5b58\u50a8\u5e73\u53f0\n        this.platforms = new Map();\n        this.initHelper();\n        this.initConfig();\n        this.initPaths();\n        this.initRunnerUtils();\n    }\n}<\/code><\/pre>\n<pre><code class=\"ts\">\/\/ packages\/taro-helper\/src\/index.ts\nexport const createDebug = (id: string) =&gt; require(&quot;debug&quot;)(id);<\/code><\/pre>\n<p><code>this.debugger<\/code> \u5f53\u6ca1\u6709\u914d\u7f6e <code>DEBUG<\/code> \u73af\u5883\u53d8\u91cf\u65f6\uff0c\u5219 <code>debugger<\/code> \u662f\u7a7a\u51fd\u6570\u3002\u914d\u7f6e\u4e86 <code>process.env.DEBUG === &quot;Taro:Kernel&quot;<\/code> \u4e3a\u5219\u8c03\u7528\u7684 <code>npm<\/code> \u5305 <a href=\"https:\/\/link.segmentfault.com\/?enc=gM6ml6yP20gafTLZMllHjw%3D%3D.%2Bq8CM%2BlU21BqarjcCfneCJdQAwSdp%2FMz8FYGzs0YW3mE7uv2wsCdMxqyPaWtrOY7\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">debug<\/a>\u3002<\/p>\n<blockquote><p>\u4e00\u4e2a\u4eff\u7167 <code>Node.js<\/code> \u6838\u5fc3\u8c03\u8bd5\u6280\u672f\u7684\u5fae\u578b <code>JavaScript<\/code> \u8c03\u8bd5\u5b9e\u7528\u7a0b\u5e8f\u3002\u9002\u7528\u4e8e <code>Node.js<\/code> \u548c <code>Web<\/code> \u6d4f\u89c8\u5668\u3002<\/p><\/blockquote>\n<p>\u6211\u4eec\u63a5\u7740\u770b\u6784\u9020\u5668\u51fd\u6570\u91cc\u8c03\u7528\u7684\u51e0\u4e2a\u521d\u59cb\u5316\u51fd\u6570\uff0c\u57fa\u672c\u90fd\u662f\u987e\u540d\u77e5\u4e49\u3002<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\ninitConfig () {\n    this.initialConfig = this.config.initialConfig\n    this.initialGlobalConfig = this.config.initialGlobalConfig\n    this.debugger('initConfig', this.initialConfig)\n}\n\ninitHelper () {\n    this.helper = helper\n    this.debugger('initHelper')\n}\n\ninitRunnerUtils () {\n    this.runnerUtils = runnerUtils\n    this.debugger('initRunnerUtils')\n}<\/code><\/pre>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\ninitPaths () {\n    this.paths = {\n        appPath: this.appPath,\n        nodeModulesPath: helper.recursiveFindNodeModules(path.join(this.appPath, helper.NODE_MODULES))\n    } as IPaths\n    if (this.config.isInitSuccess) {\n        Object.assign(this.paths, {\n        configPath: this.config.configPath,\n        sourcePath: path.join(this.appPath, this.initialConfig.sourceRoot as string),\n        outputPath: path.resolve(this.appPath, this.initialConfig.outputRoot as string)\n        })\n    }\n    this.debugger(`initPaths:${JSON.stringify(this.paths, null, 2)}`)\n}<\/code><\/pre>\n<p>\u521d\u59cb\u5316\u540e\u7684\u53c2\u6570\uff0c\u5982 <a href=\"https:\/\/link.segmentfault.com\/?enc=X0DjPNvOk6N6oMzFAV8qjQ%3D%3D.s5iUhDk%2BOgIVS2plDSddmuM49lw%2F2CfnaRjPLQ4wT32D3amK%2BPUPFXaxPJSYs1T4mrGDCcpMcA1H8tYQ%2BxwYog%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><code>taro<\/code> \u5b98\u65b9\u6587\u6863 &#8211; \u7f16\u5199\u63d2\u4ef6 api<\/a>\u4e2d\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912586\" alt=\"initConfig.png\" title=\"initConfig.png\" loading=\"lazy\"><\/p>\n<h3>7.1 cli kernel.optsPlugins \u7b49<\/h3>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912587\" alt=\"parseArgs-3.png\" title=\"parseArgs-3.png\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u63a5\u4e0b\u6765\u770b\uff0c<code>customCommand<\/code> \u51fd\u6570\u3002<\/p>\n<h3>7.2 cli customCommand \u51fd\u6570<\/h3>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912588\" alt=\"parseArgs-4.png\" title=\"parseArgs-4.png\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u6700\u7ec8\u8c03\u7528\u7684\u662f <code>customCommand<\/code> \u51fd\u6570<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-cli\/src\/commands\/customCommand.ts\nimport { Kernel } from &quot;@tarojs\/service&quot;;\n\nexport default function customCommand(\n    command: string,\n    kernel: Kernel,\n    args: { _: string[]; [key: string]: any }\n) {\n    if (typeof command === &quot;string&quot;) {\n        const options: any = {};\n        const excludeKeys = [\n            &quot;_&quot;,\n            &quot;version&quot;,\n            &quot;v&quot;,\n            &quot;help&quot;,\n            &quot;h&quot;,\n            &quot;disable-global-config&quot;,\n        ];\n        Object.keys(args).forEach((key) =&gt; {\n            if (!excludeKeys.includes(key)) {\n                options[key] = args[key];\n            }\n        });\n\n        kernel.run({\n            name: command,\n            opts: {\n                _: args._,\n                options,\n                isHelp: args.h,\n            },\n        });\n    }\n}<\/code><\/pre>\n<p><code>customCommand<\/code> \u51fd\u6570\u79fb\u9664\u4e00\u4e9b <code>run<\/code> \u51fd\u6570\u4e0d\u9700\u8981\u7684\u53c2\u6570\uff0c\u6700\u7ec8\u8c03\u7528\u7684\u662f <code>kernal.run<\/code> \u51fd\u6570\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u6765\u770b <code>kernal.run<\/code> \u51fd\u6570\u7684\u5177\u4f53\u5b9e\u73b0\u3002<\/p>\n<h2>8. kernal.run \u6267\u884c\u51fd\u6570<\/h2>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\nasync run (args: string | { name: string, opts?: any }) {\n    \/\/ \u4e0a\u534a\u90e8\u5206\n    let name\n    let opts\n    if (typeof args === 'string') {\n      name = args\n    } else {\n      name = args.name\n      opts = args.opts\n    }\n    this.debugger('command:run')\n    this.debugger(`command:run:name:${name}`)\n    this.debugger('command:runOpts')\n    this.debugger(`command:runOpts:${JSON.stringify(opts, null, 2)}`)\n    this.setRunOpts(opts)\n    \/\/ \u62c6\u89e3\u4e0b\u534a\u90e8\u5206\n}<\/code><\/pre>\n<p><code>run<\/code> \u51fd\u6570\u4e2d\uff0c\u5f00\u5934\u4e3b\u8981\u662f\u517c\u5bb9\u4e24\u79cd\u53c2\u6570\u4f20\u9012\u3002<\/p>\n<h2>9. kernal.setRunOpts<\/h2>\n<p>\u628a\u53c2\u6570\u5148\u5b58\u8d77\u6765\u3002\u4fbf\u4e8e\u7ed9\u63d2\u4ef6\u4f7f\u7528\u3002<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\nsetRunOpts (opts) {\n    this.runOpts = opts\n}<\/code><\/pre>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=wgvzsSXK7Xnj4oB0jqTliQ%3D%3D.6muIeUGd30wAfnniGOOy%2FF2V0x7%2BQFrv%2BTbHAd7LmatCza%2FGU669flfkLl20zVnABrTQgRmhRhwqGNj9WtGsIA%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Taro \u6587\u6863 &#8211; \u7f16\u5199\u63d2\u4ef6 &#8211; ctx.runOpts<\/a><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912589\" alt=\"ctx.runOpts.png\" title=\"ctx.runOpts.png\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u63a5\u7740\u6765\u770b\uff0c<code>run<\/code> \u51fd\u6570\u7684\u4e0b\u534a\u90e8\u5206\u3002<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\nasync run (args: string | { name: string, opts?: any }) {\n    \/\/ \u4e0b\u534a\u90e8\u5206\n    this.debugger('initPresetsAndPlugins')\n    this.initPresetsAndPlugins()\n\n    await this.applyPlugins('onReady')\n\n    this.debugger('command:onStart')\n    await this.applyPlugins('onStart')\n\n    if (!this.commands.has(name)) {\n      throw new Error(`${name} \u547d\u4ee4\u4e0d\u5b58\u5728`)\n    }\n\n    if (opts?.isHelp) {\n      return this.runHelp(name)\n    }\n\n    if (opts?.options?.platform) {\n      opts.config = this.runWithPlatform(opts.options.platform)\n      await this.applyPlugins({\n        name: 'modifyRunnerOpts',\n        opts: {\n          opts: opts?.config\n        }\n      })\n    }\n\n    await this.applyPlugins({\n      name,\n      opts\n    })\n}<\/code><\/pre>\n<p><code>run<\/code> \u51fd\u6570\u4e0b\u534a\u90e8\u5206\u4e3b\u8981\u6709\u4e09\u4e2a\u51fd\u6570\uff1a<\/p>\n<pre><code class=\"bash\">1. this.initPresetsAndPlugins() \u51fd\u6570\uff0c\u987e\u540d\u77e5\u4e49\u3002\u521d\u59cb\u5316\u9884\u8bbe\u63d2\u4ef6\u96c6\u5408\u548c\u63d2\u4ef6\u3002\n2. this.applyPlugins() \u6267\u884c\u63d2\u4ef6\n3. this.runHelp() \u6267\u884c \u547d\u4ee4\u884c\u7684\u5e2e\u52a9\u4fe1\u606f\uff0c\u4f8b\uff1ataro init --help<\/code><\/pre>\n<p>\u6211\u4eec\u5206\u5f00\u53d9\u8ff0<\/p>\n<blockquote><p><code>this.initPresetsAndPlugins()<\/code>\u51fd\u6570\uff0c\u56e0\u4e3a\u6b64\u5904\u6d89\u53ca\u5230\u7684\u4ee3\u7801\u76f8\u5bf9\u8f83\u591a\uff0c\u5bb9\u6613\u5f71\u54cd\u4e3b\u7ebf\u6d41\u7a0b\u3002\u6240\u4ee5\u672c\u6587\u5728\u6b64\u5148\u4e0d\u5c55\u5f00\u6df1\u5165\u5b66\u4e60\u4e86\u3002\u5c06\u653e\u5728\u4e0b\u4e00\u7bc7\u6587\u7ae0\u4e2d\u8be6\u7ec6\u8bb2\u8ff0\u3002<\/p><\/blockquote>\n<p>\u6267\u884c <code>this.initPresetsAndPlugins()<\/code> \u51fd\u6570\u4e4b\u540e\u3002\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u5728\u8c03\u8bd5\u65f6\u628a <code>kernal<\/code> \u5b9e\u4f8b\u5bf9\u8c61\u6253\u5370\u51fa\u6765\u3002<\/p>\n<p>\u6211\u4eec\u6765\u770b\u63d2\u4ef6\u7684\u6ce8\u518c\u3002<\/p>\n<h2>10. kernal ctx.registerCommand \u6ce8\u518c init \u547d\u4ee4<\/h2>\n<pre><code class=\"ts\">\/\/ packages\/taro-cli\/src\/presets\/commands\/init.ts\nimport type { IPluginContext } from &quot;@tarojs\/service&quot;;\n\nexport default (ctx: IPluginContext) =&gt; {\n    ctx.registerCommand({\n        name: &quot;init&quot;,\n        optionsMap: {\n            &quot;--name [name]&quot;: &quot;\u9879\u76ee\u540d\u79f0&quot;,\n            &quot;--description [description]&quot;: &quot;\u9879\u76ee\u4ecb\u7ecd&quot;,\n            &quot;--typescript&quot;: &quot;\u4f7f\u7528TypeScript&quot;,\n            &quot;--npm [npm]&quot;: &quot;\u5305\u7ba1\u7406\u5de5\u5177&quot;,\n            &quot;--template-source [templateSource]&quot;: &quot;\u9879\u76ee\u6a21\u677f\u6e90&quot;,\n            &quot;--clone [clone]&quot;: &quot;\u62c9\u53d6\u8fdc\u7a0b\u6a21\u677f\u65f6\u4f7f\u7528git clone&quot;,\n            &quot;--template [template]&quot;: &quot;\u9879\u76ee\u6a21\u677f&quot;,\n            &quot;--css [css]&quot;: &quot;CSS\u9884\u5904\u7406\u5668(sass\/less\/stylus\/none)&quot;,\n            &quot;-h, --help&quot;: &quot;output usage information&quot;,\n        },\n        async fn(opts) {\n            \/\/ init project\n            const { appPath } = ctx.paths;\n            const { options } = opts;\n            const {\n                \/\/ \u7701\u7565\u82e5\u5e72\u53c2\u6570\n            } = options;\n            const Project = require(&quot;..\/..\/create\/project&quot;).default;\n            console.log(Project, &quot;Project&quot;);\n            const project = new Project({\n                projectName,\n                projectDir: appPath,\n                \/\/ \u7701\u7565\u82e5\u5e72\u53c2\u6570\n            });\n\n            project.create();\n        },\n    });\n};<\/code><\/pre>\n<p>\u901a\u8fc7 <code>ctx.registerCommand<\/code> \u6ce8\u518c\u4e86\u4e00\u4e2a <code>name<\/code> \u4e3a <code>init<\/code> \u7684\u547d\u4ee4\uff0c\u4f1a\u5b58\u5165\u5230\u5185\u6838 <code>Kernal<\/code> \u5b9e\u4f8b\u5bf9\u8c61\u7684 <code>hooks<\/code> \u5c5e\u6027\u4e2d\uff0c\u5176\u4e2d <code>ctx<\/code> \u5c31\u662f <code>Kernal<\/code> \u7684\u5b9e\u4f8b\u5bf9\u8c61\u3002\u5177\u4f53\u5b9e\u73b0\u662f <code>fn<\/code> \u51fd\u6570\u3002<\/p>\n<h2>11. kernal.applyPlugins \u89e6\u53d1\u63d2\u4ef6<\/h2>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\nasync applyPlugins (args: string | { name: string, initialVal?: any, opts?: any }) {\n    \/\/ \u4e0a\u534a\u90e8\u5206\n    let name\n    let initialVal\n    let opts\n    if (typeof args === 'string') {\n      name = args\n    } else {\n      name = args.name\n      initialVal = args.initialVal\n      opts = args.opts\n    }\n    this.debugger('applyPlugins')\n    this.debugger(`applyPlugins:name:${name}`)\n    this.debugger(`applyPlugins:initialVal:${initialVal}`)\n    this.debugger(`applyPlugins:opts:${opts}`)\n    if (typeof name !== 'string') {\n      throw new Error('\u8c03\u7528\u5931\u8d25\uff0c\u672a\u4f20\u5165\u6b63\u786e\u7684\u540d\u79f0\uff01')\n    }\n    \/\/ \u62c6\u89e3\u5230\u4e0b\u534a\u90e8\u5206\n}<\/code><\/pre>\n<p>\u4e0a\u534a\u90e8\u5206\uff0c\u4e3b\u8981\u662f\u9002\u914d\u4e24\u79cd\u4f20\u53c2\u7684\u65b9\u5f0f\u3002<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\nasync applyPlugins (args: string | { name: string, initialVal?: any, opts?: any }) {\n    \/\/ \u4e0b\u534a\u90e8\u5206\n    const hooks = this.hooks.get(name) || []\n    if (!hooks.length) {\n      return await initialVal\n    }\n    const waterfall = new AsyncSeriesWaterfallHook(['arg'])\n    if (hooks.length) {\n      const resArr: any[] = []\n      for (const hook of hooks) {\n        waterfall.tapPromise({\n          name: hook.plugin!,\n          stage: hook.stage || 0,\n          \/\/ @ts-ignore\n          before: hook.before\n        }, async arg =&gt; {\n          const res = await hook.fn(opts, arg)\n          if (IS_MODIFY_HOOK.test(name) &amp;&amp; IS_EVENT_HOOK.test(name)) {\n            return res\n          }\n          if (IS_ADD_HOOK.test(name)) {\n            resArr.push(res)\n            return resArr\n          }\n          return null\n        })\n      }\n    }\n    return await waterfall.promise(initialVal)\n}<\/code><\/pre>\n<p><code>Taro<\/code> \u7684\u63d2\u4ef6\u67b6\u6784\u57fa\u4e8e <a href=\"https:\/\/link.segmentfault.com\/?enc=zfUX9pr187VCpp0T5vGfQw%3D%3D.SxVdGFJErBb8j5xSKB84Qmbr2YPZoPsyPt%2BFS53eyi9jl60igHuSE33AxlXlghw5\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Tapable<\/a>\u3002<\/p>\n<p>\u8fd9\u91cc\u4f7f\u7528\u4e86\u8fd9\u4e2a\u51fd\u6570\uff1a<code>AsyncSeriesWaterfallHook<\/code>\u3002<\/p>\n<blockquote><p>The hook type is reflected in its class name. E.g., AsyncSeriesWaterfallHook allows asynchronous functions and runs them in series, passing each function\u2019s return value into the next function.<\/p><\/blockquote>\n<p>\u7b80\u8a00\u4e4b\u5c31\u662f\u5f02\u6b65\u6216\u8005\u540c\u6b65\u65b9\u6cd5\u4e32\u8054\u8d77\u6765\uff0c\u4e0a\u4e00\u4e2a\u51fd\u6570\u7684\u7ed3\u679c\u4f5c\u4e3a\u4e0b\u4e00\u4e2a\u51fd\u6570\u7684\u53c2\u6570\u4f9d\u6b21\u6267\u884c\u3002\u4f9d\u6b21\u6267\u884c\u3002<\/p>\n<p>\u8fd9\u65f6\u8ba9\u6211\u60f3\u8d77\u4e00\u53e5\u5c0f\u864e\u961f\u7684\u7231\u7684\u6b4c\u8bcd\u3002<\/p>\n<blockquote><p>\u5594\uff0c\u628a\u4f60\u7684\u5fc3\u6211\u7684\u5fc3\u4e32\u4e00\u4e32\uff0c\u4e32\u4e00\u682a\u5e78\u8fd0\u8349\u4e32\u4e00\u4e2a\u540c\u5fc3\u5706&#8230;<\/p><\/blockquote>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\u7528\u6237\u5199\u7684\u63d2\u4ef6\u4e2d\u6709\u591a\u4e2a\u94a9\u5b50\u51fd\u6570\u3002\u6bd4\u5982 <code>onReday<\/code> \u7b49\u53ef\u4ee5\u6709\u591a\u4e2a\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912590\" alt=\"\u63d2\u4ef6\u65b9\u6cd5.png\" title=\"\u63d2\u4ef6\u65b9\u6cd5.png\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912591\" alt=\"\u63d2\u4ef6 hooks\" title=\"\u63d2\u4ef6 hooks\" loading=\"lazy\"><\/p>\n<p><code>applyPlugins<\/code> \u6839\u636e\u6267\u884c\u7684\u547d\u4ee4 <code>init<\/code> \u4ece <code>hooks<\/code> \u53d6\u51fa\uff0c\u4e32\u8d77\u6765\uff0c\u7136\u540e\u4f9d\u6b21\u6267\u884c\u63d2\u4ef6\u7684 <code>fn<\/code> \u65b9\u6cd5\u3002<\/p>\n<p>\u6211\u4eec\u987a\u4fbf\u6765\u770b\u4e00\u4e0b\uff0c<code>kernal.runHelp<\/code> \u7684\u5b9e\u73b0\u3002<\/p>\n<h2>12. kernal.runHelp \u547d\u4ee4\u5e2e\u52a9\u4fe1\u606f<\/h2>\n<p>\u5728 <code>kernal.run<\/code> \u51fd\u6570\u4e2d\uff0c\u6709\u4e00\u4e2a <code>opts.isHelp<\/code> \u7684\u5224\u65ad\uff0c\u6267\u884c <code>kernal.runHelp<\/code> \u65b9\u6cd5\u3002<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\n\/\/ run \u51fd\u6570\nif (opts?.isHelp) {\n    return this.runHelp(name);\n}<\/code><\/pre>\n<p>\u4ee5 <code>taro init --help<\/code> \u4e3a\u4f8b\u3002\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912592\" alt=\"\u547d\u4ee4\u884c help.png\" title=\"\u547d\u4ee4\u884c help.png\" loading=\"lazy\"><\/p>\n<p>\u5177\u4f53\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"ts\">\/\/ packages\/taro-service\/src\/Kernel.ts\nrunHelp (name: string) {\n    const command = this.commands.get(name)\n    const defaultOptionsMap = new Map()\n    defaultOptionsMap.set('-h, --help', 'output usage information')\n    let customOptionsMap = new Map()\n    if (command?.optionsMap) {\n      customOptionsMap = new Map(Object.entries(command?.optionsMap))\n    }\n    const optionsMap = new Map([...customOptionsMap, ...defaultOptionsMap])\n    printHelpLog(name, optionsMap, command?.synopsisList ? new Set(command?.synopsisList) : new Set())\n}<\/code><\/pre>\n<p>\u6839\u636e <code>name<\/code> \u4ece <code>this.commands<\/code> <code>Map<\/code> \u4e2d\u83b7\u53d6\u5230\u547d\u4ee4\uff0c\u8f93\u51fa\u5bf9\u5e94\u7684 <code>optionsMap<\/code> \u548c <code>synopsisList<\/code>\u3002<\/p>\n<h2>13. \u603b\u7ed3<\/h2>\n<p>\u6211\u4eec\u4e3b\u8981\u5b66\u4e86<\/p>\n<ol>\n<li>\u5b66\u4f1a\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u8c03\u8bd5 taro \u6e90\u7801<\/li>\n<li>\u5b66\u4f1a\u5165\u53e3 taro-cli \u5177\u4f53\u5b9e\u73b0\u65b9\u5f0f<\/li>\n<li>\u5b66\u4f1a cli init \u547d\u4ee4\u5b9e\u73b0\u539f\u7406\uff0c\u8bfb\u53d6\u7528\u6237\u9879\u76ee\u914d\u7f6e\u6587\u4ef6\u548c\u7528\u6237\u5168\u5c40\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u5b66\u4f1a taro-service kernal \uff08\u5185\u6838\uff09\u89e3\u8026\u5b9e\u73b0<\/li>\n<li>\u521d\u6b65\u5b66\u4f1a taro \u63d2\u4ef6\u67b6\u6784\uff0c\u5b66\u4f1a\u4e86\u5982\u4f55\u7f16\u5199\u4e00\u4e2a taro \u63d2\u4ef6<\/li>\n<\/ol>\n<p>taro-cli \u4f7f\u7528\u4e86<a href=\"https:\/\/link.segmentfault.com\/?enc=fEts%2BMI1moiUE%2F0s%2FkRAgQ%3D%3D.1kCgKuutMoA9MDt4xSB%2FOwpJ7OiLgRyrU1cxny5Npa1fIv61FzCf2dkrN8O3vgn2\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">minimist<\/a>\uff0c\u547d\u4ee4\u884c\u53c2\u6570\u89e3\u6790\u5de5\u5177\u3002<\/p>\n<p>\u4f7f\u7528\u4e86 <a href=\"https:\/\/link.segmentfault.com\/?enc=%2FboNFgGE1q3i1%2BbDGVRr4A%3D%3D.sz0jRjO3GYXz7KhtxG9g3xRAt489PGZlHXoCRpIQfUDhOwXDNzg4hWrtV1N%2BhlKy\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><code>@swc\/register<\/code><\/a> \u8bfb\u53d6 config\/index .js \u6216\u8005 .ts \u914d\u7f6e\u6587\u4ef6\u548c\u7528 fs-extra <a href=\"https:\/\/link.segmentfault.com\/?enc=67aJisnK9wP6lFYqaBVDWA%3D%3D.nKTmXuOXc%2F9mCZcrvVZCDef9IZS4RUpaa80lAnyAQzlo745iYaXnemDATIs%2BxtCTIRzeWu7x3xzDh%2FXn5O6lOuO0GQFZfx67sKSjBhXT6V8%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">fs.readJSONSync<\/a> \u5168\u5c40\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>CLI \u90e8\u5206\u6709\u5404\u79cd\u9884\u8bbe\u63d2\u4ef6\u96c6\u5408 <code>presets<\/code>\u3002<\/p>\n<p>taro \u5355\u72ec\u62bd\u79bb\u4e86\u4e00\u4e2a <code>tarojs\/service<\/code> (<code>packages\/taro-service<\/code>) \u6a21\u5757\uff0c\u5305\u542b <code>Kernal<\/code> \u5185\u6838\u3001<code>Config<\/code>\u3001<code>Plugin<\/code> \u7b49\u3002<\/p>\n<p>taro \u7684\u57fa\u4e8e <a href=\"https:\/\/link.segmentfault.com\/?enc=1jXx8dr8S0D7MUFHRRiNEw%3D%3D.RC0TCIxoLoZLXQF260uQIBZ7lZG62PmR0XDnM5EZOaJfN1Qn%2BJPSJAS0Th%2Br8Pqc\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Tapable<\/a> \u7684 <code>AsyncSeriesWaterfallHook<\/code> (\u628a\u51fd\u6570\u7ec4\u5408\u5728\u4e00\u8d77\u4e32\u884c) \u5b9e\u73b0\u7684\u63d2\u4ef6\u673a\u5236\u3002\u5404\u4e2a\u63d2\u4ef6\u53ef\u4ee5\u5206\u5f00\u5728\u5404\u4e2a\u5730\u65b9\uff0c\u8fbe\u5230\u89e3\u8026\u6548\u679c\u3002\u975e\u5e38\u503c\u5f97\u6211\u4eec\u5b66\u4e60\u3002<\/p>\n<p>\u7b80\u5355\u505a\u4e86\u4e00\u4e2a\u672c\u6587\u7684\u603b\u7ed3\u56fe\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000045912593\" alt=\"\u7b80\u5355\u603b\u7ed3\" title=\"\u7b80\u5355\u603b\u7ed3\" loading=\"lazy\"><\/p>\n<hr>\n<p><strong>\u5982\u679c\u770b\u5b8c\u6709\u6536\u83b7\uff0c\u6b22\u8fce\u70b9\u8d5e\u3001\u8bc4\u8bba\u3001\u5206\u4eab\u3001\u6536\u85cf\u652f\u6301\u3002\u4f60\u7684\u652f\u6301\u548c\u80af\u5b9a\uff0c\u662f\u6211\u5199\u4f5c\u7684\u52a8\u529b<\/strong>\u3002<\/p>\n<p>\u4f5c\u8005\uff1a\u5e38\u4ee5<strong>\u82e5\u5ddd<\/strong>\u4e3a\u540d\u6df7\u8ff9\u4e8e\u6c5f\u6e56\u3002\u6240\u77e5\u751a\u5c11\uff0c\u552f\u5584\u5b66\u3002<a href=\"https:\/\/link.segmentfault.com\/?enc=dTnT%2BHgfQq%2FA9FVtipn5ww%3D%3D.QbeFiQiD6qb5lBFXTbA7ewjkEYw%2F2qjPPEJeGJcz6OE%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u82e5\u5ddd\u7684\u535a\u5ba2<\/a>\uff0c<a href=\"https:\/\/link.segmentfault.com\/?enc=pWFNLGfoPxQmbE%2F3hWvTKw%3D%3D.Xl%2FTWn22%2FVMc0sOmYvTuvo10K7FDdZPzItIyDqTHb6hUpTECLeHcTyn2o0vH1XOz\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">github blog<\/a>\uff0c\u53ef\u4ee5\u70b9\u4e2a <code>star<\/code> \u9f13\u52b1\u4e0b\u6301\u7eed\u521b\u4f5c\u3002<\/p>\n<p>\u6700\u540e\u53ef\u4ee5\u6301\u7eed\u5173\u6ce8\u6211<a href=\"https:\/\/link.segmentfault.com\/?enc=MNhSZvyVGOhG%2FEi7M9rpXg%3D%3D.cwLaE30bAsnpF%2FHDPMUVvPCXFdb9fPlY%2FcFuDqeLzUeifEWjp1MzsvGBQvx1qVBH\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@\u82e5\u5ddd<\/a>\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684<a href=\"https:\/\/link.segmentfault.com\/?enc=n7M6QEqWzrJXjTSy9s4Jgg%3D%3D.I4CxLYEoVfYMsNN%2BynlIpr%2B%2FqhdQ4oPj6FUSkfONgawc9w%2BVzz6Xxl7vA4c48avgMd4%2FcFwdj29xoJtakWxw8g%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u516c\u4f17\u53f7\uff1a\u82e5\u5ddd\u89c6\u91ce<\/a>\u3002\u6211\u503e\u529b\u6301\u7eed\u7ec4\u7ec7\u4e86 3 \u5e74\u591a<a href=\"https:\/\/link.segmentfault.com\/?enc=YX5fi5sm8Nr6GxUPX8jiEQ%3D%3D.jDs%2FI5QYcEhpm6qydQNoq%2FaZlMs8BByVMWsuA4fjGtsnj9DESQhjb%2BTV9vaHoKRT\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u6bcf\u5468\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60 200 \u884c\u5de6\u53f3\u7684\u6e90\u7801\u5171\u8bfb\u6d3b\u52a8<\/a>\uff0c\u611f\u5174\u8da3\u7684\u53ef\u4ee5<a href=\"https:\/\/link.segmentfault.com\/?enc=bnbqArsqe00j8e%2FSGtSlvw%3D%3D.1PQ4MbzS7aRTyGsz8cMTB1aZ7dKEHGBFNarDOkvhW%2Fm8f%2FNCcSaacmbWBA7fZ%2B1S\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u70b9\u6b64\u626b\u7801\u52a0\u6211\u5fae\u4fe1 <code>ruochuan02<\/code> \u53c2\u4e0e<\/a>\u3002\u53e6\u5916\uff0c\u60f3\u5b66\u6e90\u7801\uff0c\u6781\u529b\u63a8\u8350\u5173\u6ce8\u6211\u5199\u7684\u4e13\u680f<a href=\"https:\/\/link.segmentfault.com\/?enc=nem6357MhtF5lR76zjygvg%3D%3D.4LaGNeSwb%2FuYatNJXDxNBv9ualdKXtW%2Blu0Re1TcT6h6TmuiKYNxIHjyVunMWVYl\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u300a\u5b66\u4e60\u6e90\u7801\u6574\u4f53\u67b6\u6784\u7cfb\u5217\u300b<\/a>\uff0c\u76ee\u524d\u662f\u6398\u91d1\u5173\u6ce8\u4eba\u6570\uff086k+\u4eba\uff09\u7b2c\u4e00\u7684\u4e13\u680f\uff0c\u5199\u6709\u51e0\u5341\u7bc7\u6e90\u7801\u6587\u7ae0\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000045912572\">https:\/\/segmentfault.com\/a\/1190000045912572<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u524d\u8a00 \u5927\u5bb6\u597d\uff0c\u6211\u662f\u82e5\u5ddd\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u516c\u4f17\u53f7\uff1a\u82e5\u5ddd\u89c6\u91ce\u3002\u6211\u503e\u529b\u6301\u7eed\u7ec4\u7ec7\u4e86 3 \u5e74\u591a\u6bcf\u5468\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60 200 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020591","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020591"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020591\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}