Fix app template generation: settings API and layout constant#19
Open
crimson-knight wants to merge 6 commits intomainfrom
Open
Fix app template generation: settings API and layout constant#19crimson-knight wants to merge 6 commits intomainfrom
crimson-knight wants to merge 6 commits intomainfrom
Conversation
…isting generators New generators added to `amber generate`: - `job` - Generates Amber::Jobs::Job subclass with JSON::Serializable, perform method, queue/retry overrides, and registration. Supports --queue and --max-retries options. - `mailer` - Generates Amber::Mailer::Base subclass with fluent API (to/from/subject/deliver), ECR templates, and html_body/text_body methods. Supports --actions option for multiple mailer actions. - `schema` - Generates Amber::Schema::Definition subclass with field definitions, type mapping, and format validators. Supports the name:type:required field syntax for marking required fields. - `channel` - Generates Amber::WebSockets::Channel subclass with handle_joined/handle_leave/handle_message methods, plus a companion ClientSocket struct with channel registration. Updated existing generators for V2 patterns: - Controller: defaults to ECR templates, generates specs using Amber::Testing::RequestHelpers and Assertions - Scaffold: generates a companion Schema class for create/update validation, uses schema-based params in controller, generates views with V2 form helpers (form_for, text_field, label, etc.) - Mailer: now generates Amber::Mailer::Base instead of Quartz::Mailer - Auth: generates ECR views with V2 form helpers by default - API: includes schema validation in generated controllers - Default template extension changed from slang to ecr Updated `amber new` application template: - Adds V2 directories: schemas/, jobs/, mailers/, channels/, sockets/ in both src/ and spec/ - Generates spec/spec_helper.cr with Amber::Testing setup - Generates config/routes.cr with full pipeline configuration (Error, Logger, Session, Flash, CSRF pipes) - Generates environment config files (development, test, production) - Generates .gitignore, db/seeds.cr, public assets (CSS, JS, robots.txt) - Generates .keep files for all empty directories - Main entry file requires all V2 component directories Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ng tests Implements a complete Language Server Protocol server for Amber Framework projects that provides real-time convention diagnostics. The LSP communicates via stdio using standard Content-Length framed JSON-RPC messages, exactly as editors and tools like Claude Code expect. Core infrastructure: - LSP server with initialize/shutdown/exit lifecycle - Document store for tracking open files - Project context detection via shard.yml amber dependency - YAML-based configuration with per-rule enable/disable and severity overrides - Analyzer pipeline connecting rules to the LSP protocol 15 convention rules across 10 categories: - Controllers: naming, inheritance, filter syntax, action return type - Jobs: perform method, JSON::Serializable - Channels: handle_message method - Pipes: call_next requirement - Mailers: required methods - Schemas: field type validation - File naming: snake_case, directory structure - Routing: controller action existence - Specs: spec file existence - Sockets: channel route validation End-to-end validation: - Full LSP lifecycle test (didOpen -> didSave -> didClose -> shutdown -> exit) - Multi-rule diagnostic test verifying 4 simultaneous violations - Non-Amber project isolation test (no false positives) - Job rules integration test - Configuration override test (.amber-lsp.yml) - Binary stdio integration tests spawning the compiled amber-lsp binary Also fixes rule_registry pattern matching to support absolute file paths, enabling rules with directory-based applies_to patterns (e.g., src/controllers/*) to match files opened via file:// URIs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds an `amber setup:lsp` command that configures the Amber LSP server for Claude Code integration. The command resolves or builds the amber-lsp binary, then creates .lsp.json, .claude-plugin/plugin.json, and .amber-lsp.yml in the target project directory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds custom rule engine for project-specific YAML-based rules (regex patterns, glob-based file matching, configurable severity). Includes agent E2E integration test and updates README with LSP documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All CI workflows, release pipeline, and build script now build both amber and amber-lsp binaries. Release tarballs include both. Homebrew tap dispatch points to crimson-knight/homebrew-amber-cli. README updated with dual-binary install instructions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `new` command generated apps that failed to compile due to two issues: 1. Templates referenced `Amber::Server.settings.name` but the V2 API is `Amber.settings.name` (settings is on the Amber module, not Server class) 2. The render macro's LAYOUT constant defaults to "application.slang" in the Amber framework. ECR apps need ApplicationController to override this with "application.ecr" (or whichever engine was selected). Discovered while testing Amber V2 app generation with crystal-alpha (Crystal incremental compiler). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Amber::Server.settings.name→Amber.settings.namein both ECR and Slang index templatesLAYOUT = "application.#{template}"to generatedApplicationControllerso the render macro uses the correct layout file extensionHow it was discovered
While testing Amber V2 app generation with crystal-alpha (the Crystal incremental compiler), a freshly generated ECR app failed to compile with two errors:
undefined method 'settings' for Amber::Server.class— The V2 API exposes settings on theAmbermodule directly (Amber.settings), not onAmber::ServerSlang template: src/views/layouts/application.slang doesn't exist— The Amber framework's render macro hardcodesLAYOUT = "application.slang". ECR apps need the controller to override this constant to match their template engineWhat changed
src/amber_cli/commands/new.cr:create_application_controllernow setsLAYOUT = "application.#{template}"so the layout file extension matches whichever template engine was selected (-t ecror-t slang)Amber.settings.nameTest plan
amber new test_appshards installcompletescrystal build src/test_app.crcompiles successfully🤖 Generated with Claude Code