Skip to content

Commit

Permalink
Use .js extension for config/assets.js
Browse files Browse the repository at this point in the history
It turns out the .mjs wasn’t necessary for this to work correclty with our standard esbuild config.
  • Loading branch information
timriley committed Nov 2, 2023
1 parent a02dc31 commit a0df541
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Hanami Command Line Interface

### Changed

- [Tim Riley] Rename `config/assets.mjs` to `config/assets.js` (use a plain `.js` file extension)

## v2.1.0.rc1 - 2023-11-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/cli/generators/gem/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def generate_app(app, context) # rubocop:disable Metrics/AbcSize

if context.generate_assets?
fs.write("package.json", t("package.json.erb", context))
fs.write("config/assets.mjs", file("assets.mjs"))
fs.write("config/assets.js", file("assets.js"))
fs.write("app/assets/js/app.js", t("app_js.erb", context))
fs.write("app/assets/css/app.css", t("app_css.erb", context))
fs.write("app/assets/images/favicon.ico", file("favicon.ico"))
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/hanami/cli/generators/gem/app/package.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "<%= underscored_app_name %>",
"private": true,
"scripts": {
"assets": "node config/assets.mjs"
"assets": "node config/assets.js"
},
"dependencies": {
<%= hanami_assets_npm_package %>
Expand Down
12 changes: 6 additions & 6 deletions spec/unit/hanami/cli/commands/gem/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"name": "#{app}",
"private": true,
"scripts": {
"assets": "node config/assets.mjs"
"assets": "node config/assets.js"
},
"dependencies": {
"hanami-assets": "#{hanami_npm_version}"
Expand Down Expand Up @@ -200,7 +200,7 @@ class App < Hanami::App
expect(fs.read("config/app.rb")).to eq(hanami_app)
expect(output).to include("Created config/app.rb")

# config/assets.mjs
# config/assets.js
assets = <<~EXPECTED
import * as assets from "hanami-assets";
Expand All @@ -217,8 +217,8 @@ class App < Hanami::App
// }
// });
EXPECTED
expect(fs.read("config/assets.mjs")).to eq(assets)
expect(output).to include("Created config/assets.mjs")
expect(fs.read("config/assets.js")).to eq(assets)
expect(output).to include("Created config/assets.js")

# config/settings.rb
settings = <<~EXPECTED
Expand Down Expand Up @@ -504,8 +504,8 @@ module Types
# Procfile.dev
expect(fs.read("Procfile.dev")).to_not match(/hanami assets watch/)

# config/assets.mjs
expect(fs.exist?("config/assets.mjs")).to be(false)
# config/assets.js
expect(fs.exist?("config/assets.js")).to be(false)

# app/templates/layouts/app.html.erb
app_layout = fs.read("app/templates/layouts/app.html.erb")
Expand Down

0 comments on commit a0df541

Please sign in to comment.