yugen 0.4.0
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 +7 -0
- data/bin/yugen +5 -0
- data/lib/dokku_cli.rb +120 -0
- data/lib/dokku_cli/certs.rb +5 -0
- data/lib/dokku_cli/config.rb +68 -0
- data/lib/dokku_cli/domains.rb +10 -0
- data/lib/dokku_cli/events.rb +28 -0
- data/lib/dokku_cli/keys.rb +14 -0
- data/lib/dokku_cli/nginx.rb +23 -0
- data/lib/dokku_cli/ps.rb +44 -0
- data/lib/dokku_cli/version.rb +3 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a4937d14013c57fa3ba5b74ee0eece78f0c3d7b1
|
4
|
+
data.tar.gz: 3552c530a483b0594c9c7a2345e15263db911801
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d6bb27501c207051f58598e454b6c9c1eee23086c05bf0899a881fc8dafa64f81e7df604350f7fa0a72adc0d1817003a5b16a75b7077f1644bd240eb2039bec
|
7
|
+
data.tar.gz: ebe4a0aa5097da521b25948fbe372951e7e6acf2d653c02b041d4f6f21d9d49caf1eb778547b711a2a6804f649a94949561a42c58e600605607c0bd32480e1f6
|
data/bin/yugen
ADDED
data/lib/dokku_cli.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
require "dokku_cli/version"
|
4
|
+
require "dokku_cli/config"
|
5
|
+
require "dokku_cli/domains"
|
6
|
+
require "dokku_cli/nginx"
|
7
|
+
require "dokku_cli/ps"
|
8
|
+
require "dokku_cli/events"
|
9
|
+
require "dokku_cli/certs"
|
10
|
+
require "dokku_cli/keys"
|
11
|
+
|
12
|
+
module DokkuCli
|
13
|
+
class Cli < Thor
|
14
|
+
class_option :remote
|
15
|
+
|
16
|
+
desc "logs [-n num] [-p ps] [-q quiet [-t tail]", "Display logs for the app"
|
17
|
+
method_option :n, type: :numeric, aliases: %w{-num --num},
|
18
|
+
desc: "Limit to <n> number of lines"
|
19
|
+
method_option :p, type: :string, aliases: %w{-ps --ps},
|
20
|
+
desc: "Filter by <p> process"
|
21
|
+
method_option :q, type: :boolean, aliases: %w{-quiet --quiet},
|
22
|
+
desc: "Remove docker prefixes from output"
|
23
|
+
method_option :t, type: :boolean, aliases: %w{-tail --tail},
|
24
|
+
desc: "Follow output"
|
25
|
+
def logs
|
26
|
+
args = options.map{|k, v| "-#{k} #{v}"}.join(" ")
|
27
|
+
if args.empty?
|
28
|
+
run_command "logs #{app_name}"
|
29
|
+
else
|
30
|
+
# remove unnecessary mapped remote option
|
31
|
+
args = args.gsub(/-remote [\S]*/, '')
|
32
|
+
command = "ssh -t -p #{port} dokku@#{domain} logs #{app_name} #{args}"
|
33
|
+
puts "Running #{command}..."
|
34
|
+
exec(command)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "open", "Open the app in your default browser"
|
39
|
+
def open
|
40
|
+
url = %x[yugen urls --remote #{app_name}].split("\r").first
|
41
|
+
exec("open #{url}")
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "run <cmd>", "Run a one-off command in the environment of the app"
|
45
|
+
def walk(*args)
|
46
|
+
command = "#{args.join(' ')}"
|
47
|
+
case command.gsub(" ", "")
|
48
|
+
when "rakedb:drop"
|
49
|
+
puts "You cannot use `rake db:drop`. Use Dokku directly to delete the database."
|
50
|
+
when "rakedb:create"
|
51
|
+
puts "You cannot use `rake db:create`. Use Dokku directly to create the database."
|
52
|
+
else
|
53
|
+
run_command "run #{app_name} #{command}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
map "run" => "walk"
|
57
|
+
|
58
|
+
desc "url", "Show the first URL for the app"
|
59
|
+
def url
|
60
|
+
run_command "url #{app_name}"
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "urls", "Show all URLs for the app"
|
64
|
+
def urls
|
65
|
+
run_command "urls #{app_name}"
|
66
|
+
end
|
67
|
+
|
68
|
+
def help(method = nil)
|
69
|
+
method = "walk" if method == "run"
|
70
|
+
super
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def app_name
|
76
|
+
@app_name ||= git_config["app_name"]
|
77
|
+
end
|
78
|
+
|
79
|
+
def domain
|
80
|
+
@domain ||= git_config["domain"]
|
81
|
+
end
|
82
|
+
|
83
|
+
def port
|
84
|
+
@port ||= git_config["port"]
|
85
|
+
end
|
86
|
+
|
87
|
+
def git_config
|
88
|
+
remote = "yugen"
|
89
|
+
remote = options[:remote] if options[:remote]
|
90
|
+
|
91
|
+
@git_config ||= begin
|
92
|
+
config_path = File.join(Dir.pwd, ".git", "config")
|
93
|
+
exit unless File.exist?(config_path)
|
94
|
+
config_file = File.read(config_path)
|
95
|
+
|
96
|
+
# Default dokku config: dokku@host.com:app
|
97
|
+
default_style_regex = /\[remote "#{remote}"\]\s+url \= dokku@(?<domain>.*):(?<app_name>.*)$/
|
98
|
+
match ||= config_file.match(default_style_regex)
|
99
|
+
|
100
|
+
# SSH dokku config: ssh://dokku@host.com:1337/app
|
101
|
+
ssh_style_regex = /\[remote "#{remote}"\]\s+url \= ssh:\/\/dokku@(?<domain>.*):(?<port>.*)\/(?<app_name>.*)$/
|
102
|
+
match ||= config_file.match(ssh_style_regex)
|
103
|
+
|
104
|
+
exit unless match
|
105
|
+
match = Hash[match.names.zip(match.captures)]
|
106
|
+
match["port"] ||= 22
|
107
|
+
|
108
|
+
match
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def run_command(command)
|
113
|
+
command = command.gsub(/ --remote=[\S]*/, '')
|
114
|
+
dokku_command = "ssh -t -p #{port} dokku@#{domain} #{command}"
|
115
|
+
|
116
|
+
puts "Connecting to #{app_name}..."
|
117
|
+
exec(dokku_command)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module DokkuCli
|
2
|
+
class Cli < Thor
|
3
|
+
|
4
|
+
map "config:get" => "config_get",
|
5
|
+
"config:set" => "config_set",
|
6
|
+
"config:unset" => "config_unset",
|
7
|
+
"config:set:file" => "config_set_file"
|
8
|
+
|
9
|
+
desc "config", "Display the app's environment variables"
|
10
|
+
def config
|
11
|
+
run_command "config #{app_name}"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "config:get KEY", "Display an environment variable value"
|
15
|
+
def config_get(key)
|
16
|
+
run_command "config:get #{app_name} #{key}"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "config:set KEY1=VALUE1 [KEY2=VALUE2 ...]", "Set one or more environment variables"
|
20
|
+
def config_set(*args)
|
21
|
+
# FIXME: Requires root to send config values with spaces
|
22
|
+
user = "dokku"
|
23
|
+
|
24
|
+
args = args.map{|arg|
|
25
|
+
key_value = arg.split("=")
|
26
|
+
if key_value.length == 2
|
27
|
+
if key_value[1].index(" ")
|
28
|
+
user = "root"
|
29
|
+
return_value = "#{key_value[0]}="
|
30
|
+
return_value += '\"'
|
31
|
+
return_value += key_value[1].gsub(/"|'/, "")
|
32
|
+
return_value += '\"'
|
33
|
+
return_value
|
34
|
+
else
|
35
|
+
"#{key_value[0]}=#{key_value[1].gsub(/"|'/, "")}"
|
36
|
+
end
|
37
|
+
else
|
38
|
+
arg
|
39
|
+
end
|
40
|
+
}
|
41
|
+
|
42
|
+
command = "ssh -p #{port} #{user}@#{domain} "
|
43
|
+
command += user == "root" ? "dokku " : ""
|
44
|
+
command += "config:set #{app_name} #{args.join(' ')}"
|
45
|
+
|
46
|
+
puts "Running #{command}..."
|
47
|
+
exec(command)
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "config:unset KEY1 [KEY2 ...] ", "Unset one or more environment variables"
|
51
|
+
def config_unset(*args)
|
52
|
+
run_command "config:unset #{app_name} #{args.join(' ')}"
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "config:set:file path/to/file", "Set one or more environment variables from file"
|
56
|
+
def config_set_file(config_file)
|
57
|
+
config_params = ""
|
58
|
+
if File.exists?(config_file)
|
59
|
+
File.open(config_file).each_line do |line|
|
60
|
+
config_params += line.strip + " " unless line.start_with? "#" || line.strip == ""
|
61
|
+
end
|
62
|
+
config_set(config_params)
|
63
|
+
else
|
64
|
+
puts "File #{config_file} does not exist."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module DokkuCli
|
2
|
+
class Cli < Thor
|
3
|
+
|
4
|
+
map "events:list" => "events_list",
|
5
|
+
"events:on" => "events_on",
|
6
|
+
"events:off" => "events_off"
|
7
|
+
|
8
|
+
desc "events", "Show the last events (-t follows)"
|
9
|
+
def events
|
10
|
+
run_command "events #{app_name}"
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "events:list", "List logged events"
|
14
|
+
def events_list
|
15
|
+
run_command "events:list #{app_name}"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "events:on", "Enable events logger"
|
19
|
+
def events_on
|
20
|
+
run_command "events:on #{app_name}"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "events:off", "Disable events logger"
|
24
|
+
def events_off
|
25
|
+
run_command "events:off #{app_name}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DokkuCli
|
2
|
+
class Cli < Thor
|
3
|
+
|
4
|
+
map "keys:add" => "keys_add"
|
5
|
+
|
6
|
+
desc "keys:add PATH DESCRIPTION", "Add the ssh key to your dokku machine."
|
7
|
+
def keys_add(path, description)
|
8
|
+
command = "cat #{path} | ssh -p #{port} root@#{domain} 'sudo sshcommand acl-add dokku #{description}'"
|
9
|
+
|
10
|
+
puts "Adding #{path} to your dokku machine..."
|
11
|
+
exec(command)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module DokkuCli
|
2
|
+
class Cli < Thor
|
3
|
+
|
4
|
+
map "nginx:build" => "nginx_build",
|
5
|
+
"nginx:access-logs" => "nginx_access_logs",
|
6
|
+
"nginx:error-logs" => "nginx_error_logs"
|
7
|
+
|
8
|
+
desc "nginx:build", "(Re)builds nginx config for the app"
|
9
|
+
def nginx_build
|
10
|
+
run_command "nginx:build-config #{app_name}"
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "nginx:access-logs", "Show the nginx access logs for an application"
|
14
|
+
def nginx_access_logs
|
15
|
+
run_command "nginx:access-logs #{app_name}"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "nginx:error-logs ", "Show the nginx access logs for an application"
|
19
|
+
def nginx_error_logs
|
20
|
+
run_command "nginx:error-logs #{app_name}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/dokku_cli/ps.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module DokkuCli
|
2
|
+
class Cli < Thor
|
3
|
+
|
4
|
+
map "ps:rebuild" => "ps_rebuild",
|
5
|
+
"ps:restart" => "ps_restart",
|
6
|
+
"ps:start" => "ps_start",
|
7
|
+
"ps:stop" => "ps_stop",
|
8
|
+
"ps:scale" => "ps_scale"
|
9
|
+
|
10
|
+
desc "ps", "List processes running in app container(s)"
|
11
|
+
def ps
|
12
|
+
run_command "ps #{app_name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "ps:rebuild", "Rebuild the app"
|
16
|
+
def ps_rebuild
|
17
|
+
run_command "ps:rebuild #{app_name}"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "ps:restart", "Restart the app container"
|
21
|
+
def ps_restart
|
22
|
+
run_command "ps:restart #{app_name}"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "ps:start", "Start the app container"
|
26
|
+
def ps_start
|
27
|
+
run_command "ps:start #{app_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "ps:stop", "Stop the app container"
|
31
|
+
def ps_stop
|
32
|
+
run_command "ps:stop #{app_name}"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "ps:scale", "Scale the app processes"
|
36
|
+
def ps_scale(*processes)
|
37
|
+
if processes.empty?
|
38
|
+
run_command "ps:scale #{app_name}"
|
39
|
+
else
|
40
|
+
run_command "ps:scale #{app_name} #{processes.join(' ')}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yugen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Henry Dowding
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
description: Command line tool for Yugen based on dokku-cli.
|
42
|
+
email:
|
43
|
+
- support@yugen.app
|
44
|
+
executables:
|
45
|
+
- yugen
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- bin/yugen
|
50
|
+
- lib/dokku_cli.rb
|
51
|
+
- lib/dokku_cli/certs.rb
|
52
|
+
- lib/dokku_cli/config.rb
|
53
|
+
- lib/dokku_cli/domains.rb
|
54
|
+
- lib/dokku_cli/events.rb
|
55
|
+
- lib/dokku_cli/keys.rb
|
56
|
+
- lib/dokku_cli/nginx.rb
|
57
|
+
- lib/dokku_cli/ps.rb
|
58
|
+
- lib/dokku_cli/version.rb
|
59
|
+
homepage:
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.5.2.3
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Command line tool for Yugen based on dokku-cli
|
83
|
+
test_files: []
|