modulorails 1.5.2.pre.2 → 1.7.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/skills/release-modulorails/SKILL.md +150 -0
  3. data/.rubocop.yml +2 -1
  4. data/CHANGELOG.md +55 -8
  5. data/Gemfile.lock +75 -26
  6. data/README.md +69 -9
  7. data/lib/generators/modulorails/claude_code/claude_code_generator.rb +64 -0
  8. data/lib/generators/modulorails/claude_code/templates/.gitlab-ci.yml.tt +120 -0
  9. data/lib/generators/modulorails/claude_code/templates/.modulorails-gitlab-ci +6 -0
  10. data/lib/generators/modulorails/claude_code/templates/bin/init-firewall.sh.tt +118 -0
  11. data/lib/generators/modulorails/docker/compose/compose_generator.rb +7 -6
  12. data/lib/generators/modulorails/docker/config/config_generator.rb +11 -5
  13. data/lib/generators/modulorails/docker/config/templates/config/database.yml.tt +7 -2
  14. data/lib/generators/modulorails/docker/devcontainer/devcontainer_generator.rb +52 -0
  15. data/lib/generators/modulorails/docker/devcontainer/templates/devcontainer/Dockerfile.tt +53 -0
  16. data/lib/generators/modulorails/docker/devcontainer/templates/devcontainer/compose.yml.tt +97 -0
  17. data/lib/generators/modulorails/docker/devcontainer/templates/devcontainer/devcontainer.json.tt +80 -0
  18. data/lib/generators/modulorails/docker/docker_generator.rb +7 -0
  19. data/lib/generators/modulorails/docker/dockerfile/dockerfile_generator.rb +15 -11
  20. data/lib/generators/modulorails/docker/dockerfile/templates/dockerfiles/{rails/Dockerfile.prod.tt → Dockerfile.prod.tt} +31 -12
  21. data/lib/generators/modulorails/docker/dockerfile/templates/dockerfiles/dockerignore.tt +120 -0
  22. data/lib/generators/modulorails/docker/entrypoint/entrypoint_generator.rb +11 -5
  23. data/lib/generators/modulorails/docker/entrypoint/templates/entrypoints/docker-entrypoint.sh.tt +5 -0
  24. data/lib/generators/modulorails/githooks/githooks_generator.rb +5 -3
  25. data/lib/generators/modulorails/githooks/templates/dc.sh +30 -0
  26. data/lib/generators/modulorails/githooks/templates/dcr.sh +47 -0
  27. data/lib/generators/modulorails/githooks/templates/post-rewrite.sh +1 -1
  28. data/lib/generators/modulorails/githooks/templates/pre-merge-commit.sh +1 -1
  29. data/lib/generators/modulorails/githooks/templates/refresh_generations.sh +17 -9
  30. data/lib/generators/modulorails/gitlabci/gitlabci_generator.rb +7 -1
  31. data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +15 -13
  32. data/lib/generators/modulorails/gitlabci/templates/bin/test.sh.tt +36 -0
  33. data/lib/generators/modulorails/gitlabci/templates/config/deploy/production.yaml.tt +4 -4
  34. data/lib/generators/modulorails/gitlabci/templates/config/deploy/review.yaml.tt +4 -4
  35. data/lib/generators/modulorails/gitlabci/templates/config/deploy/staging.yaml.tt +7 -7
  36. data/lib/generators/modulorails/moduloproject/moduloproject_generator.rb +8 -3
  37. data/lib/generators/modulorails/moduloproject/templates/config/environments/production.rb.tt +21 -51
  38. data/lib/generators/modulorails/rubocop/rubocop_generator.rb +8 -3
  39. data/lib/generators/modulorails/rubocop/templates/rubocop.yml.tt +7 -1
  40. data/lib/generators/modulorails/self_update/self_update_generator.rb +4 -0
  41. data/lib/generators/modulorails/sidekiq/sidekiq_generator.rb +95 -38
  42. data/lib/generators/modulorails/sidekiq/templates/config/initializers/sidekiq.rb.tt +4 -4
  43. data/lib/modulorails/configuration.rb +17 -7
  44. data/lib/modulorails/data.rb +41 -12
  45. data/lib/modulorails/generators/base.rb +1 -1
  46. data/lib/modulorails/railtie.rb +4 -1
  47. data/lib/modulorails/version.rb +1 -1
  48. data/lib/modulorails.rb +15 -5
  49. metadata +17 -10
  50. data/lib/generators/modulorails/docker/compose/templates/docker-compose.yml.tt +0 -81
  51. data/lib/generators/modulorails/docker/dockerfile/templates/dockerfiles/modulotech/Dockerfile.prod.tt +0 -66
  52. data/lib/generators/modulorails/docker/dockerfile/templates/dockerfiles/modulotech/Dockerfile.tt +0 -30
  53. data/lib/generators/modulorails/docker/entrypoint/templates/entrypoints/webpack-entrypoint.sh.tt +0 -7
  54. data/lib/generators/modulorails/githooks/templates/dockeruby.rb +0 -124
  55. data/lib/generators/modulorails/sidekiq/templates/entrypoints/sidekiq-entrypoint.sh.tt +0 -7
@@ -1,81 +0,0 @@
1
- services:
2
- app:
3
- image: modulotechgroup/<%= @image_name %>:dev
4
- build:
5
- context: .
6
- dockerfile: Dockerfile
7
- depends_on:
8
- - database
9
- - redis
10
- ports:
11
- - '3000:3000'
12
- volumes:
13
- - .:/app
14
- environment:
15
- RAILS_ENV: development
16
- URL: http://localhost:3000
17
- <%- if @adapter =~ /mysql/ -%>
18
- DATABASE_URL: mysql2://root@database/<%= @image_name %>
19
- DATABASE_TEST_URL: mysql2://root@database/<%= @image_name %>-test
20
- <%- else -%>
21
- DATABASE_URL: postgresql://postgres:postgres@database/<%= @image_name %>
22
- DATABASE_TEST_URL: postgresql://postgres:postgres@database/<%= @image_name %>-test
23
- <%- end -%>
24
- REDIS_URL: redis://redis:6379/1
25
- stdin_open: true
26
- tty: true
27
-
28
- <%- if @adapter =~ /mysql/ -%>
29
- database:
30
- image: mysql/mysql-server:8.0
31
- volumes:
32
- - db_data:/var/lib/mysql
33
- ports:
34
- - '3306:3306'
35
- environment:
36
- MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
37
- MYSQL_DATABASE: <%= @image_name %>
38
- MYSQL_ROOT_HOST: '%'
39
- <%- else -%>
40
- database:
41
- image: postgres:16-alpine
42
- volumes:
43
- - db_data:/var/lib/postgresql/data
44
- ports:
45
- - '5432:5432'
46
- environment:
47
- POSTGRES_USER: postgres
48
- POSTGRES_PASSWORD: postgres
49
- POSTGRES_DB: <%= @image_name %>
50
- LC_COLLATE: 'en_US.UTF-8'
51
- LC_CTYPE: 'en_US.UTF-8'
52
- <%- end -%>
53
-
54
- redis:
55
- image: redis:7-alpine
56
-
57
- mailcatcher:
58
- image: dockage/mailcatcher
59
- ports:
60
- - '1080:1080'
61
- - '1025:1025'
62
-
63
- <%- if @webpack_container_needed -%>
64
- webpack:
65
- image: modulotechgroup/<%= @image_name %>:dev
66
- build:
67
- context: .
68
- dockerfile: Dockerfile
69
- entrypoint: ./bin/webpack-entrypoint
70
- volumes:
71
- - .:/app
72
- ports:
73
- - '3035:3035'
74
- environment:
75
- NODE_ENV: development
76
- RAILS_ENV: development
77
- WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
78
- <%- end -%>
79
-
80
- volumes:
81
- db_data:
@@ -1,66 +0,0 @@
1
- # BUILD IMAGE
2
- FROM ruby:<%= @data.ruby_version %>-alpine as builder
3
-
4
- ENV RAILS_ENV=production \
5
- SECRET_KEY_BASE=1
6
- WORKDIR /app
7
-
8
- RUN apk add --update --no-cache \
9
- alpine-sdk \
10
- nodejs \
11
- tzdata \
12
- yarn \
13
- shared-mime-info \
14
- gcompat \
15
- <%- if @adapter =~ /mysql/ -%>
16
- mysql-dev
17
- <%- else -%>
18
- postgresql-dev
19
- <%- end -%>
20
- RUN gem install bundler -v <%= @data.bundler_version %>
21
-
22
- COPY Gemfile Gemfile.lock ./
23
- RUN bundle config set --local deployment 'true' \
24
- && bundle check || bundle install --jobs=2 \
25
- && rm -rf vendor/bundle/ruby/*/cache/*
26
-
27
- <%- if @webpack_container_needed -%>
28
- COPY package.json yarn.lock ./
29
- RUN yarn install
30
- <%- end-%>
31
-
32
- COPY . .
33
- RUN bundle exec rake assets:precompile
34
-
35
- # FINAL IMAGE
36
- FROM ruby:<%= @data.ruby_version %>-alpine
37
-
38
- ENV RAILS_ENV=development \
39
- EDITOR=vim
40
- WORKDIR /app
41
- RUN adduser -D user
42
-
43
- RUN apk add --update --no-cache \
44
- git \
45
- nodejs \
46
- tzdata \
47
- shared-mime-info \
48
- vim \
49
- <%- if @adapter =~ /mysql/ -%>
50
- mysql-dev \
51
- <%- else -%>
52
- postgresql-dev \
53
- <%- end -%>
54
- && rm -rf .git/
55
- RUN gem install bundler -v <%= @data.bundler_version %>
56
-
57
- COPY --chown=user:user --from=builder /app .
58
-
59
- RUN bundle config --local path vendor/bundle \
60
- && bundle config --local without development:test:assets
61
-
62
- EXPOSE 3000
63
-
64
- ENTRYPOINT ["./bin/docker-entrypoint"]
65
-
66
- CMD ["./bin/rails", "server"]
@@ -1,30 +0,0 @@
1
- FROM ruby:<%= @data.ruby_version %>-alpine
2
-
3
- ENV RAILS_ENV=development
4
- ENV EDITOR=vim
5
- WORKDIR /app
6
-
7
- RUN apk add --update --no-cache \
8
- alpine-sdk \
9
- nodejs \
10
- yarn \
11
- tzdata \
12
- gcompat \
13
- vim \
14
- <%- if @adapter =~ /mysql/ -%>
15
- mysql-dev
16
- <%- else -%>
17
- postgresql-dev
18
- <%- end -%>
19
- RUN gem install bundler -v <%= @data.bundler_version %>
20
-
21
- COPY Gemfile Gemfile.lock ./
22
- RUN bundle install --jobs=2
23
-
24
- COPY . .
25
-
26
- EXPOSE 3000
27
-
28
- ENTRYPOINT ["./bin/docker-entrypoint"]
29
-
30
- CMD ["./bin/rails", "server"]
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
-
3
- # Exit immediately if a command exits with a non-zero status
4
- set -e
5
-
6
- # Launch webpack
7
- exec ./bin/webpack-dev-server
@@ -1,124 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- def require_or_install(gem_name, version=nil)
5
- gem(gem_name, "~> #{version}") unless version.nil?
6
- require gem_name
7
- rescue LoadError
8
- warn "Installing gem #{gem_name}"
9
- if version.nil?
10
- Gem.install(gem_name)
11
- else
12
- Gem.install(gem_name, "~> #{version}")
13
- gem(gem_name, "~> #{version}")
14
- end
15
- require gem_name
16
- end
17
-
18
- require_or_install('shellwords')
19
-
20
- def check_dockerfile(verbose: false)
21
- return true if File.exist?('Dockerfile')
22
-
23
- puts('No Dockerfile') if verbose
24
- false
25
- end
26
-
27
- def entrypoint_location
28
- entrypoint_line = File.readlines('Dockerfile').find { |line| line.start_with?('ENTRYPOINT') }
29
-
30
- return nil if entrypoint_line.nil?
31
-
32
- md = /\[["'](.+)["']\]/.match(entrypoint_line)
33
- return nil if md.nil? || md[1].nil?
34
-
35
- md[1]
36
- end
37
-
38
- VALID_LAST_INSTRUCTION = /exec "\$\{?@}?"/.freeze
39
-
40
- def check_entrypoint(verbose: false)
41
- el = entrypoint_location
42
- return true if el.nil?
43
-
44
- unless File.exist?(el)
45
- warn("Entrypoint not found at location: #{el}") if verbose
46
- return false
47
- end
48
-
49
- last_line = File.readlines(el).last&.strip
50
- return true if VALID_LAST_INSTRUCTION.match?(last_line)
51
-
52
- warn("Invalid entrypoint: Last instruction should be 'exec \"${@}\"' instead of '#{last_line}'") if verbose
53
-
54
- false
55
- end
56
-
57
- def executer_docker_run(docker_args, verbose: false)
58
- pwd = Dir.pwd
59
- working_directory = File.basename(pwd)
60
-
61
- volumes = `docker volume ls -q -f name=modulogem`
62
- volumes = volumes.split("\n").map(&:strip)
63
- modulogem_gems = volumes.find { |volume| volume.include?('modulogem_gems') }
64
- modulogem = volumes.find { |volume| volume.include?('modulogem') }
65
- modulogem_gems_option = modulogem_gems.nil? ? '' : "-v #{modulogem_gems}:/usr/local/bundle"
66
- modulogem_option = modulogem.nil? ? '' : "-v #{modulogem}:/root"
67
-
68
- # Check if the shell is a TTY
69
- tty_option = $stdout.isatty ? '-ti' : ''
70
-
71
- # Build the command string
72
- # rubocop:disable Layout/LineLength
73
- command = %(docker run --pull=always --rm #{modulogem_gems_option} #{modulogem_option} -v '#{pwd}:/app/#{working_directory}' #{tty_option} -w '/app/#{working_directory}' ruby:latest #{docker_args})
74
- # rubocop:enable Layout/LineLength
75
-
76
- puts(command) if verbose
77
- exec(command)
78
- end
79
-
80
- def executer_compose_run(docker_args, verbose: false)
81
- entrypoint_option = check_entrypoint(verbose: verbose) ? '' : '--entrypoint "sh -c"'
82
- git_email = `git config --get user.email`.strip
83
- git_name = `git config --get user.name`.strip
84
-
85
- # Check if the shell is a TTY
86
- tty_option = $stdout.isatty ? '-ti' : ''
87
-
88
- # rubocop:disable Layout/LineLength
89
- command = %(docker compose build && docker compose run --rm #{tty_option} -e "GIT_AUTHOR_EMAIL=#{git_email}" -e "GIT_AUTHOR_NAME=#{git_name}" -e "GIT_COMMITTER_EMAIL=#{git_email}" -e "GIT_COMMITTER_NAME=#{git_name}" #{entrypoint_option} app)
90
- command = if entrypoint_option == ''
91
- "#{command} #{docker_args}"
92
- else
93
- "#{command} '#{docker_args}'"
94
- end
95
- # rubocop:enable Layout/LineLength
96
- puts(command) if verbose
97
- exec(command)
98
- end
99
-
100
- def contains_command(escaped_args)
101
- escaped_args.each_with_index.any? do |arg, index|
102
- !arg.start_with?('-') && (index.zero? || !escaped_args[index - 1].start_with?('-'))
103
- end
104
- end
105
-
106
- def main(args, verbose: false)
107
- # Escape each argument individually
108
- escaped_args = args.map { |arg| Shellwords.escape(arg) }
109
-
110
- # Prefix the arguments with a `ruby` command if there is not already one
111
- docker_args = if contains_command(escaped_args)
112
- escaped_args.join(' ')
113
- else
114
- "ruby #{escaped_args.join(' ')}"
115
- end
116
-
117
- if check_dockerfile(verbose: verbose)
118
- executer_compose_run(docker_args, verbose: verbose)
119
- else
120
- executer_docker_run(docker_args, verbose: verbose)
121
- end
122
- end
123
-
124
- main(ARGV, verbose: true)
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
-
3
- # Exit immediately if a command exits with a non-zero status
4
- set -e
5
-
6
- # Launch Sidekiq
7
- exec ./bin/bundle exec sidekiq