withfig / fig

Public issue tracker for Fig.
https://fig.io
MIT License
2.06k stars 61 forks source link

fig doesn't autocomplete yarn/npm #1723

Open MilanDeruelle opened 2 years ago

MilanDeruelle commented 2 years ago

Sanity checks

Issue Details

When I'm in a folder with a package.json, the autocomplete window opens and displays suggestions, however none of them are from the package.json script section. Doesn't work across different folders/package.json files.

Might this be related to the oh-my-zsh plugins I have installed?

image

When inspecting the autocomplete window, there seem to be no specific errors. image

Environment

### Details:
|OS|Fig|Shell|
|-|-|-|
|macOS 12.3.1 (21E258)|1.0.60|/bin/zsh|
fig diagnostic

# Fig Diagnostics
## Fig details:
  - Fig version: Version 1.0.60 (B507) [Windows Tastatur, Deutsch]
  - Bundle path: /Applications/Fig.app
  - Autocomplete: true
  - Settings.json: true
  - Accessibility: true
  - Number of specs: 0
  - Symlinked dotfiles: false
  - Only insert on tab: false
  - Keybindings path: 
  - Installation Script: true
  - PseudoTerminal Path: /Users/milanderuelle/.nvm/versions/node/v16.8.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/milanderuelle/.fig/bin:/Users/milanderuelle/.local/bin:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/npm:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/macos:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/last-working-dir:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/docker:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/autojump:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/command-not-found:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vscode:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/brew:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/dotenv:/Users/milanderuelle/.antigen/bundles/zsh-users/zsh-syntax-highlighting:/Users/milanderuelle/.antigen/bundles/arzzen/calc.plugin.zsh:/Users/milanderuelle/.antigen/bundles/romkatv/powerlevel10k
  - SecureKeyboardInput: false
  - SecureKeyboardProcess: <none>
## Hardware Info:
  - Model Name: MacBook Air
  - Model Identifier: MacBookAir10,1
  - Chip: Apple M1
  - Cores: 8 (4 performance and 4 efficiency)
  - Memory: 16 GB
## OS Info:
  - macOS 12.3.1 (21E258)
## Environment:
  - User Shell: /bin/zsh
  - Current Directory: /Users/milanderuelle/Desktop
  - CLI Installed: true
  - Executable Location: /Users/milanderuelle/.fig/bin/fig
  - Current Window ID: 322/% (com.googlecode.iterm2)
  - Active Process: zsh (31208) - not a tty
  - Terminal: iterm
  - Environment Variables:
    - FIG_INTEGRATION_VERSION=8
    - FIG_TERM=1
    - FIG_TERM_VERSION=5.1.0
    - PATH=/Users/milanderuelle/.nvm/versions/node/v16.8.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/milanderuelle/.fig/bin:/Users/milanderuelle/.local/bin:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/npm:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/macos:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/last-working-dir:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/docker:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/autojump:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/command-not-found:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vscode:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/brew:/Users/milanderuelle/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/dotenv:/Users/milanderuelle/.antigen/bundles/zsh-users/zsh-syntax-highlighting:/Users/milanderuelle/.antigen/bundles/arzzen/calc.plugin.zsh:/Users/milanderuelle/.antigen/bundles/romkatv/powerlevel10k
    - TERM=xterm-256color
    - TERM_SESSION_ID=w0t12p0:D95A6226-BB18-49A6-9D27-5CA102B320ED
    - FIG_PID=31208
## Integrations:
  - SSH: false
  - TMUX: false
  - iTerm: installed!
  - Hyper: application is not present.
  - Visual Studio Code: installed!
  - Docker: true
fedeci commented 2 years ago

Hi @MilanDeruelle, that's really strange cause it is working correctly for me. Can you try typing `yarn[space], then removing the space and adding it again? Does it suggest scripts?

MilanDeruelle commented 2 years ago

No... it suggests a bunch of yarn related commands (e.g. init, add, etc) but no scripts from the package.json

mschrage commented 2 years ago

@MilanDeruelle Are you sure you're in the correct directory? Fig seems to think you are in ~/Desktop which presumably doesn't have it's own package.json.

Can you share a screen recording of yourself navigating to this directory and typing "yarn [space]"

MilanDeruelle commented 2 years ago

Yes, I've tried a bunch of different directories with different package.json's (all working fine with just yarn/npm). The screenshots show desktop because I didn't want to leak the project names, since they are from work.

Give me second

MilanDeruelle commented 2 years ago

@mschrage

https://user-images.githubusercontent.com/9109923/186755704-f71458c8-778b-4b7f-9f96-57ff01331e0b.mov

The package.json looks like this and works fine.

{
  "name": "nextjs",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "rm -rf .next && next dev",
    "build": "NODE_ENV=production next build",
    "start": "next start",
    "lint": "next lint --quiet"
  },
  "dependencies": {
    "@splidejs/react-splide": "^0.7.8",
    "@splidejs/splide": "^4.0.7",
    "@svgr/webpack": "^6.2.1",
    "case-anything": "^2.1.10",
    "favicons": "^6.2.2",
    "fs-extra": "^10.1.0",
    "graphql": "^16.5.0",
    "graphql-request": "^4.3.0",
    "next": "12.1.6",
    "next-build-cache": "^1.0.4",
    "object.hasown": "^1.1.1",
    "prop-types": "^15.8.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "ui": "workspace:^",
    "use-resize-observer": "^9.0.2",
    "uuid": "^8.3.2"
  },
  "devDependencies": {
    "eslint": "8.17.0",
    "eslint-config-next": "12.1.6"
  }
}
mschrage commented 2 years ago

Can you share a screenshot of the Fig debugger in the menubar icon? I want to see what we think the current working directory is?

mschrage commented 2 years ago

Also is there another package.json file higher up in the folder structure?

mschrage commented 2 years ago

Btw do you have npm installed? Could you try running npm prefix in that directory?

mschrage commented 2 years ago

It looks like the yarn completion spec is using this generator under the hood: https://github.com/withfig/autocomplete/blob/4804172f7e9241d362c946c92cb1d7c24c3c1639/src/npm.ts#L159

mschrage commented 2 years ago

You might try running until [[ -f package.json ]] || [[ $PWD = '/' ]]; do cd ..; done; cat package.json as well and see what the output is?

PS. sorry for spamming comments.

MilanDeruelle commented 2 years ago

@mschrage

image

I've tried with both "complex" package.json files that are split across the folder structure and "simple" ones that exist just on their own. Same result in both cases. Also, in both cases the scripts are found in the package.json that is in the CWD.

npm prefix:

image

I was just looking at the code and tried some of the scripts fig uses to get the package.json and all I found (including the one you posted) returned the correct output.

image
github-actions[bot] commented 2 years ago

This issue has been automatically closed because there has been no activity for 14 days.

github-actions[bot] commented 2 years ago

This issue has been automatically closed because there has been no activity for 14 days.

Abhishek765Flyfin commented 10 months ago

Hi @mschrage and @MilanDeruelle , has this issue been resolved? I've been facing a similar problem since morning, as everything was working fine until yesterday.

PanosSynetos commented 10 months ago

Same here as @Abhishek765Flyfin

Abhishek765Flyfin commented 10 months ago

Hi @mschrage and @MilanDeruelle , has this issue been resolved? I've been facing a similar problem since morning, as everything was working fine until yesterday.

hey there not sure how but this is working again 👍 , thanks a lot