-
Notifications
You must be signed in to change notification settings - Fork 25
/
shopify-cli@3.rb
50 lines (39 loc) · 1.54 KB
/
shopify-cli@3.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true
require "formula"
require "language/node"
require "fileutils"
class ShopifyCliAT3 < Formula
desc "A CLI tool to build for the Shopify platform"
homepage "https://github.com/shopify/cli#readme"
url "https://registry.npmjs.org/@shopify/cli/-/cli-3.72.2.tgz"
sha256 "b69e3c23f879661df7b9c694eec9cbfbd4db7486e53dc655b6cd2ea211d6163f"
license "MIT"
depends_on "node"
depends_on "git"
livecheck do
url :stable
end
def install
existing_cli_path = `which shopify`
unless existing_cli_path.empty? || existing_cli_path.include?("homebrew")
opoo <<~WARNING
We've detected an installation of the Shopify CLI at #{existing_cli_path} that's not managed by Homebrew.
Please ensure that the Homebrew line in your shell configuration is at the bottom so that Homebrew-managed
tools take precedence.
WARNING
end
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
original_executable_path = "#{libexec}/bin/shopify"
executable_path = "#{original_executable_path}3"
new_original_executable_path = "#{executable_path}-original"
FileUtils.move(original_executable_path, new_original_executable_path)
executable_content = <<~SCRIPT
#!/usr/bin/env #{Formula["node"].opt_bin}/node
process.env.SHOPIFY_HOMEBREW_FORMULA = "shopify-cli@3"
import("#{new_original_executable_path}")
SCRIPT
File.write executable_path, executable_content
FileUtils.chmod("+x", executable_path)
bin.install_symlink executable_path
end
end