rails_deploy 0.1.1 → 0.2.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -0
  3. data/lib/deploy.rb +16 -22
  4. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92931eebe8d0a513ad0d5238770eb47b75ed29a52e0057ccd00de5403b15dcb6
4
- data.tar.gz: ef94e8d3cdb8814e5d6a1208388220fd63be1d9ac4b1eb69068b3be42f792345
3
+ metadata.gz: 8b3545822404ede0a1ffc92c820ddf7658008fc1ba7f460e70eaa50c7a361961
4
+ data.tar.gz: 31e85ff93c115de35c61767e26e010ee78c4224c771953cb4f49cde2e311f4d4
5
5
  SHA512:
6
- metadata.gz: bbfa75b58508249217e6a70d1daae6d993cb74b2a7cda625b2ffb11ad1513f31e97b3591ba9110648001a67fb8cb26210c58b76387c8018c82f1fc5414a0fd88
7
- data.tar.gz: d56ea4f405da35a81e35556155a0c0ca5087b6db88f0670e5bd78af40f3bdff54fb49b304f8b539dca53cf821723ad3adcca2740298bcf77226a4c15dc4bb73a
6
+ metadata.gz: 3e371ae42b189456172f530e9c5818ea71cd09eda651925ffc99da5c3ee3bb2cc2845339fa72ace222d5fc7c67e5dd3307b0782ecc8be76fee7fc2e30e4aa9d2
7
+ data.tar.gz: f6be3dbda15f7cb265bfe73380d17bbf7181dda28bc2e14e1fa6dbc39c167079e05124a669963c34dee0131d53e6676abf119b97339c5d8e60d6ee1da2c2bfc5
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2023-Present Mingyuan Qin <mingyuan0715@foxmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/deploy.rb CHANGED
@@ -8,21 +8,21 @@ require 'logger'
8
8
  module Deploy
9
9
  MOVED_DIRS = [
10
10
  'log',
11
- 'tmp',
12
- ]
11
+ 'tmp'
12
+ ].freeze
13
13
  SHARED_DIRS = [
14
14
  'public/assets',
15
15
  'public/fonts',
16
16
  'vendor/bundle'
17
17
  ].freeze
18
- SHARED_FILES = [
19
- 'config/credentials/production.key'
20
- ].freeze
21
18
  INIT_DIRS = [
22
19
  'tmp/sockets',
23
20
  'tmp/pids',
24
21
  'config/credentials'
25
22
  ].freeze
23
+ SHARED_FILES = [
24
+ 'config/credentials/production.key'
25
+ ].freeze
26
26
  extend self
27
27
 
28
28
  def restart
@@ -33,19 +33,13 @@ module Deploy
33
33
  OpenSSL::HMAC.hexdigest('sha1', RailsCom.config.github_hmac_key, data)
34
34
  end
35
35
 
36
- def init_shared_paths(root = Pathname.pwd.join('../shared'))
37
- dirs = []
38
- dirs += MOVED_DIRS.map { |dir| root.join(dir) }
39
- dirs += SHARED_DIRS.map { |dir| root.join(dir) }
40
- dirs += INIT_DIRS.map { |dir| root.join(dir) }
41
- FileUtils.mkdir_p dirs
36
+ def init(root: Pathname.pwd, shared: Pathname.pwd.join('../shared'))
37
+ dirs = (MOVED_DIRS + SHARED_DIRS + INIT_DIRS).map { |dir| shared.join(dir) }
38
+ FileUtils.mkdir_p dirs, verbose: true
42
39
 
43
- SHARED_FILES.map do |path|
44
- `touch #{root.join(path)}`
45
- end
46
- end
40
+ files = SHARED_FILES.map { |file| shared.join(file) }
41
+ FileUtils.touch files, verbose: true
47
42
 
48
- def ln_shared_paths(root = Pathname.pwd)
49
43
  cmds = []
50
44
  cmds << 'bundle config set --local deployment true'
51
45
  cmds << 'bundle config set --local path vendor/bundle'
@@ -54,10 +48,10 @@ module Deploy
54
48
  "rm -rf #{root.join(path)}"
55
49
  end
56
50
  cmds += (MOVED_DIRS + SHARED_DIRS).map do |path|
57
- "ln -Tsfv #{root.join('../shared', path)} #{root.join(path)}"
51
+ "ln -Tsfv #{shared.join(path)} #{root.join(path)}"
58
52
  end
59
53
  cmds += SHARED_FILES.map do |path|
60
- "ln -Tsfv #{root.join('../shared', path)} #{root.join(path)}"
54
+ "ln -Tsfv #{shared.join(path)} #{root.join(path)}"
61
55
  end
62
56
  cmds.each do |cmd|
63
57
  exec_cmd(cmd)
@@ -66,7 +60,7 @@ module Deploy
66
60
 
67
61
  def exec_cmds(env = 'production', added_cmds: [])
68
62
  start_at = Time.now
69
- logger.debug "Deploy at #{start_at}"
63
+ logger.info "Deploy started at #{start_at}"
70
64
  cmds = [
71
65
  'whoami',
72
66
  'git pull',# --recurse-submodules
@@ -79,14 +73,14 @@ module Deploy
79
73
  exec_cmd(cmd)
80
74
  end
81
75
  finish_at = Time.now
82
- logger.debug "Deploy finished at #{finish_at}, used: #{finish_at - start_at}s"
76
+ logger.info "Deploy finished at #{finish_at}, used: #{(finish_at - start_at).round(2)}s"
83
77
  end
84
78
 
85
79
  def exec_cmd(cmd)
86
80
  Open3.popen2e(cmd) do |_, output, thread|
87
- logger.debug "\e[35m #{cmd} (PID: #{thread.pid}) \e[0m"
81
+ logger.info "\e[35m #{cmd} (PID: #{thread.pid}) \e[0m"
88
82
  output.each_line do |line|
89
- logger.debug " #{line.chomp}"
83
+ logger.info " #{line.chomp}"
90
84
  end
91
85
  puts "\n"
92
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
- - qinmingyuan
7
+ - Mingyuan Qin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-17 00:00:00.000000000 Z
11
+ date: 2023-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - LICENSE
48
49
  - README.md
49
50
  - lib/deploy.rb
50
51
  homepage: https://github.com/work-design/rails_deploy
@@ -66,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 3.4.10
70
+ rubygems_version: 3.5.0.dev
70
71
  signing_key:
71
72
  specification_version: 4
72
73
  summary: Deploy from server