Introducing the Unofficial Shopify CLI for App Store Reviews

Eyal Toledano
Apr 1 · 4 min read

TLDR: Get the gem from rubygems.org

I regularly pursue education and self-improvement in my off-time. This time, I decided to dedicate my weekend to create a CLI that provides access to scraped data that lives on a website using the Nokogiri gem.

Since I’m in the process of creating a new Shopify app, and I know that app reviews are crucial to the growth of Shopify apps, I decided that my project would expose Shopify’s apps and give access to those apps most recent reviews.

The CLI essentials for the project were to:

  • Have a CLI for interfacing with the application;
  • Pull data from an external source;
  • Implement both list and detail views. The data provided must go at least one level deep; and
  • The application is pretty DRY.

The technical goals of this project were to highlight the learnings made over the last 7 seven weeks so far:

  • Basic control flow — how “if” statements work
  • Variable scopes — method, instance and class
  • Object instantiation — #new (and possibly #initialize)
  • The meaning of the “self” keyword
  • Method types — class vs. instance methods
  • Method return types — knowing what methods return
  • Iterating through collections — at least using #each with a block

App Flow

The basic flow of the app is to welcome the user and take an input right away. The CLI user can search for a Shopify app either by name or by URL, which rely on theShopify.find_by_name and ShopifyApp.find_by_url class methods.

When an input is received, the CLI will immediately attempt to return an App Detail view listing the app’s most relevant information. From this App Detail view, a sub-menu is provided to give access to the app’s 10 most recent reviews, as well as some basic sentiment analysis on the app’s overall rating as well as the 10 latest reviews.

Scraping

The data from the app comes from two separate sources; a nifty list of all Shopify App Stores to grab all of the store’s apps and of course the Shopify App Store itself to traverse and grab the 10 most recent reviews from each app on the Shopify App Store.

The order of execution is to:

(1) instantiate a new ShopifyApp object and to provide it with as much information as is available from the page listing all apps — including the ShopifyApp :name,:url, :developer_name and :developer_url.

(2) leverage each app’s :developer_url to traverse the Shopify App Store and collect the ten most recent reviews and return those as hashes

(3) instantiate a new AppReview object for each hash provided in #2 and assign it to the app itself. This completes the OO relationship

(4) from there, the CLI enables access to both of these objects and their relationships to each other through terminal commands.

The idea is to provide this functionality within an object-oriented context, such that the ShopifyApps and the AppReviews are objects which can be interacted with and extended upon.

Interface

Launch the CLI by navigating to the root of the project and running

$ bin/shopify_app_reviews

You must pass a Shopify app name or URL upon initialization
If an app exists for your query, its details (v.0.1.0) will be returned for your review.
Using ‘list reviews’ will print out the 10 latest reviews for your selected app.

Version 0.2.0 introduces basis sentiment analysis for apps and reviews. When an app has been found, it will automatically display its overall sentiment. This information can also be reaccessed using $ overall sentiment

Version 0.2.0 introduces overall sentiment, shown in the app detail table.

Once you access an app’s reviews using $ latest reviews you can then call $ trending sentiment to return the way people feel about an app lately, rather than overall. This data is calculated from the 10 latest reviews collected. This information will also be appended to the app details table.

Trending sentiment is automatically added to app details, but can be accessed using “trending sentiment.

Future iterations

An obvious iteration for the next version will be to make use of the mechanize ruby gem to interact with objects on pages (i.e. click on buttons).

This will enable me to use the same logic but to iterate it across each page which contains reviews. Once apps have all of their reviews attached rather than just a sample of the latest 10, additional functionality will be possible such as macro-level methods to return data across all Shopify Apps, and more complex sentiment analysis, such as word clouds and so on.

Contribute

Bug reports and pull requests are welcome on the project’s GitHub repository. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Thanks! 🙏

Digital Founder

Read digital entrepreneurship stories from today’s most talented growth marketers.

Eyal Toledano

Written by

Full Stack Growth Engineering. Win by helping others win. Writing about Growth, Crypto, The Force.

Digital Founder

Read digital entrepreneurship stories from today’s most talented growth marketers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade