Skip to content

Commit f81ec0f

Browse files
author
David Heinemeier Hansson
committed
Stop clobbering package.json
1 parent a1ffc08 commit f81ec0f

File tree

8 files changed

+18
-21
lines changed

8 files changed

+18
-21
lines changed

lib/install/esbuild/install.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
say "Create default package.json and install esbuild"
22
copy_file "#{__dir__}/package.json", "package.json"
33
run "yarn add esbuild"
4+
5+
say "Add build script"
6+
run %(npm set-script build "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds")

lib/install/esbuild/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/install/install.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@
2121
empty_directory app_js_entrypoint_path.parent.to_s
2222
copy_file "#{__dir__}/application.js", app_js_entrypoint_path
2323
end
24+
25+
unless Rails.root.join("package.json").exist?
26+
say "Add default package.json"
27+
copy_file "#{__dir__}/package.json", "package.json"
28+
end

lib/install/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "app",
3+
"private": "true"
4+
}

lib/install/rollup/install.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
copy_file "#{__dir__}/package.json", "package.json"
33
copy_file "#{__dir__}/rollup.config.js", "rollup.config.js"
44
run "yarn add rollup @rollup/plugin-node-resolve"
5+
6+
say "Add build script"
7+
run %(npm set-script build "rollup -c rollup.config.js")

lib/install/rollup/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/install/webpack/install.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
copy_file "#{__dir__}/package.json", "package.json"
33
copy_file "#{__dir__}/webpack.config.js", "webpack.config.js"
44
run "yarn add webpack webpack-cli"
5+
6+
say "Add build script"
7+
run %(npm set-script build "webpack --config webpack.config.js")

lib/install/webpack/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)