Class: LcpRuby::CLI::NewCommand
- Inherits:
-
Object
- Object
- LcpRuby::CLI::NewCommand
- Defined in:
- lib/lcp_ruby/cli/new_command.rb
Constant Summary collapse
- MINIMUM_RAILS_VERSION =
"8.1"- MINIMUM_RUBY_VERSION =
"3.1"- DATABASES =
%w[sqlite3 postgresql mysql2].freeze
- FORMATS =
%w[dsl yaml].freeze
- WIZARD_EXCLUDED =
The wizard’s ‘lcp new` flow exposes a curated subset of features —`api_tokens` and `oidc_role_mappings` ship as standalone post-install generators (`rails generate lcp_ruby:api_tokens`), not part of any preset. Excluding them from `WIZARD_FEATURES` keeps the picker focused; they’re still in ‘FeatureRegistry::FEATURES` so the runtime prereq concern can validate `requires_features :install_auth`.
%w[api_tokens oidc_role_mappings].freeze
- WIZARD_FEATURES =
LcpRuby::Generators::FeatureRegistry::FEATURES.reject { |k, _| WIZARD_EXCLUDED.include?(k) }.freeze
- PRESET_BASE =
{ "minimal" => [], "standard" => %w[install_auth auditing saved_filters export import], "full" => :all }.freeze
- FORMAT_AWARE =
Generators that accept the –format option (include FormatSupport). ‘install_auth` ships a metadata model file (`models/user.rb`) since PR 1, so it now honours –format too.
WIZARD_FEATURES.keys.freeze
- DEFAULT_TIMEZONE =
"UTC"- DEFAULT_LOCALE =
"en"- MENU_LAYOUTS =
%w[top sidebar both].freeze
- DEFAULT_MENU_LAYOUT =
"both"- TIMEZONE_PATTERN =
IANA timezone names: letters/digits separated by ‘/`, `_`, `+`, `-`. Rejects any character that could break out of a Ruby string literal.
%r{\A[A-Za-z][A-Za-z0-9_/+\-]*\z}- LOCALE_PATTERN =
BCP 47 lite: 2–3 letter primary tag, optional region (‘-CZ`) or script (`-Latn`). Accepts a comma-separated list of tags (with optional whitespace around the commas) for multi-locale apps: `–locale=cs,en,de`. The pattern requires at least one tag and a tag on both sides of every comma — empty input (`–locale=`), leading/trailing commas (`–locale=,cs`), and adjacent commas (`–locale=cs,,de`) all fail the regex.
/\A[a-z]{2,3}(?:-[A-Za-z]{2,4})?(?:\s*,\s*[a-z]{2,3}(?:-[A-Za-z]{2,4})?)*\z/- CONFUSABLES =
ccTLD → ISO 639-1 typo nudge. ‘–locale=cz` is a common slip for `cs` (the language tag); without this, the generated app renders 100% English fallback. Warning is non-fatal so CI smoke tests of the fallback path stay unblocked.
{ "cz" => "cs", "cn" => "zh", "jp" => "ja", "kr" => "ko", "dk" => "da", "se" => "sv", "gr" => "el", "ua" => "uk", "il" => "he", "vn" => "vi" }.freeze
Instance Method Summary collapse
-
#initialize(app_name, options, shell) ⇒ NewCommand
constructor
A new instance of NewCommand.
- #run ⇒ Object
Constructor Details
#initialize(app_name, options, shell) ⇒ NewCommand
Returns a new instance of NewCommand.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/lcp_ruby/cli/new_command.rb', line 65 def initialize(app_name, , shell) @app_name = app_name @options = @shell = shell @database = [:database] @format = [:format] @preset = [:preset] @timezone = [:timezone] @locale = [:locale] @menu_layout = [:menu_layout] @features = [] @extra_features = parse_extra_features([:features]) @gem_source = [:gem_source] end |
Instance Method Details
#run ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/lcp_ruby/cli/new_command.rb', line 80 def run validate_app_name! check_ruby_version! check_rails_version! if @options[:skip_interactive] apply_defaults else run_wizard end validate_timezone_and_locale! detect_gem_source execute_rails_new end |