jsbundling-rails 0.1.5 → 0.1.9

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: 5b113c6e1687d0f4adf95e471b46bd54fc0096b3f999d62f11145f14253a656e
4
- data.tar.gz: b59b92d84c86299b4ced4902c41f954e97131c5ea4a94edbc8390e65ba16ce31
3
+ metadata.gz: e5bde01f1cfb6e2fac2f04eda05dba4a31121ec4b45ed30c7fd1962499fd1b11
4
+ data.tar.gz: 8db0f168b477075d235c36a66239eb9a37ade5c1a711ea7668efcfe18290e095
5
5
  SHA512:
6
- metadata.gz: d4d017b80b7a35e3bb10679dc4c996a484a19b3cd0083c2d0f16bb52caafe48ade12ab4d92eb06210526471cf784ee8b6476a4fee04a12223c95d8473971fba3
7
- data.tar.gz: c72ec41731afdad48d9b2e5e852b2d3a3ea95a915b0e0a7ffcbbb20784625afcdd727fc3bf2687261cca0d0a70acd2d867f0dd2923598789f8e1a8354ec76a7e
6
+ metadata.gz: 30cc0891d989fc9cdc45784ac861d523c94d291a68430e64c753d718bf0e071eee8cd1c0ca64bbefca85110a2c56286c19917427dd4d59f9338dd4ca95796553
7
+ data.tar.gz: 730a3011e7a338a682f004df50ea68950d50a88eba314a344d346497536f06d64670a36f2ff68f6a90595dd9e31b46fe01edbdf1d6c5f07b8544712f58c53b99
@@ -2,4 +2,10 @@ say "Install esbuild"
2
2
  run "yarn add esbuild"
3
3
 
4
4
  say "Add build script"
5
- run %(npm set-script build "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds")
5
+ build_script = "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds"
6
+
7
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
8
+ say %(Add "scripts": { "build": "#{build_script}" to your package.json), :green
9
+ else
10
+ run %(npm set-script build "#{build_script}")
11
+ end
@@ -1,10 +1,14 @@
1
1
  say "Compile into app/assets/builds"
2
2
  empty_directory "app/assets/builds"
3
3
  keep_file "app/assets/builds"
4
- append_to_file "app/assets/config/manifest.js", %(//= link_tree ../builds\n)
4
+
5
+ if (sprockets_manifest_path = Rails.root.join("app/assets/config/manifest.js")).exist?
6
+ append_to_file sprockets_manifest_path, %(//= link_tree ../builds\n)
7
+ end
5
8
 
6
9
  if Rails.root.join(".gitignore").exist?
7
- append_to_file(".gitignore", %(\n/app/assets/builds/*\n!/app/assets/builds/.keep\n/node_modules\n))
10
+ append_to_file(".gitignore", %(\n/app/assets/builds/*\n!/app/assets/builds/.keep\n))
11
+ append_to_file(".gitignore", %(\n/node_modules\n))
8
12
  end
9
13
 
10
14
  if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
@@ -28,7 +32,7 @@ unless Rails.root.join("package.json").exist?
28
32
  end
29
33
 
30
34
  if Rails.root.join("Procfile.dev").exist?
31
- append_to_file "Procfile.dev", "js: yarn build --watch"
35
+ append_to_file "Procfile.dev", "js: yarn build --watch\n"
32
36
  else
33
37
  say "Add default Procfile.dev"
34
38
  copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
@@ -3,4 +3,10 @@ copy_file "#{__dir__}/rollup.config.js", "rollup.config.js"
3
3
  run "yarn add rollup @rollup/plugin-node-resolve"
4
4
 
5
5
  say "Add build script"
6
- run %(npm set-script build "rollup -c rollup.config.js")
6
+ build_script = "rollup -c rollup.config.js"
7
+
8
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
9
+ say %(Add "scripts": { "build": "#{build_script}" to your package.json), :green
10
+ else
11
+ run %(npm set-script build "#{build_script}")
12
+ end
@@ -3,4 +3,10 @@ copy_file "#{__dir__}/webpack.config.js", "webpack.config.js"
3
3
  run "yarn add webpack webpack-cli"
4
4
 
5
5
  say "Add build script"
6
- run %(npm set-script build "webpack --config webpack.config.js")
6
+ build_script = "webpack --config webpack.config.js"
7
+
8
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
9
+ say %(Add "scripts": { "build": "#{build_script}" to your package.json), :green
10
+ else
11
+ run %(npm set-script build "#{build_script}")
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Jsbundling
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -1,7 +1,9 @@
1
1
  namespace :javascript do
2
2
  desc "Build your JavaScript bundle"
3
3
  task :build do
4
- system "yarn install && yarn build"
4
+ unless system "yarn install && yarn build"
5
+ raise "jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors"
6
+ end
5
7
  end
6
8
  end
7
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsbundling-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 6.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: sprockets-rails
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.0.0
41
27
  description:
42
28
  email: david@loudthinking.com
43
29
  executables: []