nextgen 0.12.0 → 0.13.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: '0887dbfdc72d4e7001ee53d66bdd685b799b6681e7664a38c99c91db3ba1d7fd'
4
+ data.tar.gz: 552960fbfd1cc3cdabc97737273bffffca30c6e2412ed00c44b477d23ce9b0aa
5
5
  SHA512:
6
- metadata.gz: 7ebb05f8e034cbd54cc88cafebb45da4dd6d0f165a2495c108441ad4816d7ad417bbf8be86389a32cad148bcc7fbe2b997f6c655c5df6bc95f6ea26b60576adb
7
- data.tar.gz: 4ac4898307cb50f20650dcf45d4090a1c3af2c32cd316e0e0a24187db074919e92baf8bb81cefa4a1f50813641e680c12e09acbfcdbc826f401355721c9ba1ef
6
+ metadata.gz: dd040d70b511dbbd4b94ed1d4d6ccb1f07dc77b377eb8b8cd6a8eee1fd7989ebf6c9865068400372890b19c3f7469ccccbcfff97e8da72b111073ef1457f6d7c
7
+ data.tar.gz: 96a75604412e93edae9232c5c5930423171140ef74ea2d04b23ac9d90e21bd4c0e677d48b8dc9dad80b59d9de8767eb91ea57407d811b74575772d873660627c
@@ -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"
@@ -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
@@ -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
@@ -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,7 +88,7 @@ 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'"
@@ -1,3 +1,3 @@
1
1
  module Nextgen
2
- VERSION = "0.12.0".freeze
2
+ VERSION = "0.13.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)
@@ -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.13.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-12 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
@@ -220,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  - !ruby/object:Gem::Version
221
223
  version: '0'
222
224
  requirements: []
223
- rubygems_version: 3.5.6
225
+ rubygems_version: 3.5.8
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