webpacker_lite 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e6a7d776f0f2bb29a4cd64177a1ca8b447b358a
4
- data.tar.gz: ade62ad9187e06fe8f3ed007641b5cbdf2b2ef28
3
+ metadata.gz: 7e2db317915bebedc04ee628df5ebb0d007cafd5
4
+ data.tar.gz: '047779354717394e059550b300f6b86f7e0653b4'
5
5
  SHA512:
6
- metadata.gz: 90cb984e1db2305e0504a7a5ac0030bec26726b5ba7db0541a6b206444caf3e01ac06261452e2cb0d3cc9921cb9458ac0e45c37c17cd2ed1d0bf68cf14a057f0
7
- data.tar.gz: 1d1f2c2b10e55f1e78c36fab16ff7969ac1ee24129b9bde2e224e2b650c0f1aee3bfe5e3e81274704263e06573d6ecb8a57c63e13f736c1bfee7a75ee4fea16c
6
+ metadata.gz: 8a1f1f0931790a5004fbde87baa04ded96dcf69270f19c17a6e7459c0343b91439efa2ec7afccbb7c8a0d39b92e2814c4454dff8d8d728d40feb0652c124d3db
7
+ data.tar.gz: 24e05588ada561572186806b1e18e4fdd889072b525b485b8f2a8d2d9013837224834b5b193ed69ad85c9528737f42d64c0ac0cb0e92e8b49407cdf608d9ea3f
@@ -10,5 +10,4 @@ cache:
10
10
  install:
11
11
  - bundle install
12
12
  script:
13
- - bundle exec rubocop
14
- - bundle exec rake test
13
+ - bundle exec rake
@@ -6,6 +6,16 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
6
6
  ## [Unreleased]
7
7
  *Please add entries here for your pull requests.*
8
8
 
9
+ ## [2.0.2] - 2017-05-26
10
+ ### Fixed
11
+ * Fixed rake assets:clobber. [#11](https://github.com/shakacode/webpacker_lite/pull/11) by [dpuscher](https://github.com/dpuscher).
12
+
13
+ ## [2.0.1] - 2017-05-26
14
+
15
+ ### Changed
16
+ * Added better error messages for missing files.
17
+ * Added api to check if the manifest exists
18
+ [#12](https://github.com/shakacode/webpacker_lite/pull/12) by [justin808](https://github.com/justin808).
9
19
 
10
20
  ## [2.0.0] - 2017-05-23
11
21
  All in [#9](https://github.com/shakacode/webpacker_lite/pull/9) by [justin808](https://github.com/justin808) with help from [conturbo](https://github.com/conturbo) on the tests.
@@ -20,6 +30,8 @@ All in [#9](https://github.com/shakacode/webpacker_lite/pull/9) by [justin808](h
20
30
  ## [1.0.0] - 2017-05-03
21
31
  Initial release
22
32
 
23
- [Unreleased]: https://github.com/shakacode/webpacker_lite/compare/2.0.0...master
33
+ [Unreleased]: https://github.com/shakacode/webpacker_lite/compare/2.0.2...master
34
+ [2.0.2]: https://github.com/shakacode/react_on_rails/compare/2.0.1...2.0.2
35
+ [2.0.1]: https://github.com/shakacode/react_on_rails/compare/2.0.0...2.0.1
24
36
  [2.0.0]: https://github.com/shakacode/react_on_rails/compare/1.0.0...2.0.0
25
37
  [1.0.0]: https://github.com/shakacode/react_on_rails/compare/0.0.5...1.0.0
@@ -0,0 +1,76 @@
1
+ # Tips for Contributors
2
+
3
+ ## Summary
4
+
5
+ For non-doc fixes:
6
+
7
+ * Provide changelog entry in the [unreleased section of the CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#unreleased).
8
+ * Ensure CI passes and that you added a test that passes with the fix and fails without the fix.
9
+ * Optionally, squash all commits down to one with a nice commit message *ONLY* once final review is given. Make sure this single commit is rebased on top of master.
10
+ * Please address all code review comments.
11
+ * Ensure that docs are updated accordingly if a feature is added.
12
+
13
+ ## Commit Messages
14
+
15
+ From [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/)
16
+
17
+ #### The seven rules of a great git commit message
18
+ > Keep in mind: This has all been said before.
19
+
20
+ 1. Separate subject from body with a blank line
21
+ 1. Limit the subject line to 50 characters
22
+ 1. Capitalize the subject line
23
+ 1. Do not end the subject line with a period
24
+ 1. Use the imperative mood in the subject line
25
+ 1. Wrap the body at 72 characters
26
+ 1. Use the body to explain what and why vs. how
27
+
28
+
29
+ ## To run:
30
+
31
+ ### Tests
32
+ ```
33
+ rake test
34
+ ```
35
+
36
+ ### Linting
37
+
38
+ ```
39
+ rake rubocop
40
+ ```
41
+
42
+ or to autofix:
43
+
44
+ ```
45
+ bundle exec rubocop -a
46
+ ```
47
+
48
+ ### All ci
49
+
50
+ ```sh
51
+ rake
52
+ ```
53
+
54
+ # Configuring to test changes with your app
55
+
56
+ Use the relative path syntax in your gemfile.
57
+
58
+ ```ruby
59
+ gem "webpacker_lite", path: "../../../webpacker_lite"
60
+ ```
61
+
62
+ # Advice for Project Maintainers and Contributors
63
+
64
+ What do project maintainers do? What sort of work is involved? [sstephenson](https://github.com/sstephenson) wrote in the [turbolinks](https://github.com/turbolinks/turbolinks) repo:
65
+
66
+ > [Why this is not still fully merged?](https://github.com/turbolinks/turbolinks/pull/124#issuecomment-239826060)
67
+
68
+ # Releasing
69
+
70
+ If the version to bump is `2.0.1`
71
+
72
+ ```
73
+ gem bump --tag --push --version 2.0.1
74
+ ```
75
+
76
+
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker_lite (1.0.0)
4
+ webpacker_lite (2.0.1)
5
5
  activesupport (>= 4.2)
6
6
  multi_json (~> 1.2)
7
7
  railties (>= 4.2)
data/README.md CHANGED
@@ -83,7 +83,7 @@ This example config shows how we use different output directories for the webpac
83
83
  default: &default
84
84
  manifest: manifest.json
85
85
  # Used in your webpack configuration. Must be created in the
86
- # webpack_public_output_dir folder
86
+ # webpack_public_output_dir folder.
87
87
 
88
88
  development:
89
89
  <<: *default
@@ -141,6 +141,7 @@ production:
141
141
  ## Other Helpers: Getting the asset path
142
142
 
143
143
  The `asset_pack_path` helper provides the path of any given asset that's been compiled by webpack.
144
+ Note, the real file path is the subdirectory of the public.
144
145
 
145
146
  For example, if you want to create a `<link rel="prefetch">` or `<img />`
146
147
  for an asset used in your pack code you can reference them like this in your view,
@@ -148,6 +149,7 @@ for an asset used in your pack code you can reference them like this in your vie
148
149
  ```erb
149
150
  <img src="<%= asset_pack_path 'calendar.png' %>" />
150
151
  <% # => <img src="/webpack/calendar.png" /> %>
152
+ <% # real file path "public/webpack/calendar.png" /> %>
151
153
  ```
152
154
 
153
155
  ## Webpack Helper
data/Rakefile CHANGED
@@ -2,6 +2,16 @@
2
2
  require "bundler/gem_tasks"
3
3
  require "rake/testtask"
4
4
 
5
+ # Executes a string or an array of strings in a shell in the given directory
6
+ def sh_in_dir(dir, shell_commands)
7
+ shell_commands = [shell_commands] if shell_commands.is_a?(String)
8
+ shell_commands.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
9
+ end
10
+
11
+ def gem_root
12
+ File.expand_path("../.", __FILE__)
13
+ end
14
+
5
15
  Rake::TestTask.new(:test) do |t|
6
16
  t.libs << "test"
7
17
  t.libs << "lib"
@@ -9,4 +19,9 @@ Rake::TestTask.new(:test) do |t|
9
19
  t.verbose = true
10
20
  end
11
21
 
12
- task default: :test
22
+ desc "Run Rubocop as shell"
23
+ task :rubocop do
24
+ sh_in_dir(gem_root, "bundle exec rubocop .")
25
+ end
26
+
27
+ task default: [:test, :rubocop]
@@ -12,6 +12,6 @@ end
12
12
  # Run clobber if the assets:clobber is run
13
13
  if Rake::Task.task_defined?("assets:clobber")
14
14
  Rake::Task["assets:clobber"].enhance do
15
- Rake::Task["webpacker:clobber"].invoke
15
+ Rake::Task["webpacker_lite:clobber"].invoke
16
16
  end
17
17
  end
@@ -1,8 +1,8 @@
1
1
  module WebpackerLite
2
2
  def self.bootstrap
3
- WebpackerLite::Env.load
4
- WebpackerLite::Configuration.load
5
- WebpackerLite::Manifest.load
3
+ WebpackerLite::Env.load_instance
4
+ WebpackerLite::Configuration.load_instance
5
+ WebpackerLite::Manifest.load_instance
6
6
  end
7
7
 
8
8
  def env
@@ -3,6 +3,8 @@ require "webpacker_lite/file_loader"
3
3
  require "webpacker_lite/env"
4
4
 
5
5
  class WebpackerLite::Configuration < WebpackerLite::FileLoader
6
+ RAILS_WEB_PUBLIC = "public"
7
+
6
8
  class << self
7
9
  def manifest_path
8
10
  Rails.root.join(webpack_public_output_dir,
@@ -10,8 +12,7 @@ class WebpackerLite::Configuration < WebpackerLite::FileLoader
10
12
  end
11
13
 
12
14
  def webpack_public_output_dir
13
- Rails.root.join(
14
- File.join("public", configuration.fetch(:webpack_public_output_dir, "webpack")))
15
+ Rails.root.join(RAILS_WEB_PUBLIC, configuration.fetch(:webpack_public_output_dir, "webpack"))
15
16
  end
16
17
 
17
18
  def base_path
@@ -37,8 +38,8 @@ class WebpackerLite::Configuration < WebpackerLite::FileLoader
37
38
  end
38
39
 
39
40
  def configuration
40
- load if WebpackerLite::Env.development?
41
- raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Configuration.load must be called first") unless instance
41
+ load_instance if WebpackerLite::Env.development?
42
+ raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Configuration.load_instance must be called first") unless instance
42
43
  instance.data
43
44
  end
44
45
 
@@ -48,7 +49,7 @@ class WebpackerLite::Configuration < WebpackerLite::FileLoader
48
49
  end
49
50
 
50
51
  private
51
- def load
52
+ def load_data
52
53
  return super unless File.exist?(@path)
53
54
  HashWithIndifferentAccess.new(YAML.load(File.read(@path))[WebpackerLite::Env.current])
54
55
  end
@@ -25,7 +25,7 @@ class WebpackerLite::Env < WebpackerLite::FileLoader
25
25
  end
26
26
 
27
27
  private
28
- def load
28
+ def load_data
29
29
  environments = File.exist?(@path) ? YAML.load(File.read(@path)).keys : [].freeze
30
30
  return ENV["NODE_ENV"] if environments.include?(ENV["NODE_ENV"])
31
31
  return Rails.env if environments.include?(Rails.env)
@@ -7,22 +7,22 @@ class WebpackerLite::FileLoader
7
7
  attr_accessor :data
8
8
 
9
9
  class << self
10
- def load(path = file_path)
10
+ def load_instance(path = file_path)
11
11
  self.instance = new(path)
12
12
  end
13
13
 
14
14
  def file_path
15
- raise "Subclass of WebpackerLite::FileLoader should override this method"
15
+ raise FileLoaderError.new("Subclass of WebpackerLite::FileLoader should override this method")
16
16
  end
17
17
  end
18
18
 
19
19
  private
20
20
  def initialize(path)
21
21
  @path = path
22
- @data = load
22
+ @data = load_data
23
23
  end
24
24
 
25
- def load
25
+ def load_data
26
26
  {}.freeze
27
27
  end
28
28
  end
@@ -11,30 +11,61 @@ require "webpacker_lite/configuration"
11
11
 
12
12
  class WebpackerLite::Manifest < WebpackerLite::FileLoader
13
13
  class << self
14
- def file_path
15
- WebpackerLite::Configuration.manifest_path
14
+ # Helper method to determine if the manifest file exists.
15
+ def exist?
16
+ path_object = WebpackerLite::Configuration.manifest_path
17
+ path_object.exist?
16
18
  end
17
19
 
18
- def lookup(name)
19
- load if WebpackerLite::Env.development? || instance.data.empty?
20
- raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Manifest.load must be called first") unless instance
21
- instance.data[name.to_s] || missing_file_error(name)
20
+ def file_path
21
+ WebpackerLite::Configuration.manifest_path
22
22
  end
23
23
 
24
- def missing_file_error(name)
24
+ def missing_file_from_manifest_error(bundle_name)
25
25
  msg = <<-MSG
26
- WebpackerLite can't find #{name} in your manifest #{file_path}. Possible causes:
27
- 1. You are hot reloading
28
- 2. Webpack is not running
26
+ WebpackerLite can't find #{bundle_name} in your manifest #{file_path}. Possible causes:
27
+ 1. You are hot reloading.
28
+ 2. Webpack has not re-run to reflect updates.
29
29
  3. You have misconfigured WebpackerLite's config/webpacker_lite.yml file.
30
30
  4. Your Webpack configuration is not creating a manifest.
31
31
  MSG
32
32
  raise(WebpackerLite::FileLoader::NotFoundError.new(msg))
33
33
  end
34
+
35
+ # Same as lookup, but raises an error.
36
+ def lookup!(name)
37
+ lookup(name) || missing_file_from_manifest_error(name)
38
+ end
39
+
40
+ # Find the real file name from the manifest key.
41
+ def lookup(name)
42
+ instance.confirm_manifest_exists
43
+
44
+ load_instance if WebpackerLite::Env.development? || instance.data.empty?
45
+ raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Manifest.load must be called first") unless instance
46
+ instance.data[name.to_s]
47
+ end
48
+ end
49
+
50
+ def confirm_manifest_exists
51
+ raise missing_manifest_file_error(@path) unless File.exist?(@path)
34
52
  end
35
53
 
36
54
  private
37
- def load
55
+
56
+ def missing_manifest_file_error(path_object)
57
+ msg = <<-MSG
58
+
59
+ WebpackerLite can't find the manifest file: #{path_object}
60
+ Possible causes:
61
+ 1. You have not invoked webpack.
62
+ 2. You have misconfigured WebpackerLite's config/webpacker_lite.yml file.
63
+ 3. Your Webpack configuration is not creating a manifest.
64
+ MSG
65
+ raise(WebpackerLite::FileLoader::NotFoundError.new(msg))
66
+ end
67
+
68
+ def load_data
38
69
  return super unless File.exist?(@path)
39
70
  JSON.parse(File.read(@path))
40
71
  end
@@ -1,3 +1,3 @@
1
1
  module WebpackerLite
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.2".freeze
3
3
  end
@@ -11,14 +11,14 @@ class ManifestTest < Minitest::Test
11
11
  asset_file = "calendar.js"
12
12
  msg = <<-MSG
13
13
  WebpackerLite can't find #{asset_file} in your manifest #{manifest_path}. Possible causes:
14
- 1. You are hot reloading
15
- 2. Webpack is not running
14
+ 1. You are hot reloading.
15
+ 2. Webpack has not re-run to reflect updates.
16
16
  3. You have misconfigured WebpackerLite's config/webpacker_lite.yml file.
17
17
  4. Your Webpack configuration is not creating a manifest.
18
18
  MSG
19
19
 
20
20
  error = assert_raises WebpackerLite::FileLoader::NotFoundError do
21
- WebpackerLite::Manifest.lookup(asset_file)
21
+ WebpackerLite::Manifest.lookup!(asset_file)
22
22
  end
23
23
 
24
24
  assert_equal error.message, msg
@@ -26,6 +26,6 @@ class ManifestTest < Minitest::Test
26
26
 
27
27
  def test_lookup_success
28
28
  asset_file = "bootstrap.js"
29
- assert_equal WebpackerLite::Manifest.lookup(asset_file), "bootstrap-300631c4f0e0f9c865bc.js"
29
+ assert_equal WebpackerLite::Manifest.lookup!(asset_file), "bootstrap-300631c4f0e0f9c865bc.js"
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson, Justin Gordon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-23 00:00:00.000000000 Z
11
+ date: 2017-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -76,6 +76,7 @@ files:
76
76
  - ".rubocop.yml"
77
77
  - ".travis.yml"
78
78
  - CHANGELOG.md
79
+ - CONTRIBUTING.md
79
80
  - Gemfile
80
81
  - Gemfile.lock
81
82
  - MIT-LICENSE