Comments (2)
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.
Cleaning up - if you think this issue is still valid, reopen it. Thanks!
from oclif.
Related Issues (20)
- Drop dependency on `yosay` HOT 2
- infected with virus? HOT 3
- how to build and run? HOT 7
- Dynamic flags? HOT 1
- Bug: eslint - typescript support for 4.9.5 HOT 3
- how to remove "See code" from readme? HOT 8
- Bug: `enableJsonFlag` flag not working with flags and/or args? HOT 1
- Bug: AccessDenied during oclif promote
- 安装报错 HOT 2
- Oclif's bin/dev is not able to expand tsconfig paths and fails HOT 3
- Allow to change oclif's hardcoded sections' words to another idiom
- can i create multi cli bin in a single package HOT 3
- With ESM, `this.configDir` returns `~/.config/ts-node` on static `.run()` HOT 2
- cryptic "command not found" returned on typercript transpile error HOT 1
- MODULE_NOT_FOUND] import() failed to load Library HOT 1
- Verifying shasum for Node.js dist causing `oclif pack` to fail nondeterministically on some Linux distros HOT 8
- How to generate documentation in a file other than README.md using oclif? HOT 4
- Conflict between the vscode formatting/prettier default configuration and the lint of oclif HOT 1
- Full stack trace displayed rather than pretty printed error
- vite-node incompatible with oclif
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oclif.