jansmolders86 / mediacenterjs

A HTML/CSS/Javascript (NodeJS) based Media center
http://mediacenterjs.com
1.29k stars 243 forks source link

Installation method #144

Closed tracker1 closed 8 years ago

tracker1 commented 10 years ago

I propose that the installation method take the following convention.

npm install -g mediacenterjs
mediacenterjs initialize

This came out of a conversation with #143 and I feel that it's probably the right way to install an application via npm. This would allow for a common installation path, as well as future upgrades?

The data/configuration files should be in the global paths for the platform... /etc/mediacenterjs/mediacenterjs.conf and /var/mediacenterjs/* ... perhaps overridable via environment variable.

This would mean adding an entry for a mediacenterjs script that takes an initialize command. Which would make sense.

NOTE: probably needs sudo for *nix installs, not sure about cross-platform (Windows) support.

jansmolders86 commented 10 years ago

What a great solution Tracker1! I'll have to dig into this a bit to get this to work though!

Do you have any resources I can read to understand better what needs to be done?

Thanks again! Jan

tracker1 commented 10 years ago

If you look at less for an example, you'll see a bin directory with a node script that is simply called lessc It's an actual node script, it's worth noting that this could have been called lessc.js, it's just by convention. The core is that you have a script that will work as the "binary" that is called.

From there, in the package.json you'll note a bin section that is an object mapping lessc to ./bin/lessc (the right side can be any valid node script) ... npm install, when your module comes out of npm will essentially build a shim/script for nix and windows environments... for example, in my ~/AppData/Roaming/npm there is a lessc and a lessc.cmd file...

NOTE: the files below are automatically generated by npm, so you don't need to worry about them... all you need is a "bin" reference to your script that is to be run via node myscript ...

lessc

#!/bin/sh
basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/node_modules/less/bin/lessc" "$@"
  ret=$?
else 
  node  "$basedir/node_modules/less/bin/lessc" "$@"
  ret=$?
fi
exit $ret

lessc.cmd

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\node_modules\less\bin\lessc" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\node_modules\less\bin\lessc" %*
)
jansmolders86 commented 9 years ago

Hey @tracker1,

First of all, sorry it took me so long to get around doing this. I added a binary and pointed it out in the package JSON. Will this be sufficient to have proper handling of npm install -g?

Thanks for your help!

Jan

jansmolders86 commented 9 years ago

@tracker1 Is the bin dir mandatory? Or can i place the file in the root as well?