Created
October 26, 2016 20:41
-
-
Save nexdrew/b991132ca3e84708163b2095b5c81380 to your computer and use it in GitHub Desktop.
Node executable script that prints a list of all known users for an npm Enterprise instance (should be run on the npme host)
This file contains 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
#!/usr/bin/env node | |
// assumes that the Docker bridge is using ip 172.17.0.1 | |
var client = require('redis').createClient('redis://172.17.0.1:6379') | |
var users = {} | |
client.keys('user-*', function (err, keys) { | |
var numKeys = keys.length | |
var numChecked = 0 | |
keys.forEach(function (key) { | |
client.get(key, function (err, value) { | |
numChecked++ | |
if (value && value !== 'locked') { | |
var obj = JSON.parse(value) | |
users[obj.email] = true | |
if (obj.email) users[obj.email] = true | |
} | |
if (numChecked === numKeys) { | |
var u = Object.keys(users) | |
console.log('User Count:', u.length) | |
console.log(u.sort()) | |
client.quit() | |
} | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment