hyraft-rule 0.1.0.alpha1 → 0.1.0.alpha2
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/README.md +27 -22
- data/exe/hyraft-rule-db +74 -35
- data/hyraft-rule.gemspec +12 -7
- data/lib/hyraft/rule/disassemble_command.rb +15 -3
- data/lib/hyraft/rule/version.rb +1 -1
- metadata +9 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b937076a72d8bfd0cf0988d5ca46906a18ad338c08659edbea525087d45d1d4
|
|
4
|
+
data.tar.gz: 48d3f56004343a2eb270012b97bde1253bb661e3798e183179ac453947548520
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d50fea795954a932f28614abd6dad757fb5baec3c4ac390a6ec7ebe2ffeeb371d849b06926ae003837139fc3a9a84c9f8c840a61a19235988718c284cd29628
|
|
7
|
+
data.tar.gz: 3a8c9a4d04d361c83ab1652b7479321d2b0378d9bebdb5d8ccb889c3d891a9c9c248c90e1f702ad46d23b793c6ff15c1033e30740ed68a5b268e1b44dcafad6a
|
data/README.md
CHANGED
|
@@ -7,36 +7,36 @@
|
|
|
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
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
- hyraft-rule (standard)
|
|
24
|
+
- hyr-rule (alias)
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
- hyraft-rule-db (standard / database command)
|
|
27
|
+
- hyr-rule-db (alias / database command)
|
|
25
28
|
|
|
26
|
-
```bash
|
|
27
|
-
gem 'hyraft-rule'
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
Install the gem and add to the application's Gemfile by executing:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
bundle install
|
|
34
|
-
```
|
|
35
31
|
|
|
36
32
|
## Usage ( Assemble / Disassemble )
|
|
37
|
-
- hyr-rule
|
|
38
33
|
|
|
39
|
-
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
assemble - Creates blueprint structure for templates, engine, and adapters.
|
|
37
|
+
|
|
38
|
+
disassemble - Deconstructs the project into its core components.
|
|
39
|
+
```
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
# Default web-app
|
|
@@ -51,14 +51,13 @@ hyr-rule assemble {any-folder-name}/users
|
|
|
51
51
|
hyr-rule assemble admin-app/users
|
|
52
52
|
hyr-rule disassemble admin-app/users
|
|
53
53
|
|
|
54
|
-
hyr-rule assemble
|
|
55
|
-
hyr-rule disassemble
|
|
54
|
+
hyr-rule assemble api-app/products
|
|
55
|
+
hyr-rule disassemble api-app/products
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
## Usage ( Engine )
|
|
61
|
-
- hyr-rule
|
|
62
61
|
|
|
63
62
|
Generate:
|
|
64
63
|
|
|
@@ -72,18 +71,22 @@ hyr-rule source article
|
|
|
72
71
|
|
|
73
72
|
```
|
|
74
73
|
|
|
75
|
-
## Usage ( Web Adapter )
|
|
76
|
-
- hyr-rule
|
|
74
|
+
## Usage ( Web Adapter a.k.a Controller )
|
|
77
75
|
|
|
78
76
|
Generate:
|
|
79
77
|
|
|
80
78
|
```bash
|
|
79
|
+
|
|
80
|
+
# Only add the specific web adapter
|
|
81
81
|
hyr-rule web-adapter articles
|
|
82
82
|
hyr-rule web-adapter admin-app/products
|
|
83
|
+
|
|
84
|
+
# Only remove the specific web adapter
|
|
85
|
+
hyr-rule remove-adapter articles
|
|
86
|
+
hyr-rule remove-adapter admin-app/users
|
|
83
87
|
```
|
|
84
88
|
|
|
85
89
|
## Usage ( data-gateway )
|
|
86
|
-
- hyr-rule
|
|
87
90
|
|
|
88
91
|
Generate:
|
|
89
92
|
|
|
@@ -220,11 +223,13 @@ Migrations:
|
|
|
220
223
|
|
|
221
224
|
|
|
222
225
|
|
|
226
|
+
|
|
223
227
|
## Development
|
|
224
228
|
|
|
225
|
-
After checking out the repo, run `
|
|
229
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
|
230
|
+
|
|
231
|
+
Then, run `rake test` to run the tests.
|
|
226
232
|
|
|
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
233
|
|
|
229
234
|
## Contributing
|
|
230
235
|
|
data/exe/hyraft-rule-db
CHANGED
|
@@ -4,6 +4,43 @@
|
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
require 'sequel'
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
# -------------------------------
|
|
9
|
+
# COLOR HELPER METHODS
|
|
10
|
+
# -------------------------------
|
|
11
|
+
module Colorize
|
|
12
|
+
COLORS = {
|
|
13
|
+
red: "\e[31m",
|
|
14
|
+
green: "\e[32m",
|
|
15
|
+
yellow: "\e[33m",
|
|
16
|
+
blue: "\e[34m",
|
|
17
|
+
magenta: "\e[35m",
|
|
18
|
+
cyan: "\e[36m",
|
|
19
|
+
white: "\e[37m",
|
|
20
|
+
bold: "\e[1m",
|
|
21
|
+
reset: "\e[0m"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def colorize(text, color)
|
|
25
|
+
return text unless STDOUT.tty? # Only colorize if terminal supports it
|
|
26
|
+
"#{COLORS[color]}#{text}#{COLORS[:reset]}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Convenience methods
|
|
30
|
+
def red(text); colorize(text, :red); end
|
|
31
|
+
def green(text); colorize(text, :green); end
|
|
32
|
+
def yellow(text); colorize(text, :yellow); end
|
|
33
|
+
def blue(text); colorize(text, :blue); end
|
|
34
|
+
def magenta(text); colorize(text, :magenta); end
|
|
35
|
+
def cyan(text); colorize(text, :cyan); end
|
|
36
|
+
def bold(text); colorize(text, :bold); end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Include color methods in main context
|
|
40
|
+
include Colorize
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
7
44
|
# -------------------------------
|
|
8
45
|
# Helper: find application root
|
|
9
46
|
# -------------------------------
|
|
@@ -65,19 +102,19 @@ def generate_migration(migration_name, *columns)
|
|
|
65
102
|
|
|
66
103
|
File.write(full_path, migration_content)
|
|
67
104
|
|
|
68
|
-
puts "✓ Created migration: #{full_path}"
|
|
69
|
-
puts "Table name detected: #{table_name}" if table_name
|
|
105
|
+
puts green("✓ Created migration: #{full_path}")
|
|
106
|
+
puts cyan("Table name detected: #{table_name}") if table_name
|
|
70
107
|
|
|
71
108
|
if columns.any?
|
|
72
|
-
puts "Columns added: #{columns.join(', ')}"
|
|
109
|
+
puts cyan("Columns added: #{columns.join(', ')}")
|
|
73
110
|
end
|
|
74
111
|
|
|
75
112
|
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"
|
|
113
|
+
puts yellow("To apply this migration, run one of these:")
|
|
114
|
+
puts cyan(" hyr-rule-db migrate") + " # " + green("Development environment (default)")
|
|
115
|
+
puts cyan(" APP_ENV=test hyr-rule-db migrate") + " # " + yellow("For test environment")
|
|
116
|
+
puts cyan(" APP_ENV=development hyr-rule-db migrate") + " # " + blue("For development environment")
|
|
117
|
+
puts cyan(" APP_ENV=production hyr-rule-db migrate") + " # " + red("For production environment")
|
|
81
118
|
end
|
|
82
119
|
|
|
83
120
|
def extract_table_name(migration_name)
|
|
@@ -229,7 +266,7 @@ end
|
|
|
229
266
|
def run_migrations
|
|
230
267
|
migration_files = Dir.glob(File.join(MIGRATIONS_DIR, "[0-9]*_*.rb")).sort
|
|
231
268
|
if migration_files.empty?
|
|
232
|
-
puts "No migration files found in #{MIGRATIONS_DIR}"
|
|
269
|
+
puts yellow("No migration files found in #{MIGRATIONS_DIR}")
|
|
233
270
|
return
|
|
234
271
|
end
|
|
235
272
|
|
|
@@ -255,17 +292,17 @@ def run_migrations
|
|
|
255
292
|
newly_applied = applied_after - applied_before
|
|
256
293
|
|
|
257
294
|
if newly_applied.empty?
|
|
258
|
-
puts "✓ All files migrated successfully: no pending migrations"
|
|
295
|
+
puts green("✓ All files migrated successfully: no pending migrations")
|
|
259
296
|
else
|
|
260
297
|
if newly_applied.size == 1
|
|
261
|
-
puts "✓ Migration applied successfully: #{newly_applied.first}"
|
|
298
|
+
puts green("✓ Migration applied successfully: #{newly_applied.first}")
|
|
262
299
|
else
|
|
263
300
|
puts "✓ #{newly_applied.size} migrations applied successfully:"
|
|
264
301
|
newly_applied.each { |migration| puts " - #{migration}" }
|
|
265
302
|
end
|
|
266
303
|
end
|
|
267
304
|
rescue => e
|
|
268
|
-
puts "✗ Migration failed: #{e.message}"
|
|
305
|
+
puts red("✗ Migration failed: #{e.message}")
|
|
269
306
|
exit 1
|
|
270
307
|
end
|
|
271
308
|
end
|
|
@@ -285,17 +322,18 @@ def rollback_migrations
|
|
|
285
322
|
end
|
|
286
323
|
|
|
287
324
|
def show_status
|
|
288
|
-
|
|
289
|
-
puts "
|
|
325
|
+
|
|
326
|
+
puts bold("Migration Status:")
|
|
327
|
+
puts cyan("Database: #{DB.opts[:database]}")
|
|
290
328
|
|
|
291
329
|
migration_files = Dir.glob(File.join(MIGRATIONS_DIR, "[0-9]*_*.rb")).sort
|
|
292
330
|
|
|
293
331
|
if DB.table_exists?(:schema_migrations)
|
|
294
332
|
applied_migrations = DB[:schema_migrations].order(:filename).map { |r| r[:filename].gsub('.rb', '') }
|
|
295
333
|
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}"
|
|
334
|
+
puts green("Schema migrations table: ✓ created")
|
|
335
|
+
puts cyan("Latest applied migration: #{latest || 'none'}")
|
|
336
|
+
puts cyan("Applied migrations: #{applied_migrations.size} of #{migration_files.size}")
|
|
299
337
|
|
|
300
338
|
# Show pending migrations
|
|
301
339
|
pending_migrations = migration_files.reject do |file|
|
|
@@ -304,32 +342,33 @@ def show_status
|
|
|
304
342
|
end
|
|
305
343
|
|
|
306
344
|
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"
|
|
345
|
+
puts yellow("\nPending migrations:")
|
|
346
|
+
pending_migrations.each { |f| puts cyan(" - #{File.basename(f)}") }
|
|
347
|
+
puts yellow("\nRun one of these to apply pending migrations:")
|
|
348
|
+
puts cyan(" hyr-rule-db migrate") + " # " + green("Development environment (default)")
|
|
349
|
+
puts cyan(" APP_ENV=test hyr-rule-db migrate") + " # " + yellow("For test environment")
|
|
350
|
+
puts cyan(" APP_ENV=development hyr-rule-db migrate") + " # " + blue("For development environment")
|
|
351
|
+
puts cyan(" APP_ENV=production hyr-rule-db migrate") + " # " + red("For production environment")
|
|
314
352
|
else
|
|
315
|
-
puts "✓ All migrations are applied"
|
|
353
|
+
puts green("✓ All migrations are applied")
|
|
316
354
|
end
|
|
317
355
|
else
|
|
318
|
-
puts "Schema migrations table: ○ not created yet"
|
|
319
|
-
puts "Latest applied migration: none"
|
|
356
|
+
puts yellow("Schema migrations table: ○ not created yet")
|
|
357
|
+
puts cyan("Latest applied migration: none")
|
|
320
358
|
|
|
321
359
|
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"
|
|
360
|
+
puts yellow("\nMigration files:")
|
|
361
|
+
migration_files.each { |f| puts cyan(" - #{File.basename(f)}") }
|
|
362
|
+
puts yellow("\nRun one of these to apply pending migrations:")
|
|
363
|
+
puts cyan(" hyr-rule-db migrate") + " # " + green("Development environment")
|
|
364
|
+
puts cyan(" APP_ENV=test hyr-rule-db migrate") + " # " + yellow("For test environment")
|
|
365
|
+
puts cyan(" APP_ENV=development hyr-rule-db migrate") + " # " + blue("For development environment")
|
|
366
|
+
puts cyan(" APP_ENV=production hyr-rule-db migrate") + " # " + red("For production environment")
|
|
329
367
|
else
|
|
330
|
-
puts "No migration files found in #{MIGRATIONS_DIR}"
|
|
368
|
+
puts yellow("No migration files found in #{MIGRATIONS_DIR}")
|
|
331
369
|
end
|
|
332
370
|
end
|
|
371
|
+
|
|
333
372
|
end
|
|
334
373
|
|
|
335
374
|
|
data/hyraft-rule.gemspec
CHANGED
|
@@ -9,14 +9,19 @@ 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
15
|
spec.required_ruby_version = ">= 3.4.0"
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
spec.metadata
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
spec.metadata = {
|
|
20
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/hyraft-rule",
|
|
21
|
+
"source_code_uri" => "https://github.com/demjhonsilver/hyraft-rule",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
20
25
|
|
|
21
26
|
# Manual file listing without git dependency
|
|
22
27
|
# In hyraft-rule.gemspec - update the files section
|
|
@@ -48,7 +53,7 @@ Gem::Specification.new do |spec|
|
|
|
48
53
|
spec.require_paths = ["lib"]
|
|
49
54
|
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
spec.add_development_dependency "
|
|
53
|
-
spec.add_development_dependency "
|
|
56
|
+
# Runtime dependencies
|
|
57
|
+
spec.add_development_dependency "rake", "~> 13.3"
|
|
58
|
+
spec.add_development_dependency "minitest", "~> 5.26"
|
|
54
59
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
1
|
require 'fileutils'
|
|
4
2
|
|
|
5
3
|
module Hyraft
|
|
@@ -20,6 +18,20 @@ module Hyraft
|
|
|
20
18
|
|
|
21
19
|
puts "\e[31m🗑️ COMPLETE Disassembly: Removing ALL '#{@resource_name}' resources\e[0m"
|
|
22
20
|
puts "\e[33m⚠️ WARNING: This will remove engine layer, ALL adapters, and ALL templates!\e[0m"
|
|
21
|
+
puts ""
|
|
22
|
+
puts "This will delete:"
|
|
23
|
+
puts " • Engine layer (sources, circuits, ports)"
|
|
24
|
+
puts " • ALL web adapters (across all app folders)"
|
|
25
|
+
puts " • ALL templates (across all app folders)"
|
|
26
|
+
puts " • Data gateway"
|
|
27
|
+
puts ""
|
|
28
|
+
print "\e[31mAre you sure you want to continue? (yes/NO): \e[0m"
|
|
29
|
+
|
|
30
|
+
confirmation = $stdin.gets.chomp.downcase
|
|
31
|
+
unless confirmation == 'yes'
|
|
32
|
+
puts "\e[32mDisassembly cancelled\e[0m"
|
|
33
|
+
return
|
|
34
|
+
end
|
|
23
35
|
|
|
24
36
|
disassemble_engine_layer
|
|
25
37
|
disassemble_all_adapters
|
|
@@ -29,7 +41,7 @@ module Hyraft
|
|
|
29
41
|
puts "\e[32m✅ Complete Disassembly: ALL '#{@resource_name}' resources removed\e[0m"
|
|
30
42
|
end
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
private
|
|
33
45
|
|
|
34
46
|
def parse_resource_input
|
|
35
47
|
return unless @resource_input
|
data/lib/hyraft/rule/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hyraft-rule
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0.
|
|
4
|
+
version: 0.1.0.alpha2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Demjhon Silver
|
|
@@ -10,34 +10,34 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: rake
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '
|
|
18
|
+
version: '13.3'
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '
|
|
25
|
+
version: '13.3'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
27
|
+
name: minitest
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '5.26'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
40
|
-
description:
|
|
39
|
+
version: '5.26'
|
|
40
|
+
description: This is a standalone command-line interface (CLI) for the Hyraft framework.
|
|
41
41
|
executables:
|
|
42
42
|
- hyr-rule
|
|
43
43
|
- hyr-rule-db
|
|
@@ -70,9 +70,8 @@ homepage: https://github.com/demjhonsilver/hyraft-rule
|
|
|
70
70
|
licenses:
|
|
71
71
|
- MIT
|
|
72
72
|
metadata:
|
|
73
|
-
|
|
73
|
+
documentation_uri: https://www.rubydoc.info/gems/hyraft-rule
|
|
74
74
|
source_code_uri: https://github.com/demjhonsilver/hyraft-rule
|
|
75
|
-
changelog_uri: https://github.com/demjhonsilver/hyraft-rule/blob/main/CHANGELOG.md
|
|
76
75
|
rdoc_options: []
|
|
77
76
|
require_paths:
|
|
78
77
|
- lib
|