Class: Afinstaller::Installers::AFPlatformBuild

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/afinstaller/installers/AF/platformBuild.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



8
9
10
# File 'lib/afinstaller/installers/AF/platformBuild.rb', line 8

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#build_attmeptObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/afinstaller/installers/AF/platformBuild.rb', line 52

def build_attmept
  puts Rainbow("== Attempting to build project ==").cyan
  if platform.downcase == "ios"
    system! 'xcodebuild -scheme GenericAF4 -workspace GenericAF4.xcworkspace/ -sdk iphonesimulator build | xcpretty'
  else
    system! 'adb install -r app/build/outputs/apk/app-$1-debug.apk'
    system! 'adb shell monkey -p com.phunware.appframework.sample.generic_template.$1 -c android.intent.category.LAUNCHER 1'
  end
  puts Rainbow("== Project built successfully ==").magenta

rescue NoMethodError => e
  puts Rainbow("== Something went wrong. Please try again. ==").red
  exit 1
end

#clone_commandObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/afinstaller/installers/AF/platformBuild.rb', line 12

def clone_command
  v = "#{version}"
  plat = "#{platform}"

  # Create directory and change directory into created dir.
  FileUtils::mkdir "AF-#{version}-#{plat}" unless File.exists?("AF-#{version}-#{plat}")
  FileUtils.cd("AF-#{version}-#{plat}", :verbose => false)
  puts Rainbow("== Cloning Repo ==").cyan
  if platform.downcase == "ios"
    system! 'git clone -b release/v'+v+' ssh://[email protected]:7999/af/af-template-ios.git' unless File.exist?('af-template-ios')
  else
    system! 'git clone -b v'+v+' ssh://[email protected]:7999/af/af-template-android.git' unless File.exist?('af-template-android')
  end
  puts Rainbow("== Cloning Succeeded ==").magenta
end

#dependency_install_commandObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/afinstaller/installers/AF/platformBuild.rb', line 28

def dependency_install_command
  puts Rainbow("== Moving to project folder ==").cyan

  if platform.downcase == "ios"
    FileUtils.cd('af-template-ios', :verbose => false)
    puts Rainbow("== Folder is now af-template-ios ==").magenta

    puts Rainbow("== Attempting to run pod install ==").cyan
    system! 'pod install'
    puts Rainbow("== Cocoapod installation completed ==").magenta
  else
    FileUtils.cd('af-template-android', :verbose => false)
    puts Rainbow("== Folder is now af-template-android ==").magenta
    puts Rainbow("== Attempting Gradle Clean ==").cyan
    system! './gradlew clean :app:assembleDebug --parallel --daemon --configure-on-demand -PminSdk=21'
    puts Rainbow("== Gradle successful ==").magenta
  end

rescue NoMethodError => e
  puts Rainbow("== Something went wrong. Please try again. ==").red
  exit 1

end

#open_project_folderObject



67
68
69
70
71
# File 'lib/afinstaller/installers/AF/platformBuild.rb', line 67

def open_project_folder
  puts Rainbow("== Open project folder ==").cyan
  system! 'open .'
  puts Rainbow("== AF Installer process completed. Thank you ==").magenta
end