shopify-cli-extender-mellenger
v1.4.1
Published
Run Shopify CLI commands through npm/yarn with environment variables support
Maintainers
Readme
shopify-cli-extender-mellenger
A lightweight npm/yarn plugin that allows you to run Shopify CLI commands directly through your package scripts. This plugin makes it easy to create shortcuts for common Shopify development tasks and supports environment variables through .env files.
Installation
# Using yarn
yarn add shopify-cli-extender-mellenger
# Using npm
npm install shopify-cli-extender-mellengerProject Setup
- Create a .env file
Create a .env file in your project root with your environment variables:
# Required
SHOPIFY_STORE=your-store
SHOPIFY_STAGING_THEME_ID=123456789
# Optional
SHOPIFY_SRC_THEME_FOLDER=./src
SHOPIFY_DIST_THEME_FOLDER=./dist
SHOPIFY_WATCH_PORT=9393- Run a commands
# Using yarn
yarn shopify-mellenger dev
yarn shopify-mellenger json-pull-staging
# Using npm
npm run shopify-mellenger dev
npm run shopify-mellenger json-pull-stagingThese variables will be automatically used in the predefined commands.
Recommended usage
In this example usage, we compile the theme and push the changes to a sandboxed dev theme.
..., // The rest of your package.json
"scripts": {
"watch": "webpack --watch --node-env=production",
"dev": "yarn watch & shopify-mellenger dev"
}Predefined Commands
The following commands are available out of the box:
| Command | Action |
|---------|-------------------|
| dev | Compile theme + work in a sandboxed development theme. |
| staging | Compile theme + work in on your staging theme. |
| share | Push your current theme to your store in a new theme. |
| push | Push theme + config up to your store. You will be asked to choose a theme. |
| pull | Pull codebase + config up to your store. You will be asked to choose a theme. |
| pull-staging | Pull codebase + config from your staging theme. |
| codebase-push | Push codebase up to your store. You will be asked to choose a theme. |
| codebase-push-staging | Push codebase up to your store's staging theme. |
| codebase-pull | Pull codebase from your staging theme. JSON will be ignored. |
| codebase-pull-staging | Pull codebase from your staging theme. JSON will be ignored. You will be asked to choose a theme. |
| json-pull | Pull config your store theme. You will be asked to choose a theme. |
| json-pull-staging | Pull config from your staging theme. |
Predefined Flags
| Flag | Action |
|---------|-------------------|
| -h or --help | Get tips and tricks on how the command line works. |
| --env=.env.ca | Define a different .env file. Defaults to .env. |
Customizing Commands
Create a .shopify-commands.json file in your project root to add or override commands. Your custom commands will be merged with the defaults — if you use the same name as a default command, yours will take precedence.
{
"push-js-staging": "shopify theme push --path $SHOPIFY_DIST_THEME_FOLDER --store $SHOPIFY_STORE --theme $SHOPIFY_STAGING_THEME_ID --only /\\.js$/"
}Environment Variables
The plugin supports environment variables in your commands. You can use them in two formats:
${VARIABLE_NAME}- Recommended format$VARIABLE_NAME- Alternative format
All environment variables from your .env file are available to your commands.
Features
- Run Shopify CLI commands with simple npm/yarn commands
- Support for environment variables from
.envfiles - Customizable command mapping in your
package.json - Helpful error messages and command suggestions
- Automatic variable substitution in your commands
Prerequisites
- Node.js (v12 or later)
- npm or yarn
- Shopify CLI installed globally
Troubleshooting
If you encounter any issues:
Ensure Shopify CLI is installed globally:
npm install -g @shopify/cli @shopify/themeCheck your
.envfile has the correct variablesVerify your
package.jsonhas the correct configuration
License
MIT
Contributing
Feel free to submit issues or pull requests to improve this plugin.
Development
To work on and test this project, use terminal to enter a Shopify repo and run the library. Please make sure Shopify CLI is installed globally first.
# If it's not installed
npm install -g @shopify/cli@latest
# Enter your repo
cd my-sample-shopify-store-repo
# Run the CLI extender by referring back to this folder
node ../shopify-cli-extender-mellenger/index.js --help
node ../shopify-cli-extender-mellenger/index.js devReleases
Releases are fully automated via semantic-release. Do not manually bump package.json or publish to npm. Everything is handled by CI when you merge into main.
How it works
- Open a PR against
main - Merge using Squash and Merge — the PR title becomes the commit message
- The release workflow runs automatically and determines the version bump from the PR title:
| PR title | Version bump |
|---|---|
| Any title (no prefix) | Patch — 1.3.1 → 1.3.2 |
| fix: resolve env bug | Patch — 1.3.1 → 1.3.2 |
| feat: add multi-store support | Minor — 1.3.1 → 1.4.0 |
| feat!: redesign CLI API | Major — 1.3.1 → 2.0.0 |
On release, the workflow will automatically:
- Bump the version in
package.json - Update
CHANGELOG.md - Create a GitHub Release with generated release notes
- Publish to npm
