belt 0.1.8 → 0.1.9
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/belt/cli/deploy_command.rb +40 -0
- data/lib/belt/cli/destroy_command.rb +8 -28
- data/lib/belt/cli/environment_command.rb +4 -12
- data/lib/belt/cli/frontend_command.rb +11 -13
- data/lib/belt/cli/frontend_setup_command.rb +14 -55
- data/lib/belt/cli/generate_command.rb +73 -10
- data/lib/belt/cli/new_command.rb +82 -33
- data/lib/belt/cli/setup_command.rb +2 -8
- data/lib/belt/cli/tables_command.rb +16 -21
- data/lib/belt/version.rb +1 -1
- data/lib/templates/environment/backend.tf.erb +2 -2
- data/lib/templates/environment/main.tf.erb +14 -18
- data/lib/templates/environment/outputs.tf.erb +28 -3
- data/lib/templates/environment/terraform.tfvars.erb +5 -0
- data/lib/templates/environment/variables.tf.erb +6 -0
- data/lib/templates/module/dns.tf.erb +83 -0
- data/lib/templates/module/frontend.tf.erb +179 -0
- data/lib/templates/module/main.tf.erb +42 -0
- data/lib/templates/module/outputs.tf.erb +24 -0
- data/lib/templates/module/variables.tf.erb +27 -0
- data/lib/templates/views/Form.jsx.erb +63 -7
- data/lib/templates/views/Index.jsx.erb +41 -10
- data/lib/templates/views/Show.jsx.erb +12 -2
- metadata +6 -1
|
@@ -3,7 +3,13 @@ import { Link } from 'react-router-dom'
|
|
|
3
3
|
|
|
4
4
|
export default function <%= @class_name %>Form({ initialValues = {}, onSubmit, submitLabel = 'Create' }) {
|
|
5
5
|
<% @fields.each do |field| -%>
|
|
6
|
+
<% if field[:type] == 'boolean' -%>
|
|
7
|
+
const [<%= field[:name] %>, set<%= field[:name].split('_').map(&:capitalize).join %>] = useState(initialValues.<%= field[:name] %> || false)
|
|
8
|
+
<% elsif field[:type] == 'integer' || field[:type] == 'float' -%>
|
|
9
|
+
const [<%= field[:name] %>, set<%= field[:name].split('_').map(&:capitalize).join %>] = useState(initialValues.<%= field[:name] %> ?? '')
|
|
10
|
+
<% else -%>
|
|
6
11
|
const [<%= field[:name] %>, set<%= field[:name].split('_').map(&:capitalize).join %>] = useState(initialValues.<%= field[:name] %> || '')
|
|
12
|
+
<% end -%>
|
|
7
13
|
<% end -%>
|
|
8
14
|
|
|
9
15
|
function handleSubmit(e) {
|
|
@@ -15,20 +21,70 @@ export default function <%= @class_name %>Form({ initialValues = {}, onSubmit, s
|
|
|
15
21
|
<form onSubmit={handleSubmit}>
|
|
16
22
|
<% @fields.each do |field| -%>
|
|
17
23
|
<div style={{ marginBottom: '1rem' }}>
|
|
18
|
-
<label style={{ display: 'block', marginBottom: '0.25rem' }}><%= field[:name].split('_').map(&:capitalize).join(' ') %></label>
|
|
19
|
-
<%
|
|
24
|
+
<label style={{ display: 'block', marginBottom: '0.25rem', fontWeight: 500 }}><%= field[:name].split('_').map(&:capitalize).join(' ') %></label>
|
|
25
|
+
<% case field[:type] -%>
|
|
26
|
+
<% when 'text' -%>
|
|
20
27
|
<textarea value={<%= field[:name] %>} onChange={e => set<%= field[:name].split('_').map(&:capitalize).join %>(e.target.value)}
|
|
21
|
-
rows={6} style={{ width: '100%' }} />
|
|
28
|
+
rows={6} style={{ width: '100%', padding: '0.5rem', boxSizing: 'border-box' }} />
|
|
29
|
+
<% when 'boolean' -%>
|
|
30
|
+
<label style={{ display: 'inline-flex', alignItems: 'center', cursor: 'pointer', gap: '0.5rem' }}>
|
|
31
|
+
<span style={{
|
|
32
|
+
position: 'relative',
|
|
33
|
+
display: 'inline-block',
|
|
34
|
+
width: '44px',
|
|
35
|
+
height: '24px',
|
|
36
|
+
borderRadius: '12px',
|
|
37
|
+
backgroundColor: <%= field[:name] %> ? '#4f46e5' : '#d1d5db',
|
|
38
|
+
transition: 'background-color 0.2s'
|
|
39
|
+
}}>
|
|
40
|
+
<span style={{
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: '2px',
|
|
43
|
+
left: <%= field[:name] %> ? '22px' : '2px',
|
|
44
|
+
width: '20px',
|
|
45
|
+
height: '20px',
|
|
46
|
+
borderRadius: '50%',
|
|
47
|
+
backgroundColor: '#fff',
|
|
48
|
+
transition: 'left 0.2s',
|
|
49
|
+
boxShadow: '0 1px 3px rgba(0,0,0,0.2)'
|
|
50
|
+
}} />
|
|
51
|
+
</span>
|
|
52
|
+
<input type="checkbox" checked={<%= field[:name] %>}
|
|
53
|
+
onChange={e => set<%= field[:name].split('_').map(&:capitalize).join %>(e.target.checked)}
|
|
54
|
+
style={{ position: 'absolute', opacity: 0, width: 0, height: 0 }} />
|
|
55
|
+
<span style={{ fontSize: '0.875rem', color: '#6b7280' }}>{<%= field[:name] %> ? 'Yes' : 'No'}</span>
|
|
56
|
+
</label>
|
|
57
|
+
<% when 'date' -%>
|
|
58
|
+
<input type="date" value={<%= field[:name] %>} onChange={e => set<%= field[:name].split('_').map(&:capitalize).join %>(e.target.value)}
|
|
59
|
+
style={{ width: '100%', padding: '0.5rem', boxSizing: 'border-box' }} />
|
|
60
|
+
<% when 'datetime' -%>
|
|
61
|
+
<input type="datetime-local" value={<%= field[:name] %>} onChange={e => set<%= field[:name].split('_').map(&:capitalize).join %>(e.target.value)}
|
|
62
|
+
style={{ width: '100%', padding: '0.5rem', boxSizing: 'border-box' }} />
|
|
63
|
+
<% when 'integer' -%>
|
|
64
|
+
<input type="number" value={<%= field[:name] %>} onChange={e => set<%= field[:name].split('_').map(&:capitalize).join %>(e.target.value)}
|
|
65
|
+
step="1" style={{ width: '100%', padding: '0.5rem', boxSizing: 'border-box' }} />
|
|
66
|
+
<% when 'float' -%>
|
|
67
|
+
<input type="number" value={<%= field[:name] %>} onChange={e => set<%= field[:name].split('_').map(&:capitalize).join %>(e.target.value)}
|
|
68
|
+
step="any" style={{ width: '100%', padding: '0.5rem', boxSizing: 'border-box' }} />
|
|
22
69
|
<% else -%>
|
|
23
70
|
<input type="text" value={<%= field[:name] %>} onChange={e => set<%= field[:name].split('_').map(&:capitalize).join %>(e.target.value)}
|
|
24
|
-
style={{ width: '100%', padding: '0.5rem' }} />
|
|
71
|
+
style={{ width: '100%', padding: '0.5rem', boxSizing: 'border-box' }} />
|
|
25
72
|
<% end -%>
|
|
26
73
|
</div>
|
|
27
74
|
<% end -%>
|
|
28
75
|
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
76
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem', marginTop: '1.5rem' }}>
|
|
77
|
+
<button type="submit" style={{
|
|
78
|
+
padding: '0.5rem 1.5rem',
|
|
79
|
+
backgroundColor: '#4f46e5',
|
|
80
|
+
color: '#fff',
|
|
81
|
+
border: 'none',
|
|
82
|
+
borderRadius: '0.375rem',
|
|
83
|
+
cursor: 'pointer',
|
|
84
|
+
fontWeight: 500
|
|
85
|
+
}}>{submitLabel}</button>
|
|
86
|
+
<Link to="/<%= @resource_name %>" style={{ color: '#4f46e5' }}>Cancel</Link>
|
|
87
|
+
</div>
|
|
32
88
|
</form>
|
|
33
89
|
)
|
|
34
90
|
}
|
|
@@ -18,21 +18,52 @@ export default function <%= @class_name %>sIndex() {
|
|
|
18
18
|
<main style={{ padding: '2rem', maxWidth: '800px', margin: '0 auto' }}>
|
|
19
19
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
|
20
20
|
<h1><%= @class_name %>s</h1>
|
|
21
|
-
<Link to="/<%= @resource_name %>/new"
|
|
21
|
+
<Link to="/<%= @resource_name %>/new" style={{
|
|
22
|
+
padding: '0.5rem 1rem',
|
|
23
|
+
backgroundColor: '#4f46e5',
|
|
24
|
+
color: '#fff',
|
|
25
|
+
borderRadius: '0.375rem',
|
|
26
|
+
textDecoration: 'none',
|
|
27
|
+
fontWeight: 500
|
|
28
|
+
}}>New <%= @class_name %></Link>
|
|
22
29
|
</div>
|
|
23
30
|
|
|
24
31
|
{<%= @resource_name %>.length === 0 ? (
|
|
25
32
|
<p>No <%= @resource_name %> yet.</p>
|
|
26
33
|
) : (
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', marginTop: '1rem' }}>
|
|
35
|
+
<thead>
|
|
36
|
+
<tr style={{ borderBottom: '2px solid #e5e7eb', textAlign: 'left' }}>
|
|
37
|
+
<% @fields.each do |field| -%>
|
|
38
|
+
<th style={{ padding: '0.5rem' }}><%= field[:name].split('_').map(&:capitalize).join(' ') %></th>
|
|
39
|
+
<% end -%>
|
|
40
|
+
<th style={{ padding: '0.5rem' }}></th>
|
|
41
|
+
</tr>
|
|
42
|
+
</thead>
|
|
43
|
+
<tbody>
|
|
44
|
+
{<%= @resource_name %>.map(<%= @singular_name %> => (
|
|
45
|
+
<tr key={<%= @singular_name %>.id} style={{ borderBottom: '1px solid #e5e7eb' }}>
|
|
46
|
+
<% @fields.each do |field| -%>
|
|
47
|
+
<% case field[:type] -%>
|
|
48
|
+
<% when 'boolean' -%>
|
|
49
|
+
<td style={{ padding: '0.5rem' }}>{<%= @singular_name %>.<%= field[:name] %> ? '✓' : '✗'}</td>
|
|
50
|
+
<% when 'date' -%>
|
|
51
|
+
<td style={{ padding: '0.5rem' }}>{<%= @singular_name %>.<%= field[:name] %> ? new Date(<%= @singular_name %>.<%= field[:name] %>).toLocaleDateString() : '—'}</td>
|
|
52
|
+
<% when 'datetime' -%>
|
|
53
|
+
<td style={{ padding: '0.5rem' }}>{<%= @singular_name %>.<%= field[:name] %> ? new Date(<%= @singular_name %>.<%= field[:name] %>).toLocaleString() : '—'}</td>
|
|
54
|
+
<% when 'text' -%>
|
|
55
|
+
<td style={{ padding: '0.5rem', maxWidth: '200px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{<%= @singular_name %>.<%= field[:name] %>}</td>
|
|
56
|
+
<% else -%>
|
|
57
|
+
<td style={{ padding: '0.5rem' }}>{<%= @singular_name %>.<%= field[:name] %>}</td>
|
|
58
|
+
<% end -%>
|
|
59
|
+
<% end -%>
|
|
60
|
+
<td style={{ padding: '0.5rem' }}>
|
|
61
|
+
<Link to={`/<%= @resource_name %>/${<%= @singular_name %>.id}`}>Show</Link>
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
))}
|
|
65
|
+
</tbody>
|
|
66
|
+
</table>
|
|
36
67
|
)}
|
|
37
68
|
</main>
|
|
38
69
|
)
|
|
@@ -27,8 +27,18 @@ export default function <%= @class_name %>Show() {
|
|
|
27
27
|
<main style={{ padding: '2rem', maxWidth: '800px', margin: '0 auto' }}>
|
|
28
28
|
<Link to="/<%= @resource_name %>">← Back to <%= @resource_name %></Link>
|
|
29
29
|
<% @fields.each do |field| -%>
|
|
30
|
-
<%
|
|
31
|
-
|
|
30
|
+
<% case field[:type] -%>
|
|
31
|
+
<% when 'text' -%>
|
|
32
|
+
<div style={{ margin: '1rem 0' }}>
|
|
33
|
+
<strong><%= field[:name].split('_').map(&:capitalize).join(' ') %></strong>
|
|
34
|
+
<div style={{ whiteSpace: 'pre-wrap', marginTop: '0.25rem' }}>{<%= @singular_name %>.<%= field[:name] %>}</div>
|
|
35
|
+
</div>
|
|
36
|
+
<% when 'boolean' -%>
|
|
37
|
+
<p><strong><%= field[:name].split('_').map(&:capitalize).join(' ') %>:</strong> {<%= @singular_name %>.<%= field[:name] %> ? 'Yes' : 'No'}</p>
|
|
38
|
+
<% when 'date' -%>
|
|
39
|
+
<p><strong><%= field[:name].split('_').map(&:capitalize).join(' ') %>:</strong> {<%= @singular_name %>.<%= field[:name] %> ? new Date(<%= @singular_name %>.<%= field[:name] %>).toLocaleDateString() : '—'}</p>
|
|
40
|
+
<% when 'datetime' -%>
|
|
41
|
+
<p><strong><%= field[:name].split('_').map(&:capitalize).join(' ') %>:</strong> {<%= @singular_name %>.<%= field[:name] %> ? new Date(<%= @singular_name %>.<%= field[:name] %>).toLocaleString() : '—'}</p>
|
|
32
42
|
<% else -%>
|
|
33
43
|
<p><strong><%= field[:name].split('_').map(&:capitalize).join(' ') %>:</strong> {<%= @singular_name %>.<%= field[:name] %>}</p>
|
|
34
44
|
<% end -%>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: belt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stowzilla
|
|
@@ -121,6 +121,11 @@ files:
|
|
|
121
121
|
- lib/templates/frontend_infra/frontend.tf.erb
|
|
122
122
|
- lib/templates/generate/controller.rb.erb
|
|
123
123
|
- lib/templates/generate/model.rb.erb
|
|
124
|
+
- lib/templates/module/dns.tf.erb
|
|
125
|
+
- lib/templates/module/frontend.tf.erb
|
|
126
|
+
- lib/templates/module/main.tf.erb
|
|
127
|
+
- lib/templates/module/outputs.tf.erb
|
|
128
|
+
- lib/templates/module/variables.tf.erb
|
|
124
129
|
- lib/templates/new_app/AGENTS.md.erb
|
|
125
130
|
- lib/templates/new_app/Gemfile.erb
|
|
126
131
|
- lib/templates/new_app/README.md.erb
|