Code Monkey home page Code Monkey logo

Comments (2)

jdxcode avatar jdxcode commented on May 31, 2024

This is doable as a plugin—though it'd be a bit of a strange one. You would have an init hook in the plugin that would proxy over to the locally installed CLI. I'm not sure I would load it though, it'd be safer across versions to use child_process to run the bin. That way if you ever wanted to migrate away from oclif or oclif internals changed significantly in a major release it would continue to work. You don't have to know about the internals that way either.

As far as the version command, that's a bit more difficult but still doable. You'd have to have a custom main multi class that would override the behavior of the version flags. To make that easier, I could add a version hook to listen to so instead it would just be a matter of listening to the version hook.

In terms of fetching the version, I would set an environment variable when launching the dev CLI like CLARK_PARENT_VERSION=1.0.0.

Alternatively, you could just use npx. It's made to solve this problem though I don't know how well it would work in a lerna setup.

Right now this all seems pretty complex though. I wouldn't recommend any kind of automatic switching because I think it would be surprising to the end-user. I understand the issue though. What I do in this case is install CLIs globally but lock down the major version in CI environments like this:

yarn global add mycli@2
mycli foobar

But you could also use npx:

npx mycli@2 foobar

That way you retain some control over the version of the CLI but don't need to execute it under node_modules. It's not a perfect solution but it's the simplest and best pattern I've seen for node CLIs.

from oclif.

RasPhilCo avatar RasPhilCo commented on May 31, 2024

Cleaning up - if you think this issue is still valid, reopen it. Thanks!

from oclif.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.