webpacker_uploader 0.2.1 → 0.3.0

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: afcb36d0e425f938651b2aea9ac9e51044213196a4b962b3a40ab12f0a7d7aa0
4
- data.tar.gz: 11a5794d1f92a496cbd174a6e17c6c416e31c21f7939d21f9a724ce72bf0ca2a
3
+ metadata.gz: 8e574118301b21c8bcf8dae3686a791d0d335554c09b16776de598418989463e
4
+ data.tar.gz: 65423231b058c0808aacd401720ce7345e194488a2c8add95fee100278d0c197
5
5
  SHA512:
6
- metadata.gz: 0f29b023448d8b68eb5ac8029ec88a8be63a15dc0e5e960b0064b7d69fb4d5abd8d64aa236541f3fc8eb8a9378ead16e15ce74825359de2a4dbe5a69c9149ab1
7
- data.tar.gz: ac84915b894fb2dc9c46f1c89c738fd31001abfb4c66f190ff3676fd58ca92a31e49eb30f6c9f7342ac5a5fbab5e89eeda91b17af7a201feb2c1b6f7f5433bf9
6
+ metadata.gz: dd586f4296617a0898c73f58c5c88bd68a29f58f3ffd2982472325e52c47b684bbb764afb705fb3648815b97d9a34f892d624a907447d4f94241a457944a9c63
7
+ data.tar.gz: c68ea8fdac8579bfb52caa4928cd0474331653cefc6c418ca242cbda2ebd70a8432603ea9cd84d432eb3443ae3759d3f6bcdb3f84cb6506f528e275df8c64ff9
data/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [[0.3.0]](https://github.com/tlatsas/webpacker_uploader/releases/tag/v0.3.0) - 2021-03-06
8
+
9
+ ### Added
10
+
11
+ - Allow gem configuration. ([@tlatsas](https://github.com/tlatsas))
12
+
13
+ ### Changed
14
+
15
+ - With the newly introduced configuration options, ignored file extension list is now empty by default.
16
+ This means that every file type will be uploaded unless otherwise specified. ([@tlatsas](https://github.com/tlatsas))
17
+
7
18
  ## [[0.2.1]](https://github.com/tlatsas/webpacker_uploader/releases/tag/v0.2.1) - 2021-02-09
8
19
 
9
20
  ### Added
data/Gemfile.lock CHANGED
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker_uploader (0.2.1)
4
+ webpacker_uploader (0.3.0)
5
5
  mime-types
6
6
  webpacker (>= 5.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (6.1.1)
12
- actionview (= 6.1.1)
13
- activesupport (= 6.1.1)
11
+ actionpack (6.1.3)
12
+ actionview (= 6.1.3)
13
+ activesupport (= 6.1.3)
14
14
  rack (~> 2.0, >= 2.0.9)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.1.1)
19
- activesupport (= 6.1.1)
18
+ actionview (6.1.3)
19
+ activesupport (= 6.1.3)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activesupport (6.1.1)
24
+ activesupport (6.1.3)
25
25
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
26
  i18n (>= 1.6, < 2)
27
27
  minitest (>= 5.1)
@@ -45,14 +45,14 @@ GEM
45
45
  aws-sigv4 (1.2.2)
46
46
  aws-eventstream (~> 1, >= 1.0.2)
47
47
  builder (3.2.4)
48
- concurrent-ruby (1.1.7)
48
+ concurrent-ruby (1.1.8)
49
49
  crass (1.0.6)
50
50
  erubi (1.10.0)
51
- i18n (1.8.7)
51
+ i18n (1.8.9)
52
52
  concurrent-ruby (~> 1.0)
53
53
  jaro_winkler (1.5.4)
54
54
  jmespath (1.4.0)
55
- loofah (2.8.0)
55
+ loofah (2.9.0)
56
56
  crass (~> 1.0.2)
57
57
  nokogiri (>= 1.5.9)
58
58
  method_source (1.0.0)
@@ -60,7 +60,7 @@ GEM
60
60
  mime-types-data (~> 3.2015)
61
61
  mime-types-data (3.2020.0512)
62
62
  minitest (5.14.2)
63
- nokogiri (1.11.1-x86_64-darwin)
63
+ nokogiri (1.11.1)
64
64
  racc (~> 1.4)
65
65
  parallel (1.19.2)
66
66
  parser (2.7.1.4)
@@ -76,9 +76,9 @@ GEM
76
76
  nokogiri (>= 1.6)
77
77
  rails-html-sanitizer (1.3.0)
78
78
  loofah (~> 2.3)
79
- railties (6.1.1)
80
- actionpack (= 6.1.1)
81
- activesupport (= 6.1.1)
79
+ railties (6.1.3)
80
+ actionpack (= 6.1.3)
81
+ activesupport (= 6.1.3)
82
82
  method_source
83
83
  rake (>= 0.8.7)
84
84
  thor (~> 1.0)
@@ -95,7 +95,7 @@ GEM
95
95
  rubocop (>= 0.68.0)
96
96
  ruby-progressbar (1.10.1)
97
97
  semantic_range (2.3.1)
98
- thor (1.0.1)
98
+ thor (1.1.0)
99
99
  tzinfo (2.0.4)
100
100
  concurrent-ruby (~> 1.0)
101
101
  unicode-display_width (1.5.0)
data/README.md CHANGED
@@ -89,18 +89,6 @@ provider_options = {
89
89
  provider = WebpackerUploader::Providers::Aws.new(provider_options)
90
90
  ```
91
91
 
92
- ### Ignore files
93
-
94
- The uploader can be configured to skip certain files based on the file extension.
95
- By default `.map` files are excluded. This can be configured through the `ignored_extensions` attribute.
96
- In order to upload everything pass an empty array.
97
-
98
- ```ruby
99
- # skip uploading images
100
- WebpackerUploader.ignored_extensions = [".png", ".jpg", ".webp"]
101
- WebpackerUploader.upload!(provider)
102
- ```
103
-
104
92
  ### Prefix remote files
105
93
 
106
94
  Uploaded files can be prefixed by setting the `prefix` parameter during upload:
@@ -112,6 +100,42 @@ WebpackerUploader.upload!(provider, prefix: "assets")
112
100
  This will prefix all remote file paths with `assets` so instead of storing `packs/application-dd6b1cd38bfa093df600.css` it
113
101
  will store `assets/packs/application-dd6b1cd38bfa093df600.css`.
114
102
 
103
+ ### Configuration
104
+
105
+ WebpackerUploader currently supports the following configuration options:
106
+
107
+ | option | description | default value |
108
+ |----------------------|--------------------------------------------------------------|---------------------------------------|
109
+ | ignored_extensions | Which files uploader should skip based on the file extension | [] |
110
+ | log_output | Log output as we upload files | true |
111
+ | public_manifest_path | The webpack manifest path | Webpacker.config.public_manifest_path |
112
+ | public_path | The webpack public output path | Webpacker.config.public_path |
113
+
114
+ It can be configured using a block:
115
+
116
+ ```ruby
117
+ WebpackerUploader.configure do |config|
118
+ config.ignored_extensions = [".png", ".jpg", ".webp"]
119
+ config.log_output = false
120
+ config.public_manifest_path = "path/to/manifest.json"
121
+ config.public_path = "path/to/public/dir"
122
+ end
123
+ ```
124
+
125
+ or directly:
126
+
127
+ ```ruby
128
+ WebpackerUploader.config.log_output = false
129
+ ```
130
+
131
+ The uploader used to skip `.map` files by default. This has changed (see [CHANGELOG.md](https://github.com/tlatsas/webpacker_uploader/blob/main/CHANGELOG.md))
132
+ and everything is uploaded by default now. To retain the previous functionality use:
133
+
134
+ ```ruby
135
+ # skip uploading map files
136
+ WebpackerUploader.config.ignored_extensions = [".map"]
137
+ ```
138
+
115
139
  ## Development
116
140
 
117
141
  After checking out the repo, run `bin/setup` to install dependencies.
@@ -15,9 +15,10 @@ module WebpackerUploader
15
15
  @instance ||= WebpackerUploader::Instance.new
16
16
  end
17
17
 
18
- delegate :logger, :logger=, :upload!, :ignored_extensions, :ignored_extensions=, to: :instance
18
+ delegate :logger, :logger=, :configure, :config, :upload!, to: :instance
19
19
  end
20
20
 
21
+ require "webpacker_uploader/configuration"
21
22
  require "webpacker_uploader/instance"
22
23
  require "webpacker_uploader/manifest"
23
24
  require "webpacker_uploader/mime"
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class WebpackerUploader::Configuration
4
+ attr_accessor :ignored_extensions, :log_output
5
+ attr_reader :public_manifest_path, :public_path
6
+
7
+ alias_method :log_output?, :log_output
8
+
9
+ def initialize
10
+ @ignored_extensions = []
11
+ @log_output = true
12
+ @public_manifest_path = ::Webpacker.config.public_manifest_path
13
+ @public_path = ::Webpacker.config.public_path
14
+ end
15
+
16
+ def public_manifest_path=(path)
17
+ @public_manifest_path = Pathname.new(path)
18
+ end
19
+
20
+ def public_path=(path)
21
+ @public_path = Pathname.new(path)
22
+ end
23
+ end
@@ -2,17 +2,22 @@
2
2
 
3
3
  class WebpackerUploader::Instance
4
4
  cattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }
5
- cattr_accessor(:ignored_extensions) { %w[.map] }
5
+
6
+ attr_writer :config
6
7
 
7
8
  def manifest
8
9
  @manifest ||= WebpackerUploader::Manifest.new
9
10
  end
10
11
 
11
- def upload!(provider, prefix: nil)
12
- if ignored_extensions.nil?
13
- raise ArgumentError, "Ignored extensions should be specified as an array"
14
- end
12
+ def config
13
+ @config ||= WebpackerUploader::Configuration.new
14
+ end
15
15
 
16
+ def configure
17
+ yield config
18
+ end
19
+
20
+ def upload!(provider, prefix: nil)
16
21
  manifest.assets.each do |name, js_path|
17
22
  path = js_path[1..-1]
18
23
 
@@ -23,13 +28,14 @@ class WebpackerUploader::Instance
23
28
  "#{prefix}/#{path}"
24
29
  end
25
30
 
26
- file_path = Rails.root.join("public", path)
31
+ file_path = config.public_path.join(path)
27
32
 
28
- if name.end_with?(*ignored_extensions)
29
- logger.info("Skipping #{file_path}")
33
+ if name.end_with?(*config.ignored_extensions)
34
+ logger.info("Skipping #{file_path}") if config.log_output?
30
35
  else
31
36
  content_type = WebpackerUploader::Mime.mime_type(path)
32
- logger.info("Processing #{file_path} as #{content_type}")
37
+
38
+ logger.info("Processing #{file_path} as #{content_type}") if config.log_output?
33
39
 
34
40
  provider.upload!(remote_path, file_path, content_type)
35
41
  end
@@ -10,8 +10,8 @@ class WebpackerUploader::Manifest
10
10
  private
11
11
 
12
12
  def load
13
- if ::Webpacker.config.public_manifest_path.exist?
14
- JSON.parse(::Webpacker.config.public_manifest_path.read).except("entrypoints")
13
+ if WebpackerUploader.config.public_manifest_path.exist?
14
+ JSON.parse(WebpackerUploader.config.public_manifest_path.read).except("entrypoints")
15
15
  else
16
16
  {}
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module WebpackerUploader
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -15,6 +15,8 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.metadata = {
17
17
  "homepage_uri" => s.homepage,
18
+ "bug_tracker_uri" => "https://github.com/tlatsas/webpacker_uploader/issues",
19
+ "changelog_uri" => "https://github.com/tlatsas/webpacker_uploader/blob/main/CHANGELOG.md",
18
20
  "source_code_uri" => "https://github.com/tlatsas/webpacker_uploader/tree/v#{s.version}"
19
21
  }
20
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker_uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Latsas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webpacker
@@ -101,6 +101,7 @@ files:
101
101
  - bin/console
102
102
  - bin/setup
103
103
  - lib/webpacker_uploader.rb
104
+ - lib/webpacker_uploader/configuration.rb
104
105
  - lib/webpacker_uploader/instance.rb
105
106
  - lib/webpacker_uploader/manifest.rb
106
107
  - lib/webpacker_uploader/mime.rb
@@ -112,7 +113,9 @@ licenses:
112
113
  - MIT
113
114
  metadata:
114
115
  homepage_uri: https://github.com/tlatsas/webpacker_uploader
115
- source_code_uri: https://github.com/tlatsas/webpacker_uploader/tree/v0.2.1
116
+ bug_tracker_uri: https://github.com/tlatsas/webpacker_uploader/issues
117
+ changelog_uri: https://github.com/tlatsas/webpacker_uploader/blob/main/CHANGELOG.md
118
+ source_code_uri: https://github.com/tlatsas/webpacker_uploader/tree/v0.3.0
116
119
  post_install_message:
117
120
  rdoc_options: []
118
121
  require_paths: