nebrelbug / npm-to-yarn

Convert npm CLI commands to yarn, and vice versa
https://nebrelbug.github.io/npm-to-yarn/test.html
MIT License
34 stars 9 forks source link

Feature Request: add multiple commands conversion #56

Open Jay-Karia opened 2 months ago

Jay-Karia commented 2 months ago

Is your feature request related to a problem? Please describe. Say I have to convert a npm command into pnpm, yarn and bun. I have to call the convert function 3 times to accomplish the task.

There should be a convenient way to do this.

Describe the solution you'd like I would like to introduce a new function convertMultiple to fulfill this task.

There could different use cases for it:

  1. One to many (convert one command into multiple package managers' equivalent)
convertMultiple("npm i next", ["pnpm", "bun"])
// ["pnpm add next", "bun add next"]
  1. Many to one (convert many commands into one 1 package manager's equivalent)
convertMultiple(["npm i eslint", "pnpm add react"], "yarn")
// ["yarn add eslint", "yarn add react"]
  1. Many to many (convert many commands into multiple package managers' equivalent)
convertMultiple(["bun add rollup", "npm i express"], ["yarn", "pnpm"])
/*
[
    ["yarn add rollup", "yarn add express"], 
    ["pnpm add rollup", "pnpm add express"]
]
*/
nebrelbug commented 2 months ago

I like the idea of this proposal, but I'm wary of adding too much complexity to this library. I feel like we'd want to rewrite it so that it first processed a string into an AST-like structure (e.g. type: "install", arg: "react nextjs tailwind", arguments: "save-dev") and then converted that to the desired format.

Jay-Karia commented 2 months ago

Say there's a block with two commands that needs to be converted Screenshot_20240827_053821_Chrome

the AST like structure might be inefficient.