Shopify CLIの Shopify theme コマンド について
この記事では、Shopify CLIのshopify themeコマンドを紹介していこうと思います。
shopify theme コマンドについて
ターミナルにて
shopify theme -h
と入力することで、shopify themeコマンドの一覧が確認できます。

現在、○○に入るものはinit・check・pull・serve・list・open・push・share・publish・package・deleteの11種類があります。
1. shopify theme init
shopify theme init
shopify theme initは、Gitリポジトリから自分のPC(ローカル)にテーマのコピーを作成します。
コピーされるテーマは、デフォルトで「Dawn」になっています。
このとき、名前を入力することになりますが、これはコピーしたテーマを保管するフォルダ名になります。
フォルダの名前付けと、コピーしたいテーマを選択したい場合は、
shopify theme init [フォルダ名] -u[コピーを作成したいテーマのgitリポジトリのURL]
と入力することで1行で完結します。
2. shopify theme check
shopify theme checkは、テーマのコードをチェックする場合に使用します。
shopify theme check
テーマ コードのエラーを分析し、テーマと Liquid のベストプラクティスに従っていることを確認します。
3. shopify theme pull
shopify theme pullは、カスタマイズ・編集しているテーマをローカルにコピーしたい場合に使用します。
shopify theme pull [-i ダウンロードしたいテーマのID]
IDは、テーマエディターのURLの
theme/ID/editior
に該当する番号となります。
4. shopify theme serve
shopify theme serveは編集したテーマをプレビューしたい場合に使用します。
shopify theme serve
入力すると次のような表示になります。
┏━━ Viewing theme…━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┃ * Syncing theme #○○○○○○○○○○○○ on xxxxx.myshopify.com
┃
┃
┃ Serving .
┃
┃ Please open this URL in your browser:
┃ http://127.0.0.1:9292
┃
┃ Customize this theme in the Online Store Editor:
┃ https://xxxxx.myshopify.com/admin/themes/○○○○○○○○○○○○/editor
┃
┃ Share this theme preview:
┃ https://xxxxx.myshopify.com/?preview_theme_id=○○○○○○○○○○○○
┃
┃ (Use Ctrl-C to stop)
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3つのURLに飛ぶことができます。
1:Please open this URL in your browser
ローカルのサーバーでGoogleChromeでサイトの表示が確認できます。
2:Customize this theme in the Online Store Editor
オンラインストアエディター(テーマエディタ)へのリンクです。
3:Share this theme preview
他の開発者と共有することができるプレビューリンクです。
1とは異なり、このリンクにアクセスできるすべての人が確認できます。
このコマンドを使用する際は、そのフォルダにカレントディレクトリの状態でなければなりません。
5. shopify theme list
shopify theme listはID とステータスとともに、ストア内のテーマを一覧表示します。
shopify theme list
6. shopify theme open
shopify theme openは、ストア内のテーマのリスト(テーマライブラリー)から開くテーマを選択し、そのテーマをプレビューできるURLを返してくれます。
shopify theme open
テーマを指定したい場合は、最後に-t IDを付与します。
shopify theme open -t[ID]
7. shopify theme push
shopify theme pushは、ローカルで編集したテーマ ファイルをShopifyにアップロードする場合に使用します。
shopify theme push
上書きするテーマが指定されていない場合は、ストア内のテーマのリストから選択するよう求められます。
8. shopify theme share
shopify theme shareは、未公開の新しいテーマとしてテーマ ライブラリにアップロードする場合に使用します。
shopify theme share
テーマにはランダムな名前が付与されます。
※shopify theme listで確認できます。
9. shopify theme publish
shopify theme publishは、メインテーマを変更したい場合に使用します。
shopify theme publish
テーマライブラリーにある他のテーマをメインテーマに設定できます。
10. shopify theme package
shopify theme packageは、ローカルのテーマファイルをShopify にアップロードできる ZIP ファイルにパッケージ化する場合に使用します。
shopify theme package
フォルダ内に、テーマファイルを含んだZipファイルが生成されます。
11. shopify theme delete
shopify theme deleteは、テーマを削除する場合に使用します。
shopify theme delete
テーマライブラリーにテーマが複数ある場合は、リストから選択します。
終わり
以上となります。
参考サイト
Discussion