-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cli): remove pkg in favour of automatically downloading Node (…
…#454) ## Change Summary This PR completely refactors how the Prisma CLI is downloaded / installed / called. We now download Node itself at runtime and use that to install the Prisma CLI and then run it directly with Node as well. This has some significant advantages: - We are now no longer tied to releases of the packaged CLI - These were being released by Luca, who created the Go Client and is no longer at Prisma, on his own free time. - Only major versions were released which means the CLI couldn't be easily tested with the latest changes on the https://github.com/prisma/prisma repository - Prisma Studio can now be launched from the CLI - The TypeScript Client can now be generated from our CLI wrapper - We now longer have to manually download the engine binaries ourselves, that's handled transparently for us - A packaged version of Node no longer has to be installed for each new Prisma version - We now have support for ARM However, this does not come without some concerns: - Size increase - We use https://github.com/ekalinin/nodeenv to download Node at runtime if it isn't already installed. This downloads and creates extra files that are not strictly necessary for our use case. This results in an increase from ~140MB -> ~300MB. - - However this size increase can be reduced by installing [nodejs-bin](https://pypi.org/project/nodejs-bin/) which you can do by providing the `node` extra, e.g. `pip install prisma[node]`. This brings the total download size to be very similar to the packaged CLI. - This concern also doesn't apply in cases where Node is already present. It actually will greatly improve the experience in this case. ## How does it work? We now resolve a Node binary using this flow: - Check if [nodejs-bin](https://pypi.org/project/nodejs-bin/) is installed - Check if Node is installed globally - Downloads Node using https://github.com/ekalinin/nodeenv to a configurable location which defaults to `~/.cache/prisma-nodeenv` The first two steps in this flow can be skipped if you so desire through your `pyproject.toml` file or using environment variables. For example: ```toml [tool.prisma] # skip global node check use_global_node = false # skip nodejs-bin check use_nodejs_bin = false # change nodeenv installation directory nodeenv_cache_dir = '~/.foo/nodeenv' ``` Or using the environment variables, `PRISMA_USE_GLOBAL_NODE`, `PRISMA_USE_NODEJS_BIN` and `PRISMA_NODEENV_CACHE_DIR` respectively. The Prisma CLI is then installed directly from [npm](https://www.npmjs.com/package/prisma) and ran directly using the resolved Node binary.
- Loading branch information
1 parent
87d5e37
commit bd4446d
Showing
59 changed files
with
1,227 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,9 @@ | |
!src/ | ||
!tests | ||
!requirements/ | ||
!databases/ | ||
!lib/ | ||
!noxfile.py | ||
!pipelines/ | ||
!pytest.ini | ||
!MANIFEST.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ twine==4.0.1 | |
typer==0.7.0 | ||
rtoml==0.9.0 | ||
GitPython | ||
distro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
-r test.txt | ||
-r node.txt | ||
-r deps/pyright.txt | ||
interrogate==1.5.0 | ||
blue==0.9.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-r test.txt | ||
-r node.txt | ||
mypy==0.950 | ||
types-mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs-bin==16.15.1a4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ click>=7.1.2 | |
python-dotenv>=0.12.0 | ||
typing-extensions>=3.7 | ||
tomlkit | ||
nodeenv | ||
cached-property; python_version < '3.8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs-bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.