tink: Implement ancillary subcommands


(Kat Marchán) #1

We need to add support for various subcommands to tink in order to make it a more featureful package manager. I want to start with a few ancillary subcommands that should be more straightforward to implement and will help lay the groundwork towards implementing the more advanced ones.

All of these commands can also get implemented through libnpm, which is now a dependency of tink if you pull from latest. Check the libnpm docs for links to the documentation for the library version of the subcommands, and you can use lib/<command>.js from the main CLI repository as a reference for how each command is currently implemented.

Be prepared to iterate a little bit, because I’m treating “set down good practices early on” as a priority, so I might be asking folks to refactor the code they submit a few times before it gets accepted, and it might seem arbitrary, but I want to make sure the architecture looks good from 10k feet and I hugely appreciate your patience with that process as it happens.

Also keep in mind that these commands may be re-evaluated as part of a UX pass over the way tink itself does things, so they’re initially just doing what npm does, and may be thrown away entirely later, so if you want the code you contribute to last forever, this isn’t necessarily what you want to contribute to. I’ll do my best to be helpful and constructive!

One last thing: It is 100% ok to directly copy-paste any of these commands straight out of the npm CLI and add them to tink. We’ll take care of any license-related shenanigans on our end.

Once you’ve claimed a command (be replying here), head over to the tink repository and clone it, then file a PR with the implementation! That’s it! Please take one command at a time, so others get to have fun too! Don’t worry about tests – more setup needs to be done before they can be done consistently, and the related libraries are already well-tested so the window of failure is small. tink is a prototype, so it’s fine!


Using libnpm.<command>()

These libraries all use some part of libnpm subcommands, under the same name as the command itself. So tink profile uses libnpm.profile.

Using libnpm.fetch()

These subcommands are basic enough that they only use libnpm.fetch() calls directly, or the subcommand is simply not in libnpm yet.

tink: State of the Unwinder [2018/11/05]
(Michael Matuzak) #2

I’d like to claim the ping command.

(Kat Marchán) #3

All yours! lmk if you have any questions.

(Jeff C ) #4

whoami? the one claiming it :)

(Kat Marchán) #5

Go for it! It’s all yours :+1:t3:

(ƇʘƁ̆ąƇ́) #6

I would like to claim the tag command :slight_smile:

(Kat Marchán) #7

You’ve got it. Thank you! Lemme know if you have any questions.

(ƇʘƁ̆ąƇ́) #8

Thank you :slight_smile:

I am going to get the project context first.

I am not sure I will be able to contribute today as my working day will be quite long already but I hope to find some free time in the upcoming days.

(Alejandro López) #9

Hello @zkat I’d like to claim the profile command.

(Kat Marchán) #10

confirmed. I’ve edited the OP accordingly. :slight_smile:

(Michael Matuzak) #11

I can take a crack at hook

(Kat Marchán) #12

Awesome! We’re more than halfway there now: 5/9 of the commands have been claimed! Thanks, everyone. This is such a tremendous help.

@mike note that I refactored the command structure a little further, so refer back to your ping command as reference. The main difference is that the yargs-modules directory was moved outside of commands.

(Kat Marchán) #13

Quick note: I’ve refactored the command invocation stuff again, and now you only need to add a file to lib/commands/ and you’re all set. Follow the template set by ping.js.

(Michael Matuzak) #14

Does anything like otplease exist yet? Are you thinking utils like this should get dumped in lib? Or a lib/utils?

(Kat Marchán) #15

you can skip OTP support for now, and we can add it in one fell swoop. There’s nothing like that yet. Alternatively, if you want to copy-paste otplease over and set up a prompter for it, then please go ahead and take the time to do that!

(Miguel Alejandro Bolivar Portilla) #16

Greetings. I’d like to try it with the team command if that’s ok? @zkat

(Kat Marchán) #17

Go for it. It’s all yours! I’ll edit you in.

(Alejandro López) #18

Hello @zkat

I’m not sure about how to start with the profile command.

  • Should I use libnpm.profile functions, right?
  • Should I create a lib/commands/<command>.js file per function? I mean:
    • lib/commands/adduser.js
    • lib/commands/login.js
    • lib/commands/adduserWeb.js
    • lib/commands/adduserCouch.js
    • lib/commands/loginCouch.js
    • lib/commands/get.js
    • lib/commands/set.js
    • lib/commands/listTokens.js
    • lib/commands/removeTokens.js
    • lib/commands/createToken.js

I’m a bit lost :slight_smile:

Thank you!

(Kat Marchán) #19
  • yes, please refer to the original npm implementation
  • no, please define subcommands inline. Refer to the yargs docs on how to add subcommands using .command(). You have a yargs object in the build key if you base the command off of ping

(Kat Marchán) #20

@alopezsanchez and anyone else confused about subcommand definition: I’ve created a dummy subcommand that you can reference! Check it out:

Let me know if you have any other questions about how to do these bits, and thanks again for your contributions!