Shopify CLI 3.xへの移行
Shopify CLI 3.xへの移行
Shopify CLI 3系がテーマの方でも標準化されたようなので移行作業を行なっていきたい。
やりたいこと
v2からv3へのアップデート対応を進めていきたい。
以下に変更内容や手順が記載されている。
3系で何が変わった?
一部コマンドがサポートされなくなったり、名称が変更されてたりするので要注意。
特にshopify theme serve
がshopify theme dev
になってるのは罠感ある。。
CLI 3系への移行手順
次のステップで移行作業を行う。以降の記述は以下ドキュメントをベースに日本語化しています。
macOS と Homebrew
macOSでHomebrewを利用している場合は前のバージョンをアンインストールしなくても良い。
以下コマンドで直接アップグレードが可能。
nodeのバージョンは14.13.1 以上が必要。
brew upgrade shopify-cli
macOSではHomebrewを使ったインストール管理で一本化されるようですね。
その他
上記以外の方法を利用している場合は次の手段で移行を行う。
Step 1: Install new requirements
先ほどと同じくnodeのバージョンは14.13.1 以上が必要らしい。
環境ごとの要件は以下に記載されている。
Step 2: Uninstall Shopify CLI 2.x
以前のバージョンを残しているとコンフリクトを起こすようなので、まずアンインストールから行う。
以下の中から利用のパッケージマネージャーを選んで実行。
sudo apt remove shopify-cli
sudo yum remove shopify-cli
gem uninstall shopify-cli
もしShopify CLI 0.9.0以下を利用している場合はこっち👈。
Step 3: Install Shopify CLI 3.x
Shopify CLI 3.xをインストールしていく。
npmパッケージとして今後は管理されてくみたい。
macOSを利用している場合はHomebrewでパッケージをインストールする。
brew tap shopify/shopify
brew install shopify-cli
Windows もしくは Linux環境ではnpmでグローバルにパッケージインストールするらしい。
macOSだとこっちの方法はダメなのかな?
npm install -g @shopify/cli @shopify/theme
Step 4: Verify the installation
以下コマンドで問題なくインストールできたか確認します。
shopify version
以上で作業は終了です。お疲れさまでした〜☺️
2系と3系どっちも使いたいんだけど〜って方は以下を参照してください。
ただ、複雑性が増すのであんまりおすすめはできないかも。。
Shopify CLI 3.xのコマンド
shopify --help
を叩くとこんなこんな感じ。
VERSION
@shopify/cli/3.22.1 darwin-x64 node-v16.17.0
USAGE
$ shopify [COMMAND]
TOPICS
auth Auth operations
ngrok Manage ngrok tunnels
plugins List installed plugins.
theme Build Liquid themes
COMMANDS
commands list all the commands
help Display help for shopify.
logs View full debug logs from the Shopify CLI
plugins List installed plugins.
upgrade Upgrade the Shopify CLI
version Shopify CLI version
shopify theme --help
を叩くとこんなこんな感じ。
USAGE
$ shopify theme COMMAND
COMMANDS
theme check Validate the theme
theme delete Delete remote themes from the connected store. This command can't be undone
theme dev Uploads the current theme as a development theme to the connected store, then prints theme editor and preview URLs to your terminal. While running, changes will push to the store
in real time.
theme info Print basic information about your theme environment
theme init Clones a Git repository to use as a starting point for building a new theme.
theme language-server Start a Language Server Protocol server.
theme list Lists your remote themes.
theme open Opens the preview of your remote theme.
theme package Package your theme into a .zip file, ready to upload to the Online Store.
theme publish Set a remote theme as the live theme.
theme pull Download your remote theme files locally.
theme push Uploads your local theme files to the connected store, overwriting the remote version if specified.
theme share Creates a shareable, unpublished, and new theme on your theme library with a randomized name. Works like an alias to {{command:theme push -u -t=RANDOMIZED_NAME}}
Shopify CLI 3.xを使ったテーマ開発テンプレ
Shopifyテーマ開発用スターターテンプレートを作っています。良ければ使ってみてね🥳