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

Adding plugins from GitHub/Gitlab repositories #548

Closed
rhumbertgz opened this issue Nov 4, 2022 · 2 comments
Closed

Adding plugins from GitHub/Gitlab repositories #548

rhumbertgz opened this issue Nov 4, 2022 · 2 comments

Comments

@rhumbertgz
Copy link

rhumbertgz commented Nov 4, 2022

Describe the bug
Installing a plugin from a Github/Gitlab manually or using the plugin-plugins doesn't work.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Cli
    npx oclif generate mynewcli

  2. Add Github dependency (it is just a fork without any change)
    yarn add https://github.com/rhumbertgz/plugin-commands.git

As result:

"dependencies": {
    "@oclif/core": "^1.19.1",
    "@oclif/plugin-commands": "https://github.com/rhumbertgz/plugin-commands.git",
    "@oclif/plugin-help": "^5"
  },
  1. Register plugin
"oclif": {
    "bin": "chm",
    "dirname": "chm",
    "commands": "./dist/commands",
    "plugins": [
      "@oclif/plugin-help",
      "@oclif/plugin-plugins",
     "@oclif/plugin-commands"
    ]
  }, 

Screenshots
After running the --help the new "commands" command doesn't appear

image

Environment (please complete the following information):

  • OS & version: [MacOS Monterey 12.6.1 (21G217)]
  • Shell/terminal & version [ zsh 5.8.1 (x86_64-apple-darwin21.0) ]
  • oclif 3.2.24
@mdonnalley
Copy link
Contributor

mdonnalley commented Nov 4, 2022

@rhumbertgz Thanks for creating the issue.

The problem is that when you install from github, gitlab, or a local project (using yarn add file:...) the dependency is added as a pure typescript project with no compiled javascript.

If you're doing this for local development purposes, I would suggest cloning the repo, building it, and then using yarn link to add the dependency to your project.

If you absolutely must import from github, you can update the bin/dev script to have ts-node not ignore the oclif plugins inside of node_modules, .e.g

require('ts-node').register({project, ignore: ['/node_modules/(?!@oclif/plugin-*)']})

However, I'd encourage you to steer away from that solution if possible.

This ts-node issue goes into more depth on the issue of having pure typescript modules in node_modules if you're interested: TypeStrong/ts-node#155

I'm going to close this issue for now but feel free to reopen if you think there's more to this than what I found.

@rhumbertgz
Copy link
Author

@mdonnalley thanks for reaching out with the explanation. I just installed private registry (Verdaccio) to make my development easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants