doron-cohen / antidot

Cleans up your $HOME from those pesky dotfiles
MIT License
309 stars 18 forks source link

chore(rules): add yarn alias #119

Open rodweb opened 3 years ago

rodweb commented 3 years ago

Add missing alias for yarn config

doron-cohen commented 3 years ago

Thanks @rodweb . Could you link to any reference for this CLI flag? Documentation or commit.

rodweb commented 3 years ago

--use-yarnrc specifies a yarnrc file that Yarn should use (.yarnrc only, not .npmrc) (default: )```

I got it from running yarn help

$ yarn --version
1.22.10

edit: https://github.com/yarnpkg/yarn/blob/3119382885ea373d3c13d6a846de743eca8c914b/src/cli/index.js#L74-L79 It seems this option is for v1 only, I haven't tested yarn v2 yet.

doron-cohen commented 3 years ago

Question is if yarn v2 will fail to launch over bad usage for that. Kind of risky.

rodweb commented 3 years ago

Yean, it fails.

❯ alias yarn
yarn='yarn --use-yarnrc /home/rod/.config/yarn/config'
❯ yarn --version
Unknown Syntax Error: Command not found; did you mean one of:

The current migration of .yarnrc only applies to v1 too. In v2 it is called .yarnrc.yml

But I'm not sure how you'd like to handle multiple versions.

Another related problem, antidot clean can't remove the dir ~/.yarn because there is a bin folder inside, which does not seem to be part of the XDG efforts on yarn. You have to configure the bin dir on yarn config file.

doron-cohen commented 3 years ago

First, we can add a rule for .yarnrc.yml to cover yarn v2 as well. Second, we can always use the migrate action with symlink: true which will create a symlink to the new location.

About the bin dir. I never expect all files to be safely migratable. I focus on the apps that actually give yo the option to move their files. For the rest I just open issues in their repos.

Grafcube commented 2 years ago

Adding this to rules.yaml seems to work for .yarnrc for me

      - type: alias
        alias: yarn
        command: yarn --use-yarnrc "$XDG_CONFIG_HOME/yarn/config"

However, running clean on .yarn results in this output

File $HOME/.yarn/link doesn't exist. Skipping action
File $HOME/.yarn/global doesn't exist. Skipping action
File $HOME/.yarn/config doesn't exist. Skipping action
WARNING: Failed to run rule yarn: remove $HOME/.yarn: directory not empty

I've only ever used yarn for building AUR packages and installing language servers for neovim. I'm not very familiar with it so I don't know how to fix it.