Class: RosettAi::Thor::Tasks::Project
- Inherits:
-
Thor
- Object
- Thor
- RosettAi::Thor::Tasks::Project
- Defined in:
- lib/rosett_ai/thor/tasks/project.rb
Overview
CLI task for rai project — project lifecycle management.
Provides commands for template application, drift detection, upstream synchronization, and project health reporting.
Instance Method Summary collapse
- #apply_template(name = nil) ⇒ Object
-
#drift ⇒ void
Check for project configuration drift.
-
#info ⇒ void
Display project information.
-
#status ⇒ String
Return the current status.
-
#sync ⇒ void
Synchronize project configuration.
Instance Method Details
#apply_template(name = nil) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rosett_ai/thor/tasks/project.rb', line 85 def apply_template(name = nil) if [:list] list_templates return end raise RosettAi::ProjectError, 'Template name required' unless name applier = RosettAi::Project::TemplateApplier.new( project_root: resolve_project_root, template_name: name, force: [:force] ) results = applier.apply render_apply_results(results) exit 1 if results[:errors].any? end |
#drift ⇒ void
This method returns an undefined value.
Check for project configuration drift.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/rosett_ai/thor/tasks/project.rb', line 123 def drift root = resolve_project_root validate_project!(root) detector = RosettAi::Project::DriftDetector.new(project_root: root) results = detector.detect(type: [:type]) if [:format] == 'json' puts JSON.pretty_generate(results) else render_drift_results(results) end total_drift = results.values.flatten.size exit 4 if total_drift.positive? end |
#info ⇒ void
This method returns an undefined value.
Display project information.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rosett_ai/thor/tasks/project.rb', line 57 def info manager = RosettAi::Project::Manager.new(project_root: resolve_project_root) result = manager.info rows = result.map { |key, value| [key.to_s.tr('_', ' ').capitalize, value.to_s] } table = ::Terminal::Table.new( title: ::I18n.t('rosett_ai.project.info_title'), rows: rows ) puts table end |
#status ⇒ String
Return the current status.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rosett_ai/thor/tasks/project.rb', line 35 def status manager = RosettAi::Project::Manager.new(project_root: resolve_project_root) result = manager.status if [:format] == 'json' puts JSON.pretty_generate(result) else render_status(result) end end |
#sync ⇒ void
This method returns an undefined value.
Synchronize project configuration.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/rosett_ai/thor/tasks/project.rb', line 160 def sync sync_mgr = RosettAi::Project::SyncManager.new( project_root: resolve_project_root, force: [:force] ) results = [:simulate] ? sync_mgr.simulate : sync_mgr.sync render_sync_results(results, simulate: [:simulate]) if results[:error] warn Rainbow(" Error: #{results[:error]}").red exit 1 end exit 5 if results[:conflicts].any? end |