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

How to "compile" this plugin for testing? #28

Open
drakkhen opened this issue Sep 12, 2021 · 3 comments
Open

How to "compile" this plugin for testing? #28

drakkhen opened this issue Sep 12, 2021 · 3 comments

Comments

@drakkhen
Copy link
Contributor

drakkhen commented Sep 12, 2021

@trympet: I realize this is WELL outside the scope of this particular project, and forgive me for creating a separate "Issue", but I figured that might be the most appropriate method..

I'm a grey-bearded Javascript (and other languages) developer. I only really understand traditional in-browser javascript, but I'm trying to to get up to speed on modern JS/TS development. There's a lot (LOT) to learn!

Since I'm tinkering with this plugin, I'd like to use my fork as the source on my own Homebridge instance. But when I did sudo npm install -g github:drakkhen/homebridge-volvo on my pi the plugin did not work at all. It installed without any explicit errors but the /usr/lib/node_modules/homebridge-volvo directory did not contain a dist/ directory (it had node_modules and a few other files but nothing from src/). Seems like some post-processing/building did not trigger.

I'm totally at a loss as to what magic duct-tape didn't fire off to make my github-based-npm-install work. I simply forked the repo and make a few tiny changes, but I don't get why the build process would be affected.

Do you have any tips or resources that you can link me to so that I can use my fork for final testing before submitting PRs? Thanks!

@trympet
Copy link
Owner

trympet commented Sep 13, 2021

Thank you for your interest in the project!

Since I'm tinkering with this plugin, I'd like to use my fork as the source on my own Homebridge instance. But when I did sudo npm install -g github:drakkhen/homebridge-volvo on my pi the plugin did not work at all. It installed without any explicit errors but the /usr/lib/node_modules/homebridge-volvo directory did not contain a dist/ directory

This is expected behavior. AFAIK, the dist folder is not part of the package layout -- only an intermediate staging directory for packaging / "compiled" code locally. My guess is that the files you saw were originally from the root of the dist folder when I built the package.

I'm totally at a loss as to what magic duct-tape didn't fire off to make my github-based-npm-install work. I simply forked the repo and make a few tiny changes, but I don't get why the build process would be affected.

It happens to the best of us! You should be able to get it up and running by

  1. Clone your fork on your pi.
  2. Install the typescript compiler: sudo npm install -g typescript
  3. Install local package dependencies of homebridge-volvo: npm install
  4. Build and run: npm run dev

npm run dev is a custom build command, which executes the following: npm run build && DEBUG=* /usr/bin/node --inspect-brk /usr/bin/homebridge -P $PWD -D. It launches homebridge, instructing it to look for plugins in $PWD, and break before execution.

You can then attach chrome to step though your code.

Feel free to let me know if you have any further questions 😄

@drakkhen
Copy link
Contributor Author

Ah, so when you make a release and push it to npm, does the npm server-side service read the package.json file to see what needs to run to make a build (scripts.publish_only's value, I assume), then create the dist/ directory on their side, and then when users run npm install homebridge-volvo simply copies the pre-built dist/ folder over?

As for dev... oh wow that sounds a LOT better than what I have been doing -- definitely looking forward to trying that out!

@trympet
Copy link
Owner

trympet commented Sep 18, 2021

Yes, you are correct, except the package is built locally. If you execute npm run build, you will see that the dist folder is populated. The build is done with the typescript compiler, since typescript is not executable by the js interpreter. You can read more here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants