public
Description: Ruby build tools for the SproutCore JavaScript framework. Install via sudo gem install sproutcore
Homepage: http://www.sproutcore.com
Clone URL: git://github.com/sproutit/sproutcore-buildtools.git
sproutcore-buildtools / bin / sc-install
100755 102 lines (76 sloc) 2.572 kb
1
2
3
4
5
6
7
8
9
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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env ruby
 
# INSTALLS A SPROUTCORE BUNDLE
# This script will attempt to download and install framework and application
# bundles from github.
#
# Usage:
# sc-install owner-projectname
#
# You can also choose a different install URL:
# sc-install owner-projectname --source=sproutit/sproutcore-samples
#
# You can select an install method. (git is preferred and the default)
# sc-install owner-projectname --method=zip
 
 
APP_ROOT = File.expand_path(Dir.pwd)
SC_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.unshift File.join(SC_ROOT,'lib') ;
 
# Set String encoding to Unicode
$KCODE = 'u'
 
# Require SproutCore
require 'rubygems'
require 'rubigen'
require 'sproutcore'
require 'optparse'
 
############################################################
## Define Helper Methods
##
 
 
############################################################
## Process Options
##
 
# Process options
bundle_name = ARGV.shift if (ARGV.size > 0 && ARGV[0][0..0] != '-')
options = { :verbose => false, :library_root => APP_ROOT }
 
opts = OptionParser.new do |opts|
  opts.version = SproutCore::VERSION::STRING
 
  opts.banner = "Usage: sc-install {bundle-name} {options}"
  opts.define_head "Remotely install JavaScript bundles from Github and other sources"
  opts.separator ''
  opts.separator '*'*80
  opts.separator 'If no flags are given, sc-install will attempt to install the named bundle from'
  opts.separator 'github into the local project.'
  opts.separator '*'*80
 
  SC::BundleInstaller.configure_tool_options(opts, options)
 
end
 
begin
  opts.parse!
rescue Exception => e
  puts opts
  puts e
  exit(1)
end
 
############################################################
## SETUP ENVIRONMENT
##
 
# Configure logger
SC.logger.level = (options[:verbose]) ? Logger::DEBUG : Logger::INFO
SC.logger.progname = $0
SC.logger.info("sc-install v#{SproutCore::VERSION::STRING}")
 
# Confirm various safety settings
SC.logger.info(" ~ Verbose logging enabled") if options[:verbose]
SC.logger.info(" ~ Dry run mode - no change will be made") if options[:dry_run]
 
# Load Library
library = SC.library_for(options[:library_root])
 
############################################################
## PERFORM THE INSTALL
##
 
if bundle_name.nil?
  puts opts
  SC.logger.fatal("A bundle name is required.")
  exit(1)
end
 
if library.nil?
  SC.logger.fatal("No SproutCore library could be found. Make sure you are inside of your project directory (the one with an sc-config file in it).")
  exit(1)
end
 
library.install_bundle(bundle_name, options)
SC.logger.debug("")