better_app_gen 0.1.0
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +134 -0
- data/CHANGELOG.md +29 -0
- data/CLAUDE.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +174 -0
- data/RELEASE.md +25 -0
- data/Rakefile +10 -0
- data/exe/better_app_gen +6 -0
- data/lib/better_app_gen/app_generator.rb +75 -0
- data/lib/better_app_gen/cli.rb +136 -0
- data/lib/better_app_gen/configuration.rb +90 -0
- data/lib/better_app_gen/dependency_checker.rb +129 -0
- data/lib/better_app_gen/errors.rb +56 -0
- data/lib/better_app_gen/generators/base.rb +219 -0
- data/lib/better_app_gen/generators/database.rb +64 -0
- data/lib/better_app_gen/generators/docker.rb +73 -0
- data/lib/better_app_gen/generators/gemfile.rb +26 -0
- data/lib/better_app_gen/generators/home_controller.rb +34 -0
- data/lib/better_app_gen/generators/locale.rb +24 -0
- data/lib/better_app_gen/generators/rails_app.rb +60 -0
- data/lib/better_app_gen/generators/simple_form.rb +33 -0
- data/lib/better_app_gen/generators/solid_stack.rb +18 -0
- data/lib/better_app_gen/generators/vite.rb +122 -0
- data/lib/better_app_gen/templates/app/controllers/home_controller.rb.erb +4 -0
- data/lib/better_app_gen/templates/app/helpers/home_helper.rb.erb +2 -0
- data/lib/better_app_gen/templates/app/views/home/index.html.erb.erb +2 -0
- data/lib/better_app_gen/templates/app/views/layouts/application.html.erb.erb +33 -0
- data/lib/better_app_gen/templates/bin/dev.erb +11 -0
- data/lib/better_app_gen/templates/bin/docker-entrypoint.erb +7 -0
- data/lib/better_app_gen/templates/bin/docker-entrypoint.prod.erb +12 -0
- data/lib/better_app_gen/templates/config/application.rb.erb +80 -0
- data/lib/better_app_gen/templates/config/database.yml.erb +65 -0
- data/lib/better_app_gen/templates/config/initializers/active_record_schema_settings.rb.erb +3 -0
- data/lib/better_app_gen/templates/config/initializers/better_vite_helper.rb.erb +5 -0
- data/lib/better_app_gen/templates/config/initializers/simple_form.rb.erb +21 -0
- data/lib/better_app_gen/templates/config/locales/it.yml.erb +68 -0
- data/lib/better_app_gen/templates/config/locales/simple_form.it.yml.erb +49 -0
- data/lib/better_app_gen/templates/config/routes.rb.erb +15 -0
- data/lib/better_app_gen/templates/db/cable_migrate/create_solid_cable_schema.rb.erb +15 -0
- data/lib/better_app_gen/templates/db/cache_migrate/create_solid_cache_schema.rb.erb +16 -0
- data/lib/better_app_gen/templates/db/migrate/create_shared_schema.rb.erb +31 -0
- data/lib/better_app_gen/templates/db/migrate/enable_uuid_extension.rb.erb +7 -0
- data/lib/better_app_gen/templates/db/queue_migrate/create_solid_queue_schema.rb.erb +133 -0
- data/lib/better_app_gen/templates/docker/DEPLOY.md.erb +129 -0
- data/lib/better_app_gen/templates/docker/Dockerfile.dev.erb +58 -0
- data/lib/better_app_gen/templates/docker/Dockerfile.prod.erb +172 -0
- data/lib/better_app_gen/templates/docker/compose.runner.yml.erb +6 -0
- data/lib/better_app_gen/templates/docker/compose.yml.erb +86 -0
- data/lib/better_app_gen/templates/docker/env.docker.erb +28 -0
- data/lib/better_app_gen/templates/lib/tasks/db.rake.erb +28 -0
- data/lib/better_app_gen/templates/public/robots.txt.erb +1 -0
- data/lib/better_app_gen/templates/root/Procfile.dev.erb +2 -0
- data/lib/better_app_gen/templates/root/env.example.erb +27 -0
- data/lib/better_app_gen/templates/root/gitignore.erb +404 -0
- data/lib/better_app_gen/templates/root/yarnrc.yml.erb +6 -0
- data/lib/better_app_gen/templates/script/dc-attach.erb +13 -0
- data/lib/better_app_gen/templates/script/dc-build.erb +8 -0
- data/lib/better_app_gen/templates/script/dc-down.erb +8 -0
- data/lib/better_app_gen/templates/script/dc-logs-tail.erb +16 -0
- data/lib/better_app_gen/templates/script/dc-logs.erb +17 -0
- data/lib/better_app_gen/templates/script/dc-rails.erb +8 -0
- data/lib/better_app_gen/templates/script/dc-restart.erb +11 -0
- data/lib/better_app_gen/templates/script/dc-shell.erb +12 -0
- data/lib/better_app_gen/templates/script/dc-up.erb +11 -0
- data/lib/better_app_gen/templates/vite/application.css.erb +12 -0
- data/lib/better_app_gen/templates/vite/application.js.erb +6 -0
- data/lib/better_app_gen/templates/vite/controllers/application.js.erb +9 -0
- data/lib/better_app_gen/templates/vite/controllers/hello_controller.js.erb +7 -0
- data/lib/better_app_gen/templates/vite/controllers/index.js.erb +8 -0
- data/lib/better_app_gen/templates/vite/postcss.config.js.erb +5 -0
- data/lib/better_app_gen/templates/vite/vite.config.js.erb +48 -0
- data/lib/better_app_gen/version.rb +5 -0
- data/lib/better_app_gen.rb +23 -0
- metadata +182 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 721659195e0a7e2ee4457d05891e43e3e013c98dabd09bbabbad900a3c4321d5
|
|
4
|
+
data.tar.gz: 602beed079b01394f79859d134fe3d45198a7a823fb8d6b761d48dbaa17d3cbe
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 45ba11604764fd6aaf9ff589126a65f40096d49485dd6b71ec1b665a5005743c3f31c326bdb7416faaa3da59f8b3160415576c6f7b19ac66080d58eae96515b7
|
|
7
|
+
data.tar.gz: a8e81ffd71ccd05e32efec4807e52cfe49c7e4f49b324ae0bbb0f6a75775153b97597f371649c35d6c522deb128626f0f010b45a7de19bf59cb8effba6fb0e50
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
|
|
2
|
+
|
|
3
|
+
require:
|
|
4
|
+
- rubocop-rspec
|
|
5
|
+
|
|
6
|
+
AllCops:
|
|
7
|
+
TargetRubyVersion: 3.2
|
|
8
|
+
NewCops: enable
|
|
9
|
+
SuggestExtensions: false
|
|
10
|
+
Exclude:
|
|
11
|
+
- "bin/**/*"
|
|
12
|
+
- "vendor/**/*"
|
|
13
|
+
- "spec/fixtures/**/*"
|
|
14
|
+
|
|
15
|
+
Style/Documentation:
|
|
16
|
+
Enabled: false
|
|
17
|
+
|
|
18
|
+
Style/StringLiterals:
|
|
19
|
+
EnforcedStyle: double_quotes
|
|
20
|
+
|
|
21
|
+
Style/StringLiteralsInInterpolation:
|
|
22
|
+
EnforcedStyle: double_quotes
|
|
23
|
+
|
|
24
|
+
Layout/LineLength:
|
|
25
|
+
Max: 120
|
|
26
|
+
|
|
27
|
+
Metrics/MethodLength:
|
|
28
|
+
Max: 50
|
|
29
|
+
|
|
30
|
+
Metrics/AbcSize:
|
|
31
|
+
Max: 60
|
|
32
|
+
|
|
33
|
+
Metrics/ClassLength:
|
|
34
|
+
Max: 200
|
|
35
|
+
|
|
36
|
+
# RSpec cops
|
|
37
|
+
RSpec/MultipleExpectations:
|
|
38
|
+
Max: 10
|
|
39
|
+
|
|
40
|
+
RSpec/ExampleLength:
|
|
41
|
+
Max: 15
|
|
42
|
+
|
|
43
|
+
RSpec/FilePath:
|
|
44
|
+
Enabled: false
|
|
45
|
+
|
|
46
|
+
RSpec/SpecFilePathFormat:
|
|
47
|
+
Enabled: false
|
|
48
|
+
|
|
49
|
+
# Disable Capybara cops (not used)
|
|
50
|
+
Capybara:
|
|
51
|
+
Enabled: false
|
|
52
|
+
|
|
53
|
+
Capybara/RSpec:
|
|
54
|
+
Enabled: false
|
|
55
|
+
|
|
56
|
+
Capybara/RSpec/PredicateMatcher:
|
|
57
|
+
Enabled: false
|
|
58
|
+
|
|
59
|
+
# Override deprecated RSpec/Capybara/* cops (now Capybara/*)
|
|
60
|
+
Capybara/CurrentPathExpectation:
|
|
61
|
+
Enabled: false
|
|
62
|
+
Capybara/MatchStyle:
|
|
63
|
+
Enabled: false
|
|
64
|
+
Capybara/NegationMatcher:
|
|
65
|
+
Enabled: false
|
|
66
|
+
Capybara/SpecificActions:
|
|
67
|
+
Enabled: false
|
|
68
|
+
Capybara/SpecificFinders:
|
|
69
|
+
Enabled: false
|
|
70
|
+
Capybara/SpecificMatcher:
|
|
71
|
+
Enabled: false
|
|
72
|
+
Capybara/VisibilityMatcher:
|
|
73
|
+
Enabled: false
|
|
74
|
+
|
|
75
|
+
# Disable FactoryBot cops (not used)
|
|
76
|
+
FactoryBot:
|
|
77
|
+
Enabled: false
|
|
78
|
+
|
|
79
|
+
# Override deprecated RSpec/FactoryBot/* cops (now FactoryBot/*)
|
|
80
|
+
FactoryBot/AttributeDefinedStatically:
|
|
81
|
+
Enabled: false
|
|
82
|
+
FactoryBot/ConsistentParenthesesStyle:
|
|
83
|
+
Enabled: false
|
|
84
|
+
FactoryBot/CreateList:
|
|
85
|
+
Enabled: false
|
|
86
|
+
FactoryBot/FactoryClassName:
|
|
87
|
+
Enabled: false
|
|
88
|
+
FactoryBot/FactoryNameStyle:
|
|
89
|
+
Enabled: false
|
|
90
|
+
FactoryBot/IdSequence:
|
|
91
|
+
Enabled: false
|
|
92
|
+
FactoryBot/RedundantFactoryOption:
|
|
93
|
+
Enabled: false
|
|
94
|
+
FactoryBot/SyntaxMethods:
|
|
95
|
+
Enabled: false
|
|
96
|
+
|
|
97
|
+
# Disable RSpec/Rails cops (not a Rails app)
|
|
98
|
+
RSpecRails:
|
|
99
|
+
Enabled: false
|
|
100
|
+
|
|
101
|
+
# Override deprecated RSpec/Rails/* cops (now RSpecRails/*)
|
|
102
|
+
RSpecRails/AvoidSetupHook:
|
|
103
|
+
Enabled: false
|
|
104
|
+
RSpecRails/HaveHttpStatus:
|
|
105
|
+
Enabled: false
|
|
106
|
+
RSpecRails/HttpStatus:
|
|
107
|
+
Enabled: false
|
|
108
|
+
RSpecRails/InferredSpecType:
|
|
109
|
+
Enabled: false
|
|
110
|
+
RSpecRails/MinitestAssertions:
|
|
111
|
+
Enabled: false
|
|
112
|
+
RSpecRails/NegationBeValid:
|
|
113
|
+
Enabled: false
|
|
114
|
+
RSpecRails/TravelAround:
|
|
115
|
+
Enabled: false
|
|
116
|
+
|
|
117
|
+
# Allow longer parameter lists for configuration objects
|
|
118
|
+
Metrics/ParameterLists:
|
|
119
|
+
Max: 8
|
|
120
|
+
|
|
121
|
+
# Allow higher complexity for CLI commands
|
|
122
|
+
Metrics/CyclomaticComplexity:
|
|
123
|
+
Max: 12
|
|
124
|
+
|
|
125
|
+
Metrics/PerceivedComplexity:
|
|
126
|
+
Max: 12
|
|
127
|
+
|
|
128
|
+
# Allow predicate names without ?
|
|
129
|
+
Naming/PredicateMethod:
|
|
130
|
+
Enabled: false
|
|
131
|
+
|
|
132
|
+
# Allow more memoized helpers for orchestrator tests that need many mocks
|
|
133
|
+
RSpec/MultipleMemoizedHelpers:
|
|
134
|
+
Max: 12
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-01-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release of better_app_gen gem
|
|
13
|
+
- CLI for generating Rails 8 applications with `new`, `check`, and `version` commands
|
|
14
|
+
- Solid Stack integration (Cache, Queue, Cable) backed by PostgreSQL
|
|
15
|
+
- Vite 7 + Tailwind CSS 4 + Stimulus frontend setup
|
|
16
|
+
- Multi-database PostgreSQL configuration (primary, cache, queue, cable)
|
|
17
|
+
- UUID primary keys by default across all models
|
|
18
|
+
- Docker development environment with helper scripts (dc-up, dc-down, dc-shell, etc.)
|
|
19
|
+
- Production Docker support with multi-stage Dockerfile, Thruster, Jemalloc, and YJIT
|
|
20
|
+
- DEPLOY.md documentation for production deployments
|
|
21
|
+
- Configurable locale support (en, it, de, fr, es, pt, nl, pl, ru, ja, zh)
|
|
22
|
+
- Optional SimpleForm integration with Tailwind styling
|
|
23
|
+
- Configurable Rails and Vite server ports
|
|
24
|
+
- Comprehensive dependency checking (Ruby, Rails, Node, Yarn, Git, PostgreSQL)
|
|
25
|
+
- Comprehensive test suite with SimpleCov coverage
|
|
26
|
+
- better_vite_helper gem for improved Vite integration
|
|
27
|
+
- CLAUDE.md for Claude Code guidance
|
|
28
|
+
- GitHub Actions workflows for CI and release
|
|
29
|
+
- RELEASE.md with release process documentation
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
BetterAppGen is a Ruby gem that generates Rails 8 applications with an opinionated, production-ready stack. It creates apps with Solid Stack (Cache, Queue, Cable backed by PostgreSQL), Vite 7 + Tailwind CSS 4, multi-database architecture, UUID primary keys, and Docker support.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Install dependencies
|
|
13
|
+
bin/setup
|
|
14
|
+
|
|
15
|
+
# Run tests
|
|
16
|
+
bundle exec rspec
|
|
17
|
+
|
|
18
|
+
# Run a single test file
|
|
19
|
+
bundle exec rspec spec/configuration_spec.rb
|
|
20
|
+
|
|
21
|
+
# Run linter
|
|
22
|
+
bundle exec rubocop
|
|
23
|
+
|
|
24
|
+
# Auto-fix linting issues
|
|
25
|
+
bundle exec rubocop -A
|
|
26
|
+
|
|
27
|
+
# Test the CLI locally
|
|
28
|
+
bundle exec bin/better_app_gen new test-app --skip-docker
|
|
29
|
+
|
|
30
|
+
# Check dependencies
|
|
31
|
+
bundle exec bin/better_app_gen check
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Architecture
|
|
35
|
+
|
|
36
|
+
### Entry Points
|
|
37
|
+
- `exe/better_app_gen` - CLI executable
|
|
38
|
+
- `lib/better_app_gen.rb` - Main module, loads all components
|
|
39
|
+
|
|
40
|
+
### Core Components
|
|
41
|
+
- `lib/better_app_gen/cli.rb` - Thor-based CLI with `new`, `check`, `version` commands
|
|
42
|
+
- `lib/better_app_gen/configuration.rb` - Immutable config object, validates app name, ports, locale
|
|
43
|
+
- `lib/better_app_gen/app_generator.rb` - Orchestrator that runs generators in sequence
|
|
44
|
+
- `lib/better_app_gen/dependency_checker.rb` - Validates Ruby, Rails, Node, Yarn, Git, PostgreSQL versions
|
|
45
|
+
|
|
46
|
+
### Generators (`lib/better_app_gen/generators/`)
|
|
47
|
+
Each generator inherits from `Base` and implements `generate!`:
|
|
48
|
+
- `rails_app.rb` - Creates base Rails app with `rails new`
|
|
49
|
+
- `gemfile.rb` - Adds gems (solid_cache, solid_queue, solid_cable, better_vite_helper, etc.)
|
|
50
|
+
- `database.rb` - Multi-database config (primary, cache, queue, cable)
|
|
51
|
+
- `solid_stack.rb` - Solid Cache/Queue/Cable configuration in config/application.rb
|
|
52
|
+
- `vite.rb` - Vite + Tailwind CSS + Stimulus setup
|
|
53
|
+
- `home_controller.rb` - HomeController with root route
|
|
54
|
+
- `locale.rb` - i18n configuration
|
|
55
|
+
- `docker.rb` - Docker development environment
|
|
56
|
+
- `simple_form.rb` - Optional SimpleForm with Tailwind
|
|
57
|
+
|
|
58
|
+
### Templates (`lib/better_app_gen/templates/`)
|
|
59
|
+
ERB templates organized by destination path. Access config values via `@config` binding.
|
|
60
|
+
|
|
61
|
+
## Key Patterns
|
|
62
|
+
|
|
63
|
+
- **Bundler isolation**: Use `Bundler.with_unbundled_env` when running shell commands that need system gems (rails, yarn)
|
|
64
|
+
- **Config access in templates**: Templates receive `@config` with methods like `app_name`, `app_name_pascal`, `rails_port`, `vite_port`, `locale`, `timezone`
|
|
65
|
+
- **Locale handling**: Only `en` and `it` have translation templates; other locales trigger a warning
|
|
66
|
+
|
|
67
|
+
## Supported Locales
|
|
68
|
+
en, it, de, fr, es, pt, nl, pl, ru, ja, zh (only en/it include translation files)
|
|
69
|
+
|
|
70
|
+
## Commit Convention
|
|
71
|
+
Use conventional commits format:
|
|
72
|
+
- `feat:` new feature
|
|
73
|
+
- `fix:` bug fix
|
|
74
|
+
- `docs:` documentation changes
|
|
75
|
+
- `refactor:` code refactoring
|
|
76
|
+
- `test:` adding/updating tests
|
|
77
|
+
- `chore:` maintenance tasks
|
|
78
|
+
- `ci:` CI/CD changes
|
|
79
|
+
|
|
80
|
+
## Release
|
|
81
|
+
See `RELEASE.md`. Automated via GitHub Actions:
|
|
82
|
+
1. Run "Prepare Release" workflow with version
|
|
83
|
+
2. Merge the PR
|
|
84
|
+
3. Tag auto-created → publishes to RubyGems
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pandev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# BetterAppGen
|
|
2
|
+
|
|
3
|
+
Generate Rails 8 applications with an opinionated, production-ready stack.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Solid Stack**: PostgreSQL-backed caching, jobs, and WebSockets (no Redis needed)
|
|
8
|
+
- Solid Cache for caching
|
|
9
|
+
- Solid Queue for background jobs
|
|
10
|
+
- Solid Cable for Action Cable
|
|
11
|
+
- **Modern Frontend**: Vite 7 + Tailwind CSS 4 + Stimulus
|
|
12
|
+
- **Multi-Database Architecture**: Separate databases for app, cache, queue, and cable
|
|
13
|
+
- **UUID Primary Keys**: By default across all models
|
|
14
|
+
- **Docker Development**: Complete Docker setup for development
|
|
15
|
+
- **Production Docker**: Optimized multi-stage Dockerfile with Thruster, Jemalloc, and YJIT
|
|
16
|
+
- **Configurable Locale**: Support for multiple languages (en, it, de, fr, es, pt, nl, pl, ru, ja, zh)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
gem install better_app_gen
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Generate a New Application
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Basic usage (English locale, default ports)
|
|
30
|
+
better_app_gen new my-app
|
|
31
|
+
|
|
32
|
+
# With SimpleForm
|
|
33
|
+
better_app_gen new my-app --with-simple-form
|
|
34
|
+
|
|
35
|
+
# With Italian locale
|
|
36
|
+
better_app_gen new my-app --locale it
|
|
37
|
+
|
|
38
|
+
# Custom ports
|
|
39
|
+
better_app_gen new my-app --rails-port 3001 --vite-port 5174
|
|
40
|
+
|
|
41
|
+
# Skip Docker
|
|
42
|
+
better_app_gen new my-app --skip-docker
|
|
43
|
+
|
|
44
|
+
# Combine options
|
|
45
|
+
better_app_gen new my-app --with-simple-form --locale it --rails-port 3001
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Check Dependencies
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
better_app_gen check
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### View Version
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
better_app_gen version
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Options
|
|
61
|
+
|
|
62
|
+
| Flag | Default | Description |
|
|
63
|
+
|------|---------|-------------|
|
|
64
|
+
| `--with-simple-form` | false | Include SimpleForm with Tailwind CSS styling |
|
|
65
|
+
| `--rails-port PORT` | 3000 | Rails server port |
|
|
66
|
+
| `--vite-port PORT` | 5173 | Vite dev server port |
|
|
67
|
+
| `--skip-docker` | false | Skip Docker configuration |
|
|
68
|
+
| `--locale LOCALE` | en | Default locale (en, it, de, fr, es, pt, nl, pl, ru, ja, zh) |
|
|
69
|
+
|
|
70
|
+
## Generated Application Structure
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
my-app/
|
|
74
|
+
├── app/
|
|
75
|
+
│ ├── assets/
|
|
76
|
+
│ │ ├── javascripts/
|
|
77
|
+
│ │ │ ├── application.js
|
|
78
|
+
│ │ │ └── controllers/
|
|
79
|
+
│ │ └── stylesheets/
|
|
80
|
+
│ │ └── application.css
|
|
81
|
+
│ ├── controllers/
|
|
82
|
+
│ │ └── home_controller.rb
|
|
83
|
+
│ ├── helpers/
|
|
84
|
+
│ │ └── home_helper.rb
|
|
85
|
+
│ └── views/
|
|
86
|
+
│ ├── home/
|
|
87
|
+
│ │ └── index.html.erb
|
|
88
|
+
│ └── layouts/
|
|
89
|
+
│ └── application.html.erb
|
|
90
|
+
├── config/
|
|
91
|
+
│ ├── application.rb
|
|
92
|
+
│ ├── database.yml
|
|
93
|
+
│ ├── initializers/
|
|
94
|
+
│ │ └── better_vite_helper.rb
|
|
95
|
+
│ └── routes.rb
|
|
96
|
+
├── db/
|
|
97
|
+
│ ├── migrate/
|
|
98
|
+
│ ├── cache_migrate/
|
|
99
|
+
│ ├── queue_migrate/
|
|
100
|
+
│ └── cable_migrate/
|
|
101
|
+
├── .docker/
|
|
102
|
+
│ ├── Dockerfile.dev
|
|
103
|
+
│ ├── Dockerfile.prod
|
|
104
|
+
│ └── DEPLOY.md
|
|
105
|
+
├── bin/
|
|
106
|
+
│ ├── dev
|
|
107
|
+
│ ├── docker-entrypoint
|
|
108
|
+
│ └── docker-entrypoint.prod
|
|
109
|
+
├── script/
|
|
110
|
+
│ ├── dc-up
|
|
111
|
+
│ ├── dc-down
|
|
112
|
+
│ ├── dc-shell
|
|
113
|
+
│ └── ...
|
|
114
|
+
├── compose.yml
|
|
115
|
+
├── compose.runner.yml
|
|
116
|
+
├── vite.config.js
|
|
117
|
+
├── postcss.config.js
|
|
118
|
+
├── Procfile.dev
|
|
119
|
+
└── ...
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Development Workflow
|
|
123
|
+
|
|
124
|
+
### With Docker (Recommended)
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
cd my-app
|
|
128
|
+
script/dc-up # Start Docker containers
|
|
129
|
+
script/dc-shell # Open shell in Rails container
|
|
130
|
+
rails db:create # Create databases
|
|
131
|
+
rails db:schema:load # Load schema
|
|
132
|
+
exit # Exit shell
|
|
133
|
+
script/dc-down && script/dc-up # Restart containers
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Without Docker
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cd my-app
|
|
140
|
+
bundle install
|
|
141
|
+
yarn install
|
|
142
|
+
rails db:create db:schema:load
|
|
143
|
+
bin/dev # Start Rails + Vite
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Requirements
|
|
147
|
+
|
|
148
|
+
- Ruby >= 3.2.0
|
|
149
|
+
- Rails >= 8.0.0
|
|
150
|
+
- Node.js >= 20.0.0
|
|
151
|
+
- Yarn >= 4.0.0
|
|
152
|
+
- PostgreSQL >= 16
|
|
153
|
+
- Git
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
git clone https://github.com/umbertopeserico/better_app_gen.git
|
|
161
|
+
cd better_app_gen
|
|
162
|
+
bin/setup
|
|
163
|
+
rake spec
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/umbertopeserico/better_app_gen.
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/RELEASE.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Release Process
|
|
2
|
+
|
|
3
|
+
## Setup (one-time)
|
|
4
|
+
|
|
5
|
+
Add `RUBYGEMS_API_KEY` secret in GitHub: Settings → Secrets → Actions
|
|
6
|
+
|
|
7
|
+
Get your API key from https://rubygems.org/profile/api_keys
|
|
8
|
+
|
|
9
|
+
## Release Steps
|
|
10
|
+
|
|
11
|
+
### 1. Prepare Release
|
|
12
|
+
Go to **Actions → Prepare Release → Run workflow** and enter the version (e.g., `0.2.0`)
|
|
13
|
+
|
|
14
|
+
This creates a PR with:
|
|
15
|
+
- Updated `lib/better_app_gen/version.rb`
|
|
16
|
+
- Updated `CHANGELOG.md`
|
|
17
|
+
|
|
18
|
+
### 2. Review and Merge
|
|
19
|
+
Review the PR and merge to main.
|
|
20
|
+
|
|
21
|
+
That's it! After merge:
|
|
22
|
+
1. Tag is created automatically
|
|
23
|
+
2. Tests run
|
|
24
|
+
3. Gem is published to RubyGems
|
|
25
|
+
4. GitHub Release is created
|
data/Rakefile
ADDED
data/exe/better_app_gen
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "tty-spinner"
|
|
4
|
+
require "pastel"
|
|
5
|
+
|
|
6
|
+
module BetterAppGen
|
|
7
|
+
# Main orchestrator for generating a complete Rails application
|
|
8
|
+
class AppGenerator
|
|
9
|
+
attr_reader :config, :pastel
|
|
10
|
+
|
|
11
|
+
def initialize(config)
|
|
12
|
+
@config = config
|
|
13
|
+
@pastel = Pastel.new
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def generate!
|
|
17
|
+
run_generator("Creating Rails application", Generators::RailsApp)
|
|
18
|
+
run_generator("Configuring Gemfile", Generators::Gemfile)
|
|
19
|
+
run_generator("Setting up database configuration", Generators::Database)
|
|
20
|
+
run_generator("Configuring Solid Stack", Generators::SolidStack)
|
|
21
|
+
run_generator("Setting up Vite + Tailwind CSS", Generators::Vite)
|
|
22
|
+
run_generator("Creating HomeController", Generators::HomeController)
|
|
23
|
+
run_generator("Configuring locale", Generators::Locale)
|
|
24
|
+
run_generator("Setting up Docker", Generators::Docker) unless config.skip_docker
|
|
25
|
+
run_generator("Configuring SimpleForm", Generators::SimpleForm) if config.with_simple_form
|
|
26
|
+
run_post_generation_tasks
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def run_generator(description, generator_class)
|
|
32
|
+
spinner = TTY::Spinner.new("[:spinner] #{description}...", format: :dots)
|
|
33
|
+
spinner.auto_spin
|
|
34
|
+
|
|
35
|
+
begin
|
|
36
|
+
generator = generator_class.new(config)
|
|
37
|
+
generator.generate!
|
|
38
|
+
spinner.success(pastel.green("done"))
|
|
39
|
+
rescue StandardError => e
|
|
40
|
+
spinner.error(pastel.red("failed"))
|
|
41
|
+
raise e
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def run_post_generation_tasks
|
|
46
|
+
spinner = TTY::Spinner.new("[:spinner] Installing dependencies...", format: :dots)
|
|
47
|
+
spinner.auto_spin
|
|
48
|
+
|
|
49
|
+
begin
|
|
50
|
+
Dir.chdir(config.app_path) do
|
|
51
|
+
# Run outside of bundler environment
|
|
52
|
+
Bundler.with_unbundled_env do
|
|
53
|
+
system("bundle install > /dev/null 2>&1")
|
|
54
|
+
system("yarn install > /dev/null 2>&1")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
spinner.success(pastel.green("done"))
|
|
58
|
+
rescue StandardError => e
|
|
59
|
+
spinner.error(pastel.red("failed"))
|
|
60
|
+
raise e
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Require all generators
|
|
67
|
+
require_relative "generators/rails_app"
|
|
68
|
+
require_relative "generators/gemfile"
|
|
69
|
+
require_relative "generators/database"
|
|
70
|
+
require_relative "generators/solid_stack"
|
|
71
|
+
require_relative "generators/vite"
|
|
72
|
+
require_relative "generators/home_controller"
|
|
73
|
+
require_relative "generators/locale"
|
|
74
|
+
require_relative "generators/docker"
|
|
75
|
+
require_relative "generators/simple_form"
|