antfu-collective / package-manager-detector

Package manager detector
MIT License
36 stars 4 forks source link

feat!: use arrays to represent commands, new `resolveCommand` function #8

Closed userquin closed 2 months ago

userquin commented 3 months ago

Description

This PR converts every command in COMMANDS to command and argument pairs.

And provide a new utility, constructCommand, to make the resolution easier.

Linked Issues

https://github.com/antfu-collective/ni/pull/231#discussion_r1718864647

Additional context

I do my best to keep types similar to COMMANDS in agents.ts, I guess it is fine using satisfies in the buildCommands return type.

userquin commented 3 months ago

don't merge yet, I'm going to add an utility helper to allow return the CommandType in all commands, that's, all new agents commands actions will be functions like npm.run: will also handle {0}

userquin commented 3 months ago

This is the current ni behavior, generated commands here with same behavior:

imagen

benmccann commented 3 months ago

it would be helpful to update the readme showing how to use the new functionality

antfu commented 2 months ago

I refactored it a bit. So the COMMANDS is now an object of arrays. Which means it would be a breaking change. I also provided a utility constructCommand to make it easier to construct.

@benmccann could you help to confirm how much it would affect your usage? If not much I am thinking to have it as 0.2 and then update the usage side on ni