This is a standalone command-line interface (CLI) for the Hyraft framework.
Syntax ( Command KEY )
- hyraft-rule (standard)
- hyr-rule (alias)
- hyraft-rule-db (standard / database command)
- hyr-rule-db (alias / database command)
Usage ( in-api )
Generate:
hyraft-rule in-api articles title content
hyraft-rule in-api users name email role
hyraft-rule in-api products name price stock
hyraft-rule in-api posts title body author
Usage ( out-data )
Generate:
# Generate storage for any resource
hyraft-rule out-data articles title content
hyraft-rule out-data users name email password
hyraft-rule out-data products name price stock quantity
hyraft-rule out-data comments body author_id post_id
hyraft-rule out-data posts title content published
hyraft-rule out-data categories name description
hyraft-rule out-data tags name
Usage ( Engine )
Generate:
# Generate engine with attributes
hyraft-rule engine articles title content
# With custom target directory
hyraft-rule engine articles title content ./myapp
# Without attributes (will show placeholder)
hyraft-rule engine articles
Usage ( Port )
Generate:
# Basic usage
hyraft-rule port articles
# Different resources
hyraft-rule port users
hyraft-rule port products
hyraft-rule port comments
# With custom path
hyraft-rule port articles ./my_project
Usage ( Cable )
Generate:
# Generate cable for articles
hyraft-rule cable articles title content
# Generate cable for users
hyraft-rule cable users name email password
# Generate cable for products
hyraft-rule cable products name price stock
# Generate cable for comments
hyraft-rule cable comments body author_id post_id
Usage ( JWT key )
Generate:
hyraft-rule jwt generate
hyraft-rule jwt g
hyraft-rule jwt show
hyraft-rule jwt help
Usage ( Routes )
Generate:
# Add traditional routes for articles
hyraft-rule routes articles tra
# Add SPA routes for articles
hyraft-rule routes articles spa
# Default is tra
hyraft-rule routes articles
Usage ( API Routes )
Generate:
hyr-rule api-routes articles
hyraft-rule api-routes articles
Usage ( Templates )
Generate:
hyr-rule template articles
hyraft-rule template articles
hyr-rule template admin-app/users
hyraft-rule template admin-app/users
Usage ( For Help )
Generate:
hyr-rule h
hyr-rule help
hyr-rule -h
hyraft-rule h
hyraft-rule help
hyraft-rule -h
Usage ( Database )
- hyraft-rule-db
Schema:
hyraft-rule-db generate create_users
hyraft-rule-db generate add_email_to_users
- Migration Generation Schema Examples:
hyraft-rule-db generate create_users
hyraft-rule-db generate create_articles
hyraft-rule-db generate create_products
hyraft-rule-db generate create_categories
hyraft-rule-db generate add_image_file_to_articles
hyraft-rule-db generate add_price_to_products
hyraft-rule-db generate remove_status_from_posts
hyraft-rule-db generate drop_old_tables
Examples:
hyraft-rule-db generate create_articles title content:text
hyraft-rule-db generate create_products name:string price:decimal description:text user_id:int
hyraft-rule-db generate create_users username:string age:int email:string active:bool created_at:datetime
hyraft-rule-db generate create_products name:string price:decimal description:text user_id:int
hyraft-rule-db generate create_users username age:int email active:bool
hyraft-rule-db generate create_articles title content:text published_at:datetime views:int
Migrations:
Hyraft Rule Database Commands
Commands:
migrate, up - Run all pending migrations
rollback, down - Rollback all migrations
status - Show migration status
reset - Rollback and re-run all migrations
generate <name> - Create a new migration file
help - Show this help
Examples:
hyraft-rule-db migrate
hyraft-rule-db status
hyraft-rule-db rollback
hyraft-rule-db reset
hyraft-rule-db help
Environment Usage:
hyraft-rule-db migrate # Current environment (run: hyr s thin)
APP_ENV=test hyraft-rule-db migrate # Test environment (run: APP_ENV=test hyr s thin)
APP_ENV=development hyraft-rule-db migrate # Development environment (run: APP_ENV=development hyr s thin)
APP_ENV=production hyraft-rule-db migrate # Production environment (run: APP_ENV=production hyr s thin)
Quick Reference:
# Generate and run migrations for a new table
hyr-rule-db generate create_users
hyr-rule-db migrate
# Add a column to existing table
hyr-rule-db generate add_email_to_users
hyr-rule-db migrate
# Check what needs to be applied
hyr-rule-db status
# Rollback if something went wrong
hyr-rule-db rollback
Development
After checking out the repo, run bundle install to install dependencies.
Then, run rake test to run the tests.
rake test
comment this: FileUtils.rm_rf(TEST_APP_DIR) located at test_helper.rb
- To generate files
# Run single test file
rake test TEST=test/hyraft/rule/circuit/port_command_test.rb
or
ruby -Ilib:test test/hyraft/rule/circuit/port_command_test.rb
# Run specific test method
rake test TEST=test/hyraft/rule/circuit/port_command_test.rb -n test_generates_port_file
# Run with pattern
rake test TEST=test/hyraft/rule/circuit/port_command_test.rb -n /test_generates/
rake test TEST=test/hyraft/rule/base/in_api_command_test.rb
rake test TEST=test/hyraft/rule/circuit/engine_command_test.rb
rake test TEST=test/hyraft/rule/connectors/cable_command_test.rb
rake test TEST=test/hyraft/rule/base/out_data_command_test.rb
rake test TEST=test/hyraft/rule/jwt/jwt_command_test.rb
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/demjhonsilver/hyraft-rule. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Hyraft::Rule project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.