rails_app 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.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.ruby-version +1 -0
  4. data/.standard.yml +3 -0
  5. data/CHANGELOG.md +5 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +42 -0
  8. data/Rakefile +10 -0
  9. data/bin/rails_app +5 -0
  10. data/lib/rails_app/cli.rb +16 -0
  11. data/lib/rails_app/command.rb +41 -0
  12. data/lib/rails_app/error.rb +6 -0
  13. data/lib/rails_app/rails_app.rb +9 -0
  14. data/lib/rails_app/template/.rspec +3 -0
  15. data/lib/rails_app/template/.rubocop.yml +5 -0
  16. data/lib/rails_app/template/.rubocop_todo.yml +0 -0
  17. data/lib/rails_app/template/Brewfile +11 -0
  18. data/lib/rails_app/template/app_bootstrap/assets/stylesheets/_customized_bootstrap.scss +20 -0
  19. data/lib/rails_app/template/app_bootstrap/assets/stylesheets/application.bootstrap.scss +4 -0
  20. data/lib/rails_app/template/app_bootstrap/assets/stylesheets/custom.scss +140 -0
  21. data/lib/rails_app/template/app_bootstrap/helpers/application_helper.rb +2 -0
  22. data/lib/rails_app/template/app_bootstrap/helpers/bootstrap_helper.rb +10 -0
  23. data/lib/rails_app/template/app_bootstrap/views/devise/confirmations/new.html.erb +22 -0
  24. data/lib/rails_app/template/app_bootstrap/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  25. data/lib/rails_app/template/app_bootstrap/views/devise/mailer/email_changed.html.erb +7 -0
  26. data/lib/rails_app/template/app_bootstrap/views/devise/mailer/password_change.html.erb +3 -0
  27. data/lib/rails_app/template/app_bootstrap/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  28. data/lib/rails_app/template/app_bootstrap/views/devise/mailer/unlock_instructions.html.erb +7 -0
  29. data/lib/rails_app/template/app_bootstrap/views/devise/passwords/edit.html.erb +29 -0
  30. data/lib/rails_app/template/app_bootstrap/views/devise/passwords/new.html.erb +20 -0
  31. data/lib/rails_app/template/app_bootstrap/views/devise/registrations/edit.html.erb +45 -0
  32. data/lib/rails_app/template/app_bootstrap/views/devise/registrations/new.html.erb +29 -0
  33. data/lib/rails_app/template/app_bootstrap/views/devise/sessions/new.html.erb +32 -0
  34. data/lib/rails_app/template/app_bootstrap/views/devise/shared/_error_messages.html.erb +15 -0
  35. data/lib/rails_app/template/app_bootstrap/views/devise/shared/_links.html.erb +25 -0
  36. data/lib/rails_app/template/app_bootstrap/views/devise/unlocks/new.html.erb +20 -0
  37. data/lib/rails_app/template/app_bootstrap/views/layouts/application.html.erb +32 -0
  38. data/lib/rails_app/template/app_bootstrap/views/layouts/mailer.html.erb +13 -0
  39. data/lib/rails_app/template/app_bootstrap/views/layouts/mailer.text.erb +1 -0
  40. data/lib/rails_app/template/app_bootstrap/views/shared/_footer.html.erb +5 -0
  41. data/lib/rails_app/template/app_bootstrap/views/shared/_form_errors.html.erb +7 -0
  42. data/lib/rails_app/template/app_bootstrap/views/shared/_navbar.html.erb +18 -0
  43. data/lib/rails_app/template/app_bootstrap/views/shared/_notices.html.erb +8 -0
  44. data/lib/rails_app/template/app_bootstrap/views/static/home.html.erb +2 -0
  45. data/lib/rails_app/template/bin/ci +20 -0
  46. data/lib/rails_app/template/bin/setup +55 -0
  47. data/lib/rails_app/template/bin/yarn +18 -0
  48. data/lib/rails_app/template/config/gems/app.rb +16 -0
  49. data/lib/rails_app/template/config/gems/rspec_gemfile.rb +14 -0
  50. data/lib/rails_app/template/config/initializers/generators.rb +9 -0
  51. data/lib/rails_app/template/esbuild.config.mjs +89 -0
  52. data/lib/rails_app/template/spec/rails_helper.rb +56 -0
  53. data/lib/rails_app/template/spec/spec_helper.rb +92 -0
  54. data/lib/rails_app/template/spec/support/vcr_setup.rb +24 -0
  55. data/lib/rails_app/template/spec/support/webmock.rb +18 -0
  56. data/lib/rails_app/template/template.rb +146 -0
  57. data/lib/rails_app/version.rb +5 -0
  58. data/lib/rails_app.rb +10 -0
  59. data/rails_app.gemspec +36 -0
  60. metadata +159 -0
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "shellwords"
5
+
6
+ puts "options: #{options}"
7
+ puts "args: #{args}"
8
+
9
+ def add_template_to_source_path
10
+ source_paths.unshift(File.expand_path(File.join(__dir__)))
11
+ end
12
+
13
+ def add_gems
14
+ gsub_file "Gemfile", /^ruby ['"].*['"]/, "ruby file: '.ruby-version'"
15
+
16
+ inject_into_file "Gemfile", after: "ruby file: '.ruby-version'" do
17
+ "\neval_gemfile 'config/gems/app.rb'"
18
+ end
19
+
20
+ inject_into_file "Gemfile", after: "eval_gemfile 'config/gems/app.rb'" do
21
+ "\neval_gemfile 'config/gems/rspec_gemfile.rb'"
22
+ end
23
+
24
+ directory "config", "config", force: true
25
+ end
26
+
27
+ def add_javascript
28
+ run "yarn add chokidar -D"
29
+ run "yarn add esbuild-rails"
30
+
31
+ run "echo | node -v | cut -c 2- > .node-version"
32
+ end
33
+
34
+ def add_esbuild_script
35
+ copy_file "esbuild.config.mjs", "esbuild.config.mjs"
36
+ build_script = "node esbuild.config.mjs"
37
+
38
+ case `npx -v`.to_f
39
+ when 7.1...8.0
40
+ run %(npm set-script build "#{build_script}")
41
+ run %(yarn build)
42
+ when (8.0..)
43
+ run %(npm pkg set scripts.build="#{build_script}")
44
+ run %(yarn build)
45
+ else
46
+ say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
47
+ end
48
+ end
49
+
50
+ def add_users
51
+ generate "devise:install"
52
+
53
+ environment "config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }", env: "development"
54
+ environment "config.action_mailer.default_url_options = { host: 'example.com' }", env: "test"
55
+
56
+ generate :devise, "User", "admin:boolean"
57
+
58
+ # Set admin default to false
59
+ in_root do
60
+ migration = Dir.glob("db/migrate/*").max_by { |f| File.mtime(f) }
61
+ gsub_file migration, /:admin/, ":admin, default: false"
62
+ end
63
+
64
+ gsub_file "config/initializers/devise.rb", / {2}# config.secret_key = .+/, " config.secret_key = Rails.application.credentials.secret_key_base"
65
+ end
66
+
67
+ def add_static
68
+ generate "controller static home"
69
+
70
+ route "root to: 'static#home'"
71
+ end
72
+
73
+ def add_bootstrap
74
+ directory "app_bootstrap", "app", force: true
75
+ end
76
+
77
+ def setup_rspec
78
+ copy_file ".rspec", ".rspec"
79
+ directory "spec", "spec", force: true
80
+ end
81
+
82
+ def copy_templates
83
+ copy_file ".rubocop.yml", ".rubocop.yml"
84
+ copy_file ".rubocop_todo.yml", ".rubocop_todo.yml"
85
+ copy_file "Brewfile", "Brewfile"
86
+
87
+ directory "bin", "bin", force: true
88
+ end
89
+
90
+ def database_setup
91
+ remove_file "config/database.yml"
92
+ rails_command("db:system:change --to=postgresql")
93
+ rails_command("db:create")
94
+ rails_command("db:migrate")
95
+ end
96
+
97
+ def command_available?(command)
98
+ system("command -v #{command} >/dev/null 2>&1")
99
+ end
100
+
101
+ def run_setup
102
+ # Install system dependencies if Homebrew is installed
103
+ if command_available?("brew")
104
+ system("brew bundle check --no-lock --no-upgrade") || system!("brew bundle --no-upgrade --no-lock")
105
+ end
106
+ end
107
+
108
+ def add_binstubs
109
+ run "bundle binstub rubocop"
110
+ run "bundle binstub rspec-core" if options[:skip_test]
111
+ end
112
+
113
+ def lint_code
114
+ run "bundle exec rubocop -a"
115
+ end
116
+
117
+ def initial_commit
118
+ run "git init"
119
+ run "git add . && git commit -m \"Initial_commit\""
120
+ end
121
+
122
+ # Main setup
123
+ add_template_to_source_path
124
+
125
+ add_gems
126
+
127
+ after_bundle do
128
+ add_javascript
129
+ add_esbuild_script
130
+ add_users
131
+ add_static
132
+ add_bootstrap
133
+ setup_rspec
134
+ copy_templates
135
+ database_setup
136
+ run_setup
137
+ add_binstubs
138
+ lint_code
139
+ initial_commit
140
+
141
+ say
142
+ say "Rails app successfully created!", :blue
143
+ say
144
+ say "To get started with your new app:", :green
145
+ say " cd #{app_name}"
146
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsApp
4
+ VERSION = "0.1.0"
5
+ end
data/lib/rails_app.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rails_app/version"
4
+
5
+ module RailsApp
6
+ autoload :App, "rails_app/rails_app"
7
+ autoload :CLI, "rails_app/cli"
8
+ autoload :Command, "rails_app/command"
9
+ autoload :Error, "rails_app/error"
10
+ end
data/rails_app.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rails_app/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rails_app"
7
+ spec.version = RailsApp::VERSION
8
+ spec.authors = ["Chuck Smith"]
9
+ spec.email = ["chuck@eclecticsaddlebag.com"]
10
+
11
+ spec.summary = "Write a short summary, because RubyGems requires one."
12
+ spec.description = "Write a longer description or delete this line."
13
+ spec.homepage = "https://github.com/eclectic-coding/rails_app"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.1.4"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/eclectic-coding/rails_app"
19
+ spec.metadata["changelog_uri"] = "https://github.com/eclectic-coding/rails_app/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.bindir = "bin"
30
+ spec.executables = ["rails_app"]
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "bootsnap", "~> 1.18", ">= 1.18.3" # used by rails new
34
+ spec.add_dependency "thor", "~> 1.3", ">= 1.3.1"
35
+ spec.add_dependency "tty-prompt", "~> 0.23.1"
36
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chuck Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bootsnap
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.18'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.18.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.18'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.18.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: thor
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.3.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.3'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.3.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: tty-prompt
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 0.23.1
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 0.23.1
67
+ description: Write a longer description or delete this line.
68
+ email:
69
+ - chuck@eclecticsaddlebag.com
70
+ executables:
71
+ - rails_app
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".rspec"
76
+ - ".ruby-version"
77
+ - ".standard.yml"
78
+ - CHANGELOG.md
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/rails_app
83
+ - lib/rails_app.rb
84
+ - lib/rails_app/cli.rb
85
+ - lib/rails_app/command.rb
86
+ - lib/rails_app/error.rb
87
+ - lib/rails_app/rails_app.rb
88
+ - lib/rails_app/template/.rspec
89
+ - lib/rails_app/template/.rubocop.yml
90
+ - lib/rails_app/template/.rubocop_todo.yml
91
+ - lib/rails_app/template/Brewfile
92
+ - lib/rails_app/template/app_bootstrap/assets/stylesheets/_customized_bootstrap.scss
93
+ - lib/rails_app/template/app_bootstrap/assets/stylesheets/application.bootstrap.scss
94
+ - lib/rails_app/template/app_bootstrap/assets/stylesheets/custom.scss
95
+ - lib/rails_app/template/app_bootstrap/helpers/application_helper.rb
96
+ - lib/rails_app/template/app_bootstrap/helpers/bootstrap_helper.rb
97
+ - lib/rails_app/template/app_bootstrap/views/devise/confirmations/new.html.erb
98
+ - lib/rails_app/template/app_bootstrap/views/devise/mailer/confirmation_instructions.html.erb
99
+ - lib/rails_app/template/app_bootstrap/views/devise/mailer/email_changed.html.erb
100
+ - lib/rails_app/template/app_bootstrap/views/devise/mailer/password_change.html.erb
101
+ - lib/rails_app/template/app_bootstrap/views/devise/mailer/reset_password_instructions.html.erb
102
+ - lib/rails_app/template/app_bootstrap/views/devise/mailer/unlock_instructions.html.erb
103
+ - lib/rails_app/template/app_bootstrap/views/devise/passwords/edit.html.erb
104
+ - lib/rails_app/template/app_bootstrap/views/devise/passwords/new.html.erb
105
+ - lib/rails_app/template/app_bootstrap/views/devise/registrations/edit.html.erb
106
+ - lib/rails_app/template/app_bootstrap/views/devise/registrations/new.html.erb
107
+ - lib/rails_app/template/app_bootstrap/views/devise/sessions/new.html.erb
108
+ - lib/rails_app/template/app_bootstrap/views/devise/shared/_error_messages.html.erb
109
+ - lib/rails_app/template/app_bootstrap/views/devise/shared/_links.html.erb
110
+ - lib/rails_app/template/app_bootstrap/views/devise/unlocks/new.html.erb
111
+ - lib/rails_app/template/app_bootstrap/views/layouts/application.html.erb
112
+ - lib/rails_app/template/app_bootstrap/views/layouts/mailer.html.erb
113
+ - lib/rails_app/template/app_bootstrap/views/layouts/mailer.text.erb
114
+ - lib/rails_app/template/app_bootstrap/views/shared/_footer.html.erb
115
+ - lib/rails_app/template/app_bootstrap/views/shared/_form_errors.html.erb
116
+ - lib/rails_app/template/app_bootstrap/views/shared/_navbar.html.erb
117
+ - lib/rails_app/template/app_bootstrap/views/shared/_notices.html.erb
118
+ - lib/rails_app/template/app_bootstrap/views/static/home.html.erb
119
+ - lib/rails_app/template/bin/ci
120
+ - lib/rails_app/template/bin/setup
121
+ - lib/rails_app/template/bin/yarn
122
+ - lib/rails_app/template/config/gems/app.rb
123
+ - lib/rails_app/template/config/gems/rspec_gemfile.rb
124
+ - lib/rails_app/template/config/initializers/generators.rb
125
+ - lib/rails_app/template/esbuild.config.mjs
126
+ - lib/rails_app/template/spec/rails_helper.rb
127
+ - lib/rails_app/template/spec/spec_helper.rb
128
+ - lib/rails_app/template/spec/support/vcr_setup.rb
129
+ - lib/rails_app/template/spec/support/webmock.rb
130
+ - lib/rails_app/template/template.rb
131
+ - lib/rails_app/version.rb
132
+ - rails_app.gemspec
133
+ homepage: https://github.com/eclectic-coding/rails_app
134
+ licenses:
135
+ - MIT
136
+ metadata:
137
+ homepage_uri: https://github.com/eclectic-coding/rails_app
138
+ source_code_uri: https://github.com/eclectic-coding/rails_app
139
+ changelog_uri: https://github.com/eclectic-coding/rails_app/blob/main/CHANGELOG.md
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 3.1.4
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubygems_version: 3.5.6
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Write a short summary, because RubyGems requires one.
159
+ test_files: []