-
Notifications
You must be signed in to change notification settings - Fork 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
feat(cli): Allow to use capacitor commands in custom platforms #3091
Conversation
I'm thinking we actually should implement
Then, when using
Once the package is resolved, it runs the |
@jcesarmobile @IT-MikeS please review |
Haven't been able to dig a ton but this current state works for me in testing after Only issue I found in the little time I got was that we lose the console output from the script that is run via |
@IT-MikeS I noticed that, too. If you don't mind, I'd like to tackle that at a later time. It may require some CLI refactoring. |
@dwieeb Yeah thats fine, it functions, and the logs do show after the script ends so if an error is thrown the user can see it and deal with it. Just need to make sure error origins are clear in the scripts, but that's up to the custom platform 👍 |
This PR (jcesarmobile#1) uses spawn instead of exec to run commands and thus doesn't hide live console output. |
To sum up, we want this feature to go into 2.3.0 so people can start using @IT-MikeS's new electron platform. We can't remove the existing electron platform without a breaking change (see #3140). So, the caveat is that people will need to use the commands like this until Capacitor 3:
Instead of simply using @IT-MikeS's PR is a quick fix to achieve more advanced output from the platform (we talked about it). For Capacitor 3, I would like to refactor how the Capacitor CLI handles subprocesses. |
fix: support console output for platform hooks
should we also add an open command? |
Yes. If platforms can't handle it, they can just print a message. |
I agree with adding it. I'll put one in the community platform |
I can't approve since the PR was originally mine, but looks good, updated my test platform and all commands work fine. |
Co-authored-by: Dan Imhoff <[email protected]> Co-authored-by: Mike S <[email protected]>
Co-authored-by: Dan Imhoff <[email protected]> Co-authored-by: IT-MikeS <[email protected]>
This is a POC
It allows to have custom platforms in Capacitor
Example platform https://github.com/jcesarmobile/test-platform
Steps to test:
npm install https://github.com/jcesarmobile/test-platform
npx cap add @jcesarmobile/test-platform
,npx cap copy @jcesarmobile/test-platform
,npx cap update @jcesarmobile/test-platform
,npx cap sync @jcesarmobile/test-platform
,npx cap open @jcesarmobile/test-platform
.Custom platforms need 4 scripts in scripts section of
package.json
(not all mandatory if the platform don't need them, but will show an error)sync runs copy + update
At first I also did a
npx cap add customPlatorm
command that just ran npm install on the custom platform (could be http url, npm package, local folder, etc. whatever npm install supports), but then thought it might not be a good idea as it install the package and might install the wrong thing if the user type it wrong, so I think it's better not to wrap it and just tell the user to use npm install