fvm 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +65 -0
- data/Rakefile +39 -0
- data/bin/fvm +4 -0
- data/fvm.gemspec +28 -0
- data/lib/fvm.rb +39 -0
- data/lib/fvm/cli/build.rb +41 -0
- data/lib/fvm/cli/driver.rb +161 -0
- data/lib/fvm/cli/installation.rb +34 -0
- data/lib/fvm/cli/installer.rb +54 -0
- data/lib/fvm/cli/linker.rb +44 -0
- data/lib/fvm/cli/shell.rb +102 -0
- data/lib/fvm/cli/thor.rb +66 -0
- data/lib/fvm/manipulator.rb +43 -0
- data/lib/fvm/parser.rb +57 -0
- data/lib/fvm/version.rb +6 -0
- data/scripts/fvm +9 -0
- data/test/fixtures/confirmer/Confirmation.html +851 -0
- data/test/fixtures/linker/bin/executable +3 -0
- data/test/fixtures/linker/bin/not_executable +1 -0
- data/test/fixtures/linker/bin/shell_script.sh +1 -0
- data/test/fixtures/parser/Flex_SDK_3.html +1031 -0
- data/test/fixtures/parser/Flex_SDK_4.html +948 -0
- data/test/fixtures/parser/Flex_SDK_Hero.html +888 -0
- data/test/fixtures/parser/Simplified.html +57 -0
- data/test/fvm/test_build.rb +35 -0
- data/test/fvm/test_installation.rb +37 -0
- data/test/fvm/test_linker.rb +33 -0
- data/test/fvm/test_manipulator.rb +48 -0
- data/test/fvm/test_parser.rb +35 -0
- data/test/test_helper.rb +7 -0
- metadata +206 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
Flex SDK Version Manager
|
2
|
+
========================
|
3
|
+
|
4
|
+
**FVM is a work in progress! It DOES NOT WORK RIGHT NOW. I'll remove this notice when we're good to go.**
|
5
|
+
|
6
|
+
**fvm** is a ruby gem and executable for managing versions of the [Adobe Open Source Flex SDK][flex-sdk].
|
7
|
+
|
8
|
+
*It has only been tested on Mac OSX 10.6.4 and is likely to not work on many other configurations.* If you
|
9
|
+
have any success stories, however, please let me know and I'll add them here.
|
10
|
+
|
11
|
+
The manager provides a command-line installation process for any available Flex SDK versions and the
|
12
|
+
ability to symlink to the SDK's executables from `/usr/local/bin` (The same place [Homebrew][homebrew] suggests).
|
13
|
+
This allows programs like `mxmlc`, `asdoc`, and `compc` to be available from the command line easily.
|
14
|
+
The manager uses the symlink approach to make it easy to switch the symlinks immediately between
|
15
|
+
installed versions of the SDK if you need to.
|
16
|
+
|
17
|
+
Installation
|
18
|
+
------------
|
19
|
+
|
20
|
+
First, install the **fvm** gem:
|
21
|
+
|
22
|
+
gem install fvm
|
23
|
+
|
24
|
+
Next, add the following to your bash initialization script (bashrc, bash_init, /etc/profile, whatever you prefer):
|
25
|
+
|
26
|
+
[[ -s $(fvm restart) ]] && source $(fvm restart)
|
27
|
+
# This loads FVM into a shell session.
|
28
|
+
|
29
|
+
*Note: If you also have **rvm** installed, make sure these lines go **AFTER** the **rvm** initialization.*
|
30
|
+
|
31
|
+
Restart your shell and you're good to go.
|
32
|
+
|
33
|
+
Caveats
|
34
|
+
-------
|
35
|
+
|
36
|
+
- As of v0.1.1, I've only included `mxmlc`, `asdoc`, and `compc` to the list of executables to link. I'll
|
37
|
+
be adding more as fast as I can test them out, but if you want some programs before others, hit me up.
|
38
|
+
|
39
|
+
- I'm still trying to find a clean way to reset $FLEX_HOME after installing/using a new Flex SDK version.
|
40
|
+
Currently, the environment variable cannot be set in the ruby process, so there is a helper script,
|
41
|
+
`fvm-restart` that you'll need to run after either of those commands. Also, `fvm-restart` will be run
|
42
|
+
for any new shells (if you followed the installation instructions) so you could just re-start Terminal.
|
43
|
+
|
44
|
+
Usage
|
45
|
+
-----
|
46
|
+
|
47
|
+
`fvm install` installs a specific Flex SDK version.
|
48
|
+
|
49
|
+
`fvm list` lists installed Flex SDK versions.
|
50
|
+
|
51
|
+
`fvm use` can switch symlinks to a specific installed Flex SDK version.
|
52
|
+
|
53
|
+
`fvm unlink` removes any symlinks installed by **fvm**.
|
54
|
+
|
55
|
+
`fvm which` prints the currently-linked Flex SDK version.
|
56
|
+
|
57
|
+
`fvm-restart` re-sets the $FLEX_HOME environment variable.
|
58
|
+
|
59
|
+
Wish-List
|
60
|
+
---------
|
61
|
+
|
62
|
+
- `fvm langref` to install (or build) the language reference for this flex version
|
63
|
+
|
64
|
+
[flex-sdk]: http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK "Adobe Open Source Flex SDK"
|
65
|
+
[homebrew]: https://github.com/mxcl/homebrew "Homebrew GitHub Repo"
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
$: << File.join( File.dirname( __FILE__ ), 'test' )
|
5
|
+
|
6
|
+
require 'open-uri'
|
7
|
+
|
8
|
+
namespace :fixtures do
|
9
|
+
|
10
|
+
desc "Pulls down the target Flex SDK download pages"
|
11
|
+
task :parser do
|
12
|
+
[ '4', '3', 'Hero' ].each do |sdk|
|
13
|
+
open( "http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+#{sdk}" ) do |response|
|
14
|
+
File.open( "test/fixtures/parser/Flex_SDK_#{sdk}.html", "w" ) do |f|
|
15
|
+
f << response.read
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Pulls down an example license confirmation page"
|
22
|
+
task :confirmer do
|
23
|
+
open( 'http://opensource.adobe.com/wiki/display/flexsdk/download?build=4.1.0.16076&pkgtype=2&release=4' ) do |response|
|
24
|
+
File.open( "test/fixtures/confirmer/Confirmation.html", 'w' ) do |f|
|
25
|
+
f << response.read
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Pulls down all fixture pages"
|
31
|
+
task :all => [ :parser, :confirmer ]
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
desc "Runs the test suite"
|
37
|
+
task :test do
|
38
|
+
require 'test_helper'
|
39
|
+
end
|
data/bin/fvm
ADDED
data/fvm.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$: << File.join( File.dirname( __FILE__ ), 'lib' )
|
4
|
+
|
5
|
+
require 'fvm/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'fvm'
|
9
|
+
s.version = Fvm::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = [ 'Jeremy Ruppel' ]
|
12
|
+
s.email = [ 'jeremy.ruppel@gmail.com' ]
|
13
|
+
s.homepage = 'https://github.com/SFCRD/fvm'
|
14
|
+
s.summary = 'Flex SDK version manager'
|
15
|
+
s.description = 'Flex SDK version manager'
|
16
|
+
|
17
|
+
s.add_dependency 'thor', '0.14.3'
|
18
|
+
s.add_dependency 'highline', '~> 1.6'
|
19
|
+
s.add_dependency 'nokogiri', '~> 1.4.4'
|
20
|
+
s.add_dependency 'activeresource', '~> 3.0.4'
|
21
|
+
s.add_dependency 'geoffrey', '~> 1.1.3'
|
22
|
+
s.add_dependency 'versionomy', '~> 0.4.0'
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename( f ) }
|
27
|
+
s.require_paths = [ 'lib' ]
|
28
|
+
end
|
data/lib/fvm.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fvm
|
2
|
+
|
3
|
+
module CLI
|
4
|
+
autoload :Build, 'fvm/cli/build'
|
5
|
+
autoload :Installer, 'fvm/cli/installer'
|
6
|
+
autoload :Installation, 'fvm/cli/installation'
|
7
|
+
autoload :Linker, 'fvm/cli/linker'
|
8
|
+
autoload :Shell, 'fvm/cli/shell'
|
9
|
+
autoload :Driver, 'fvm/cli/driver'
|
10
|
+
autoload :Thor, 'fvm/cli/thor'
|
11
|
+
end
|
12
|
+
|
13
|
+
# TODO move into module
|
14
|
+
autoload :Manipulator, 'fvm/manipulator'
|
15
|
+
|
16
|
+
autoload :Parser, 'fvm/parser'
|
17
|
+
|
18
|
+
module System
|
19
|
+
def self.active_version?
|
20
|
+
active_version.nil? == false
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.active_version
|
24
|
+
@@active_version ||= find_active_version
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.active?( build )
|
28
|
+
active_version? ? active_version.version.eql?( build.version ) : false
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def self.find_active_version
|
34
|
+
mxmlc = `which mxmlc`
|
35
|
+
mxmlc.empty? ? nil : CLI::Installation.new( Pathname.new( `readlink #{mxmlc}` ).join( '..', '..' ) )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'active_resource'
|
2
|
+
require 'versionomy'
|
3
|
+
|
4
|
+
module Fvm
|
5
|
+
module CLI
|
6
|
+
class Build < ActiveResource::Base
|
7
|
+
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
self.site = 'http://fvm.heroku.com'
|
11
|
+
self.format = :json
|
12
|
+
|
13
|
+
def self.sdk( name )
|
14
|
+
all( :params => { :sdk => name } )
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.version( name )
|
18
|
+
all( :params => { :version => name } )
|
19
|
+
end
|
20
|
+
|
21
|
+
def zip_url
|
22
|
+
"http://fpdownload.adobe.com/pub/flex/sdk/builds/flex#{sdk.to_s.downcase}/flex_sdk_#{version}_mpl.zip"
|
23
|
+
end
|
24
|
+
|
25
|
+
def active?
|
26
|
+
Fvm::System.active?( self )
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_menu
|
30
|
+
out = [ version, milestone ]
|
31
|
+
out.unshift '*' if active?
|
32
|
+
out.join ' '
|
33
|
+
end
|
34
|
+
|
35
|
+
def <=>( other )
|
36
|
+
Versionomy.parse( version ) <=> Versionomy.parse( other.version )
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
module Fvm
|
2
|
+
module CLI
|
3
|
+
class Driver
|
4
|
+
=begin rdoc
|
5
|
+
Installs a version of the Flex SDK and creates symlinks to the included binaries.
|
6
|
+
|
7
|
+
If no options are provided, FVM will fetch all available builds and present them to
|
8
|
+
the user as an interactive menu.
|
9
|
+
|
10
|
+
Because we're trying to stay honest, the user will be prompted to agree to the MPL
|
11
|
+
license no matter what.
|
12
|
+
|
13
|
+
OPTIONS
|
14
|
+
|
15
|
+
-v, --version Specify a version of the Flex SDK to install
|
16
|
+
|
17
|
+
-s, --sdk Only present a menu containing builds from the given SDK name
|
18
|
+
|
19
|
+
=end
|
20
|
+
def install( options )
|
21
|
+
|
22
|
+
if options.version?
|
23
|
+
|
24
|
+
begin
|
25
|
+
builds = Fvm::CLI::Build.version( options.version )
|
26
|
+
rescue
|
27
|
+
shell.exit 'There was a problem connecting to the FVM API. Please try again.'
|
28
|
+
end
|
29
|
+
|
30
|
+
shell.exit "No Flex SDK build found with version #{options.version}" if builds.empty?
|
31
|
+
build = builds.first
|
32
|
+
|
33
|
+
elsif options.sdk?
|
34
|
+
|
35
|
+
begin
|
36
|
+
builds = Fvm::CLI::Build.sdk( options.sdk )
|
37
|
+
rescue
|
38
|
+
shell.exit 'There was a problem connecting to the FVM API. Please try again.'
|
39
|
+
end
|
40
|
+
|
41
|
+
shell.exit "No Flex SDK build found in SDK #{options.sdk}" if builds.empty?
|
42
|
+
build = shell.choose builds
|
43
|
+
|
44
|
+
else
|
45
|
+
|
46
|
+
begin
|
47
|
+
builds = Fvm::CLI::Build.all
|
48
|
+
rescue
|
49
|
+
shell.exit 'There was a problem connecting to the FVM API. Please try again.'
|
50
|
+
end
|
51
|
+
|
52
|
+
build = shell.choose builds
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
shell.exit "You must agree to the MPL terms before installing the Flex SDK." unless shell.mpl?
|
57
|
+
|
58
|
+
installed = installer.install build.zip_url, build.version
|
59
|
+
|
60
|
+
linker.link File.join( installed, 'bin' )
|
61
|
+
|
62
|
+
shell.props "Flex SDK version #{build.version} successfully installed to #{installed}"
|
63
|
+
|
64
|
+
shell.warn_restart!
|
65
|
+
|
66
|
+
end
|
67
|
+
=begin rdoc
|
68
|
+
Select an installed version of the Flex SDK to link to.
|
69
|
+
=end
|
70
|
+
def use
|
71
|
+
|
72
|
+
installations = installer.installations
|
73
|
+
|
74
|
+
shell.exit "No Flex SDK versions installed. Run 'fvm install' to install some!" if installations.empty?
|
75
|
+
|
76
|
+
installation = shell.choose installations
|
77
|
+
|
78
|
+
linker.link File.join( installation.dir, 'bin' )
|
79
|
+
|
80
|
+
shell.props "Now using Flex SDK version #{installation.version}"
|
81
|
+
|
82
|
+
shell.warn_restart!
|
83
|
+
|
84
|
+
end
|
85
|
+
=begin rdoc
|
86
|
+
List Flex SDK builds installed locally. Will also show which build is currently linked.
|
87
|
+
|
88
|
+
OPTIONS
|
89
|
+
|
90
|
+
-r, --remote List available remote builds.
|
91
|
+
|
92
|
+
=end
|
93
|
+
def list( options )
|
94
|
+
if options.remote?
|
95
|
+
begin
|
96
|
+
builds = Build.all
|
97
|
+
rescue
|
98
|
+
shell.exit 'There was a problem connecting to the FVM API. Please try again.'
|
99
|
+
end
|
100
|
+
|
101
|
+
shell.list builds
|
102
|
+
else
|
103
|
+
installations = installer.installations
|
104
|
+
|
105
|
+
shell.exit "No Flex SDK versions installed. Run 'fvm install' to install some!" if installations.empty?
|
106
|
+
|
107
|
+
shell.list installations
|
108
|
+
end
|
109
|
+
end
|
110
|
+
=begin rdoc
|
111
|
+
Removes all symlinks created by FVM.
|
112
|
+
=end
|
113
|
+
def unlink
|
114
|
+
linker.unlink!
|
115
|
+
shell.props "All Flex SDK symlinks successfully removed."
|
116
|
+
end
|
117
|
+
=begin rdoc
|
118
|
+
Prints the active Flex SDK version number
|
119
|
+
=end
|
120
|
+
def which
|
121
|
+
puts Fvm::System.active_version? ? Fvm::System.active_version.version : ''
|
122
|
+
end
|
123
|
+
=begin rdoc
|
124
|
+
Prints the active Flex SDK home directory
|
125
|
+
=end
|
126
|
+
def home
|
127
|
+
installations = installer.installations.select( &:active? )
|
128
|
+
puts installations.any? ? installations.first.dir : ''
|
129
|
+
end
|
130
|
+
=begin rdoc
|
131
|
+
Prints the location of the fvm-restart script
|
132
|
+
=end
|
133
|
+
def restart
|
134
|
+
puts restart_script_path
|
135
|
+
end
|
136
|
+
|
137
|
+
protected
|
138
|
+
|
139
|
+
def executables
|
140
|
+
%w| asdoc compc mxmlc |
|
141
|
+
end
|
142
|
+
|
143
|
+
def installer
|
144
|
+
@installer ||= Installer.new( '~/Developer/SDKs', executables )
|
145
|
+
end
|
146
|
+
|
147
|
+
def linker
|
148
|
+
@linker ||= Linker.new( '/usr/local/bin', executables )
|
149
|
+
end
|
150
|
+
|
151
|
+
def shell
|
152
|
+
@shell ||= Shell.new
|
153
|
+
end
|
154
|
+
|
155
|
+
def restart_script_path
|
156
|
+
File.expand_path( File.join( `gem which fvm`.chomp, '..', '..', 'scripts', 'fvm' ) )
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'versionomy'
|
3
|
+
|
4
|
+
module Fvm
|
5
|
+
module CLI
|
6
|
+
class Installation
|
7
|
+
include Comparable
|
8
|
+
|
9
|
+
attr_reader :dir
|
10
|
+
def initialize( dir )
|
11
|
+
@dir = Pathname.new( dir ).expand_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def version
|
15
|
+
@dir.basename.to_s.sub( /^flex_sdk_/, '' )
|
16
|
+
end
|
17
|
+
|
18
|
+
def active?
|
19
|
+
Fvm::System.active?( self )
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_menu
|
23
|
+
out = [ version ]
|
24
|
+
out.unshift '*' if active?
|
25
|
+
out.join ' '
|
26
|
+
end
|
27
|
+
|
28
|
+
def <=> ( other )
|
29
|
+
Versionomy.parse( version ) <=> Versionomy.parse( other.version )
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'geoffrey'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module Fvm
|
6
|
+
module CLI
|
7
|
+
class Installer
|
8
|
+
|
9
|
+
attr_reader :dir, :executables
|
10
|
+
def initialize( dir, executables )
|
11
|
+
@dir = Pathname.new( dir ).expand_path
|
12
|
+
@executables = executables
|
13
|
+
end
|
14
|
+
|
15
|
+
def install( zip_url, version )
|
16
|
+
# download the zip and unzip it
|
17
|
+
temp = download zip_url
|
18
|
+
# create the destination directory name for this sdk version
|
19
|
+
dest = File.join( dir, "flex_sdk_#{version}" )
|
20
|
+
# move the unzipped directory to the destination
|
21
|
+
move = FileUtils.mv temp, dest
|
22
|
+
# make all executables in bin actually executable
|
23
|
+
make_executables_executable! dest
|
24
|
+
# return the destination
|
25
|
+
dest
|
26
|
+
end
|
27
|
+
|
28
|
+
def installations
|
29
|
+
Dir[ File.join( dir, 'flex_sdk_*' ) ].map { |d| Installation.new( d ) }
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def download( zip_url )
|
35
|
+
Geoffrey.package do
|
36
|
+
url zip_url
|
37
|
+
def install
|
38
|
+
puts
|
39
|
+
File.dirname file_to_install
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def make_executables_executable!( dir )
|
45
|
+
executables_in( dir ).each { |name| `chmod 755 #{name}` }
|
46
|
+
end
|
47
|
+
|
48
|
+
def executables_in( dir )
|
49
|
+
Dir[ File.join( dir, 'bin', '*' ) ].select { |name| executables.include? File.basename( name ) }
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|