Class: ReactNativeUtil::CLI

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods, Util
Defined in:
lib/react_native_util/cli.rb

Instance Method Summary collapse

Methods included from Util

#boolean_env_var?, #execute, #float_env_var, #have_command?, #log, #mac?, #platform, #run_command_with_spinner!, #validate_commands!

Instance Method Details

#runObject



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
# File 'lib/react_native_util/cli.rb', line 10

def run
  program :name, SUMMARY
  program :version, VERSION
  program :description, DESCRIPTION

  command :react_pod do |c|
    c.syntax = "#{NAME} react_pod [OPTIONS]"
    c.summary = 'Convert a React Native app to use the React pod from node_modules.'
    c.description = "[Work in progress] Removes all static libraries built by the Libraries group and adds a generic " \
      "Podfile.\nResults in a buildable, working project."

    c.option '--[no-]repo-update', 'Update the local podspec repo (default: update; env. var. REACT_NATIVE_UTIL_REPO_UPDATE)'

    c.action do |_args, opts|
      begin
        converter = Converter.new repo_update: opts.repo_update
        converter.convert_to_react_pod!
        exit 0
      rescue ExecutionError => e
        # Generic command failure.
        log e.message.red.bold
        exit(-1)
      rescue ConversionError => e
        log "Conversion failed: #{e.message}".red.bold
        exit(-1)
      end
    end
  end

  run!
end