npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

tink: Implement ancillary subcommands

Should be able to use libnpm.getPrefix() to find the package.json (and libnpm.readJSON to read it)

I would like to claim the tag command :slight_smile:

how can I test whoamI?
Thanks in advance :-)

PR #23 for deprecate has been submitted.

whoami? the one claiming it :)

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

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

incidentally, I picked up tink org and have finished the command set :+1:

Should semver be added as a dependency? Or does one of the existing dependencies include its functionality?

I’d like to claim the ping command.

All yours! lmk if you have any questions.

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.

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

Yeah I was messing around with things and broke everything. It’ll be back in order soon. Do temp patches as needed for now.

Update: Should be fixed now, I think.

Hi @zkat. Had this observation with the latest branch. When testing tink command(s) (e.g. tink build), I ran into the following error.

→ tink build
    process.tink.config = yargv

TypeError: Cannot set property 'config' of undefined
    at runCommandWithYargs (/Users/bchen/github/tink/bin/tink.js:49:25)
    at main (/Users/bchen/github/tink/bin/tink.js:30:10)
    at Object.<anonymous> (/Users/bchen/github/tink/bin/tink.js:22:3)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
    at startup (internal/bootstrap/node.js:300:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:826:3)

After debugging, I could simply comment out process.tink.config = yargv in tink/bin/tink.js:49, and tink command(s) worked again. Thought I’d post this comment to confirm. Thanks!

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.

Hi @zkat, can I claim the “think access” subcommand from the unclaimed items from the checklist? Would like to learn more and help out.

@BeniCheni you can probably wait until @jcar787 finishes the whoami implementation, and then you’ll be able to call it directly. For the time being, just skip the case where [entity] is missing. We’ll fill it in before you’re done.

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

Haha I was having difficulties signing up here - @noelleleigh enjoy!

Keep an eye out. Someone may drop out and in that case, there will be some commands free for the taking~

yup. We’re going full-on async/await now!

We use standard. is the implementation to reference for deprecate, which no longer uses n-r-c.

That topic and tink: Implement tink view are the main ones experimenting with ink right now, yeah.

I’ll put up a new TODO in #development about doing the edit commands once this topic wraps up!

got for it. It’s all yours!

Hello @zkat , I have some questions about profile command.


Is there an .eslintrc.json that we should be using while working on these?

Are callback arguments being phased out in this codebase? I see a lot of cb's in npm cli’s code, but none in the tink commands so far. I assume switching to async makes those unnecessary?

take your time. I’m expecting all this to take another week or two!

But noted – I might just end up doing hook myself if I’m bored for tasks and need a change of pace, but it’s still all yours for now.

yes. I thought it already was. But go ahead and add it.

I can take a crack at hook

aaaaand with that, all ancillary commands are spoken for! I look forward to seeing everyone’s PRs! Thanks a bunch, y’all! I’ll be having some nice installer-related treats for you soon that I’m working on, too. Coming Soon™ ;)

Not sure what you’re actually doing or why it fails tbh

This is all pretty new to me, but I’d like to take a shot at tink deprecate if that’s okay!

You’ll need to update to node 10. Also, I recommend running npm link in the tink repo and you’ll have $ tink ... available from then on

No worries about implementing login. npm login works for that, and it’s a bit more involved.

@zkat just fyi this week has been terrible. I’m still down to do hook, but also don’t want to hold it up so if someone else wants to jump in and take it I’m totally cool with giving it up.

If I’m reading the OP right, the deprecate command will have to use libnpm.fetch to send a command an API endpoint. This repo appears to be the location where such endpoints would be documented, but I can find nothing in there beyond GET'ing information, no POST'ing.

Looking at how the npm CLI does it, it uses npm-registry-client, which exposes a deprecate method. Tink currently doesn’t have npm-registry-client as a dependency. Is it alright if I add it?

As I mentioned in the PR, there’s no commands I know of which actually implement edit. And, tbh, I’m fine with it being left out entirely.

If you’re feeling like doing something a bit fun, you can try using ink to implement an interactive team editor, which could be pretty cool, but is a much bigger project. But hey you’d be using react in a CLI and it’d look snazzy af!

EDIT #2: I’m going to split off adding tink <x> edit commands to all the subcommands as a single, unified project. I think it’s definitely bigger than this specific topic and I think it’s better off being done as a single effort with a single design across commands.

Check out the docs for yargs. tl;dr defining a command like this does the trick:

.command('ls <org>', ...)

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

Thanks for your review, @zkat. The latest update to the PR would be a “wrap” for the tink access subcommand, w. the agreed “TODO” stubs.

I am up for the “fun” to try out the interactive team editor, using ink. (React in CLI sounds definite “futuristic”!) Found this New Search UI topic to see if I could “shadow” the same idea. But if you have any advice other than the “New Search UI” topic, please definitely advise.

I’m also interested in helping out this tink <x> edit idea. But would need to absorb more requirements. Is this topic worth of creating its own topic thread to discuss further?

Last by not least, if you have any other more prioritized tink task to tackle before the Team Interactive UI or unified tink <x> edit, I’m also happy to help out. Just let me know.

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.

wow there’s some hot competition for deprecate, but you ended up being the first to actually post about it, so it’s all yours!

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.

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!

@zkat et al,

Implemented tink access ls-collaborators [<package> [<user>]] in these 2 commits (652897e & 5639535) in this WIP PR tonight. Seems to work in quick test:

→ tink access ls-collaborators npm
│ collab  │ role       │
│ isaacs  │ read-write │
│ ceejbot │ read-write │
│ iarna   │ read-write │
│ zkat    │ read-write │

Have a test case, where [<package>|<user>] is not provided. When trying regular npm access ls-collaborators without providing a package name or user name, it seems to use the package.json. Still trying to figure out in a stab.

Temporarily checked the ls-collaborators item off from the PR’s checklost, but would like to hear your thoughts/advice to “overcome” the test case, when option(s) are not provided to the tink access ls-collaborators command. :pray:

Don’t bother with those two commands right now. :slight_smile:

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

@jcar787 don’t worry about testing that right now

@zkat, when trying node bin/tink.js org ls, I could see a helpful message (“Not enough non-option arguments: got 0, need at least 1”).

Would like to try the same approach to ensure arg(s) are provided correctly, i.e. node bin/tink.js access ls could receive the same validation message.

Would you mind sharing some tips?

(I could try when finishing the stubs in this WIP access PR.

Good evening, @zkat. Per tink access, thanks for merging #12. I reviewed the code more & did a follow-up PR (#34) to improve a few things. Please review at convenience. :v:

Greetings @zkat how’ve you been? I’m continuing the work with the ‘team’ command. I’ve been reading about how it actually works, and I’m trying to use it with npm and I found that in order to create teams and some other operations I need to login, and that’s with ‘npm login’. So now the question is: Should I add the ‘login’ command too? I’m cool with it but I wanted to ask you first before code it at all.

And also when running create() I got an error about the scope: ‘Scope not found’, but I’m sending the registry as ‘scope:name

I’m just hoping not being completely lost at all haha. Thank you :slight_smile: :metal:

I see @zkat. And about the scope problem? I even did a little program and ran it like the docs for create team and it still shows me the error about scope not found :thinking:

@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!

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

Hello @zkat

Here is the tink profile PR :slight_smile:

Thanks for previous help, @zkat. I’ve finished ~95% of tink access subcommands, except edit. So believe the WIP PR is good shape for review.

Per tink access edit, I’ve looked through the libnpmaccess doc and couldn’t see a similar API method such as .edit(...). Also tried looking at the npm/cli access.js#L78 parseParams method. I couldn’t seem to find any logic that could map to edit.

Would you mind guiding the approach to implement tink access edit? (the last remaining item to wrap the PR. :cowboy_hat_face::pray:t2:

Hi @zkat
Attempted to implement tink access ls-packages [enitity] in commit cef334a in the WIP PR.

Ran into a use case when [entity] is not provided & from reading the npm cli access.js code, it seems to fetch the current authenticated user by whoami support . Tested with npm access ls-packages to confirm.

What would you advise in tink to address this use case with tink access ls-packages without [entity]?

Is it a correct assumption to get the authenticated user? (In that case, how do you verify authenticated user via libnpm API?) :pray:

@zkat I was working today adding the “team” command. I already add some utils and the initial files. I got a question about running tink, I’m sorry for the newbie question I think. I try to run the tink command with:

node bin/tink.js

When I first ran like that, I got an error regarding the function: “internalModuleReadJSON”, I had to modify that in the file: “lib/node/module.js” to be like:

const { internalModuleReadFile: interModuleReadJSON, internalModuleStat } = process.binding('fs');

Doing that I can get tink running, I can see the help and the other commands, I can even run the ping. Well far from being a question, I was wondering if that’s ok, I don’t know if maybe I have a wrong env, I’m running the project with node v9.10.1 and npm v6.4.1. Thanks a lot for letting me help, and my apologies again for maybe a newbie question :sweat:

Hello @zkat

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

I’m a bit lost :slight_smile:

Thank you!

Greetings. PR #25 for team command is up :metal: