nextgen 0.12.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6db9fb7cd60bea395ad5018e18a905246e877a34bc6f8742194e7302035b5ad
4
- data.tar.gz: f3538f1ec8b8bd8280caa19f0410a04c43376343de6b2d5870ff01f7ea17eb17
3
+ metadata.gz: c12df02c71f082201cf7bf8c9e24c4f3d2d1c30a9969a70cf91b5597375b0648
4
+ data.tar.gz: cd01af3eebf2075ef05b9d1bc5c1dc4856acc101589f87bb0c5d8d59126553d4
5
5
  SHA512:
6
- metadata.gz: 7ebb05f8e034cbd54cc88cafebb45da4dd6d0f165a2495c108441ad4816d7ad417bbf8be86389a32cad148bcc7fbe2b997f6c655c5df6bc95f6ea26b60576adb
7
- data.tar.gz: 4ac4898307cb50f20650dcf45d4090a1c3af2c32cd316e0e0a24187db074919e92baf8bb81cefa4a1f50813641e680c12e09acbfcdbc826f401355721c9ba1ef
6
+ metadata.gz: 630e92302ffd0d5f87b3e37c9d64fb4f4f6fa7a67ce45b585e1398bab30566097e3f092e54b922db3f8a68ba83c8b0d661fbde48c8f636baff3f908af4de724c
7
+ data.tar.gz: 760e9b02cc4b8bb948a2e6d707af9bfdfd212658699e80578249ca7ca02ec1763f5baebc2583d8e44c7b054d718a458536acce757414334224090df31361ef26
data/README.md CHANGED
@@ -28,7 +28,7 @@ Nextgen is an **interactive** and flexible alternative to `rails new` that inclu
28
28
 
29
29
  Nextgen generates apps using **Rails 7.1**.
30
30
 
31
- - **Ruby 3.0+** is required
31
+ - **Ruby 3.1+** is required
32
32
  - **Rubygems 3.4.8+** is required (run `gem update --system` to get it)
33
33
  - **Node 18.12+ and Yarn** are required if you choose Vite or other Node-based options
34
34
  - Additional tools may be required depending on the options you select (e.g. PostgreSQL)
@@ -119,6 +119,10 @@ sidekiq:
119
119
  description: "Install sidekiq gem to use in production"
120
120
  requires: active_job
121
121
 
122
+ staging:
123
+ prompt: "Staging environment"
124
+ description: "Define a staging environment"
125
+
122
126
  stylelint:
123
127
  prompt: "Stylelint"
124
128
  description: "Install stylelint and apply prettier format to CSS"
@@ -13,7 +13,7 @@ module Nextgen
13
13
  false
14
14
  else
15
15
  say_status :gemfile, [name, version].compact.join(", ")
16
- gemfile.add(name, version: version, group: group, require: require)
16
+ gemfile.add(name, version:, group:, require:)
17
17
  true
18
18
  end
19
19
  end
@@ -44,7 +44,7 @@ module Nextgen
44
44
 
45
45
  Bundler.with_original_env do
46
46
  say_status :bundle, cmd, :green if verbose
47
- run! full_command, env: {"BUNDLE_IGNORE_MESSAGES" => "1"}, verbose: false, capture: capture
47
+ run! full_command, env: {"BUNDLE_IGNORE_MESSAGES" => "1"}, verbose: false, capture:
48
48
  end
49
49
  end
50
50
 
@@ -55,6 +55,10 @@ module Nextgen
55
55
  false
56
56
  end
57
57
 
58
+ def bundler_ruby_file_supported?
59
+ bundler_version_satisifed?(">= 2.4.20")
60
+ end
61
+
58
62
  def noisy_bundler_version?
59
63
  bundler_version_satisifed?("< 2.4.17")
60
64
  end
@@ -7,7 +7,7 @@ module Nextgen
7
7
  alias add_yarn_package add_yarn_packages
8
8
 
9
9
  def remove_yarn_packages(*packages, capture: false)
10
- yarn_command "remove #{packages.map(&:shellescape).join(" ")}", capture: capture
10
+ yarn_command "remove #{packages.map(&:shellescape).join(" ")}", capture:
11
11
  end
12
12
  alias remove_yarn_package remove_yarn_packages
13
13
 
@@ -22,7 +22,7 @@ module Nextgen
22
22
  result, status = Open3.capture2e(env, cmd)
23
23
  success = status.success?
24
24
  else
25
- result = success = run(cmd, env: env, verbose: verbose)
25
+ result = success = run(cmd, env:, verbose:)
26
26
  end
27
27
 
28
28
  return result if success
@@ -82,9 +82,9 @@ module Nextgen
82
82
 
83
83
  def document_deploy_var(var_name, desc = nil, required: false, default: nil)
84
84
  insertion = "`#{var_name}`"
85
+ insertion << " **REQUIRED**" if required
85
86
  insertion << " - #{desc}" if desc.present?
86
87
  insertion << " (default: #{default})" unless default.nil?
87
- insertion.prepend "**REQUIRED** " if required
88
88
 
89
89
  copy_file "DEPLOYMENT.md" unless File.exist?("DEPLOYMENT.md")
90
90
  inject_into_file "DEPLOYMENT.md", "#{insertion}\n- ", after: /^## Environment variables.*?^- /m
@@ -26,9 +26,9 @@ module Nextgen
26
26
  say <<~BANNER
27
27
  Welcome to nextgen, the interactive Rails app generator!
28
28
 
29
- You are about to create a Rails app named "#{app_name}" in the following directory:
29
+ You are about to create a Rails app named "#{cyan(app_name)}" in the following directory:
30
30
 
31
- #{app_path}
31
+ #{cyan(app_path)}
32
32
 
33
33
  You'll be asked ~10 questions about database, test framework, and other options.
34
34
  The standard Rails "omakase" experience will be selected by default.
@@ -83,10 +83,10 @@ module Nextgen
83
83
  say <<~DONE.gsub(/^/, " ")
84
84
 
85
85
 
86
- #{set_color("Done!", :green)}
86
+ #{green("Done!")}
87
87
 
88
- A Rails #{rails_version} app was generated in #{set_color(app_path, :cyan)}.
89
- Run #{set_color("bin/setup", :yellow)} in that directory to get started.
88
+ A Rails #{rails_version} app was generated in #{cyan(app_path)}.
89
+ Run #{yellow("bin/setup")} in that directory to get started.
90
90
 
91
91
 
92
92
  DONE
@@ -96,7 +96,7 @@ module Nextgen
96
96
 
97
97
  attr_accessor :app_path, :app_name, :rails_opts, :generators
98
98
 
99
- def_delegators :shell, :say, :set_color
99
+ def_delegators :shell, :say
100
100
 
101
101
  def continue_if(question)
102
102
  if prompt.yes?(question)
@@ -141,12 +141,12 @@ module Nextgen
141
141
  "None (disable Active Record)" => nil
142
142
  )
143
143
  rails_opts.database =
144
- prompt.select("Which database?", common_databases.merge("More options..." => false)) ||
145
- prompt.select("Which database?", all_databases)
144
+ prompt_select("Which database?", common_databases.merge("More options..." => false)) ||
145
+ prompt_select("Which database?", all_databases)
146
146
  end
147
147
 
148
148
  def ask_full_stack_or_api
149
- api = prompt.select(
149
+ api = prompt_select(
150
150
  "What style of Rails app do you need?",
151
151
  "Standard, full-stack Rails (default)" => false,
152
152
  "API only" => true
@@ -155,12 +155,13 @@ module Nextgen
155
155
  end
156
156
 
157
157
  def ask_frontend_management
158
- frontend = prompt.select(
158
+ frontend = prompt_select(
159
159
  "How will you manage frontend assets?",
160
160
  "Sprockets (default)" => "sprockets",
161
161
  "Propshaft" => "propshaft",
162
162
  "Vite" => :vite
163
163
  )
164
+
164
165
  if frontend == :vite
165
166
  rails_opts.asset_pipeline = nil
166
167
  rails_opts.javascript = "vite"
@@ -170,7 +171,7 @@ module Nextgen
170
171
  end
171
172
 
172
173
  def ask_css
173
- rails_opts.css = prompt.select(
174
+ rails_opts.css = prompt_select(
174
175
  "Which CSS framework will you use with the asset pipeline?",
175
176
  "None (default)" => nil,
176
177
  "Bootstrap" => "bootstrap",
@@ -182,7 +183,7 @@ module Nextgen
182
183
  end
183
184
 
184
185
  def ask_javascript
185
- rails_opts.javascript = prompt.select(
186
+ rails_opts.javascript = prompt_select(
186
187
  "Which JavaScript bundler will you use with the asset pipeline?",
187
188
  "Importmap (default)" => "importmap",
188
189
  "Bun" => "bun",
@@ -223,7 +224,7 @@ module Nextgen
223
224
  end
224
225
 
225
226
  def ask_test_framework
226
- rails_opts.test_framework = prompt.select(
227
+ rails_opts.test_framework = prompt_select(
227
228
  "Which test framework will you use?",
228
229
  "Minitest (default)" => "minitest",
229
230
  "RSpec" => "rspec",
@@ -232,7 +233,7 @@ module Nextgen
232
233
  end
233
234
 
234
235
  def ask_system_testing
235
- system_testing = prompt.select(
236
+ system_testing = prompt_select(
236
237
  "Include system testing (capybara)?",
237
238
  "Yes (default)" => true,
238
239
  "No" => false
@@ -241,7 +242,7 @@ module Nextgen
241
242
  end
242
243
 
243
244
  def ask_optional_enhancements
244
- @generators = Generators.compatible_with(rails_opts: rails_opts)
245
+ @generators = Generators.compatible_with(rails_opts:)
245
246
 
246
247
  answers = prompt.multi_select(
247
248
  "Which optional enhancements would you like to add?",
@@ -309,5 +310,10 @@ module Nextgen
309
310
  def shell
310
311
  @shell ||= Thor::Base.shell.new
311
312
  end
313
+
314
+ def cyan(string) = shell.set_color(string, :cyan)
315
+ def green(string) = shell.set_color(string, :green)
316
+ def yellow(string) = shell.set_color(string, :yellow)
317
+ def prompt_select(question, choices) = prompt.select(question, choices, cycle: true)
312
318
  end
313
319
  end
@@ -33,7 +33,11 @@ end
33
33
 
34
34
  if File.exist?(".ruby-version") && File.read(".ruby-version").match?(/\A\d+\.\d+.\d+.\s*\z/m)
35
35
  say_git "DRY up Gemfile and .ruby-version file"
36
- replacement = 'ruby Pathname.new(__dir__).join(".ruby-version").read.strip'
36
+ replacement = if bundler_ruby_file_supported?
37
+ 'ruby file: ".ruby-version"'
38
+ else
39
+ 'ruby Pathname.new(__dir__).join(".ruby-version").read.strip'
40
+ end
37
41
  gsub_file "Gemfile", /^ruby "\d.*"$/, replacement
38
42
  end
39
43
 
@@ -1,7 +1,9 @@
1
1
  say_git "Install eslint"
2
2
  add_yarn_packages(
3
- "eslint",
3
+ "@eslint/js",
4
+ "eslint@^9",
4
5
  "eslint-config-prettier",
6
+ "eslint-formatter-compact",
5
7
  "eslint-plugin-prettier",
6
8
  "prettier",
7
9
  "npm-run-all",
@@ -14,7 +16,7 @@ add_package_json_scripts(
14
16
  lint: "npm-run-all lint:**",
15
17
  fix: "npm-run-all fix:**"
16
18
  )
17
- copy_file ".eslintrc.cjs"
19
+ copy_file "eslint.config.js"
18
20
 
19
21
  say_git "Add eslint to default rake task"
20
22
  copy_file "lib/tasks/eslint.rake"
@@ -0,0 +1,12 @@
1
+ copy_file "config/environments/staging.rb"
2
+ gsub_file "DEPLOYMENT.md", '"production"', '"production" or "staging"' if File.exist?("DEPLOYMENT.md")
3
+
4
+ %w[config/cable.yml config/database.yml].each do |file|
5
+ next unless File.exist?(file)
6
+
7
+ config_yml = File.read(file)
8
+ config_yml.sub!(/^production:\n( .*\n)+/) do |match|
9
+ match + "\n" + match.gsub("production", "staging")
10
+ end
11
+ File.write(file, config_yml)
12
+ end
@@ -46,9 +46,13 @@ say_git "Install autoprefixer"
46
46
  add_yarn_packages "postcss@^8.4.24", "autoprefixer@^10.4.14"
47
47
  copy_file "postcss.config.cjs"
48
48
 
49
- say_git "Disable autoBuild in test environment"
50
- gsub_file "config/vite.json", /("test": \{.+?"autoBuild":\s*)true/m, '\1false'
51
- copy_test_support_file "vite.rb"
49
+ # TODO: rspec support
50
+ if File.exist?("test/application_system_test_case.rb")
51
+ say_git "Disable autoBuild in test environment"
52
+ gsub_file "config/vite.json", /("test": \{.+?"autoBuild":\s*)true/m, '\1false'
53
+ copy_file "test/vite_helper.rb"
54
+ inject_into_file "test/application_system_test_case.rb", "\nrequire \"vite_helper\"", after: /require "test_helper"$/
55
+ end
52
56
 
53
57
  say_git "Install modern-normalize and base stylesheets"
54
58
  add_yarn_package "modern-normalize@^2.0.0"
@@ -84,11 +88,11 @@ end
84
88
  copy_file "app/helpers/inline_svg_helper.rb"
85
89
  copy_file "app/frontend/images/example.svg"
86
90
  # TODO: rspec support
87
- copy_file "test/helpers/inline_svg_helper_test.rb" if minitest?
91
+ copy_file "test/helpers/inline_svg_helper_test.rb" if File.exist?("test/vite_helper.rb")
88
92
 
89
93
  say_git "Add a `yarn start` script"
90
94
  start = "concurrently -i -k --kill-others-on-fail -p none 'RUBY_DEBUG_OPEN=true bin/rails s' 'bin/vite dev'"
91
- add_package_json_script start: start
95
+ add_package_json_script(start:)
92
96
  add_yarn_package "concurrently", dev: true
93
97
  gsub_file "README.md", %r{bin/rails s(erver)?}, "yarn start"
94
98
  gsub_file "bin/setup", %r{bin/rails s(erver)?}, "yarn start"
@@ -40,7 +40,7 @@ module Nextgen
40
40
  name = name.to_sym
41
41
  raise ArgumentError, "Generator #{name.inspect} was already added" if generators.key?(name)
42
42
 
43
- generators[name] = {node: node, prompt: prompt, description: description}
43
+ generators[name] = {node:, prompt:, description:}
44
44
  activate(name) unless prompt
45
45
  end
46
46
 
data/lib/nextgen/rails.rb CHANGED
@@ -29,10 +29,10 @@ module Nextgen
29
29
  Thor::Base.shell.new.say_status(...)
30
30
  end
31
31
 
32
- def with_original_bundler_env(&block)
32
+ def with_original_bundler_env(&)
33
33
  return yield unless defined?(Bundler)
34
34
 
35
- Bundler.with_original_env(&block)
35
+ Bundler.with_original_env(&)
36
36
  end
37
37
  end
38
38
  end
@@ -23,7 +23,7 @@ module Nextgen
23
23
 
24
24
  if given_args.first == "help"
25
25
  retry_with_args = ["help"] if given_args.length > 1
26
- elsif (e.unknown & %w[-h --help]).any?
26
+ elsif e.unknown.intersect?(%w[-h --help])
27
27
  retry_with_args = ["help", (given_args - e.unknown).first]
28
28
  end
29
29
  raise unless retry_with_args.any?
@@ -27,7 +27,7 @@ module Nextgen
27
27
  def add(gem, version: nil, group: nil, require: nil)
28
28
  return false if include?(gem)
29
29
 
30
- gem_line = build_gem_line(gem, version: version, require: require, indent: group ? " " : "")
30
+ gem_line = build_gem_line(gem, version:, require:, indent: group ? " " : "")
31
31
 
32
32
  if group
33
33
  group_line = create_group_if_needed(group)
@@ -1,3 +1,3 @@
1
1
  module Nextgen
2
- VERSION = "0.12.0".freeze
2
+ VERSION = "0.14.0".freeze
3
3
  end
@@ -73,7 +73,7 @@ jobs:
73
73
  bundler-cache: true
74
74
  - run: bin/erblint --lint-all
75
75
  <% end -%>
76
- <% if Dir[".eslintrc*"].any? -%>
76
+ <% if Dir["eslint.config.*"].any? -%>
77
77
  eslint:
78
78
  name: "Lint / eslint"
79
79
  runs-on: ubuntu-latest
@@ -13,7 +13,7 @@ PreCommit:
13
13
  include: "**/*.html.erb"
14
14
  <% end -%>
15
15
 
16
- <% if File.exist?(".eslintrc.cjs") -%>
16
+ <% if File.exist?("eslint.config.js") -%>
17
17
  EsLint:
18
18
  enabled: true
19
19
  required_executable: npx
@@ -5,6 +5,7 @@
5
5
  These environment variables affect how the app functions when deployed in production.
6
6
 
7
7
  - `RAILS_DISABLE_SSL` - Disable HSTS and secure cookies
8
+ - `RAILS_ENV` **REQUIRED** - "production"
8
9
  - `RAILS_MAX_THREADS` - Number of threads per Puma process (default: 5)
9
- - **REQUIRED** `SECRET_KEY_BASE` - Unique, secret key used to encrypt and sign cookies and other sensitive data
10
+ - `SECRET_KEY_BASE` **REQUIRED** - Unique, secret key used to encrypt and sign cookies and other sensitive data
10
11
  - `WEB_CONCURRENCY` - Number of Puma processes (default: number of CPUs)
data/template/bin/setup CHANGED
@@ -27,7 +27,7 @@ def run(command, echo: true, silent: false, exception: true)
27
27
  say_status(:run, command, :blue) if echo
28
28
  with_original_bundler_env do
29
29
  options = silent ? {out: File::NULL, err: File::NULL} : {}
30
- system(command, exception: exception, **options)
30
+ system(command, exception:, **options)
31
31
  end
32
32
  end
33
33
 
@@ -59,10 +59,10 @@ def git_safe_needed?
59
59
  ENV["PATH"].include?(".git/safe/../../bin") && !Dir.exist?(".git/safe")
60
60
  end
61
61
 
62
- def with_original_bundler_env(&block)
62
+ def with_original_bundler_env(&)
63
63
  return yield unless defined?(Bundler)
64
64
 
65
- Bundler.with_original_env(&block)
65
+ Bundler.with_original_env(&)
66
66
  end
67
67
 
68
68
  def env(env_file, from:)
@@ -0,0 +1,2 @@
1
+ # The staging environment is based on production
2
+ require_relative "production"
@@ -0,0 +1,32 @@
1
+ /** @type {import("@types/eslint").Linter.Config */
2
+
3
+ import globals from "globals";
4
+ import js from "@eslint/js";
5
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
6
+
7
+ export default [
8
+ js.configs.recommended,
9
+ eslintPluginPrettierRecommended,
10
+ {
11
+ languageOptions: {
12
+ ecmaVersion: 2022,
13
+ sourceType: "module",
14
+ globals: {
15
+ ...globals.browser,
16
+ ...globals.es2021,
17
+ },
18
+ },
19
+ rules: {
20
+ "no-unused-vars": [
21
+ "error",
22
+ {
23
+ args: "after-used",
24
+ argsIgnorePattern: "^_",
25
+ varsIgnorePattern: "^_",
26
+ },
27
+ ],
28
+ "no-var": "error",
29
+ "prettier/prettier": "error",
30
+ },
31
+ },
32
+ ];
@@ -1,4 +1,5 @@
1
1
  require "test_helper"
2
+ require "vite_helper"
2
3
 
3
4
  class InlineSvgHelperTest < ActionView::TestCase
4
5
  test "inline_svg_tag returns contents of svg file as html_safe string" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nextgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-02 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -133,6 +133,7 @@ files:
133
133
  - lib/nextgen/generators/rubocop.rb
134
134
  - lib/nextgen/generators/shoulda.rb
135
135
  - lib/nextgen/generators/sidekiq.rb
136
+ - lib/nextgen/generators/staging.rb
136
137
  - lib/nextgen/generators/stylelint.rb
137
138
  - lib/nextgen/generators/thor.rb
138
139
  - lib/nextgen/generators/tomo.rb
@@ -146,7 +147,6 @@ files:
146
147
  - template/.editorconfig
147
148
  - template/.env.sample
148
149
  - template/.erb-lint.yml.tt
149
- - template/.eslintrc.cjs
150
150
  - template/.github/PULL_REQUEST_TEMPLATE.md.tt
151
151
  - template/.github/dependabot.yml
152
152
  - template/.github/workflows/ci.yml.tt
@@ -168,10 +168,12 @@ files:
168
168
  - template/app/helpers/inline_svg_helper.rb
169
169
  - template/app/views/home/index.html.erb.tt
170
170
  - template/bin/setup
171
+ - template/config/environments/staging.rb
171
172
  - template/config/initializers/generators.rb
172
173
  - template/config/initializers/rack_mini_profiler.rb
173
174
  - template/config/initializers/sidekiq.rb
174
175
  - template/config/sidekiq.yml
176
+ - template/eslint.config.js
175
177
  - template/lib/puma/plugin/open.rb
176
178
  - template/lib/tasks/auto_annotate_models.rake
177
179
  - template/lib/tasks/erblint.rake
@@ -194,8 +196,8 @@ files:
194
196
  - template/test/support/mailer.rb
195
197
  - template/test/support/shoulda.rb
196
198
  - template/test/support/vcr.rb.tt
197
- - template/test/support/vite.rb
198
199
  - template/test/support/webmock.rb
200
+ - template/test/vite_helper.rb
199
201
  homepage: https://github.com/mattbrictson/nextgen
200
202
  licenses:
201
203
  - MIT
@@ -213,14 +215,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
215
  requirements:
214
216
  - - ">="
215
217
  - !ruby/object:Gem::Version
216
- version: '3.0'
218
+ version: '3.1'
217
219
  required_rubygems_version: !ruby/object:Gem::Requirement
218
220
  requirements:
219
221
  - - ">="
220
222
  - !ruby/object:Gem::Version
221
223
  version: '0'
222
224
  requirements: []
223
- rubygems_version: 3.5.6
225
+ rubygems_version: 3.5.9
224
226
  signing_key:
225
227
  specification_version: 4
226
228
  summary: Generate your next Rails app interactively!
@@ -1,26 +0,0 @@
1
- /** @type {import("@types/eslint").Linter.Config */
2
-
3
- module.exports = {
4
- env: {
5
- browser: true,
6
- es2021: true,
7
- },
8
- parserOptions: {
9
- ecmaVersion: 2022,
10
- sourceType: "module",
11
- },
12
- plugins: ["prettier"],
13
- rules: {
14
- "no-unused-vars": [
15
- "error",
16
- {
17
- args: "after-used",
18
- argsIgnorePattern: "^_",
19
- varsIgnorePattern: "^_",
20
- },
21
- ],
22
- "no-var": "error",
23
- "prettier/prettier": "error",
24
- },
25
- extends: ["eslint:recommended", "prettier"],
26
- };
File without changes