Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any 3rd party package manager #15622

Closed
1 task done
Jordan-Hall opened this issue Mar 12, 2023 · 10 comments
Closed
1 task done

Allow any 3rd party package manager #15622

Jordan-Hall opened this issue Mar 12, 2023 · 10 comments
Assignees

Comments

@Jordan-Hall
Copy link
Contributor

Description

Currently NX supports 3 package managers, npm, yarn and pnpm. This is great however, I think we should allow for any package manager but add a warning to the console log saying something like "You are using a unknown / unsupported package manager"

Motivation

I think they some great tools out there and NX should be agnostic as possible and focus on what it does the best. This would allow community to build great community plugins.

I've been looking at bun support and it would allow use to create workspaces with bun install rather than npm first.

Suggested Implementation

Currently you work on a switch statement, If you try and use one you get the following error
Argument: packageManager, Given: "bun", Choices: "npm", "pnpm", "yarn"

I think it should assume the package manager has an install method and attempt to use package name install

Alternate Implementations

Could add another argument like

npx create-nx-workspace@latest --packageManager bun --packageInstaller install --ignoreScripts

@Jordan-Hall
Copy link
Contributor Author

Jordan-Hall commented Mar 12, 2023

I think it will need two new options

.option('packageInstaller', {
  alias: 'pi',
  describe: chalk.dim`Custom package installer e.g. install --silent --ignoreScripts`,
  type: 'string',
})
.option('packageExc', {
  alias: 'pi',
  describe: chalk.dim`Custom package exc e.g. npx`,
  type: 'string',
})

@AgentEnder AgentEnder added the scope: core core nx functionality label Mar 13, 2023
@AgentEnder
Copy link
Member

This is something I've thought a bit about too, but isn't something that we have settled on an api for yet. I think it's more likely something that we would add plugin support for, via something like:

export interface NxPlugin {
  // ... other existing extension points

  providesPackageManagers: () => Record<string, PackageManager>
}

@Jordan-Hall
Copy link
Contributor Author

Would the plugin work for something like Nx init or create-nx-workspace? Using that API would be lovely though

@AgentEnder
Copy link
Member

It would be something you'd have to configure afterwards, I could see an alternative for create nx workspace or nx init that is just --install-command or something

@Jordan-Hall
Copy link
Contributor Author

@AgentEnder Happy to take a look at this if you want, it be nice and I can use Bun as proof of concept in using it

@Jordan-Hall
Copy link
Contributor Author

Jordan-Hall commented Aug 26, 2023

So thinking about it. This could be done with nx.json adding a packageManager which supports the current three as a string form then provide a common interface for interacting with package mangers.

Just like you have with task runner.

{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "affected": 
  "tasksRunnerOptions": 
  "targetDefaults": 
  "namedInputs": {
  "packageManager: 'nx/packageManager' // example but you could just as easy have npm, yarn or pnpm here else a export default path here
}

The export for the package would be what you have in package-manager.ts

{
        install: 'npm install',
        ciInstall: 'npm ci',
        add: 'npm install',
        addDev: 'npm install -D',
        rm: 'npm rm',
        exec: 'npx',
        run: (script: string, args: string) => `npm run ${script} -- ${args}`,
        list: 'npm ls',
      };
      
  Then all you need to do is update package-manager.ts to read from NX.json file

@ffMathy
Copy link

ffMathy commented Jan 16, 2024

@AgentEnder any thoughts on this?

Would love to see this supported.

@Jordan-Hall
Copy link
Contributor Author

@meeroslav is there anything or tasks list you can produce to move package manager to nx/js happy to try and help move it along. Think that's a good idea for repository away from JS

Copy link

This issue has been automatically marked as stale because it hasn't had any activity for 6 months.
Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore.
If at this point, this is still an issue, please respond with updated information.
It will be closed in 21 days if no further activity occurs.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Sep 30, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants