Tag Archives: tips

npm CLI Quick-Start for Organizations

We have a number of private npm packages, and I needed to create a new user, grant that user read-only access to our private packages. The npm docs are great. Really great. Go there for details. But here are the key commands for this (probably common) series of steps.

Create a new team

$ npm team create <scope:team>

Grant team read-only access to all existing private packages

Get a list of all private packages for your organization (scope)

$ npm access ls-packages <scope></scope>
# Returns json :'(
# Let's use https://github.com/trentm/json to help
# Install: npm install -g json
$ npm access ls-packages <scope> | json -Ma key</scope>
# Returns list of package names. Noice.

Tying it all together

$ for PKG in $(npm access ls-packages <scope> | json -Ma key); do \
npm access grant read-only <scope:team> "${PKG}"; \
done

Create a new user

Backup your existing ~/.npmrc

$ npm adduser

Save your credentials (auth token will be in ~/.npmrc)

Restore your previous ~/.npmrc

Invite user to organization

Not implemented from the CLI. Use the website: https://www.npmjs.com/org/<scope>/members

npm-add-team-member

Add user to a team

$ npm team add <scope:team> <user>

Remove user from a team

$ npm team rm <scope:team> <user>

So you want to move your Homebrew folder

By default, Homebrew gets installed under /usr/local. This is great, because it doesn't require you to use sudo to install and upgrade packages. But the downside is that it turns your /usr/local directory into a git repository. If you don't have any conflict with this, then by all means, stick with the default.

I had a conflict. Specifically, I use nave for node version management. Unfortunately, both Homebrew and nave drop a README.md in /usr/local, which means nave frequently modifies a file that's under Homebrew's version control and brew update breaks.

Solution

I decided to "move" my Homebrew directory to ~/Homebrew. Here are the steps I followed:


I didn't document this as I did it. Hopefully, I didn't forget anything.

updated

Using watch with a bash alias

I love the Unix watch command. On OSX, you can install it easily with Homebrew:

brew install watch

Something I didn't realize until 10 minutes ago is that if you want to watch the output of something in your bash aliases, watch will complain because it cannot find the command. This is because watch evaluates the command you pass to it with 'sh -c', which does not expand aliases. However, if you also create an alias for watch itself, aliases will work. So, you can add the following to your .bashrc:

alias watch='watch '

Note the trailing space inside the quotation marks.

Link:

Remap Mac Terminal Command-K

In case I need to remember that I did this...

By default, the Mac Terminal assigns the "Clear Scrollback" command to Command-K. This is annoying, because I often use Nano, which uses Control-K to cut a line of text, and I frequently press Command-K instead of Control-K by accident. This clears my screen while I'm in the middle of editing a file. Very annoying.

The solution is to assign a new (harder to hit by accident) command to the "Clear Scrollback" command, so that when I inevitably mistype Command-K, nothing happens.

Remap Command-K

XMPP and Google Apps for Domains

Jesus, my head hurts.

I setup xmpppy on my box, thinking I could quickly set up a bot to run as one of my Google Apps for Domains users. I've spent about six or seven hours (off and on) getting this to work, though, because the documentation from Google about setting up my DNS configuration is incomplete. Thanks a lot!!! Like DNS isn't difficult enough for amateurs.

After many searches, I finally found the magic incantation, so here it is for posterity, in case that link disappears:

_xmpp-server._tcp.YOURDOMAIN.TLD. 3600 IN SRV 5 0 5269 xmpp-server.l.google.com.
_xmpp-server._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server1.l.google.com.
_xmpp-server._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server2.l.google.com.
_xmpp-server._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server3.l.google.com.
_xmpp-server._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server4.l.google.com.
_jabber._tcp.YOURDOMAIN.TLD. 3600 IN SRV 5 0 5269 xmpp-server.l.google.com.
_jabber._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server1.l.google.com.
_jabber._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server2.l.google.com.
_jabber._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server3.l.google.com.
_jabber._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5269 xmpp-server4.l.google.com.
_xmpp-client._tcp.YOURDOMAIN.TLD. 3600 IN SRV 5 0 5222 talk.l.google.com.
_xmpp-client._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5222 talk1.l.google.com.
_xmpp-client._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5222 talk2.l.google.com.
_xmpp-client._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5222 talk3.l.google.com.
_xmpp-client._tcp.YOURDOMAIN.TLD. 3600 IN SRV 20 0 5222 talk4.l.google.com.

N.B. Those trailing periods at the end of the domain names may or may not be necessary, depending on how you update your DNS records. For example, GoDaddy inserted them for me. YMMV.