Class: FWToolkit::Project

Inherits:
Thor
  • Object
show all
Includes:
ThorUtils, Thor::Actions
Defined in:
lib/fwtoolkit/cli/project.rb

Instance Method Summary collapse

Methods included from ThorUtils

included

Methods included from Thor::Actions

#run, #run!, #run_base, #template_directory

Instance Method Details

#conf_rvm(project_language, project_root = Dir.pwd) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fwtoolkit/cli/project.rb', line 45

def conf_rvm(project_language, project_root=Dir.pwd)
  @project_name = File.basename(project_root)
  @ruby_version = Config.ruby_version
  destination_root = project_root

  say 'Configuring rvm'

  directory "templates/default_project/rvm", destination_root

  inside(destination_root) do
    run! "rvm install ruby-#{Config.ruby_version}"
    run! "rvm #{Config.ruby_version} do rvm --ruby-version --create ruby-#{Config.ruby_version}@#{@project_name}", {:capture => true}
    bundle_update
  end
end

#new(project_language, project_name, class_prefix) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fwtoolkit/cli/project.rb', line 18

def new(project_language, project_name, class_prefix)
  unless project_language == "swift" or project_language == "objc" 
    say_status :error, "Project language should be either swift or objc", :red
    return
  end
  destination_root = File.join(Dir.pwd, project_name)

  say "Creating new project in: #{File.expand_path destination_root}"

  invoke :conf_rvm, [project_language, destination_root]

  invoke FWToolkit::Bitrise, 'new', [destination_root, project_name, class_prefix.upcase]

  invoke FWToolkit::Xcode, 'new', [project_language, project_name, class_prefix.upcase, File.join(Dir.pwd, project_name)]
  invoke FWToolkit::Cocoapods, 'install', [destination_root]

  git_repo = GitClient::Repository.new destination_root
  # gitignore is included on xcode new.. for now
  
  if(git_repo.initialized?)
    say_status :skip, 'The git repository is already initialized', :yellow
  else
    invoke FWToolkit::Git, 'new', [destination_root]
  end
end

#update(project_root = Dir.pwd) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/fwtoolkit/cli/project.rb', line 62

def update(project_root=Dir.pwd)
  bundle_update
  
  invoke FWToolkit::Git, 'update', [project_root]
  invoke FWToolkit::Cocoapods, 'install', [project_root]
  
end