first_deployment 0.1.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/exe/first_deployment +26 -0
- data/lib/first_deployment.rb +11 -0
- data/lib/first_deployment/command_result.rb +15 -0
- data/lib/first_deployment/errors.rb +6 -0
- data/lib/first_deployment/logger.rb +38 -0
- data/lib/first_deployment/results_helper.rb +48 -0
- data/lib/first_deployment/shell_helper.rb +46 -0
- data/lib/first_deployment/version.rb +5 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 16e0d68fcda7561f7c0c74549c5b584397dd13f550928f176c086c1ae7ec34cc
|
4
|
+
data.tar.gz: dcb5882749187fcff08f294c87b72b3183b2bd8de4fe52465b355be5ae0ae755
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4fe13967b4ccc3af7e5085e04b9eed62cc2f6fe54c4e3e5854e07411a7bae614b7a11f7ee7ba303b967799f9c6557015c9e878c811bc55577f89251933c1be4
|
7
|
+
data.tar.gz: 5e11dc7435547435ecb2402fbbfa78196281516218bab72f816ffb79ca7c2dce6586cb329b317562c81ab71ee03b6df651d58079cc4a96d4ff02840d53f85ef7
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path("../lib", __dir__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require("byebug") if ENV["DEBUG"] && !Gem::Specification.find_all_by_name("byebug").empty?
|
8
|
+
require "first_deployment"
|
9
|
+
require "optionparser"
|
10
|
+
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: first_deployment"
|
13
|
+
|
14
|
+
opts.on("-h", "--help", "Prints this help") do
|
15
|
+
puts opts
|
16
|
+
exit 0
|
17
|
+
end
|
18
|
+
end.parse!
|
19
|
+
|
20
|
+
begin
|
21
|
+
# TODO
|
22
|
+
rescue StandardError => e
|
23
|
+
FirstDeployment::LOG.error(e.message)
|
24
|
+
FirstDeployment::LOG.error(e.backtrace.join("\n")) if ENV["DEBUG"]
|
25
|
+
exit 1
|
26
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "first_deployment/version"
|
4
|
+
require "first_deployment/errors"
|
5
|
+
require "first_deployment/logger"
|
6
|
+
require "first_deployment/command_result"
|
7
|
+
require "first_deployment/shell_helper"
|
8
|
+
require "first_deployment/results_helper"
|
9
|
+
|
10
|
+
module FirstDeployment
|
11
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "logger"
|
4
|
+
require "time"
|
5
|
+
require "colorize"
|
6
|
+
|
7
|
+
module FirstDeployment
|
8
|
+
LOG = Logger.new(STDOUT)
|
9
|
+
LOG.level = Logger::INFO
|
10
|
+
LOG.formatter = proc do |severity, datetime, _progname, message|
|
11
|
+
line = "[#{datetime.strftime('%Y-%m-%d %H:%M:%S')}] #{severity} -- #{message}\n"
|
12
|
+
|
13
|
+
case severity
|
14
|
+
when "ERROR"
|
15
|
+
line.colorize(:red)
|
16
|
+
else
|
17
|
+
line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class << LOG
|
22
|
+
def info_success(message)
|
23
|
+
LOG.info(message.colorize(:green))
|
24
|
+
end
|
25
|
+
|
26
|
+
def info_error(message)
|
27
|
+
LOG.info(message.colorize(:red))
|
28
|
+
end
|
29
|
+
|
30
|
+
def info_warning(message)
|
31
|
+
LOG.info(message.colorize(:yellow))
|
32
|
+
end
|
33
|
+
|
34
|
+
def info_notice(message)
|
35
|
+
LOG.info(message.colorize(:light_blue))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "colorize"
|
5
|
+
|
6
|
+
module FirstDeployment
|
7
|
+
module ResultsHelper
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def process(results, config:)
|
11
|
+
if config["output"].nil? || config["output"] == "STDOUT"
|
12
|
+
output_to_stdout(results)
|
13
|
+
else
|
14
|
+
output_to_directory(results, directory: config["output"])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def output_to_stdout(results)
|
19
|
+
results.each_pair do |env_name, result|
|
20
|
+
puts
|
21
|
+
puts "== Output for #{env_name}".colorize(:green)
|
22
|
+
puts
|
23
|
+
puts result
|
24
|
+
end
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
|
28
|
+
def output_to_directory(results, directory:)
|
29
|
+
FileUtils.mkdir_p(directory)
|
30
|
+
filenames = []
|
31
|
+
results.each_pair do |env_name, result|
|
32
|
+
filename = File.join(directory, env_name + ".txt")
|
33
|
+
filenames << filename
|
34
|
+
|
35
|
+
File.open(filename, "w+") do |file|
|
36
|
+
file.write(result)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
message = +"Command outputs are now present in the following files:\n"
|
41
|
+
message << filenames.join("\n")
|
42
|
+
|
43
|
+
puts
|
44
|
+
puts message.colorize(:green)
|
45
|
+
puts
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "English"
|
4
|
+
require "open3"
|
5
|
+
require "shellwords"
|
6
|
+
|
7
|
+
module FirstDeployment
|
8
|
+
module ShellHelper
|
9
|
+
def run_command(command, success_only: true, no_capture: false)
|
10
|
+
LOG.info("Running `#{command.colorize(:light_yellow)}` ...")
|
11
|
+
|
12
|
+
exit_status, result_str = no_capture ? run_no_capture_command(command) : run_capture_command(command)
|
13
|
+
raise "(non-zero exit code: #{exit_status.exitstatus})" if success_only && !exit_status.success?
|
14
|
+
|
15
|
+
CommandResult.new(result_str).tap do |result|
|
16
|
+
result.success = exit_status.success?
|
17
|
+
end
|
18
|
+
rescue StandardError => e
|
19
|
+
raise Error, <<~MSG
|
20
|
+
Error running the command `#{command}`:
|
21
|
+
=> error: #{e.message}
|
22
|
+
=> command output: #{result_str}
|
23
|
+
MSG
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_no_capture_command(command)
|
27
|
+
system(command)
|
28
|
+
[$CHILD_STATUS, ""]
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_capture_command(command)
|
32
|
+
exit_status = nil
|
33
|
+
result_str = +""
|
34
|
+
|
35
|
+
Open3.popen2e(command) do |_stdin, stdout_and_stderr, wait_thr|
|
36
|
+
stdout_and_stderr.each do |line|
|
37
|
+
result_str << line
|
38
|
+
end
|
39
|
+
exit_status = wait_thr.value
|
40
|
+
end
|
41
|
+
exit_status.success? ? LOG.info_success(result_str) : LOG.info_error(result_str)
|
42
|
+
|
43
|
+
[exit_status, result_str]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: first_deployment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christophe Maximin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
description: FirstDeployment is a zero-conf tool which will deploy your Rails app
|
28
|
+
to a web server
|
29
|
+
email:
|
30
|
+
- christophe.maximin@gmail.com
|
31
|
+
executables:
|
32
|
+
- first_deployment
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- exe/first_deployment
|
37
|
+
- lib/first_deployment.rb
|
38
|
+
- lib/first_deployment/command_result.rb
|
39
|
+
- lib/first_deployment/errors.rb
|
40
|
+
- lib/first_deployment/logger.rb
|
41
|
+
- lib/first_deployment/results_helper.rb
|
42
|
+
- lib/first_deployment/shell_helper.rb
|
43
|
+
- lib/first_deployment/version.rb
|
44
|
+
homepage: https://github.com/christophemaximin/first_deployment
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/christophemaximin/first_deployment
|
49
|
+
source_code_uri: https://github.com/christophemaximin/first_deployment
|
50
|
+
changelog_uri: https://github.com/christophemaximin/first_deployment/blob/master/CHANGELOG.md
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.0.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: FirstDeployment is a zero-conf tool which will deploy your Rails app to a
|
70
|
+
web server
|
71
|
+
test_files: []
|