nextgen 0.26.0 → 0.27.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: c1f17283eec0996db671512afbc900f11af08f922309834accf9379c4c19b2a2
4
- data.tar.gz: dfa1a949a4afdeac6ce8ce6ebe80b70871623d167688f0348572f157f7e6352b
3
+ metadata.gz: a76bc266683ea81445dc12e1762ced7a254592e66f0eb376bda3d4ba6921b64b
4
+ data.tar.gz: c5aca3c936d6af421f25e53f6b2132bf0c4989c21954416bf6a09b15b3f651c8
5
5
  SHA512:
6
- metadata.gz: c03e8e7fb944e64a5d5f1c07bd16cc7332a7c80f8ecf3c7c57714ee185d133d6e462ebe92fea7597ecd1b9f30a6184af2d773037386789fd9eef299eb80daf87
7
- data.tar.gz: 958604869b9991b4650c811ba68833c9b245b1a7a5ec14f16d33fc7f8929d0a4772b7ad9519014e1d50a14de1d95b5b2917c05f56fd404fd4e8e31c5e212af6e
6
+ metadata.gz: faf4a4f4562bd69f61b97c0e306ffdee4e96560b8b25acb26a8e788e97878af2927f489fa77e5822a8dfb7be49b71fa320093dbc64f30182ab837ba972e6e895
7
+ data.tar.gz: ad9f4e7fb5c887c38ce650950473329101c93f6631767dda29f41a209a7701c8516d60d84710d4a5020843b275c241ee5b8f6616eb0979f032d8e45f7ce6c6e2
data/README.md CHANGED
@@ -30,7 +30,7 @@ Nextgen generates apps using **Rails 7.2**.
30
30
 
31
31
  - **Ruby 3.1+** is required (Ruby 3.2 if you choose a Rails 8 pre-release)
32
32
  - **Rubygems 3.4.8+** is required (run `gem update --system` to get it)
33
- - **Node 18.12+ and Yarn** are required if you choose Vite or other Node-based options
33
+ - **Node 18.12+ and Yarn** are required if you choose Vite or other Node-based options (see the [npm note](#yarn-or-npm) below)
34
34
  - Additional tools may be required depending on the options you select (e.g. PostgreSQL)
35
35
 
36
36
  Going forward, my goal is that Nextgen will always target the latest stable version of Rails and the next pre-release version. Support for Node LTS and Ruby versions will be dropped as soon as they reach EOL (see [Ruby](https://endoflife.date/ruby) and [Node](https://endoflife.date/nodejs) EOL schedules).
@@ -71,6 +71,13 @@ If you've opted into GitHub Actions, Nextgen will automatically add jobs to your
71
71
 
72
72
  Prefer RSpec? Nextgen can set you up with RSpec, plus the gems and configuration you need for system specs (browser testing). Or stick with the Rails Minitest defaults. In either case, Nextgen will set up a good default Rake task and appropriate CI job.
73
73
 
74
+ ### Yarn or npm
75
+
76
+ Prefer npm? Nextgen allows you to choose Yarn or npm to manage your app's JavaScript dependencies. Your Dockerfile, CI jobs, `bin/setup` script, etc. will be adjusted appropriately.
77
+
78
+ > [!NOTE]
79
+ > As of Rails 8.0, `rails new` is still hard-coded to use Yarn in some places. Therefore you may still need Yarn installed on your system in order to generate a new app. Nextgen will remove these Yarn references from your generated project if you select the npm option.
80
+
74
81
  ### Opinionated RuboCop Config
75
82
 
76
83
  By default, Rails apps include RuboCop with a config defined by the [rubocop-rails-omakase](https://github.com/rails/rubocop-rails-omakase) gem. Nextgen allows you to opt out of RuboCop entirely, or use Nextgen's own custom RuboCop config. Nextgen's config will automatically include Capybara, FactoryBot, and RSpec rules, should your app include those frameworks.
@@ -21,7 +21,11 @@ rspec_github_actions:
21
21
  requires: rspec
22
22
 
23
23
  node:
24
- description: "Set up Node and Yarn"
24
+ description: "Set up Node"
25
+
26
+ npm:
27
+ description: "Use npm as JavaScript package manager"
28
+ requires: npm
25
29
 
26
30
  vite:
27
31
  description: "Replace the asset pipeline with Vite in app/frontend"
@@ -29,7 +33,7 @@ vite:
29
33
  node: true
30
34
 
31
35
  action_mailer:
32
- description: "Improve Action Mailer support for absolute URLs and testing"
36
+ description: "Configure Action Mailer for testing"
33
37
  requires: action_mailer
34
38
 
35
39
  annotate:
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nextgen
4
+ module Actions::Javascript
5
+ def add_js_packages(*packages, dev: false)
6
+ command = yarn? ? +"yarn add" : +"npm install --fund=false --audit-false"
7
+ command << " -D" if dev
8
+ run_js_command "#{command} #{packages.map(&:shellescape).join(" ")}"
9
+ end
10
+ alias add_js_package add_js_packages
11
+
12
+ def remove_js_packages(*packages, capture: false)
13
+ command = yarn? ? "yarn remove" : "npm uninstall"
14
+ run_js_command "#{command} #{packages.map(&:shellescape).join(" ")}", capture:
15
+ end
16
+ alias remove_js_package remove_js_packages
17
+
18
+ def add_package_json_scripts(scripts)
19
+ scripts.each do |name, script|
20
+ cmd = "npm pkg set scripts.#{name.to_s.shellescape}=#{script.shellescape}"
21
+ say_status :run, cmd.truncate(60), :green
22
+ run! cmd, verbose: false
23
+ end
24
+ end
25
+ alias add_package_json_script add_package_json_scripts
26
+
27
+ def remove_package_json_script(name)
28
+ cmd = "npm pkg delete scripts.#{name.to_s.shellescape}"
29
+ say_status :run, cmd.truncate(60), :green
30
+ run! cmd, verbose: false
31
+ end
32
+
33
+ def js_package_manager
34
+ File.exist?("yarn.lock") ? :yarn : :npm
35
+ end
36
+
37
+ def yarn?
38
+ js_package_manager == :yarn
39
+ end
40
+
41
+ def run_js_command(cmd, capture: false)
42
+ say_status(*cmd.split(" ", 2), :green)
43
+ output = run! cmd, capture: true, verbose: false
44
+ return output if capture
45
+ return puts(output) unless output.match?(/^success /)
46
+
47
+ puts output.lines.grep(/^(warning|success) /).join
48
+ end
49
+ end
50
+ end
@@ -4,7 +4,7 @@ module Nextgen
4
4
  module Actions
5
5
  include Bundler
6
6
  include Git
7
- include Yarn
7
+ include Javascript
8
8
 
9
9
  def with_nextgen_source_path
10
10
  path = Nextgen.template_path.to_s
@@ -50,7 +50,10 @@ module Nextgen
50
50
  ask_rails_frameworks
51
51
  ask_test_framework
52
52
  ask_system_testing if rails_opts.frontend? && rails_opts.test_framework?
53
+ reload_generators
53
54
  ask_optional_enhancements
55
+ ask_js_package_manager if node?
56
+ reload_generators
54
57
 
55
58
  say <<~SUMMARY
56
59
 
@@ -67,10 +70,11 @@ module Nextgen
67
70
 
68
71
  if node?
69
72
  say <<~NODE
70
- Based on the options you selected, your app will require Node and Yarn. For reference, you are using these versions:
73
+ Based on the options you selected, your app will require a JavaScript runtime. For reference, you are using:
71
74
 
72
- Node: #{capture_version("node")}
73
- Yarn: #{capture_version("yarn")}
75
+ node: #{capture_version("node")}
76
+ yarn: #{capture_version("yarn")}
77
+ npm: #{capture_version("npm")}
74
78
 
75
79
  NODE
76
80
  end
@@ -78,7 +82,7 @@ module Nextgen
78
82
  continue_if "Continue?"
79
83
 
80
84
  create_initial_commit_message
81
- copy_package_json if node?
85
+ create_package_json if node?
82
86
  Nextgen::RailsCommand.run "new", *rails_new_args
83
87
  Dir.chdir(app_path) do
84
88
  Nextgen::RailsCommand.run "app:template", "LOCATION=#{write_generators_script}"
@@ -111,12 +115,13 @@ module Nextgen
111
115
  end
112
116
  end
113
117
 
114
- def copy_package_json
118
+ def create_package_json
115
119
  FileUtils.mkdir_p(app_path)
116
120
  FileUtils.cp(
117
121
  Nextgen.template_path.join("package.json"),
118
122
  File.join(app_path, "package.json")
119
123
  )
124
+ FileUtils.touch(File.join(app_path, rails_opts.npm? ? "package-lock.json" : "yarn.lock"))
120
125
  end
121
126
 
122
127
  def ask_rails_version
@@ -240,9 +245,13 @@ module Nextgen
240
245
  rails_opts.skip_system_test! unless system_testing
241
246
  end
242
247
 
243
- def ask_optional_enhancements
248
+ def reload_generators
249
+ selected = generators ? (generators.all_active & generators.optional.values) : []
244
250
  @generators = Generators.compatible_with(rails_opts:)
251
+ generators.activate(*(selected & generators.optional.values))
252
+ end
245
253
 
254
+ def ask_optional_enhancements
246
255
  answers = prompt.multi_select(
247
256
  "Which optional enhancements would you like to add?",
248
257
  generators.optional.sort_by { |label, _| label.downcase }.to_h
@@ -250,6 +259,14 @@ module Nextgen
250
259
  generators.activate(*answers)
251
260
  end
252
261
 
262
+ def ask_js_package_manager
263
+ options = {
264
+ "yarn (default)" => :yarn,
265
+ "npm" => :npm
266
+ }
267
+ rails_opts.js_package_manager = prompt_select("Which JavaScript package manager will you use?", options)
268
+ end
269
+
253
270
  def create_initial_commit_message
254
271
  path = File.join(app_path, "tmp", "initial_nextgen_commit")
255
272
  FileUtils.mkdir_p(File.dirname(path))
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- say_git "Configure Action Mailer for testing"
4
3
  copy_test_support_file "mailer.rb"
5
4
  if minitest?
6
5
  empty_directory_with_keep_file "test/mailers"
@@ -49,6 +49,7 @@ if missing_ruby_decl && File.exist?(".ruby-version") && File.read(".ruby-version
49
49
  'ruby Pathname.new(__dir__).join(".ruby-version").read.strip'
50
50
  end
51
51
  gsub_file "Gemfile", /^source .*$/, '\0' + "\n#{ruby_decl}"
52
+ bundle_command! "lock"
52
53
  end
53
54
 
54
55
  if File.exist?("app/views/layouts/application.html.erb")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  say_git "Install eslint"
4
- add_yarn_packages(
4
+ add_js_packages(
5
5
  "@eslint/js",
6
6
  "eslint@^9",
7
7
  "eslint-config-prettier",
@@ -21,7 +21,7 @@ add_package_json_scripts(
21
21
  copy_file "eslint.config.js"
22
22
 
23
23
  say_git "Add eslint to default rake task"
24
- copy_file "lib/tasks/eslint.rake"
24
+ template "lib/tasks/eslint.rake.tt"
25
25
  add_lint_task "eslint"
26
26
 
27
27
  if File.exist?(".github/workflows/ci.yml")
@@ -39,16 +39,16 @@ if File.exist?(".github/workflows/ci.yml")
39
39
  uses: actions/setup-node@v4
40
40
  with:
41
41
  #{node_spec}
42
- cache: yarn
42
+ cache: #{js_package_manager}
43
43
 
44
- - name: Install Yarn packages
44
+ - name: Install #{js_package_manager} packages
45
45
  run: npx --yes ci
46
46
 
47
47
  - name: Lint JavaScript files with eslint
48
- run: yarn lint:js
48
+ run: #{js_package_manager} run lint:js
49
49
 
50
50
  YAML
51
51
  end
52
52
 
53
53
  say_git "Auto-correct any existing issues"
54
- run "yarn fix:js", capture: true
54
+ run "#{js_package_manager} run fix:js", capture: true
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- say_git "Add Node and Yarn prerequisites"
4
3
  copy_file "package.json" unless File.exist?("package.json")
5
4
  inject_into_file "README.md", "\n- Node 18 (LTS) or newer\n- Yarn 1.x (classic)", after: /^- Ruby.*$/
6
5
  inject_into_file "README.md", "\nbrew install node\nbrew install yarn", after: /^brew install rbenv.*$/
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ remove_file "yarn.lock"
4
+ run! "npm install --fund=false --audit=false"
5
+
6
+ gsub_file "README.md", "\n- Yarn 1.x (classic)", ""
7
+ gsub_file "README.md", "\nbrew install yarn", ""
8
+
9
+ gsub_file "Procfile.dev", "yarn build", "npm run build --" if File.exist?("Procfile.dev")
10
+
11
+ if File.exist?("Dockerfile")
12
+ gsub_file "Dockerfile", /^\s*ARG YARN_VERSION.*\n/, ""
13
+ gsub_file "Dockerfile", /^\s*npm install -g yarn.*\n/, ""
14
+ gsub_file "Dockerfile", "yarn.lock", "package-lock.json"
15
+ gsub_file "Dockerfile", /RUN yarn install.*/, "RUN npm ci"
16
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  say_git "Install stylelint"
4
- add_yarn_packages(
4
+ add_js_packages(
5
5
  "stylelint",
6
6
  "stylelint-config-standard",
7
7
  "stylelint-declaration-strict-value",
@@ -19,7 +19,7 @@ add_package_json_scripts(
19
19
  copy_file ".stylelintrc.js"
20
20
 
21
21
  say_git "Add stylelint to default rake task"
22
- copy_file "lib/tasks/stylelint.rake"
22
+ template "lib/tasks/stylelint.rake.tt"
23
23
  add_lint_task "stylelint"
24
24
 
25
25
  if File.exist?(".github/workflows/ci.yml")
@@ -37,16 +37,16 @@ if File.exist?(".github/workflows/ci.yml")
37
37
  uses: actions/setup-node@v4
38
38
  with:
39
39
  #{node_spec}
40
- cache: yarn
40
+ cache: #{js_package_manager}
41
41
 
42
- - name: Install Yarn packages
42
+ - name: Install #{js_package_manager} packages
43
43
  run: npx --yes ci
44
44
 
45
45
  - name: Lint CSS files with stylelint
46
- run: yarn lint:css
46
+ run: #{js_package_manager} run lint:css
47
47
 
48
48
  YAML
49
49
  end
50
50
 
51
51
  say_git "Auto-correct any existing issues"
52
- run "yarn fix:css", capture: true
52
+ run "#{js_package_manager} run fix:css", capture: true
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  say_git "Remove esbuild"
4
- remove_yarn_package "esbuild"
4
+ remove_js_package "esbuild"
5
5
  remove_package_json_script(:build)
6
6
 
7
7
  say_git "Install the vite_rails gem"
@@ -22,15 +22,14 @@ inject_into_class "config/application.rb", "Application", <<-RUBY
22
22
  RUBY
23
23
 
24
24
  say_git "Run the vite installer"
25
- FileUtils.touch "yarn.lock"
26
25
  bundle_command "exec vite install"
27
26
  gsub_file "app/views/layouts/application.html.erb",
28
27
  /vite_javascript_tag 'application' %>/,
29
28
  'vite_javascript_tag "application", "data-turbo-track": "reload" %>'
30
29
 
31
30
  say_git "Replace vite-plugin-ruby with vite-plugin-rails"
32
- add_yarn_packages "rollup@^4.2.0", "vite-plugin-rails"
33
- remove_yarn_package "vite-plugin-ruby"
31
+ add_js_packages "rollup@^4.2.0", "vite-plugin-rails"
32
+ remove_js_package "vite-plugin-ruby"
34
33
  gsub_file "vite.config.ts", "import RubyPlugin from 'vite-plugin-ruby'", 'import ViteRails from "vite-plugin-rails"'
35
34
  gsub_file "vite.config.ts", /^\s*?RubyPlugin\(\)/, <<~TYPESCRIPT.gsub(/^/, " ").rstrip
36
35
  ViteRails({
@@ -44,12 +43,12 @@ TYPESCRIPT
44
43
 
45
44
  say_git "Move vite package from devDependencies to dependencies"
46
45
  if (vite_version = File.read("package.json")[/"vite":\s*"(.+?)"/, 1])
47
- remove_yarn_package "vite", capture: true
48
- add_yarn_package "vite@#{vite_version}"
46
+ remove_js_package "vite", capture: true
47
+ add_js_packages "vite@#{vite_version}"
49
48
  end
50
49
 
51
50
  say_git "Install autoprefixer"
52
- add_yarn_packages "postcss@^8.4.24", "autoprefixer@^10.4.14"
51
+ add_js_packages "postcss@^8.4.24", "autoprefixer@^10.4.14"
53
52
  copy_file "postcss.config.cjs"
54
53
 
55
54
  # TODO: rspec support
@@ -61,7 +60,7 @@ if File.exist?("test/application_system_test_case.rb")
61
60
  end
62
61
 
63
62
  say_git "Install modern-normalize and base stylesheets"
64
- add_yarn_package "modern-normalize@^3.0.0"
63
+ add_js_packages "modern-normalize@^3.0.0"
65
64
  copy_file "app/frontend/stylesheets/index.css"
66
65
  copy_file "app/frontend/stylesheets/base.css"
67
66
  copy_file "app/frontend/stylesheets/reset.css"
@@ -74,7 +73,7 @@ if package_json.match?(%r{@hotwired/turbo-rails})
74
73
  JS
75
74
  end
76
75
  if package_json.match?(%r{@hotwired/stimulus})
77
- add_yarn_package "stimulus-vite-helpers"
76
+ add_js_package "stimulus-vite-helpers"
78
77
  copy_file "app/frontend/controllers/index.js", force: true
79
78
  prepend_to_file "app/frontend/entrypoints/application.js", <<~JS
80
79
  import "~/controllers";
@@ -97,7 +96,7 @@ copy_file "app/frontend/images/example.svg"
97
96
  copy_file "test/helpers/inline_svg_helper_test.rb" if File.exist?("test/vite_helper.rb")
98
97
 
99
98
  say_git "Add a `bin/dev` script that uses run-pty"
100
- add_yarn_package "run-pty@^5", dev: true
99
+ add_js_packages "run-pty@^5", dev: true
101
100
  copy_file "bin/dev-node", "bin/dev", mode: :preserve, force: true
102
101
  copy_file "run-pty.json"
103
102
  remove_file "Procfile.dev"
@@ -129,9 +128,9 @@ if File.exist?(".github/workflows/ci.yml")
129
128
  uses: actions/setup-node@v4
130
129
  with:
131
130
  #{node_spec}
132
- cache: yarn
131
+ cache: #{js_package_manager}
133
132
 
134
- - name: Install Yarn packages
133
+ - name: Install #{js_package_manager} packages
135
134
  run: npx --yes ci
136
135
  YAML
137
136
  end
@@ -19,7 +19,9 @@ module Nextgen
19
19
  jbuilder
20
20
  ].freeze
21
21
 
22
- attr_reader :asset_pipeline, :css, :javascript, :database, :test_framework
22
+ JS_PACKAGE_MANAGERS = %i[npm yarn].freeze
23
+
24
+ attr_reader :asset_pipeline, :css, :javascript, :js_package_manager, :database, :test_framework
23
25
 
24
26
  def_delegators :version, :asset_pipelines, :databases, :default_features, :optional_features
25
27
 
@@ -31,6 +33,7 @@ module Nextgen
31
33
  @skip_features = []
32
34
  @skip_system_test = false
33
35
  @test_framework = :minitest
36
+ @js_package_manager = :yarn
34
37
  end
35
38
 
36
39
  def version_label
@@ -57,6 +60,16 @@ module Nextgen
57
60
  @javascript = framework
58
61
  end
59
62
 
63
+ def js_package_manager=(tool)
64
+ raise ArgumentError, "Unknown package manager: #{tool}" unless JS_PACKAGE_MANAGERS.include?(tool)
65
+
66
+ @js_package_manager = tool
67
+ end
68
+
69
+ def npm?
70
+ js_package_manager == :npm
71
+ end
72
+
60
73
  def vite!
61
74
  self.asset_pipeline = nil
62
75
  @javascript = "esbuild"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nextgen
4
- VERSION = "0.26.0"
4
+ VERSION = "0.27.0"
5
5
  end
@@ -82,7 +82,7 @@ PreCommit:
82
82
  exclude:
83
83
  - "**/db/structure.sql"
84
84
 
85
- <% if File.exist?("yarn.lock") -%>
85
+ <% if yarn? -%>
86
86
  YarnCheck:
87
87
  enabled: true
88
88
  <% end -%>
data/template/bin/setup CHANGED
@@ -9,7 +9,7 @@ def setup!
9
9
  run "bundle install" if bundle_needed?
10
10
  run "overcommit --install" if overcommit_installable?
11
11
  run "bin/rails db:prepare" if database_present?
12
- run "yarn install --check-files" if yarn_needed?
12
+ run install_node_packages_command if node_present?
13
13
  run "bin/rails tmp:create" if tmp_missing?
14
14
  run "bin/rails restart" if pid_present?
15
15
 
@@ -48,8 +48,16 @@ def database_present?
48
48
  File.exist?("config/database.yml")
49
49
  end
50
50
 
51
- def yarn_needed?
52
- File.exist?("yarn.lock")
51
+ def node_present?
52
+ File.exist?("package.json")
53
+ end
54
+
55
+ def install_node_packages_command
56
+ if File.exist?("yarn.lock")
57
+ "yarn install --check-files"
58
+ else
59
+ "npm install"
60
+ end
53
61
  end
54
62
 
55
63
  def tmp_missing?
@@ -2,12 +2,12 @@
2
2
 
3
3
  desc "Run ESLint"
4
4
  task :eslint do
5
- sh "yarn lint:js"
5
+ sh "<%= js_package_manager %> run lint:js"
6
6
  end
7
7
 
8
8
  namespace :eslint do
9
9
  desc "Autocorrect ESLint offenses"
10
10
  task :autocorrect do
11
- sh "yarn fix:js"
11
+ sh "<%= js_package_manager %> run fix:js"
12
12
  end
13
13
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  desc "Run Stylelint"
4
4
  task :stylelint do
5
- sh "yarn lint:css"
5
+ sh "<%= js_package_manager %> run lint:css"
6
6
  end
7
7
 
8
8
  namespace :stylelint do
9
9
  desc "Autocorrect Stylelint offenses"
10
10
  task :autocorrect do
11
- sh "yarn fix:css"
11
+ sh "<%= js_package_manager %> run fix:css"
12
12
  end
13
13
  end
@@ -8,6 +8,9 @@ RSpec.configure do |config|
8
8
  # Allows running in Docker
9
9
  options.add_argument("--disable-dev-shm-usage")
10
10
  options.add_argument("--no-sandbox")
11
+
12
+ # Fixes slowdowns on macOS
13
+ options.add_argument("--disable-gpu")
11
14
  end
12
15
  end
13
16
  end
@@ -9,5 +9,8 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
9
9
  # Allows running in Docker
10
10
  options.add_argument("--disable-dev-shm-usage")
11
11
  options.add_argument("--no-sandbox")
12
+
13
+ # Fixes slowdowns on macOS
14
+ options.add_argument("--disable-gpu")
12
15
  end
13
16
  end
@@ -3,5 +3,6 @@
3
3
  return if ViteRuby.config.auto_build
4
4
 
5
5
  # Compile assets once at the start of testing
6
- millis = Benchmark.ms { ViteRuby.commands.build }
7
- puts format("Built Vite assets (%.1fms)", millis)
6
+ require "benchmark"
7
+ seconds = Benchmark.realtime { ViteRuby.commands.build }
8
+ puts format("Built Vite assets (%.1fms)", seconds * 1_000)
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.26.0
4
+ version: 0.27.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-09-26 00:00:00.000000000 Z
11
+ date: 2024-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -98,7 +98,7 @@ files:
98
98
  - lib/nextgen/actions.rb
99
99
  - lib/nextgen/actions/bundler.rb
100
100
  - lib/nextgen/actions/git.rb
101
- - lib/nextgen/actions/yarn.rb
101
+ - lib/nextgen/actions/javascript.rb
102
102
  - lib/nextgen/cli.rb
103
103
  - lib/nextgen/commands/create.rb
104
104
  - lib/nextgen/ext/prompt/list.rb
@@ -123,6 +123,7 @@ files:
123
123
  - lib/nextgen/generators/letter_opener.rb
124
124
  - lib/nextgen/generators/mocha.rb
125
125
  - lib/nextgen/generators/node.rb
126
+ - lib/nextgen/generators/npm.rb
126
127
  - lib/nextgen/generators/open_browser_on_start.rb
127
128
  - lib/nextgen/generators/overcommit.rb
128
129
  - lib/nextgen/generators/pgcli_rails.rb
@@ -179,9 +180,9 @@ files:
179
180
  - template/lib/puma/plugin/open.rb
180
181
  - template/lib/tasks/auto_annotate_models.rake
181
182
  - template/lib/tasks/erblint.rake
182
- - template/lib/tasks/eslint.rake
183
+ - template/lib/tasks/eslint.rake.tt
183
184
  - template/lib/tasks/rubocop.rake
184
- - template/lib/tasks/stylelint.rake
185
+ - template/lib/tasks/stylelint.rake.tt
185
186
  - template/lib/templates/rspec/system/system_spec.rb
186
187
  - template/lib/vite_inline_svg_file_loader.rb
187
188
  - template/package.json
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nextgen
4
- module Actions::Yarn
5
- def add_yarn_packages(*packages, dev: false)
6
- add = dev ? "add -D" : "add"
7
- yarn_command "#{add} #{packages.map(&:shellescape).join(" ")}"
8
- end
9
- alias add_yarn_package add_yarn_packages
10
-
11
- def remove_yarn_packages(*packages, capture: false)
12
- yarn_command "remove #{packages.map(&:shellescape).join(" ")}", capture:
13
- end
14
- alias remove_yarn_package remove_yarn_packages
15
-
16
- def add_package_json_scripts(scripts)
17
- scripts.each do |name, script|
18
- cmd = "npm pkg set scripts.#{name.to_s.shellescape}=#{script.shellescape}"
19
- say_status :run, cmd.truncate(60), :green
20
- run! cmd, verbose: false
21
- end
22
- end
23
- alias add_package_json_script add_package_json_scripts
24
-
25
- def remove_package_json_script(name)
26
- cmd = "npm pkg delete scripts.#{name.to_s.shellescape}"
27
- say_status :run, cmd.truncate(60), :green
28
- run! cmd, verbose: false
29
- end
30
-
31
- def yarn_command(cmd, capture: false)
32
- say_status :yarn, cmd, :green
33
- output = run! "yarn #{cmd}", capture: true, verbose: false
34
- return output if capture
35
- return puts(output) unless output.match?(/^success /)
36
-
37
- puts output.lines.grep(/^(warning|success) /).join
38
- end
39
- end
40
- end