"npm Logo" created by Mathias Pettersson and Brian Hammond,
used with permission.
+"Gubblebum Blocky" font
+Copyright (c) 2007 by Tjarda Koster, http://jelloween.deviantart.com
+included for use in the npm website and documentation,
+used with permission.
+
This program uses "node-uuid", Copyright (c) 2010 Robert Kieffer,
according to the terms of the MIT license.
process.title = "npm"
-var log = require("../lib/utils/log.js")
-log.waitForConfig()
-log.info("ok", "it worked if it ends with")
+var log = require("npmlog")
+log.pause() // will be unpaused when config is loaded.
+log.info("it worked if it ends with", "ok")
var fs = require("graceful-fs")
, path = require("path")
process.argv.splice(1, 1, "npm", "-g")
}
-log.verbose(process.argv, "cli")
+log.verbose("cli", process.argv)
var conf = nopt(types, shorthands)
npm.argv = conf.argv.remain
return
}
-log.info("npm@"+npm.version, "using")
-log.info("node@"+process.version, "using")
+log.info("using", "npm@%s", npm.version)
+log.info("using", "node@%s", process.version)
// make sure that this version of node works with this version of npm.
var semver = require("semver")
Always create a new Error object with your message. Don't just return a
string message to the callback. Stack traces are handy.
-Use the `require("./utils/log").er` function. It takes a callback and an
-error message, and returns an object that will report the message in the
-event of a failure. It's quite handy.
-
- function myThing (args, cb) {
- getData(args, function (er, data) {
- if (er) return log.er(cb, "Couldn't get data")(er)
- doSomethingElse(data, cb)
- })
- }
- function justHasToWork (cb) {
- doSomething(log.er(cb, "the doSomething failed."))
- }
-
## Logging
+Logging is done using the [npmlog](https://github.com/isaacs/npmlog)
+utility.
+
Please clean up logs when they are no longer helpful. In particular,
logging the same object over and over again is not helpful. Logs should
report what's happening so that it's easier to track down where a fault
occurs.
-Use appropriate log levels. The default log() function logs at the
-"info" level. See `npm-config(1)` and search for "loglevel".
+Use appropriate log levels. See `npm-config(1)` and search for
+"loglevel".
## Case, naming, etc.
* the globally installed version is identical to the version that is
being installed locally.
-### logfd
-
-* Default: stderr file descriptor
-* Type: Number or Stream
-
-The location to write log output.
-
### loglevel
* Default: "http"
Any logs of a higher level than the setting are shown.
The default is "http", which shows http, warn, and error output.
-### logprefix
-
-* Default: true on Posix, false on Windows
-* Type: Boolean
-
-Whether or not to prefix log messages with "npm" and the log level. See
-also "color" and "loglevel".
-
### long
* Default: false
A node module to `require()` when npm loads. Useful for programmatic
usage.
-### outfd
-
-* Default: standard output file descriptor
-* Type: Number or Stream
-
-Where to write "normal" output. This has no effect on log output.
-
### parseable
* Default: false
<p>This function should not be used programmatically. Instead, just refer
to the <code>npm.bin</code> member.</p>
</div>
-<p id="footer">bin — npm@1.1.24</p>
+<p id="footer">bin — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This command will launch a browser, so this command may not be the most
friendly for programmatic use.</p>
</div>
-<p id="footer">bugs — npm@1.1.24</p>
+<p id="footer">bugs — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/index.html">index(1)</a></li></ul>
</div>
-<p id="footer">commands — npm@1.1.24</p>
+<p id="footer">commands — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/npm.html">npm(3)</a></li></ul>
</div>
-<p id="footer">config — npm@1.1.24</p>
+<p id="footer">config — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/publish.html">publish(3)</a></li><li><a href="../api/unpublish.html">unpublish(3)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">deprecate — npm@1.1.24</p>
+<p id="footer">deprecate — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This command will launch a browser, so this command may not be the most
friendly for programmatic use.</p>
</div>
-<p id="footer">docs — npm@1.1.24</p>
+<p id="footer">docs — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Since this command opens an editor in a new process, be careful about where
and how this is used.</p>
</div>
-<p id="footer">edit — npm@1.1.24</p>
+<p id="footer">edit — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The first element in the 'args' parameter must be a package name. After that is the optional command, which can be any number of strings. All of the strings will be combined into one, space-delimited command.</p>
</div>
-<p id="footer">explore — npm@1.1.24</p>
+<p id="footer">explore — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The silent parameter is not neccessary not used, but it may in the future.</p>
</div>
-<p id="footer">help-search — npm@1.1.24</p>
+<p id="footer">help-search — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p><a href="../doc/json.html">json(1)</a></p>
</div>
-<p id="footer">init — npm@1.1.24</p>
+<p id="footer">init — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Finally, 'callback' is a function that will be called when all packages have been
installed or when an error has been encountered.</p>
</div>
-<p id="footer">install — npm@1.1.24</p>
+<p id="footer">install — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Now, any changes to the redis package will be reflected in
the package in the current working directory</p>
</div>
-<p id="footer">link — npm@1.1.24</p>
+<p id="footer">link — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>For a list of all the available command-line configs, see <code>npm help config</code></p>
</div>
-<p id="footer">load — npm@1.1.24</p>
+<p id="footer">load — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
This means that if a submodule a same dependency as a parent module, then the
dependency will only be output once.</p>
</div>
-<p id="footer">ls — npm@1.1.24</p>
+<p id="footer">ls — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="VERSION">VERSION</h2>
-<p>1.1.24</p>
+<p>1.1.25</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<pre><code>var cmd = npm.deref("unp") // cmd === "unpublish"</code></pre>
</div>
-<p id="footer">npm — npm@1.1.24</p>
+<p id="footer">npm — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>If the 'packages' parameter is left out, npm will check all packages.</p>
</div>
-<p id="footer">outdated — npm@1.1.24</p>
+<p id="footer">outdated — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/publish.html">publish(3)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">owner — npm@1.1.24</p>
+<p id="footer">owner — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>If no arguments are supplied, then npm packs the current package folder.</p>
</div>
-<p id="footer">pack — npm@1.1.24</p>
+<p id="footer">pack — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically</p>
</div>
-<p id="footer">prefix — npm@1.1.24</p>
+<p id="footer">prefix — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Extraneous packages are packages that are not listed on the parent
package's dependencies list.</p>
</div>
-<p id="footer">prune — npm@1.1.24</p>
+<p id="footer">prune — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../api/owner.html">owner(3)</a></li></ul>
</div>
-<p id="footer">publish — npm@1.1.24</p>
+<p id="footer">publish — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>See <code>npm help build</code></p>
</div>
-<p id="footer">rebuild — npm@1.1.24</p>
+<p id="footer">rebuild — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/start.html">start(3)</a></li><li><a href="../api/stop.html">stop(3)</a></li></ul>
</div>
-<p id="footer">restart — npm@1.1.24</p>
+<p id="footer">restart — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically.</p>
</div>
-<p id="footer">root — npm@1.1.24</p>
+<p id="footer">root — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../api/test.html">test(3)</a></li><li><a href="../api/start.html">start(3)</a></li><li><a href="../api/restart.html">restart(3)</a></li><li><a href="../api/stop.html">stop(3)</a></li></ul>
</div>
-<p id="footer">run-script — npm@1.1.24</p>
+<p id="footer">run-script — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
and doesn't try to read your mind (it doesn't do any verb tense matching or the
like).</p>
</div>
-<p id="footer">search — npm@1.1.24</p>
+<p id="footer">search — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Finally, 'callback' is a function that will be called when the shrinkwrap has
been saved.</p>
</div>
-<p id="footer">shrinkwrap — npm@1.1.24</p>
+<p id="footer">shrinkwrap — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>npm can run tests on multiple packages. Just specify multiple packages
in the <code>packages</code> parameter.</p>
</div>
-<p id="footer">start — npm@1.1.24</p>
+<p id="footer">start — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>npm can run stop on multiple packages. Just specify multiple packages
in the <code>packages</code> parameter.</p>
</div>
-<p id="footer">stop — npm@1.1.24</p>
+<p id="footer">stop — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li>npm help json</li><li>git help submodule</li></ul>
</div>
-<p id="footer">submodule — npm@1.1.24</p>
+<p id="footer">submodule — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
used. For more information about how to set this config, check
<code>man 3 npm-config</code> for programmatic usage or <code>man npm-config</code> for cli usage.</p>
</div>
-<p id="footer">tag — npm@1.1.24</p>
+<p id="footer">tag — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>npm can run tests on multiple packages. Just specify multiple packages
in the <code>packages</code> parameter.</p>
</div>
-<p id="footer">test — npm@1.1.24</p>
+<p id="footer">test — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Finally, 'callback' is a function that will be called when all packages have been
uninstalled or when an error has been encountered.</p>
</div>
-<p id="footer">uninstall — npm@1.1.24</p>
+<p id="footer">uninstall — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>If no version is specified, or if all versions are removed then
the root package entry is removed from the registry entirely.</p>
</div>
-<p id="footer">unpublish — npm@1.1.24</p>
+<p id="footer">unpublish — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The 'packages' argument is an array of packages to update. The 'callback' parameter will be called when done or when an error occurs.</p>
</div>
-<p id="footer">update — npm@1.1.24</p>
+<p id="footer">update — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
parameter. The difference, however, is this function will fail if it does
not have exactly one element. The only element should be a version number.</p>
</div>
-<p id="footer">version — npm@1.1.24</p>
+<p id="footer">version — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>corresponding to the list of fields selected.</p>
</div>
-<p id="footer">view — npm@1.1.24</p>
+<p id="footer">view — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically</p>
</div>
-<p id="footer">whoami — npm@1.1.24</p>
+<p id="footer">whoami — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/help.html">help(1)</a></li><li><a href="../doc/index.html">index(1)</a></li></ul>
</div>
-<p id="footer"><a href="../doc/README.html">README</a> — npm@1.1.24</p>
+<p id="footer"><a href="../doc/README.html">README</a> — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li><li><a href="../doc/whoami.html">whoami(1)</a></li></ul>
</div>
-<p id="footer">adduser — npm@1.1.24</p>
+<p id="footer">adduser — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/prefix.html">prefix(1)</a></li><li><a href="../doc/root.html">root(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">bin — npm@1.1.24</p>
+<p id="footer">bin — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/docs.html">docs(1)</a></li><li><a href="../doc/view.html">view(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">bugs — npm@1.1.24</p>
+<p id="footer">bugs — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/link.html">link(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">build — npm@1.1.24</p>
+<p id="footer">build — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">bundle — npm@1.1.24</p>
+<p id="footer">bundle — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/pack.html">pack(1)</a></li></ul>
</div>
-<p id="footer">cache — npm@1.1.24</p>
+<p id="footer">cache — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li></ul>
</div>
-<p id="footer">changelog — npm@1.1.24</p>
+<p id="footer">changelog — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Always create a new Error object with your message. Don't just return a
string message to the callback. Stack traces are handy.</p>
-<p>Use the <code>require("./utils/log").er</code> function. It takes a callback and an
-error message, and returns an object that will report the message in the
-event of a failure. It's quite handy.</p>
-
-<pre><code>function myThing (args, cb) {
- getData(args, function (er, data) {
- if (er) return log.er(cb, "Couldn't get data")(er)
- doSomethingElse(data, cb)
- })
-}
-function justHasToWork (cb) {
- doSomething(log.er(cb, "the doSomething failed."))
-}</code></pre>
-
<h2 id="Logging">Logging</h2>
+<p>Logging is done using the <a href="https://github.com/isaacs/npmlog">npmlog</a>
+utility.</p>
+
<p>Please clean up logs when they are no longer helpful. In particular,
logging the same object over and over again is not helpful. Logs should
report what's happening so that it's easier to track down where a fault
occurs.</p>
-<p>Use appropriate log levels. The default log() function logs at the
-"info" level. See <code><a href="../doc/config.html">config(1)</a></code> and search for "loglevel".</p>
+<p>Use appropriate log levels. See <code><a href="../doc/config.html">config(1)</a></code> and search for
+"loglevel".</p>
<h2 id="Case-naming-etc">Case, naming, etc.</h2>
<ul><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">coding-style — npm@1.1.24</p>
+<p id="footer">coding-style — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">completion — npm@1.1.24</p>
+<p id="footer">completion — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li>The package is not already installed globally, or</li><li>the globally installed version is identical to the version that is
being installed locally.</li></ul>
-<h3 id="logfd">logfd</h3>
-
-<ul><li>Default: stderr file descriptor</li><li>Type: Number or Stream</li></ul>
-
-<p>The location to write log output.</p>
-
<h3 id="loglevel">loglevel</h3>
<ul><li>Default: "http"</li><li>Type: String</li><li>Values: "silent", "win", "error", "warn", "http", "info", "verbose", "silly"</li></ul>
<p>Any logs of a higher level than the setting are shown.
The default is "http", which shows http, warn, and error output.</p>
-<h3 id="logprefix">logprefix</h3>
-
-<ul><li>Default: true on Posix, false on Windows</li><li>Type: Boolean</li></ul>
-
-<p>Whether or not to prefix log messages with "npm" and the log level. See
-also "color" and "loglevel".</p>
-
<h3 id="long">long</h3>
<ul><li>Default: false</li><li>Type: Boolean</li></ul>
<p>A node module to <code>require()</code> when npm loads. Useful for programmatic
usage.</p>
-<h3 id="outfd">outfd</h3>
-
-<ul><li>Default: standard output file descriptor</li><li>Type: Number or Stream</li></ul>
-
-<p>Where to write "normal" output. This has no effect on log output.</p>
-
<h3 id="parseable">parseable</h3>
<ul><li>Default: false</li><li>Type: Boolean</li></ul>
<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">config — npm@1.1.24</p>
+<p id="footer">config — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">deprecate — npm@1.1.24</p>
+<p id="footer">deprecate — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/init.html">init(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">developers — npm@1.1.24</p>
+<p id="footer">developers — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li></ul>
</div>
-<p id="footer">disputes — npm@1.1.24</p>
+<p id="footer">disputes — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/view.html">view(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">docs — npm@1.1.24</p>
+<p id="footer">docs — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/explore.html">explore(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">edit — npm@1.1.24</p>
+<p id="footer">edit — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/submodule.html">submodule(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/edit.html">edit(1)</a></li><li><a href="../doc/rebuild.html">rebuild(1)</a></li><li><a href="../doc/build.html">build(1)</a></li><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">explore — npm@1.1.24</p>
+<p id="footer">explore — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li></ul>
</div>
-<p id="footer">faq — npm@1.1.24</p>
+<p id="footer">faq — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/pack.html">pack(1)</a></li><li><a href="../doc/cache.html">cache(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li></ul>
</div>
-<p id="footer">folders — npm@1.1.24</p>
+<p id="footer">folders — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/help.html">help(1)</a></li></ul>
</div>
-<p id="footer">help-search — npm@1.1.24</p>
+<p id="footer">help-search — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/README.html">README</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/help-search.html">help-search(1)</a></li><li><a href="../doc/index.html">index(1)</a></li></ul>
</div>
-<p id="footer">help — npm@1.1.24</p>
+<p id="footer">help — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p> Display npm username</p>
</div>
-<p id="footer">index — npm@1.1.24</p>
+<p id="footer">index — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/version.html">version(1)</a></li></ul>
</div>
-<p id="footer">init — npm@1.1.24</p>
+<p id="footer">init — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/update.html">update(1)</a></li><li><a href="../doc/link.html">link(1)</a></li><li><a href="../doc/rebuild.html">rebuild(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/build.html">build(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/tag.html">tag(1)</a></li><li><a href="../doc/rm.html">rm(1)</a></li><li><a href="../doc/shrinkwrap.html">shrinkwrap(1)</a></li></ul>
</div>
-<p id="footer">install — npm@1.1.24</p>
+<p id="footer">install — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/semver.html">semver(1)</a></li><li><a href="../doc/init.html">init(1)</a></li><li><a href="../doc/version.html">version(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/help.html">help(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/rm.html">rm(1)</a></li></ul>
</div>
-<p id="footer">json — npm@1.1.24</p>
+<p id="footer">json — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">link — npm@1.1.24</p>
+<p id="footer">link — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/link.html">link(1)</a></li><li><a href="../doc/prune.html">prune(1)</a></li><li><a href="../doc/outdated.html">outdated(1)</a></li><li><a href="../doc/update.html">update(1)</a></li></ul>
</div>
-<p id="footer">list — npm@1.1.24</p>
+<p id="footer">list — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="VERSION">VERSION</h2>
-<p>1.1.24</p>
+<p>1.1.25</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<ul><li><a href="../doc/help.html">help(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/README.html">README</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/index.html">index(1)</a></li><li><a href="../api/npm.html">npm(3)</a></li></ul>
</div>
-<p id="footer">npm — npm@1.1.24</p>
+<p id="footer">npm — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/update.html">update(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li></ul>
</div>
-<p id="footer">outdated — npm@1.1.24</p>
+<p id="footer">outdated — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/disputes.html">disputes(1)</a></li></ul>
</div>
-<p id="footer">owner — npm@1.1.24</p>
+<p id="footer">owner — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/cache.html">cache(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">pack — npm@1.1.24</p>
+<p id="footer">pack — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/root.html">root(1)</a></li><li><a href="../doc/bin.html">bin(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">prefix — npm@1.1.24</p>
+<p id="footer">prefix — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/rm.html">rm(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/list.html">list(1)</a></li></ul>
</div>
-<p id="footer">prune — npm@1.1.24</p>
+<p id="footer">prune — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li><li><a href="../doc/deprecate.html">deprecate(1)</a></li><li><a href="../doc/tag.html">tag(1)</a></li></ul>
</div>
-<p id="footer">publish — npm@1.1.24</p>
+<p id="footer">publish — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/build.html">build(1)</a></li><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">rebuild — npm@1.1.24</p>
+<p id="footer">rebuild — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/disputes.html">disputes(1)</a></li></ul>
</div>
-<p id="footer">registry — npm@1.1.24</p>
+<p id="footer">registry — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/README.html">README</a></li><li><a href="../doc/rm.html">rm(1)</a></li><li><a href="../doc/prune.html">prune(1)</a></li></ul>
</div>
-<p id="footer">removing-npm — npm@1.1.24</p>
+<p id="footer">removing-npm — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">restart — npm@1.1.24</p>
+<p id="footer">restart — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/prefix.html">prefix(1)</a></li><li><a href="../doc/bin.html">bin(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">root — npm@1.1.24</p>
+<p id="footer">root — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">run-script — npm@1.1.24</p>
+<p id="footer">run-script — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">scripts — npm@1.1.24</p>
+<p id="footer">scripts — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/view.html">view(1)</a></li></ul>
</div>
-<p id="footer">search — npm@1.1.24</p>
+<p id="footer">search — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">semver — npm@1.1.24</p>
+<p id="footer">semver — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/list.html">list(1)</a></li></ul>
</div>
-<p id="footer">shrinkwrap — npm@1.1.24</p>
+<p id="footer">shrinkwrap — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/view.html">view(1)</a></li><li><a href="../doc/whoami.html">whoami(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li></ul>
</div>
-<p id="footer">star — npm@1.1.24</p>
+<p id="footer">star — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">start — npm@1.1.24</p>
+<p id="footer">start — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li></ul>
</div>
-<p id="footer">stop — npm@1.1.24</p>
+<p id="footer">stop — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/json.html">json(1)</a></li><li>git help submodule</li></ul>
</div>
-<p id="footer">submodule — npm@1.1.24</p>
+<p id="footer">submodule — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">tag — npm@1.1.24</p>
+<p id="footer">tag — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">test — npm@1.1.24</p>
+<p id="footer">test — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/prune.html">prune(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">uninstall — npm@1.1.24</p>
+<p id="footer">uninstall — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/deprecate.html">deprecate(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li></ul>
</div>
-<p id="footer">unpublish — npm@1.1.24</p>
+<p id="footer">unpublish — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/outdated.html">outdated(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/list.html">list(1)</a></li></ul>
</div>
-<p id="footer">update — npm@1.1.24</p>
+<p id="footer">update — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/init.html">init(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/semver.html">semver(1)</a></li></ul>
</div>
-<p id="footer">version — npm@1.1.24</p>
+<p id="footer">version — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/search.html">search(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/docs.html">docs(1)</a></li></ul>
</div>
-<p id="footer">view — npm@1.1.24</p>
+<p id="footer">view — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li></ul>
</div>
-<p id="footer">whoami — npm@1.1.24</p>
+<p id="footer">whoami — npm@1.1.25</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
-/* @license
- * MyFonts Webfont Build ID 2303021, 2012-06-04T14:43:21-0400
- *
- * The fonts listed in this notice are subject to the End User License
- * Agreement(s) entered into by the website owner. All other parties are
- * explicitly restricted from using the Licensed Webfonts(s).
- *
- * You may obtain a valid license at the URLs below.
- *
- * Webfont: Gubblebum Blocky by Jelloween
- * URL: http://www.myfonts.com/fonts/jelloween/gubblebum/blocky/
- * Licensed pageviews: unspecified
- *
- *
- * License: http://www.myfonts.com/viewlicense?type=web&buildid=2303021
- * Webfonts copyright: Copyright (c) 2007 by Tjarda Koster. All rights reserved.
- *
- * © 2012 Bitstream Inc
+/*
+
+Webfont: Gubblebum Blocky by Jelloween
+License: http://www.myfonts.com/viewlicense?type=web&buildid=2303021
+Webfonts copyright: Copyright (c) 2007 by Tjarda Koster. All rights reserved.
+
+"Gubblebum Blocky" font
+Copyright (c) 2007 by Tjarda Koster, http://jelloween.deviantart.com
+included for use in the npm website and documentation,
+used with permission.
+
*/
@font-face {
module.exports = adduser
-var registry = require("./utils/npm-registry-client/index.js")
- , ini = require("./utils/ini.js")
- , log = require("./utils/log.js")
+var ini = require("./utils/ini.js")
+ , log = require("npmlog")
, npm = require("./npm.js")
+ , registry = npm.registry
, read = require("read")
, promiseChain = require("./utils/promise-chain.js")
, crypto
if (changed) npm.config.del("_auth")
registry.adduser(u.u, u.p, u.e, function (er) {
if (er) return cb(er)
+ registry.username = u.u
+ registry.password = u.p
+ registry.email = u.e
ini.set("username", u.u, "user")
ini.set("_password", u.p, "user")
ini.set("email", u.e, "user")
- log("Authorized user " + u.u, "adduser")
+ log.info("adduser", "Authorized user %s", u.u)
ini.save("user", cb)
})
})
bugs.usage = "npm bugs <pkgname>"
+var exec = require("./utils/exec.js")
+ , npm = require("./npm.js")
+ , registry = npm.registry
+ , log = require("npmlog")
+
bugs.completion = function (opts, cb) {
if (opts.conf.argv.remain.length > 2) return cb()
- registry.get("/-/short", null, 60000, function (er, list) {
+ registry.get("/-/short", 60000, function (er, list) {
return cb(null, list || [])
})
}
-var exec = require("./utils/exec.js")
- , registry = require("./utils/npm-registry-client/index.js")
- , npm = require("./npm.js")
- , log = require("./utils/log.js")
-
function bugs (args, cb) {
if (!args.length) return cb(bugs.usage)
var n = args[0].split("@").shift()
- registry.get(n, "latest", 3600, function (er, d) {
+ registry.get(n + "/latest", 3600, function (er, d) {
if (er) return cb(er)
var bugs = d.bugs
, repo = d.repository || d.repositories
if (repo) {
if (Array.isArray(repo)) repo = repo.shift()
if (repo.hasOwnProperty("url")) repo = repo.url
- log.verbose(repo, "repository")
+ log.verbose("repository", repo)
if (repo && repo.match(/^(https?:\/\/|git(:\/\/|@))github.com/)) {
return open(repo.replace(/^git(@|:\/\/)/, "http://")
.replace(/^https?:\/\/github.com:/, "github.com/")
// This runs AFTER install or link are completed.
var npm = require("./npm.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, chain = require("slide").chain
, fs = require("graceful-fs")
, path = require("path")
function build_ (global, didPre, didRB) { return function (folder, cb) {
folder = path.resolve(folder)
build._didBuild[folder] = true
- log.info(folder, "build")
+ log.info("build", folder)
readJson(path.resolve(folder, "package.json"), function (er, pkg) {
if (er) return cb(er)
chain
, top = parent === npm.dir
, gtop = parent === gnm
- log.verbose([global, gnm, gtop, parent], "linkStuff")
- log(pkg._id, "linkStuff")
+ log.verbose("linkStuff", [global, gnm, gtop, parent])
+ log.info("linkStuff", pkg._id)
if (top && pkg.preferGlobal && !global) {
- log.warn(pkg._id + " should be installed with -g", "prefer global")
+ log.warn("prefer global", pkg._id + " should be installed with -g")
}
asyncMap( [linkBins, linkMans, !didRB && rebuildBundles]
, function (fn, cb) {
if (!fn) return cb()
- log.verbose(pkg._id, fn.name)
+ log.verbose(fn.name, pkg._id)
fn(pkg, folder, parent, gtop, cb)
}, cb)
}
// error means no bundles
if (er) return cb()
- log.verbose(files, "rebuildBundles")
+ log.verbose("rebuildBundles", files)
// don't asyncMap these, because otherwise build script output
// gets interleaved and is impossible to read
chain(files.filter(function (file) {
file = path.resolve(folder, "node_modules", file)
return function (cb) {
if (build._didBuild[file]) return cb()
- log.verbose(file, "rebuild bundle")
+ log.verbose("rebuild bundle", file)
// if file is not a package dir, then don't do it.
fs.lstat(path.resolve(file, "package.json"), function (er, st) {
if (er) return cb()
}
var binRoot = gtop ? npm.globalBin
: path.resolve(parent, ".bin")
- log.verbose([pkg.bin, binRoot, gtop], "bins linking")
+ log.verbose("link bins", [pkg.bin, binRoot, gtop])
asyncMap(Object.keys(pkg.bin), function (b, cb) {
linkBin( path.resolve(folder, pkg.bin[b])
2. goto folder(2)
adding a name@version:
-1. registry.get(name, version)
+1. registry.get(name/version)
2. if response isn't 304, add url(dist.tarball)
adding a name@range:
, fs = require("graceful-fs")
, rm = require("rimraf")
, readJson = require("./utils/read-json.js")
- , registry = require("./utils/npm-registry-client/index.js")
- , log = require("./utils/log.js")
+ , registry = npm.registry
+ , log = require("npmlog")
, path = require("path")
, output
, sha = require("./utils/sha.js")
}
if (forceBypass && npm.config.get("force")) {
- log.verbose(true, "force found, skipping cache")
+ log.verbose("using force", "skipping cache")
return addNamed(name, ver, c)
}
add([pkg, ver], cb)
})
}
- log.verbose([pkg, ver], "cache add")
+ log.verbose("cache add", [pkg, ver])
return add([pkg, ver], cb)
}
spec = args[0]
}
- log.silly([name, spec, args], "cache add: name, spec, args")
+ log.silly("cache add", "name=%j spec=%j args=%j", name, spec, args)
+
if (!name && !spec) return cb(usage)
// see if the spec is a url
// otherwise, treat as name@version
var p = url.parse(spec) || {}
- log.verbose(p, "parsed url")
+ log.verbose("parsed url", p)
// it could be that we got name@http://blah
// in that case, we will not have a protocol now, but if we
delete inFlightURLs[u]
}
- log.verbose([u, shasum], "addRemoteTarball")
+ log.verbose("addRemoteTarball", [u, shasum])
var tmp = path.join(npm.tmp, Date.now()+"-"+Math.random(), "tmp.tgz")
mkdir(path.dirname(tmp), function (er) {
if (er) return cb(er)
fetch(u, tmp, function (er) {
- if (er) return log.er(cb, "failed to fetch "+u)(er)
+ if (er) {
+ log.error("fetch failed", u)
+ return cb(er)
+ }
if (!shasum) return done()
// validate that the url we just downloaded matches the expected shasum.
sha.check(tmp, shasum, done)
u = u.replace(/^ssh:\/\//, "")
}
- log.verbose([u, co], "addRemoteGit")
+ log.verbose("addRemoteGit", [u, co])
var tmp = path.join(npm.tmp, Date.now()+"-"+Math.random())
mkdir(path.dirname(tmp), function (er) {
, function (er, code, stdout, stderr) {
stdout = (stdout + "\n" + stderr).trim()
if (er) {
- log.error(stdout, "git clone "+u)
+ log.error("git clone " + u, stdout)
return cb(er)
}
- log.verbose(stdout, "git clone "+u)
+ log.verbose("git clone "+u, stdout)
exec( npm.config.get("git"), ["checkout", co], null, false, tmp
, function (er, code, stdout, stderr) {
stdout = (stdout + "\n" + stderr).trim()
if (er) {
- log.error(stdout, "git checkout "+co)
+ log.error("git checkout " + co, stdout)
return cb(er)
}
- log.verbose(stdout, "git checkout "+co)
+ log.verbose("git checkout " + co, stdout)
addLocalDirectory(tmp, cb)
})
})
// name@blah thing.
var inFlightNames = {}
function addNamed (name, x, cb_) {
- log.verbose([name, x], "addNamed")
+ log.verbose("addNamed", [name, x])
var k = name + "@" + x
if (!inFlightNames[k]) inFlightNames[k] = []
var iF = inFlightNames[k]
delete inFlightNames[k]
}
- log.verbose([semver.valid(x), semver.validRange(x)], "addNamed")
+ log.verbose("addNamed", [semver.valid(x), semver.validRange(x)])
return ( null !== semver.valid(x) ? addNameVersion
: null !== semver.validRange(x) ? addNameRange
: addNameTag
}
function addNameTag (name, tag, cb) {
- log([name, tag], "addNameTag")
+ log.info("addNameTag", [name, tag])
var explicit = true
if (!tag) {
explicit = false
if (range === null) return cb(new Error(
"Invalid version range: "+range))
- log.silly([name, range, !!data], "name, range, hasData")
+ log.silly("addNameRange", {name:name, range:range, hasData:!!data})
if (data) return next()
registry.get(name, function (er, d, json, response) {
})
function next () {
- log.silly([name, range, !!data], "name, range, hasData 2")
+ log.silly( "addNameRange", "number 2"
+ , {name:name, range:range, hasData:!!data})
engineFilter(data)
if (npm.config.get("registry")) return next_()
}
function next_ () {
- log.silly([data.name, Object.keys(data.versions)], "versions")
+ log.silly("addNameRange", "versions"
+ , [data.name, Object.keys(data.versions)])
+
// if the tagged version satisfies, then use that.
var tagged = data["dist-tags"][npm.config.get("tag")]
if (tagged && data.versions[tagged] && semver.satisfies(tagged, range)) {
// filter the versions down based on what's already in cache.
function cachedFilter (data, range, cb) {
- log.silly(data.name, "cachedFilter")
+ log.silly("cachedFilter", data.name)
ls_(data.name, 1, function (er, files) {
- if (er) return log.er(cb, "Not in cache, can't fetch: "+data.name)(er)
+ if (er) {
+ log.error("cachedFilter", "Not in cache, can't fetch", data.name)
+ return cb(er)
+ }
files = files.map(function (f) {
return path.basename(f.replace(/(\\|\/)$/, ""))
}).filter(function (f) {
return cb(new Error("Not in cache, can't fetch: "+data.name+"@"+range))
}
- log.silly([data.name, files], "cached")
+ log.silly("cached", [data.name, files])
Object.keys(data.versions).forEach(function (v) {
if (files.indexOf(v) === -1) delete data.versions[v]
})
if (Object.keys(data.versions).length === 0) {
- return log.er(cb, "Not in cache, can't fetch: "+data.name)(er)
+ log.error("cachedFilter", "Not in cache, can't fetch", data.name)
+ return cb(new Error("Not in cache, can't fetch: "+data.name+"@"+range))
}
- log.silly([data.name, Object.keys(data.versions)], "filtered")
+ log.silly("filtered", [data.name, Object.keys(data.versions)])
cb(null, data)
})
}
response = null
return next()
}
- registry.get(name, ver, function (er, d, json, resp) {
+ registry.get(name + "/" + ver, function (er, d, json, resp) {
if (er) return cb(er)
data = d
response = resp
var bd = npm.config.get("bindist")
, b = dist.bin && bd && dist.bin[bd]
- log.verbose([bd, dist], "bin dist")
+ log.verbose("bin dist", [bd, dist])
if (b && b.tarball && b.shasum) {
- log.info(data._id, "prebuilt")
- log.verbose(b, "prebuilt "+data._id)
+ log.info("prebuilt", data._id)
+ log.verbose("prebuilt", data._id, b)
dist = b
}
&& (process.platform !== "win32" || p.indexOf("\\") === -1)) {
return addNamed(p, "", cb_)
}
- return log.er(cb_, "Could not install: "+p)(er)
+ log.error("addLocal", "Could not install %s", p)
+ return cb_(er)
}
return cb_(er, data)
}
to.on("error", errHandler)
to.on("close", function () {
if (errState) return
- log.verbose(npm.modes.file.toString(8), "chmod "+tmp)
+ log.verbose("chmod", tmp, npm.modes.file.toString(8))
fs.chmod(tmp, npm.modes.file, function (er) {
if (er) return cb(er)
addTmpTarball(tmp, name, cb)
fs.stat(npm.cache, function (er, st) {
if (er) return makeCacheDir(cb)
if (!st.isDirectory()) {
- return log.er(cb, "invalid cache directory: "+npm.cache)(er)
+ log.error("getCacheStat", "invalid cache dir %j", npm.cache)
+ return cb(er)
}
return cb(null, cacheStat = st)
})
}
fs.stat(process.env.HOME, function (er, st) {
- if (er) return log.er(cb, "homeless?")(er)
+ if (er) {
+ log.error("makeCacheDir", "homeless?")
+ return cb(er)
+ }
cacheStat = st
- log.silly([st.uid, st.gid], "uid, gid for cache dir")
+ log.silly("makeCacheDir", "cache dir uid, gid", [st.uid, st.gid])
return mkdir(npm.cache, afterMkdir)
})
, folder = path.join(target, "package")
rm(folder, function (er) {
- if (er) return log.er(cb, "Could not remove "+folder)(er)
+ if (er) {
+ log.error("addPlacedTarball", "Could not remove %j", folder)
+ return cb(er)
+ }
tar.unpack(p, folder, null, null, uid, gid, function (er) {
- if (er) return log.er(cb, "Could not unpack "+p+" to "+target)(er)
+ if (er) {
+ log.error("addPlacedTarball", "Could not unpack %j to %j", p, target)
+ return cb(er)
+ }
// calculate the sha of the file that we just unpacked.
// this is so that the data is available when publishing.
sha.get(p, function (er, shasum) {
- if (er) return log.er(cb, "couldn't validate shasum of "+p)(er)
+ if (er) {
+ log.error("addPlacedTarball", "shasum fail", p)
+ return cb(er)
+ }
readJson(path.join(folder, "package.json"), function (er, data) {
- if (er) return log.er(cb, "couldn't read json in "+folder)(er)
+ if (er) {
+ log.error("addPlacedTarball", "Couldn't read json in %j"
+ , folder)
+ return cb(er)
+ }
data.dist = data.dist || {}
if (shasum) data.dist.shasum = shasum
deprCheck(data)
asyncMap([p], function (f, cb) {
- log.verbose(npm.modes.file.toString(8), "chmod "+f)
+ log.verbose("chmod", f, npm.modes.file.toString(8))
fs.chmod(f, npm.modes.file, cb)
}, function (f, cb) {
if (process.platform === "win32") {
- log.silly(f, "skipping chown for windows")
+ log.silly("chown", "skipping for windows", f)
cb()
} else if (typeof uid === "number"
&& typeof gid === "number"
&& parseInt(uid, 10) === uid
&& parseInt(gid, 10) === gid) {
- log.verbose([f, uid, gid], "chown")
+ log.verbose("chown", f, [uid, gid])
fs.chown(f, uid, gid, cb)
} else {
- log.verbose([f, uid, gid], "not chowning, invalid uid/gid")
+ log.verbose("chown", "skip for invalid uid/gid", [f, uid, gid])
cb()
}
}, function (er) {
mkdir(path.dirname(tgz), function (er, made) {
if (er) return cb(er)
tar.pack(tgz, p, data, doFancyCrap, function (er) {
- if (er) return log.er(cb,"couldn't pack "+p+ " to "+tgz)(er)
+ if (er) {
+ log.error( "addLocalDirectory", "Could not pack %j to %j"
+ , p, tgz )
+ return cb(er)
+ }
- if (er || !cs || isNaN(cs.uid) || isNaN(cs.gid)) return cb()
+ // if we don't get a cache stat, or if the gid/uid is not
+ // a number, then just move on. chown would fail anyway.
+ if (!cs || isNaN(cs.uid) || isNaN(cs.gid)) return cb()
chownr(made || tgz, cs.uid, cs.gid, function (er) {
if (er) return cb(er)
read(pkg, ver, false, function (er, data) {
if (er) {
- log.error("Could not read data for "+pkg+"@"+ver)
+ log.error("unpack", "Could not read data for %s", pkg + "@" + ver)
return cb(er)
}
npm.commands.unbuild([unpackTarget], function (er) {
else return
if (!deprWarned[data._id]) {
deprWarned[data._id] = true
- log.warn(data._id+": "+data.deprecated, "deprecated")
+ log.warn("deprecated", "%s: %s", data._id, data.deprecated)
}
}
+ "\nnpm get [<key>]"
var ini = require("./utils/ini.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, npm = require("./npm.js")
, exec = require("./utils/exec.js")
, fs = require("graceful-fs")
}
key = key.trim()
val = val.trim()
- log("set "+key+" "+val, "config")
+ log.info("config", "set %j %j", key, val)
var where = ini.get("global") ? "global" : "user"
ini.set(key, val, where)
ini.save(where, cb)
})
}
-var registry = require("./utils/npm-registry-client/index.js")
- , semver = require("semver")
- , log = require("./utils/log.js")
+var semver = require("semver")
, npm = require("./npm.js")
+ , registry = npm.registry
function deprecate (args, cb) {
var pkg = args[0]
data.versions[v].deprecated = msg
})
// now update the doc on the registry
- registry.request.PUT(data._id, data, cb)
+ registry.request('PUT', data._id, data, cb)
})
}
docs.completion = function (opts, cb) {
if (opts.conf.argv.remain.length > 2) return cb()
- registry.get("/-/short", null, 60000, function (er, list) {
+ registry.get("/-/short", 60000, function (er, list) {
return cb(null, list || [])
})
}
var exec = require("./utils/exec.js")
- , registry = require("./utils/npm-registry-client/index.js")
, npm = require("./npm.js")
- , log = require("./utils/log.js")
+ , registry = npm.registry
+ , log = require("npmlog")
function docs (args, cb) {
if (!args.length) return cb(docs.usage)
var n = args[0].split("@").shift()
- registry.get(n, "latest", 3600, function (er, d) {
+ registry.get(n + "/latest", 3600, function (er, d) {
if (er) return cb(er)
var homepage = d.homepage
, repo = d.repository || d.repositories
if (repo) {
if (Array.isArray(repo)) repo = repo.shift()
if (repo.hasOwnProperty("url")) repo = repo.url
- log.verbose(repo, "repository")
+ log.verbose("repository", repo)
if (repo) {
return open(repo.replace(/^git(@|:\/\/)/, 'http://')
.replace(/\.git$/, '')+"#readme", cb)
, exec = require("./utils/exec.js")
, path = require("path")
, fs = require("graceful-fs")
- , log = require("./utils/log.js")
function edit (args, cb) {
var p = args[0]
, asyncMap = require("slide").asyncMap
, cliDocsPath = path.join(__dirname, "..", "doc", "cli")
, apiDocsPath = path.join(__dirname, "..", "doc", "api")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, npm = require("./npm.js")
helpSearch.usage = "npm help-search <text>"
}
fs.readdir(docsPath, function(er, files) {
- if (er) return log.er(cb, "Could not load documentation")(er)
+ if (er) {
+ log.error("helpSearch", "Could not load documentation")
+ return cb(er)
+ }
var search = args.join(" ")
, results = []
, exec = require("./utils/exec.js")
, npm = require("./npm.js")
, output = require("./utils/output.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
function help (args, cb) {
var num = 1
&& npm.commands[section].usage
) {
npm.config.set("loglevel", "silent")
+ log.level = "silent"
return output.write(npm.commands[section].usage, cb)
}
} else getSections(function (er, sections) {
if (er) return cb(er)
npm.config.set("loglevel", "silent")
+ log.level = "silent"
output.write
( ["\nUsage: npm <command>"
, ""
, promiseChain = require("./utils/promise-chain.js")
, exec = require("./utils/exec.js")
, semver = require("semver")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, npm = require("./npm.js")
, output = require("./utils/output.js")
function init (args, cb) {
var folder = args[0] || "."
- , ll = npm.config.get("loglevel")
- npm.config.set("loglevel", "paused")
+ log.pause()
if (folder.charAt(0) !== "/") folder = path.join(process.cwd(), folder)
readJson(path.join(folder, "package.json"), function (er, data) {
, url: npm.config.get("init.author.url") }
init_(data, folder, function (er) {
- npm.config.set("loglevel", ll)
- if (!er) log(path.resolve(folder, "package.json"), "written")
+ log.resume()
+ if (!er) log.info("written", path.resolve(folder, "package.json"))
cb(er)
})
})
// if it has a slash, then it's gotta be a folder
// if it starts with https?://, then just give up, because it's a url
// for now, not yet implemented.
- var registry = require("./utils/npm-registry-client/index.js")
+ var registry = npm.registry
registry.get("/-/short", function (er, pkgs) {
if (er) return cb()
if (!opts.partialWord) return cb(null, pkgs)
var npm = require("./npm.js")
, semver = require("semver")
, readJson = require("./utils/read-json.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, path = require("path")
, fs = require("graceful-fs")
, cache = require("./cache.js")
where = args
args = [].concat(cb_) // pass in [] to do default dep-install
cb_ = arguments[2]
- log.verbose([where, args], "install(where, what)")
+ log.verbose("install", "where,what", [where, args])
}
if (!npm.config.get("global")) {
, where
, { dev: !npm.config.get("production") }
, function (er, data) {
- if (er) return log.er(cb, "Couldn't read dependencies.")(er)
+ if (er) {
+ log.error("install", "Couldn't read dependencies")
+ return cb(er)
+ }
var deps = Object.keys(data.dependencies || {})
- log.verbose([where, deps], "where, deps")
+ log.verbose("install", "where, deps", [where, deps])
var context = { family: {}
, ancestors: {}
, explicit: false
if (er) return cb(er)
if (wrap) {
- log.verbose([where, wrap], "readDependencies: using existing wrap")
+ log.verbose("readDependencies: using existing wrap", [where, wrap])
var rv = {}
Object.keys(data).forEach(function (key) {
rv[key] = data[key]
})
rv.dependencies = {}
Object.keys(wrap).forEach(function (key) {
- log.verbose([key, wrap[key]], "from wrap")
+ log.verbose("from wrap", [key, wrap[key]])
var w = wrap[key]
rv.dependencies[key] = w.from || w.version
})
- log.verbose([rv.dependencies], "readDependencies: returned deps")
+ log.verbose("readDependencies returned deps", rv.dependencies)
return cb(null, rv, wrap)
}
fs.readFile(wrapfile, "utf8", function (er, wrapjson) {
if (er) {
- log.verbose("readDependencies: using package.json deps")
+ log.verbose("readDependencies", "using package.json deps")
return cb(null, data, null)
}
return cb(ex)
}
- log.info(wrapfile, "using shrinkwrap file")
+ log.info("shrinkwrap", "file %j", wrapfile)
var rv = {}
Object.keys(data).forEach(function (key) {
rv[key] = data[key]
var w = newwrap.dependencies[key]
rv.dependencies[key] = w.from || w.version
})
- log.verbose([rv.dependencies], "readDependencies: returned deps")
+ log.verbose("readDependencies returned deps", rv.dependencies)
return cb(null, rv, newwrap.dependencies)
})
})
return l
}, {})
- //log.warn(whatWhere, "whatWhere")
+ //log.warn("install", whatWhere, "whatWhere")
return Object.keys(whatWhere).reduce(function (l, r) {
var ww = whatWhere[r]
- //log.warn([r, ww], "r, ww")
+ //log.warn("r, ww", [r, ww])
if (!ww.parent) {
l[r] = ww
} else {
targets.forEach(function (t) {
newPrev[t.name] = t.version
})
- log.silly(targets, "resolved")
+ log.silly("resolved", targets)
targets.filter(function (t) { return t }).forEach(function (t) {
- log.info(t._id, "into "+where)
+ log.info("install", "%s into %s", t._id, where)
})
asyncMap(targets, function (target, cb) {
- log.info(target._id, "installOne")
+ log.info("installOne", target._id)
var newWrap = wrap ? wrap[target.name].dependencies || {} : null
var newContext = { family: newPrev
, ancestors: newAnc
// now we know what's been installed here manually,
// or tampered with in some way that npm doesn't want to overwrite.
if (alreadyInstalledManually.indexOf(what.split("@").shift()) !== -1) {
- log.verbose("skipping "+what, "already installed in "+where)
+ log.verbose("already installed", "skipping %s %s", what, where)
return cb(null, [])
}
// If installing from a shrinkwrap, it must match exactly.
if (context.family[what]) {
if (wrap && wrap[what].version === context.family[what]) {
- log.verbose(what, "using existing (matches shrinkwrap)")
+ log.verbose("shrinkwrap", "use existing", what)
return cb(null, [])
}
}
// doing `npm install foo` inside of the foo project. Print
// a warning, and skip it.
if (parent && parent.name === what && !npm.config.get("force")) {
- log.warn("Refusing to install "+what+" as a dependency of itself"
- ,"install")
+ log.warn("install", "Refusing to install %s as a dependency of itself"
+ , what)
return cb(null, [])
}
name = what.split(/@/).shift()
if (wrap[name]) {
var wrapTarget = wrap[name].from || wrap[name].version
- log.verbose("resolving "+what+" to "+wrapTarget, "shrinkwrap")
+ log.verbose("shrinkwrap", "resolving %s to %s", wrapTarget, what)
what = name + "@" + wrapTarget
} else {
- log.verbose("skipping "+what+" (not in shrinkwrap)", "shrinkwrap")
+ log.verbose("shrinkwrap", "skipping %s (not in shrinkwrap)", what)
}
} else if (deps[what]) {
what = what + "@" + deps[what]
cache.add(what, function (er, data) {
if (er && parent && parent.optionalDependencies &&
parent.optionalDependencies.hasOwnProperty(what.split("@")[0])) {
- log.warn(what, "optional dependency failed, continuing")
- log.verbose([what, er], "optional dependency failed, continuing")
+ log.warn("optional dep failed, continuing", what)
+ log.verbose("optional dep failed, continuing", [what, er])
return cb(null, [])
}
!context.explicit &&
context.family[data.name] === data.version &&
!npm.config.get("force")) {
- log.info(data.name + "@" + data.version, "already installed")
+ log.info("already installed", data.name + "@" + data.version)
return cb(null, [])
}
// check if this one is optional to its parent.
if (er && context.parent && context.parent.optionalDependencies &&
context.parent.optionalDependencies.hasOwnProperty(target.name)) {
- log.warn(target._id, "optional dependency failed, continuing")
- log.verbose([target._id, er], "optional dependency failed, continuing")
+ log.warn("optional dep failed, continuing", target._id)
+ log.verbose("optional dep failed, continuing", [target._id, er])
er = null
}
}
function localLink (target, where, context, cb) {
- log.verbose(target._id, "try to link")
+ log.verbose("localLink", target._id)
var jsonFile = path.resolve( npm.globalDir, target.name
, "package.json" )
, parent = context.parent
function thenLink () {
npm.commands.link([target.name], function (er, d) {
- log.silly([er, d], "back from link")
+ log.silly("localLink", "back from link", [er, d])
cb(er, [resultList(target, where, parent && parent._id)])
})
}
} else {
- log.verbose(target._id, "install locally (no link)")
+ log.verbose("localLink", "install locally (no link)", target._id)
installOne_(target, where, context, cb)
}
})
if (nodev && eng.node && !semver.satisfies(nodev, eng.node)
|| eng.npm && !semver.satisfies(npmv, eng.npm)) {
var er = new Error("Unsupported")
- er.errno = npm.ENOTSUP
+ er.code = "ENOTSUP"
er.required = eng
er.pkgid = target._id
return cb(er)
}
if (!osOk || !cpuOk) {
var er = new Error("Unsupported")
- er.errno = npm.EBADPLATFORM
+ er.code = "EBADPLATFORM"
er.os = target.os || ['any']
er.cpu = target.cpu || ['any']
er.pkgid = target._id
tree.push(JSON.parse(JSON.stringify(t)))
t = Object.getPrototypeOf(t)
}
- log.verbose(tree, "unresolvable dependency tree")
+ log.verbose("unresolvable dependency tree", tree)
er.pkgid = target._id
- er.errno = npm.ECYCLE
+ er.code = "ECYCLE"
return cb(er)
}
if (!er && s.isDirectory()) {
var e = new Error("Appears to be a git repo or submodule.")
e.path = folder
- e.errno = npm.EISGIT
+ e.code = "EISGIT"
return cb(e)
}
cb()
if (false === npm.config.get("rollback")) return cb_(er)
npm.commands.unbuild([targetFolder], function (er2) {
- if (er2) log.error(er2, "error rolling back "+target._id)
+ if (er2) log.error("error rolling back", target._id, er2)
return cb_(er, data)
})
}
t = d + "@" + t
return t
}), targetFolder, newcontext, function (er, d) {
- log.verbose(targetFolder, "about to build")
+ log.verbose("about to build", targetFolder)
if (er) return cb(er)
npm.commands.build( [targetFolder]
, npm.config.get("global")
-
// link with no args: symlink the folder to the global location
// link with package arg: symlink the global to the local
var npm = require("./npm.js")
, symlink = require("./utils/link.js")
, fs = require("graceful-fs")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, asyncMap = require("slide").asyncMap
, chain = require("slide").chain
, path = require("path")
function link (args, cb) {
if (process.platform === "win32") {
- var e = new Error("npm link not supported on windows")
- e.code = "ENOTSUP"
- e.errno = require("constants").ENOTSUP
- return cb(e)
+ var semver = require("semver")
+ if (!semver.satisfies(process.version, ">=0.7.9")) {
+ var msg = "npm link not supported on windows prior to node 0.7.9"
+ , e = new Error(msg)
+ e.code = "ENOTSUP"
+ e.errno = require("constants").ENOTSUP
+ return cb(e)
+ }
}
if (npm.config.get("global")) {
return cb(new Error("link should never be --global.\n"
+"Please re-run this command with --local"))
}
+
if (args.length === 1 && args[0] === ".") args = []
if (args.length) return linkInstall(args, cb)
linkPkg(npm.prefix, cb)
next()
} else {
return fs.realpath(pp, function (er, real) {
- if (er) log.warn(pkg, "invalid symbolic link")
+ if (er) log.warn("invalid symbolic link", pkg)
else rp = real
next()
})
function next () {
chain
( [ [npm.commands, "unbuild", [target]]
- , [log.verbose, "symlinking " + pp + " to "+target, "link"]
+ , [function (cb) {
+ log.verbose("link", "symlinking %s to %s", pp, target)
+ cb()
+ }]
, [symlink, pp, target]
// do run lifecycle scripts - full build here.
, rp && [build, [target]]
function linkPkg (folder, cb_) {
var me = folder || npm.prefix
, readJson = require("./utils/read-json.js")
+
+ log.verbose("linkPkg", folder)
+
readJson( path.resolve(me, "package.json")
, { dev: true }
, function (er, d) {
if (er) return cb(er)
symlink(me, target, function (er) {
if (er) return cb(er)
- log.verbose(target, "link: build target")
+ log.verbose("link", "build target", target)
// also install missing dependencies.
npm.commands.install(me, [], function (er, installed) {
if (er) return cb(er)
var npm = require("./npm.js")
, readInstalled = require("./utils/read-installed.js")
, output = require("./utils/output.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, relativize = require("./utils/relativize.js")
, path = require("path")
, archy = require("archy")
if (typeof cb !== "function") cb = silent, silent = false
if (args.length) {
+ // TODO: it would actually be nice to maybe show the locally
+ // installed packages only matching the argument names.
log.warn("ls doesn't take positional args. Try the 'search' command")
}
if (depth < npm.config.get("depth")) {
// just missing
var p = parent.link || parent.path
- log.warn("Unmet dependency in "+p, d+" "+data)
+ log.warn("unmet dependency", "%s in %s", d+" "+data, p)
data = "\033[31;40mUNMET DEPENDENCY\033[0m " + d + " " + data
} else {
- data = d+"@'"+ data +"' (max depth reached)"
+ data = d+"@"+ data +" (max depth reached)"
}
return data
}
if (typeof data === "string") {
if (data.depth < npm.config.get("depth")) {
var p = parent.link || parent.path
- log.warn("Unmet dependency in "+p, d+" "+data)
+ log.warn("unmet dependency", "%s in %s", d+" "+data, p)
data = npm.config.get("long")
? path.resolve(parent.path, "node_modules", d)
+ ":"+d+"@"+JSON.stringify(data)+":INVALID:MISSING"
, npm = module.exports = new EventEmitter
, config = require("./config.js")
, ini = require("./utils/ini.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, fs = require("graceful-fs")
, path = require("path")
, abbrev = require("abbrev")
, mkdirp = require("mkdirp")
, slide = require("slide")
, chain = slide.chain
+ , RegClient = require("npm-registry-client")
// /usr/local is often a read-only fs, which is not
// well handled by node or mkdirp. Just double-check
}
npm.commands = {}
-npm.ELIFECYCLE = {}
-npm.E404 = {}
-npm.EPUBLISHCONFLICT = {}
-npm.EJSONPARSE = {}
-npm.EISGIT = {}
-npm.ECYCLE = {}
-npm.ENOTSUP = {}
-npm.EBADPLATFORM = {}
try {
// startup, ok to do this synchronously
npm.version = j.version
npm.nodeVersionRequired = j.engines.node
if (!semver.satisfies(process.version, j.engines.node)) {
- log.error([""
+ log.error("unsupported version", [""
,"npm requires node version: "+j.engines.node
,"And you have: "+process.version
,"which is not satisfactory."
,""
,"Bad things will likely happen. You have been warned."
- ,""].join("\n"), "unsupported version")
+ ,""].join("\n"))
}
} catch (ex) {
try {
- log(ex, "error reading version")
+ log.info("error reading version", ex)
} catch (er) {}
npm.version = ex
}
}
}
- log.waitForConfig()
+ log.pause()
load(npm, conf, cb)
}
//console.error("about to look up configs")
ini.resolveConfigs(conf, function (er) {
- //console.error("back from config lookup", er && er.stack)
+ log.level = npm.config.get("loglevel")
+ log.heading = "npm"
+ switch (npm.config.get("color")) {
+ case "always": log.enableColor(); break
+ case false: log.disableColor(); break
+ }
+ log.resume()
+
if (er) return cb(er)
+ // at this point the configs are all set.
+ // go ahead and spin up the registry client.
+ npm.registry = new RegClient(
+ { registry: npm.config.get("registry")
+ , cache: npm.config.get("cache")
+ , auth: npm.config.get("_auth")
+ , alwaysAuth: npm.config.get("always-auth")
+ , email: npm.config.get("email")
+ , tag: npm.config.get("tag")
+ , ca: npm.config.get("ca")
+ , strictSSL: npm.config.get("strict-ssl")
+ , userAgent: npm.config.get("user-agent")
+ , E404: npm.E404
+ , EPUBLISHCONFLICT: npm.EPUBLISHCONFLICT
+ , log: log
+ })
+
var umask = parseInt(conf.umask, 8)
npm.modes = { exec: 0777 & (~umask)
, file: 0666 & (~umask)
var prefix = path.resolve(cl.get("prefix"))
mkdir(prefix, function (er) {
if (er) {
- log.error(prefix, "could not create prefix directory")
+ log.error("could not create prefix dir", prefix)
return cb(er)
}
fs.stat(prefix, function (er, st) {
, cache = require("./cache.js")
, asyncMap = require("slide").asyncMap
, npm = require("./npm.js")
- , log = require("./utils/log.js")
, semver = require("semver")
, relativize = require("./utils/relativize.js")
}
}
-var registry = require("./utils/npm-registry-client/index.js")
- , get = registry.request.GET
- , put = registry.request.PUT
- , log = require("./utils/log.js")
+var npm = require("./npm.js")
+ , registry = npm.registry
+ , log = require("npmlog")
, output
- , npm = require("./npm.js")
function owner (args, cb) {
var action = args.shift()
function ls (pkg, cb) {
if (!pkg) return cb(owner.usage)
- get(pkg, function (er, data) {
+ registry.get(pkg, function (er, data) {
var msg = ""
- if (er) return log.er(cb, "Couldn't get owner data for "+pkg)(er)
+ if (er) {
+ log.error("owner ls", "Couldn't get owner data", pkg)
+ return cb(er)
+ }
var owners = data.maintainers
if (!owners || !owners.length) msg = "admin party!"
else msg = owners.map(function (o) { return o.name +" <"+o.email+">" }).join("\n")
add(user, pkg, cb)
})
- log.verbose(user+" to "+pkg, "owner add")
+ log.verbose("owner add", "%s to %s", user, pkg)
mutate(pkg, user, function (u, owners) {
if (!owners) owners = []
for (var i = 0, l = owners.length; i < l; i ++) {
var o = owners[i]
if (o.name === u.name) {
- log( "Already a package owner: "+o.name+" <"+o.email+">"
- , "owner add"
- )
+ log.info( "owner add"
+ , "Already a package owner: "+o.name+" <"+o.email+">")
return false
}
}
rm(user, pkg, cb)
})
- log.verbose(user+" from "+pkg, "owner rm")
+ log.verbose("owner rm", "%s from %s", user, pkg)
mutate(pkg, null, function (u, owners) {
var found = false
, m = owners.filter(function (o) {
return !match
})
if (!found) {
- log("Not a package owner: "+user, "owner rm")
+ log.info("owner rm", "Not a package owner: "+user)
return false
}
if (!m.length) return new Error(
function mutate (pkg, user, mutation, cb) {
if (user) {
- get("/-/user/org.couchdb.user:"+user, mutate_)
+ registry.get("/-/user/org.couchdb.user:"+user, mutate_)
} else {
mutate_(null, null)
}
function mutate_ (er, u) {
- if (er) return log.er(cb, "Error getting user data for "+user)(er)
- if (user && (!u || u.error)) return cb(new Error(
- "Couldn't get user data for "+user+": "+JSON.stringify(u)))
+ if (!er && user && (!u || u.error)) er = new Error(
+ "Couldn't get user data for "+user+": "+JSON.stringify(u))
+
+ if (er) {
+ log.error("owner mutate", "Error getting user data for %s", user)
+ return cb(er)
+ }
+
if (u) u = { "name" : u.name, "email" : u.email }
- get("/"+pkg, function (er, data) {
- if (er) return log.er(cb, "Couldn't get package data for "+pkg)(er)
+ registry.get(pkg, function (er, data) {
+ if (er) {
+ log.error("owner mutate", "Error getting package data for %s", pkg)
+ return cb(er)
+ }
var m = mutation(u, data.maintainers)
if (!m) return cb() // handled
if (m instanceof Error) return cb(m) // error
, _rev : data._rev
, maintainers : m
}
- put("/"+pkg+"/-rev/"+data._rev, data, function (er, data) {
- if (er) return log.er(cb, "Failed to update package metadata")(er)
- if (data.error) return cb(new Error(
- "Failed to update package metadata: "+JSON.stringify(data)))
- cb(null, data)
+ registry.request("PUT"
+ , pkg+"/-rev/"+data._rev, data
+ , function (er, data) {
+ if (!er && data.error) er = new Error(
+ "Failed to update package metadata: "+JSON.stringify(data))
+ if (er) {
+ log.error("owner mutate", "Failed to update package metadata")
+ }
+ cb(er, data)
})
})
}
module.exports = publish
var npm = require("./npm.js")
- , registry = require("./utils/npm-registry-client/index.js")
- , log = require("./utils/log.js")
+ , registry = npm.registry
+ , log = require("npmlog")
, tar = require("./utils/tar.js")
, sha = require("./utils/sha.js")
, path = require("path")
if (args.length === 0) args = ["."]
if (args.length !== 1) return cb(publish.usage)
- log.verbose(args, "publish")
+ log.verbose("publish", args)
var arg = args[0]
// if it's a local folder, then run the prepublish there, first.
readJson(path.resolve(arg, "package.json"), function (er, data) {
function cacheAddPublish (arg, didPre, isRetry, cb) {
npm.commands.cache.add(arg, function (er, data) {
if (er) return cb(er)
- log.silly(data, "publish")
+ log.silly("publish", data)
var cachedir = path.resolve( npm.cache
, data.name
, data.version
// check for publishConfig hash
if (data.publishConfig) {
Object.keys(data.publishConfig).forEach(function (k) {
- log.info(k + "=" + data.publishConfig[k], "publishConfig")
+ log.info("publishConfig", k + "=" + data.publishConfig[k])
npm.config.set(k, data.publishConfig[k])
})
}
, tb = path.resolve(cf, "package-"+bd+".tgz")
, sourceBall = path.resolve(cf, "package.tgz")
- log.verbose("about to cache unpack")
- log.verbose(sourceBall, "the tarball")
+ log.verbose("preBuild", "about to cache unpack")
+ log.verbose("preBuild", "tarball = %s", sourceBall)
npm.commands.install(pb, sourceBall, function (er) {
- log.info(data._id, "prebuild done")
+ log.info("preBuild", "done", data._id)
// build failure just means that we can't prebuild
if (er) {
- log.warn(er.message, "prebuild failed "+bd)
+ log.warn("preBuild", "failed (continuing without prebuild)", bd, er)
return cb()
}
// now strip the preinstall/install scripts
function regPublish (data, prebuilt, isRetry, arg, cachedir, cb) {
// check to see if there's a README.md in there.
var readme = path.resolve(cachedir, "README.md")
+ , tarball = cachedir + ".tgz"
+
fs.readFile(readme, function (er, readme) {
// ignore error. it's an optional feature
- registry.publish(data, prebuilt, readme, function (er) {
- if (er && er.errno === npm.EPUBLISHCONFLICT
+
+ registry.publish(data, tarball, readme, function (er) {
+ if (er && er.code === "EPUBLISHCONFLICT"
&& npm.config.get("force") && !isRetry) {
- log.warn("Forced publish over "+data._id, "publish")
+ log.warn("publish", "Forced publish over "+data._id)
return npm.commands.unpublish([data._id], function (er) {
// ignore errors. Use the force. Reach out with your feelings.
publish([arg], true, cb)
var readInstalled = require("./utils/read-installed.js")
, semver = require("semver")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, path = require("path")
, npm = require("./npm.js")
, output = require("./utils/output.js")
function rebuild (args, cb) {
readInstalled(npm.prefix, function (er, data) {
- log(typeof data, "read Installed")
+ log.info("readInstalled", typeof data)
if (er) return cb(er)
var set = filter(data, args)
, folders = Object.keys(set).filter(function (f) {
return f !== npm.prefix
})
if (!folders.length) return cb()
- log.silly(folders, "rebuild set")
+ log.silly("rebuild set", folders)
cleanBuild(folders, set, cb)
})
}
}
}
if (pass && data._id) {
- log.verbose([data.path, data._id], "path id")
+ log.verbose("rebuild", "path, id", [data.path, data._id])
set[data.path] = data._id
}
// need to also dive through kids, always.
var npm = require("./npm.js")
, output = require("./utils/output.js")
- , log = require("./utils/log.js")
root.usage = "npm root\nnpm root -g\n(just prints the root folder)"
, npm = require("./npm.js")
, path = require("path")
, readJson = require("./utils/read-json.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, chain = require("slide").chain
, fs = require("graceful-fs")
, asyncMap = require("slide").asyncMap
if (!cmd.match(/^(pre|post)/)) {
cmds = ["pre"+cmd].concat(cmds).concat("post"+cmd)
}
- log.verbose(cmds, "run-script")
+ log.verbose("run-script", cmds)
chain(cmds.map(function (c) {
// when running scripts explicitly, assume that they're trusted.
return [lifecycle, pkg, c, wd, true]
module.exports = exports = search
var npm = require("./npm.js")
- , registry = require("./utils/npm-registry-client/index.js")
+ , registry = npm.registry
, semver = require("semver")
, output
- , log = require("./utils/log.js")
search.usage = "npm search [some search terms ...]"
}
function getFilteredData (staleness, args, notArgs, cb) {
- registry.get( "/-/all", null, staleness, false
+ registry.get( "/-/all", staleness, false
, true, function (er, data) {
if (er) return cb(er)
return cb(null, filter(data, args, notArgs))
var npm = require("./npm.js")
, output = require("./utils/output.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, fs = require("fs")
, path = require("path")
if (typeof cb !== "function") cb = silent, silent = false
if (args.length) {
- log.warn("shrinkwrap doesn't take positional args.")
+ log.warn("shrinkwrap", "doesn't take positional args")
}
npm.commands.ls([], true, function (er, _, pkginfo) {
try {
var swdata = JSON.stringify(pkginfo, null, 2) + "\n"
} catch (er) {
- log.error("Error converting package info to json")
+ log.error("shrinkwrap", "Error converting package info to json")
return cb(er)
}
module.exports = star
var npm = require("./npm.js")
- , registry = require("./utils/npm-registry-client/index.js")
- , log = require("./utils/log.js")
+ , registry = npm.registry
+ , log = require("npmlog")
, asyncMap = require("slide").asyncMap
, output = require("./utils/output.js")
+ "npm unstar <package> [pkg, pkg, ...]"
star.completion = function (opts, cb) {
- registry.get("/-/short", null, 60000, function (er, list) {
+ registry.get("/-/short", 60000, function (er, list) {
return cb(null, list || [])
})
}
registry.star(pkg, using, function (er, data, raw, req) {
if (!er) {
output.write(s + " "+pkg, npm.config.get("outfd"))
- log.verbose(data, "back from star/unstar")
+ log.verbose("star", data)
}
cb(er, data, raw, req)
})
module.exports = substack
var npm = require("./npm.js")
- , log = require("./utils/log.js")
+
+var isms =
+ [ "\033[32mbeep \033[35mboop\033[m"
+ , "Replace your configs with services"
+ , "SEPARATE ALL THE CONCERNS!"
+ , "MODULE ALL THE THINGS!"
+ , "\\o/"
+ , "but first, burritos"
+ , "full time mad scientist here"
+ , "c/,,\\" ]
function substack (args, cb) {
- console.log("\033[32mbeep \033[35mboop\033[m")
+ var i = Math.floor(Math.random() * isms.length)
+ console.log(isms[i])
var c = args.shift()
if (c) npm.commands[c](args, cb)
else cb()
tag.completion = require("./unpublish.js").completion
var npm = require("./npm.js")
+ , registry = npm.registry
function tag (args, cb) {
var thing = (args.shift() || "").split("@")
, version = thing.join("@")
, t = args.shift() || npm.config.get("tag")
if (!project || !version || !t) return cb("Usage:\n"+tag.usage)
- require("./utils/npm-registry-client/index.js").tag(project, version, t, cb)
+ registry.tag(project, version, t, cb)
}
, lifecycle = require("./utils/lifecycle.js")
, asyncMap = require("slide").asyncMap
, chain = require("slide").chain
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, build = require("./build.js")
// args is a list of folders.
log.verbose([binRoot, pkg.bin], "binRoot")
asyncMap(Object.keys(pkg.bin), function (b, cb) {
if (process.platform === "win32") {
- rm(path.resolve(binRoot, b) + ".cmd", cb)
+ chain([ [rm, path.resolve(binRoot, b) + ".cmd"]
+ , [rm, path.resolve(binRoot, b) ] ], cb)
} else {
gentlyRm( path.resolve(binRoot, b)
, !npm.config.get("force") && folder
uninstall.completion = require("./utils/completion/installed-shallow.js")
var fs = require("graceful-fs")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, readJson = require("./utils/read-json.js")
, path = require("path")
, npm = require("./npm.js")
// uninstall .. should not delete /usr/local/lib/node_modules/..
var p = path.join(path.resolve(nm), path.join("/", arg))
if (path.resolve(p) === nm) {
- log.warn(arg, "uninstall: invalid argument")
+ log.warn("uninstall", "invalid argument: %j", arg)
return cb(null, [])
}
fs.lstat(p, function (er) {
if (er) {
- log.warn(arg, "Not installed in "+nm)
+ log.warn("uninstall", "not installed in %s: %j", nm, arg)
return cb(null, [])
}
cb(null, p)
module.exports = unpublish
-var registry = require("./utils/npm-registry-client/index.js")
- , log = require("./utils/log.js")
+var log = require("npmlog")
, npm = require("./npm.js")
+ , registry = npm.registry
, readJson = require("./utils/read-json.js")
, path = require("path")
, output = require("./utils/output.js")
// remove from the cache first
npm.commands.cache(["clean", project, version], function (er) {
- if (er) return log.er(cb, "Failed to clean cache")(er)
+ if (er) {
+ log.error("unpublish", "Failed to clean cache")
+ return cb(er)
+ }
+
registry.unpublish(project, version, cb)
})
}
var npm = require("./npm.js")
, lifecycle = require("./utils/lifecycle.js")
, asyncMap = require("slide").asyncMap
- , log = require("./utils/log.js")
+ , log = require("npmlog")
// load these, just so that we know that they'll be available, in case
// npm itself is getting overwritten.
function update (args, cb) {
npm.commands.outdated(args, true, function (er, outdated) {
- log(outdated, "outdated updating")
+ log.info("outdated", "updating", outdated)
if (er) return cb(er)
asyncMap(outdated, function (ww, cb) {
, chain = require("slide").chain
, mkdir = require("mkdirp")
, rm = require("rimraf")
- , log = require("./log.js")
+ , log = require("npmlog")
, path = require("path")
, relativize = require("./relativize.js")
, npm = require("../npm.js")
fs.writeFile(to + ".cmd", cmd, "utf8", function (er) {
if (er) {
- log.warn("Could not write "+to+".cmd", "cmdShim")
+ log.warn("cmdShim", "Could not write "+to+".cmd")
return cb(er)
}
fs.writeFile(to, sh, "utf8", function (er) {
if (er) {
- log.warn("Could not write "+to, "shShim")
+ log.warn("shShim", "Could not write "+to)
return cb(er)
}
fs.chmod(to, 0755, cb)
module.exports = remotePackages
-var registry = require("../npm-registry-client/index.js")
+var npm = require("../../npm.js")
+ , registry = npm.registry
, containsSingleMatch = require("./contains-single-match.js")
, getCompletions = require("./get-completions.js")
if (name === undefined) name = ""
if (name.indexOf("/") !== -1) return cb(null, [])
// use up-to 1 hour stale cache. not super urgent.
- registry.get("/", null, 3600, function (er, d) {
+ registry.get("/", 3600, function (er, d) {
if (er) return cb(er)
var remoteList = Object.keys(d)
, found = remoteList.indexOf(name)
module.exports = users
-var registry = require("../npm-registry-client/index.js")
+var npm = require("../../npm")
+ , registry = npm.registry
, containsSingleMatch = require("./contains-single-match.js")
, getCompletions = require("./get-completions.js")
- , log = require("../log.js")
+ , log = require("npmlog")
function users (args, index, cb) {
var name = (args.length + 1 === index) ? args[args.length - 1] : ""
if (name === undefined) name = ""
// use up-to 1 day stale cache. doesn't change much
- log.warn("About to fetch", "users completion")
- registry.get("/-/users", null, 24*60*60, function (er, d) {
- log.warn(d, "userdata")
- log.warn(name, "name")
+ log.warn("users completion", "About to fetch")
+ registry.get("/-/users", 24*60*60, function (er, d) {
+ log.warn("userdata", d)
+ log.warn("name", name)
if (er) return cb(er)
var remoteList = Object.keys(d)
, simpleMatches = getCompletions(name, remoteList)
, stableFamily = semver.parse(process.version)
, os = require("os")
, nopt = require("nopt")
- , log = require("./log.js")
+ , log = require("npmlog")
, npm = require("../npm.js")
function Octal () {}
nopt.typeDefs.Octal = { type: Octal, validate: validateOctal }
nopt.invalidHandler = function (k, val, type, data) {
- log.warn(k + "=" + JSON.stringify(val), "invalid config")
+ log.warn("invalid config", k + "=" + JSON.stringify(val))
if (Array.isArray(type)) {
if (type.indexOf(url) !== -1) type = url
switch (type) {
case Octal:
- log.warn("Must be octal number, starting with 0", "invalid config")
+ log.warn("invalid config", "Must be octal number, starting with 0")
break
case url:
- log.warn("Must be a full url with 'http://'", "invalid config")
+ log.warn("invalid config", "Must be a full url with 'http://'")
break
case path:
- log.warn("Must be a valid filesystem path", "invalid config")
+ log.warn("invalid config", "Must be a valid filesystem path")
break
case Number:
- log.warn("Must be a numeric value", "invalid config")
+ log.warn("invalid config", "Must be a numeric value")
break
}
}
if (!stableFamily || (+stableFamily[2] % 2)) stableFamily = null
else stableFamily = stableFamily[1] + "." + stableFamily[2]
-var httpsOk = semver.satisfies(process.version, ">=0.4.9")
-var winColor = semver.satisfies(process.version, ">=0.5.9")
-
var defaults
var temp = process.env.TMPDIR
, "cache-max": Infinity
, "cache-min": 0
- , color : process.platform !== "win32" || winColor
+ , color : true
, coverage: false
, depth: Infinity
, description : true
, "init.author.url" : ""
, json: false
, link: false
- , logfd : 2
, loglevel : "http"
- , logprefix : process.platform !== "win32" || winColor
, long : false
, message : "%s"
, "node-version" : process.version
process.env.HTTP_PROXY || process.env.http_proxy || null
, "user-agent" : "npm/" + npm.version + " node/" + process.version
, "rebuild-bundle" : true
- , registry : "http" + (httpsOk ? "s" : "") + "://registry.npmjs.org/"
+ , registry : "https://registry.npmjs.org/"
, rollback : true
, save : false
, "save-dev" : false
, "init.author.url" : ["", url]
, json: Boolean
, link: Boolean
- , logfd : [Number, Stream]
, loglevel : ["silent","win","error","warn","http","info","verbose","silly"]
- , logprefix : Boolean
, long : Boolean
, message: String
, "node-version" : [null, semver]
module.exports = errorHandler
var cbCalled = false
- , log = require("./log.js")
+ , log = require("npmlog")
, npm = require("../npm.js")
, rm = require("rimraf")
- , constants = require("constants")
, itWorked = false
, path = require("path")
, ini = require("./ini.js")
if (itWorked) log.info("ok")
else {
if (!cbCalled) {
- log.error("cb() never called!\n ")
+ log.error("", "cb() never called!")
}
+
if (wroteLogFile) {
- log.error([""
+ log.error("", [""
,"Additional logging details can be found in:"
," " + path.resolve("npm-debug.log")
].join("\n"))
wroteLogFile = false
}
- log.win("not ok")
+ log.error("not ok", "code", code)
}
var doExit = npm.config.get("_exit")
exitCode = exitCode || code
var doExit = npm.config.get("_exit")
- log.verbose([code, doExit], "exit")
- if (log.level === log.LEVEL.silent) noLog = true
+ log.verbose("exit", [code, doExit])
+ if (log.level === "silent") noLog = true
if (code && !noLog) writeLogFile(reallyExit)
else rm("npm-debug.log", function () { rm(npm.tmp, reallyExit) })
function reallyExit() {
+ // truncate once it's been written.
+ log.record.length = 0
+
itWorked = !code
// just emit a fake exit event.
cbCalled = true
if (!er) return exit(0)
if (!(er instanceof Error)) {
- log.error(er)
+ log.error("weird error", er)
return exit(1, true)
}
var m = er.code || er.message.match(/^(?:Error: )?(E[A-Z]+)/)
- if (m) {
- m = m[1]
- if (!constants[m] && !npm[m]) constants[m] = {}
- er.errno = npm[m] || constants[m]
- }
+ if (m && !er.code) er.code = m
- console.error("")
- switch (er.code || er.errno) {
+ switch (er.code) {
case "ECONNREFUSED":
- case constants.ECONNREFUSED:
- log.error(er)
- log.error(["\nIf you are behind a proxy, please make sure that the"
+ log.error("", er)
+ log.error("", ["\nIf you are behind a proxy, please make sure that the"
,"'proxy' config is set properly. See: 'npm help config'"
].join("\n"))
break
case "EACCES":
case "EPERM":
- case constants.EACCES:
- case constants.EPERM:
- log.error(er)
- log.error(["\nPlease try running this command again as root/Administrator."
+ log.error("", er)
+ log.error("", ["\nPlease try running this command again as root/Administrator."
].join("\n"))
break
- case npm.ELIFECYCLE:
+ case "ELIFECYCLE":
er.code = "ELIFECYCLE"
- log.error(er.message)
- log.error(["","Failed at the "+er.pkgid+" "+er.stage+" script."
+ log.error("", er.message)
+ log.error("", ["","Failed at the "+er.pkgid+" "+er.stage+" script."
,"This is most likely a problem with the "+er.pkgname+" package,"
,"not with npm itself."
,"Tell the author that this fails on your system:"
].join("\n"))
break
- case npm.EJSONPARSE:
+ case "EJSONPARSE":
er.code = "EJSONPARSE"
- log.error(er.message)
- log.error("File: "+er.file)
- log.error(["Failed to parse package.json data."
+ log.error("", er.message)
+ log.error("", "File: "+er.file)
+ log.error("", ["Failed to parse package.json data."
,"package.json must be actual JSON, not just JavaScript."
,"","This is not a bug in npm."
,"Tell the package author to fix their package.json file."
].join("\n"), "JSON.parse")
break
- case npm.E404:
+ case "E404":
er.code = "E404"
if (er.pkgid && er.pkgid !== "-") {
var msg = ["'"+er.pkgid+"' is not in the npm registry."
}
msg.push("\nNote that you can also install from a"
,"tarball, folder, or http url, or git url.")
- log.error(msg.join("\n"), "404")
+ log.error("404", msg.join("\n"))
}
break
- case npm.EPUBLISHCONFLICT:
+ case "EPUBLISHCONFLICT":
er.code = "EPUBLISHCONFLICT"
- log.error(["Cannot publish over existing version."
+ log.error("publish fail", ["Cannot publish over existing version."
,"Bump the 'version' field, set the --force flag, or"
," npm unpublish '"+er.pkgid+"'"
,"and try again"
- ].join("\n"), "publish fail" )
+ ].join("\n"))
break
- case npm.EISGIT:
+ case "EISGIT":
er.code = "EISGIT"
- log.error([er.message
+ log.error("git", [er.message
," "+er.path
,"Refusing to remove it. Update manually,"
,"or move it out of the way first."
- ].join("\n"), "git" )
+ ].join("\n"))
break
- case npm.ECYCLE:
+ case "ECYCLE":
er.code = "ECYCLE"
- log.error([er.message
+ log.error("cycle", [er.message
,"While installing: "+er.pkgid
,"Found a pathological dependency case that npm cannot solve."
,"Please report this to the package author."
].join("\n"))
break
- case npm.ENOTSUP:
- er.code = "ENOTSUP"
- log.error([er.message
- ,"Not compatible with your version of node/npm: "+er.pkgid
- ,"Required: "+JSON.stringify(er.required)
- ,"Actual: "
- +JSON.stringify({npm:npm.version
- ,node:npm.config.get("node-version")})
- ].join("\n"))
- break
-
- case npm.EBADPLATFORM:
+ case "EBADPLATFORM":
er.code = "EBADPLATFORM"
- log.error([er.message
+ log.error("notsup", [er.message
,"Not compatible with your operating system or architecture: "+er.pkgid
,"Valid OS: "+er.os.join(",")
,"Valid Arch: "+er.cpu.join(",")
break
case "EEXIST":
- case constants.EEXIST:
log.error([er.message
,"File exists: "+er.path
,"Move it away, and try again."].join("\n"))
break
+ case "ENOTSUP":
+ if (er.required) {
+ log.error("notsup", [er.message
+ ,"Not compatible with your version of node/npm: "+er.pkgid
+ ,"Required: "+JSON.stringify(er.required)
+ ,"Actual: "
+ +JSON.stringify({npm:npm.version
+ ,node:npm.config.get("node-version")})
+ ].join("\n"))
+ break
+ } // else passthrough
+
default:
- log.error(er)
- log.error(["You may report this log at:"
+ log.error("", er)
+ log.error("", ["You may report this log at:"
," <http://github.com/isaacs/npm/issues>"
,"or email it to:"
," <npm-@googlegroups.com>"
}
var os = require("os")
- log.error("")
- log.error(os.type() + " " + os.release(), "System")
- log.error(process.argv
- .map(JSON.stringify).join(" "), "command")
- log.error(process.cwd(), "cwd")
- log.error(process.version, "node -v")
- log.error(npm.version, "npm -v")
+ // just a line break
+ console.error("")
+ log.error("System", os.type() + " " + os.release())
+ log.error("command", process.argv
+ .map(JSON.stringify).join(" "))
+ log.error("cwd", process.cwd())
+ log.error("node -v", process.version)
+ log.error("npm -v", npm.version)
; [ "file"
, "path"
, "fstream_class"
, "fstream_finish_call"
, "fstream_linkpath"
- , "arguments"
, "code"
, "message"
, "errno"
].forEach(function (k) {
- if (er[k]) log.error(er[k], k)
+ if (er[k]) log.error(k, er[k])
})
if (er.fstream_stack) {
- log.error(er.fstream_stack.join("\n"), "fstream_stack")
+ log.error("fstream_stack", er.fstream_stack.join("\n"))
}
if (er.errno && typeof er.errno !== "object") log.error(er.errno, "errno")
var fs = require("graceful-fs")
, fstr = fs.createWriteStream("npm-debug.log")
, util = require("util")
-
- log.history.forEach(function (m) {
- var lvl = log.LEVEL[m.level]
- , pref = m.pref ? " " + m.pref : ""
- , b = lvl + pref + " "
- , eol = process.platform === "win32" ? "\r\n" : "\n"
- , msg = typeof m.msg === "string" ? m.msg
- : msg instanceof Error ? msg.stack || msg.message
- : util.inspect(m.msg, 0, 4)
- fstr.write(new Buffer(b
- +(msg.split(/\r?\n+/).join(eol+b))
- + eol))
+ , eol = process.platform === "win32" ? "\r\n" : "\n"
+ , out = ""
+
+ log.record.forEach(function (m) {
+ var pref = [m.id, m.level]
+ if (m.prefix) pref.push(m.prefix)
+ pref = pref.join(' ')
+
+ m.message.trim().split(/\r?\n/).map(function (line) {
+ return (pref + ' ' + line).trim()
+ }).forEach(function (line) {
+ out += line + eol
+ })
})
- fstr.end()
+
+ fstr.end(out)
fstr.on("close", cb)
}
module.exports = exec
exec.spawn = spawn
-exec.pipe = pipe
-var log = require("./log.js")
+var log = require("npmlog")
, child_process = require("child_process")
, util = require("util")
, npm = require("../npm.js")
}
}
if (uid !== myUID) {
- log.verbose(uid, "Setting uid from "+myUID)
- log.verbose(new Error().stack, "stack at uid setting")
+ log.verbose("set uid", "from=%s to=%s", myUID, uid)
}
if (uid && gid && (isNaN(uid) || isNaN(gid))) {
})
}
- log.silly(cmd+" "+args.map(JSON.stringify).join(" "), "exec")
+ log.silly("exec", cmd+" "+args.map(JSON.stringify).join(" "))
var stdout = ""
, stderr = ""
, cp = spawn(cmd, args, env, takeOver, cwd, uid, gid)
return cp
}
-function logger (d) { if (d) process.stderr.write(d+"") }
-function pipe (cp1, cp2, cb) {
- util.pump(cp1.stdout, cp2.stdin)
- var errState = null
- , buff1 = ""
- , buff2 = ""
- if (log.level <= log.LEVEL.silly) {
- cp1.stderr.on("data", logger)
- cp2.stderr.on("data", logger)
- } else {
- cp1.stderr.on("data", function (d) { buff1 += d })
- cp2.stderr.on("data", function (d) { buff2 += d })
- }
-
- cp1.on("exit", function (code) {
- if (!code) return log.verbose(cp1.name || "<unknown>", "success")
- if (!cp2._exited) cp2.kill()
- log.error(buff1, cp1.name || "<unknown>")
- cb(errState = new Error(
- "Failed "+(cp1.name || "<unknown>")+"\nexited with "+code))
- })
-
- cp2.on("exit", function (code) {
- cp2._exited = true
- if (errState) return
- if (!code) return log.verbose(cp2.name || "<unknown>", "success", cb)
- log.error(buff2, cp2.name || "<unknown>")
- cb(new Error( "Failed "
- + (cp2.name || "<unknown>")
- + "\nexited with " + code ))
- })
-}
function spawn (c, a, env, takeOver, cwd, uid, gid) {
var fds = [ 0, 1, 2 ]
, fs = require("graceful-fs")
, npm = require("../npm.js")
, url = require("url")
- , log = require("./log.js")
+ , log = require("npmlog")
, path = require("path")
, mkdir = require("mkdirp")
, chownr = require("chownr")
function fetch (remote, local, headers, cb) {
if (typeof cb !== "function") cb = headers, headers = {}
- log.verbose(local, "fetch to")
+ log.verbose("fetch", "to=", local)
mkdir(path.dirname(local), function (er, made) {
if (er) return cb(er)
fetch_(remote, local, headers, cb)
function makeRequest (remote, fstr, headers) {
remote = url.parse(remote)
- log.http(remote.href, "GET")
+ log.http("GET", remote.href)
regHost = regHost || url.parse(npm.config.get("registry")).host
if (remote.host === regHost && npm.config.get("always-auth")) {
, onResponse: onResponse }).pipe(fstr)
function onResponse (er, res) {
if (er) return fstr.emit("error", er)
- log.http(res.statusCode + " " + remote.href)
+ log.http(res.statusCode, remote.href)
}
}
, mkdir = require("mkdirp")
, npm = require("../npm.js")
- , log = require("./log.js")
+ , log = require("npmlog")
, configDefs = require("./config-defs.js")
, myUid = process.env.SUDO_UID !== undefined
// just put this here for a moment, so that the logs
// in the config-loading phase don't cause it to blow up.
-configList.push({loglevel:"warn"})
function resolveConfigs (cli, cb_) {
defaultConfig = defaultConfig || configDefs.defaults
if (er) return cb(er)
if (conf.hasOwnProperty("prefix")) {
- log.warn("Cannot set prefix in globalconfig file"
+ log.warn( "globalconfig"
+ , "Cannot set prefix in globalconfig file"
, cl.get("globalconfig"))
delete conf.prefix
}
function parseFile (file, cb) {
if (!file) return cb(null, {})
- log.verbose(file, "config file")
+ log.verbose("config file", file)
fs.readFile(file, function (er, data) {
// treat all errors as just an empty file
if (er) return cb(null, {})
exports = module.exports = lifecycle
exports.cmd = cmd
-var log = require("./log.js")
+var log = require("npmlog")
, exec = require("./exec.js")
, npm = require("../npm.js")
, path = require("path")
while (pkg && pkg._data) pkg = pkg._data
if (!pkg) return cb(new Error("Invalid package data"))
- log(pkg._id, stage)
+ log.info(stage, pkg._id)
if (!pkg.scripts) pkg.scripts = {}
validWd(wd || path.resolve(npm.dir, pkg.name), function (er, wd) {
if ((wd.indexOf(npm.dir) !== 0 || path.basename(wd) !== pkg.name)
&& !unsafe && pkg.scripts[stage]) {
- log.warn(pkg._id+" "+pkg.scripts[stage], "skipping, cannot run in "+wd)
+ log.warn( "cannot run in wd", "%s %s (wd=%s)"
+ , pkg._id, pkg.scripts[stage], wd)
return cb()
}
if (failOk) {
cb = (function (cb_) { return function (er) {
- if (er) log.warn(er.message, "continuing anyway")
+ if (er) log.warn("continuing anyway", er.message)
cb_()
}})(cb)
}
if (npm.config.get("force")) {
cb = (function (cb_) { return function (er) {
- if (er) log(er, "forced, continuing")
+ if (er) log.info("forced, continuing", er)
cb_()
}})(cb)
}
shFlag = "/c"
}
- log.verbose(unsafe, "unsafe-perm in lifecycle")
+ log.verbose("unsafe-perm in lifecycle", unsafe)
var note = "\n> " + pkg._id + " " + stage + " " + wd
+ "\n> " + cmd + "\n"
, user, group
, function (er, code, stdout, stderr) {
if (er && !npm.ROLLBACK) {
- log("Failed to exec "+stage+" script", pkg._id)
+ log.info(pkg._id, "Failed to exec "+stage+" script")
er.message = pkg._id + " "
+ stage + ": `" + env.npm_lifecycle_script+"`\n"
+ er.message
- if (er.errno !== constants.EPERM) {
- er.errno = npm.ELIFECYCLE
+ if (er.code !== "EPERM") {
+ er.code = "ELIFECYCLE"
}
er.pkgid = pkg._id
er.stage = stage
er.pkgname = pkg.name
return cb(er)
} else if (er) {
- log.error(er, pkg._id+"."+stage)
- log.error("failed, but continuing anyway", pkg._id+"."+stage)
+ log.error(pkg._id+"."+stage, er)
+ log.error(pkg._id+"."+stage, "continuing anyway")
return cb()
}
cb(er)
, function (er) {
if (er) {
er.message += "\nFailed to exec "+stage+" hook script"
- log(er, pkg._id)
+ log.info(pkg._id, er)
}
if (npm.ROLLBACK) return cb()
cb(er)
return
}
var value = ini.get(i)
- if (/^(log|out)fd$/.test(i) && typeof value === "object") {
- // not an fd, a stream
- return
- }
if (!value) value = ""
else if (typeof value !== "string") value = JSON.stringify(value)
, chain = require("slide").chain
, mkdir = require("mkdirp")
, rm = require("./gently-rm.js")
- , log = require("./log.js")
, path = require("path")
, relativize = require("./relativize.js")
, npm = require("../npm.js")
function link (from, to, gently, cb) {
if (typeof cb !== "function") cb = gently, gently = null
if (npm.config.get("force")) gently = false
+
+ // junction symlinks on windows must be absolute
+ var rel = process.platform === "win32" ? from : relativize(from, to)
+
chain
( [ [fs, "stat", from]
, [rm, to, gently]
, [mkdir, path.dirname(to)]
- , [fs, "symlink", relativize(from, to), to] ]
+ , [fs, "symlink", rel, to, "junction"] ]
, cb)
}
module.exports = loadPackageDefaults
var path = require("path")
- , log = require("./log.js")
+ , log = require("npmlog")
, find = require("./find.js")
, asyncMap = require("slide").asyncMap
, npm = require("../npm.js")
pkg._defaultsLoaded = true
asyncMap
( [pkg]
- , function (pkg, cb) { log.verbose(pkg._id, "loadDefaults", cb) }
+ , function (pkg, cb) { log.verbose("loadDefaults", pkg._id); cb() }
, readDefaultBins(pkgDir)
, readDefaultMans(pkgDir)
, function (er) { cb(er, pkg) } )
var bin = pkg.directories && pkg.directories.bin
if (pkg.bins) pkg.bin = pkg.bins, delete pkg.bins
if (pkg.bin || !bin) return cb(null, pkg)
- log.verbose("linking default bins", pkg._id)
+ log.verbose("loadDefaults", pkg._id, "linking default bins")
var binDir = path.join(pkgDir, bin)
pkg.bin = {}
find(binDir, function (er, filenames) {
, val = filename.substr(cut)
if (key.length && val.length) pkg.bin[key] = val
})
- log.silly(pkg.bin, pkg._id+".bin")
+ log.silly("loadDefaults", pkg._id, "bin", pkg.bin)
cb(null, pkg)
})
}}
+++ /dev/null
-
-module.exports = log
-
-var output = require("./output.js")
-
-function colorize (msg, color) {
- return msg ? "\033["+color+"m"+msg+"\033[0m" : ""
-}
-
-var l = -1
- , LEVEL = { silly : l++
- , verbose : l++
- , info : l++
- , "http" : l++
- , WARN : l++
- , "ERR!" : l++
- , ERROR : "ERR!"
- , ERR : "ERR!"
- , win : 0x15AAC5
- , paused : 0x19790701
- , silent : 0xDECAFBAD
- }
- , COLOR = {}
- , SHOWLEVEL = null
- , normalNames = {}
-log.LEVEL = LEVEL
-normalNames[LEVEL["ERR!"]] = "error"
-normalNames[LEVEL.WARN] = "warn"
-normalNames[LEVEL.info] = "info"
-normalNames[LEVEL.verbose] = "verbose"
-normalNames[LEVEL.silly] = "silly"
-normalNames[LEVEL.win] = "win"
-
-Object.keys(LEVEL).forEach(function (l) {
- if (typeof LEVEL[l] === "string") LEVEL[l] = LEVEL[LEVEL[l]]
- else LEVEL[LEVEL[l]] = l
- LEVEL[l.toLowerCase()] = LEVEL[l]
- if (l === "silent" || l === "paused") return
- log[l] = log[l.toLowerCase()] =
- function (msg, pref, cb) { return log(msg, pref, l, cb) }
-})
-
-COLOR[LEVEL.silly] = 30
-COLOR[LEVEL.verbose] = "34;40"
-COLOR[LEVEL.info] = 32
-COLOR[LEVEL.http] = "32;40"
-COLOR[LEVEL.warn] = "30;41"
-COLOR[LEVEL.error] = "31;40"
-for (var c in COLOR) COLOR[LEVEL[c]] = COLOR[c]
-COLOR.npm = "37;40"
-COLOR.pref = 35
-
-var logBuffer = []
- , ini = require("./ini.js")
- , waitForConfig
-log.waitForConfig = function () { waitForConfig = true }
-
-// now the required stuff has been loaded,
-// so the transitive module dep will work
-var util = require("util")
- , npm = require("../npm.js")
- , net = require("net")
-
-Object.defineProperty(log, "level",
- { get : function () {
- if (SHOWLEVEL !== null) return SHOWLEVEL
- var show = npm.config && npm.config.get("loglevel") || ''
- show = show.split(",")[0]
- if (!isNaN(show)) show = +show
- else if (!LEVEL.hasOwnProperty(show)) {
- util.error("Invalid loglevel config: "+JSON.stringify(show))
- show = "info"
- }
- if (isNaN(show)) show = LEVEL[show]
- else show = +show
- if (!waitForConfig || ini.resolved) SHOWLEVEL = show
- return show
- }
- , set : function (l) {
- SHOWLEVEL = null
- npm.config.set("showlevel", l)
- }
- })
-
-function log (msg, pref, level, cb) {
- if (typeof level === "function") cb = level, level = null
- var show = log.level
- if (show === LEVEL.silent || show === LEVEL.paused) return cb && cb()
- if (level == null) level = LEVEL.info
- if (isNaN(level)) level = LEVEL[level]
- else level = +level
-
- // logging just undefined is almost never the right thing.
- // a lot of these are kicking around throughout the codebase
- // with relatively unhelpful prefixes.
- if (msg === undefined && level > LEVEL.silly) {
- msg = new Error("undefined log message")
- }
- if (typeof msg === "object" && (msg instanceof Error)) level = LEVEL.error
- if (!ini.resolved && waitForConfig || level === LEVEL.paused) {
- return logBuffer.push([msg, pref, level, cb])
- }
- if (logBuffer.length && !logBuffer.discharging) {
- logBuffer.push([msg, pref, level, cb])
- logBuffer.discharging = true
- logBuffer.forEach(function (l) { log.apply(null, l) })
- logBuffer.length = 0
- delete logBuffer.discharging
- return
- }
- log.level = show
- npm.emit("log", { level : level, msg : msg, pref : pref, cb : cb })
- npm.emit("log."+normalNames[level], { msg : msg, pref : pref, cb : cb })
-}
-
-var loglog = log.history = []
- , loglogLen = 0
-npm.on("log", function (logData) {
- var level = logData.level
- , msg = logData.msg
- , pref = logData.pref
- , cb = logData.cb || function () {}
- , show = log.level
- , spaces = " "
- , logFD = npm.config.get("logfd")
- if (msg instanceof Error) {
- msg = logData.msg = msg.stack || msg.toString()
- }
- loglog.push(logData)
- loglogLen ++
- if (loglogLen > 2000) {
- loglog = loglog.slice(loglogLen - 1000)
- loglogLen = 1000
- }
- if (!isFinite(level) || level < show) return cb()
- if (typeof msg !== "string" && !(msg instanceof Error)) {
- msg = util.inspect(msg, 0, 4, true)
- }
-
- // console.error("level, showlevel, show", level, show, (level >= show))
- if (pref && COLOR.pref) {
- pref = colorize(pref, COLOR.pref)
- }
- if (!pref) pref = ""
-
- if (npm.config.get("logprefix")) {
- pref = colorize("npm", COLOR.npm)
- + (COLOR[level] ? " "+colorize(
- (LEVEL[level]+spaces).substr(0,4), COLOR[level]) : "")
- + (pref ? (" " + pref) : "")
- }
- if (pref) pref += " "
-
-
-
- if (msg.indexOf("\n") !== -1) {
- msg = msg.split(/\n/).join("\n"+pref)
- }
- msg = pref+msg
- return output.write(msg, logFD, cb)
-})
-
-log.er = function (cb, msg) {
- if (!msg) throw new Error(
- "Why bother logging it if you're not going to print a message?")
- return function (er) {
- if (er) log.error(msg)
- cb.apply(this, arguments)
- }
-}
+++ /dev/null
-
-module.exports = adduser
-
-var uuid = require("node-uuid")
- , request = require("./request.js")
- , log = require("../log.js")
- , npm = require("../../npm.js")
- , crypto
-
-try {
- crypto = process.binding("crypto") && require("crypto")
-} catch (ex) {}
-
-function sha (s) {
- return crypto.createHash("sha1").update(s).digest("hex")
-}
-
-function adduser (username, password, email, cb) {
- if (!crypto) return cb(new Error(
- "You must compile node with ssl support to use the adduser feature"))
-
- password = ("" + (password || "")).trim()
- if (!password) return cb(new Error("No password supplied."))
-
- email = ("" + (email || "")).trim()
- if (!email) return cb(new Error("No email address supplied."))
- if (!email.match(/^[^@]+@[^\.]+\.[^\.]+/)) {
- return cb(new Error("Please use a real email address."))
- }
-
- if (password.indexOf(":") !== -1) return cb(new Error(
- "Sorry, ':' chars are not allowed in passwords.\n"+
- "See <https://issues.apache.org/jira/browse/COUCHDB-969> for why."))
- var salt = uuid()
- , userobj =
- { name : username
- , salt : salt
- , password_sha : sha(password + salt)
- , email : email
- , _id : 'org.couchdb.user:'+username
- , type : "user"
- , roles : []
- , date: new Date().toISOString()
- }
- cb = done(cb)
- log.verbose(userobj, "before first PUT")
- request.PUT
- ( '/-/user/org.couchdb.user:'+encodeURIComponent(username)
- , userobj
- , function (error, data, json, response) {
- // if it worked, then we just created a new user, and all is well.
- // but if we're updating a current record, then it'll 409 first
- if (error && !npm.config.get("_auth")) {
- // must be trying to re-auth on a new machine.
- // use this info as auth
- npm.config.set("username", username)
- npm.config.set("_password", password)
- var b = new Buffer(username + ":" + password)
- npm.config.set("_auth", b.toString("base64"))
- }
- if (!error || !response || response.statusCode !== 409) {
- return cb(error, data, json, response)
- }
- log.verbose("update existing user", "adduser")
- return request.GET
- ( '/-/user/org.couchdb.user:'+encodeURIComponent(username)
- , function (er, data, json, response) {
- userobj._rev = data._rev
- userobj.roles = data.roles
- log.verbose(userobj, "userobj")
- request.PUT
- ( '/-/user/org.couchdb.user:'+encodeURIComponent(username)
- + "/-rev/" + userobj._rev
- , userobj
- , cb )
- }
- )
- }
- )
-}
-
-function done (cb) { return function (error, data, json, response) {
- if (!error && (!response || response.statusCode === 201)) {
- return cb(error, data, json, response)
- }
- log.verbose([error, data, json], "back from adduser")
- if (!error) {
- error = new Error( (response && response.statusCode || "") + " "+
- "Could not create user\n"+JSON.stringify(data))
- }
- if (response
- && (response.statusCode === 401 || response.statusCode === 403)) {
- log.warn("Incorrect username or password\n"
- +"You can reset your account by visiting:\n"
- +"\n"
- +" http://admin.npmjs.org/reset\n")
- }
-
- return cb(error)
-}}
+++ /dev/null
-
-module.exports = get
-
-var GET = require("./request.js").GET
- , fs = require("graceful-fs")
- , npm = require("../../npm.js")
- , path = require("path")
- , log = require("../log.js")
- , mkdir = require("mkdirp")
- , cacheStat = null
- , chownr = require("chownr")
-
-function get (project, version, timeout, nofollow, staleOk, cb) {
- if (typeof cb !== "function") cb = staleOk, staleOk = false
- if (typeof cb !== "function") cb = nofollow, nofollow = false
- if (typeof cb !== "function") cb = timeout, timeout = -1
- if (typeof cb !== "function") cb = version, version = null
- if (typeof cb !== "function") cb = project, project = null
- if (typeof cb !== "function") {
- throw new Error("No callback provided to registry.get")
- }
-
- timeout = Math.min(timeout, npm.config.get("cache-max"))
- timeout = Math.max(timeout, npm.config.get("cache-min"))
-
- if ( process.env.COMP_CWORD !== undefined
- && process.env.COMP_LINE !== undefined
- && process.env.COMP_POINT !== undefined
- ) timeout = Math.max(timeout, 60000)
-
- var uri = []
- uri.push(project || "")
- if (version) uri.push(version)
- uri = uri.join("/")
-
- // /-/all is special.
- // It uses timestamp-based caching and partial updates,
- // because it is a monster.
- if (uri === "/-/all") {
- return requestAll(cb)
- }
-
- var cache = path.join(npm.cache, uri, ".cache.json")
- fs.stat(cache, function (er, stat) {
- if (!er) fs.readFile(cache, function (er, data) {
- try { data = JSON.parse(data) }
- catch (ex) { data = null }
- get_(uri, timeout, cache, stat, data, nofollow, staleOk, cb)
- })
- else get_(uri, timeout, cache, null, null, nofollow, staleOk, cb)
- })
-}
-
-function requestAll (cb) {
- var cache = path.join(npm.cache, "/-/all", ".cache.json")
-
- mkdir(path.join(npm.cache, "-", "all"), function (er) {
- fs.readFile(cache, function (er, data) {
- if (er) return requestAll_(0, {}, cb)
- try {
- data = JSON.parse(data)
- } catch (ex) {
- fs.writeFile(cache, "{}", function (er) {
- if (er) return cb(new Error("Broken cache. "
- +"Please run 'npm cache clean' "
- +"and try again."))
- return requestAll_(0, {}, cb)
- })
- }
- var t = +data._updated || 0
- requestAll_(t, data, cb)
- })
- })
-}
-
-function requestAll_ (c, data, cb) {
- // use the cache and update in the background if it's not too old
- if (Date.now() - c < 60000) {
- cb(null, data)
- cb = function () {}
- }
-
- var uri = "/-/all/since?stale=update_after&startkey=" + c
-
- if (c === 0) {
- log.warn("Building the local index for the first time, please be patient")
- uri = "/-/all"
- }
-
- var cache = path.join(npm.cache, "-/all", ".cache.json")
- GET(uri, function (er, updates, _, res) {
- if (er) return cb(er, data)
- var headers = res.headers
- , updated = Date.parse(headers.date)
- Object.keys(updates).forEach(function (p) {
- data[p] = updates[p]
- })
- data._updated = updated
- fs.writeFile( cache, JSON.stringify(data)
- , function (er) {
- delete data._updated
- return cb(er, data)
- })
- })
-}
-
-function get_ (uri, timeout, cache, stat, data, nofollow, staleOk, cb) {
- var etag
- if (data && data._etag) etag = data._etag
- if (timeout && timeout > 0 && stat && data) {
- if ((Date.now() - stat.mtime.getTime())/1000 < timeout) {
- log.verbose("not expired, no request", "registry.get " +uri)
- delete data._etag
- return cb(null, data, JSON.stringify(data), {statusCode:304})
- }
- if (staleOk) {
- log.verbose("staleOk, background update", "registry.get " +uri)
- delete data._etag
- process.nextTick(cb.bind( null, null, data, JSON.stringify(data)
- , {statusCode: 304} ))
- cb = function () {}
- }
- }
-
- GET(uri, etag, nofollow, function (er, remoteData, raw, response) {
- // if we get an error talking to the registry, but we have it
- // from the cache, then just pretend we got it.
- if (er && cache && data && !data.error) {
- er = null
- response = {statusCode: 304}
- }
-
- if (response) {
- log.silly([response.statusCode, response.headers], "get cb")
- if (response.statusCode === 304 && etag) {
- remoteData = data
- log.verbose(uri+" from cache", "etag")
- }
- }
-
- data = remoteData
- if (!data) {
- er = er || new Error("failed to fetch from registry: " + uri)
- }
-
- if (er) return cb(er, data, raw, response)
-
- // just give the write the old college try. if it fails, whatever.
- function saved () {
- delete data._etag
- cb(er, data, raw, response)
- }
-
- saveToCache(cache, data, saved)
- })
-}
-
-function saveToCache (cache, data, saved) {
- if (cacheStat) {
- return saveToCache_(cache, data, cacheStat.uid, cacheStat.gid, saved)
- }
- fs.stat(npm.cache, function (er, st) {
- if (er) {
- return fs.stat(process.env.HOME || "", function (er, st) {
- // if this fails, oh well.
- if (er) return saved()
- cacheStat = st
- return saveToCache(cache, data, saved)
- })
- }
- cacheStat = st || { uid: null, gid: null }
- return saveToCache(cache, data, saved)
- })
-}
-
-function saveToCache_ (cache, data, uid, gid, saved) {
- mkdir(path.dirname(cache), function (er, made) {
- if (er) return saved()
- fs.writeFile(cache, JSON.stringify(data), function (er) {
- if (er || uid === null || gid === null) {
- return saved()
- }
- chownr(made || cache, uid, gid, saved)
- })
- })
-}
+++ /dev/null
-
-// utilities for working with the js-registry site.
-
-var cached = {}
-function lazyGet (p) { return function () {
- return cached[p] || (cached[p] = require("./"+p+".js"))
-}}
-
-function setLazyGet (p) {
- Object.defineProperty(exports, p,
- { get : lazyGet(p)
- , enumerable : true })
-}
-
-; ["publish", "unpublish", "tag", "adduser", "get", "request", "star"]
- .forEach(setLazyGet)
+++ /dev/null
-
-module.exports = publish
-
-var request = require("./request.js")
- , GET = request.GET
- , PUT = request.PUT
- , DELETE = request.DELETE
- , reg = request.reg
- , upload = request.upload
- , log = require("../log.js")
- , path = require("path")
- , npm = require("../../npm.js")
- , url = require("url")
-
-function publish (data, prebuilt, readme, cb) {
- if (typeof readme === "function") cb = readme, readme = ""
- if (typeof prebuilt === "function") cb = prebuilt, prebuilt = null
- // add the dist-url to the data, pointing at the tarball.
- // if the {name} isn't there, then create it.
- // if the {version} is already there, then fail.
- // then:
- // PUT the data to {config.registry}/{data.name}/{data.version}
- var registry = reg()
- if (registry instanceof Error) return cb(registry)
-
- readme = readme ? "" + readme : ""
-
- var fullData =
- { _id : data.name
- , name : data.name
- , description : data.description
- , "dist-tags" : {}
- , versions : {}
- , readme: readme
- , maintainers :
- [ { name : npm.config.get("username")
- , email : npm.config.get("email")
- }
- ]
- }
-
- var tbName = data.name + "-" + data.version + ".tgz"
- , bd = npm.config.get("bindist")
- , pbName = data.name + "-" + data.version + "-" + bd + ".tgz"
- , tbURI = data.name + "/-/" + tbName
- , pbURI = data.name + "/-/" + pbName
-
- data._id = data.name+"@"+data.version
- data.dist = data.dist || {}
- data.dist.tarball = url.resolve(registry, tbURI)
- .replace(/^https:\/\//, "http://")
-
- if (prebuilt && bd) {
- data.dist.bin[bd] = data.dist.bin[bd] || {}
- data.dist.bin[bd].tarball = url.resolve(registry, pbURI)
- .replace(/^https:\/\//, "http://")
- }
-
-
-
-
- // first try to just PUT the whole fullData, and this will fail if it's
- // already there, because it'll be lacking a _rev, so couch'll bounce it.
- PUT(encodeURIComponent(data.name), fullData,
- function (er, parsed, json, response) {
- // get the rev and then upload the attachment
- // a 409 is expected here, if this is a new version of an existing package.
- if (er
- && !(response && response.statusCode === 409)
- && !( parsed
- && parsed.reason ===
- "must supply latest _rev to update existing package" )) {
- return log.er(cb, "Failed PUT response "
- +(response && response.statusCode))(er)
- }
- var dataURI = encodeURIComponent(data.name)
- + "/" + encodeURIComponent(data.version)
-
- var tag = data.tag || npm.config.get("tag")
- if (npm.config.get("pre")) dataURI += "/-pre/true"
- else if (tag) dataURI += "/-tag/" + tag
- else dataURI += "/-tag/latest"
-
- // let's see what verions are already published.
- // could be that we just need to update the bin dist values.
- GET(data.name, function (er, fullData) {
- if (er) return cb(er)
-
- var exists = fullData.versions && fullData.versions[data.version]
- if (exists) {
- log(exists._id, "Already published")
- var ebin = exists.dist.bin || {}
- , nbin = data.dist.bin || {}
- , needs = Object.keys(nbin).filter(function (bd) {
- return !ebin.hasOwnProperty(bd)
- })
- log.verbose(needs, "uploading bin dists")
- if (!needs.length) return cb(conflictError(data._id))
- // attach the needed bindists, upload the new metadata
- exists.dist.bin = ebin
- needs.forEach(function (bd) { exists.dist.bin[bd] = nbin[bd] })
- return PUT(dataURI + "/-rev/" + fullData._rev, exists, function (er) {
- if (er) return cb(er)
- attach(data.name, prebuilt, pbName, cb)
- })
- }
-
- // this way, it'll also get attached to packages that were previously
- // published with a version of npm that lacked this feature.
- if (!fullData.readme) {
- data.readme = readme
- }
- PUT(dataURI, data, function (er) {
- if (er) {
- if (er.message.indexOf("conflict Document update conflict.") === 0) {
- return cb(conflictError(data._id))
- }
- return log.er(cb, "Error sending version data")(er)
- }
-
- var c = path.resolve(npm.cache, data.name, data.version)
- , tb = path.resolve(c, "package.tgz")
-
- cb = rollbackFailure(data, cb)
-
- log.verbose([data.name, tb, tbName], "attach 2")
- attach(data.name, tb, tbName, function (er) {
- log.verbose([er, data.name, prebuilt, pbName], "attach 3")
- if (er || !prebuilt) return cb(er)
- attach(data.name, prebuilt, pbName, cb)
- })
- })
- })
- })
-}
-
-function conflictError (pkgid) {
- var e = new Error("publish fail")
- e.errno = npm.EPUBLISHCONFLICT
- e.pkgid = pkgid
- return e
-}
-
-function attach (doc, file, filename, cb) {
- doc = encodeURIComponent(doc)
- GET(doc, function (er, d) {
- if (er) return cb(er)
- if (!d) return cb(new Error(
- "Attempting to upload to invalid doc "+doc))
- var rev = "-rev/"+d._rev
- , attURI = doc + "/-/" + encodeURIComponent(filename) + "/" + rev
- log.verbose([attURI, file], "uploading")
- upload(attURI, file, cb)
- })
-}
-
-function rollbackFailure (data, cb) { return function (er) {
- if (!er) return cb()
- npm.ROLLBACK = true
- log.error(er, "publish failed")
- log("rollback", "publish failed")
- npm.commands.unpublish([data.name+"@"+data.version], function (er_) {
- if (er_) {
- log.error(er_, "rollback failed")
- log.error( "Invalid data in registry! Please report this."
- , "rollback failed" )
- } else log("rolled back", "publish failed")
- cb(er)
- })
-}}
+++ /dev/null
-module.exports = regRequest
-
-regRequest.GET = GET
-regRequest.PUT = PUT
-regRequest.reg = reg
-regRequest.upload = upload
-
-var npm = require("../../npm.js")
- , url = require("url")
- , log = require("../log.js")
- , fs = require("graceful-fs")
- , rm = require("rimraf")
- , asyncMap = require("slide").asyncMap
- , warnedAuth = false
- , newloctimeout = 0
- , stream = require("stream")
- , Stream = stream.Stream
- , request = require("request")
-
-function regRequest (method, where, what, etag, nofollow, cb_) {
- if (typeof cb_ !== "function") cb_ = nofollow, nofollow = false
- if (typeof cb_ !== "function") cb_ = etag, etag = null
- if (typeof cb_ !== "function") cb_ = what, what = null
-
- // Since there are multiple places where an error could occur,
- // don't let the cb be called more than once.
- var errState = null
- function cb (er) {
- if (errState) return
- if (er) errState = er
- cb_.apply(null, arguments)
- }
-
- if (where.match(/^\/?favicon.ico/)) {
- return cb(new Error("favicon.ico isn't a package, it's a picture."))
- }
-
- var registry = reg()
- if (registry instanceof Error) return cb(registry)
-
- var adduserChange = /^\/?-\/user\/org\.couchdb\.user:([^\/]+)\/-rev/
- , adduserNew = /^\/?-\/user\/org\.couchdb\.user:([^\/]+)/
- , authRequired = (what || npm.config.get("always-auth"))
- && !where.match(adduserNew)
- || where.match(adduserChange)
- || method === "DELETE"
-
- // resolve to a full url on the registry
- if (!where.match(/^https?:\/\//)) {
- log.verbose(where, "raw, before any munging")
-
- var q = where.split("?")
- where = q.shift()
- q = q.join("?")
-
- if (where.charAt(0) !== "/") where = "/" + where
- where = "." + where.split("/").map(function (p) {
- p = p.trim()
- if (p.match(/^org.couchdb.user/)) {
- return p.replace(/\//g, encodeURIComponent("/"))
- }
- return encodeURIComponent(p)
- }).join("/")
- if (q) where += "?" + q
- log.verbose([registry, where], "url resolving")
- where = url.resolve(registry, where)
- log.verbose(where, "url resolved")
- }
-
- var remote = url.parse(where)
- , auth = authRequired && npm.config.get("_auth")
-
- if (authRequired && !auth) {
- return cb(new Error(
- "Cannot insert data into the registry without authorization\n"
- + "See: npm-adduser(1)"))
- }
-
- if (auth) remote.auth = new Buffer(auth, "base64").toString("utf8")
-
- makeRequest(method, remote, where, what, etag, nofollow, cb)
-}
-
-function makeRequest (method, remote, where, what, etag, nofollow, cb) {
- var opts = { url: remote
- , method: method
- , ca: npm.config.get("ca")
- , strictSSL: npm.config.get("strict-ssl") }
- , headers = opts.headers = {}
- if (etag) {
- log.verbose(etag, "etag")
- headers[method === "GET" ? "if-none-match" : "if-match"] = etag
- }
-
- headers.accept = "application/json"
-
- headers["user-agent"] = npm.config.get("user-agent")
-
- opts.proxy = npm.config.get( remote.protocol === "https:"
- ? "https-proxy" : "proxy" )
-
- // figure out wth 'what' is
- if (what) {
- if (Buffer.isBuffer(what) || typeof what === "string") {
- opts.body = what
- headers["content-type"] = "application/json"
- headers["content-length"] = Buffer.byteLength(what)
- } else if (what instanceof Stream) {
- headers["content-type"] = "application/octet-stream"
- if (what.size) headers["content-length"] = what.size
- } else {
- delete what._etag
- opts.json = what
- }
- }
-
- if (nofollow) {
- opts.followRedirect = false
- }
-
- log.http(remote.href || "/", method)
-
- var req = request(opts, requestDone(method, where, cb))
- var r = npm.config.get("registry")
- if (!r) {
- return new Error("Must define registry URL before accessing registry.")
- }
-
- req.on("error", cb)
-
- if (what && (what instanceof Stream)) {
- what.pipe(req)
- }
-}
-
-// cb(er, parsed, raw, response)
-function requestDone (method, where, cb) { return function (er, response, data) {
- if (er) return cb(er)
-
- log.http(response.statusCode + " " + url.parse(where).href)
-
- var parsed
-
- if (Buffer.isBuffer(data)) {
- data = data.toString()
- }
-
- if (data && typeof data === "string" && response.statusCode !== 304) {
- try {
- parsed = JSON.parse(data)
- } catch (ex) {
- ex.message += "\n" + data
- log.verbose(data, "bad json")
- log.error("error parsing json", "registry")
- return cb(ex, null, data, response)
- }
- } else if (data) {
- parsed = data
- data = JSON.stringify(parsed)
- }
-
- // expect data with any error codes
- if (!data && response.statusCode >= 400) {
- return cb( response.statusCode + " "
- + require("http").STATUS_CODES[response.statusCode]
- , null, data, response )
- }
-
- var er = null
- if (parsed && response.headers.etag) {
- parsed._etag = response.headers.etag
- }
-
- if (parsed && parsed.error && response.statusCode >= 400) {
- var w = url.parse(where).pathname.substr(1)
- if (!w.match(/^-/) && parsed.error === "not_found") {
- w = w.split("/")
- name = w[w.indexOf("_rewrite") + 1]
- er = new Error("404 Not Found: "+name)
- er.errno = npm.E404
- er.pkgid = name
- } else {
- er = new Error(
- parsed.error + " " + (parsed.reason || "") + ": " + w)
- }
- } else if (method !== "HEAD" && method !== "GET") {
- // invalidate cache
- // This is irrelevant for commands that do etag caching, but
- // ls and view also have a timed cache, so this keeps the user
- // from thinking that it didn't work when it did.
- // Note that failure is an acceptable option here, since the
- // only result will be a stale cache for some helper commands.
- var path = require("path")
- , p = url.parse(where).pathname.split("/")
- , _ = "/"
- , caches = p.map(function (part) {
- return _ = path.join(_, part)
- }).map(function (cache) {
- return path.join(npm.cache, cache, ".cache.json")
- })
-
- // if the method is DELETE, then also remove the thing itself.
- // Note that the search index is probably invalid. Whatever.
- // That's what you get for deleting stuff. Don't do that.
- if (method === "DELETE") {
- p = p.slice(0, p.indexOf("-rev"))
- caches.push(path.join(npm.cache, p.join("/")))
- }
-
- asyncMap(caches, rm, function () {})
- }
- return cb(er, parsed, data, response)
-}}
-
-function GET (where, etag, nofollow, cb) {
- regRequest("GET", where, null, etag, nofollow, cb)
-}
-
-function PUT (where, what, etag, nofollow, cb) {
- regRequest("PUT", where, what, etag, nofollow, cb)
-}
-
-function upload (where, filename, etag, nofollow, cb) {
- if (typeof nofollow === "function") cb = nofollow, nofollow = false
- if (typeof etag === "function") cb = etag, etag = null
-
- fs.stat(filename, function (er, stat) {
- if (er) return cb(er)
- var s = fs.createReadStream(filename)
- s.size = stat.size
- s.on("error", cb)
-
- PUT(where, s, etag, nofollow, cb)
- })
-}
-
-function reg () {
- var r = npm.config.get("registry")
- if (!r) {
- return new Error("Must define registry URL before accessing registry.")
- }
- if (r.substr(-1) !== "/") r += "/"
- npm.config.set("registry", r)
- return r
-}
+++ /dev/null
-
-module.exports = star
-
-var request = require("./request.js")
- , GET = request.GET
- , PUT = request.PUT
- , log = require("../log.js")
- , npm = require("../../npm.js")
-
-function star (package, starred, cb) {
- var users = {}
-
- GET(package, function (er, fullData) {
- if (er) return cb(er)
-
- fullData = { _id: fullData._id
- , _rev: fullData._rev
- , users: fullData.users || {} }
-
- if (starred) {
- log.info("starring", fullData._id)
- fullData.users[npm.config.get("username")] = true
- log.verbose(fullData)
- } else {
- delete fullData.users[npm.config.get("username")]
- log.info("unstarring", fullData._id)
- log.verbose(fullData)
- }
-
- return PUT(package, fullData, cb)
- })
-}
+++ /dev/null
-
-module.exports = tag
-
-var PUT = require("./request.js").PUT
-
-function tag (project, version, tag, cb) {
- PUT(project+"/"+tag, JSON.stringify(version), cb)
-}
+++ /dev/null
-
-// fetch the data
-// modify to remove the version in question
-// If no versions remaining, then DELETE
-// else, PUT the modified data
-// delete the tarball
-
-module.exports = unpublish
-
-var request = require("./request.js")
- , log = require("../log.js")
- , get = require("./get.js")
- , semver = require("semver")
- , url = require("url")
- , chain = require("slide").chain
-
-function unpublish (name, ver, cb) {
- if (!cb) cb = ver, ver = null
- if (!cb) throw new Error(
- "Not enough arguments for registry unpublish")
-
- get(name, null, -1, true, function (er, data) {
- if (er) return log(name+" not published", "unpublish", cb)
- // remove all if no version specified
- if (!ver) {
- log("No version specified, removing all", "unpublish")
- return request("DELETE", name+'/-rev/'+data._rev, cb)
- }
-
- var versions = data.versions || {}
- , versionPublic = versions.hasOwnProperty(ver)
-
- if (!versionPublic) log(name+"@"+ver+" not published", "unpublish")
- else {
- var dist = versions[ver].dist
- log.verbose(dist, "removing attachments")
- }
-
- delete versions[ver]
- // if it was the only version, then delete the whole package.
- if (!Object.keys(versions).length) {
- log("No versions remain, removing entire package", "unpublish")
- return request("DELETE", name+"/-rev/"+data._rev, cb)
- }
-
- if (!versionPublic) return cb()
-
- var latestVer = data["dist-tags"].latest
- for (var tag in data["dist-tags"]) {
- if (data["dist-tags"][tag] === ver) delete data["dist-tags"][tag]
- }
-
- if (latestVer === ver) {
- data["dist-tags"].latest =
- Object.getOwnPropertyNames(versions).sort(semver.compare).pop()
- }
-
- var rev = data._rev
- delete data._revisions
- delete data._attachments
- // log(data._rev, "rev")
- request.PUT(name+"/-rev/"+rev, data,
- log.er(detacher(data, dist, cb), "Failed to update the data"))
- })
-}
-
-function detacher (data, dist, cb) { return function (er) {
- if (er) return cb(er)
- get(data.name, function (er, data) {
- if (er) return cb(er)
-
- var tb = url.parse(dist.tarball)
-
- detach(data, tb.pathname, data._rev, function (er) {
- if (er || !dist.bin) return cb(er)
- chain(Object.keys(dist.bin).map(function (bt) {
- return function (cb) {
- var d = dist.bin[bt]
- detach(data, url.parse(d.tarball).pathname, null, cb)
- }
- }), cb)
- })
- })
-}}
-
-function detach (data, path, rev, cb) {
- if (rev) {
- path += "/-rev/" + rev
- log(path, "detach")
- return request("DELETE", path, cb)
- }
- get(data.name, function (er, data) {
- rev = data._rev
- if (!rev) return cb(new Error(
- "No _rev found in "+data._id))
- detach(data, path, rev, cb)
- })
-}
, asyncMap = require("slide").asyncMap
, semver = require("semver")
, readJson = require("./read-json.js")
- , log = require("./log.js")
+ , log = require("npmlog")
, url = require("url")
module.exports = readInstalled
if (parent && !obj.link) obj.parent = parent
rpSeen[real] = obj
obj.depth = depth
- if (depth >= maxDepth) return cb(null, obj)
+ //if (depth >= maxDepth) return cb(null, obj)
asyncMap(installed, function (pkg, cb) {
var rv = obj.dependencies[pkg]
if (!rv && obj.devDependencies) rv = obj.devDependencies[pkg]
+ if (depth >= maxDepth) {
+ // just try to get the version number
+ var pkgfolder = path.resolve(folder, "node_modules", pkg)
+ , jsonFile = path.resolve(pkgfolder, "package.json")
+ return readJson(jsonFile, function (er, depData) {
+ // already out of our depth, ignore errors
+ if (er || !depData || !depData.version) return cb(null, obj)
+ obj.dependencies[pkg] = depData.version
+ cb(null, obj)
+ })
+ }
+
readInstalled_( path.resolve(folder, "node_modules/"+pkg)
, obj, pkg, obj.dependencies[pkg], depth + 1, maxDepth
, cb )
+
}, function (er, installedData) {
if (er) return cb(er)
installedData.forEach(function (dep) {
&& !url.parse(deps[d]).protocol
&& !semver.satisfies(found.version, deps[d])) {
// the bad thing will happen
- log.warn(obj.path + " requires "+d+"@'"+deps[d]
+ log.warn("unmet dependency", obj.path + " requires "+d+"@'"+deps[d]
+"' but will load\n"
+found.path+",\nwhich is version "+found.version
- ,"unmet dependency")
+ )
found.invalid = true
}
deps[d] = found
}
})
- log.verbose([obj._id], "returning")
+ log.verbose("readInstalled", "returning", obj._id)
return obj
}
var fs = require("graceful-fs")
, semver = require("semver")
, path = require("path")
- , log = require("./log.js")
+ , log = require("npmlog")
, npm = require("../npm.js")
, cache = {}
, timers = {}
function readJson (jsonFile, opts, cb) {
if (typeof cb !== "function") cb = opts, opts = {}
if (cache.hasOwnProperty(jsonFile)) {
- log.verbose(jsonFile, "from cache")
+ log.verbose("json from cache", jsonFile)
return cb(null, cache[jsonFile])
}
+ log.verbose("read json", jsonFile)
+
opts.file = jsonFile
- if (!opts.tag) {
- var parsedPath = jsonFile.indexOf(npm.dir) === 0 && jsonFile.match(
- /\/([^\/]+)\/([^\/]+)\/package\/package\.json$/)
- if (parsedPath && semver.valid(parsedPath[2])) {
- // this is a package.json in some installed package.
- // infer the opts.tag so that linked packages behave right.
- opts.tag = parsedPath[2]
- }
- }
var wscript = null
, contributors = null
if (opts.file && opts.file.indexOf(npm.dir) === 0) {
try {
json = require("vm").runInNewContext("(\n"+jsonString+"\n)")
- log.error(opts.file, "Error parsing json")
- log.error(ex, "parse error ")
+ log.error("Error parsing json", opts.file, ex)
} catch (ex2) {
return jsonParseFail(ex, opts.file, cb)
}
function jsonParseFail (ex, file, cb) {
var e = new Error(
"Failed to parse json\n"+ex.message)
- e.errno = npm.EJSONPARSE
+ e.code = "EJSONPARSE"
e.file = file
if (cb) return cb(e)
throw e
typoWarned[json._id] = true
if (json.modules) {
- log.warn("package.json: 'modules' object is deprecated", json._id)
+ log.verbose("package.json", "'modules' object is deprecated", json._id)
delete json.modules
}
Object.keys(typos).forEach(function (d) {
if (json.hasOwnProperty(d)) {
- log.warn( "package.json: '" + d + "' should probably be '"
- + typos[d] + "'", json._id)
+ log.warn( json._id, "package.json: '" + d + "' should probably be '"
+ + typos[d] + "'" )
}
})
var scriptTypos = { "server": "start" }
if (json.scripts) Object.keys(scriptTypos).forEach(function (d) {
if (json.scripts.hasOwnProperty(d)) {
- log.warn( "package.json: scripts['" + d + "'] should probably be "
- + "scripts['" + scriptTypos[d] + "']", json._id)
+ log.warn( json._id
+ , "package.json: scripts['" + d + "'] should probably be "
+ + "scripts['" + scriptTypos[d] + "']" )
}
})
}
function processObject (opts, cb) { return function (er, json) {
// json._npmJsonOpts = opts
- // log.warn(json, "processing json")
if (npm.config.get("username")) {
json._npmUser = { name: npm.config.get("username")
, email: npm.config.get("email") }
// uncomment once this is no longer an issue.
// if (cb) return cb(e)
// throw e
- log.error(msg, "incorrect json: "+json.name)
+ log.error("json", "incorrect json: "+json.name, msg)
json.repostory = json.repositories[0]
delete json.repositories
}
}
if (repo.match(/github\.com\/[^\/]+\/[^\/]+\/?$/)
&& repo.match(/\.git\.git$/)) {
- log.warn(repo, "Probably broken git url")
+ log.warn(json._id, "Probably broken git url", repo)
}
json.repository.url = repo
}
var files = json.files
if (files && !Array.isArray(files)) {
- log.warn(files, "Invalid 'files' member. See 'npm help json'")
+ log.warn(json._id, "Invalid 'files' member. See 'npm help json'", files)
delete json.files
}
json._id = json.name+"@"+json.version
- var tag = opts.tag
- if (tag) json.version = tag
-
var scripts = json.scripts || {}
// if it has a bindings.gyp, then build with node-gyp
if (opts.gypfile && !json.prebuilt) {
- log.verbose([json.prebuilt, opts], "has bindings.gyp")
+ log.verbose(json._id, "has bindings.gyp", [json.prebuilt, opts])
if (!scripts.install && !scripts.preinstall) {
scripts.install = "node-gyp rebuild"
json.scripts = scripts
// if it has a wscript, then build it.
if (opts.wscript && !json.prebuilt) {
- log.verbose([json.prebuilt, opts], "has wscript")
+ log.verbose(json._id, "has wscript", [json.prebuilt, opts])
if (!scripts.install && !scripts.preinstall) {
// don't fail if it was unexpected, just try.
scripts.preinstall = "node-waf clean || (exit 0); node-waf configure build"
json._npmVersion = npm.version
json._nodeVersion = process.version
if (opts.file) {
- log.verbose(opts.file, "caching")
+ log.verbose("caching json", opts.file)
cache[opts.file] = json
// arbitrary
var keys = Object.keys(cache)
}
if (json.engines.node === "") json.engines.node = "*"
if (json.engines.node && null === semver.validRange(json.engines.node)) {
- log.warn( json.engines.node
- , "Invalid range in engines.node. Please see `npm help json`" )
+ log.warn( json._id
+ , "Invalid range in engines.node. Please see `npm help json`"
+ , json.engines.node )
}
if (nodeVer) {
var fs = require("graceful-fs")
, crypto = require("crypto")
- , log = require("./log.js")
+ , log = require("npmlog")
, binding
try { binding = process.binding("crypto") }
function check (file, sum, cb) {
if (!binding) {
- log.warn("crypto binding not found. Cannot verify shasum.", "shasum")
+ log.warn("shasum", "crypto binding not found. Cannot verify shasum.")
return cb()
}
get(file, function (er, actual) {
- if (er) return log.er(cb, "Error getting shasum")(er)
+ if (er) {
+ log.error("shasum", "error getting shasum")
+ return cb(er)
+ }
var expected = sum.toLowerCase().trim()
, ok = actual === expected
cb(ok ? null : new Error(
function get (file, cb) {
if (!binding) {
- log.warn("crypto binding not found. Cannot verify shasum.", "shasum")
+ log.warn("shasum", "crypto binding not found. Cannot verify shasum.")
return cb()
}
var h = crypto.createHash("sha1")
, errState = null
s.on("error", function (er) {
if (errState) return
- log.silly(er.stack || er.message, "sha error")
+ log.silly("shasum", "error", er)
return cb(errState = er)
}).on("data", function (chunk) {
if (errState) return
- log.silly(chunk.length, "updated sha bytes")
+ log.silly("shasum", "updated bytes", chunk.length)
h.update(chunk)
}).on("end", function () {
if (errState) return
var actual = h.digest("hex").toLowerCase().trim()
- log(actual+"\n"+file, "shasum")
+ log.info("shasum", actual+"\n"+file)
cb(null, actual)
})
}
var npm = require("../npm.js")
, fs = require("graceful-fs")
, path = require("path")
- , log = require("./log.js")
+ , log = require("npmlog")
, uidNumber = require("uid-number")
, rm = require("rimraf")
, readJson = require("./read-json.js")
exports.unpack = unpack
function pack (targetTarball, folder, pkg, dfc, cb) {
- log.verbose([targetTarball, folder], "tar.pack")
+ log.verbose("tar pack", [targetTarball, folder])
if (typeof cb !== "function") cb = dfc, dfc = false
- log.verbose(targetTarball, "tarball")
- log.verbose(folder, "folder")
+ log.verbose("tarball", targetTarball)
+ log.verbose("folder", folder)
if (dfc) {
// do fancy crap
function pack_ (targetTarball, folder, pkg, cb) {
new Packer({ path: folder, type: "Directory", isDirectory: true })
- .on("error", log.er(cb, "error reading "+folder))
+ .on("error", function (er) {
+ if (er) log.error("tar pack", "Error reading " + folder)
+ return cb(er)
+ })
// By default, npm includes some proprietary attributes in the
// package tarball. This is sane, and allowed by the spec.
// so that it can be more easily bootstrapped using old and
// non-compliant tar implementations.
.pipe(tar.Pack({ noProprietary: !npm.config.get("proprietary-attribs") }))
- .on("error", log.er(cb, "tar creation error "+targetTarball))
+ .on("error", function (er) {
+ if (er) log.error("tar.pack", "tar creation error", targetTarball)
+ cb(er)
+ })
.pipe(zlib.Gzip())
- .on("error", log.er(cb, "gzip error "+targetTarball))
+ .on("error", function (er) {
+ if (er) log.error("tar.pack", "gzip error "+targetTarball)
+ cb(er)
+ })
.pipe(fstream.Writer({ type: "File", path: targetTarball }))
- .on("error", log.er(cb, "Could not write "+targetTarball))
- .on("close", function () {
- cb()
+ .on("error", function (er) {
+ if (er) log.error("tar.pack", "Could not write "+targetTarball)
+ cb(er)
})
+ .on("close", cb)
}
function unpack (tarball, unpackTarget, dMode, fMode, uid, gid, cb) {
- log.verbose(tarball, "unpack")
+ log.verbose("tar unpack", tarball)
if (typeof cb !== "function") cb = gid, gid = null
if (typeof cb !== "function") cb = uid, uid = null
if (typeof cb !== "function") cb = fMode, fMode = npm.modes.file
function gunzTarPerm (tarball, target, dMode, fMode, uid, gid, cb_) {
if (!dMode) dMode = npm.modes.exec
if (!fMode) fMode = npm.modes.file
- log.silly([dMode.toString(8), fMode.toString(8)], "gunzTarPerm modes")
+ log.silly("gunzTarPerm", "modes", [dMode.toString(8), fMode.toString(8)])
var cbCalled = false
function cb (er) {
}
function extractEntry (entry) {
- log.silly(entry.path, "extracting entry")
+ log.silly("gunzTarPerm", "extractEntry", entry.path)
// never create things that are user-unreadable,
// or dirs that are user-un-listable. Only leads to headaches.
var originalMode = entry.mode = entry.mode || entry.props.mode
entry.mode = entry.mode & (~npm.modes.umask)
entry.props.mode = entry.mode
if (originalMode !== entry.mode) {
- log.silly([entry.path, originalMode, entry.mode], "modified mode")
+ log.silly( "gunzTarPerm", "modified mode"
+ , [entry.path, originalMode, entry.mode])
}
// if there's a specific owner uid/gid that we want, then set that
extractOpts.filter = function () {
// symbolic links are not allowed in packages.
if (this.type.match(/^.*Link$/)) {
- log.warn( this.path.substr(target.length + 1)
- + ' -> ' + this.linkpath
- , "excluding symbolic link")
+ log.warn( "excluding symbolic link"
+ , this.path.substr(target.length + 1)
+ + ' -> ' + this.linkpath )
return false
}
return true
}
- fst.on("error", log.er(cb, "error reading "+tarball))
+ fst.on("error", function (er) {
+ if (er) log.error("tar.unpack", "error reading "+tarball)
+ cb(er)
+ })
fst.on("data", function OD (c) {
// detect what it is.
// Then, depending on that, we'll figure out whether it's
c[2] === 0x08) {
fst
.pipe(zlib.Unzip())
- .on("error", log.er(cb, "unzip error "+tarball))
+ .on("error", function (er) {
+ if (er) log.error("tar.unpack", "unzip error "+tarball)
+ cb(er)
+ })
.pipe(tar.Extract(extractOpts))
.on("entry", extractEntry)
- .on("error", log.er(cb, "untar error "+tarball))
+ .on("error", function (er) {
+ if (er) log.error("tar.unpack", "untar error "+tarball)
+ cb(er)
+ })
.on("close", cb)
} else if (c.toString().match(/^package\//)) {
// naked tar
fst
.pipe(tar.Extract(extractOpts))
.on("entry", extractEntry)
- .on("error", log.er(cb, "untar error "+tarball))
+ .on("error", function (er) {
+ if (er) log.error("tar.unpack", "untar error "+tarball)
+ cb(er)
+ })
.on("close", cb)
} else {
// naked js file
fst
.pipe(fstream.Writer(jsOpts))
- .on("error", log.er(cb, "copy error "+tarball))
+ .on("error", function (er) {
+ if (er) log.error("tar.unpack", "copy error "+tarball)
+ cb(er)
+ })
.on("close", function () {
var j = path.resolve(target, "package.json")
readJson(j, function (er, d) {
if (er) {
- log.error(tarball, "Not a package")
+ log.error("not a package", tarball)
return cb(er)
}
fs.writeFile(j, JSON.stringify(d) + "\n", cb)
, path = require("path")
, fs = require("graceful-fs")
, chain = require("slide").chain
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, npm = require("./npm.js")
version.usage = "npm version <newversion> [--message commit-message]"
function version (args, cb) {
if (args.length !== 1) return cb(version.usage)
readJson(path.join(process.cwd(), "package.json"), function (er, data) {
- if (er) return log.er(cb, "No package.json found")(er)
+ if (er) {
+ log.error("version", "No package.json found")
+ return cb(er)
+ }
var newVer = semver.valid(args[0])
if (!newVer) newVer = semver.inc(data.version, args[0])
if (!newVer) return cb(version.usage)
}
}
-var registry = require("./utils/npm-registry-client/index.js")
+var npm = require("./npm.js")
+ , registry = npm.registry
, ini = require("ini")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
, util = require("util")
, output
- , npm = require("./npm.js")
, semver = require("semver")
, readJson = require("./utils/read-json.js")
if (name === ".") return cb(view.usage)
// get the data about this package
- registry.get(name, null, 600, function (er, data) {
+ registry.get(name, 600, function (er, data) {
if (er) return cb(er)
if (data["dist-tags"].hasOwnProperty(version)) {
version = data["dist-tags"][version]
if (args.length === 1 && args[0] === "") {
retval = cleanBlanks(retval)
- log.silly(retval, "cleanup")
+ log.silly("cleanup", retval)
}
if (error || silent) cb(error, retval)
var npm = require("./npm.js")
, output = require("./utils/output.js")
- , log = require("./utils/log.js")
whoami.usage = "npm whoami\n(just prints the 'username' config)"
// happy xmas
var npm = require("./npm.js")
- , log = require("./utils/log.js")
+ , log = require("npmlog")
module.exports = function (args, cb) {
-npm.config.set("loglevel", "win")
var s = process.platform === "win32" ? " *" : " \u2605"
, f = "\uFF0F"
, b = "\uFF3C"
}
})(20)
w("\n\n")
-log.win("Happy Xmas, Noders!", "loves you", cb)
+log.heading = ''
+log.addLevel('npm', 100000, log.headingStyle)
+log.npm("loves you", "Happy Xmas, Noders!")
+cb()
}
var dg=false
Object.defineProperty(module.exports, "usage", {get:function () {
Always create a new Error object with your message\. Don\'t just return a
string message to the callback\. Stack traces are handy\.
.
-.P
-Use the \fBrequire("\./utils/log")\.er\fR function\. It takes a callback and an
-error message, and returns an object that will report the message in the
-event of a failure\. It\'s quite handy\.
-.
-.IP "" 4
-.
-.nf
-function myThing (args, cb) {
- getData(args, function (er, data) {
- if (er) return log\.er(cb, "Couldn\'t get data")(er)
- doSomethingElse(data, cb)
- })
-}
-function justHasToWork (cb) {
- doSomething(log\.er(cb, "the doSomething failed\."))
-}
-.
-.fi
-.
-.IP "" 0
-.
.SH "Logging"
+Logging is done using the npmlog \fIhttps://github\.com/isaacs/npmlog\fR
+utility\.
+.
+.P
Please clean up logs when they are no longer helpful\. In particular,
logging the same object over and over again is not helpful\. Logs should
report what\'s happening so that it\'s easier to track down where a fault
occurs\.
.
.P
-Use appropriate log levels\. The default log() function logs at the
-"info" level\. See \fBnpm help config\fR and search for "loglevel"\.
+Use appropriate log levels\. See \fBnpm help config\fR and search for
+"loglevel"\.
.
.SH "Case, naming, etc\."
Use \fBlowerCamelCase\fR for multiword identifiers when they refer to objects,
.
.IP "" 0
.
-.SS "logfd"
-.
-.IP "\(bu" 4
-Default: stderr file descriptor
-.
-.IP "\(bu" 4
-Type: Number or Stream
-.
-.IP "" 0
-.
-.P
-The location to write log output\.
-.
.SS "loglevel"
.
.IP "\(bu" 4
Any logs of a higher level than the setting are shown\.
The default is "http", which shows http, warn, and error output\.
.
-.SS "logprefix"
-.
-.IP "\(bu" 4
-Default: true on Posix, false on Windows
-.
-.IP "\(bu" 4
-Type: Boolean
-.
-.IP "" 0
-.
-.P
-Whether or not to prefix log messages with "npm" and the log level\. See
-also "color" and "loglevel"\.
-.
.SS "long"
.
.IP "\(bu" 4
A node module to \fBrequire()\fR when npm loads\. Useful for programmatic
usage\.
.
-.SS "outfd"
-.
-.IP "\(bu" 4
-Default: standard output file descriptor
-.
-.IP "\(bu" 4
-Type: Number or Stream
-.
-.IP "" 0
-.
-.P
-Where to write "normal" output\. This has no effect on log output\.
-.
.SS "parseable"
.
.IP "\(bu" 4
.fi
.
.SH "VERSION"
-1.1.24
+1.1.25
.
.SH "DESCRIPTION"
npm is the package manager for the Node JavaScript platform\. It puts
.fi
.
.SH "VERSION"
-1.1.24
+1.1.25
.
.SH "DESCRIPTION"
This is the API documentation for npm\.
{
"name": "mkdirp",
"description": "Recursively mkdir, like `mkdir -p`",
- "version": "0.3.2",
+ "version": "0.3.3",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"name": "isaacs",
"email": "i@izs.me"
},
- "_id": "mkdirp@0.3.2",
+ "_id": "mkdirp@0.3.3",
"dependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.23",
+ "_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
- "dist": {
- "shasum": "bebd1a16759571a6bd30f89a7edffc38ad442881"
- },
- "_from": "../mkdirp"
+ "_from": "mkdirp@0.3"
}
"dependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.23",
+ "_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
"_from": "ansi@0.0.x"
"_id": "glob@3.1.9",
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.23",
+ "_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
"_from": "glob@3"
"devDependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.23",
+ "_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
- "dist": {
- "shasum": "9ddb9c4218322fd3d6b9771b27c236c4e5965e3b"
- },
- "_from": "node-gyp@~0.4.4"
+ "_from": "node-gyp@~0.4.5"
}
* `followRedirect` - follow HTTP 3xx responses as redirects. defaults to true.
* `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects. defaults to false.
* `maxRedirects` - the maximum number of redirects to follow, defaults to 10.
-* `onResponse` - If true the callback will be fired on the "response" event instead of "end". If a function it will be called on "response" and not effect the regular semantics of the main callback on "end".
* `encoding` - Encoding to be used on `setEncoding` of response data. If set to `null`, the body is returned as a Buffer.
* `pool` - A hash object containing the agents for these requests. If omitted this request will use the global pool which is set to node's default maxSockets.
* `pool.maxSockets` - Integer containing the maximum amount of sockets in the pool.
self._callback.apply(self, arguments)
self._callbackCalled = true
}
+ self.on('error', self.callback.bind())
+ self.on('complete', self.callback.bind(self, null))
}
if (self.url) {
// do the HTTP CONNECT dance using koichik/node-tunnel
if (http.globalAgent && self.uri.protocol === "https:") {
+ self.tunnel = true
var tunnelFn = self.proxy.protocol === "http:"
? tunnel.httpsOverHttp : tunnel.httpsOverHttps
var tunnelOptions = { proxy: { host: self.proxy.hostname
- , port: +self.proxy.port
+ , port: +self.proxy.port
, proxyAuth: self.proxy.auth }
, ca: this.ca }
self.host = self.uri.hostname
}
- if (self.onResponse === true) {
- self.onResponse = self.callback
- delete self.callback
- }
-
self.clientErrorHandler = function (error) {
if (self._aborted) return
return
}
if (self.timeout && self.timeoutTimer) {
- clearTimeout(self.timeoutTimer);
- self.timeoutTimer = null;
+ clearTimeout(self.timeoutTimer)
+ self.timeoutTimer = null
}
self.emit('error', error)
}
- if (self.onResponse) self.on('error', function (e) {self.onResponse(e)})
- if (self.callback) self.on('error', function (e) {self.callback(e)})
if (options.form) {
self.form(options.form)
})
}
-// Must call this when following a redirect from https to http or vice versa
-// Attempts to keep everything as identical as possible, but update the
-// httpModule, Tunneling agent, and/or Forever Agent in use.
-Request.prototype._updateProtocol = function () {
- var self = this
- var protocol = self.uri.protocol
-
- if (protocol === 'https:') {
- // previously was doing http, now doing https
- // if it's https, then we might need to tunnel now.
- if (self.proxy) {
- self.tunnel = true
- var tunnelFn = self.proxy.protocol === 'http:'
- ? tunnel.httpsOverHttp : tunnel.httpsOverHttps
- var tunnelOptions = { proxy: { host: self.proxy.hostname
- , post: +self.proxy.port
- , proxyAuth: self.proxy.auth }
- , ca: self.ca }
- self.agent = tunnelFn(tunnelOptions)
- return
- }
-
- self.httpModule = https
- switch (self.agentClass) {
- case ForeverAgent:
- self.agentClass = ForeverAgent.SSL
- break
- case http.Agent:
- self.agentClass = https.Agent
- break
- default:
- // nothing we can do. Just hope for the best.
- return
- }
-
- // if there's an agent, we need to get a new one.
- if (self.agent) self.agent = self.getAgent()
-
- } else {
- if (log) log('previously https, now http')
- // previously was doing https, now doing http
- // stop any tunneling.
- if (self.tunnel) self.tunnel = false
- self.httpModule = http
- switch (self.agentClass) {
- case ForeverAgent.SSL:
- self.agentClass = ForeverAgent
- break
- case https.Agent:
- self.agentClass = http.Agent
- break
- default:
- // nothing we can do. just hope for the best
- return
- }
-
- // if there's an agent, then get a new one.
- if (self.agent) {
- self.agent = null
- self.agent = self.getAgent()
- }
- }
-}
-
Request.prototype.getAgent = function () {
var Agent = this.agentClass
var options = {}
poolKey += this.host + ':' + this.port
}
- // ca option is only relevant if proxy or destination are https
- var proxy = this.proxy
- if (typeof proxy === 'string') proxy = url.parse(proxy)
- var caRelevant = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:'
- if (options.ca && caRelevant) {
+ if (options.ca) {
if (poolKey) poolKey += ':'
poolKey += options.ca
}
return this.httpModule.globalAgent
}
- // we're using a stored agent. Make sure it's protocol-specific
- poolKey = this.uri.protocol + poolKey
-
// already generated an agent for this setting
if (this.pool[poolKey]) return this.pool[poolKey]
self.response = response
response.request = self
+ response.toJSON = toJSON
if (self.httpModule === https &&
self.strictSSL &&
if (self.setHost) delete self.headers.host
if (self.timeout && self.timeoutTimer) {
- clearTimeout(self.timeoutTimer);
- self.timeoutTimer = null;
+ clearTimeout(self.timeoutTimer)
+ self.timeoutTimer = null
}
if (response.headers['set-cookie'] && (!self._disableCookies)) {
if (!isUrl.test(response.headers.location)) {
response.headers.location = url.resolve(self.uri.href, response.headers.location)
}
-
- var uriPrev = self.uri
- self.uri = url.parse(response.headers.location)
-
- // handle the case where we change protocol from https to http or vice versa
- if (self.uri.protocol !== uriPrev.protocol) {
- self._updateProtocol()
- }
-
+ self.uri = response.headers.location
self.redirects.push(
{ statusCode : response.statusCode
, redirectUri: response.headers.location
}
)
- self.method = 'GET'; // Force all redirects to use GET
+ if (self.followAllRedirects) self.method = 'GET'
+ // self.method = 'GET'; // Force all redirects to use GET || commented out fixes #215
delete self.req
delete self.agent
delete self._started
self.emit('response', response)
- if (self.onResponse) {
- self.onResponse(null, response)
- }
if (self.callback) {
var buffer = []
var bodyLen = 0
response.body = JSON.parse(response.body)
} catch (e) {}
}
-
- self.callback(null, response, response.body)
+
+ self.emit('complete', response, response.body)
})
}
}
// server freeze after sending headers
if (self.req.setTimeout) { // only works on node 0.6+
self.req.setTimeout(self.timeout, function(){
- if (self.req) {
- self.req.abort()
- var e = new Error("ESOCKETTIMEDOUT")
- e.code = "ESOCKETTIMEDOUT"
- self.emit("error", e)
- }
+ if (self.req) {
+ self.req.abort()
+ var e = new Error("ESOCKETTIMEDOUT")
+ e.code = "ESOCKETTIMEDOUT"
+ self.emit("error", e)
+ }
})
}
}
self.body = []
if (!self.headers['content-type']) {
- self.headers['content-type'] = 'multipart/related;boundary="frontier"';
+ self.headers['content-type'] = 'multipart/related; boundary=frontier';
} else {
- self.headers['content-type'] = self.headers['content-type'].split(';')[0] + ';boundary="frontier"';
+ self.headers['content-type'] = self.headers['content-type'].split(';')[0] + '; boundary=frontier';
}
if (!multipart.forEach) throw new Error('Argument error, options.multipart.')
delete oa['oauth_'+i]
}
}
- this.headers.authorization =
+ this.headers.Authorization =
'OAuth '+Object.keys(oa).sort().map(function (i) {return i+'="'+oauth.rfc3986(oa[i])+'"'}).join(',')
- this.headers.authorization += ',oauth_signature="'+oauth.rfc3986(signature)+'"'
+ this.headers.Authorization += ',oauth_signature="'+oauth.rfc3986(signature)+'"'
return this
}
Request.prototype.jar = function (jar) {
for (var i in options) {
if (params.options[i] === undefined) params.options[i] = options[i]
}
- return method(params.uri, params.options, params.callback)
+ return method(params.options, params.callback)
}
return d
}
if (typeof str !== 'string') throw new Error("The cookie function only accepts STRING as param")
return new Cookie(str)
}
+
+// Safe toJSON
+
+function getSafe (self, uuid) {
+ if (typeof self === 'object' || typeof self === 'function') var safe = {}
+ if (Array.isArray(self)) var safe = []
+
+ var recurse = []
+
+ Object.defineProperty(self, uuid, {})
+
+ var attrs = Object.keys(self).filter(function (i) {
+ if (i === uuid) return false
+ if ( (typeof self[i] !== 'object' && typeof self[i] !== 'function') || self[i] === null) return true
+ return !(Object.getOwnPropertyDescriptor(self[i], uuid))
+ })
+
+
+ for (var i=0;i<attrs.length;i++) {
+ if ( (typeof self[attrs[i]] !== 'object' && typeof self[attrs[i]] !== 'function') ||
+ self[attrs[i]] === null
+ ) {
+ safe[attrs[i]] = self[attrs[i]]
+ } else {
+ recurse.push(attrs[i])
+ Object.defineProperty(self[attrs[i]], uuid, {})
+ }
+ }
+
+ for (var i=0;i<recurse.length;i++) {
+ safe[recurse[i]] = getSafe(self[recurse[i]], uuid)
+ }
+
+ return safe
+}
+
+function toJSON () {
+ return getSafe(this, (((1+Math.random())*0x10000)|0).toString(16))
+}
+
+Request.prototype.toJSON = toJSON
+
function rfc3986 (str) {
return encodeURIComponent(str)
- .replace('!','%21')
- .replace('*','%2A')
- .replace('(','%28')
- .replace(')','%29')
- .replace("'",'%27')
+ .replace(/!/g,'%21')
+ .replace(/\*/g,'%2A')
+ .replace(/\(/g,'%28')
+ .replace(/\)/g,'%29')
+ .replace(/'/g,'%27')
;
}
"util",
"utility"
],
- "version": "2.9.153",
+ "version": "2.9.202",
"author": {
"name": "Mikeal Rogers",
"email": "mikeal.rogers@gmail.com"
"name": "isaacs",
"email": "i@izs.me"
},
- "_id": "request@2.9.153",
+ "_id": "request@2.9.202",
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.8",
- "_nodeVersion": "v0.6.12",
+ "_npmVersion": "1.1.24",
+ "_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
"dist": {
- "shasum": "6f07c2ba3acfbe0cfe941f43647102740f05ff73"
+ "shasum": "f762430e0080df88bd7917330acb00d1c1b3481d"
},
- "_from": "../request"
+ "_from": "request@2.9.202"
}
-{"name":"rimraf"
-,"version":"2.0.1"
-,"main":"rimraf.js"
-,"description":"A deep deletion module for node (like `rm -rf`)"
-,"author":"Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
-,"license":
- {"type":"MIT", "url": "https://github.com/isaacs/rimraf/raw/master/LICENSE"}
-,"optionalDependencies":{"graceful-fs":"~1.1"}
-,"repository":"git://github.com/isaacs/rimraf.git"
-,"scripts":{"test":"cd test && bash run.sh"}}
+{
+ "name": "rimraf",
+ "version": "2.0.2",
+ "main": "rimraf.js",
+ "description": "A deep deletion module for node (like `rm -rf`)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "license": {
+ "type": "MIT",
+ "url": "https://github.com/isaacs/rimraf/raw/master/LICENSE"
+ },
+ "optionalDependencies": {
+ "graceful-fs": "~1.1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/rimraf.git"
+ },
+ "scripts": {
+ "test": "cd test && bash run.sh"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "rimraf@2.0.2",
+ "contributors": [
+ {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me"
+ },
+ {
+ "name": "Wayne Larsen",
+ "email": "wayne@larsen.st",
+ "url": "http://github.com/wvl"
+ },
+ {
+ "name": "ritch",
+ "email": "skawful@gmail.com"
+ },
+ {
+ "name": "Marcel Laverdet"
+ },
+ {
+ "name": "Yosef Dinerstein",
+ "email": "yosefd@microsoft.com"
+ }
+ ],
+ "dependencies": {
+ "graceful-fs": "~1.1"
+ },
+ "devDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "_engineSupported": true,
+ "_npmVersion": "1.1.24",
+ "_nodeVersion": "v0.7.10-pre",
+ "_defaultsLoaded": true,
+ "_from": "rimraf@2"
+}
fs = require("fs")
}
-var lstat = process.platform === "win32" ? "stat" : "lstat"
- , lstatSync = lstat + "Sync"
+var lstat = "lstat"
+if (process.platform === "win32") {
+ // not reliable on windows prior to 0.7.9
+ var v = process.version.replace(/^v/, '').split(/\.|-/).map(Number)
+ if (v[0] === 0 && (v[1] < 7 || v[1] == 7 && v[2] < 9)) {
+ lstat = "stat"
+ }
+}
+if (!fs[lstat]) lstat = "stat"
+var lstatSync = lstat + "Sync"
// for EMFILE handling
var timeout = 0
rimraf_(p, function CB (er) {
if (er) {
if (er.code === "EBUSY" && busyTries < exports.BUSYTRIES_MAX) {
- var time = (exports.BUSYTRIES_MAX - busyTries) * 100
busyTries ++
+ var time = busyTries * 100
// try again, with the same exact callback as this one.
return setTimeout(function () {
rimraf_(p, CB)
- })
+ }, time)
}
// this one won't happen if graceful-fs is used.
{
+ "version": "1.1.25",
"name": "npm",
"publishConfig": {
"proprietary-attribs": false
"install",
"package.json"
],
- "version": "1.1.24",
"preferGlobal": true,
"config": {
"publishtest": false
"fstream": "~0.1.17",
"block-stream": "*",
"inherits": "1",
- "mkdirp": "0.3",
+ "mkdirp": "~0.3.3",
"read": "0",
"lru-cache": "1",
"node-gyp": "~0.4.5",
"fstream-npm": "0.1",
"uid-number": "0",
"archy": "0",
- "chownr": "0"
+ "chownr": "0",
+ "npmlog": "0",
+ "ansi": "~0.1.2",
+ "npm-registry-client": "0"
},
"bundleDependencies": [
"slide",
"fstream-npm",
"uid-number",
"archy",
- "chownr"
+ "chownr",
+ "npmlog",
+ "ansi",
+ "npm-registry-client"
],
"devDependencies": {
"ronn": "https://github.com/isaacs/ronnjs/tarball/master"
},
"scripts": {
"test": "node ./test/run.js",
- "prepublish": "npm prune; rm -rf node_modules/*/{test,example,bench}*; make -j4 doc",
+ "prepublish": "npm prune ; make -j4 doc",
"dumpconf": "env | grep npm | sort | uniq"
},
"licenses": [