currents-dev / cli

0 stars 0 forks source link

Currents is not working with yarn 3 #3

Closed adrienharnay closed 2 years ago

adrienharnay commented 2 years ago

Hello,

I just upgraded a project from Yarn 1 to Yarn 3 (without Plug'n'Play), and now Currents is not able to find cypress.

Error: Cannot detect cypress. Is cypress installed?

I see the code relies on npm-which, which has not been updated for 6 years. When logging into getStateModulePath in cy2/lib/patch.js, here is the result of the candidates variable:

[
  '/private/var/folders/kb/0ht5tzkd6knbz4wn7nfpnfwh0000gn/T/xfs-91d8a950/node_modules/cypress/lib/tasks/state.js',
  '/private/var/folders/kb/0ht5tzkd6knbz4wn7nfpnfwh0000gn/T/lib/tasks/state.js',
  '/private/var/folders/kb/0ht5tzkd6knbz4wn7nfpnfwh0000gn/T/cypress/lib/tasks/state.js'
]

Do you think the logic could be updated to support Yarn 3 as more and more people are migrating to it?

Thanks in advance and have a nice evening

agoldis commented 2 years ago

Hey @adrienharnay can you please try using @currents/cli@2.0.0-beta.0


~ ❯ mkdir yarn3
~ ❯ cd $_
yarn3 ❯ yarn init -y
{
  name: 'yarn3',
  packageManager: 'yarn@3.2.0'
}
yarn3 ❯ touch yarn.lock
yarn3 ❯ yarn --version
3.2.0
yarn3 ❯ node --version
v16.14.0

yarn3 ❯ yarn add cypress @currents/cli@2.0.0-beta.0
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 1s 82ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ wrap-ansi@npm:6.2.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wrap-ansi@npm:7.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wrappy@npm:1.0.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yallist@npm:4.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yauzl@npm:2.10.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 6s 86ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ cypress@npm:9.5.1 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 1s 427ms
➤ YN0000: Done with warnings in 8s 623ms

yarn3 ❯ yarn currents --help
[currents] Running cypress with API URL: https://cy.currents.dev
Usage: cypress <command> [options]

Options:
  -v, --version      prints Cypress version
  -h, --help         display help for command

Commands:
  help               Shows CLI help and exits
  version            prints Cypress version
  open [options]     Opens Cypress in the interactive GUI.
  run [options]      Runs Cypress tests from the CLI without the GUI
  open-ct [options]  Opens Cypress component testing interactive mode.
  run-ct [options]   Runs all Cypress Component Testing suites
  install [options]  Installs the Cypress executable matching this package's version
  verify [options]   Verifies that Cypress is installed correctly and executable
  cache [options]    Manages the Cypress binary cache
  info [options]     Prints Cypress and system information
adrienharnay commented 2 years ago

Hi @agoldis, thanks a lot! I confirm the new version works with Yarn 3.