Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype: Add annotations command #930

Merged
merged 1 commit into from May 13, 2022
Merged

Prototype: Add annotations command #930

merged 1 commit into from May 13, 2022

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented May 12, 2022

Motivation

Provide a way to share shims across projects:

$ tapioca annotations

This is feature is similar to the sorbet-typed command of srb.

Implementation

This command follows these steps:

  1. Gather the central repository index.json (see below)
  2. List all the gems from the project Gemfile.lock
  3. Delete all files in sorbet/rbi/annotations that do not match the gems inside Gemfile.lock
  4. For each gem in Gemfile.lock, if the gem is listed in index.json, download it and store it in sorbet/rbi/annotations/

The structure of the repo must be as follows:

index.json
rbi/
    annotations/
        gem1.rbi
        gem2.rbi

For now, the structure of the index.json is the following:

{
  "gem1": {},
  "gem2": {},
}

Where gem1 and gem2 are the names of gems we can find in the repo under /rbi/annotations/. The {} hash will be used to store options later. We use a hash rather than an array to avoid duplicated entries.

There are a lot of TODOs remaining:

  • Handle multiple repos
  • Handle private repos
  • Handle gem versioning
  • Merge conflicts between repos

But I think this is enough to get us started.

An example of repository can be found at https://github.com/Shopify/rbi-central.

Tests

See automated tests.

Special thanks to @KaanOzkan who has been instrumental on making all of this working internally and ready to open-source.

@Morriar Morriar requested a review from a team May 12, 2022 22:17
@Morriar Morriar self-assigned this May 12, 2022
lib/tapioca/repo_index.rb Show resolved Hide resolved
spec/tapioca/cli/annotations_spec.rb Outdated Show resolved Hide resolved
spec/tapioca/cli/annotations_spec.rb Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
lib/tapioca/commands/annotations.rb Show resolved Hide resolved
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few nitpicks but LGTM. We can iterate on this later, once we see people using it.

lib/tapioca/commands/annotations.rb Outdated Show resolved Hide resolved
lib/tapioca/repo_index.rb Outdated Show resolved Hide resolved
Used to pull annotations from a central RBI repository.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar merged commit c24f5ca into main May 13, 2022
@Morriar Morriar deleted the at-annotations branch May 13, 2022 20:10
@shopify-shipit shopify-shipit bot temporarily deployed to production May 13, 2022 23:08 Inactive
@shopify-shipit shopify-shipit bot temporarily deployed to 0-8-stable May 30, 2022 13:45 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants