sensible-cli 0.2.0 → 0.2.3
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 +4 -4
- data/lib/sensible/shell.rb +9 -6
- data/lib/sensible/task.rb +58 -4
- data/lib/sensible/version.rb +1 -1
- data/lib/sensible.rb +35 -24
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6074b7bd0e754e6cc54845ea3f3b4a8992b13886236905fd4c1bda349d113c47
|
4
|
+
data.tar.gz: 4460129fc2e46849b5d3af3b2d527f7ab8391d7aba8b992e20c26c7e1f754e28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 023a8f832a2b6f7772186f42e47391fd4cedd52a67e7a3292738ce5de430a022b05a2d6cf35c15fe4aef4ba759a29bd0cc7109c8c7d5511951b1230eeae77b82
|
7
|
+
data.tar.gz: 1c6ff28b297c82f3c44f6caa5026eb85a4915e2806d744cb16ec75c04a394229c3ac78b4f90dd48bb1afc30c61c1c3957a09678b1a9dabee95e1228c4b7c925c
|
data/lib/sensible/shell.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/ssh'
|
2
|
+
require 'shellwords'
|
2
3
|
|
3
4
|
module Sensible
|
4
5
|
class Shell
|
@@ -37,15 +38,17 @@ module Sensible
|
|
37
38
|
else
|
38
39
|
# Standard local shell command
|
39
40
|
# If command contains new lines, use a temporary file
|
41
|
+
if user != nil
|
42
|
+
system("sudo runuser -l #{user} -c '#{command}'", out: (show_output ? $stdout : File::NULL), err: (show_output ? $stderr : File::NULL))
|
43
|
+
return $?.success?
|
44
|
+
end
|
45
|
+
|
46
|
+
|
40
47
|
if command.include?("\n")
|
41
|
-
system("bash", "-c", command, out: (show_output ? $stdout : File::NULL), err: (show_output ? $stderr : File::NULL))
|
48
|
+
system("bash", "-c", command, out: (show_output ? $stdout : File::NULL), err: (show_output ? $stderr : File::NULL))
|
42
49
|
return $?.success?
|
43
50
|
else
|
44
|
-
|
45
|
-
system("sudo -u #{user} #{command}", out: (show_output ? $stdout : File::NULL), err: (show_output ? $stderr : File::NULL))
|
46
|
-
else
|
47
|
-
system(command, out: (show_output ? $stdout : File::NULL), err: (show_output ? $stderr : File::NULL))
|
48
|
-
end
|
51
|
+
system(command, out: (show_output ? $stdout : File::NULL), err: (show_output ? $stderr : File::NULL))
|
49
52
|
return $?.success?
|
50
53
|
end
|
51
54
|
end
|
data/lib/sensible/task.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require_relative 'package'
|
2
2
|
require_relative 'shell'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'shellwords'
|
3
5
|
|
4
6
|
module Sensible
|
5
7
|
class Task
|
@@ -14,6 +16,7 @@ module Sensible
|
|
14
16
|
attr_reader :user
|
15
17
|
attr_reader :description
|
16
18
|
attr_accessor :show_output
|
19
|
+
attr_reader :copy
|
17
20
|
|
18
21
|
def initialize(taskHash, file_name, user = nil, sensible)
|
19
22
|
@name = taskHash['name']
|
@@ -24,6 +27,7 @@ module Sensible
|
|
24
27
|
@file_name = file_name
|
25
28
|
@description = taskHash['description']
|
26
29
|
@show_output = taskHash['showOutput']
|
30
|
+
@copy = taskHash['copy']
|
27
31
|
|
28
32
|
# If task is initalized with user, force use of that
|
29
33
|
if user != nil
|
@@ -58,8 +62,8 @@ module Sensible
|
|
58
62
|
has_all_packages_install = false
|
59
63
|
end
|
60
64
|
end
|
61
|
-
|
62
|
-
return has_all_packages_install
|
65
|
+
|
66
|
+
return has_all_packages_install
|
63
67
|
end
|
64
68
|
|
65
69
|
# Install the packages in this task
|
@@ -76,6 +80,11 @@ module Sensible
|
|
76
80
|
end
|
77
81
|
|
78
82
|
def do_check
|
83
|
+
# Always return false to force copy
|
84
|
+
if @copy != nil
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
79
88
|
# If check is not set, always run the task
|
80
89
|
if @check == nil
|
81
90
|
return false
|
@@ -83,17 +92,62 @@ module Sensible
|
|
83
92
|
|
84
93
|
# If there is no check, default to false, to force task to script every time
|
85
94
|
shell = Shell.new(@sensible)
|
86
|
-
return shell.run_command(@check, @user)
|
95
|
+
return shell.run_command(@check, @user, show_output: @show_output)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def do_copy
|
100
|
+
origin = File.expand_path(@copy['origin'])
|
101
|
+
destination = @copy['dest']
|
102
|
+
destination_expanded = File.expand_path(@copy['dest'])
|
103
|
+
|
104
|
+
puts destination
|
105
|
+
|
106
|
+
commmand = nil
|
107
|
+
|
108
|
+
if @sensible.opts.host
|
109
|
+
if @user
|
110
|
+
|
111
|
+
command = "rsync -avu --delete #{Shellwords.escape(origin)} root@#{@sensible.opts.host}:#{Shellwords.escape(destination.sub('~', "/home/#{user}"))}"
|
112
|
+
else
|
113
|
+
command = "rsync -avu --delete #{Shellwords.escape(origin)} root@#{@sensible.opts.host}:#{Shellwords.escape(destination)}"
|
114
|
+
end
|
115
|
+
|
116
|
+
else
|
117
|
+
command = "rsync -avu --delete #{Shellwords.escape(origin)} #{Shellwords.escape(destination_expanded)}"
|
118
|
+
end
|
119
|
+
|
120
|
+
if @sensible.opts.verbose
|
121
|
+
system(command)
|
122
|
+
else
|
123
|
+
system(command, out: File::NULL, err: File::NULL)
|
124
|
+
end
|
125
|
+
|
126
|
+
return $?.success?
|
87
127
|
end
|
88
128
|
|
89
129
|
def do_script
|
90
130
|
# TODO: Handle the show output property!
|
91
131
|
shell = Shell.new(@sensible)
|
92
|
-
return shell.run_command(@script, @user)
|
132
|
+
return shell.run_command(@script, @user, show_output: @show_output)
|
93
133
|
end
|
94
134
|
|
95
135
|
def do_verify
|
96
136
|
return true
|
97
137
|
end
|
138
|
+
|
139
|
+
|
140
|
+
def check_exists(path)
|
141
|
+
is_folder = path.end_with?('/')
|
142
|
+
expanded_path = File.expand_path(path)
|
143
|
+
|
144
|
+
if is_folder == true
|
145
|
+
return Dir.exist?(expanded_path)
|
146
|
+
else
|
147
|
+
return File.exist?(expanded_path)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Handle remote
|
151
|
+
end
|
98
152
|
end
|
99
153
|
end
|
data/lib/sensible/version.rb
CHANGED
data/lib/sensible.rb
CHANGED
@@ -97,17 +97,18 @@ module Sensible
|
|
97
97
|
# end
|
98
98
|
if task.packages.length > 0
|
99
99
|
if task.do_packages_check
|
100
|
-
Logger.success("
|
100
|
+
Logger.success("Task packages installed!")
|
101
101
|
else
|
102
|
-
Logger.danger("
|
102
|
+
Logger.danger("Task packages NOT installed!")
|
103
103
|
end
|
104
104
|
end
|
105
|
-
|
106
|
-
if
|
105
|
+
|
106
|
+
# Only do check if script exists
|
107
|
+
if task.script
|
107
108
|
if task.do_check
|
108
|
-
Logger.success("
|
109
|
+
Logger.success("Task is installed!")
|
109
110
|
else
|
110
|
-
Logger.danger("
|
111
|
+
Logger.danger("Task is NOT installed!")
|
111
112
|
end
|
112
113
|
end
|
113
114
|
end
|
@@ -141,38 +142,48 @@ module Sensible
|
|
141
142
|
# end
|
142
143
|
if task.packages.length > 0
|
143
144
|
if task.do_packages_check
|
144
|
-
Logger.success("
|
145
|
+
Logger.success("Task packages installed!")
|
145
146
|
else
|
146
147
|
Logger.info("Installing packages...\r", use_print: true)
|
147
148
|
if task.do_packages_install
|
148
149
|
Logger.clear_line
|
149
|
-
Logger.success("
|
150
|
+
Logger.success("Task packages installed!")
|
150
151
|
else
|
151
152
|
Logger.clear_line
|
152
|
-
Logger.danger("
|
153
|
+
Logger.danger("Task packages NOT installed!")
|
153
154
|
end
|
154
155
|
|
155
156
|
Logger.flush
|
156
157
|
end
|
157
158
|
end
|
158
159
|
|
159
|
-
if task.
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
else
|
169
|
-
Logger.clear_line
|
170
|
-
Logger.danger("Is NOT installed!")
|
171
|
-
end
|
172
|
-
Logger.flush
|
160
|
+
if task.do_check
|
161
|
+
Logger.success("Task is installed!")
|
162
|
+
else
|
163
|
+
# Handle copy task
|
164
|
+
if task.copy
|
165
|
+
Logger.info("Copying files...\r", use_print: true)
|
166
|
+
if task.do_copy
|
167
|
+
Logger.clear_line
|
168
|
+
Logger.success("Files was copied!")
|
173
169
|
else
|
174
|
-
Logger.
|
170
|
+
Logger.clear_line
|
171
|
+
Logger.danger("Files was NOT copied!")
|
175
172
|
end
|
173
|
+
Logger.flush
|
174
|
+
end
|
175
|
+
|
176
|
+
# Handle task script
|
177
|
+
if task.script
|
178
|
+
Logger.info("Running task...\r", use_print: true)
|
179
|
+
if task.do_script
|
180
|
+
Logger.clear_line
|
181
|
+
Logger.success("Task is installed!")
|
182
|
+
else
|
183
|
+
Logger.clear_line
|
184
|
+
Logger.danger("Task is NOT installed!")
|
185
|
+
end
|
186
|
+
Logger.flush
|
176
187
|
end
|
177
188
|
end
|
178
189
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensible-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Jensen
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-07-30 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: shellopts
|
@@ -113,6 +113,48 @@ dependencies:
|
|
113
113
|
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: ed25519
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
type: :runtime
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: bcrypt_pbkdf
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
type: :runtime
|
138
|
+
prerelease: false
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
name: logger
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 1.6.0
|
151
|
+
type: :runtime
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 1.6.0
|
116
158
|
description: A small tool to manage projects, making shell scripts easier to manage,
|
117
159
|
and faster to setup projects!
|
118
160
|
email:
|
@@ -161,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
203
|
- !ruby/object:Gem::Version
|
162
204
|
version: '0'
|
163
205
|
requirements: []
|
164
|
-
rubygems_version: 3.6.
|
206
|
+
rubygems_version: 3.6.5
|
165
207
|
specification_version: 4
|
166
208
|
summary: A small tool to manage projects.
|
167
209
|
test_files: []
|