-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
cli: add global cache for binaries #1254
Conversation
79aa1da
to
22828b5
Compare
This closes cypress-io#1188
22828b5
to
556565c
Compare
So, I think it's good now, just waiting for comments 😄! One thing tho: I don't know how to test the functionality for real (which is not ideal of course). |
pinging @bahmutov My thoughts: There are some existing node modules that handle the "global cache" like this - which prevents you from having to build up the Alternatively - Cypress itself uses the "proper" application cache of the OS which we utilize here https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/app_data.coffee. It may make more sense to store the binaries there since we also give you a way to "View App Data" from the "File" menu from the GUI itself. It would make things more consistent and that code is already cross platform ready and would not create two different areas where we store data on your system. We'd need to extract this file into something more generic to make it available to the CLI. As for testing this code for real - you generally just start from another project and call directly into the CLI code by invoking |
@bahmutov thinking about this further.... Maybe instead of caching the zipped Cypress globally and then unzipping it into the This would save you from having Cypress (which is very large) installed on multiple projects. As long as they use the same version number they'd all use the exact binary. We'd have to likely come up with some new CLI flags to clear the cache when you want to do reinstall the binary or maybe a |
While I like where this is headed and it will help the issue, it won't resolve #1188 which seems to be that cloudflare is abysmal in the eastern hemisphere. Not only does re-downloading Cypress take 30 minutes, but the docs take an enormous amount of time to load. |
I'm all for unzipping into same folder by cypress version. Also finding a module that can help if possible because cross platform is a nightmare.
NPM cache location by default
```
Default: ~/.npm on Posix, or %AppData%/npm-cache on Windows.
```
From https://docs.npmjs.com/cli/cache though we have to be careful about storing anything in the NPM's cache. It can disappear or be blown away at any second. And guess what - NPM already caches package tgz file for us by version :)
```
$ l -R ~/.npm/cypress
total 0
drwxr-xr-x 4 gleb staff 136 Jan 1 16:21 1.4.1
drwxr-xr-x 4 gleb staff 136 Feb 4 21:52 1.4.2
/Users/gleb/.npm/cypress/1.4.1:
total 64
drwxr-xr-x 3 gleb staff 102 Feb 5 21:45 package
-rw-r--r-- 1 gleb staff 30327 Jan 1 16:21 package.tgz
/Users/gleb/.npm/cypress/1.4.1/package:
total 8
-rw-r--r-- 1 gleb staff 2135 Feb 5 21:45 package.json
/Users/gleb/.npm/cypress/1.4.2:
total 80
drwxr-xr-x 3 gleb staff 102 Feb 5 21:33 package
-rw-r--r-- 1 gleb staff 37472 Feb 4 21:52 package.tgz
/Users/gleb/.npm/cypress/1.4.2/package:
total 8
-rw-r--r-- 1 gleb staff 2134 Feb 5 21:33 package.json
```
Proposal: create another folder under NPM cache folder named `app`. Inside store unzipped Cypress in folders by version
```
~/.npm/cypress
/1.4.1 (package)
/1.4.2 (package)
/app
/1.4.1
/Cypress.app
info.json
/1.4.2
/Cypress.app
info.json
```
Maybe even as a first step add a flag to CLI to check and load Cypress app from a given folder?
… On Feb 6, 2018, at 23:53, Paul Falgout ***@***.***> wrote:
While I like where this is headed and it will help the issue, it won't resolve #1188 which seems to be that cloudflare is abysmal in the eastern hemisphere. Not only does re-downloading Cypress take 30 minutes, but the docs take an enormous amount of time to load.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
// ... and also add it to the global cache | ||
fs.copy( | ||
options.downloadDestination, | ||
`${home}/.cypress/${options.version}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should never concatenate paths ourselves (Windows ...)
BTW last comment: I usually do not struggle with Cypress installs because I use https://github.com/bahmutov/have-it to pull an alias from some other project that already has it installed
|
@maxime1992 I will close this request in favor of #1300 - reusing same binary from different projects. This will avoid custom code and will do the same caching as other projects are doing (like Electron). |
Global cache will speed up local development when running
npm i
oryarn
.It'll downloaded Cypress binaries once and if available, next time will only get the cached one.
I believe it might also be safer for projects using Cypress to cache only that global cache folder + yarn or npm cache on CI instead of the whole node_modules.
This closes #1188