yoker 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/.rubocop.yml +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +223 -0
- data/Rakefile +12 -0
- data/exe/yoker +177 -0
- data/exe/yoker (Copy) +87 -0
- data/lib/yoker/cli/base.rb +106 -0
- data/lib/yoker/cli/init.rb +193 -0
- data/lib/yoker/cli/update.rb +457 -0
- data/lib/yoker/configuration.rb +290 -0
- data/lib/yoker/detectors/database_detector.rb +35 -0
- data/lib/yoker/detectors/rails_detector.rb +48 -0
- data/lib/yoker/detectors/version_manager_detector.rb +91 -0
- data/lib/yoker/errors.rb +149 -0
- data/lib/yoker/generators/base_generator.rb +116 -0
- data/lib/yoker/generators/container/docker.rb +255 -0
- data/lib/yoker/generators/container/docker_compose.rb +255 -0
- data/lib/yoker/generators/container/none.rb +314 -0
- data/lib/yoker/generators/database/mysql.rb +147 -0
- data/lib/yoker/generators/database/postgresql.rb +64 -0
- data/lib/yoker/generators/database/sqlite.rb +123 -0
- data/lib/yoker/generators/version_manager/mise.rb +140 -0
- data/lib/yoker/generators/version_manager/rbenv.rb +165 -0
- data/lib/yoker/generators/version_manager/rvm.rb +246 -0
- data/lib/yoker/templates/bin/setup.rb.erb +232 -0
- data/lib/yoker/templates/config/database_mysql.yml.erb +47 -0
- data/lib/yoker/templates/config/database_postgresql.yml.erb +34 -0
- data/lib/yoker/templates/config/database_sqlite.yml.erb +40 -0
- data/lib/yoker/templates/docker/Dockerfile.erb +124 -0
- data/lib/yoker/templates/docker/docker-compose.yml.erb +117 -0
- data/lib/yoker/templates/docker/entrypoint.sh.erb +94 -0
- data/lib/yoker/templates/docker/init_mysql.sql.erb +44 -0
- data/lib/yoker/templates/docker/init_postgresql.sql.erb +203 -0
- data/lib/yoker/templates/version_managers/gemrc.erb +61 -0
- data/lib/yoker/templates/version_managers/mise.toml.erb +72 -0
- data/lib/yoker/templates/version_managers/rbenv_setup.sh.erb +93 -0
- data/lib/yoker/templates/version_managers/rvm_setup.sh.erb +99 -0
- data/lib/yoker/templates/version_managers/rvmrc.erb +70 -0
- data/lib/yoker/version.rb +5 -0
- data/lib/yoker.rb +32 -0
- data/sig/yoker.rbs +4 -0
- metadata +215 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
-- MySQL initialization script generated by rails-dev-setup
|
2
|
+
-- This script runs when the MySQL container is first created
|
3
|
+
|
4
|
+
-- Create test database
|
5
|
+
CREATE DATABASE IF NOT EXISTS `<%= app_name %>_test` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
6
|
+
|
7
|
+
-- Create additional user for development (if different from root)
|
8
|
+
<% if username != "root" -%>
|
9
|
+
-- Create rails user with full privileges
|
10
|
+
CREATE USER IF NOT EXISTS '<%= username %>'@'%' IDENTIFIED BY '<%= password %>';
|
11
|
+
|
12
|
+
-- Grant all privileges on development databases
|
13
|
+
GRANT ALL PRIVILEGES ON `<%= app_name %>_development`.* TO '<%= username %>'@'%';
|
14
|
+
GRANT ALL PRIVILEGES ON `<%= app_name %>_test`.* TO '<%= username %>'@'%';
|
15
|
+
|
16
|
+
-- Grant privileges for creating/dropping test databases (needed for Rails)
|
17
|
+
GRANT CREATE, DROP ON *.* TO '<%= username %>'@'%';
|
18
|
+
|
19
|
+
-- Reload privileges
|
20
|
+
FLUSH PRIVILEGES;
|
21
|
+
<% else -%>
|
22
|
+
-- Using root user - grant privileges on test database
|
23
|
+
GRANT ALL PRIVILEGES ON `<%= app_name %>_test`.* TO 'root'@'%';
|
24
|
+
FLUSH PRIVILEGES;
|
25
|
+
<% end -%>
|
26
|
+
|
27
|
+
-- Development-friendly MySQL settings
|
28
|
+
SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO';
|
29
|
+
|
30
|
+
-- Enable general query log for development debugging (optional)
|
31
|
+
-- SET GLOBAL general_log = 'ON';
|
32
|
+
-- SET GLOBAL general_log_file = '/var/log/mysql/general.log';
|
33
|
+
|
34
|
+
-- Enable slow query log for performance monitoring
|
35
|
+
SET GLOBAL slow_query_log = 'ON';
|
36
|
+
SET GLOBAL long_query_time = 2; -- Log queries taking longer than 2 seconds
|
37
|
+
|
38
|
+
-- Optimize for development workload
|
39
|
+
SET GLOBAL innodb_flush_log_at_trx_commit = 2; -- Better performance, slightly less durability
|
40
|
+
SET GLOBAL innodb_buffer_pool_size = 134217728; -- 128MB buffer pool
|
41
|
+
|
42
|
+
-- Show configuration
|
43
|
+
SELECT 'MySQL initialized for Rails development' as message;
|
44
|
+
SHOW DATABASES;
|
@@ -0,0 +1,203 @@
|
|
1
|
+
-- PostgreSQL initialization script generated by rails-dev-setup
|
2
|
+
-- This script runs when the PostgreSQL container is first created
|
3
|
+
|
4
|
+
-- Set some development-friendly PostgreSQL settings
|
5
|
+
-- These will be applied to the current session and any new connections
|
6
|
+
|
7
|
+
-- Enable more detailed logging for development
|
8
|
+
SET log_statement = 'all';
|
9
|
+
SET log_duration = on;
|
10
|
+
SET log_min_duration_statement = 100; -- Log queries taking longer than 100ms
|
11
|
+
|
12
|
+
-- Create test database
|
13
|
+
SELECT 'CREATE DATABASE ' || quote_ident('<%= app_name %>_test')
|
14
|
+
WHERE NOT EXISTS (
|
15
|
+
SELECT FROM pg_database WHERE datname = '<%= app_name %>_test'
|
16
|
+
)\gexec
|
17
|
+
|
18
|
+
<% if username != "postgres" -%>
|
19
|
+
-- Create additional development user (if different from postgres)
|
20
|
+
DO $$
|
21
|
+
BEGIN
|
22
|
+
IF NOT EXISTS (SELECT FROM pg_catalog.pg_user WHERE usename = '<%= username %>') THEN
|
23
|
+
CREATE USER <%= username %> WITH ENCRYPTED PASSWORD '<%= password %>';
|
24
|
+
END IF;
|
25
|
+
END
|
26
|
+
$$;
|
27
|
+
|
28
|
+
-- Grant privileges to the development user
|
29
|
+
GRANT ALL PRIVILEGES ON DATABASE <%= app_name %>_development TO <%= username %>;
|
30
|
+
GRANT ALL PRIVILEGES ON DATABASE <%= app_name %>_test TO <%= username %>;
|
31
|
+
|
32
|
+
-- Grant schema privileges (needed for Rails migrations)
|
33
|
+
\c <%= app_name %>_development;
|
34
|
+
GRANT ALL ON SCHEMA public TO <%= username %>;
|
35
|
+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO <%= username %>;
|
36
|
+
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO <%= username %>;
|
37
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO <%= username %>;
|
38
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO <%= username %>;
|
39
|
+
|
40
|
+
\c <%= app_name %>_test;
|
41
|
+
GRANT ALL ON SCHEMA public TO <%= username %>;
|
42
|
+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO <%= username %>;
|
43
|
+
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO <%= username %>;
|
44
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO <%= username %>;
|
45
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO <%= username %>;
|
46
|
+
|
47
|
+
-- Switch back to main database
|
48
|
+
\c <%= app_name %>_development;
|
49
|
+
<% end -%>
|
50
|
+
|
51
|
+
-- Install useful PostgreSQL extensions for Rails development
|
52
|
+
-- These are commonly used extensions that enhance Rails functionality
|
53
|
+
|
54
|
+
-- UUID extension for UUID primary keys
|
55
|
+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
56
|
+
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
|
57
|
+
|
58
|
+
-- Full-text search extension
|
59
|
+
CREATE EXTENSION IF NOT EXISTS "unaccent";
|
60
|
+
|
61
|
+
-- Additional useful extensions (uncomment as needed)
|
62
|
+
-- CREATE EXTENSION IF NOT EXISTS "hstore"; -- Key-value store
|
63
|
+
-- CREATE EXTENSION IF NOT EXISTS "ltree"; -- Tree-like data structures
|
64
|
+
-- CREATE EXTENSION IF NOT EXISTS "pg_trgm"; -- Trigram matching for fuzzy search
|
65
|
+
-- CREATE EXTENSION IF NOT EXISTS "btree_gin"; -- GIN indexes for btree-compatible data types
|
66
|
+
-- CREATE EXTENSION IF NOT EXISTS "btree_gist"; -- GiST indexes for btree-compatible data types
|
67
|
+
|
68
|
+
-- PostGIS for geospatial data (uncomment if needed)
|
69
|
+
-- CREATE EXTENSION IF NOT EXISTS "postgis";
|
70
|
+
|
71
|
+
-- Development-friendly PostgreSQL configuration
|
72
|
+
-- These settings optimize for development workflow over production performance
|
73
|
+
|
74
|
+
-- Increase shared buffers for better performance during development
|
75
|
+
-- Note: These settings only affect the current session
|
76
|
+
SET shared_buffers = '256MB';
|
77
|
+
SET work_mem = '32MB';
|
78
|
+
SET maintenance_work_mem = '128MB';
|
79
|
+
|
80
|
+
-- Enable auto-explain for slow queries (helps with debugging)
|
81
|
+
-- Load the auto_explain module and set it to log slow queries
|
82
|
+
LOAD 'auto_explain';
|
83
|
+
SET auto_explain.log_min_duration = '100ms'; -- Log queries taking longer than 100ms
|
84
|
+
SET auto_explain.log_analyze = on;
|
85
|
+
SET auto_explain.log_buffers = on;
|
86
|
+
SET auto_explain.log_timing = on;
|
87
|
+
SET auto_explain.log_triggers = on;
|
88
|
+
SET auto_explain.log_verbose = on;
|
89
|
+
SET auto_explain.log_nested_statements = on;
|
90
|
+
|
91
|
+
-- Increase statement timeout for long-running migrations
|
92
|
+
SET statement_timeout = '300s'; -- 5 minutes
|
93
|
+
|
94
|
+
-- Configure checkpoint settings for development
|
95
|
+
-- More frequent checkpoints, less impact on development workflow
|
96
|
+
SET checkpoint_completion_target = 0.9;
|
97
|
+
|
98
|
+
-- Enable detailed connection logging
|
99
|
+
SET log_connections = on;
|
100
|
+
SET log_disconnections = on;
|
101
|
+
|
102
|
+
-- Log lock waits (useful for debugging concurrency issues)
|
103
|
+
SET log_lock_waits = on;
|
104
|
+
SET deadlock_timeout = '1s';
|
105
|
+
|
106
|
+
-- Set timezone to UTC (Rails best practice)
|
107
|
+
SET timezone = 'UTC';
|
108
|
+
|
109
|
+
-- Enable plan caching (improves performance for repeated queries)
|
110
|
+
SET plan_cache_mode = 'auto';
|
111
|
+
|
112
|
+
-- Create a development-friendly function to reset sequences
|
113
|
+
-- This is useful when importing test data
|
114
|
+
CREATE OR REPLACE FUNCTION reset_sequences() RETURNS void AS $$
|
115
|
+
DECLARE
|
116
|
+
sequence_record RECORD;
|
117
|
+
BEGIN
|
118
|
+
FOR sequence_record IN
|
119
|
+
SELECT schemaname, tablename, attname, seq
|
120
|
+
FROM (
|
121
|
+
SELECT
|
122
|
+
schemaname,
|
123
|
+
tablename,
|
124
|
+
attname,
|
125
|
+
'SELECT SETVAL(' || quote_literal(quote_ident(schemaname) || '.' || quote_ident(seq)) ||
|
126
|
+
', COALESCE(MAX(' || quote_ident(attname) || '), 1)) FROM ' ||
|
127
|
+
quote_ident(schemaname) || '.' || quote_ident(tablename) AS seq
|
128
|
+
FROM (
|
129
|
+
SELECT
|
130
|
+
n.nspname AS schemaname,
|
131
|
+
c.relname AS tablename,
|
132
|
+
a.attname AS attname,
|
133
|
+
REPLACE(split_part(split_part(d.adsrc, '''', 2), '''', 1), schemaname || '.', '') AS seq
|
134
|
+
FROM pg_class c
|
135
|
+
JOIN pg_attribute a ON (c.oid = a.attrelid)
|
136
|
+
JOIN pg_attrdef d ON (a.attrelid = d.adrelid AND a.attnum = d.adnum)
|
137
|
+
JOIN pg_namespace n ON (c.relnamespace = n.oid)
|
138
|
+
WHERE has_schema_privilege(n.oid, 'USAGE')
|
139
|
+
AND n.nspname NOT LIKE 'pg!_%' ESCAPE '!'
|
140
|
+
AND n.nspname != 'information_schema'
|
141
|
+
AND c.relkind = 'r'
|
142
|
+
AND a.attnum > 0
|
143
|
+
AND NOT a.attisdropped
|
144
|
+
AND d.adsrc ~ '^nextval'
|
145
|
+
) seq_info
|
146
|
+
) t
|
147
|
+
LOOP
|
148
|
+
EXECUTE sequence_record.seq;
|
149
|
+
END LOOP;
|
150
|
+
END;
|
151
|
+
$$ LANGUAGE plpgsql;
|
152
|
+
|
153
|
+
-- Create a convenience view for monitoring database activity
|
154
|
+
CREATE OR REPLACE VIEW development_activity AS
|
155
|
+
SELECT
|
156
|
+
pid,
|
157
|
+
now() - pg_stat_activity.query_start AS duration,
|
158
|
+
query,
|
159
|
+
state,
|
160
|
+
wait_event_type,
|
161
|
+
wait_event
|
162
|
+
FROM pg_stat_activity
|
163
|
+
WHERE state != 'idle'
|
164
|
+
AND query NOT LIKE '%development_activity%'
|
165
|
+
ORDER BY duration DESC;
|
166
|
+
|
167
|
+
-- Create a function to show table sizes (useful for development)
|
168
|
+
CREATE OR REPLACE FUNCTION table_sizes()
|
169
|
+
RETURNS TABLE(
|
170
|
+
table_name text,
|
171
|
+
row_count bigint,
|
172
|
+
total_size text,
|
173
|
+
index_size text,
|
174
|
+
toast_size text
|
175
|
+
) AS $$
|
176
|
+
BEGIN
|
177
|
+
RETURN QUERY
|
178
|
+
SELECT
|
179
|
+
schemaname||'.'||tablename AS table_name,
|
180
|
+
n_tup_ins - n_tup_del AS row_count,
|
181
|
+
pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,
|
182
|
+
pg_size_pretty(pg_indexes_size(schemaname||'.'||tablename)) AS index_size,
|
183
|
+
pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) -
|
184
|
+
pg_relation_size(schemaname||'.'||tablename) -
|
185
|
+
pg_indexes_size(schemaname||'.'||tablename)) AS toast_size
|
186
|
+
FROM pg_stat_user_tables
|
187
|
+
ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;
|
188
|
+
END;
|
189
|
+
$$ LANGUAGE plpgsql;
|
190
|
+
|
191
|
+
-- Show initialization completion
|
192
|
+
SELECT
|
193
|
+
'PostgreSQL initialized for Rails development' AS message,
|
194
|
+
version() AS postgresql_version,
|
195
|
+
current_database() AS database_name,
|
196
|
+
current_user AS current_user,
|
197
|
+
now() AS initialized_at;
|
198
|
+
|
199
|
+
-- Show created databases
|
200
|
+
SELECT datname AS databases FROM pg_database WHERE datname LIKE '<%= app_name %>%';
|
201
|
+
|
202
|
+
-- Show installed extensions
|
203
|
+
SELECT extname AS installed_extensions FROM pg_extension ORDER BY extname;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Gem configuration generated by rails-dev-setup
|
2
|
+
# This file configures RubyGems for optimal development experience
|
3
|
+
|
4
|
+
# Skip documentation generation for faster gem installation
|
5
|
+
<% if skip_rdoc -%>
|
6
|
+
gem: --no-rdoc --no-ri
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
# Install gems in parallel for faster installation
|
10
|
+
<% if parallel_install -%>
|
11
|
+
install: --jobs 4
|
12
|
+
update: --jobs 4
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
# Development-specific configuration
|
16
|
+
<% if development_mode -%>
|
17
|
+
# Use local gem server if available (for air-gapped development)
|
18
|
+
# sources:
|
19
|
+
# - http://localhost:8808
|
20
|
+
# - https://rubygems.org
|
21
|
+
|
22
|
+
# Verbose output for troubleshooting (uncomment if needed)
|
23
|
+
<% if verbose -%>
|
24
|
+
install: --verbose
|
25
|
+
update: --verbose
|
26
|
+
<% end -%>
|
27
|
+
|
28
|
+
# Custom gem installation directory (uncomment if needed)
|
29
|
+
# gemhome: ~/.gem/ruby
|
30
|
+
# gempath: ~/.gem/ruby
|
31
|
+
|
32
|
+
# Development quality-of-life settings
|
33
|
+
backtrace: true
|
34
|
+
bulk_threshold: 1000
|
35
|
+
|
36
|
+
# Security settings for development
|
37
|
+
# ssl_verify_mode: 1 # Verify SSL certificates
|
38
|
+
# ssl_ca_file: /path/to/cacert.pem
|
39
|
+
|
40
|
+
<% end -%>
|
41
|
+
<% if gemset_aware -%>
|
42
|
+
# RVM-specific settings
|
43
|
+
# These settings work well with RVM gemsets
|
44
|
+
|
45
|
+
# Automatically install dependencies
|
46
|
+
install: --env-shebang
|
47
|
+
|
48
|
+
# RVM wrapper compatibility
|
49
|
+
wrappers: true
|
50
|
+
|
51
|
+
<% end -%>
|
52
|
+
# Benchmark gem installation (uncomment for performance analysis)
|
53
|
+
# benchmark: true
|
54
|
+
|
55
|
+
# Custom sources (add private gem servers here)
|
56
|
+
# sources:
|
57
|
+
# - https://gems.company.com
|
58
|
+
# - https://rubygems.org
|
59
|
+
|
60
|
+
# Disable automatic suggestions (uncomment if they're annoying)
|
61
|
+
# suggestions: false
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Generated by yoker
|
2
|
+
# This file defines the tools and configuration for your Rails development environment
|
3
|
+
|
4
|
+
[tools]
|
5
|
+
ruby = "<%= ruby_version %>"
|
6
|
+
node = "20.0.0"
|
7
|
+
<% if container == "none" && database == "postgresql" -%>
|
8
|
+
postgres = "16"
|
9
|
+
<% elsif container == "none" && database == "mysql" -%>
|
10
|
+
mysql = "8.0"
|
11
|
+
<% end -%>
|
12
|
+
<% if additional_services&.include?("redis") && container == "none" -%>
|
13
|
+
redis = "7.0"
|
14
|
+
<% end -%>
|
15
|
+
|
16
|
+
[tasks.dev]
|
17
|
+
description = "Development environment tasks"
|
18
|
+
|
19
|
+
[tasks."dev:setup"]
|
20
|
+
description = "Set up development environment"
|
21
|
+
run = "./bin/setup"
|
22
|
+
|
23
|
+
[tasks."dev:server"]
|
24
|
+
description = "Start development server"
|
25
|
+
run = "bin/rails server"
|
26
|
+
|
27
|
+
[tasks."dev:console"]
|
28
|
+
description = "Start Rails console"
|
29
|
+
run = "bin/rails console"
|
30
|
+
|
31
|
+
[tasks."dev:test"]
|
32
|
+
description = "Run test suite"
|
33
|
+
run = "bin/rails test"
|
34
|
+
|
35
|
+
<% if additional_services&.include?("sidekiq") -%>
|
36
|
+
[tasks."dev:sidekiq"]
|
37
|
+
description = "Start Sidekiq background jobs"
|
38
|
+
run = "bundle exec sidekiq"
|
39
|
+
|
40
|
+
<% end -%>
|
41
|
+
<% if container == "docker-compose" -%>
|
42
|
+
[tasks."dev:up"]
|
43
|
+
description = "Start all services with Docker Compose"
|
44
|
+
run = "docker compose up -d"
|
45
|
+
|
46
|
+
[tasks."dev:down"]
|
47
|
+
description = "Stop all services"
|
48
|
+
run = "docker compose down"
|
49
|
+
|
50
|
+
[tasks."dev:logs"]
|
51
|
+
description = "View service logs"
|
52
|
+
run = "docker compose logs -f"
|
53
|
+
|
54
|
+
<% end -%>
|
55
|
+
[settings]
|
56
|
+
experimental = true
|
57
|
+
activate_aggressive = false
|
58
|
+
legacy_version_file = false
|
59
|
+
|
60
|
+
# Environment variables for development
|
61
|
+
<% if container == "docker-compose" -%>
|
62
|
+
[env]
|
63
|
+
<% if database == "postgresql" -%>
|
64
|
+
DATABASE_URL = "postgresql://postgres:password@localhost:5432/<%= app_name %>_development"
|
65
|
+
<% elsif database == "mysql" -%>
|
66
|
+
DATABASE_URL = "mysql2://rails:password@localhost:3306/<%= app_name %>_development"
|
67
|
+
<% end -%>
|
68
|
+
<% if additional_services&.include?("redis") -%>
|
69
|
+
REDIS_URL = "redis://localhost:6379/0"
|
70
|
+
<% end -%>
|
71
|
+
RAILS_ENV = "development"
|
72
|
+
<% end -%>
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# rbenv setup script generated by rails-dev-setup
|
3
|
+
# This script ensures the correct Ruby version and gems are installed
|
4
|
+
|
5
|
+
set -e
|
6
|
+
|
7
|
+
# Colors for output
|
8
|
+
RED='\033[0;31m'
|
9
|
+
GREEN='\033[0;32m'
|
10
|
+
YELLOW='\033[1;33m'
|
11
|
+
NC='\033[0m' # No Color
|
12
|
+
|
13
|
+
echo -e "${GREEN}🚀 Setting up rbenv environment for <%= app_name %>${NC}"
|
14
|
+
|
15
|
+
# Check if rbenv is installed
|
16
|
+
if ! command -v rbenv &> /dev/null; then
|
17
|
+
echo -e "${RED}❌ rbenv is not installed or not in PATH${NC}"
|
18
|
+
echo "Please install rbenv first:"
|
19
|
+
echo " macOS: brew install rbenv ruby-build"
|
20
|
+
echo " Ubuntu: https://github.com/rbenv/rbenv#installation"
|
21
|
+
exit 1
|
22
|
+
fi
|
23
|
+
|
24
|
+
# Check if ruby-build is installed
|
25
|
+
if ! rbenv install --list &> /dev/null; then
|
26
|
+
echo -e "${RED}❌ ruby-build plugin is not installed${NC}"
|
27
|
+
echo "Please install ruby-build:"
|
28
|
+
echo " git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build"
|
29
|
+
exit 1
|
30
|
+
fi
|
31
|
+
|
32
|
+
echo -e "${YELLOW}📋 Checking Ruby version <%= ruby_version %>${NC}"
|
33
|
+
|
34
|
+
# Install Ruby version if not already installed
|
35
|
+
if ! rbenv versions --bare | grep -q "^<%= ruby_version %>$"; then
|
36
|
+
echo -e "${YELLOW}📦 Installing Ruby <%= ruby_version %>...${NC}"
|
37
|
+
rbenv install <%= ruby_version %>
|
38
|
+
echo -e "${GREEN}✅ Ruby <%= ruby_version %> installed${NC}"
|
39
|
+
else
|
40
|
+
echo -e "${GREEN}✅ Ruby <%= ruby_version %> already installed${NC}"
|
41
|
+
fi
|
42
|
+
|
43
|
+
# Set local Ruby version
|
44
|
+
rbenv local <%= ruby_version %>
|
45
|
+
|
46
|
+
# Rehash to ensure new binaries are recognized
|
47
|
+
rbenv rehash
|
48
|
+
|
49
|
+
echo -e "${YELLOW}💎 Installing essential gems${NC}"
|
50
|
+
|
51
|
+
# Update rubygems
|
52
|
+
gem update --system --no-document
|
53
|
+
|
54
|
+
# Install bundler
|
55
|
+
<% if bundler_version != "latest" -%>
|
56
|
+
gem install bundler -v '<%= bundler_version %>' --no-document
|
57
|
+
<% else -%>
|
58
|
+
gem install bundler --no-document
|
59
|
+
<% end -%>
|
60
|
+
|
61
|
+
<% gems_to_install.each do |gem_info| -%>
|
62
|
+
# Install <%= gem_info[:name] %>
|
63
|
+
if ! gem list -i <%= gem_info[:name] %> &> /dev/null; then
|
64
|
+
gem install <%= gem_info[:name] %> -v '<%= gem_info[:version] %>' --no-document
|
65
|
+
echo -e "${GREEN}✅ Installed <%= gem_info[:name] %>${NC}"
|
66
|
+
else
|
67
|
+
echo -e "${GREEN}✅ <%= gem_info[:name] %> already installed${NC}"
|
68
|
+
fi
|
69
|
+
|
70
|
+
<% end -%>
|
71
|
+
# Rehash after installing gems
|
72
|
+
rbenv rehash
|
73
|
+
|
74
|
+
# Verify installation
|
75
|
+
echo -e "${YELLOW}🔍 Verifying installation${NC}"
|
76
|
+
echo "Ruby version: $(ruby --version)"
|
77
|
+
echo "Bundler version: $(bundle --version)"
|
78
|
+
echo "Gem environment: $(gem environment home)"
|
79
|
+
|
80
|
+
# Install project dependencies
|
81
|
+
if [ -f "Gemfile" ]; then
|
82
|
+
echo -e "${YELLOW}📦 Installing project gems${NC}"
|
83
|
+
bundle install
|
84
|
+
echo -e "${GREEN}✅ Project gems installed${NC}"
|
85
|
+
fi
|
86
|
+
|
87
|
+
echo -e "${GREEN}🎉 rbenv setup complete!${NC}"
|
88
|
+
echo ""
|
89
|
+
echo "Next steps:"
|
90
|
+
echo "1. Make sure your shell is configured for rbenv:"
|
91
|
+
echo " echo 'eval \"\$(rbenv init -)\"' >> ~/.bashrc # or ~/.zshrc"
|
92
|
+
echo "2. Restart your shell or run: source ~/.bashrc"
|
93
|
+
echo "3. Verify with: rbenv version"
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# RVM setup script generated by rails-dev-setup
|
3
|
+
# This script ensures the correct Ruby version, gemset, and gems are installed
|
4
|
+
|
5
|
+
set -e
|
6
|
+
|
7
|
+
# Colors for output
|
8
|
+
RED='\033[0;31m'
|
9
|
+
GREEN='\033[0;32m'
|
10
|
+
YELLOW='\033[1;33m'
|
11
|
+
BLUE='\033[0;34m'
|
12
|
+
NC='\033[0m' # No Color
|
13
|
+
|
14
|
+
echo -e "${GREEN}🚀 Setting up RVM environment for <%= app_name %>${NC}"
|
15
|
+
|
16
|
+
# Check if RVM is installed
|
17
|
+
if ! command -v rvm &> /dev/null; then
|
18
|
+
echo -e "${RED}❌ RVM is not installed or not properly sourced${NC}"
|
19
|
+
echo "Please install RVM first:"
|
20
|
+
echo " curl -sSL https://get.rvm.io | bash"
|
21
|
+
echo "Then restart your terminal or run: source ~/.rvm/scripts/rvm"
|
22
|
+
exit 1
|
23
|
+
fi
|
24
|
+
|
25
|
+
# Source RVM if not already sourced
|
26
|
+
if ! type rvm | grep -q 'function'; then
|
27
|
+
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
|
28
|
+
fi
|
29
|
+
|
30
|
+
echo -e "${YELLOW}📋 Setting up Ruby <%= ruby_version %> with gemset <%= gemset_name %>${NC}"
|
31
|
+
|
32
|
+
# Install Ruby version if not already installed
|
33
|
+
if ! rvm list | grep -q "ruby-<%= ruby_version %>"; then
|
34
|
+
echo -e "${YELLOW}📦 Installing Ruby <%= ruby_version %>...${NC}"
|
35
|
+
rvm install <%= ruby_version %>
|
36
|
+
echo -e "${GREEN}✅ Ruby <%= ruby_version %> installed${NC}"
|
37
|
+
else
|
38
|
+
echo -e "${GREEN}✅ Ruby <%= ruby_version %> already installed${NC}"
|
39
|
+
fi
|
40
|
+
|
41
|
+
# Create and use the gemset
|
42
|
+
echo -e "${YELLOW}💎 Creating gemset <%= gemset_name %>${NC}"
|
43
|
+
rvm use <%= ruby_version %>@<%= gemset_name %> --create
|
44
|
+
|
45
|
+
# Update RubyGems
|
46
|
+
echo -e "${YELLOW}⬆️ Updating RubyGems${NC}"
|
47
|
+
gem update --system --no-document
|
48
|
+
|
49
|
+
# Install essential gems
|
50
|
+
echo -e "${YELLOW}💎 Installing essential development gems${NC}"
|
51
|
+
|
52
|
+
<% gems_to_install.each do |gem_info| -%>
|
53
|
+
# Install <%= gem_info[:name] %>
|
54
|
+
if ! gem list -i <%= gem_info[:name] %> &> /dev/null; then
|
55
|
+
echo -e "${BLUE}Installing <%= gem_info[:name] %> <%= gem_info[:version] %>${NC}"
|
56
|
+
gem install <%= gem_info[:name] %> -v '<%= gem_info[:version] %>' --no-document
|
57
|
+
echo -e "${GREEN}✅ Installed <%= gem_info[:name] %>${NC}"
|
58
|
+
else
|
59
|
+
echo -e "${GREEN}✅ <%= gem_info[:name] %> already installed${NC}"
|
60
|
+
fi
|
61
|
+
|
62
|
+
<% end -%>
|
63
|
+
# Set default gems for this Ruby version (optional)
|
64
|
+
rvm use <%= ruby_version %>@global
|
65
|
+
if ! gem list bundler -i &> /dev/null; then
|
66
|
+
gem install bundler --no-document
|
67
|
+
fi
|
68
|
+
rvm use <%= ruby_version %>@<%= gemset_name %>
|
69
|
+
|
70
|
+
# Install project dependencies if Gemfile exists
|
71
|
+
if [ -f "Gemfile" ]; then
|
72
|
+
echo -e "${YELLOW}📦 Installing project gems${NC}"
|
73
|
+
bundle install
|
74
|
+
echo -e "${GREEN}✅ Project gems installed${NC}"
|
75
|
+
fi
|
76
|
+
|
77
|
+
# Create wrappers for common commands
|
78
|
+
echo -e "${YELLOW}🔗 Creating RVM wrappers${NC}"
|
79
|
+
rvm wrapper <%= ruby_version %>@<%= gemset_name %> <%= app_name %> ruby bundler rails rake
|
80
|
+
|
81
|
+
# Set up RVM project file
|
82
|
+
echo "<%= ruby_version %>@<%= gemset_name %>" > .rvmrc
|
83
|
+
rvm rvmrc trust .
|
84
|
+
|
85
|
+
echo -e "${GREEN}🎉 RVM setup complete!${NC}"
|
86
|
+
echo ""
|
87
|
+
echo -e "${BLUE}Environment Summary:${NC}"
|
88
|
+
echo "Ruby version: $(ruby --version)"
|
89
|
+
echo "Gemset: $(rvm-prompt g)"
|
90
|
+
echo "Bundler version: $(bundle --version)"
|
91
|
+
echo "Gem path: $(gem environment gemdir)"
|
92
|
+
echo ""
|
93
|
+
echo -e "${BLUE}Useful commands:${NC}"
|
94
|
+
echo " rvm use <%= ruby_version %>@<%= gemset_name %> # Switch to this gemset"
|
95
|
+
echo " rvm gemset list # List all gemsets"
|
96
|
+
echo " rvm gemset empty <%= gemset_name %> # Clear gemset"
|
97
|
+
echo " rvm gemset delete <%= gemset_name %> # Delete gemset"
|
98
|
+
echo ""
|
99
|
+
echo -e "${GREEN}✅ Ready to develop <%= app_name %>!${NC}"
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# RVM configuration generated by rails-dev-setup
|
3
|
+
# This file is automatically sourced when entering the project directory
|
4
|
+
|
5
|
+
# Ruby version and gemset configuration
|
6
|
+
ruby_version="<%= ruby_version %>"
|
7
|
+
gemset_name="<%= gemset_name %>"
|
8
|
+
|
9
|
+
# RVM options
|
10
|
+
<% rvm_options.each do |option| -%>
|
11
|
+
<%= option %>
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
# Use the specified Ruby version and gemset
|
15
|
+
rvm use $ruby_version@$gemset_name --create
|
16
|
+
|
17
|
+
# Environment variables for development
|
18
|
+
<% environment_variables.each do |key, value| -%>
|
19
|
+
export <%= key %>="<%= value %>"
|
20
|
+
<% end -%>
|
21
|
+
|
22
|
+
# Project-specific aliases (optional)
|
23
|
+
alias be="bundle exec"
|
24
|
+
alias ber="bundle exec rails"
|
25
|
+
alias bes="bundle exec rspec"
|
26
|
+
alias bem="bundle exec rake db:migrate"
|
27
|
+
alias bet="bundle exec rake db:test:prepare"
|
28
|
+
|
29
|
+
# RVM project hooks
|
30
|
+
project_rvmrc_hook() {
|
31
|
+
local hook_file=".rvmrc.local"
|
32
|
+
if [[ -f "$hook_file" ]]; then
|
33
|
+
source "$hook_file"
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
# Ruby performance tuning for development
|
38
|
+
export RUBY_GC_HEAP_INIT_SLOTS=10000
|
39
|
+
export RUBY_GC_HEAP_FREE_SLOTS=4000
|
40
|
+
export RUBY_GC_HEAP_GROWTH_FACTOR=1.1
|
41
|
+
export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=10000
|
42
|
+
|
43
|
+
# Bundler configuration
|
44
|
+
export BUNDLE_JOBS=4
|
45
|
+
export BUNDLE_RETRY=3
|
46
|
+
|
47
|
+
# Development environment indicators
|
48
|
+
echo "🚀 <%= app_name %> development environment"
|
49
|
+
echo " Ruby: $(ruby --version | cut -d' ' -f1-2)"
|
50
|
+
echo " Gemset: $gemset_name"
|
51
|
+
echo " Bundler: $(bundle --version 2>/dev/null || echo 'Not installed')"
|
52
|
+
|
53
|
+
# Check for required gems and offer to install
|
54
|
+
if ! gem list bundler -i &> /dev/null; then
|
55
|
+
echo "⚠️ Bundler not found in this gemset"
|
56
|
+
echo " Run: gem install bundler"
|
57
|
+
fi
|
58
|
+
|
59
|
+
if [[ -f "Gemfile" ]] && ! bundle check &> /dev/null; then
|
60
|
+
echo "⚠️ Bundle is not satisfied"
|
61
|
+
echo " Run: bundle install"
|
62
|
+
fi
|
63
|
+
|
64
|
+
# Run project hook if it exists
|
65
|
+
project_rvmrc_hook
|
66
|
+
|
67
|
+
# Auto-install gems if script exists
|
68
|
+
if [[ -f "bin/rvm-setup" ]]; then
|
69
|
+
echo "💡 Tip: Run ./bin/rvm-setup to install all development dependencies"
|
70
|
+
fi
|
data/lib/yoker.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "yoker/version"
|
4
|
+
require_relative "yoker/configuration"
|
5
|
+
require_relative "yoker/errors"
|
6
|
+
require_relative "yoker/detectors/rails_detector"
|
7
|
+
require_relative "yoker/detectors/database_detector"
|
8
|
+
require_relative "yoker/detectors/version_manager_detector"
|
9
|
+
|
10
|
+
module Yoker
|
11
|
+
class Error < StandardError; end
|
12
|
+
|
13
|
+
def self.root
|
14
|
+
File.dirname __dir__
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.template_path
|
18
|
+
File.join(root, "lib", "yoker", "templates")
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configuration
|
22
|
+
@configuration ||= Configuration.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configure
|
26
|
+
yield(configuration) if block_given?
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.reset_configuration!
|
30
|
+
@configuration = nil
|
31
|
+
end
|
32
|
+
end
|
data/sig/yoker.rbs
ADDED