-
Notifications
You must be signed in to change notification settings - Fork 0
/
shopify-cli-pre.rb
61 lines (48 loc) · 1.95 KB
/
shopify-cli-pre.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
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require "formula"
require "language/node"
require "fileutils"
class ShopifyCliPre < 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.47.0-pre.0.tgz"
sha256 "65b4604adfb54684cfbe4b897f7e7a78fc9cc2817048ac4217ebb869893e14af"
license "MIT"
depends_on "node"
depends_on "ruby"
depends_on "git"
resource "cli-theme-commands" do
url "https://registry.npmjs.org/@shopify/theme/-/theme-3.47.0-pre.0.tgz"
sha256 "50577245ffc6fadd4183bf13c2340e44386a92fd79e9fc00663694424f242f15"
end
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}-pre"
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_RUBY_BINDIR = "#{Formula["ruby"].opt_bin}"
process.env.SHOPIFY_HOMEBREW_FORMULA = "shopify-cli-pre"
import("#{new_original_executable_path}")
SCRIPT
File.write executable_path, executable_content
FileUtils.chmod("+x", executable_path)
bin.install_symlink executable_path
resource("cli-theme-commands").stage {
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
}
end
end