tiktok-sparo/assets/js/45779d82.b724e2ec.js
2024-03-01 00:59:14 -08:00

1 line
No EOL
9.4 KiB
JavaScript

"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[421],{9917:(e,s,r)=>{r.r(s),r.d(s,{assets:()=>l,contentTitle:()=>i,default:()=>p,frontMatter:()=>t,metadata:()=>c,toc:()=>a});var o=r(678),n=r(4738);const t={title:"Getting Started"},i=void 0,c={id:"pages/guide/getting_started",title:"Getting Started",description:"\ud83d\udea7 UNDER CONSTRUCTION \ud83d\udea7",source:"@site/docs/pages/guide/getting_started.md",sourceDirName:"pages/guide",slug:"/pages/guide/getting_started",permalink:"/sparo/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:"Getting Started"},sidebar:"docsSidebar",previous:{title:"Overview",permalink:"/sparo/"},next:{title:"Sparo profiles",permalink:"/sparo/pages/guide/sparo_profiles"}},l={},a=[{value:"Everyday workflow",id:"everyday-workflow",level:2},{value:"Step 1: Upgrade Git",id:"step-1-upgrade-git",level:3},{value:"Step 2: Clone your Rush monorepo",id:"step-2-clone-your-rush-monorepo",level:3},{value:"Step 3: Create a sparse profile",id:"step-3-create-a-sparse-profile",level:3},{value:"Step 4: Check out your Sparo profile",id:"step-4-check-out-your-sparo-profile",level:3},{value:"Step 5: Use the mirrored subcommands",id:"step-5-use-the-mirrored-subcommands",level:3}];function d(e){const s={a:"a",blockquote:"blockquote",code:"code",em:"em",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,n.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(s.blockquote,{children:["\n",(0,o.jsx)(s.p,{children:"\ud83d\udea7 UNDER CONSTRUCTION \ud83d\udea7"}),"\n",(0,o.jsxs)(s.p,{children:["This is an early test release of the software.\r\nIt is not yet ready for general usage.\r\nIf you have questions about this project, let us know\r\nusing ",(0,o.jsx)(s.a,{href:"https://github.com/tiktok/sparo/discussions",children:"GitHub discussions"}),"."]}),"\n"]}),"\n",(0,o.jsx)(s.h2,{id:"everyday-workflow",children:"Everyday workflow"}),"\n",(0,o.jsx)(s.h3,{id:"step-1-upgrade-git",children:"Step 1: Upgrade Git"}),"\n",(0,o.jsxs)(s.p,{children:["Many Git optimizations are relatively new and not available in older versions of the software. For macOS, we recommend to use ",(0,o.jsx)(s.a,{href:"https://git-scm.com/download/mac",children:"brew install git"}),". For other operating systems, see the ",(0,o.jsx)(s.a,{href:"https://git-scm.com/book/en/v2/Getting-Started-Installing-Git",children:"Git documentation"})," for instructions."]}),"\n",(0,o.jsx)(s.h3,{id:"step-2-clone-your-rush-monorepo",children:"Step 2: Clone your Rush monorepo"}),"\n",(0,o.jsxs)(s.p,{children:["Clone your ",(0,o.jsx)(s.a,{href:"https://rushjs.io/",children:"RushJS"})," monorepo:"]}),"\n",(0,o.jsx)(s.pre,{children:(0,o.jsx)(s.code,{className:"language-shell",children:"sparo clone https://github.com/my-company/my-monorepo.git\n"})}),"\n",(0,o.jsxs)(s.p,{children:["\ud83d\udc49 ",(0,o.jsx)(s.em,{children:"For a real world demo, try this repo:"}),"\r\n",(0,o.jsx)(s.a,{href:"https://github.com/Azure/azure-sdk-for-js.git",children:"https://github.com/Azure/azure-sdk-for-js.git"})]}),"\n",(0,o.jsxs)(s.blockquote,{children:["\n",(0,o.jsx)(s.p,{children:"\ud83d\udca1 Support for PNPM and Yarn workspaces is planned but not implemented yet. Contributions welcome!"}),"\n"]}),"\n",(0,o.jsx)(s.p,{children:(0,o.jsx)(s.strong,{children:"Behind the scenes:"})}),"\n",(0,o.jsxs)(s.ul,{children:["\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsxs)(s.p,{children:["Only the default branch (usually ",(0,o.jsx)(s.code,{children:"main"}),") is fetched."]}),"\n"]}),"\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsxs)(s.p,{children:["Git blobless ",(0,o.jsx)(s.a,{href:"/sparo/pages/reference/git_optimization",children:"partial clone"})," is enabled to postpone downloading file contents."]}),"\n"]}),"\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsxs)(s.p,{children:["Git ",(0,o.jsx)(s.a,{href:"/sparo/pages/reference/git_optimization",children:"sparse checkout"})," is used to clone only the ",(0,o.jsx)(s.a,{href:"/sparo/pages/reference/skeleton_folders",children:'"skeleton" folders'}),", which includes all workspace ",(0,o.jsx)(s.strong,{children:"package.json"})," files, but excludes the source code subfolders."]}),"\n"]}),"\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsx)(s.p,{children:'Sparse checkout is configured for the more efficient "cone mode".'}),"\n"]}),"\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsxs)(s.p,{children:["To understand exactly what actions and Git operations are being performed, invoke ",(0,o.jsx)(s.code,{children:"sparo --debug clone"})," instead of ",(0,o.jsx)(s.code,{children:"sparo clone"}),"."]}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(s.h3,{id:"step-3-create-a-sparse-profile",children:"Step 3: Create a sparse profile"}),"\n",(0,o.jsxs)(s.p,{children:["Define a ",(0,o.jsx)(s.a,{href:"/sparo/pages/configs/profile_json",children:"Sparo profile"})," describing the subset of repository folders for Git sparse checkout. Here is a basic example:"]}),"\n",(0,o.jsx)(s.p,{children:(0,o.jsx)(s.strong,{children:"common/sparo-profiles/my-team.json"})}),"\n",(0,o.jsx)(s.pre,{children:(0,o.jsx)(s.code,{className:"language-json",children:'{\r\n "selections": [\r\n {\r\n "selector": "--to",\r\n "argument": "my-rush-project"\r\n }\r\n ]\r\n}\n'})}),"\n",(0,o.jsxs)(s.p,{children:["The ",(0,o.jsx)(s.code,{children:"--to"})," ",(0,o.jsx)(s.a,{href:"https://rushjs.io/pages/developer/selecting_subsets/#--to",children:"project selector"})," instructs Sparo to checkout all dependencies in the workspace that are required to build ",(0,o.jsx)(s.code,{children:"my-rush-project"}),"."]}),"\n",(0,o.jsxs)(s.p,{children:["\ud83d\udc49 ",(0,o.jsxs)(s.em,{children:["If you're demoing ",(0,o.jsx)(s.strong,{children:"azure-sdk-for-js"}),", replace ",(0,o.jsx)(s.code,{children:"my-rush-project"})," with ",(0,o.jsx)(s.code,{children:"@azure/arm-commerce"}),"."]})]}),"\n",(0,o.jsx)(s.h3,{id:"step-4-check-out-your-sparo-profile",children:"Step 4: Check out your Sparo profile"}),"\n",(0,o.jsxs)(s.p,{children:["The ",(0,o.jsx)(s.code,{children:"--profile"})," parameter can be included with ",(0,o.jsx)(s.code,{children:"sparo checkout"})," (and in the future also ",(0,o.jsx)(s.code,{children:"sparo clone"})," and ",(0,o.jsx)(s.code,{children:"sparo pull"}),"). This parameter specifies the name of the JSON file to be selected. You can also combine multiple profiles (",(0,o.jsx)(s.code,{children:"sparo checkout --profile p1 --profile p2"}),"), in which case the union of their selections will be used. (Combining profiles is an advanced scenario, but useful for example if your pull request will impact sets of projects belonging to multiple teams.)"]}),"\n",(0,o.jsx)(s.p,{children:(0,o.jsx)(s.strong,{children:"Sparse checkout based on common/sparo-profiles/my-team.json"})}),"\n",(0,o.jsx)(s.pre,{children:(0,o.jsx)(s.code,{className:"language-shell",children:"sparo checkout --profile my-team\n"})}),"\n",(0,o.jsx)(s.p,{children:(0,o.jsx)(s.strong,{children:"Behind the scenes:"})}),"\n",(0,o.jsxs)(s.ul,{children:["\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsxs)(s.p,{children:["Sparo automatically generates the ",(0,o.jsx)(s.code,{children:"$GIT_DIR/info/sparse-checkout"})," configuration automatically based on your profile selections. To avoid conflicts, while using Sparo do not edit this file directly or rewrite it using other tools such as ",(0,o.jsx)(s.code,{children:"git sparse-checkout"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsxs)(s.p,{children:["To checkout just the skeleton (returning to the initial state from Step 1 where no profile is chosen yet), specify ",(0,o.jsx)(s.code,{children:"--no-profile"})," instead of ",(0,o.jsx)(s.code,{children:"--profile NAME"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(s.li,{children:["\n",(0,o.jsxs)(s.p,{children:["To add more profiles, combining with your existing selection, use ",(0,o.jsx)(s.code,{children:"--add-profile NAME"})," instead of ",(0,o.jsx)(s.code,{children:"--profile NAME"}),". For example, these two commands produce the same result as ",(0,o.jsx)(s.code,{children:"sparo checkout --profile p1 --profile p2"}),":"]}),"\n",(0,o.jsx)(s.pre,{children:(0,o.jsx)(s.code,{className:"language-shell",children:"sparo checkout --profile p1\r\nsparo checkout --add-profile p2\n"})}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(s.h3,{id:"step-5-use-the-mirrored-subcommands",children:"Step 5: Use the mirrored subcommands"}),"\n",(0,o.jsxs)(s.p,{children:["For everyday work, consider choosing ",(0,o.jsx)(s.a,{href:"/sparo/pages/commands/overview",children:"mirrored subcommands"})," such as ",(0,o.jsx)(s.code,{children:"sparo revert"})," instead of ",(0,o.jsx)(s.code,{children:"git revert"}),". The Sparo wrapper provides (1) better defaults, (2) suggestions for better performance, and (3) optional anonymized performance metrics."]}),"\n",(0,o.jsx)(s.p,{children:"Examples:"}),"\n",(0,o.jsx)(s.pre,{children:(0,o.jsx)(s.code,{className:"language-shell",children:'sparo pull\r\n\r\nsparo commit -m "Example command"\n'})})]})}function p(e={}){const{wrapper:s}={...(0,n.R)(),...e.components};return s?(0,o.jsx)(s,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},4738:(e,s,r)=>{r.d(s,{R:()=>i,x:()=>c});var o=r(6166);const n={},t=o.createContext(n);function i(e){const s=o.useContext(t);return o.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function c(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:i(e.components),o.createElement(t.Provider,{value:s},e.children)}}}]);