deployed 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 50080d040c3bff4dd637c1a713099f647b33da038b2941b39a5880231626b8ac
4
+ data.tar.gz: 5c65431ac771b299bb08bfce1af59e7b8ac4654a8676205c3df2faa28fc18696
5
+ SHA512:
6
+ metadata.gz: 862ee593d481ad2fcaa39a97ca378c90b92463f3ca66fb88d024df960a8c9dc4bc4c3a7673e42c4353159c582b7f200049c67b170287ca5a2136ea592b584baf
7
+ data.tar.gz: 9e7ca19e33afe77160a635491e66a79f66aebe8cefb306264262f27034f9acadc23522ef5a8b66d7db9b2752dd4b0116538909635eac21c3a06c2a312aacfbfe
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ 2023 Copyright Simon Chiu
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/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Deployed
2
+
3
+ Deployed is a web interface for the deployment library, [Kamal](https://kamal-deploy.org).
4
+
5
+ ## Usage
6
+ How to use my plugin.
7
+
8
+ ## Installation
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem "deployed"
13
+ ```
14
+
15
+ And then execute:
16
+ ```bash
17
+ $ bundle
18
+ ```
19
+
20
+ Or install it yourself as:
21
+ ```bash
22
+ $ gem install deployed
23
+ ```
24
+
25
+ ## Contributing
26
+ Contribution directions go here.
27
+
28
+ ## License
29
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/deployed .css
@@ -0,0 +1,104 @@
1
+ import 'https://cdn.skypack.dev/@hotwired/turbo-rails'
2
+ import 'https://cdn.skypack.dev/alpine-turbo-drive-adapter'
3
+ import Alpine from 'https://cdn.skypack.dev/alpinejs'
4
+ window.Alpine = Alpine
5
+ Alpine.start()
6
+
7
+ window.execDeployed = (commandToRun) => {
8
+ // Let the frontend know we're starting
9
+ Alpine.store('process').start()
10
+
11
+ let outputContainerEl = document.getElementById('deploy-output')
12
+ let spinnerEl = document.getElementById('spinner')
13
+
14
+ if (outputContainerEl.innerHTML !== '') {
15
+ outputContainerEl.innerHTML += "<div class='py-2'></div>"
16
+ }
17
+
18
+ spinnerEl.classList.remove('hidden')
19
+ var source = new EventSource(`/deployed/execute?command=${commandToRun}`)
20
+
21
+ source.onmessage = (event) => {
22
+ if (!Alpine.store('process').running) {
23
+ source.close()
24
+ } else {
25
+ if (event.data.includes('[Deployed Rails] End transmission')) {
26
+ source.close()
27
+ outputContainerEl.innerHTML += `<div class="text-slate-400 pb-4">Executed: <span class='text-slate-400 font-semibold'>kamal ${commandToRun}</span></div>`
28
+ spinnerEl.classList.add('hidden')
29
+
30
+ // Let the frontend know we're done
31
+ Alpine.store('process').stop()
32
+ } else {
33
+ outputContainerEl.innerHTML += event.data
34
+ }
35
+ }
36
+
37
+ outputContainerEl.scrollIntoView({ behavior: "smooth", block: "end" })
38
+ spinnerEl.scrollIntoView({ behavior: "smooth", block: "end" })
39
+ }
40
+ }
41
+
42
+ window.abortDeployed = () => {
43
+ // Let the frontend know we're starting
44
+ Alpine.store('process').startAbort()
45
+
46
+ let outputContainerEl = document.getElementById('deploy-output')
47
+ let spinnerEl = document.getElementById('spinner')
48
+
49
+ outputContainerEl.innerHTML += `<div class="text-red-400 py-4">Aborting...</div>`
50
+
51
+ var source = new EventSource(`/deployed/cancel`)
52
+
53
+ source.onmessage = (event) => {
54
+ if (event.data.includes('[Deployed Rails] End transmission')) {
55
+ source.close()
56
+
57
+ spinnerEl.classList.add('hidden')
58
+
59
+ // Let the frontend know we're done
60
+ Alpine.store('process').stop()
61
+ Alpine.store('process').resetAbort()
62
+ } else {
63
+ outputContainerEl.innerHTML += event.data
64
+ }
65
+
66
+ outputContainerEl.scrollIntoView({ behavior: "smooth", block: "end" })
67
+ spinnerEl.scrollIntoView({ behavior: "smooth", block: "end" })
68
+ }
69
+ }
70
+
71
+ // Some other JS that probably should be refactored at some point...
72
+ document.addEventListener('DOMContentLoaded', (event) => {
73
+ // Hackish way to refresh git status with turbo frames
74
+ // setInterval(() => {
75
+ // document.getElementById('git-status').reload()
76
+ // }, 2500)
77
+
78
+ // Resizing functionality
79
+ let isResizing = false
80
+ let initialY
81
+ let initialHeight
82
+
83
+ const deployOutputContainer = document.getElementById('deploy-output-container')
84
+ const resizeHandle = document.getElementById('resize-handle')
85
+
86
+ const startResize = (e) => {
87
+ isResizing = true
88
+ initialY = e.clientY
89
+ initialHeight = deployOutputContainer.clientHeight
90
+ }
91
+
92
+ const stopResize = () => { isResizing = false }
93
+
94
+ const resize = (e) => {
95
+ if (isResizing) {
96
+ const deltaY = initialY - e.clientY
97
+ deployOutputContainer.style.height = initialHeight + deltaY + 'px'
98
+ }
99
+ }
100
+
101
+ resizeHandle.addEventListener('mousedown', startResize)
102
+ document.addEventListener('mousemove', resize)
103
+ document.addEventListener('mouseup', stopResize)
104
+ })