Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
rake extensions:install & disable auto install
Browse files Browse the repository at this point in the history
  • Loading branch information
t6d committed Sep 17, 2021
1 parent e3890eb commit 0f98a82
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
53 changes: 36 additions & 17 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,46 @@ end
desc("Builds all distribution packages of the CLI")
task(package: "package:all")

namespace :shopify do
namespace :extensions do
task :update do
version = ENV.fetch("VERSION").strip
error("Invalid version") unless /^v\d+\.\d+\.\d+/.match(version)
extconf = File.expand_path("../ext/shopify-extensions/extconf.rb", __FILE__)
File.open(extconf) do |f|
IO.write(extconf, f.read.gsub(/(?<=version: ")(.*?)(?=")/, version))
end
namespace :extensions do
task :update do
version = ENV.fetch("VERSION").strip
error("Invalid version") unless /^v\d+\.\d+\.\d+/.match(version)
extconf = Paths.extension("extconf.rb")
File.open(extconf) do |f|
IO.write(extconf, f.read.gsub(/(?<=version: ")(.*?)(?=")/, version))
end
end

task :symlink do
source = Paths.root("..", "shopify-cli-extensions", "shopify-extensions")
error("Unable to find shopify-extensions executable: #{executable}") unless File.executable?(source)
target = Paths.extension("shopify-extensions")
File.delete(target) if File.exist?(target)
File.symlink(source, target)
end

task :symlink do
root = File.dirname(__FILE__)
executable = File.expand_path("../shopify-cli-extensions/shopify-extensions", root)
error("Unable to find shopify-extensions executable: #{executable}") unless File.executable?(executable)
File.symlink(executable, File.join(root, "ext/shopify-extensions/shopify-extensions"))
task :install do
target = Paths.extension("shopify-extensions")
require_relative Paths.extension("shopify_extensions.rb")
File.delete(target) if File.exist?(target)
ShopifyExtensions.install(
version: "v0.1.0",
target: target
)
end

module Paths
def self.extension(*args)
root("ext", "shopify-extensions", *args)
end

def error(message, output: STDERR, code: 1)
output.puts(message)
exit(code)
def self.root(*args)
Pathname(File.dirname(__FILE__)).join(*args).to_s
end
end
end

def error(message, output: STDERR, code: 1)
output.puts(message)
exit(code)
end
2 changes: 1 addition & 1 deletion ext/shopify-extensions/shopify_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.call(platform: Platform.new, **args)
end

def call(platform:, version:, target:)
target = platform.format_path(target)
target = platform.format_path(target.to_s)

asset = Asset.new(
platform: platform,
Expand Down
2 changes: 1 addition & 1 deletion shopify-cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
end
spec.bindir = "bin"
spec.require_paths = ["lib", "vendor"]
spec.extensions = ["ext/shopify-cli/extconf.rb", "ext/shopify-extensions/extconf.rb"]
spec.extensions = ["ext/shopify-cli/extconf.rb"]
# Do NOT include `shopify` as a listed executable via `spec.executables`.
# `ext/shopify-cli/extconf.rb` will dynamically create a script and soft-link
# `/usr/local/bin/shopify` to that script, in order to "lock" the Ruby used to
Expand Down

0 comments on commit 0f98a82

Please sign in to comment.