Introducing Siteglide CLI

 Last Edited: Sep 18, 2019

Siteglide CLI is a tool that enables you to work on your project from your local editor and has similar behaviours to that of using FTP, in that you can sync up and pull down changes from your website. You will be required to use some terminal commands to use this feature.

Dependencies

The CLI is distributed via Node Package Manager (NPM) and so you will need NodeJS installed on your machine. The easiest way to get this is to visit https://nodejs.org/ and download the LTS version as this has better support.

Siteglide CLI requires a minimum of NodeJS version 10

Installing & Updating

You can use the following to install Siteglide CLI. You can use the same command to install the latest version.

npm i -g @siteglide/siteglide-cli

If you are on a Mac you may need to run this using sudo.

Commands

These commands should be run from within the project folder.

Add

The first time you use the CLI with a project on your device, you will need to create an environment. This is essentially a config file that authorises your connection.

siteglide-cli add env --email me@mydomain.com --url https://my_great_site.com

You must use the email of your Siteglide partner account to replace me@mydomain.com and the development domain of the website you are connecting with to replace https://my_great_site.com.

Replace env with a chosen name for the environment, for example production. On larger projects you may have more than one environment to allow you to interact with both staging and production websites.

Sync

siteglide-cli sync env

This command will setup a watcher that will automatically sync up files when you hit save in your IDE. As above, replace env with a chosen name for the environment, for example production.

Logs

siteglide-cli logs env

This command will output the last 20 logs and then a live list of logs from your site. Logs are written by using the log liquid code, for example: {% log 'Hello World!' -%} . As above, replace env with a chosen name for the environment, for example production.

Graphql

siteglide-cli graphql env

This command will open up the GraphiQL editor locally. This will let you run Graph queries and mutations to test them out before creating them within your site. Also good for quickly getting data out of the database to check. As above, replace env with a chosen name for the environment, for example production.

Pull

siteglide-cli pull env

This will pull down all files from the site in to a folder named `marketplace_builder` within your current directory. During this process it will also overwrite any local versions of files if they already exist. If you have made any changes locally that you have not synced they WILL be overwritten. As above, replace env with a chosen name for the environment, for example production.

Note: The Assets folder is not downloaded as part of CLI Pull

Init

siteglide-cli init

This will create a blank folder structure within the folder you run the command, which includes all folders that are automatically created for you when making a new website on Siteglide. If these folders already exist, you will receive an error and so it will not overwrite existing files.

GitHub Versioning

When you initially create a site within Siteglide, a GitHub Repo is created along side it. All changes made within the Admin are automatically pushed via our API to the Repo. In addition, all changes you sync up using our CLI are also pushed to the Repo. This means you can rest assured we can reverse most files if you make a mistake.