Class: ShopifyCLI::JsDeps

Inherits:
Object
  • Object
show all
Includes:
SmartProperties
Defined in:
lib/shopify_cli/js_deps.rb

Overview

ShopifyCLI::JsDeps ensures that all JavaScript dependencies are installed for projects.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.install(ctx, verbose = false) ⇒ Object

Proxy to instance method ShopifyCLI::JsDeps.new.install.

#### Parameters

  • ‘ctx`: running context from your command

  • ‘verbose`: whether to run the installation tools in silent mode

#### Example

ShopifyCLI::JsDeps.install(ctx)


24
25
26
# File 'lib/shopify_cli/js_deps.rb', line 24

def self.install(ctx, verbose = false)
  new(ctx: ctx).install(verbose)
end

Instance Method Details

#install(verbose = false) ⇒ Object

Installs all of a project’s JavaScript dependencies using Yarn or NPM, based on the project’s settings.

#### Parameters

  • ‘verbose`: whether to run the installation tools in silent mode

#### Example

# context is the running context for the command
ShopifyCLI::JsDeps.new(context).install(true)


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/shopify_cli/js_deps.rb', line 39

def install(verbose = false)
  title = ctx.message("core.js_deps.installing", @system.package_manager)
  success = ctx.message("core.js_deps.installed")
  failure = ctx.message("core.js_deps.error.install_error", @system.package_manager)

  CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
    @system.call(
      yarn: -> { yarn(verbose) },
      npm: -> { npm(verbose) }
    )
  end
end