Sunday, November 27, 2016

Install any App Store software from command line using mas-cli

   Recently I had a need to create easy onboarding setup.
   Whenever a new member joins the team I want him to be up and running with a local dev environment in a shortest amount of time. I want the process to be error prone, repeatable and involve as less manual interaction as possible. Wouldn't it be nice to just say: "Hey, run this script. And you good!"
   As a part of this effort there is a need to be able to programmatically install apps that are only distributed via App Store and are not available via Homebrew.
   Meet mas-cli utility.
   It allows you to search, install and update App Store distributed software.
   Installing mas-cli on you machine is as easy as running brew install mas in the Terminal window.
The way mas-cli works is that you first need to know the ID of the app you're interested in. You can find it by running mas search <name_here>. This will return a list of available app that have anything to do with the name you provided. Find the one you most interested in and make a note of the ID displayed next to the program name. Now you can run mas install <id_here>. And that's it. The program will be installed without you ever having the need to interact with App Store directly.
   That's cool. But what we really interested here is to come up with a way to put software installation routine in the onboarding script.
   Here is an example of how to do that if you lets say want to install Xcode:
         mas install $(mas search xcode | grep 'Xcode' |head -1 | awk '{print $1}')
Here we first search the registry for xcode. Select the result that equals to 'Xcode'. Take only first column - that would be the ID. And we pass it to mas install command.

  So what left here is to add a line like this into your onboarding script. Just make sure you have mas utility installed on the machine prior to invoking such routine.

  Mas-cli GitHub page https://github.com/mas-cli/mas

Sunday, October 30, 2016

Why Homebrew is awesome

   Homebrew is a package manager for Mac OS. Similar to yum on Centos and apt-get on Ubuntu you can search repositories for specific software and install it on your machine using brew install package_name.
   Now, this post is about a cool feature of Homebrew I didn't know before. You can install full fledged apps that typically are distributed in a form of .dmg files right from Terminal using Homebrew.
   For example you can install heavyweight apps like IntelliJ and RubyMine by JetBrains, Atom, Chrome browser etc ... without ever leaving the Terminal, opening the browser to look for installers.
   The only thing you need to do is to specify cask option in brew command.
For example, if we want to install IntelliJ just run  brew cask install Caskroom/cask/intellij-idea
   Isn't that cool! No more looking and googling around for app's distributions and how to install it.
   Installing java is a good example. Instead of going to Oracle website, figuring out which link to press, which type of package you need for your specific need. With Homebrew you just type brew search java and once you settled on what package you like you go brew cask install Caskroom/cask/java... without ever leaving the Terminal window.
   Now, how do you know when you need to use cask option?
   Let's talk about brew search name. This command is used to search for available packages which have name in them. If the package you like to install is having cask in it - you need to use cask option.

  So let's go over an example - I want to install Chrome. Here's how it would look like:
  1. search for available packages by running brew search chrome

    seems like we want to use package Caskroom/cask/google-chrome
  2. install the package by running brew cask install Caskroom/cask/google-chrome
That's it! Chrome should be installed and available in your Applications folder.

Friday, February 12, 2016

Work on personal project www.stocksinsight.net

I'm a founder and sole owner of www.stocksinsight.net. Resource is dedicated to help traders of various skill level to find practical trading info. 
Ruby on Rails - HTML - CSS - JavaScript - PostreSQL - Heroku - Git