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

Print suggestions upon failing to find a package by name #1257

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

fsoikin
Copy link
Collaborator

@fsoikin fsoikin commented Jul 25, 2024

Description of the change

Fixes #1184

  • When looking up a package,
    • Either among workspace packages, e.g. spago build -p bogus-package
    • Or from a package set, e.g. dependencies: ["bogus-package"] or spago install bogus-package
  • If the package is not there,
  • Print a list of suggestions based on Levenshtein distance <= 2, and only top 5 in case there are too many.
  • If there are no suggestions that are close enough:
    • When looking up among workspace packages, fall back to previous behavior of printing out all available packages.
    • When looking up in a package set, don't print anything.
 λ npx spago build -p spago-pg

<snip>
❌ The following packages do not exist in your package set:
  - effcet (did you mean: effect)
  - elmish-hml (did you mean: elmish-html)


 λ npx spago build -p mind

<snip>
❌ Selected package mind was not found in the local packages.
Did you mean:
  minder

 λ npx spago build -p bnder

<snip>
❌ Selected package bnder was not found in the local packages.
Did you mean:
  binder
  minder
  finder

 λ npx spago build -p flounder

<snip>
❌ Selected package flounder was not found in the local packages.
Did you mean:
  founder

 λ npx spago build -p fnder

<snip>
❌ Selected package fnder was not found in the local packages.
Did you mean:
  finder
  minder
  founder
  binder

 λ npx spago install bff

<snip>
✅ Selecting 6 packages to build:
    binder
    bound
    finder
    founder
    minder
    spago-pg

⚠️ You tried to install some packages that are already present in the configuration, proceeding anyways:
  - effcet

❌ The following packages do not exist in your package set:
  - bff (did you mean: aff, rdf, b64)
  - effcet (did you mean: effect)
  - elmish-hml (did you mean: elmish-html)

 λ npx spago build -p foobar

<snip>
❌ Selected package foobar was not found in the local packages.
All available packages:
  binder
  bound
  finder
  founder
  minder
  spago-pg

Checklist:

  • Added the change to the "Unreleased" section of the changelog
  • [ ] Added some example of the new feature to the README
  • Added a test for the contribution (if applicable)

@@ -59,7 +59,7 @@ spec = Spec.around withTempDir do

Spec.it "can't add dependencies that are not in the package set" \{ spago, fixture } -> do
spago [ "init", "--name", "aaaa", "--package-set", "29.3.0" ] >>= shouldBeSuccess
spago [ "install", "foo", "bar" ] >>= shouldBeFailureErr (fixture "missing-dependencies.txt")
spago [ "install", "foo-foo-foo", "bar-bar-bar", "effcet", "arrys" ] >>= shouldBeFailureErr (fixture "missing-dependencies.txt")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Making sure there are no packages accidentally fuzzy-matching "foo" or "bar".

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, brilliant

Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

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

Amazing ❤️

@f-f f-f merged commit 20afe6e into purescript:master Jul 25, 2024
5 checks passed
@fsoikin fsoikin deleted the suggest-typos branch July 26, 2024 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diff names when listing workspace packages due to not finding local package
2 participants