Skip to content
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

Capacitor: run executors runs the incorrect cap #915

Open
distante opened this issue Mar 16, 2023 · 5 comments
Open

Capacitor: run executors runs the incorrect cap #915

distante opened this issue Mar 16, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@distante
Copy link

Describe the bug
Running @nxext/capacitor:cap:run will try to install package=@capacitor/cli instead of using the one found on node_modules

To Reproduce
call @nxext/capacitor:cap run

Expected behavior
Run should call the existing @capacitor/cli from node_modules

Additional context
The problem was introduced by #817

@borgoat
Copy link

borgoat commented Apr 25, 2023

It took me longer than I care to admit to debug this while attempting to update to Capacitor 5...

In the end, I reverted back to plain nx:run-commands in my executors:

    "update": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "apps/mobile",
        "command": "cap update"
      },
      "configurations": {
        "ios": {
          "ios": {
            "command": "cap update ios"
          },
          "android": {
            "command": "cap update android"
          }
        }
      }
    },

I believe this plugin should do the same in fact, and not even invoke npx. It should let Nx do its thing, and avoid forcing another version of users. We can expect quite some troubles when version 5 will be in general availability, and npx will default to that.

@muuvmuuv
Copy link

@borgoat how do you invoke the configuration? You nested ios.android because..?

@muuvmuuv
Copy link

Ok so we migrated to this and I think this is enough:

"capacitor": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "apps/project",
        "commands": [
          {
            "command": "capacitor",
            "forwardAllArgs": true
          }
        ]
      }
    }
pnpm nx run project:capacitor copy ios

@borgoat
Copy link

borgoat commented May 31, 2023

@borgoat how do you invoke the configuration? You nested ios.android because..?

Sorry, you can ignore that part... a copy-paste mistake I guess. I think we wrongly copied it from other tasks such as "open" and "run" to do platform specific things, but for sync we always invoke just 1 command for both platforms: nx sync mobile.

@muuvmuuv
Copy link

btw. if you dont want to run this long NX command, you can install npm-run-all and shorten it to just pnpm cap copy ios with:

"cap": "npm-run-all \"nx run project:capacitor {@}\" --",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants