Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/bmeck/npm into bmeck-search
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 11, 2010
2 parents 73d63d1 + ee75881 commit 0a7c483
Show file tree
Hide file tree
Showing 79 changed files with 2,406 additions and 1,060 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
output.log
test/root
test/bin
25 changes: 17 additions & 8 deletions Makefile
@@ -1,8 +1,11 @@

docs = $(shell ls doc/*.md \
|sed 's|.md|.1|g' \
|sed 's|doc/|man/|g' \
)
docs = $(shell find doc -name '*.md' \
|sed 's|.md|.1|g' \
|sed 's|doc/|man/|g' \
)
doc_subfolders = $(shell find doc -type d \
|sed 's|doc/|man/|g' \
)

install-stable:
./cli.js --auto-activate always install npm@stable
Expand All @@ -17,13 +20,19 @@ uninstall:
./cli.js cache clean
./cli.js rm npm

man:
@mkdir man
man: $(doc_subfolders)
@if ! test -d man ; then mkdir -p man ; fi

doc: man $(docs)
@true

man/%.1: doc/%.md
ronn --roff $< > $@
ronn --roff --pipe $< > $@

.PHONY: install install-stable link doc clean uninstall
man/%/: doc/%/
@if ! test -d $@ ; then mkdir -p $@ ; fi

test:
./test/run.sh

.PHONY: install install-stable link doc clean uninstall test
26 changes: 7 additions & 19 deletions README.md
Expand Up @@ -6,19 +6,15 @@ More info available via `man npm`.

## Simple Install

To install npm, create a folder where you want to put the code, and then
cd there, and do this:
To install npm, do this:

curl -L http://github.com/isaacs/npm/tarball/master | tar xz --strip 1
cd npm
make
curl http://npmjs.org/install.sh | sh

If it dies with a "Permission Denied" or EACCESS error, then that probably
means that you are running node in a shared root-owned location. In that
case, you'll have to use sudo, and it'll behave like a multi-user app.
case, you'll have to use sudo.

You can customize this behavior by using the `root` and `binroot` config
options. See npm-config(1)
curl http://npmjs.org/install.sh | sudo sh

## More Fancy Installing

Expand Down Expand Up @@ -55,17 +51,9 @@ Or, if that fails,

Check out the [docs](http://github.com/isaacs/npm/blob/master/doc/).

You can use the [npm help](http://github.com/isaacs/npm/blob/master/doc/help.md#readme)
command to read any of them.

If you're a developer, and you want to use npm to publish your program,
you should
[read this](http://github.com/isaacs/npm/blob/master/doc/developers.md#readme)

## A note about password security

In order to publish your packages, you must have your auth info
saved into your .npmrc file. If Cipher and Decipher are supported
in the "crypto" module, then npm will use them. However, as of
node 0.1.95, these functions aren't integrated yet.

You can get around this by doing:

npm install crypto@0.0.5
44 changes: 31 additions & 13 deletions cli.js
Expand Up @@ -2,13 +2,16 @@

// don't assume that npm is installed in any particular spot, since this
// might conceivably be a bootstrap attempt.
var log = require("./lib/utils/log")

log("ok", "it worked if it ends with")

var fs = require("fs")
, path = require("path")
, sys = require("sys")
, npm = require("./npm")

// supported commands.
, log = require("./lib/utils/log")
, argv = process.argv.slice(2)
, arg = ""

Expand All @@ -19,7 +22,6 @@ var fs = require("fs")
, flagsDone

log(sys.inspect(argv), "cli")
log(npm.version, "version")

while (arg = argv.shift()) {
if (!command && (arg in npm.commands)) {
Expand All @@ -41,9 +43,19 @@ if (key) conf[key] = true
npm.argv = arglist
for (var k in conf) npm.config.set(k, conf[k])

process.addListener("uncaughtException", errorHandler)
var vindex = arglist.indexOf("-v")
, printVersion = vindex !== -1 || conf.version
if (printVersion) {
sys.puts(npm.version)
if (vindex !== -1) arglist.splice(vindex, 1)
} else log(npm.version, "version")

process.on("uncaughtException", errorHandler)
process.on("exit", function () { if (!itWorked) log("not ok") })

var itWorked = false

if (!command) {
if (!command) { if (!printVersion) {
// npm.commands.help([arglist.join(" ")])
if (arglist.length) log(arglist, "unknown command")
sys.error( "What do you want me to do?\n\n"
Expand All @@ -52,16 +64,22 @@ if (!command) {
+ "Check 'man npm' or 'man npm-help' for more information\n\n"
+ "This is supposed to happen. "
)
} else npm.commands[command](arglist, errorHandler)
process.exit(1)
}} else npm.commands[command](arglist, errorHandler)

function errorHandler (er) {
if (er) {
sys.error("")
log(er, "!")
sys.error("")
log("try running: 'npm help "+command+"'", "failure")
log("Report this *entire* log at <http://github.com/isaacs/npm/issues>", "failure")
log("or email it to <npm-@googlegroups.com>", "failure")
} else log("ok")
if (!er) {
itWorked = true
log("ok")
if (npm.SHOULD_EXIT) process.exit()
return
}
sys.error("")
log(er, "!")
sys.error("")
log("try running: 'npm help "+command+"'", "failure")
log("Report this *entire* log at <http://github.com/isaacs/npm/issues>", "failure")
log("or email it to <npm-@googlegroups.com>", "failure")
process.exit(1)
}

28 changes: 11 additions & 17 deletions doc/adduser.md
Expand Up @@ -3,26 +3,20 @@ npm-adduser(1) -- Add a registry user account

## SYNOPSIS

npm adduser <username> <password> <email>
npm adduser

## DESCRIPTION

Create a user named `<username>` in the npm registry, and save the
credentials to the `.npmrc` file. Note that this leaves the password
in your `.bash_history`, and it is currently stored in the clear in
the config file. So, don't use a password you care too much about.
Create or verify a user named `<username>` in the npm registry, and
save the credentials to the `.npmrc` file.

For now, if you somehow break your `.npmrc` file, and have forgotten your
password, you're boned. Send an email to i@izs.me and I'll delete the
record from the registry so that you can re-add it.
The username, password, and email are read in from prompts. This command
cannot be scripted. If you think you need to script the creation of new
users, or the authorization of existing ones, without human intervention,
please rethink your use case. That's a very bad idea.

If you break your `.npmrc` file, but you remember your password, you
can put your user auth back by using the `base64` program like so:
You may use this command to change your email address, but not username
or password.

npm config set auth $( echo user:pass | base64 )

Install base64 using whichever method you normally use to put programs on
your computer. (apt-get, homebrew, macports, yum, or just download the
code and build it yourself.)

Or bug me to to remove your account, and then recreate it.
You may use this command multiple times with the same user account to
authorize on a new machine.
27 changes: 27 additions & 0 deletions doc/future-ideas/deploy.md
@@ -0,0 +1,27 @@
npm-deploy(1) -- Deploy a package to a remote host
==================================================

## FUTURE

This functionality does not yet exist.

## SUMMARY

npm deploy <pkg> [--host <hostname>]

## DESCRIPTION

This is a porcelain command. It is equivalent to doing:

npm publish --registry $(npm config get host) <pkg>
npm remote install <pkg-name>@<pkg-version>

That is, it first publishes the package to the server specified
by the `host` config, and then remotely installs that package
on the host.

## SEE ALSO

* npm-remote(1)
* npm-site(1)
* npm-publish(1)
23 changes: 23 additions & 0 deletions doc/future-ideas/remote.md
@@ -0,0 +1,23 @@
npm-remote(1) -- Execute commands on a remote machine
=====================================================

## FUTURE

This functionality does not yet exist.

## SYNOPSIS

npm remote <commands>

## DESCRIPTION

Run a command on a remote npm site instance.

In order to do this, the current authenticated user must be in
the "admin" list on the server, and it must be running with https
support.

It uses the `host` config to know where to do things.



58 changes: 58 additions & 0 deletions doc/future-ideas/site.md
@@ -0,0 +1,58 @@
npm-site(1) -- Run the npm web site
===================================

## FUTURE

This functionality does not yet exist.

## SYNOPSIS

npm site [ start | stop ]

## DESCRIPTION

This starts up npm in "site" mode. The following configs are relevant,
and can either be specified in the `.npmrc` file, or as command line
options.

* userfile:
A file containing the encrypted authorization info for all users. If
specified, then this is used for `npm adduser` requests
to this registry.
* admin:
A comma-delimited list of admin users. All of these must already be
in the local adduser config. If there is no admin, then the site will
not allow remote management. All admin usernames must already be
in the userfile, and a userfile must be specified.
* listen:
Ports to listen on for WS requests. The first number is for http,
the second for https, and the third for secure TCP. Set any to "-",
or omit, to use the default.
Defaults to "80,443,15443"
* registry:
If a package is not found, then its contents will be fetched from the
upstream registry, and cached for future retrieval.

isaacs: Make sure that this does loop-detection, so that a "ring" of
registries can work as a distributed network. Also, once we have
support for checking multiple registries, you could have a distribution
ring that secondarily depends on some other upstream resource.

The content for the site is stored in the npm cache directory, which is
inside the folder used for the `root` setting, at `{root}/.npm/.cache`.
It is organized in a simple hierarchical folder structure corresponding
to the web service URLs that npm uses.

## TCP Server

The TCP server starts up to support the `npm remote` command, if there is
a valid admin userlist.

## NOTE

This also is what happens when you do `npm start npm`.

## SEE ALSO

* npm-remote(1)
* npm-config(1)
40 changes: 31 additions & 9 deletions doc/help.md
Expand Up @@ -5,16 +5,38 @@ npm-help(1) -- Get help about npm commands

npm help <section>

Where `<section>` is one of:
`activate`, `adduser`, `build`, `config`, `deactivate`, `folders`, `help`
(this page), `install`, `json`, `link` (or `ln`), `list` (or `ls`), `npm`,
`publish`, `registry`, `scripts`, `tag`, `uninstall` (or `rm`),
`developers`, `coding-style`
Where `<section>` is one of:
activate
adduser
build
cache
coding-style
config
deactivate
developers
folders
help
install
json
link
list
ln
ls
npm
publish
registry
restart
rm
scripts
start
stop
tag
test
uninstall
unpublish

Note that you can get the exact same help content by doing:

man npm-<section>

## Todo

It'd be nice if this page was automatically generated.
It'd be nice if this page was automatically generated so that it stays
up to date better.

0 comments on commit 0a7c483

Please sign in to comment.