Skip to content

Instantly share code, notes, and snippets.

@nexdrew
Created October 26, 2016 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nexdrew/b991132ca3e84708163b2095b5c81380 to your computer and use it in GitHub Desktop.
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)
#!/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