Brewskey / spark-server

An API compatible open source server for interacting with devices speaking the spark-protocol
https://www.particle.io/
GNU Affero General Public License v3.0
54 stars 27 forks source link

.env not working if spark-server is used as dependency #272

Closed haeferer closed 6 years ago

haeferer commented 6 years ago

Within my project (https://github.com/keatec/spark-rabbit) i use spark-server as a dependency. this works well, except the update-Firmware does not work and so the whole NPM install for my package fails.

Reason: spark-server defines a postinstall script which is executed (correct!) but the .env file is not found (correct, it is not part of spark-server). The postinstall fails, so the package is removed and an error is raised (BAD)

Workaround: Install SparkProtocol and SparkServer using NPM INSTALL, provide GITHUB credentials using ENV

export GITHUB_AUTH_TYPE=oauth; export GITHUB_AUTH_TOKEN=<removed>; npm install git+https://github.com/Brewskey/spark-server.git#dev --unsafe-pem

Solution dotenv must lookup .env files also in directories above the CWD (which is default)

I will try to make a solution in my fork and make a PR if this works

jlkalberer commented 6 years ago

Thanks, if you come up with a solution that will be great.

The Brewskey project uses this as a dependency as well but we haven't upgraded to the newer version that uses .env files yet.

haeferer commented 6 years ago

I've found a Solution at my fork.

https://github.com/keatec/spark-protocol/commit/0687acb95ba61cfc1ec9b00208bb7be3c2e72f4a

I will make a PR after the PR regarding Download and Flashing.

brahma-dev commented 6 years ago

@jlkalberer https://github.com/Brewskey/spark-protocol/commit/37590ffab25f2cbe618cfef0feaf0fbd24ff0d17#r31348098

jlkalberer commented 6 years ago

@brahma-dev - thanks. I was testing on Windows and my solution worked for me. When I moved it to my Linux box it failed but I couldn't test much else otherwise my production service would go down.

@AntonPuko - can you patch the fix?

jlkalberer commented 6 years ago

This should be fixed now.