mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-23 23:58:12 -05:00
1 line
No EOL
13 KiB
JavaScript
1 line
No EOL
13 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[703],{1422:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>t,contentTitle:()=>i,default:()=>p,frontMatter:()=>c,metadata:()=>l,toc:()=>d});var r=s(678),o=s(4738);const c={title:"\u5165\u95e8\u6307\u5357"},i=void 0,l={id:"pages/guide/getting_started",title:"\u5165\u95e8\u6307\u5357",description:"\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u91cd\u6e29\u5feb\u901f\u6f14\u793a\u7684\u6b65\u9aa4\uff0c\u4f46\u8fd9\u6b21\u6211\u4eec\u5c06\u66f4\u8be6\u7ec6\u5730\u63a2\u8ba8 Sparo \u7684\u5de5\u4f5c\u6d41\u7a0b\u3002",source:"@site/i18n/zh-cn/docusaurus-plugin-content-docs/current/pages/guide/getting_started.md",sourceDirName:"pages/guide",slug:"/pages/guide/getting_started",permalink:"/sparo/zh-cn/pages/guide/getting_started",draft:!1,unlisted:!1,editUrl:"https://github.com/tiktok/sparo/tree/main/apps/website/docs/pages/guide/getting_started.md",tags:[],version:"current",frontMatter:{title:"\u5165\u95e8\u6307\u5357"},sidebar:"docsSidebar",previous:{title:"\u6982\u8ff0",permalink:"/sparo/zh-cn/"},next:{title:"Sparo \u914d\u7f6e\u6587\u4ef6",permalink:"/sparo/zh-cn/pages/guide/sparo_profiles"}},t={},d=[{value:"\u7b2c 1 \u6b65\uff1a\u5347\u7ea7 Git",id:"\u7b2c-1-\u6b65\u5347\u7ea7-git",level:2},{value:"\u7b2c 2 \u6b65\uff1a\u514b\u9686\u60a8\u7684 Rush monorepo",id:"\u7b2c-2-\u6b65\u514b\u9686\u60a8\u7684-rush-monorepo",level:2},{value:"\u7b2c 3 \u6b65\uff1a\u521b\u5efa\u7a00\u758f\u914d\u7f6e\u6587\u4ef6",id:"\u7b2c-3-\u6b65\u521b\u5efa\u7a00\u758f\u914d\u7f6e\u6587\u4ef6",level:2},{value:"\u7b2c 4 \u6b65\uff1a\u68c0\u51fa\u60a8\u7684 Sparo \u914d\u7f6e\u6587\u4ef6",id:"\u7b2c-4-\u6b65\u68c0\u51fa\u60a8\u7684-sparo-\u914d\u7f6e\u6587\u4ef6",level:2},{value:"\u7b2c 5 \u6b65\uff1a\u4f7f\u7528\u955c\u50cf\u5b50\u547d\u4ee4",id:"\u7b2c-5-\u6b65\u4f7f\u7528\u955c\u50cf\u5b50\u547d\u4ee4",level:2}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.p,{children:["\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u91cd\u6e29",(0,r.jsx)(n.a,{href:"/sparo/zh-cn/#%E5%BF%AB%E9%80%9F%E6%BC%94%E7%A4%BA",children:"\u5feb\u901f\u6f14\u793a"}),"\u7684\u6b65\u9aa4\uff0c\u4f46\u8fd9\u6b21\u6211\u4eec\u5c06\u66f4\u8be6\u7ec6\u5730\u63a2\u8ba8 Sparo \u7684\u5de5\u4f5c\u6d41\u7a0b\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u7b2c-1-\u6b65\u5347\u7ea7-git",children:"\u7b2c 1 \u6b65\uff1a\u5347\u7ea7 Git"}),"\n",(0,r.jsx)(n.p,{children:"\u8bf7\u8bb0\u4f4f\u5c06 Git \u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\uff01\u8bb8\u591a Git \u4f18\u5316\u529f\u80fd\u76f8\u5bf9\u8f83\u65b0\uff0c\u5728\u65e7\u7248\u672c\u7684\u8f6f\u4ef6\u4e2d\u4e0d\u53ef\u7528\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u5bf9\u4e8e macOS\uff0c\u6211\u4eec\u63a8\u8350\u4f7f\u7528 ",(0,r.jsx)(n.a,{href:"https://git-scm.com/download/mac",children:"brew install git"}),"\u3002\u5bf9\u4e8e\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff0c\u8bf7\u53c2\u9605 ",(0,r.jsx)(n.a,{href:"https://git-scm.com/book/en/v2/Getting-Started-Installing-Git",children:"Git \u6587\u6863"})," \u4e86\u89e3\u5b89\u88c5\u8bf4\u660e\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u7b2c-2-\u6b65\u514b\u9686\u60a8\u7684-rush-monorepo",children:"\u7b2c 2 \u6b65\uff1a\u514b\u9686\u60a8\u7684 Rush monorepo"}),"\n",(0,r.jsxs)(n.p,{children:["\u514b\u9686\u60a8\u7684 ",(0,r.jsx)(n.a,{href:"https://rushjs.io/",children:"RushJS"})," monorepo\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-shell",children:"# \u4ece NPM \u5168\u5c40\u5b89\u88c5 Sparo CLI\nnpm install -g sparo\n\n# \u4f7f\u7528 Sparo \u514b\u9686\u4f60\u7684\u4ed3\u5e93\nsparo clone https://github.com/my-company/my-monorepo.git\n\ncd my-monorepo\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\ud83d\udc49 ",(0,r.jsx)(n.em,{children:"\u5bf9\u4e8e\u771f\u5b9e\u4e16\u754c\u7684\u6f14\u793a\uff0c\u5c1d\u8bd5\u514b\u9686\u8fd9\u4e2a\u4ed3\u5e93\uff1a"}),"\n",(0,r.jsx)(n.a,{href:"https://github.com/Azure/azure-sdk-for-js.git",children:"https://github.com/Azure/azure-sdk-for-js.git"})]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:'"sparo clone" \u7684\u4f18\u5316\u65b9\u5f0f\uff1a'})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["\u4ec5\u83b7\u53d6\u9ed8\u8ba4\u5206\u652f\uff08\u901a\u5e38\u662f ",(0,r.jsx)(n.code,{children:"main"})," \u5206\u652f\uff09\u3002\u8fd9\u663e\u8457\u51cf\u5c11\u4e86\u4e0b\u8f7d\u5927\u5c0f\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["\u542f\u7528\u4e86 Git \u65e0 Blob \u7684",(0,r.jsx)(n.a,{href:"/sparo/zh-cn/pages/reference/git_optimization",children:"\u90e8\u5206\u514b\u9686"}),"\u4ee5\u5ef6\u8fdf\u4e0b\u8f7d\u6587\u4ef6\u5185\u5bb9\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["\u4f7f\u7528 Git ",(0,r.jsx)(n.a,{href:"https://git-scm.com/docs/git-sparse-checkout",children:"\u7a00\u758f\u68c0\u51fa"})," \u4ec5\u514b\u9686",(0,r.jsx)(n.a,{href:"/sparo/zh-cn/pages/reference/skeleton_folders",children:'"\u9aa8\u67b6"\u6587\u4ef6\u5939'}),"\uff0c\u5176\u4e2d\u5305\u62ec\u6240\u6709\u5de5\u4f5c\u533a\u7684 ",(0,r.jsx)(n.strong,{children:"package.json"})," \u6587\u4ef6\uff0c\u4f46\u4e0d\u5305\u62ec\u6e90\u4ee3\u7801\u5b50\u6587\u4ef6\u5939\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["\u7a00\u758f\u68c0\u51fa\u5df2\u914d\u7f6e\u4e3a\u66f4\u9ad8\u6548\u7684",(0,r.jsx)(n.a,{href:"https://git-scm.com/docs/git-sparse-checkout#_internalsnon_cone_problems",children:'"\u9525\u5f62\u6a21\u5f0f"'}),"\u3002"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"\u63d0\u793a:"})," \u5982\u679c\u60f3\u67e5\u770b\u6267\u884c\u7684\u64cd\u4f5c\u548c Git \u64cd\u4f5c\uff0c\u4f7f\u7528 ",(0,r.jsx)(n.code,{children:"sparo --debug clone"})," \u4ee3\u66ff ",(0,r.jsx)(n.code,{children:"sparo clone"}),"\u3002"]}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:"\ud83d\udca1 \u76ee\u524d\u652f\u6301 PNPM \u548c Yarn \u5de5\u4f5c\u533a\u7684\u529f\u80fd\u8ba1\u5212\u4e2d\uff0c\u4f46\u5c1a\u672a\u5b9e\u73b0\u3002\u6b22\u8fce\u8d21\u732e\uff01"}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u7b2c-3-\u6b65\u521b\u5efa\u7a00\u758f\u914d\u7f6e\u6587\u4ef6",children:"\u7b2c 3 \u6b65\uff1a\u521b\u5efa\u7a00\u758f\u914d\u7f6e\u6587\u4ef6"}),"\n",(0,r.jsxs)(n.p,{children:["\u5b9a\u4e49\u4e00\u4e2a ",(0,r.jsx)(n.a,{href:"/sparo/zh-cn/pages/configs/profile_json",children:"Sparo \u914d\u7f6e\u6587\u4ef6"}),"\uff0c\u63cf\u8ff0 Git \u7a00\u758f\u68c0\u51fa\u7684\u4ed3\u5e93\u6587\u4ef6\u5939\u5b50\u96c6\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-shell",children:"# \u5c06\u6a21\u677f\u5199\u5165 common/sparo-profiles/my-team.json\nsparo init-profile --profile my-team\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u7f16\u8f91\u521b\u5efa\u7684 ",(0,r.jsx)(n.strong,{children:"my-team.json"})," \u6587\u4ef6\u5e76\u6dfb\u52a0\u4e00\u4e2a\u9009\u62e9\u5668\u3002\u4f8b\u5982\uff1a"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"common/sparo-profiles/my-team.json"})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-json",children:'{\n "selections": [\n {\n "selector": "--to",\n "argument": "my-rush-project"\n }\n ]\n}\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\ud83d\udc49 ",(0,r.jsxs)(n.em,{children:["\u5982\u679c\u60a8\u6b63\u5728\u6f14\u793a ",(0,r.jsx)(n.strong,{children:"azure-sdk-for-js"}),"\uff0c\u8bf7\u5c06 ",(0,r.jsx)(n.code,{children:"my-rush-project"})," \u66ff\u6362\u4e3a ",(0,r.jsx)(n.code,{children:"@azure/arm-commerce"}),"\u3002"]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c",(0,r.jsx)(n.code,{children:"--to"})," ",(0,r.jsx)(n.a,{href:"https://rushjs.io/pages/developer/selecting_subsets/#--to",children:"\u9879\u76ee\u9009\u62e9\u5668"})," \u6307\u793a Sparo \u68c0\u51fa\u5de5\u4f5c\u533a\u4e2d\u6784\u5efa ",(0,r.jsx)(n.code,{children:"my-rush-project"})," \u6240\u9700\u7684\u6240\u6709\u4f9d\u8d56\u9879\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-shell",children:'# \u5c06\u60a8\u7684\u914d\u7f6e\u6587\u4ef6\u63d0\u4ea4\u5230 Git\u3002\uff08\u6b64\u6b65\u9aa4\u5728\u5feb\u901f\u6f14\u793a\u4e2d\u5df2\u8df3\u8fc7\u3002\uff09\n# Sparo \u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u5e94\u5b58\u50a8\u5728 Git \u4e2d\uff0c\u56e0\u4e3a\u8fd9\u53ef\u4ee5\u4f7f\u60a8\u5728\u5206\u652f\u4e4b\u95f4\u79fb\u52a8\u65f6\u65e0\u9700\u62c5\u5fc3\n# \u67d0\u4e2a\u5206\u652f\u4e2d\u5b58\u5728\u54ea\u4e9b\u9879\u76ee\u3002\nsparo add .\nsparo commit -m "Created a new Sparo profile"\n'})}),"\n",(0,r.jsx)(n.h2,{id:"\u7b2c-4-\u6b65\u68c0\u51fa\u60a8\u7684-sparo-\u914d\u7f6e\u6587\u4ef6",children:"\u7b2c 4 \u6b65\uff1a\u68c0\u51fa\u60a8\u7684 Sparo \u914d\u7f6e\u6587\u4ef6"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"--profile"})," \u53c2\u6570\u53ef\u4ee5\u4e0e ",(0,r.jsx)(n.code,{children:"sparo checkout"})," \u4e00\u8d77\u4f7f\u7528\uff08\u672a\u6765\u4e5f\u53ef\u4ee5\u4e0e ",(0,r.jsx)(n.code,{children:"sparo clone"})," \u548c ",(0,r.jsx)(n.code,{children:"sparo pull"})," \u4e00\u8d77\u4f7f\u7528\uff09\u3002\u6b64\u53c2\u6570\u6307\u5b9a\u8981\u9009\u62e9\u7684 JSON \u6587\u4ef6\u7684\u540d\u79f0\u3002\u60a8\u8fd8\u53ef\u4ee5\u7ec4\u5408\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\uff08",(0,r.jsx)(n.code,{children:"sparo checkout --profile p1 --profile p2"}),"\uff09\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5c06\u4f7f\u7528\u5b83\u4eec\u9009\u62e9\u7684\u96c6\u5408\u7684\u5e76\u96c6\u3002\u7ec4\u5408\u914d\u7f6e\u6587\u4ef6\u662f\u4e00\u4e2a\u9ad8\u7ea7\u573a\u666f\uff0c\u4f46\u5728\u4f8b\u5982\u60a8\u7684\u62c9\u53d6\u8bf7\u6c42\u5c06\u5f71\u54cd\u5c5e\u4e8e\u591a\u4e2a\u56e2\u961f\u7684\u9879\u76ee\u96c6\u65f6\u975e\u5e38\u6709\u7528\u3002"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"\u57fa\u4e8e common/sparo-profiles/my-team.json \u7684\u7a00\u758f\u68c0\u51fa"})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-shell",children:"sparo checkout --profile my-team\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:'\u5173\u4e8e "sparo checkout" \u7684\u66f4\u591a\u4fe1\u606f\uff1a'})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Sparo \u6839\u636e\u60a8\u7684\u914d\u7f6e\u6587\u4ef6\u9009\u62e9\u81ea\u52a8\u751f\u6210 Git \u7684 ",(0,r.jsx)(n.code,{children:"$GIT_DIR/info/sparse-checkout"})," ",(0,r.jsx)(n.a,{href:"https://git-scm.com/docs/git-sparse-checkout#_internalssparse_checkout",children:"\u914d\u7f6e\u6587\u4ef6"}),"\u3002\u4e3a\u907f\u514d\u51b2\u7a81\uff0c\u8bf7\u4e0d\u8981\u76f4\u63a5\u7f16\u8f91\u6b64\u6587\u4ef6\u6216\u4f7f\u7528\u5176\u4ed6\u5de5\u5177\uff08\u5982 ",(0,r.jsx)(n.code,{children:"git sparse-checkout"}),"\uff09\u91cd\u5199\u5b83\u3002\uff08\u8fd9\u6837\u505a\u4e0d\u4f1a\u7834\u574f\u4efb\u4f55\u4e1c\u897f\uff0c\u4f46\u53ef\u80fd\u4f1a\u5e72\u6270 Sparo \u7684\u64cd\u4f5c\u3002\uff09"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["\u8981\u4ec5\u68c0\u51fa\u9aa8\u67b6\uff08\u8fd4\u56de\u5230\u7b2c 1 \u6b65\u5c1a\u672a\u9009\u62e9\u4efb\u4f55\u914d\u7f6e\u6587\u4ef6\u7684\u521d\u59cb\u72b6\u6001\uff09\uff0c\u8bf7\u6307\u5b9a ",(0,r.jsx)(n.code,{children:"--no-profile"})," \u4ee3\u66ff ",(0,r.jsx)(n.code,{children:"--profile NAME"}),"\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["\u8981\u6dfb\u52a0\u66f4\u591a\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u4e0e\u73b0\u6709\u9009\u62e9\u7ec4\u5408\uff0c\u8bf7\u4f7f\u7528 ",(0,r.jsx)(n.code,{children:"--add-profile NAME"})," \u4ee3\u66ff ",(0,r.jsx)(n.code,{children:"--profile NAME"}),"\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\u4e0e ",(0,r.jsx)(n.code,{children:"sparo checkout --profile p1 --profile p2"})," \u4ea7\u751f\u76f8\u540c\u7684\u7ed3\u679c\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-shell",children:"sparo checkout --profile p1\nsparo checkout --add-profile p2\n"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u7b2c-5-\u6b65\u4f7f\u7528\u955c\u50cf\u5b50\u547d\u4ee4",children:"\u7b2c 5 \u6b65\uff1a\u4f7f\u7528\u955c\u50cf\u5b50\u547d\u4ee4"}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\uff0c\u8003\u8651\u9009\u62e9 ",(0,r.jsx)(n.a,{href:"/sparo/zh-cn/pages/commands/overview",children:"\u955c\u50cf\u5b50\u547d\u4ee4"}),"\uff0c\u4f8b\u5982 ",(0,r.jsx)(n.code,{children:"sparo revert"})," \u800c\u4e0d\u662f ",(0,r.jsx)(n.code,{children:"git revert"}),"\u3002Sparo \u5305\u88c5\u5668\u63d0\u4f9b (1) \u66f4\u597d\u7684\u9ed8\u8ba4\u8bbe\u7f6e\uff0c(2) \u66f4\u597d\u7684\u6027\u80fd\u5efa\u8bae\uff0c\u4ee5\u53ca (3) \u53ef\u9009\u7684\u533f\u540d\u5316\u6027\u80fd\u6307\u6807\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-shell",children:'sparo pull\n\nsparo commit -m "Example command"\n'})})]})}function p(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},4738:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>l});var r=s(6166);const o={},c=r.createContext(o);function i(e){const n=r.useContext(c);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),r.createElement(c.Provider,{value:n},e.children)}}}]); |