rails / cssbundling-rails

Bundle and process CSS in Rails with Tailwind, PostCSS, and Sass via Node.js.
MIT License
563 stars 83 forks source link

Possible issue with escaping string at lib/install/bootstrap/install.rb #137

Closed duduribeiro closed 5 months ago

duduribeiro commented 9 months ago

I've generated a new Rails 7.1.beta1 app with

rails new test_app -c bootstrap -d postgresql --skip-action-mailbox --skip-action-cable -a propshaft

this ended by generating the following content at package.json file:

{
..
  "scripts": {
  ...
    "watch:css": "nodemon --watch ./app/assets/stylesheets/ --ext scss --exec \\\"bun run build:css\\\""
  }
}

this triple \ looks weird for me and I got the following error when running bin/dev

20:56:27 css.1  | [nodemon] failed to start process, ""bun" exec not found

I THINK the desired output result for the package.json should have:

"watch:css": "nodemon --watch ./app/assets/stylesheets/ --ext scss --exec \"bun run build:css\""

am I correct? Because when I update with this content, it works fine:

20:57:44 css.1  | [nodemon] starting `bun run build:css`
20:57:44 css.1  | $ bun run build:css:compile && bun run build:css:prefix
20:57:44 css.1  | $ sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules
20:57:44 web.1  | DEBUGGER: Debugger can attach via UNIX domain socket (/var/folders/rm/02kb1lcj2n57_vdhhw1g9_tm0000gn/T/ruby-debug-sock-501/ruby-debug-cadu-2573)
20:57:44 web.1  | => Booting Puma
20:57:44 web.1  | => Rails 7.1.0.beta1 application starting in development
20:57:44 web.1  | => Run `bin/rails server --help` for more startup options
20:57:44 web.1  | Puma starting in single mode...
20:57:44 web.1  | * Puma version: 6.3.1 (ruby 3.2.2-p53) ("Mugi No Toki Itaru")
20:57:44 web.1  | *  Min threads: 5
20:57:44 web.1  | *  Max threads: 5
20:57:44 web.1  | *  Environment: development
20:57:44 web.1  | *          PID: 2573
20:57:44 web.1  | * Listening on http://127.0.0.1:3000
20:57:44 web.1  | * Listening on http://[::1]:3000
20:57:44 web.1  | Use Ctrl-C to stop
20:57:44 css.1  | $ postcss ./app/assets/builds/application.css --use=autoprefixer --output=./app/assets/builds/application.css
20:57:45 css.1  | [nodemon] clean exit - waiting for changes before restart

I see this was changed at: https://github.com/rails/cssbundling-rails/pull/136

duduribeiro commented 9 months ago

and I'm with 1.3.3

test_app % cat Gemfile.lock| grep cssbundling cssbundling-rails (1.3.3)

floydj commented 7 months ago

Can confirm this. Should #136 be reverted? That seems to focus on the output of the install script, but it means the actual package.json file has the wrong command.

heyitspaul commented 6 months ago

Was directed here, can confirm this is still an issue. Replacing \\\" with either ' or \" makes the script work.

skipkayhil commented 5 months ago

Does this only happen when you have bun in your path? I tried generating a new app with rails new --css bootstrap and I get the correct script added to my package.json (I don't have bun):

"watch:css": "nodemon --watch ./app/assets/stylesheets/ --ext scss --exec \"yarn build:css\""
floydj commented 5 months ago

@skipkayhil - I do have bun in my path.

Peredery commented 5 months ago

Can confirm. Script is not correct, should remove triple "\\" from script.

that one works as expected:

"watch:css": "nodemon --watch ./app/assets/stylesheets/ --ext scss --exec \"bun run build:css\""