traquitana 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Gemfile.lock +8 -8
- data/README.md +39 -23
- data/bin/traq +26 -26
- data/config/custom.yml +11 -24
- data/config/default.yml +1 -0
- data/config/proc.sh +52 -0
- data/config/traq.yml +1 -0
- data/gem-public_cert.pem +24 -20
- data/lib/bar.rb +1 -1
- data/lib/cleaner.rb +2 -2
- data/lib/config.rb +8 -7
- data/lib/deployer.rb +15 -8
- data/lib/packager.rb +18 -12
- data/lib/selector.rb +1 -1
- data/lib/ssh.rb +1 -1
- data/lib/traquitana.rb +1 -1
- data/lib/traquitana/version.rb +1 -1
- data/spec/bar_spec.rb +48 -41
- data/spec/cleaner_spec.rb +17 -16
- data/spec/config/Gemfile +3 -0
- data/spec/config/Rakefile +11 -0
- data/spec/config/config/traq.yml +1 -0
- data/spec/config_spec.rb +106 -101
- data/spec/deploy_spec.rb +14 -7
- data/spec/network_spec.rb +55 -52
- data/spec/packager_spec.rb +40 -40
- data/spec/selector_spec.rb +9 -9
- data/traq/config.yml +8 -0
- data/traquitana.gemspec +11 -11
- metadata +35 -35
- metadata.gz.sig +0 -0
- data/lib/migrator.rb +0 -25
- data/spec/migrator_spec.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6fdc190124c932c15410e7994dd52801913b9846662596b886fa3b96ec886ff7
|
4
|
+
data.tar.gz: 194e6f942110bd6ea3f81109af4c30dcb8eb4c12c88604894608bee0cd5635c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ef43b8ad6fe8fd7b3327ece03c7c23679797cab4bad48ad397fee4c4ec038f591c4f39f34df6e0bf7abc44c1fa5c1c531035bab908e7d2155b67f6f21ab138
|
7
|
+
data.tar.gz: e329d4b28d85fe6b3831697dfbae6b327ca954cde52e167cb34a85847c9bae44304d3ffad808be0e771607482de160f97b1dafe4ecf523108665a5bf195e5d09
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
traquitana (0.1.
|
4
|
+
traquitana (0.1.3)
|
5
5
|
highline
|
6
6
|
net-scp
|
7
7
|
net-ssh
|
8
|
-
rubyzip (>=
|
8
|
+
rubyzip (>= 2.0.0)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
highline (
|
14
|
-
net-scp (
|
15
|
-
net-ssh (>= 2.6.5)
|
16
|
-
net-ssh (
|
17
|
-
rubyzip (
|
13
|
+
highline (2.0.3)
|
14
|
+
net-scp (2.0.0)
|
15
|
+
net-ssh (>= 2.6.5, < 6.0.0)
|
16
|
+
net-ssh (5.2.0)
|
17
|
+
rubyzip (2.0.0)
|
18
18
|
|
19
19
|
PLATFORMS
|
20
20
|
ruby
|
@@ -23,4 +23,4 @@ DEPENDENCIES
|
|
23
23
|
traquitana!
|
24
24
|
|
25
25
|
BUNDLED WITH
|
26
|
-
1.
|
26
|
+
1.17.2
|
data/README.md
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
[![Downloads](https://img.shields.io/gem/dt/traquitana.svg)](https://rubygems.org/gems/traquitana)
|
2
|
+
[![Version](https://img.shields.io/gem/v/traquitana.svg)](https://rubygems.org/gems/traquitana)
|
3
|
+
[![License](https://img.shields.io/badge/license-GPLV2-brightgreen.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
|
4
4
|
|
5
5
|
# Traquitana
|
6
6
|
|
7
7
|
This project is a collection of scripts I used before met Capistrano and the
|
8
|
-
other tools to do that.
|
9
|
-
|
10
|
-
|
11
|
-
default libs on Ruby like net/ssh and net/scp, and rubyzip to zip all the files
|
12
|
-
and try to make
|
13
|
-
things faster.
|
8
|
+
other tools to do that. It send some files from your local Rails app directory
|
9
|
+
to a production remote server, using some default libs on Ruby like net/ssh and
|
10
|
+
net/scp, and rubyzip to zip all the files and try to make things faster.
|
14
11
|
|
15
12
|
It was made to run on GNU/Linux, but should work on similar systems.
|
16
13
|
|
@@ -18,15 +15,21 @@ It was made to run on GNU/Linux, but should work on similar systems.
|
|
18
15
|
|
19
16
|
Add this line to your application's Gemfile:
|
20
17
|
|
21
|
-
|
18
|
+
```
|
19
|
+
gem 'traquitana'
|
20
|
+
```
|
22
21
|
|
23
22
|
And then execute:
|
24
23
|
|
25
|
-
|
24
|
+
```
|
25
|
+
$ bundle
|
26
|
+
```
|
26
27
|
|
27
28
|
Or install it yourself as:
|
28
29
|
|
29
|
-
|
30
|
+
```
|
31
|
+
$ gem install traquitana
|
32
|
+
```
|
30
33
|
|
31
34
|
## Usage
|
32
35
|
|
@@ -44,8 +47,10 @@ Or install it yourself as:
|
|
44
47
|
|
45
48
|
On the list can have two elements by row, like:
|
46
49
|
|
47
|
-
|
48
|
-
|
50
|
+
```
|
51
|
+
- - public/images/**/*
|
52
|
+
- public/images/uploads/**/*
|
53
|
+
```
|
49
54
|
|
50
55
|
On this example, all below public/images will be send BUT ignoring what is on
|
51
56
|
public/images/uploads. This is a way to make sure you'll not overwrite some
|
@@ -60,7 +65,7 @@ Or install it yourself as:
|
|
60
65
|
specify any tags. Take a look on the custom.yml file provided and use
|
61
66
|
-t or --target <target>.
|
62
67
|
|
63
|
-
- Run traq (just type traq).
|
68
|
+
- Run traq (just type `traq`).
|
64
69
|
- It will search for changed files
|
65
70
|
- Will create a list with the file names found
|
66
71
|
- Will zíp the files.
|
@@ -85,16 +90,27 @@ break something.
|
|
85
90
|
|
86
91
|
There are some command line options:
|
87
92
|
|
88
|
-
*
|
89
|
-
*
|
90
|
-
*
|
91
|
-
*
|
92
|
-
*
|
93
|
+
* `-f` or `--file <file>` - specify the config file path
|
94
|
+
* `-v` or `--version` - show current version
|
95
|
+
* `-c` or `--cleanup` - clean old versions backups stored on the remote host
|
96
|
+
* `-v` or `--verbose` - be verbose while running
|
97
|
+
* `-t` or `--target <target>` - specify which target will be loaded on the config file
|
98
|
+
|
99
|
+
## Drawbacks
|
100
|
+
|
101
|
+
As we're sending the local files to the server, if you deleted some file from
|
102
|
+
your local repository, **it will not be deleted from your server**, so, you'll
|
103
|
+
need to take care of this by yourself. I was inclined to check for the deleted
|
104
|
+
files on the file list sent to the server, comparing with the local files there,
|
105
|
+
and then delete the files, but I think file deletion could be a little more
|
106
|
+
invasive than I'd would like about how this gem works. Maybe on future I can
|
107
|
+
change my mind.
|
93
108
|
|
94
109
|
## Contributing
|
95
110
|
|
96
111
|
1. Fork it
|
97
112
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
98
|
-
3.
|
99
|
-
4.
|
100
|
-
5.
|
113
|
+
3. Test it! Run `$ rake test`. You'll need `minitest` and `minitest-focus`.
|
114
|
+
4. Commit your changes (`git commit -am 'Added some feature'`)
|
115
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
116
|
+
6. Create new Pull Request
|
data/bin/traq
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require File.dirname(File.expand_path(__FILE__))+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'yaml'
|
5
|
+
require 'zip'
|
6
|
+
require 'net/scp'
|
7
|
+
require 'net/ssh'
|
8
|
+
require 'fileutils'
|
9
|
+
require 'optparse'
|
10
|
+
require File.dirname(File.expand_path(__FILE__)) + '/../lib/traquitana.rb'
|
11
11
|
|
12
|
-
@options = {:
|
12
|
+
@options = { verbose: false }
|
13
13
|
|
14
14
|
opts = OptionParser.new
|
15
|
-
opts.banner =
|
15
|
+
opts.banner = 'Usage: traq [options] <setup>'
|
16
16
|
|
17
|
-
opts.on(
|
18
|
-
|
19
|
-
|
17
|
+
opts.on('-v', '--version', 'Show version') do
|
18
|
+
puts Traquitana::VERSION
|
19
|
+
exit 0
|
20
20
|
end
|
21
21
|
|
22
|
-
opts.on(
|
23
|
-
|
24
|
-
|
22
|
+
opts.on('-c', '--cleanup', 'Clean up old files') do
|
23
|
+
Traquitana::Cleaner.new.run
|
24
|
+
exit 0
|
25
25
|
end
|
26
26
|
|
27
|
-
opts.on(
|
28
|
-
|
27
|
+
opts.on('-V', '--verbose', 'Verbose mode') do
|
28
|
+
@options[:verbose] = true
|
29
29
|
end
|
30
30
|
|
31
|
-
opts.on(
|
32
|
-
|
31
|
+
opts.on('-f', '--file file', 'Config file') do |file|
|
32
|
+
@options[:filename] = file
|
33
33
|
end
|
34
34
|
|
35
|
-
opts.on(
|
36
|
-
|
35
|
+
opts.on('-t', '--target target', 'Target') do |target|
|
36
|
+
@options[:target] = target
|
37
37
|
end
|
38
38
|
|
39
39
|
opts.parse!
|
40
40
|
|
41
41
|
if ARGV[0] =~ /setup/
|
42
|
-
|
43
|
-
else
|
44
|
-
|
45
|
-
end
|
42
|
+
Traquitana::Config.instance.setup
|
43
|
+
else
|
44
|
+
Traquitana::Deployer.new(@options).run
|
45
|
+
end
|
data/config/custom.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
default:
|
1
|
+
# This is the default configuration, created by the traq setup command
|
2
|
+
default: &default
|
3
3
|
directory: /tmp/traq_test
|
4
4
|
user: taq
|
5
5
|
list:
|
@@ -12,6 +12,7 @@ default:
|
|
12
12
|
- - config/environments/production.rb
|
13
13
|
- - config/locales/**/*
|
14
14
|
- - config/routes.rb
|
15
|
+
- - config/storage.yml
|
15
16
|
- - app/**/*
|
16
17
|
- - db/migrate/**/*
|
17
18
|
- - public/javascripts/**/*
|
@@ -24,27 +25,13 @@ default:
|
|
24
25
|
host: localhost
|
25
26
|
server: passenger
|
26
27
|
shell: bash -l -c
|
28
|
+
|
29
|
+
# This is a custom configuration to be used wit -t or --target option.
|
30
|
+
# It inherits all the default configs, just changing the directory.
|
31
|
+
# It can be used like:
|
32
|
+
# $ traq -t custom
|
33
|
+
# or
|
34
|
+
# $ traq --target custom
|
27
35
|
custom:
|
36
|
+
<<: *default
|
28
37
|
directory: /tmp/traq_test_custom
|
29
|
-
user: taq
|
30
|
-
list:
|
31
|
-
- Rakefile
|
32
|
-
- config.ru
|
33
|
-
- Gemfile
|
34
|
-
- - config/application.rb
|
35
|
-
- - config/environment.rb
|
36
|
-
- - config/initializers/**/*
|
37
|
-
- - config/environments/production.rb
|
38
|
-
- - config/locales/**/*
|
39
|
-
- - config/routes.rb
|
40
|
-
- - app/**/*
|
41
|
-
- - db/migrate/**/*
|
42
|
-
- - public/javascripts/**/*
|
43
|
-
- - public/stylesheets/**/*
|
44
|
-
- - lib/**/*
|
45
|
-
- - bin/**/*
|
46
|
-
- - public/images/**/*
|
47
|
-
- public/images/uploads/**/*
|
48
|
-
password: fill your password here
|
49
|
-
host: localhost
|
50
|
-
shell: bash -l -c
|
data/config/default.yml
CHANGED
data/config/proc.sh
CHANGED
@@ -134,6 +134,15 @@ function migrate() {
|
|
134
134
|
fi
|
135
135
|
}
|
136
136
|
|
137
|
+
#
|
138
|
+
# Check if the channels dir exists
|
139
|
+
#
|
140
|
+
function channels() {
|
141
|
+
if [ ! -d app/assets/javascripts/channels ]; then
|
142
|
+
mkdir -p app/assets/javascripts/channels
|
143
|
+
fi
|
144
|
+
}
|
145
|
+
|
137
146
|
#
|
138
147
|
# Precompile assets if needed
|
139
148
|
#
|
@@ -193,6 +202,47 @@ function sanity_check() {
|
|
193
202
|
fi
|
194
203
|
}
|
195
204
|
|
205
|
+
function activate_gems() {
|
206
|
+
msg "Activating gems on $(pwd) ..."
|
207
|
+
|
208
|
+
local GEMFILE_VERSION=""
|
209
|
+
|
210
|
+
if [ -z "$GEMFILE_VERSION" ] && [ -f Gemfile ]; then
|
211
|
+
msg "Trying find Ruby version on Gemfile ..."
|
212
|
+
GEMFILE_VERSION=$(grep -e "^ruby" Gemfile | cut -f2 -d' ' | tr -d "'")
|
213
|
+
fi
|
214
|
+
|
215
|
+
if [ -z "$GEMFILE_VERSION" ] && [ -f .ruby-version ]; then
|
216
|
+
msg "Trying find Ruby version on .ruby-version file ..."
|
217
|
+
GEMFILE_VERSION=$(cat .ruby-version)
|
218
|
+
fi
|
219
|
+
|
220
|
+
if [ -z "$GEMFILE_VERSION" ]; then
|
221
|
+
msg "\e[31mCould not determine Ruby version.\e[0m"
|
222
|
+
return
|
223
|
+
fi
|
224
|
+
|
225
|
+
local PROVIDER=$(gem_provider)
|
226
|
+
local RVM_LOCAL=$HOME/.rvm/scripts/rvm
|
227
|
+
local RVM_SYSTEM=/usr/local/rvm/scripts/rvm
|
228
|
+
local RVM_SOURCE=""
|
229
|
+
|
230
|
+
if [ "$PROVIDER" == "rvm" ]; then
|
231
|
+
msg "Activating $GEMFILE_VERSION on RVM ..."
|
232
|
+
|
233
|
+
if [ -f "$RVM_LOCAL" ]; then
|
234
|
+
msg "Activating local RVM ..."
|
235
|
+
RVM_SOURCE="$RVM_LOCAL"
|
236
|
+
else
|
237
|
+
msg "Activating system RVM ..."
|
238
|
+
RVM_SOURCE="$RVM_SYSTEM"
|
239
|
+
fi
|
240
|
+
|
241
|
+
source "$RVM_SOURCE"
|
242
|
+
rvm $GEMFILE_VERSION
|
243
|
+
fi
|
244
|
+
}
|
245
|
+
|
196
246
|
# force the production enviroment
|
197
247
|
export RAILS_ENV=production
|
198
248
|
|
@@ -249,8 +299,10 @@ safe_copy "${config_id}"
|
|
249
299
|
|
250
300
|
# here is where things happens on the server
|
251
301
|
install_new_files "${config_id}"
|
302
|
+
activate_gems
|
252
303
|
fix_gems
|
253
304
|
createdb
|
305
|
+
channels
|
254
306
|
migrate
|
255
307
|
assets
|
256
308
|
permissions
|
data/config/traq.yml
CHANGED
data/gem-public_cert.pem
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
2
|
+
MIIEVjCCAr6gAwIBAgIBATANBgkqhkiG9w0BAQsFADAqMSgwJgYDVQQDDB9ldXN0
|
3
|
+
YXF1aW9yYW5nZWwvREM9Z21haWwvREM9Y29tMB4XDTIxMDEwNTE1MTMzNFoXDTIy
|
4
|
+
MDEwNTE1MTMzNFowKjEoMCYGA1UEAwwfZXVzdGFxdWlvcmFuZ2VsL0RDPWdtYWls
|
5
|
+
L0RDPWNvbTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAKBL7R3l8n3I
|
6
|
+
RXuw3CvEa/fDbd1//jFhfXwow41Mo4fQMuccm9fYs/kTZ4+06zv0ALlQtu5tsD6A
|
7
|
+
An9uR3d91VKN+M5mSK3lQF4FgsWqyU3kJ7qqWhWjylTyYBqku5RJINdFU6lkk/9Y
|
8
|
+
jxaCkOETfmzKUbfLV0+qrOvDsOzyoOv7HGJORjIy4NWfxu8mwDbhogyq4h81MCLC
|
9
|
+
EIvp5LdfpbgahPsPdqvQO868oUmxN+U+ZTXfRwrcyrC8bjaURS0jPW8PWQCjsfO9
|
10
|
+
L/viUwHlHUDVY/iT2kvSuZrCdhRVPt9QikdLGbze+YkdNkOXfR6EQjxRmg4OQjs9
|
11
|
+
DvMbS6D2Zd6VK6PXFLqDA6BrLFqK6Zvr87xVmxDIZ/WN63PjgNCMEFb5ZKzy2hix
|
12
|
+
N5f2pQDcdoR1m5psHoKe4nCPc/vFnYsTbfcbcF5+vV7+EgmTmSWyhei09eytrz/5
|
13
|
+
FLn0Pizaffk1DFHg68fl/b6QrsfmRRJCr4hrwGlUl+6eDUdxUktW2wIDAQABo4GG
|
14
|
+
MIGDMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQeQRJ+Zb0whKTS
|
15
|
+
5l+2kfAZROALwzAkBgNVHREEHTAbgRlldXN0YXF1aW9yYW5nZWxAZ21haWwuY29t
|
16
|
+
MCQGA1UdEgQdMBuBGWV1c3RhcXVpb3JhbmdlbEBnbWFpbC5jb20wDQYJKoZIhvcN
|
17
|
+
AQELBQADggGBAF60gRzDOWc7B6g4jQzR2Bi90pVSfUXRCkODqCaosSET18pXu63G
|
18
|
+
mXh4ACRSKMM3X6Cj2uDQEhrvWnxt0R5P1TD6G3uOXGzMAmihPVyCJyUCFwuxAt9V
|
19
|
+
GLCyn2Ti9MIT0FyujhEXSQdJjAyuDGtEkO2LIKBJ+CIbG68FBqc1k+UwPQiNJCgE
|
20
|
+
s3Fsha0Wv75uupzqu57FHXHSjdnBNeQHfdC+Ma8VIlWdKxfcxZKOEL589tnJTJHF
|
21
|
+
IRNTTxZFwTTvZy2aSvBb73m+clb36mlGO3emb/S3WMu2oOlmorHD4CAbyZjPTwIs
|
22
|
+
zYVH+Nlf2O8Li2j3QNGL0r2MNCJWeuhB23IOoL60AaxvpyHAbWnfOpqidQU1Zwpg
|
23
|
+
cXxQcroczXGs/RH1diJes5AihU97po1EVyVpxjkyiVZxd0fl+r3OR7iYSSNMrdpH
|
24
|
+
Ey5t62RSM7fM69lDtUa1Jmv/CCRAeeY4TQUFwDrnNYhxQshCWcrFWQMb4ExJtwbC
|
25
|
+
iQ4FrdvzJJS+rA==
|
22
26
|
-----END CERTIFICATE-----
|
data/lib/bar.rb
CHANGED
data/lib/cleaner.rb
CHANGED
@@ -11,9 +11,9 @@ module Traquitana
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run
|
14
|
-
STDOUT.print
|
14
|
+
STDOUT.print 'Cleaning old files ... '
|
15
15
|
@network.execute(["find #{@config.directory}/traq -type f -iname '*.zip' -o -iname '*.list' | sort | head -n-2 | xargs rm $1"])
|
16
|
-
STDOUT.puts
|
16
|
+
STDOUT.puts 'done.'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/config.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'singleton'
|
2
2
|
|
3
3
|
module Traquitana
|
4
4
|
class Config
|
@@ -7,7 +7,7 @@ module Traquitana
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@configs = {}
|
10
|
-
@filename =
|
10
|
+
@filename = 'config/traq.yml'
|
11
11
|
@target = nil
|
12
12
|
load
|
13
13
|
end
|
@@ -23,22 +23,22 @@ module Traquitana
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def method_missing(meth)
|
26
|
-
@configs[meth.to_s] ||
|
26
|
+
@configs[meth.to_s] || ''
|
27
27
|
end
|
28
28
|
|
29
29
|
def setup
|
30
|
-
STDOUT.puts
|
30
|
+
STDOUT.puts 'Running setup'
|
31
31
|
|
32
32
|
if File.exists?(self.filename)
|
33
33
|
STDERR.puts "The configuration file #{self.filename} already exists."
|
34
34
|
return false
|
35
35
|
end
|
36
36
|
|
37
|
-
dir = File.dirname(
|
37
|
+
dir = File.dirname(filename)
|
38
38
|
Dir.mkdir(dir) if !File.exist?(dir)
|
39
39
|
|
40
|
-
STDOUT.puts "Writing #{
|
41
|
-
File.open(
|
40
|
+
STDOUT.puts "Writing #{filename}"
|
41
|
+
File.open(filename, "w") do |file|
|
42
42
|
file << File.read(self.default)
|
43
43
|
end
|
44
44
|
|
@@ -48,6 +48,7 @@ module Traquitana
|
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
51
|
+
|
51
52
|
def check_configs(file)
|
52
53
|
@configs = YAML.load(File.read(file || self.filename)) rescue nil
|
53
54
|
STDERR.puts "Configs not found (tried '#{file}' and '#{self.filename}')" if !@configs
|