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

add support for npm install #46

Open
woloski opened this issue Jun 23, 2012 · 11 comments
Open

add support for npm install #46

woloski opened this issue Jun 23, 2012 · 11 comments

Comments

@woloski
Copy link
Contributor

woloski commented Jun 23, 2012

Things to take into account

  • Support for multiple apps
  • Compat between npm and node engines declared in the app

cc @johnnyhalife

@tjanczuk
Copy link
Owner

We should also consider the impact of running npm install on the latency of application update. Npm adds a few seconds to the process. I think there are a few approaches we can take:

  • bite the bullet and see and see how it goes: just run npm install on all apps after post receive hook
  • be more selective: only run npm install for the apps that have actually changed in the process (inspect the payload of the post receive hook)
  • be even more selective: only run npm install for applications which dependencies have changed (based on package.json content)
  • make it manual, e.g. git azure reset --npm

I lean towards somewhere between the last two options.


From: Matias Woloski [[email protected]]
Sent: Saturday, June 23, 2012 9:04 AM
To: Tomasz Janczuk
Subject: [git-azure] add support for npm install (#46)

Things to take into account

  • Support for multiple apps
  • Compat between npm and node engines declared in the app

Reply to this email directly or view it on GitHub:
#46

@woloski
Copy link
Contributor Author

woloski commented Jun 23, 2012

option 3 is ideal, so the process would be:

Analysis

  1. foreach commit in postreceive hook, search each file added or modified.
  2. If the $file == package.json then add an item to a hash { "$app_name" : package }
  3. If hash not empty, iterate through it and compare package.depdendencies with the current package.json for the app. If depdendencies are equal, remove item from hash

Execution

  1. If hash is not empty, iterate throguh it and run npm install for each app int he hash

I would have option 4 as a backup strategy if something went out of sync.

This logic sounds like it will have to go in arr.js, not batch.

@tjanczuk
Copy link
Owner

I wonder if we can save ourselves the step of groveling through the data in the post receive hook and just inspect package.json files for all apps. After all, how many are there going to be?


From: Matias Woloski [[email protected]]
Sent: Saturday, June 23, 2012 11:15 AM
To: Tomasz Janczuk
Subject: Re: [git-azure] add support for npm install (#46)

option 3 is ideal, so the process would be:

Analysis

  1. foreach commit in postreceive hook, search each file added or modified.
  2. If the file == package.json then add an item to a hash { "app_name" : package }
  3. If hash not empty, iterate through it and compare package.depdendencies with the current package.json for the app. If depdendencies are equal, remove item from hash

Execution

  1. If hash is not empty, iterate throguh it and run npm install for each app int he hash

I would have option 4 as a backup strategy if something went out of sync.

This logic sounds like it will have to go in arr.js, not batch.


Reply to this email directly or view it on GitHub:
#46 (comment)

@johnnyhalife
Copy link

+1 on running the npm install for every package. I think as part of the doc we should advise people on running npm shrinkwrap and avoid latest packages to reduce the latency. Anyway, I don't think npm adds much latency, as different vendors (like Heroku or Nodejitsu) do that per deployment and experience is yet perceived as awesome.

@johnnyhalife
Copy link

I was playing today with NPM on the machine I'm using with git-azure and I've learned so far:

  • In order for it to work we need to make sure that npm (which is a cmd) is copied over for each engine
  • The arr.js should be the one in charge of running the npm using the proper version (basically express doesn't work >= 7 and it fails with the bundled npm install)
  • Once you have all that it works seamlessly

May be tonight, I'll start prototyping this, as I'm needing it right now.

@tjanczuk
Copy link
Owner

Great data. Do you know if npm can be run SxS? Doesn't it have some global cache?

@johnnyhalife
Copy link

As far as I've seen it's a CMD, it looks for node.exe on the current directory and if not it uses the global alias, I ran it SxS on my machine by doing that copy (mentioned above)

@tjanczuk
Copy link
Owner

@gblock, did we learn anything from Isaak regarding running npm SxS?

@woloski
Copy link
Contributor Author

woloski commented Jun 25, 2012

Also, I remember the issue @gblock had with the npm cache http://codebetter.com/glennblock/2012/02/27/my-tale-of-npm-woe-when-all-else-fails-clear-you-cache/ ... not sure how he got to that state... but if that happens on git-azure runtime this git azure reset --npm should run npm cache clean

@johnnyhalife
Copy link

Definitely copying npm.cmd, npm and node_modules from %programfiles(x86)%\nodejs to .\runtime\engines\vX is the way to work. It definitely works great, I've repeated the steps my self through SSH and it works SxS with other npm installations (0.7.x - default one)

I'm trying to get our app to work on Windows Azure, but I've installed a Windows hence I'll be able to work on this a little bit more (for getting npm support)

@glennblock
Copy link

npm is just a node cli. It should work side by side fine. It does use a cache, but that is configurable.

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

4 participants