dokku-installer-cli 0.1.3 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b362f64ffe33bf2332b30bccf6dfc0566a9e2ad9
4
- data.tar.gz: 875be774fb38f75bbf46c226886f24a3c4cd3bc2
3
+ metadata.gz: 5c104c86300fc07513b25c7c5588d60001ad523b
4
+ data.tar.gz: 791d4a07292db5e75cd8476160f773fcce6ba553
5
5
  SHA512:
6
- metadata.gz: 7b0ad9a8d8cb557a58706d99530a71091b74df15e223fb6eb32757aa130c2d90ee3659327b07c1c9a8d8c480f7590ea8e8ec65aece1b5fd21e684daca5511a84
7
- data.tar.gz: 8f235856ca998bedd643d990e656624cc59b206ad378b0b4526415121225ce22011d668c19d0273c32f602b2a96d289c0273722e701f1439888a839930ea15b9
6
+ metadata.gz: b2c32c98ef467298ea3cdc4c21bce5979b6efbc0a35be902050f99ebc8aa8a20a6bedc87a417255556bd464835d5a41620842df4ad2e2f4ee1735124ae4e1c4a
7
+ data.tar.gz: 0373575a4e801a9b33c3b1d76fa7a03e42de7249caeaf0230d036b7464a5f3cc076fc8875ac9660203f0ca93f8eb34b7fd15465426788ca51a61c340b7e758d0
data/bin/dokku CHANGED
@@ -24,7 +24,7 @@ module DokkuInstaller
24
24
  end
25
25
 
26
26
  desc "restart", "Restart the application"
27
- def restart(*args)
27
+ def restart
28
28
  run_command "restart #{app_name}"
29
29
  end
30
30
 
@@ -74,23 +74,6 @@ module DokkuInstaller
74
74
  @app_name ||= git_config_match[2]
75
75
  end
76
76
 
77
- def backup_filename(number)
78
- # Make sure the number is valid or use 1
79
- number = number.to_s.gsub(/\D/, "").to_i
80
- number = 1 if number < 1
81
-
82
- # Get the file name for the numbered backup
83
- puts "Getting list of backups..."
84
- command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
85
- backups = `#{command}`
86
- index = number - 1
87
- if filename = backups.split("\n").reverse[index]
88
- filename.strip
89
- else
90
- nil
91
- end
92
- end
93
-
94
77
  def domain
95
78
  @domain ||= git_config_match[1]
96
79
  end
@@ -7,8 +7,8 @@ module DokkuInstaller
7
7
  end
8
8
 
9
9
  desc "config:get KEY", "Display an environment variable value"
10
- def config_get(*args)
11
- run_command "config:get #{app_name} #{args.first}"
10
+ def config_get(key)
11
+ run_command "config:get #{app_name} #{key}"
12
12
  end
13
13
 
14
14
  desc "config:set KEY1=VALUE1 [KEY2=VALUE2 ...]", "Set one or more environment variables"
@@ -2,7 +2,7 @@ module DokkuInstaller
2
2
  class Cli < Thor
3
3
 
4
4
  desc "domains", "Display the app's domains"
5
- def domains(*args)
5
+ def domains
6
6
  run_command "domains #{app_name}"
7
7
  end
8
8
 
@@ -1,17 +1,17 @@
1
1
  module DokkuInstaller
2
2
  class Cli < Thor
3
3
 
4
- desc "postgres:backups", "List available PostgreSQL backups"
4
+ desc "postgres:backups", "List available PostgreSQL backups as a numbered list"
5
5
  def postgres_backups
6
6
  command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
7
7
  puts "Running #{command}..."
8
8
  backups = `#{command}`
9
- backups.split("\n").reverse.each_with_index do |line, index|
9
+ backups.split("\n").select{|backup| backup != "" }.reverse.each_with_index do |line, index|
10
10
  number = "#{index + 1}"
11
11
  if number.length < 2
12
12
  number = " #{number}"
13
13
  end
14
- puts "#{number}. #{line}"
14
+ puts "[#{number}] #{line}"
15
15
  end
16
16
  end
17
17
 
@@ -34,8 +34,8 @@ module DokkuInstaller
34
34
  end
35
35
 
36
36
  desc "postgres:backups:download <number>", "Download the numbered PostgreSQL backup"
37
- def postgres_backups_download(*args)
38
- number = args.first ? args.first : 1
37
+ def postgres_backups_download(number = nil)
38
+ number ||= 1
39
39
 
40
40
  if backup = backup_filename(number)
41
41
  command = "postgres:backups:download #{app_name} #{backup} > #{backup}"
@@ -53,10 +53,25 @@ module DokkuInstaller
53
53
  exec(command)
54
54
  end
55
55
 
56
- desc "postgres:backups:restore:local <number>", "Restore the numbered PostgreSQL backup locally"
57
- def postgres_backups_restore_local(*args)
56
+ desc "postgres:backups:restore <number>", "Restore a numbered PostgreSQL backup"
57
+ def postgres_backups_restore(number = nil)
58
+ if number.nil?
59
+ puts "You must specify a numbered backup."
60
+ exit
61
+ end
62
+
63
+ if backup = backup_filename(number)
64
+ command = "postgres:backups:restore #{app_name} #{backup}"
65
+ run_command(command)
66
+ else
67
+ puts "Invalid backup number"
68
+ end
69
+ end
70
+
71
+ desc "postgres:backups:restore:local <number>", "Restore a numbered PostgreSQL backup locally"
72
+ def postgres_backups_restore_local(number = nil)
58
73
  # Download the backup file
59
- number = args.first ? args.first : 1
74
+ number ||= 1
60
75
 
61
76
  if backup = backup_filename(number)
62
77
  command = "ssh -t dokku@#{domain} postgres:backups:download #{app_name} #{backup} > #{backup}"
@@ -75,8 +90,37 @@ module DokkuInstaller
75
90
  end
76
91
  end
77
92
 
93
+ desc "postgres:export <file.sql>", "Export Postgres data to local file"
94
+ def postgres_export(file = "export.sql")
95
+ command = "postgres:dump #{app_name} > #{file}"
96
+ run_command(command)
97
+ end
98
+
99
+ desc "postgres:import <file.sql>", "Restore database data from a local file"
100
+ def postgres_import(file)
101
+ command = "postgres:restore #{app_name} < #{file}"
102
+ run_command(command)
103
+ end
104
+
78
105
  private
79
106
 
107
+ def backup_filename(number)
108
+ # Make sure the number is valid or use 1
109
+ number = number.to_s.gsub(/\D/, "").to_i
110
+ number = 1 if number < 1
111
+
112
+ # Get the file name for the numbered backup
113
+ puts "Getting list of backups..."
114
+ command = "ssh -t dokku@#{domain} postgres:backups #{app_name}"
115
+ backups = `#{command}`
116
+ index = number - 1
117
+ if filename = backups.split("\n").select{|backup| backup != "" }.reverse[index]
118
+ filename.strip
119
+ else
120
+ nil
121
+ end
122
+ end
123
+
80
124
  def psql_options
81
125
  @psql_options ||= begin
82
126
  restore_options = nil
@@ -40,8 +40,7 @@ module DokkuInstaller
40
40
  end
41
41
 
42
42
  desc "ssl:force DOMAIN", "Force SSL on the given domain."
43
- def ssl_force(*args)
44
- domain = args.first
43
+ def ssl_force(domain = nil)
45
44
  if domain.nil?
46
45
  puts "Specify a domain to force SSL."
47
46
  exit
@@ -3,7 +3,7 @@ require "net/http"
3
3
  require "thor"
4
4
 
5
5
  module DokkuInstaller
6
- VERSION = "0.1.3"
6
+ VERSION = "0.1.4"
7
7
 
8
8
  class Cli < Thor
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokku-installer-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Pattison