-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve --install
#525
Comments
We can avoid this side effect by using the package manager: |
However, this way is not so convenient as just |
Today I played with it and wrote a simple They get required versions of packages from It could be good to have similar functionality just with |
But is it a problem? Will npm check what package is already installed and it will be noop.
I this this is a feature! Each script can have each own versions. One is using ^2, other ^1. Yes ncu will not detect version/packages. For outdated versions we can create separate package for checking and updating comments (zx-check-updates).
I'm not familiar with this setup. ¯\_(ツ)_/¯
For example?
What about different version per script? Also Keeping deps and version in one place is better. |
In some cases, this check can take a long time - 2 days ago in one project it took about 5 minutes without installing anything - and it was one of the reasons why I wrote this issue.
A good practice is defining dependencies in one place - each new place where dependencies are defined, even with a new tool for controlling versions - is a pain. It's a good practice to reuse one dependency in different places of the project - however, if required to use different versions, it's not a big problem to specify it as a comment / in a local, not the root,
However, it's a significant use case. For example, here we use
I think that already shown cases are enougth.
See above. |
I guess we can check what node_modules/foo exists, but what about checking the version? Why npm is so slow about it?
We already have package.json and zx scripts can use project deps. The --install feature is useful for standalone scripts, or scripts fetched from the web.
Let's explore the problem space ) |
At least, NPM uses ranges and checks for new versions.
Such scripts can be in the scope of the project - for example, for CI is useful granular loading of dependencies - in one task linting, in another NodeJS testing (with different versions, so cache does not work), in one more - browsers, etc. Some scripts can be standalone and used only locally - but too often they should reuse the same dependencies as the rest project.
I already updated this comment:
|
(Note that I forgot that |
Let’s try to break down to a few smaller parts what easier to implement. |
It can be related oven-sh/bun#1459 |
Is this |
I think zx should not try to replace the package manager. I suggest using script composition for complex corner cases instead:
import {$, cd} from 'zx'
// read your deps from anywhere
const deps = Object.entries(fs.readJsonSync("package.json").dependencies).reduce(...).join(' ')
// need isolated scope?
// cd('your/temp')
// check `./node_modules`, verify ranges with semver, modify deps, etc
// use any package manager for setup
await $`npm i ${deps}`
// use zx to run zx :-)
await $`zx script.js` |
@antonmedv it's not about a replacement of the package manager, it's about calling a package manager when it's required. Just like in this wrapper, but from the box - since for my use cases that's required too frequently. |
--install
option is an interesting feature. When you maintain a big project, it could significantly help you - for example, avoid loading to CI unnecessary heavy dependencies that are used only in some scripts. However, now this option has some significant issues.workspaces
) also installed and resolved incorrectly.node_modules
of the project before installing.package.json
(top-level of the project or defined in another place) without installing those dependencies. In the case of the top-levelpackage.json
, it can beoptionalDependencies
.The text was updated successfully, but these errors were encountered: