Closed5

Shopify CLI 3.xへの移行

Kazuki YonemotoKazuki Yonemoto

CLI 3系への移行手順

次のステップで移行作業を行う。以降の記述は以下ドキュメントをベースに日本語化しています。

https://shopify.dev/themes/tools/cli/migrate

macOS と Homebrew

macOSでHomebrewを利用している場合は前のバージョンをアンインストールしなくても良い。
以下コマンドで直接アップグレードが可能。

nodeのバージョンは14.13.1 以上が必要。

brew upgrade shopify-cli

https://brew.sh/index_ja

macOSではHomebrewを使ったインストール管理で一本化されるようですね。

その他

上記以外の方法を利用している場合は次の手段で移行を行う。

Step 1: Install new requirements

先ほどと同じくnodeのバージョンは14.13.1 以上が必要らしい。
環境ごとの要件は以下に記載されている。
https://shopify.dev/themes/tools/cli/install

Step 2: Uninstall Shopify CLI 2.x

以前のバージョンを残しているとコンフリクトを起こすようなので、まずアンインストールから行う。
以下の中から利用のパッケージマネージャーを選んで実行。

apt
sudo apt remove shopify-cli
Yum
sudo yum remove shopify-cli
RubyGems
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系どっちも使いたいんだけど〜って方は以下を参照してください。
ただ、複雑性が増すのであんまりおすすめはできないかも。。
https://shopify.dev/themes/tools/cli/migrate#using-both-shopify-cli-2-x-and-3-x

Kazuki YonemotoKazuki Yonemoto

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}}
このスクラップは2022/11/10にクローズされました