command_proposal 1.0.15 → 1.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/command_proposal/comment.rb +1 -1
- data/app/models/command_proposal/iteration.rb +7 -3
- data/app/models/command_proposal/service/json_wrapper.rb +1 -1
- data/app/models/command_proposal/service/proposal_presenter.rb +1 -0
- data/app/models/command_proposal/task.rb +1 -1
- data/app/views/command_proposal/tasks/_lines.html.erb +1 -1
- data/lib/command_proposal/services/runner.rb +24 -16
- data/lib/command_proposal/services/shut_down.rb +1 -1
- data/lib/command_proposal/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 193d5b467c63b2d95e5ca542ac33354a4ee6343d9da70ff0cefd5557e28c55f5
|
4
|
+
data.tar.gz: fd8fae6e4623ce876852e8c11608a0c917e7e7aeaa0ece76c5dddafcbf9a673c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48d63efa8ed693c2b30e3839deb6d406446c66ec067492bd3ef9300973a675d85f3421303def7abdcae2168336b158268401b59e3a84abe37ea5c94629ff2aa4
|
7
|
+
data.tar.gz: b7ace39b402981e847a73d5a89c28a75c96e7b2c4f310b5b2a5bae9248ccd24c31ed128da7bb5ef8bb214f1cc986e7ed1113916c99bb2bd196a93f9465f393e0
|
@@ -9,6 +9,6 @@ class ::CommandProposal::Comment < ApplicationRecord
|
|
9
9
|
self.table_name = :command_proposal_comments
|
10
10
|
include ::CommandProposal::Service::ExternalBelong
|
11
11
|
|
12
|
-
belongs_to :iteration, optional: true
|
12
|
+
belongs_to :iteration, optional: true, class_name: "CommandProposal::Iteration"
|
13
13
|
external_belongs_to :author
|
14
14
|
end
|
@@ -18,14 +18,14 @@ require_dependency "command_proposal/service/json_wrapper"
|
|
18
18
|
|
19
19
|
class ::CommandProposal::Iteration < ApplicationRecord
|
20
20
|
self.table_name = :command_proposal_iterations
|
21
|
-
serialize :args, ::CommandProposal::Service::
|
21
|
+
serialize :args, ::CommandProposal::Service::JsonWrapper
|
22
22
|
include ::CommandProposal::Service::ExternalBelong
|
23
23
|
|
24
24
|
TRUNCATE_COUNT = 2000
|
25
25
|
# Also hardcoded in JS: app/assets/javascripts/command_proposal/console.js
|
26
26
|
|
27
|
-
has_many :comments
|
28
|
-
belongs_to :task
|
27
|
+
has_many :comments, class_name: "CommandProposal::Comment"
|
28
|
+
belongs_to :task, class_name: "CommandProposal::Task"
|
29
29
|
external_belongs_to :requester
|
30
30
|
external_belongs_to :approver
|
31
31
|
|
@@ -65,6 +65,10 @@ class ::CommandProposal::Iteration < ApplicationRecord
|
|
65
65
|
task.primary_iteration == self
|
66
66
|
end
|
67
67
|
|
68
|
+
def approved?
|
69
|
+
super || (session_type == "function" && approved_at?)
|
70
|
+
end
|
71
|
+
|
68
72
|
def complete?
|
69
73
|
success? || failed? || cancelled? || terminated?
|
70
74
|
end
|
@@ -13,6 +13,7 @@ module CommandProposal
|
|
13
13
|
delegate :description, to: :iteration
|
14
14
|
delegate :args, to: :iteration
|
15
15
|
delegate :code, to: :iteration
|
16
|
+
delegate :result, to: :iteration
|
16
17
|
delegate :status, to: :iteration
|
17
18
|
delegate :approved_at, to: :iteration
|
18
19
|
delegate :started_at, to: :iteration
|
@@ -9,7 +9,7 @@ class ::CommandProposal::Task < ApplicationRecord
|
|
9
9
|
self.table_name = :command_proposal_tasks
|
10
10
|
attr_accessor :user, :skip_approval
|
11
11
|
|
12
|
-
has_many :iterations
|
12
|
+
has_many :iterations, class_name: "CommandProposal::Iteration"
|
13
13
|
has_many :ordered_iterations, -> { order(created_at: :desc) }, class_name: "CommandProposal::Iteration"
|
14
14
|
|
15
15
|
scope :search, ->(text) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if lines.blank? && !(skip_empty ||= false) -%><div class="line"></div><% end
|
2
|
-
-%><% lines&.split("\n")
|
2
|
+
-%><% lines&.split("\n")&.each do |line|
|
3
3
|
truncate = ::CommandProposal::Iteration::TRUNCATE_COUNT
|
4
4
|
-%><div class="line"><%= line.truncate(truncate) -%></div><%=
|
5
5
|
if line.length > truncate
|
@@ -65,7 +65,7 @@ module CommandProposal
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def quick_run(friendly_id)
|
68
|
-
task = ::CommandProposal::Task.
|
68
|
+
task = ::CommandProposal::Task.find_by!(friendly_id: friendly_id)
|
69
69
|
iteration = task&.primary_iteration
|
70
70
|
|
71
71
|
raise CommandProposal::Error, ":#{friendly_id} does not have approval to run." unless iteration&.approved?
|
@@ -98,12 +98,12 @@ module CommandProposal
|
|
98
98
|
return @iteration.result = results_from_exception(e)
|
99
99
|
end
|
100
100
|
|
101
|
-
stored_stdout = $stdout
|
102
|
-
$stdout = StringIO.new
|
101
|
+
stored_stdout = $stdout # quiet
|
102
|
+
$stdout = StringIO.new # quiet
|
103
103
|
result = nil # Init var for scope
|
104
104
|
status = nil
|
105
105
|
|
106
|
-
|
106
|
+
runner_proc = proc {
|
107
107
|
begin
|
108
108
|
# Run `bring` functions in here so we can capture any string outputs
|
109
109
|
# OR! Run the full runner and instead of saving to an iteration, return the string for prepending here
|
@@ -115,28 +115,36 @@ module CommandProposal
|
|
115
115
|
|
116
116
|
result = results_from_exception(e)
|
117
117
|
end
|
118
|
-
|
119
|
-
|
120
|
-
while running_thread.status.present?
|
121
|
-
@iteration.reload
|
118
|
+
}
|
122
119
|
|
123
|
-
|
124
|
-
|
120
|
+
if Rails.application.config.active_job&.queue_adapter == :inline
|
121
|
+
runner_proc.call
|
122
|
+
else
|
123
|
+
running_thread = Thread.new do
|
124
|
+
runner_proc.call
|
125
125
|
end
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
status = :cancelled
|
130
|
-
end
|
127
|
+
while running_thread.status.present?
|
128
|
+
@iteration.reload
|
131
129
|
|
132
|
-
|
130
|
+
if $stdout.try(:string) != @iteration.result
|
131
|
+
@iteration.update(result: $stdout.try(:string).dup)
|
132
|
+
end
|
133
|
+
|
134
|
+
if @iteration.cancelling?
|
135
|
+
running_thread.exit
|
136
|
+
status = :cancelled
|
137
|
+
end
|
138
|
+
|
139
|
+
sleep 0.4
|
140
|
+
end
|
133
141
|
end
|
134
142
|
|
135
143
|
output = $stdout.try(:string)
|
136
144
|
output = nil if output == ""
|
137
145
|
# Not using presence because we want to maintain other empty objects such as [] and {}
|
138
146
|
|
139
|
-
$stdout = stored_stdout
|
147
|
+
$stdout = stored_stdout # quiet
|
140
148
|
@iteration.status = status
|
141
149
|
@iteration.result = [output, result].compact.join("\n")
|
142
150
|
end
|
@@ -13,7 +13,7 @@ module CommandProposal
|
|
13
13
|
def terminate(iteration)
|
14
14
|
return unless iteration.running?
|
15
15
|
|
16
|
-
terminated_result = iteration
|
16
|
+
terminated_result = "#{iteration&.result}\n\n~~~~~ TERMINATED ~~~~~"
|
17
17
|
iteration.update(
|
18
18
|
status: :terminated,
|
19
19
|
result: terminated_result,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_proposal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rocco Nicholls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
rubygems_version: 3.2.
|
165
|
+
rubygems_version: 3.2.3
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: Gives the ability to run approved commands through a UI in your browser
|