Last active
December 18, 2015 09:39
-
-
Save isaacs/5762752 to your computer and use it in GitHub Desktop.
This is how I change people's packages over to a different username in npm. It requires admin powers, of course, unless you're doing it with your own username.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl http://registry.npmjs.org/-/by-user/testuser | |
{"testuser":["npm-test-blerg","npm-test-publish"]} | |
$ curl http://registry.npmjs.org/-/by-user/testuser2 | |
{} | |
$ npmswitch testuser testuser2 | |
+ npm cache clean npm-test-blerg | |
+ npm owner add testuser2 npm-test-blerg | |
npm http GET https://registry.npmjs.org/-/user/org.couchdb.user:testuser2 | |
npm http 304 https://registry.npmjs.org/-/user/org.couchdb.user:testuser2 | |
npm http GET https://registry.npmjs.org/npm-test-blerg | |
npm http 200 https://registry.npmjs.org/npm-test-blerg | |
npm http PUT https://registry.npmjs.org/npm-test-blerg/-rev/7-3f9d49f42448eb319fa2581cb5abaed6 | |
npm http 201 https://registry.npmjs.org/npm-test-blerg/-rev/7-3f9d49f42448eb319fa2581cb5abaed6 | |
+ npm owner rm testuser npm-test-blerg | |
npm http GET https://registry.npmjs.org/npm-test-blerg | |
npm http 200 https://registry.npmjs.org/npm-test-blerg | |
npm http PUT https://registry.npmjs.org/npm-test-blerg/-rev/8-a67e81b92157daecccd7a9f66b3a9275 | |
npm http 201 https://registry.npmjs.org/npm-test-blerg/-rev/8-a67e81b92157daecccd7a9f66b3a9275 | |
+ npm cache clean npm-test-publish | |
+ npm owner add testuser2 npm-test-publish | |
npm http GET https://registry.npmjs.org/npm-test-publish | |
npm http 200 https://registry.npmjs.org/npm-test-publish | |
npm http PUT https://registry.npmjs.org/npm-test-publish/-rev/11-5e0d022e73b8793beedf416ea6ed8a59 | |
npm http 201 https://registry.npmjs.org/npm-test-publish/-rev/11-5e0d022e73b8793beedf416ea6ed8a59 | |
+ npm owner rm testuser npm-test-publish | |
npm http GET https://registry.npmjs.org/npm-test-publish | |
npm http 200 https://registry.npmjs.org/npm-test-publish | |
npm http PUT https://registry.npmjs.org/npm-test-publish/-rev/12-90756085000ffd5dfe9fbe399adb1efd | |
npm http 201 https://registry.npmjs.org/npm-test-publish/-rev/12-90756085000ffd5dfe9fbe399adb1efd | |
$ curl http://registry.npmjs.org/-/by-user/testuser | |
{} | |
$ curl http://registry.npmjs.org/-/by-user/testuser2 | |
{"testuser2":["npm-test-blerg","npm-test-publish"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npmswitch () { | |
local n1=$1; | |
local n2=$2; | |
curl -s http://registry.npmjs.org/-/by-user/$n1 \ | |
| json $n1 \ | |
| json -a \ | |
| xargs -I P sh -x -c '\ | |
npm cache clean P && \ | |
npm owner add '$n2' P && \ | |
npm owner rm '$n1' P \ | |
' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@isaacs the route you use in this gist
http://registry.npmjs.org/-/by-user/:user
seems to be throwing 503 errors these days. has this route been deprecated/removed? tested withcurl http://registry.npmjs.org/-/by-user/isaacs