dvm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.idea/.name +1 -0
- data/.idea/compiler.xml +23 -0
- data/.idea/copyright/profiles_settings.xml +3 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +20 -0
- data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
- data/.idea/misc.xml +95 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +713 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/dvm +5 -0
- data/dvm.gemspec +25 -0
- data/dvm.iml +25 -0
- data/lib/dvm/cli.rb +154 -0
- data/lib/dvm/version.rb +3 -0
- data/lib/dvm.rb +5 -0
- metadata +109 -0
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Xingjian Xu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Dvm
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'dvm'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install dvm
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/dvm/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/dvm
ADDED
data/dvm.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dvm/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'dvm'
|
8
|
+
spec.version = DVM::VERSION
|
9
|
+
spec.authors = ['Xingjian Xu']
|
10
|
+
spec.email = ['dotswing@gmail.com']
|
11
|
+
spec.summary = %q{Deploy version manager}
|
12
|
+
spec.description = %q{Deploy version manager}
|
13
|
+
spec.homepage = 'https://github.com/dotswing/dvm'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'colorize', '~> 0.7'
|
25
|
+
end
|
data/dvm.iml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="CompassSettings">
|
4
|
+
<option name="compassSupportEnabled" value="true" />
|
5
|
+
</component>
|
6
|
+
<component name="FacetManager">
|
7
|
+
<facet type="gem" name="Ruby Gem">
|
8
|
+
<configuration>
|
9
|
+
<option name="GEM_APP_ROOT_PATH" value="" />
|
10
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
11
|
+
<option name="GEM_APP_LIB_PATH" value="" />
|
12
|
+
</configuration>
|
13
|
+
</facet>
|
14
|
+
</component>
|
15
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
16
|
+
<exclude-output />
|
17
|
+
<content url="file://$MODULE_DIR$" />
|
18
|
+
<orderEntry type="jdk" jdkName="ruby-2.1.2-p95" jdkType="RUBY_SDK" />
|
19
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.5, ruby-2.1.2-p95) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="colorize (v0.7.3, ruby-2.1.2-p95) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, ruby-2.1.2-p95) [gem]" level="application" />
|
23
|
+
</component>
|
24
|
+
</module>
|
25
|
+
|
data/lib/dvm/cli.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module DVM
|
4
|
+
class CLI
|
5
|
+
|
6
|
+
def initialize(root, repo)
|
7
|
+
@root = root
|
8
|
+
@repo = repo
|
9
|
+
end
|
10
|
+
|
11
|
+
def path(p)
|
12
|
+
File.join @root, p
|
13
|
+
end
|
14
|
+
|
15
|
+
def scm
|
16
|
+
path 'scm'
|
17
|
+
end
|
18
|
+
|
19
|
+
def current
|
20
|
+
path 'current'
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_path(*p)
|
24
|
+
File.join current, p
|
25
|
+
end
|
26
|
+
|
27
|
+
def releases
|
28
|
+
path 'releases'
|
29
|
+
end
|
30
|
+
|
31
|
+
def release(v)
|
32
|
+
File.join releases, v
|
33
|
+
end
|
34
|
+
|
35
|
+
def share
|
36
|
+
path 'share'
|
37
|
+
end
|
38
|
+
|
39
|
+
def share_path(*p)
|
40
|
+
File.join share, p
|
41
|
+
end
|
42
|
+
|
43
|
+
def shared_dirs
|
44
|
+
%w(public/upload log)
|
45
|
+
end
|
46
|
+
|
47
|
+
def shared_files
|
48
|
+
Dir.glob(current_path('config', '*.example')).collect do |c|
|
49
|
+
File.join 'config', File.basename(c, File.extname(c))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def version(order)
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def new_version(version)
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def drop_version(version)
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def clone
|
67
|
+
`git clone --bare #{@repo} #{scm}`
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def checkout
|
72
|
+
version = `cd #{scm};git rev-parse --short HEAD`.strip
|
73
|
+
vd = release version
|
74
|
+
FileUtils.makedirs vd
|
75
|
+
`cd #{scm};git archive master | tar -x -f - -C #{vd}`
|
76
|
+
`echo #{version} > #{vd}/REVISION`
|
77
|
+
new_version version
|
78
|
+
version
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def copy_config
|
83
|
+
Dir.glob(current_path('config', '*.example')).each do |c|
|
84
|
+
FileUtils.cp c, share_path('config', File.basename(c, '.example'))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def link_current(v)
|
90
|
+
`unlink #{current}` if File.directory? current
|
91
|
+
`ln -s #{release(v)} #{current}`
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
def link_shared
|
96
|
+
shared_dirs.each do |e|
|
97
|
+
`rm -rf #{current_path(e)};ln -s #{share_path(e)} #{File.dirname(current_path(e))}`
|
98
|
+
end
|
99
|
+
|
100
|
+
shared_files.each do |e|
|
101
|
+
`rm -f #{current_path(e)};ln -s #{share_path(e)} #{current_path(e)}`
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def init_install
|
107
|
+
clone
|
108
|
+
link_current checkout
|
109
|
+
shared_dirs.each { |e| FileUtils.makedirs share_path(e) }
|
110
|
+
shared_files.each { |e| FileUtils.makedirs File.dirname(share_path(e)) }
|
111
|
+
copy_config
|
112
|
+
link_shared
|
113
|
+
`cd #{current};RAILS_ENV=production bundle install`
|
114
|
+
`cd #{current};vam install`
|
115
|
+
`cd #{current};RAILS_ENV=production rake assets:precompile`
|
116
|
+
`cd #{current};RAILS_ENV=production rake db:setup`
|
117
|
+
|
118
|
+
puts '======= Deploy success ======'
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
def self.run(argv)
|
123
|
+
if argv.length >0
|
124
|
+
action = argv[0]
|
125
|
+
if action == 'remote'
|
126
|
+
puts '1'
|
127
|
+
|
128
|
+
elsif action == 'deploy'
|
129
|
+
else
|
130
|
+
root = Dir.getwd
|
131
|
+
repo = action
|
132
|
+
|
133
|
+
if action.start_with? 'g:'
|
134
|
+
repo = "git@github.com:#{action[2..-1]}.git"
|
135
|
+
elsif action.start_with? 'b:'
|
136
|
+
repo = "git@bitbucket.org:#{action[2..-1]}.git"
|
137
|
+
end
|
138
|
+
|
139
|
+
if argv[1]
|
140
|
+
root = File.join root, argv[1]
|
141
|
+
else
|
142
|
+
root = File.join root, File.basename(repo, File.extname(repo))
|
143
|
+
end
|
144
|
+
|
145
|
+
CLI.new(root, repo).init_install
|
146
|
+
|
147
|
+
end
|
148
|
+
else
|
149
|
+
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
data/lib/dvm/version.rb
ADDED
data/lib/dvm.rb
ADDED
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dvm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Xingjian Xu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.7'
|
55
|
+
description: Deploy version manager
|
56
|
+
email:
|
57
|
+
- dotswing@gmail.com
|
58
|
+
executables:
|
59
|
+
- dvm
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".idea/.name"
|
65
|
+
- ".idea/compiler.xml"
|
66
|
+
- ".idea/copyright/profiles_settings.xml"
|
67
|
+
- ".idea/encodings.xml"
|
68
|
+
- ".idea/inspectionProfiles/Project_Default.xml"
|
69
|
+
- ".idea/inspectionProfiles/profiles_settings.xml"
|
70
|
+
- ".idea/misc.xml"
|
71
|
+
- ".idea/modules.xml"
|
72
|
+
- ".idea/scopes/scope_settings.xml"
|
73
|
+
- ".idea/vcs.xml"
|
74
|
+
- ".idea/workspace.xml"
|
75
|
+
- Gemfile
|
76
|
+
- LICENSE.txt
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- bin/dvm
|
80
|
+
- dvm.gemspec
|
81
|
+
- dvm.iml
|
82
|
+
- lib/dvm.rb
|
83
|
+
- lib/dvm/cli.rb
|
84
|
+
- lib/dvm/version.rb
|
85
|
+
homepage: https://github.com/dotswing/dvm
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Deploy version manager
|
109
|
+
test_files: []
|