Class: ShopifyExtensions::Install

Inherits:
Object
  • Object
show all
Defined in:
ext/shopify-extensions/shopify_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(platform: Platform.new, **args) ⇒ Object



12
13
14
# File 'ext/shopify-extensions/shopify_extensions.rb', line 12

def self.call(platform: Platform.new, **args)
  new.call(platform: platform, **args)
end

.versionObject



16
17
18
# File 'ext/shopify-extensions/shopify_extensions.rb', line 16

def self.version
  File.read(File.expand_path("../version", __FILE__)).strip
end

Instance Method Details

#call(platform:, version: self.class.version, target:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'ext/shopify-extensions/shopify_extensions.rb', line 20

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

  asset = Asset.new(
    platform: platform,
    version: version,
    owner: "Shopify",
    repository: "shopify-cli-extensions",
    basename: "shopify-extensions"
  )
  downloaded = asset.download(target: target)
  raise InstallationError.asset_not_found(platform: platform, version: version) unless downloaded

  raise InstallationError.installation_failed unless verify(target, version: version)
end