shopapp 0.2.29 → 0.2.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/shop +28 -0
- data/lib/shopapp/tasks/shopapp.rake +77 -5
- data/shopapp.gemspec +5 -4
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 611ca4b67a9782f38b15b1d2de1bd717d55b4668982c6f7aebea59a59bddb84d
|
4
|
+
data.tar.gz: 03a29f9ed777bab16c79a37896b2299332ed75a15839e730da344970a55845f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dd37f4465ff7f9b82920fbbf8cd20100e2a5ca6ea1fc85af45e44b68bb3dbabf26a5219a00e0f547db0d41ceca1f442bb0a274d34b44486e0aa2f5dc8cb795e
|
7
|
+
data.tar.gz: 7ad0bf3eb0c2c87e1c76a3abc57b30bc40b808be0b3ab608827489ab1fd0041585a607e2fb8734302c5debc1d083718d1c4835ab344248b62f97158d4b242da5
|
data/bin/shop
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
unless File.exist?(Dir.pwd + '/Gemfile') && /gem.*shopapp/.match?(File.read(Dir.pwd + '/Gemfile'))
|
3
|
+
puts "You can only call shop macro from a shopapp root folder"
|
4
|
+
return
|
5
|
+
end
|
6
|
+
|
7
|
+
deployment_targets = `rake shopapp:targets`.strip
|
8
|
+
commands = %w(console rake tail bash run pulldb fetchdb restoredb help)
|
9
|
+
if ARGV.count == 2 && ARGV[0] == 'help' && (commands.include? ARGV[1])
|
10
|
+
cmd = "rake shopapp:help cmd=#{ARGV[1]}"
|
11
|
+
elsif ARGV.count <= 1 && ARGV[0] == 'restore'
|
12
|
+
cmd = "rake shopapp:restore #{ARGV[1..-1].join ' '}"
|
13
|
+
elsif ARGV.count < 2 ||
|
14
|
+
!(deployment_targets.split(', ').include? ARGV[0]) ||
|
15
|
+
!(commands.include? ARGV[1])
|
16
|
+
puts "Usage: shop [TARGET] COMMAND [parameters]"
|
17
|
+
puts "Targets: #{deployment_targets}."
|
18
|
+
puts "Commands: #{commands.join ', '}."
|
19
|
+
puts "No target for restore and help, mandatory for all others."
|
20
|
+
puts "For more info on specific command: shop help COMMAND."
|
21
|
+
return
|
22
|
+
else
|
23
|
+
parameters = ARGV[2..-1].join ' '
|
24
|
+
parameters = %( "#{parameters}") if parameters.to_s.length > 0
|
25
|
+
cmd = "target=#{ARGV[0]} rake shopapp:#{ARGV[1]}#{parameters}"
|
26
|
+
end
|
27
|
+
|
28
|
+
exec cmd
|
@@ -6,13 +6,14 @@ namespace :shopapp do
|
|
6
6
|
)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def deployment_targets
|
10
|
+
Rails.configuration.settings['deployment'].to_h.keys - ['default']
|
11
|
+
end
|
12
|
+
|
13
|
+
def fetchdb(timestamp)
|
12
14
|
user = deployment_settings['dbuser'] || deployment_settings['user']
|
13
15
|
server = deployment_settings['dbserver'] || deployment_settings['server']
|
14
16
|
db_name = deployment_settings['dbname'] || Rails.configuration.database_configuration['production']['database']
|
15
|
-
dev_db_name = Rails.configuration.database_configuration['development']['database']
|
16
17
|
dump_filename = "#{db_name}_#{timestamp}.dump"
|
17
18
|
|
18
19
|
puts "Creating production db backup from #{db_name} to #{dump_filename}..."
|
@@ -23,11 +24,35 @@ namespace :shopapp do
|
|
23
24
|
mkdir_p Rails.root.join('tmp')
|
24
25
|
puts "Copying to local..."
|
25
26
|
system "scp #{user}@#{server}:#{dump_filename} #{Rails.root.join('tmp')}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def restoredb(timestamp)
|
30
|
+
db_name = deployment_settings['dbname'] || Rails.configuration.database_configuration['production']['database']
|
31
|
+
dump_filename = "#{db_name}_#{timestamp}.dump"
|
32
|
+
dev_db_name = Rails.configuration.database_configuration['development']['database']
|
26
33
|
puts "Restoring to local development database..."
|
27
34
|
system "pg_restore --no-owner --verbose -c --no-acl -n public --dbname #{dev_db_name} #{Rails.root.join('tmp', dump_filename)}"
|
28
35
|
puts 'Restored production database to local development.'
|
29
36
|
end
|
30
37
|
|
38
|
+
desc 'list existing targets'
|
39
|
+
task targets: :environment do
|
40
|
+
puts deployment_targets.join(', ')
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'pull prod db to local dev'
|
44
|
+
task pulldb: :environment do
|
45
|
+
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
|
46
|
+
fetchdb(timestamp)
|
47
|
+
restoredb(timestamp)
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'fetch prod db to local tmp folder'
|
51
|
+
task fetchdb: :environment do
|
52
|
+
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
|
53
|
+
fetchdb(timestamp)
|
54
|
+
end
|
55
|
+
|
31
56
|
desc 'execute command on production server'
|
32
57
|
task run: :environment do
|
33
58
|
ARGV.each { |a| task a.to_sym do ; end }
|
@@ -39,7 +64,54 @@ namespace :shopapp do
|
|
39
64
|
Rails.application.class.parent_name).to_s.downcase.parameterize.underscore}/current"
|
40
65
|
|
41
66
|
cmd = %(ssh -t #{user}@#{server} 'cd #{deployment_folder_name}; bash --login -c "#{ARGV[1..-1].join(' ')}"')
|
42
|
-
#puts cmd
|
43
67
|
exec cmd
|
44
68
|
end
|
69
|
+
|
70
|
+
desc "tails and follows target's log/production.log"
|
71
|
+
task :tail do
|
72
|
+
exec %(target=#{ENV['target']} rake shopapp:run "tail -f log/production.log")
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "opens bash prompt on target"
|
76
|
+
task :bash do
|
77
|
+
exec %(target=#{ENV['target']} rake shopapp:run "/bin/bash")
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "opens rails console on target"
|
81
|
+
task :console do
|
82
|
+
exec %(target=#{ENV['target']} rake shopapp:run "rails c")
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "executes rake task(s) on target"
|
86
|
+
task rake: :environment do
|
87
|
+
exec %(target=#{ENV['target']} rake shopapp:run "rake #{ARGV[1]}")
|
88
|
+
end
|
89
|
+
|
90
|
+
desc 'help about these rakes tasks'
|
91
|
+
task :help do
|
92
|
+
puts case ENV['cmd']
|
93
|
+
when 'console'
|
94
|
+
'Opens rails console on the target. No parameters allowed.'
|
95
|
+
when 'tail'
|
96
|
+
'Tails main production log on target, until CTRL+C. No parameters allowed.'
|
97
|
+
when 'bash'
|
98
|
+
'Opens the bash terminal on target with application user in the deployment folder. No parameters allowed.'
|
99
|
+
when 'run'
|
100
|
+
'Executes on target in deployment directory under deployment user arbitrary command specified by parameters.'
|
101
|
+
when 'rake'
|
102
|
+
"Executes a rake task on target in deployment directory under deployment user.\n" +
|
103
|
+
"First parameter is task name (possiblly with namespace(s)), other parameters are passed to rake task."
|
104
|
+
when 'pulldb'
|
105
|
+
'Dumps target production database and restores it to local development db. No parameters allowed.'
|
106
|
+
when 'fetchdb'
|
107
|
+
'Dumps target production database and copies it to local tmp folder.'
|
108
|
+
when 'restoredb'
|
109
|
+
"Restores database dump fetched with fetchdb from tmp folder.\n" +
|
110
|
+
"Parameter is the database name without dump suffix). Default is the latest dump."
|
111
|
+
when 'help'
|
112
|
+
"Com'on, for real!"
|
113
|
+
else
|
114
|
+
"There is no command #{ENV['cmd']}"
|
115
|
+
end
|
116
|
+
end
|
45
117
|
end
|
data/shopapp.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'shopapp'
|
3
|
-
s.version = '0.2.
|
4
|
-
s.date = '2019-03-
|
3
|
+
s.version = '0.2.30'
|
4
|
+
s.date = '2019-03-21'
|
5
5
|
s.summary = 'Do a shoplift.'
|
6
6
|
s.description = 'Ha! Art thou Bedlam? Dost thou thirst base Trojan, to have me fold up Parca\'s fatal web? Hence!\
|
7
7
|
I am qualmish at the smell of leek.'
|
@@ -11,7 +11,8 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.files = `git ls-files`.split("\n") - %w(.rvmrc .gitignore)
|
12
12
|
|
13
13
|
s.bindir = 'bin'
|
14
|
-
s.executables
|
14
|
+
s.executables << 'shopitapp'
|
15
|
+
s.executables << 'shop'
|
15
16
|
s.homepage = 'http://rubygems.org/gems/shopapp'
|
16
17
|
s.license = 'MIT'
|
17
18
|
s.require_paths = ["lib"]
|
@@ -28,7 +29,7 @@ Gem::Specification.new do |s|
|
|
28
29
|
s.add_dependency 'oauth2', '~> 1.4'
|
29
30
|
s.add_dependency 'rest-client', '~> 2.0'
|
30
31
|
s.add_dependency 'gravatar_image_tag', '~> 1.2'
|
31
|
-
s.add_dependency 'redcarpet', '
|
32
|
+
s.add_dependency 'redcarpet', '>= 2.3'
|
32
33
|
|
33
34
|
s.add_dependency 'capistrano', '~> 3.11'
|
34
35
|
s.add_dependency 'capistrano-rvm', '~> 0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zeljko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -160,14 +160,14 @@ dependencies:
|
|
160
160
|
name: redcarpet
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- - "
|
163
|
+
- - ">="
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '2.3'
|
166
166
|
type: :runtime
|
167
167
|
prerelease: false
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
|
-
- - "
|
170
|
+
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '2.3'
|
173
173
|
- !ruby/object:Gem::Dependency
|
@@ -232,6 +232,7 @@ description: |-
|
|
232
232
|
email: zeljko@z-ware.fi
|
233
233
|
executables:
|
234
234
|
- shopitapp
|
235
|
+
- shop
|
235
236
|
extensions: []
|
236
237
|
extra_rdoc_files: []
|
237
238
|
files:
|
@@ -272,6 +273,7 @@ files:
|
|
272
273
|
- app/views/shopapp/_shopapp.html.haml
|
273
274
|
- app/views/shopapp/_shopapp2.html.haml
|
274
275
|
- app/views/shopapp/_shopapp_alerts.html.haml
|
276
|
+
- bin/shop
|
275
277
|
- bin/shopitapp
|
276
278
|
- config/initializers/active_settings.rb
|
277
279
|
- config/initializers/audited.rb
|