Haravan CLI for themes
Haravan CLI is a command-line interface tool that helps you build Haravan themes.
Features
Haravan CLI accelerates your theme development process with the following features:
- Pull and backup themes from the command line
- Work on multiple themes and across multiple stores
Installation
Requirements
- Node.js 16 or higher
To install Haravan CLI for themes, install the @haravan/cli Node.js packages globally using the command line.
npm install -g @haravan/cli@latest
The "permission denied" error typically occurs when you don't have the required permissions to install global packages on your system. This issue is commonly encountered when running npm install -g
without administrative privileges. To fix this issue, use sudo
(superuser do) to run the command with administrative privileges:
sudo npm install -g @haravan/cli@latest
To verify that Haravan CLI is installed properly, run the following command (the command returns a version number):
haravan -v
Review the available commands:
haravan -help
Authenticating and accessing stores
As a theme developer, you might want to use a Haravan store to test your theme, or to share your theme with stakeholders. You also might need to work on multiple stores, or use a different set of credentials to authenticate with a particular store. Learn about the authentication methods that you can use to work on stores using Haravan CLI, and how to switch between accounts and stores.
You can use the following types of Haravan accounts to access the store you want to work on:
- A staff account with the Themes permission
- The store owner account
To authenticate with a Haravan account, run a command that requires store access. You'll be prompted to log in.
haravan login
For multi-store authentication, run the above command again. You'll be prompted to login other stores.
Connecting to a theme
Create a directory to hold your theme, and make that your working directory:
mkdir mytheme
cd mytheme
To check the current account in the working directory, use the following command:
haravan whoiam
Select an account for the working directory:
haravan select [org_id]
Lists your remote themes:
haravan theme list
Download your remote theme files locally:
haravan theme fetch [theme_id]
The command creates the file .haravan-cli_local.json
for your theme, storing the information of the current theme in the working directory.
The "An error has occurred" error typically occurs when your theme have a file error. You need to review and edit that file on Shop Admin -> Website -> Themes -> Edit code. Then try again.
Directory structure
The default Haravan theme directory structure is as follows:
└── project
├── assets
├── config
├── layout
├── locales
├── snippets
└── templates
Export theme
To export the theme to a zip file. use following command in working directory.
haravan theme export [file name]
After successful export theme, then you can upload the zip file to website theme.