tiktok-sparo/apps/website/docs/index.md
2024-03-04 23:51:56 -08:00

4.6 KiB

title hide_title custom_edit_url
Overview true null

import { ThemedImage } from '@site/src/components/ThemedImage';

Clone faster!

Sparo optimizes performance of Git operations for your large frontend monorepo.

Key features

  • Familiar interface: The sparo command-line interface (CLI) wrapper offers better defaults and performance suggestions without altering the familiar git syntax. (The native git CLI is also supported.)

  • A proven solution: Git provides quite a lot of ingredients for optimizing very large repos; Sparo is your recipe for combining these features intelligently.

  • Simplified sparse checkout: Work with sparse checkout profiles instead of confusing "cones" and globs

  • Frontend integration: Sparo leverages Rush and PNPM workspace configurations, including the ability to automatically checkout project dependencies

  • Dual workflows: The sparo-ci tool implements a specialized checkout model optimized for continuous integration (CI) pipelines

  • Extra safeguards: Avoid common Git mistakes such as checkouts with staged files outside the active view

  • Go beyond Git hooks: Optionally collect anonymized Git timing metrics in your monorepo, enabling your build team to set data-driven goals for local developer experience (not just CI!)

    (Metrics are transmitted to your own service and are not accessible by any other party.)

Quick demo

Try out Sparo in 5 easy steps:

  1. Upgrade to the latest Git version! For macOS, we recommend to use brew install git. For other operating systems, see the Git documentation for instructions.

  2. For this demo, we'll use the Azure SDK which is a large public RushJS monorepo from GitHub. The following command will check out the skeleton folders but not the source code:

    sparo clone https://github.com/Azure/azure-sdk-for-js.git
    
    cd azure-sdk-for-js
    

    💡 Support for PNPM and Yarn workspaces is planned but not implemented yet. Contributions welcome!

  3. Define a Sparo profile describing the subset of repository folders for Git sparse checkout.

    # Writes a template to common/sparo-profiles/my-team.json
    sparo init-profile --profile my-team
    

    Edit the created my-team.json file to add this selector:

    common/sparo-profiles/my-team.json

    {
      "selections": [
         {
           // This demo profile will check out the "@azure/arm-commerce" project
           // and all of its dependencies:
           "selector": "--to",
           "argument": "@azure/arm-commerce"
         }
      ]
    }
    

    The --to project selector instructs Sparo to checkout all dependencies in the workspace that are required to build my-rush-project.

  4. After saving your changes to my-team.json, now it's time to apply it:

    sparo checkout --profile my-team
    

    Try it out! For example:

    rush install
    
    # The build should succeed because Sparo ensured that dependency projects
    # were included in the sparse checkout:
    rush build --to @azure/arm-commerce
    
  5. For everyday work, consider choosing mirrored subcommands such as sparo revert instead of git revert. The Sparo wrapper provides (1) better defaults, (2) suggestions for better performance, and (3) optional anonymized performance metrics.

    Examples:

    sparo pull
    
    sparo commit -m "Example command"
    

👍👍 This concludes the Quick Demo. For a more detailed walkthrough, proceed to Getting Started.