Module: Ruflet::CLI

Extended by:
CLI, BuildCommand, ExtraCommand, NewCommand, RunCommand, UpdateCommand
Included in:
CLI
Defined in:
lib/ruflet/cli.rb,
lib/ruflet/cli/templates.rb,
lib/ruflet/cli/android_sdk.rb,
lib/ruflet/cli/flutter_sdk.rb,
lib/ruflet/cli/new_command.rb,
lib/ruflet/cli/run_command.rb,
lib/ruflet/cli/build_command.rb,
lib/ruflet/cli/extra_command.rb,
lib/ruflet/cli/update_command.rb,
lib/ruflet/cli/environment_setup.rb

Defined Under Namespace

Modules: AndroidSdk, BuildCommand, EnvironmentSetup, ExtraCommand, FlutterSdk, NewCommand, RunCommand, UpdateCommand

Constant Summary collapse

MAIN_TEMPLATE =
<<~RUBY
require "ruflet"
Ruflet.run do |page|
  page.title = "%<app_title>s"
  count = 0
  count_text = text(count.to_s, style: {size: 40})
  page.add(
    container(
      expand: true,
      alignment: Ruflet::MainAxisAlignment::CENTER,
      content: column(
        alignment: Ruflet::MainAxisAlignment::CENTER,
        horizontal_alignment: Ruflet::CrossAxisAlignment::CENTER,
        children: [
          text("You have pushed the button this many times:"),
          count_text
        ]
      )
    ),
    floating_action_button: fab(
      icon: "add",
      on_click: ->(_e) do
        count += 1
        page.update(count_text, value: count.to_s)
      end
    )
  )
end

RUBY
GEMFILE_TEMPLATE =
<<~GEMFILE
  source "https://rubygems.org"

  gem "ruflet", ">= #{Ruflet::VERSION}"
  gem "ruflet_core", ">= #{Ruflet::VERSION}"
  gem "ruflet_server", ">= #{Ruflet::VERSION}"
GEMFILE
README_TEMPLATE =
<<~MD
  # %<app_name>s

  Ruflet app.

  ## Setup

  ```bash
  bundle install
  ```

  ## Run

  ```bash
  bundle exec ruflet run main
  ```

  ## Build

  ```bash
  bundle exec ruflet build apk
  bundle exec ruflet build ios
  ```
MD

Constants included from NewCommand

NewCommand::CLIENT_EXTENSION_MAP, NewCommand::RUNTIME_REPO_URL, NewCommand::TEMPLATE_REPO_URL

Constants included from UpdateCommand

UpdateCommand::VALID_UPDATE_PLATFORMS

Constants included from BuildCommand

BuildCommand::CLIENT_EXTENSION_MAP, BuildCommand::DEFAULT_SERVICE_NATIVE_REQUIREMENTS, BuildCommand::SERVICE_EXTENSION_MAP

Constants included from AndroidSdk

AndroidSdk::ANDROID_BUILD_TOOLS, AndroidSdk::ANDROID_PLATFORM, AndroidSdk::CMDLINE_TOOLS_BASE, AndroidSdk::CMDLINE_TOOLS_VERSION, AndroidSdk::JDK_PACKAGES, AndroidSdk::MINIMUM_JAVA_MAJOR

Constants included from EnvironmentSetup

EnvironmentSetup::LINUX_PACKAGE_MANAGERS

Constants included from FlutterSdk

FlutterSdk::DEFAULT_FLUTTER_CHANNEL, FlutterSdk::RELEASES_BASE

Instance Method Summary collapse

Methods included from NewCommand

command_new

Methods included from RunCommand

command_run

Methods included from UpdateCommand

command_update

Methods included from BuildCommand

command_build, command_install, run_build_command, with_project_build_lock

Methods included from AndroidSdk

#android_build_env, #android_environment_setup!, #detect_android_sdk_root, #managed_android_sdk_root

Methods included from EnvironmentSetup

#environment_setup!, #required_system_tools, #system_package_manager

Methods included from FlutterSdk

#ensure_flutter!, #flutter_version_summary

Methods included from ExtraCommand

command_create, command_debug, command_devices, command_doctor, command_emulators

Instance Method Details

#bootstrap(path) ⇒ Object



86
87
88
89
# File 'lib/ruflet/cli.rb', line 86

def bootstrap(path)
  command_new([path || Dir.pwd])
  0
end


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ruflet/cli.rb', line 67

def print_help
  puts <<~HELP
    Ruflet CLI

    Commands:
      ruflet --version
      ruflet create <appname>
      ruflet new <appname>
      ruflet run [scriptname|path] [--web|--desktop] [--port PORT]
      ruflet update [web|desktop|all] [--check] [--force] [--platform PLATFORM]
      ruflet debug [scriptname|path]
      ruflet build <apk|android|ios|aab|web|macos|windows|linux> [--self] [--verbose]
      ruflet install [--device DEVICE_ID] [--verbose]
      ruflet devices
      ruflet emulators
      ruflet doctor
  HELP
end

#run(argv = ARGV) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ruflet/cli.rb', line 29

def run(argv = ARGV)
  command = (argv.shift || "help").downcase
  ensure_first_run_assets(command)

  case command
  when "version", "-v", "--version"
    puts version_string
    0
  when "create"
    command_create(argv)
  when "new", "bootstrap", "init"
    command_new(argv)
  when "run"
    command_run(argv)
  when "update"
    command_update(argv)
  when "debug"
    command_debug(argv)
  when "build"
    command_build(argv)
  when "install"
    command_install(argv)
  when "devices"
    command_devices(argv)
  when "emulators"
    command_emulators(argv)
  when "doctor"
    command_doctor(argv)
  when "help", "-h", "--help"
    print_help
    0
  else
    warn "Unknown command: #{command}"
    print_help
    1
  end
end

#version_stringObject



91
92
93
# File 'lib/ruflet/cli.rb', line 91

def version_string
  "ruflet #{Ruflet::VERSION}"
end