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 +4 -4
- data/config/generators.yml +4 -0
- data/lib/nextgen/actions/bundler.rb +4 -0
- data/lib/nextgen/actions.rb +1 -1
- data/lib/nextgen/commands/create.rb +20 -14
- data/lib/nextgen/generators/base.rb +5 -1
- data/lib/nextgen/generators/eslint.rb +4 -2
- data/lib/nextgen/generators/staging.rb +12 -0
- data/lib/nextgen/generators/vite.rb +8 -4
- data/lib/nextgen/version.rb +1 -1
- data/template/.github/workflows/ci.yml.tt +1 -1
- data/template/.overcommit.yml.tt +1 -1
- data/template/DEPLOYMENT.md +2 -1
- data/template/config/environments/staging.rb +2 -0
- data/template/eslint.config.js +32 -0
- data/template/test/helpers/inline_svg_helper_test.rb +1 -0
- metadata +7 -5
- data/template/.eslintrc.cjs +0 -26
- /data/template/test/{support/vite.rb → vite_helper.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0887dbfdc72d4e7001ee53d66bdd685b799b6681e7664a38c99c91db3ba1d7fd'
|
4
|
+
data.tar.gz: 552960fbfd1cc3cdabc97737273bffffca30c6e2412ed00c44b477d23ce9b0aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd040d70b511dbbd4b94ed1d4d6ccb1f07dc77b377eb8b8cd6a8eee1fd7989ebf6c9865068400372890b19c3f7469ccccbcfff97e8da72b111073ef1457f6d7c
|
7
|
+
data.tar.gz: 96a75604412e93edae9232c5c5930423171140ef74ea2d04b23ac9d90e21bd4c0e677d48b8dc9dad80b59d9de8767eb91ea57407d811b74575772d873660627c
|
data/config/generators.yml
CHANGED
@@ -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"
|
data/lib/nextgen/actions.rb
CHANGED
@@ -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
|
-
#{
|
86
|
+
#{green("Done!")}
|
87
87
|
|
88
|
-
A Rails #{rails_version} app was generated in #{
|
89
|
-
Run #{
|
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
|
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
|
-
|
145
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 ".
|
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
|
-
|
50
|
-
|
51
|
-
|
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
|
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'"
|
data/lib/nextgen/version.rb
CHANGED
data/template/.overcommit.yml.tt
CHANGED
data/template/DEPLOYMENT.md
CHANGED
@@ -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**
|
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,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
|
+
];
|
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.
|
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-
|
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.
|
225
|
+
rubygems_version: 3.5.8
|
224
226
|
signing_key:
|
225
227
|
specification_version: 4
|
226
228
|
summary: Generate your next Rails app interactively!
|
data/template/.eslintrc.cjs
DELETED
@@ -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
|