hyraft-rule 0.1.0.alpha1 → 1.0.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 +4 -4
- data/CHANGELOG.md +10 -2
- data/README.md +154 -65
- data/exe/hyr-rule +0 -0
- data/exe/hyr-rule-db +0 -0
- data/exe/hyraft-rule +0 -0
- data/exe/hyraft-rule-db +77 -37
- data/hyraft-rule.gemspec +23 -17
- data/lib/hyraft/rule/base/in_api_command.rb +208 -0
- data/lib/hyraft/rule/base/out_data_command.rb +264 -0
- data/lib/hyraft/rule/circuit/engine_command.rb +169 -0
- data/lib/hyraft/rule/circuit/port_command.rb +70 -0
- data/lib/hyraft/rule/command.rb +46 -37
- data/lib/hyraft/rule/connectors/cable_command.rb +133 -0
- data/lib/hyraft/rule/jwt/jwt_command.rb +133 -0
- data/lib/hyraft/rule/router/api_routes_command.rb +93 -0
- data/lib/hyraft/rule/router/web_routes_command.rb +213 -0
- data/lib/hyraft/rule/template/template_command.rb +347 -0
- data/lib/hyraft/rule/version.rb +1 -1
- data/lib/hyraft/rule.rb +9 -17
- metadata +18 -30
- data/lib/hyraft/rule/adapter_exhaust/data_gateway_command.rb +0 -132
- data/lib/hyraft/rule/adapter_request/remove_adapter_command.rb +0 -76
- data/lib/hyraft/rule/adapter_request/web_adapter_command.rb +0 -211
- data/lib/hyraft/rule/assemble_command.rb +0 -98
- data/lib/hyraft/rule/disassemble_command.rb +0 -127
- data/lib/hyraft/rule/engine/circuit_command.rb +0 -82
- data/lib/hyraft/rule/engine/port_command.rb +0 -60
- data/lib/hyraft/rule/engine/source_command.rb +0 -70
- data/lib/hyraft/rule/template_command.rb +0 -102
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ceb5f5d19fd16ef3f5f54d282e81d1e15db13cac65137688889280762ab47a1
|
|
4
|
+
data.tar.gz: 14b7bd672260e3ad84089ed5c3f13282808317b6a564a6f1669a401b820f629f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b76d6da0d1df616cb966c523b900b93e471536a18caed301b605d5adac7ade0535d0e48e5d03076a101a27287cbb36bd8aabdb95fc196ee4d27a4145f1f40f8a
|
|
7
|
+
data.tar.gz: f1e7505c49b11ec307cfc6592bdc8af86cc6f4eb12b7b5bb1dbbb2f6869b8b3f0f1e4137c5b92fa2eb819a06d43eafb1111031845a89c070c7ab75653d5603d9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
-
## [
|
|
3
|
+
## [1.0.0] - 2026-7-12
|
|
4
|
+
### Fixed
|
|
5
|
+
Supports Ruby 4 and above only.
|
|
4
6
|
|
|
5
|
-
-
|
|
7
|
+
## [0.1.0.alpha2] - 2025-11-30
|
|
8
|
+
### Fixed
|
|
9
|
+
- Fixed README documentation
|
|
10
|
+
- Add safety flag to disassemble command
|
|
11
|
+
|
|
12
|
+
## [0.1.0.alpha1] - 2025-11-26
|
|
13
|
+
- Initial release
|
data/README.md
CHANGED
|
@@ -7,96 +7,150 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|

|
|
10
|
+

|
|
10
11
|
|
|
11
12
|
</div>
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
This is a standalone command-line interface (CLI) for the Hyraft framework.
|
|
15
17
|
|
|
16
|
-
# Hyraft Rule - ( CLI ) Command system for Hyraft applications
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
## Syntax ( Command KEY )
|
|
21
|
+
```bash
|
|
22
|
+
|
|
23
|
+
- hyraft-rule (standard)
|
|
24
|
+
- hyr-rule (alias)
|
|
25
|
+
|
|
26
|
+
- hyraft-rule-db (standard / database command)
|
|
27
|
+
- hyr-rule-db (alias / database command)
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
|
|
20
31
|
|
|
21
|
-
##
|
|
32
|
+
## Usage ( in-api )
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
put:
|
|
34
|
+
Generate:
|
|
25
35
|
|
|
26
36
|
```bash
|
|
27
|
-
|
|
37
|
+
hyraft-rule in-api articles title content
|
|
38
|
+
hyraft-rule in-api users name email role
|
|
39
|
+
hyraft-rule in-api products name price stock
|
|
40
|
+
hyraft-rule in-api posts title body author
|
|
28
41
|
```
|
|
42
|
+
## Usage ( out-data )
|
|
29
43
|
|
|
30
|
-
|
|
44
|
+
Generate:
|
|
31
45
|
|
|
32
46
|
```bash
|
|
33
|
-
|
|
47
|
+
|
|
48
|
+
# Generate storage for any resource
|
|
49
|
+
hyraft-rule out-data articles title content
|
|
50
|
+
hyraft-rule out-data users name email password
|
|
51
|
+
hyraft-rule out-data products name price stock quantity
|
|
52
|
+
hyraft-rule out-data comments body author_id post_id
|
|
53
|
+
hyraft-rule out-data posts title content published
|
|
54
|
+
hyraft-rule out-data categories name description
|
|
55
|
+
hyraft-rule out-data tags name
|
|
56
|
+
|
|
34
57
|
```
|
|
35
58
|
|
|
36
|
-
## Usage ( Assemble / Disassemble )
|
|
37
|
-
- hyr-rule
|
|
38
59
|
|
|
39
|
-
Package setup:
|
|
40
60
|
|
|
41
|
-
```bash
|
|
42
|
-
# Default web-app
|
|
43
|
-
hyr-rule assemble articles
|
|
44
|
-
hyr-rule disassemble articles
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
## Usage ( Engine )
|
|
47
63
|
|
|
48
|
-
|
|
64
|
+
Generate:
|
|
49
65
|
|
|
66
|
+
```bash
|
|
67
|
+
# Generate engine with attributes
|
|
68
|
+
hyraft-rule engine articles title content
|
|
50
69
|
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
# With custom target directory
|
|
71
|
+
hyraft-rule engine articles title content ./myapp
|
|
53
72
|
|
|
54
|
-
|
|
55
|
-
|
|
73
|
+
# Without attributes (will show placeholder)
|
|
74
|
+
hyraft-rule engine articles
|
|
56
75
|
```
|
|
57
76
|
|
|
77
|
+
## Usage ( Port )
|
|
78
|
+
|
|
79
|
+
Generate:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Basic usage
|
|
83
|
+
hyraft-rule port articles
|
|
58
84
|
|
|
85
|
+
# Different resources
|
|
86
|
+
hyraft-rule port users
|
|
87
|
+
hyraft-rule port products
|
|
88
|
+
hyraft-rule port comments
|
|
59
89
|
|
|
60
|
-
|
|
61
|
-
-
|
|
90
|
+
# With custom path
|
|
91
|
+
hyraft-rule port articles ./my_project
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Usage ( Cable )
|
|
62
95
|
|
|
63
96
|
Generate:
|
|
64
97
|
|
|
65
98
|
```bash
|
|
99
|
+
# Generate cable for articles
|
|
100
|
+
hyraft-rule cable articles title content
|
|
66
101
|
|
|
67
|
-
|
|
102
|
+
# Generate cable for users
|
|
103
|
+
hyraft-rule cable users name email password
|
|
68
104
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
hyr-rule source article
|
|
105
|
+
# Generate cable for products
|
|
106
|
+
hyraft-rule cable products name price stock
|
|
72
107
|
|
|
108
|
+
# Generate cable for comments
|
|
109
|
+
hyraft-rule cable comments body author_id post_id
|
|
73
110
|
```
|
|
74
111
|
|
|
75
|
-
## Usage (
|
|
76
|
-
- hyr-rule
|
|
112
|
+
## Usage ( JWT key )
|
|
77
113
|
|
|
78
114
|
Generate:
|
|
79
115
|
|
|
80
116
|
```bash
|
|
81
|
-
|
|
82
|
-
|
|
117
|
+
|
|
118
|
+
hyraft-rule jwt generate
|
|
119
|
+
hyraft-rule jwt g
|
|
120
|
+
hyraft-rule jwt show
|
|
121
|
+
hyraft-rule jwt help
|
|
122
|
+
|
|
83
123
|
```
|
|
84
124
|
|
|
85
|
-
## Usage (
|
|
86
|
-
- hyr-rule
|
|
125
|
+
## Usage ( Routes )
|
|
87
126
|
|
|
88
127
|
Generate:
|
|
89
128
|
|
|
90
129
|
```bash
|
|
91
|
-
|
|
92
|
-
|
|
130
|
+
|
|
131
|
+
# Add traditional routes for articles
|
|
132
|
+
hyraft-rule routes articles tra
|
|
133
|
+
|
|
134
|
+
# Add SPA routes for articles
|
|
135
|
+
hyraft-rule routes articles spa
|
|
136
|
+
|
|
137
|
+
# Default is tra
|
|
138
|
+
hyraft-rule routes articles
|
|
139
|
+
|
|
93
140
|
```
|
|
94
141
|
|
|
142
|
+
## Usage ( API Routes )
|
|
95
143
|
|
|
144
|
+
Generate:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
|
|
148
|
+
hyr-rule api-routes articles
|
|
149
|
+
hyraft-rule api-routes articles
|
|
150
|
+
```
|
|
96
151
|
|
|
97
152
|
|
|
98
153
|
## Usage ( Templates )
|
|
99
|
-
- hyr-rule
|
|
100
154
|
|
|
101
155
|
Generate:
|
|
102
156
|
|
|
@@ -109,8 +163,8 @@ hyr-rule template admin-app/users
|
|
|
109
163
|
hyraft-rule template admin-app/users
|
|
110
164
|
```
|
|
111
165
|
|
|
166
|
+
|
|
112
167
|
## Usage ( For Help )
|
|
113
|
-
- hyr-rule
|
|
114
168
|
|
|
115
169
|
Generate:
|
|
116
170
|
|
|
@@ -132,37 +186,37 @@ hyraft-rule -h
|
|
|
132
186
|
|
|
133
187
|
|
|
134
188
|
## Usage ( Database )
|
|
135
|
-
-
|
|
189
|
+
- hyraft-rule-db
|
|
136
190
|
|
|
137
191
|
|
|
138
192
|
Schema:
|
|
139
193
|
|
|
140
194
|
|
|
141
195
|
```bash
|
|
142
|
-
|
|
143
|
-
|
|
196
|
+
hyraft-rule-db generate create_users
|
|
197
|
+
hyraft-rule-db generate add_email_to_users
|
|
144
198
|
|
|
145
199
|
- Migration Generation Schema Examples:
|
|
146
200
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
201
|
+
hyraft-rule-db generate create_users
|
|
202
|
+
hyraft-rule-db generate create_articles
|
|
203
|
+
hyraft-rule-db generate create_products
|
|
204
|
+
hyraft-rule-db generate create_categories
|
|
205
|
+
hyraft-rule-db generate add_image_file_to_articles
|
|
206
|
+
hyraft-rule-db generate add_price_to_products
|
|
207
|
+
hyraft-rule-db generate remove_status_from_posts
|
|
208
|
+
hyraft-rule-db generate drop_old_tables
|
|
155
209
|
|
|
156
210
|
|
|
157
211
|
Examples:
|
|
158
|
-
|
|
212
|
+
hyraft-rule-db generate create_articles title content:text
|
|
159
213
|
|
|
160
|
-
|
|
161
|
-
|
|
214
|
+
hyraft-rule-db generate create_products name:string price:decimal description:text user_id:int
|
|
215
|
+
hyraft-rule-db generate create_users username:string age:int email:string active:bool created_at:datetime
|
|
162
216
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
217
|
+
hyraft-rule-db generate create_products name:string price:decimal description:text user_id:int
|
|
218
|
+
hyraft-rule-db generate create_users username age:int email active:bool
|
|
219
|
+
hyraft-rule-db generate create_articles title content:text published_at:datetime views:int
|
|
166
220
|
|
|
167
221
|
|
|
168
222
|
```
|
|
@@ -182,18 +236,18 @@ Migrations:
|
|
|
182
236
|
|
|
183
237
|
Examples:
|
|
184
238
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
239
|
+
hyraft-rule-db migrate
|
|
240
|
+
hyraft-rule-db status
|
|
241
|
+
hyraft-rule-db rollback
|
|
242
|
+
hyraft-rule-db reset
|
|
243
|
+
hyraft-rule-db help
|
|
190
244
|
|
|
191
245
|
Environment Usage:
|
|
192
246
|
|
|
193
|
-
|
|
194
|
-
APP_ENV=test
|
|
195
|
-
APP_ENV=development
|
|
196
|
-
APP_ENV=production
|
|
247
|
+
hyraft-rule-db migrate # Current environment (run: hyr s thin)
|
|
248
|
+
APP_ENV=test hyraft-rule-db migrate # Test environment (run: APP_ENV=test hyr s thin)
|
|
249
|
+
APP_ENV=development hyraft-rule-db migrate # Development environment (run: APP_ENV=development hyr s thin)
|
|
250
|
+
APP_ENV=production hyraft-rule-db migrate # Production environment (run: APP_ENV=production hyr s thin)
|
|
197
251
|
|
|
198
252
|
Quick Reference:
|
|
199
253
|
|
|
@@ -220,11 +274,46 @@ Migrations:
|
|
|
220
274
|
|
|
221
275
|
|
|
222
276
|
|
|
277
|
+
|
|
223
278
|
## Development
|
|
224
279
|
|
|
225
|
-
After checking out the repo, run `
|
|
280
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
|
281
|
+
|
|
282
|
+
Then, run `rake test` to run the tests.
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
|
|
286
|
+
rake test
|
|
287
|
+
|
|
288
|
+
comment this: FileUtils.rm_rf(TEST_APP_DIR) located at test_helper.rb
|
|
289
|
+
|
|
290
|
+
- To generate files
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
# Run single test file
|
|
294
|
+
rake test TEST=test/hyraft/rule/circuit/port_command_test.rb
|
|
295
|
+
|
|
296
|
+
or
|
|
297
|
+
|
|
298
|
+
ruby -Ilib:test test/hyraft/rule/circuit/port_command_test.rb
|
|
299
|
+
|
|
300
|
+
# Run specific test method
|
|
301
|
+
rake test TEST=test/hyraft/rule/circuit/port_command_test.rb -n test_generates_port_file
|
|
302
|
+
|
|
303
|
+
# Run with pattern
|
|
304
|
+
rake test TEST=test/hyraft/rule/circuit/port_command_test.rb -n /test_generates/
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
rake test TEST=test/hyraft/rule/base/in_api_command_test.rb
|
|
309
|
+
rake test TEST=test/hyraft/rule/circuit/engine_command_test.rb
|
|
310
|
+
rake test TEST=test/hyraft/rule/connectors/cable_command_test.rb
|
|
311
|
+
rake test TEST=test/hyraft/rule/base/out_data_command_test.rb
|
|
312
|
+
|
|
313
|
+
rake test TEST=test/hyraft/rule/jwt/jwt_command_test.rb
|
|
314
|
+
|
|
315
|
+
```
|
|
226
316
|
|
|
227
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
228
317
|
|
|
229
318
|
## Contributing
|
|
230
319
|
|
data/exe/hyr-rule
CHANGED
|
File without changes
|
data/exe/hyr-rule-db
CHANGED
|
File without changes
|
data/exe/hyraft-rule
CHANGED
|
File without changes
|
data/exe/hyraft-rule-db
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
|
+
#hyarft-rule-db.rb
|
|
3
4
|
|
|
4
5
|
require 'fileutils'
|
|
5
6
|
require 'sequel'
|
|
6
7
|
|
|
8
|
+
|
|
9
|
+
# -------------------------------
|
|
10
|
+
# COLOR HELPER METHODS
|
|
11
|
+
# -------------------------------
|
|
12
|
+
module Colorize
|
|
13
|
+
COLORS = {
|
|
14
|
+
red: "\e[31m",
|
|
15
|
+
green: "\e[32m",
|
|
16
|
+
yellow: "\e[33m",
|
|
17
|
+
blue: "\e[34m",
|
|
18
|
+
magenta: "\e[35m",
|
|
19
|
+
cyan: "\e[36m",
|
|
20
|
+
white: "\e[37m",
|
|
21
|
+
bold: "\e[1m",
|
|
22
|
+
reset: "\e[0m"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def colorize(text, color)
|
|
26
|
+
return text unless STDOUT.tty? # Only colorize if terminal supports it
|
|
27
|
+
"#{COLORS[color]}#{text}#{COLORS[:reset]}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Convenience methods
|
|
31
|
+
def red(text); colorize(text, :red); end
|
|
32
|
+
def green(text); colorize(text, :green); end
|
|
33
|
+
def yellow(text); colorize(text, :yellow); end
|
|
34
|
+
def blue(text); colorize(text, :blue); end
|
|
35
|
+
def magenta(text); colorize(text, :magenta); end
|
|
36
|
+
def cyan(text); colorize(text, :cyan); end
|
|
37
|
+
def bold(text); colorize(text, :bold); end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Include color methods in main context
|
|
41
|
+
include Colorize
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
7
45
|
# -------------------------------
|
|
8
46
|
# Helper: find application root
|
|
9
47
|
# -------------------------------
|
|
@@ -29,7 +67,7 @@ $LOAD_PATH.unshift(APP_ROOT) unless $LOAD_PATH.include?(APP_ROOT)
|
|
|
29
67
|
|
|
30
68
|
begin
|
|
31
69
|
require File.join(APP_ROOT, 'boot')
|
|
32
|
-
require File.join(APP_ROOT, '
|
|
70
|
+
require File.join(APP_ROOT, 'setup', 'database', 'sequel_connection')
|
|
33
71
|
rescue LoadError => e
|
|
34
72
|
puts "❌ Error loading dependencies: #{e.message}"
|
|
35
73
|
exit 1
|
|
@@ -44,7 +82,7 @@ rescue => e
|
|
|
44
82
|
exit 1
|
|
45
83
|
end
|
|
46
84
|
|
|
47
|
-
MIGRATIONS_DIR = File.join(APP_ROOT, '
|
|
85
|
+
MIGRATIONS_DIR = File.join(APP_ROOT, 'setup', 'database', 'migrations')
|
|
48
86
|
|
|
49
87
|
# -------------------------------
|
|
50
88
|
# Generate Migration Methods
|
|
@@ -65,19 +103,19 @@ def generate_migration(migration_name, *columns)
|
|
|
65
103
|
|
|
66
104
|
File.write(full_path, migration_content)
|
|
67
105
|
|
|
68
|
-
puts "✓ Created migration: #{full_path}"
|
|
69
|
-
puts "Table name detected: #{table_name}" if table_name
|
|
106
|
+
puts green("✓ Created migration: #{full_path}")
|
|
107
|
+
puts cyan("Table name detected: #{table_name}") if table_name
|
|
70
108
|
|
|
71
109
|
if columns.any?
|
|
72
|
-
puts "Columns added: #{columns.join(', ')}"
|
|
110
|
+
puts cyan("Columns added: #{columns.join(', ')}")
|
|
73
111
|
end
|
|
74
112
|
|
|
75
113
|
puts ""
|
|
76
|
-
puts "To apply this migration, run one of these:"
|
|
77
|
-
puts " hyr-rule-db migrate # Development environment (default)"
|
|
78
|
-
puts " APP_ENV=test hyr-rule-db migrate # For test environment"
|
|
79
|
-
puts " APP_ENV=development hyr-rule-db migrate # For development environment"
|
|
80
|
-
puts " APP_ENV=production hyr-rule-db migrate # For production environment"
|
|
114
|
+
puts yellow("To apply this migration, run one of these:")
|
|
115
|
+
puts cyan(" hyr-rule-db migrate") + " # " + green("Development environment (default)")
|
|
116
|
+
puts cyan(" APP_ENV=test hyr-rule-db migrate") + " # " + yellow("For test environment")
|
|
117
|
+
puts cyan(" APP_ENV=development hyr-rule-db migrate") + " # " + blue("For development environment")
|
|
118
|
+
puts cyan(" APP_ENV=production hyr-rule-db migrate") + " # " + red("For production environment")
|
|
81
119
|
end
|
|
82
120
|
|
|
83
121
|
def extract_table_name(migration_name)
|
|
@@ -229,7 +267,7 @@ end
|
|
|
229
267
|
def run_migrations
|
|
230
268
|
migration_files = Dir.glob(File.join(MIGRATIONS_DIR, "[0-9]*_*.rb")).sort
|
|
231
269
|
if migration_files.empty?
|
|
232
|
-
puts "No migration files found in #{MIGRATIONS_DIR}"
|
|
270
|
+
puts yellow("No migration files found in #{MIGRATIONS_DIR}")
|
|
233
271
|
return
|
|
234
272
|
end
|
|
235
273
|
|
|
@@ -255,17 +293,17 @@ def run_migrations
|
|
|
255
293
|
newly_applied = applied_after - applied_before
|
|
256
294
|
|
|
257
295
|
if newly_applied.empty?
|
|
258
|
-
puts "✓ All files migrated successfully: no pending migrations"
|
|
296
|
+
puts green("✓ All files migrated successfully: no pending migrations")
|
|
259
297
|
else
|
|
260
298
|
if newly_applied.size == 1
|
|
261
|
-
puts "✓ Migration applied successfully: #{newly_applied.first}"
|
|
299
|
+
puts green("✓ Migration applied successfully: #{newly_applied.first}")
|
|
262
300
|
else
|
|
263
301
|
puts "✓ #{newly_applied.size} migrations applied successfully:"
|
|
264
302
|
newly_applied.each { |migration| puts " - #{migration}" }
|
|
265
303
|
end
|
|
266
304
|
end
|
|
267
305
|
rescue => e
|
|
268
|
-
puts "✗ Migration failed: #{e.message}"
|
|
306
|
+
puts red("✗ Migration failed: #{e.message}")
|
|
269
307
|
exit 1
|
|
270
308
|
end
|
|
271
309
|
end
|
|
@@ -285,17 +323,18 @@ def rollback_migrations
|
|
|
285
323
|
end
|
|
286
324
|
|
|
287
325
|
def show_status
|
|
288
|
-
|
|
289
|
-
puts "
|
|
326
|
+
|
|
327
|
+
puts bold("Migration Status:")
|
|
328
|
+
puts cyan("Database: #{DB.opts[:database]}")
|
|
290
329
|
|
|
291
330
|
migration_files = Dir.glob(File.join(MIGRATIONS_DIR, "[0-9]*_*.rb")).sort
|
|
292
331
|
|
|
293
332
|
if DB.table_exists?(:schema_migrations)
|
|
294
333
|
applied_migrations = DB[:schema_migrations].order(:filename).map { |r| r[:filename].gsub('.rb', '') }
|
|
295
334
|
latest = applied_migrations.last
|
|
296
|
-
puts "Schema migrations table: ✓ created"
|
|
297
|
-
puts "Latest applied migration: #{latest || 'none'}"
|
|
298
|
-
puts "Applied migrations: #{applied_migrations.size} of #{migration_files.size}"
|
|
335
|
+
puts green("Schema migrations table: ✓ created")
|
|
336
|
+
puts cyan("Latest applied migration: #{latest || 'none'}")
|
|
337
|
+
puts cyan("Applied migrations: #{applied_migrations.size} of #{migration_files.size}")
|
|
299
338
|
|
|
300
339
|
# Show pending migrations
|
|
301
340
|
pending_migrations = migration_files.reject do |file|
|
|
@@ -304,32 +343,33 @@ def show_status
|
|
|
304
343
|
end
|
|
305
344
|
|
|
306
345
|
if pending_migrations.any?
|
|
307
|
-
puts "\nPending migrations:"
|
|
308
|
-
pending_migrations.each { |f| puts " - #{File.basename(f)}" }
|
|
309
|
-
puts "\nRun one of these to apply pending migrations:"
|
|
310
|
-
puts " hyr-rule-db migrate # Development environment (default)"
|
|
311
|
-
puts " APP_ENV=test hyr-rule-db migrate # For test environment"
|
|
312
|
-
puts " APP_ENV=development hyr-rule-db migrate # For development environment"
|
|
313
|
-
puts " APP_ENV=production hyr-rule-db migrate # For production environment"
|
|
346
|
+
puts yellow("\nPending migrations:")
|
|
347
|
+
pending_migrations.each { |f| puts cyan(" - #{File.basename(f)}") }
|
|
348
|
+
puts yellow("\nRun one of these to apply pending migrations:")
|
|
349
|
+
puts cyan(" hyr-rule-db migrate") + " # " + green("Development environment (default)")
|
|
350
|
+
puts cyan(" APP_ENV=test hyr-rule-db migrate") + " # " + yellow("For test environment")
|
|
351
|
+
puts cyan(" APP_ENV=development hyr-rule-db migrate") + " # " + blue("For development environment")
|
|
352
|
+
puts cyan(" APP_ENV=production hyr-rule-db migrate") + " # " + red("For production environment")
|
|
314
353
|
else
|
|
315
|
-
puts "✓ All migrations are applied"
|
|
354
|
+
puts green("✓ All migrations are applied")
|
|
316
355
|
end
|
|
317
356
|
else
|
|
318
|
-
puts "Schema migrations table: ○ not created yet"
|
|
319
|
-
puts "Latest applied migration: none"
|
|
357
|
+
puts yellow("Schema migrations table: ○ not created yet")
|
|
358
|
+
puts cyan("Latest applied migration: none")
|
|
320
359
|
|
|
321
360
|
if migration_files.any?
|
|
322
|
-
puts "\nMigration files:"
|
|
323
|
-
migration_files.each { |f| puts " - #{File.basename(f)}" }
|
|
324
|
-
puts "\nRun one of these to apply pending migrations:"
|
|
325
|
-
puts " hyr-rule-db migrate #
|
|
326
|
-
puts " APP_ENV=test hyr-rule-db migrate # For test environment"
|
|
327
|
-
puts " APP_ENV=development hyr-rule-db migrate # For development environment"
|
|
328
|
-
puts " APP_ENV=production hyr-rule-db migrate # For production environment"
|
|
361
|
+
puts yellow("\nMigration files:")
|
|
362
|
+
migration_files.each { |f| puts cyan(" - #{File.basename(f)}") }
|
|
363
|
+
puts yellow("\nRun one of these to apply pending migrations:")
|
|
364
|
+
puts cyan(" hyr-rule-db migrate") + " # " + green("Development environment")
|
|
365
|
+
puts cyan(" APP_ENV=test hyr-rule-db migrate") + " # " + yellow("For test environment")
|
|
366
|
+
puts cyan(" APP_ENV=development hyr-rule-db migrate") + " # " + blue("For development environment")
|
|
367
|
+
puts cyan(" APP_ENV=production hyr-rule-db migrate") + " # " + red("For production environment")
|
|
329
368
|
else
|
|
330
|
-
puts "No migration files found in #{MIGRATIONS_DIR}"
|
|
369
|
+
puts yellow("No migration files found in #{MIGRATIONS_DIR}")
|
|
331
370
|
end
|
|
332
371
|
end
|
|
372
|
+
|
|
333
373
|
end
|
|
334
374
|
|
|
335
375
|
|
data/hyraft-rule.gemspec
CHANGED
|
@@ -9,14 +9,20 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
spec.summary = "Hyraft Rule - Command system for Hyraft applications"
|
|
12
|
-
spec.description = "
|
|
12
|
+
spec.description = "This is a standalone command-line interface (CLI) for the Hyraft framework."
|
|
13
13
|
spec.homepage = "https://github.com/demjhonsilver/hyraft-rule"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
-
spec.required_ruby_version = ">=
|
|
15
|
+
spec.required_ruby_version = ">= 4.0.0"
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
spec.metadata
|
|
19
|
-
|
|
17
|
+
|
|
18
|
+
spec.metadata = {
|
|
19
|
+
"homepage_uri" => "https://github.com/demjhonsilver/hyraft-rule",
|
|
20
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/hyraft-rule",
|
|
21
|
+
"source_code_uri" => "https://github.com/demjhonsilver/hyraft-rule/tree/main",
|
|
22
|
+
"changelog_uri" => "https://github.com/demjhonsilver/hyraft-rule/blob/main/CHANGELOG.md"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
20
26
|
|
|
21
27
|
# Manual file listing without git dependency
|
|
22
28
|
# In hyraft-rule.gemspec - update the files section
|
|
@@ -28,15 +34,15 @@ Gem::Specification.new do |spec|
|
|
|
28
34
|
"lib/hyraft/rule.rb",
|
|
29
35
|
"lib/hyraft/rule/version.rb",
|
|
30
36
|
"lib/hyraft/rule/command.rb",
|
|
31
|
-
"lib/hyraft/rule/
|
|
32
|
-
"lib/hyraft/rule/
|
|
33
|
-
"lib/hyraft/rule/
|
|
34
|
-
"lib/hyraft/rule/
|
|
35
|
-
"lib/hyraft/rule/
|
|
36
|
-
"lib/hyraft/rule/
|
|
37
|
-
"lib/hyraft/rule/
|
|
38
|
-
"lib/hyraft/rule/
|
|
39
|
-
|
|
37
|
+
"lib/hyraft/rule/base/in_api_command.rb",
|
|
38
|
+
"lib/hyraft/rule/base/out_data_command.rb",
|
|
39
|
+
"lib/hyraft/rule/connectors/cable_command.rb",
|
|
40
|
+
"lib/hyraft/rule/circuit/port_command.rb",
|
|
41
|
+
"lib/hyraft/rule/circuit/engine_command.rb",
|
|
42
|
+
"lib/hyraft/rule/router/web_routes_command.rb",
|
|
43
|
+
"lib/hyraft/rule/router/api_routes_command.rb",
|
|
44
|
+
"lib/hyraft/rule/template/template_command.rb",
|
|
45
|
+
"lib/hyraft/rule/jwt/jwt_command.rb",
|
|
40
46
|
"LICENSE.txt",
|
|
41
47
|
"README.md",
|
|
42
48
|
"CHANGELOG.md",
|
|
@@ -48,7 +54,7 @@ Gem::Specification.new do |spec|
|
|
|
48
54
|
spec.require_paths = ["lib"]
|
|
49
55
|
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
spec.add_development_dependency "
|
|
53
|
-
spec.add_development_dependency "
|
|
57
|
+
# Runtime dependencies
|
|
58
|
+
spec.add_development_dependency "rake", "~> 13.3"
|
|
59
|
+
# spec.add_development_dependency "minitest", "~> 5.26"
|
|
54
60
|
end
|