Module: Extension::Features::ArgoSetupSteps

Defined in:
lib/project_types/extension/features/argo_setup_steps.rb

Constant Summary collapse

YARN_INITIALIZE_COMMAND =
%w(generate).freeze
NPM_INITIALIZE_COMMAND =
%w(run generate --).freeze
INITIALIZE_TYPE_PARAMETER =
'--type=%s'

Class Method Summary collapse

Class Method Details

.check_dependencies(dependency_checks) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/project_types/extension/features/argo_setup_steps.rb', line 10

def self.check_dependencies(dependency_checks)
  ArgoSetupStep.always_successful do |context, _identifier, _directory_name, _js_system|
    dependency_checks.each do |dependency_check|
      dependency_check.call(context)
    end
  end
end

.clone_template(git_template) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/project_types/extension/features/argo_setup_steps.rb', line 18

def self.clone_template(git_template)
  ArgoSetupStep.default do |context, _identifier, directory_name, _js_system|
    begin
      ShopifyCli::Git.clone(git_template, directory_name, ctx: context)
      context.root = File.join(context.root, directory_name)
    rescue StandardError
      context.puts('{{x}} Unable to clone the repository.')
    end
  end
end

.initialize_projectObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/project_types/extension/features/argo_setup_steps.rb', line 35

def self.initialize_project
  ArgoSetupStep.default do |context, identifier, _directory_name, js_system|
    frame_title = context.message('create.setup_project_frame_title')
    failure_message = context.message('features.argo.initialization_error')

    result = true
    CLI::UI::Frame.open(frame_title, failure_text: failure_message) do
      result = js_system.call(
        yarn: YARN_INITIALIZE_COMMAND + [INITIALIZE_TYPE_PARAMETER % identifier],
        npm: NPM_INITIALIZE_COMMAND + [INITIALIZE_TYPE_PARAMETER % identifier]
      )
    end

    result
  end
end

.install_dependenciesObject



29
30
31
32
33
# File 'lib/project_types/extension/features/argo_setup_steps.rb', line 29

def self.install_dependencies
  ArgoSetupStep.default do |context, _identifier, _directory_name, js_system|
    ShopifyCli::JsDeps.new(ctx: context, system: js_system).install
  end
end