.jsan packaging -- making it work with npm ver 1+

Skip to first unread message

Michael Bradley, Jr.

Jul 2, 2011, 7:04:52 PM7/2/11
to joos...@googlegroups.com
Node v0.4.9 came out a couple of days ago, and when I went to tinker with it this morning, I bumped up against the ".jsan packaging" issue again.

What I mean, more specifically, is that I'm using Tim Caswell's nvm which when I ask it to install a new version of node automatically installs the most recent stable version of npm along with it (quite convenient).  But when I run, say:

$ npm install task-joose-nodejs

(and I have `global = true` in my ~/.npmrc)

When I go to look for the .jsan directory in:


It's not there, nor elsewhere ..... so I put on my best sleuthing hat today and here's what I figured out:

If I do:

$ cd ~/.nvm/v0.4.9/lib/node_modules/task-joose-node-js
$ chmod +x __script/postactivate.sh
$ export npm_config_root=/Users/michael/.nvm/v0.4.9/lib/
$ __script/postactivate.sh

Tada!!  Now the .jsan directory is in place and the files I want and expect are inside, ready for use with JooseX.Namespace.Depended (assuming I have the NODE_PATH environment variable set properly)


So why isn't it that script running as part of `npm install ...` ?

I think the answer is that within a script in Nickolay's Dist-Zilla-Plugin-JSAN plugin, the keyword that's being specified in the package.json file (built by that script) is deprecated:

   $package->{ scripts }   = {
         "postactivate" => '$SHELL __script/postactivate.sh'

See the current npm documentation (and or the man page with `npm help scripts`):

There's no mention of `postactivate`; perhaps it should be changed to postinstall?

Nickolay Platonov

Jul 3, 2011, 4:51:30 AM7/3/11
to joos...@googlegroups.com
Good finding!

Right, seems there's no "postactivate" stage anymore and scripts should switch to "postinstall".

Hopefully I'll be able to revise the dzil plugin soon (we are now using it at $work btw :)


You received this message because you are subscribed to the Google Groups "Joose" group.
To view this discussion on the web visit https://groups.google.com/d/msg/joose-js/-/UhcTmqbKnKwJ.
To post to this group, send email to joos...@googlegroups.com.
To unsubscribe from this group, send email to joose-js+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joose-js?hl=en.


Michael Bradley, Jr.

Jul 3, 2011, 9:37:04 PM7/3/11
to joos...@googlegroups.com
Sounds good, in the meantime I've cooked up the following shell script.......


export npm_config_root=$(npm root -g 2>/dev/null)

cd $npm_config_root

find . -name postactivate.sh -exec chmod +x '{}' \;

scripts=$(find . -name __script -type d)

for script in $scripts
 cd $script
 cd ..
 cd $npm_config_root

At that point, the `.jsan` directory will be located (and properly populated) in $npm_config_root ; for me that's currently:


Keep in mind you'll want something like the following your in ~/.bashrc or .bash_profile, etc. (ignore the nvm stuff if you're not using nvm)

. $NVM_DIR/nvm.sh
nvm use v0.4.9

export NODE_PATH=$(npm root -g 2>/dev/null):$(npm root -g 2>/dev/null)'/.jsan'

(I'm sure you already have your env setup properly, Nickolay, but I'm noting it for others who may read this thread.)

Reply all
Reply to author
0 new messages