rails-assets-manifest 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +66 -0
- data/.gitignore +2 -0
- data/.rspec +2 -1
- data/.rubocop.yml +5 -209
- data/Appraisals +17 -0
- data/CHANGELOG.md +40 -1
- data/Gemfile +14 -1
- data/README.md +33 -13
- data/bin/console +1 -0
- data/gemfiles/rails_5.2.gemfile +19 -0
- data/gemfiles/rails_6.0.gemfile +19 -0
- data/gemfiles/rails_6.1.gemfile +19 -0
- data/gemfiles/rails_7.0.gemfile +19 -0
- data/lib/rails/assets/manifest/helper.rb +45 -22
- data/lib/rails/assets/manifest/manifest.rb +10 -12
- data/lib/rails/assets/manifest/railtie.rb +11 -32
- data/lib/rails/assets/manifest/version.rb +3 -3
- data/lib/rails/assets/manifest.rb +18 -6
- data/rails-assets-manifest.gemspec +6 -3
- data/renovate.json +3 -0
- metadata +12 -10
- data/.travis.yml +0 -37
- data/gemfiles/rails-4-2.gemfile +0 -9
- data/gemfiles/rails-5-0.gemfile +0 -9
- data/gemfiles/rails-5-1.gemfile +0 -9
- data/gemfiles/rails-5-2.gemfile +0 -9
- data/gemfiles/rails-master.gemfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36c667b7c457d214df43ac5f4c9e54f5baac237c0f9a61ac3eeedc6d1d458ab9
|
4
|
+
data.tar.gz: 1a7c777200e2087c05be7759091007857861261a5d00912256f35f5ff98d2a6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6117f1e88a27ba3dd5ce5edc85a21952e91de97abd3d72bc9b37a1527aa8352a7170371acf2bec29a268a8aced6b3519af4d9e4409848f041c9d950090ca38cb
|
7
|
+
data.tar.gz: 2f38b29bf90d82cd5a4a8e039a2fef2bd536326d1fe81eb3ee9e04d5b2637f4f3114a5deeb75ce6a6aec332cdf7874056033d4dde53d8bea7bc5d053774dbc6a
|
@@ -0,0 +1,66 @@
|
|
1
|
+
---
|
2
|
+
name: test
|
3
|
+
on: push
|
4
|
+
jobs:
|
5
|
+
rspec:
|
6
|
+
name: "ruby:${{ matrix.ruby }} rails:${{ matrix.rails }} ${{ matrix.variant }}"
|
7
|
+
runs-on: ubuntu-20.04
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby:
|
13
|
+
- "3.1"
|
14
|
+
- "3.0"
|
15
|
+
- "2.7"
|
16
|
+
rails:
|
17
|
+
- "7.0"
|
18
|
+
- "6.1"
|
19
|
+
- "6.0"
|
20
|
+
- "5.2"
|
21
|
+
variant:
|
22
|
+
- ""
|
23
|
+
- "no-sprockets"
|
24
|
+
exclude:
|
25
|
+
- ruby: "3.1"
|
26
|
+
rails: "6.1"
|
27
|
+
- ruby: "3.1"
|
28
|
+
rails: "6.0"
|
29
|
+
- ruby: "3.1"
|
30
|
+
rails: "5.2"
|
31
|
+
- ruby: "3.0"
|
32
|
+
rails: "5.2"
|
33
|
+
|
34
|
+
env:
|
35
|
+
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile
|
36
|
+
BUNDLE_WITHOUT: development
|
37
|
+
BUNDLE_JOBS: 4
|
38
|
+
BUNDLE_RETRY: 3
|
39
|
+
VARIANT: ${{ matrix.variant }}
|
40
|
+
|
41
|
+
steps:
|
42
|
+
- uses: actions/checkout@master
|
43
|
+
- uses: ruby/setup-ruby@v1
|
44
|
+
with:
|
45
|
+
ruby-version: ${{ matrix.ruby }}
|
46
|
+
bundler-cache: true
|
47
|
+
|
48
|
+
- run: bundle exec rspec --color
|
49
|
+
|
50
|
+
rubocop:
|
51
|
+
name: rubocop
|
52
|
+
runs-on: ubuntu-20.04
|
53
|
+
|
54
|
+
env:
|
55
|
+
BUNDLE_WITHOUT: development
|
56
|
+
BUNDLE_JOBS: 4
|
57
|
+
BUNDLE_RETRY: 3
|
58
|
+
|
59
|
+
steps:
|
60
|
+
- uses: actions/checkout@master
|
61
|
+
- uses: ruby/setup-ruby@v1
|
62
|
+
with:
|
63
|
+
ruby-version: 3.1
|
64
|
+
bundler-cache: true
|
65
|
+
|
66
|
+
- run: bundle exec rubocop --parallel --fail-level E
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,211 +1,7 @@
|
|
1
|
-
|
2
|
-
-
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-config: default.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
- 'db/schema.rb'
|
9
|
-
- 'vendor/**'
|
10
|
-
TargetRubyVersion: 2.5
|
11
|
-
TargetRailsVersion: 5.2
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# -----------------------------------------------------------------------------
|
16
|
-
# RAILS
|
17
|
-
|
18
|
-
Rails:
|
19
|
-
Enabled: true
|
20
|
-
|
21
|
-
#
|
22
|
-
# False positives:
|
23
|
-
# * On Acfs::Resource#update_attriubutes!
|
24
|
-
#
|
25
|
-
Rails/ActiveRecordAliases:
|
26
|
-
Exclude:
|
27
|
-
- spec/**/*_spec.rb
|
28
|
-
|
29
|
-
#
|
30
|
-
# False positives:
|
31
|
-
# * On embedded models in migrations.
|
32
|
-
#
|
33
|
-
Rails/ApplicationRecord:
|
34
|
-
Exclude:
|
35
|
-
- 'db/**/*'
|
36
|
-
|
37
|
-
#
|
38
|
-
# Often when triggered it just wants to pass joined paths as separate
|
39
|
-
# arguments but that can hurt readability.
|
40
|
-
#
|
41
|
-
Rails/FilePath:
|
42
|
-
Enabled: false
|
43
|
-
|
44
|
-
#
|
45
|
-
# False positives:
|
46
|
-
# * Specs and migrations often need to update things without validations.
|
47
|
-
#
|
48
|
-
Rails/SkipsModelValidations:
|
49
|
-
Exclude:
|
50
|
-
- 'db/migrations/**.rb'
|
51
|
-
- 'spec/**/*_spec.rb'
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
# -----------------------------------------------------------------------------
|
56
|
-
# RSPEC
|
57
|
-
|
58
|
-
RSpec:
|
59
|
-
Include:
|
60
|
-
- 'spec/**/*_spec.rb'
|
61
|
-
- 'spec/spec_helper.rb'
|
62
|
-
- 'spec/rails_helper.rb'
|
63
|
-
|
64
|
-
RSpec/ContextWording:
|
65
|
-
Enabled: false
|
66
|
-
|
67
|
-
RSpec/ExampleLength:
|
68
|
-
Enabled: false
|
69
|
-
|
70
|
-
RSpec/ExpectInHook:
|
71
|
-
Enabled: false
|
72
|
-
|
73
|
-
RSpec/FilePath:
|
74
|
-
Exclude:
|
75
|
-
- 'spec/client/**/*_spec.rb'
|
76
|
-
|
77
|
-
RSpec/MessageSpies:
|
78
|
-
Enabled: false
|
79
|
-
|
80
|
-
RSpec/MissingExampleGroupArgument:
|
81
|
-
Enabled: false
|
82
|
-
|
83
|
-
RSpec/MultipleExpectations:
|
84
|
-
Enabled: false
|
85
|
-
|
86
|
-
RSpec/NestedGroups:
|
87
|
-
Max: 5
|
88
|
-
|
89
|
-
# -----------------------------------------------------------------------------
|
90
|
-
# Layout
|
91
|
-
|
92
|
-
Layout/AlignParameters:
|
93
|
-
EnforcedStyle: with_fixed_indentation
|
94
|
-
|
95
|
-
Layout/CaseIndentation:
|
96
|
-
EnforcedStyle: end
|
97
|
-
SupportedStyles:
|
98
|
-
- case
|
99
|
-
- end
|
100
|
-
IndentOneStep: true
|
101
|
-
|
102
|
-
Layout/MultilineMethodCallIndentation:
|
103
|
-
EnforcedStyle: indented
|
104
|
-
|
105
|
-
Layout/SpaceInsideBlockBraces:
|
106
|
-
EnforcedStyle: space
|
107
|
-
EnforcedStyleForEmptyBraces: no_space
|
108
|
-
SpaceBeforeBlockParameters: false
|
109
|
-
|
110
|
-
Layout/SpaceInsideHashLiteralBraces:
|
111
|
-
EnforcedStyle: no_space
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
# -----------------------------------------------------------------------------
|
116
|
-
# Lint
|
117
|
-
|
118
|
-
#
|
119
|
-
# False positives:
|
120
|
-
# * expect { something }.to change { something } often triggers this
|
121
|
-
#
|
122
|
-
Lint/AmbiguousBlockAssociation:
|
123
|
-
Exclude:
|
124
|
-
- 'spec/**/*_spec.rb'
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
# -----------------------------------------------------------------------------
|
129
|
-
# Metrics
|
130
|
-
|
131
|
-
Metrics/BlockLength:
|
132
|
-
Exclude:
|
133
|
-
- 'db/**/*'
|
134
|
-
- 'spec/**/*'
|
135
|
-
- 'config/**/*'
|
136
|
-
- '**/*.rake'
|
137
|
-
|
138
|
-
Metrics/ClassLength:
|
139
|
-
Max: 200
|
140
|
-
|
141
|
-
Metrics/LineLength:
|
142
|
-
Exclude:
|
143
|
-
- 'db/**/*'
|
144
|
-
- 'spec/**/*'
|
145
|
-
- 'config/**/*'
|
146
|
-
|
147
|
-
Metrics/MethodLength:
|
148
|
-
Exclude:
|
149
|
-
- 'db/**/*'
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
# -----------------------------------------------------------------------------
|
154
|
-
# Style
|
155
|
-
|
156
|
-
Style/BracesAroundHashParameters:
|
157
|
-
EnforcedStyle: context_dependent
|
158
|
-
|
159
|
-
#
|
160
|
-
# Both styles or mixtures are reasonable
|
161
|
-
#
|
162
|
-
Style/ClassAndModuleChildren:
|
163
|
-
EnforcedStyle: compact
|
164
|
-
Enabled: false
|
165
|
-
|
166
|
-
#
|
167
|
-
# Would be better but unlikely...
|
168
|
-
#
|
169
|
-
Style/Documentation:
|
170
|
-
Enabled: false
|
171
|
-
|
172
|
-
#
|
173
|
-
# Scripts might include on top-level
|
174
|
-
#
|
175
|
-
Style/MixinUsage:
|
176
|
-
Exclude:
|
177
|
-
- 'scripts/**/*'
|
178
|
-
|
179
|
-
Style/RaiseArgs:
|
180
|
-
EnforcedStyle: compact
|
181
|
-
|
182
|
-
#
|
183
|
-
# Quick single line rescues in specs
|
184
|
-
#
|
185
|
-
Style/RescueModifier:
|
186
|
-
Exclude:
|
187
|
-
- 'spec/**/*_spec.rb'
|
188
|
-
|
189
|
-
#
|
190
|
-
# Quick single line rescues in specs
|
191
|
-
#
|
192
|
-
Style/RescueStandardError:
|
193
|
-
Exclude:
|
194
|
-
- 'spec/**/*_spec.rb'
|
195
|
-
|
196
|
-
#
|
197
|
-
# Often used pattern in chaining subjects in specs
|
198
|
-
#
|
199
|
-
Style/Semicolon:
|
200
|
-
Exclude:
|
201
|
-
- 'spec/**/*_spec.rb'
|
202
|
-
|
203
|
-
Style/SignalException:
|
204
|
-
EnforcedStyle: only_raise
|
205
|
-
|
206
|
-
Style/TrailingCommaInArrayLiteral:
|
207
|
-
EnforcedStyleForMultiline: comma
|
208
|
-
|
209
|
-
Style/TrailingCommaInHashLiteral:
|
210
|
-
EnforcedStyleForMultiline: comma
|
211
|
-
|
5
|
+
TargetRubyVersion: 2.7
|
6
|
+
SuggestExtensions: False
|
7
|
+
NewCops: enable
|
data/Appraisals
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
appraise 'rails-7.0' do
|
4
|
+
gem 'rails', '~> 7.0.0'
|
5
|
+
end
|
6
|
+
|
7
|
+
appraise 'rails-6.1' do
|
8
|
+
gem 'rails', '~> 6.1.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise 'rails-6.0' do
|
12
|
+
gem 'rails', '~> 6.0.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise 'rails-5.2' do
|
16
|
+
gem 'rails', '~> 5.2.0'
|
17
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,46 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
|
|
17
17
|
### Breaks
|
18
18
|
|
19
19
|
|
20
|
+
## 3.0.0 - (2022-02-08)
|
21
|
+
---
|
22
|
+
|
23
|
+
### New
|
24
|
+
* Test integration with a Rails application without sprockets
|
25
|
+
* Add support for Rails 7.0 and Ruby 3.1
|
26
|
+
|
27
|
+
|
28
|
+
### Breaks
|
29
|
+
* Default to `public/assets/assets-manifest.json` manifest path matching new default from `webpack-assets-manifest` plugin
|
30
|
+
* Only support single manifest source file and error if not found (#9)
|
31
|
+
* Use `config.assets_manifest` as the config base to avoid conflicts in apps without sprockets (#9)
|
32
|
+
* Drop support for Ruby <2.7
|
33
|
+
|
34
|
+
|
35
|
+
## 2.1.2 - (2021-09-05)
|
36
|
+
---
|
37
|
+
|
38
|
+
### Fixes
|
39
|
+
* Return correct fully qualified URLs from manifest when relative URL host or asset host is configured
|
40
|
+
|
41
|
+
|
42
|
+
## 2.1.1 - (2021-06-20)
|
43
|
+
---
|
44
|
+
|
45
|
+
### Fixes
|
46
|
+
* Super method signature for keyword arguments
|
47
|
+
|
48
|
+
|
49
|
+
## 2.1.0 - (2019-09-11)
|
50
|
+
---
|
51
|
+
|
52
|
+
### New
|
53
|
+
* Automatically add `crossorigin="anonymous"` for SRI resources
|
54
|
+
* Separate manifest caching and eager loading
|
55
|
+
|
56
|
+
### Changes
|
57
|
+
* Remove defunct onboot manifest validation (f3fe8f57)
|
58
|
+
|
59
|
+
|
20
60
|
## 2.0.1 - (2019-08-09)
|
21
61
|
---
|
22
62
|
|
@@ -33,7 +73,6 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
|
|
33
73
|
|
34
74
|
### Breaks
|
35
75
|
* Change `manifest` configuration option into `manifests` to support multiple files
|
36
|
-
* Change configuration option into to support multiple files
|
37
76
|
|
38
77
|
|
39
78
|
## 1.1.0 - (2019-08-08)
|
data/Gemfile
CHANGED
@@ -5,5 +5,18 @@ source 'https://rubygems.org'
|
|
5
5
|
# Load gem's dependencies
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem '
|
8
|
+
gem 'net-smtp', require: false # not bundled in Ruby 3.1+
|
9
|
+
gem 'rails', require: false
|
10
|
+
gem 'sprockets-rails', require: false # not included by default in Rails 7+
|
11
|
+
gem 'sqlite3', require: false
|
12
|
+
|
13
|
+
gem 'rake', '~> 13.0'
|
9
14
|
gem 'rspec', '~> 3.0'
|
15
|
+
gem 'rspec-rails', '~> 5.0'
|
16
|
+
|
17
|
+
gem 'pry'
|
18
|
+
gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v7', require: false
|
19
|
+
|
20
|
+
group :development do
|
21
|
+
gem 'appraisal'
|
22
|
+
end
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Rails::Assets::Manifest
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/rails-assets-manifest?logo=ruby)](https://rubygems.org/gems/rails-assets-manifest)
|
4
|
+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/jgraichen/rails-assets-manifest/test?logo=github)](https://github.com/jgraichen/rails-assets-manifest/actions)
|
4
5
|
|
5
|
-
|
6
|
+
Load all assets in your Rails application from a `manifest.json`, e.g. generated by [webpack-assets-manifest](https://github.com/webdeveric/webpack-assets-manifest).
|
7
|
+
|
8
|
+
This gem does not make any assumption on which tool to use to make your assets not how to configure or invoke it. It only requires a manifest JSON. The manifest must either be a simple string map or must map to objects having a `'src'` attribute. Sub-resource integrity is supported too:
|
6
9
|
|
7
10
|
```json
|
8
11
|
{
|
@@ -17,7 +20,7 @@ This gem does not make any assumption on which tool to use to make your assets n
|
|
17
20
|
}
|
18
21
|
```
|
19
22
|
|
20
|
-
This gem does not add new helper methods but extends the existing helpers. SRI is automatically added if available and within a secure context
|
23
|
+
This gem does not add new helper methods but extends the existing helpers. SRI is automatically added if available and within a secure context. A `crossorigin="anonymous"` attribute is automatically added if non is present.
|
21
24
|
|
22
25
|
```slim
|
23
26
|
html
|
@@ -27,8 +30,8 @@ html
|
|
27
30
|
```
|
28
31
|
|
29
32
|
```html
|
30
|
-
<link rel="stylesheet" media="all" href="2b16adf6f756625a0194.css" integrity="sha384-/oreyvcV6U6htGZD0fDWR8/Txezke8KhD0QNgHb660hSaW7M+ZzxxuB4Vo+PuAC9">
|
31
|
-
<script src="2b16adf6f756625a0194.js" integrity="sha384-iJ55fQQApbQGxWEWSbWStBabi+yNGxZSQy/010+1Dhxl+rymyhGF4NtjUkOsYv7B"></script>
|
33
|
+
<link rel="stylesheet" media="all" href="2b16adf6f756625a0194.css" integrity="sha384-/oreyvcV6U6htGZD0fDWR8/Txezke8KhD0QNgHb660hSaW7M+ZzxxuB4Vo+PuAC9" crossorigin="anonymous">
|
34
|
+
<script src="2b16adf6f756625a0194.js" integrity="sha384-iJ55fQQApbQGxWEWSbWStBabi+yNGxZSQy/010+1Dhxl+rymyhGF4NtjUkOsYv7B" crossorigin="anonymous"></script>
|
32
35
|
```
|
33
36
|
|
34
37
|
## Installation
|
@@ -41,22 +44,39 @@ gem 'rails-assets-manifest'
|
|
41
44
|
|
42
45
|
## Usage
|
43
46
|
|
44
|
-
The manifest path can be configured e.g. in an
|
47
|
+
The manifest path can be configured e.g. in an `environments/*.rb` file:
|
45
48
|
|
46
49
|
```ruby
|
47
|
-
config.
|
50
|
+
config.assets_manifest.path = "public/.asset-manifest.json"
|
48
51
|
```
|
49
52
|
|
50
|
-
If `config.cache_classes` is set to `true` the manifest file be loaded once on boot
|
53
|
+
If `config.cache_classes` is set to `true` the manifest file be loaded once on boot. Assets included with `integrity: true` will raise an error if the integrity option is missing in the manifest.
|
51
54
|
|
52
|
-
|
55
|
+
## Webpack Assets Manifest Example
|
53
56
|
|
54
|
-
|
57
|
+
The following snippet provides an example configuration for the[webpack-assets-manifest](https://github.com/webdeveric/webpack-assets-manifest) plugin to generating a compatible assets manifest file.
|
55
58
|
|
56
|
-
```
|
57
|
-
|
59
|
+
```ts
|
60
|
+
new WebpackAssetsManifest({
|
61
|
+
integrity: true,
|
62
|
+
integrityHashes: ["sha384"],
|
63
|
+
writeToDisk: true,
|
64
|
+
entrypoints: false,
|
65
|
+
entrypointsUseAssets: true,
|
66
|
+
publicPath,
|
67
|
+
// Ignore a source maps and compressed files.
|
68
|
+
customize(e) {
|
69
|
+
if (e.key.endsWith(".map") || e.key.endsWith(".gz")) {
|
70
|
+
return false;
|
71
|
+
}
|
72
|
+
|
73
|
+
return e;
|
74
|
+
},
|
75
|
+
})
|
58
76
|
```
|
59
77
|
|
78
|
+
Specifying `writeToDisk: true` allows running the `webpack-dev-server` as proxy to the Rails application, and still generate correct assets links in Rails code. `rails-assets-manifest` defaults to using `public/assets/assets-manifest.json` as the manifest path.
|
79
|
+
|
60
80
|
## TODO
|
61
81
|
|
62
82
|
* Override/Join with `asset_host` URL?
|
@@ -72,7 +92,7 @@ Multiple manifests can be loaded by specifying multiple files. Glob patterns are
|
|
72
92
|
|
73
93
|
## MIT License
|
74
94
|
|
75
|
-
Copyright (c) 2018 Jan Graichen
|
95
|
+
Copyright (c) 2018-2022 Jan Graichen
|
76
96
|
|
77
97
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
78
98
|
of this software and associated documentation files (the "Software"), to deal
|
data/bin/console
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 5.2.0"
|
6
|
+
gem "sprockets-rails", require: false
|
7
|
+
gem "net-smtp", require: false
|
8
|
+
gem "sqlite3", require: false
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails", "~> 5.0"
|
12
|
+
gem "rubocop", "~> 1.14"
|
13
|
+
gem "pry"
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem "appraisal"
|
17
|
+
end
|
18
|
+
|
19
|
+
gemspec path: "../"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 6.0.0"
|
6
|
+
gem "sprockets-rails", require: false
|
7
|
+
gem "net-smtp", require: false
|
8
|
+
gem "sqlite3", require: false
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails", "~> 5.0"
|
12
|
+
gem "rubocop", "~> 1.14"
|
13
|
+
gem "pry"
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem "appraisal"
|
17
|
+
end
|
18
|
+
|
19
|
+
gemspec path: "../"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 6.1.0"
|
6
|
+
gem "sprockets-rails", require: false
|
7
|
+
gem "net-smtp", require: false
|
8
|
+
gem "sqlite3", require: false
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails", "~> 5.0"
|
12
|
+
gem "rubocop", "~> 1.14"
|
13
|
+
gem "pry"
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem "appraisal"
|
17
|
+
end
|
18
|
+
|
19
|
+
gemspec path: "../"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 7.0.0"
|
6
|
+
gem "sprockets-rails", require: false
|
7
|
+
gem "net-smtp", require: false
|
8
|
+
gem "sqlite3", require: false
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails", "~> 5.0"
|
12
|
+
gem "rubocop", "~> 1.14"
|
13
|
+
gem "pry"
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem "appraisal"
|
17
|
+
end
|
18
|
+
|
19
|
+
gemspec path: "../"
|
@@ -2,22 +2,44 @@
|
|
2
2
|
|
3
3
|
module Rails::Assets::Manifest
|
4
4
|
module Helper
|
5
|
-
|
5
|
+
URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}i.freeze
|
6
|
+
|
7
|
+
def path_to_asset(source, options)
|
8
|
+
if (entry = ::Rails::Assets::Manifest.lookup(path_with_extname(source, options)))
|
9
|
+
# Directly return the entry src if it is a fully qualified URL. Otherwise,
|
10
|
+
# Rails will join the URL with `relative_url_root` and/or asset host.
|
11
|
+
return entry.src if URI_REGEXP.match?(entry.src)
|
12
|
+
|
13
|
+
if entry.src[0] == '/'
|
14
|
+
# When the asset name starts with a slash, Rails will skip an
|
15
|
+
# additional lookup via `#compute_asset_path` and directly use the
|
16
|
+
# provided path. As we already have looked up the manifest entry here,
|
17
|
+
# we can pass the entry source, but only *if* it starts with a slash.
|
18
|
+
return super entry.src, options
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def compute_asset_path(name, _options)
|
6
26
|
::Rails::Assets::Manifest.lookup!(name).src
|
7
|
-
rescue EntryMissing
|
27
|
+
rescue EntryMissing
|
8
28
|
return super if Rails::Assets::Manifest.passthrough?
|
29
|
+
|
9
30
|
raise
|
10
31
|
end
|
11
32
|
|
12
|
-
def asset_integrity(name,
|
13
|
-
::Rails::Assets::Manifest.lookup!(path_with_extname(name,
|
14
|
-
rescue EntryMissing
|
33
|
+
def asset_integrity(name, options)
|
34
|
+
::Rails::Assets::Manifest.lookup!(path_with_extname(name, options)).integrity
|
35
|
+
rescue EntryMissing
|
15
36
|
return super if Rails::Assets::Manifest.passthrough?
|
37
|
+
|
16
38
|
raise
|
17
39
|
end
|
18
40
|
|
19
41
|
def javascript_include_tag(*sources, integrity: nil, **kwargs)
|
20
|
-
return super(*sources, **kwargs) unless
|
42
|
+
return super(*sources, **kwargs) unless manifest_use_integrity?(integrity)
|
21
43
|
|
22
44
|
with_integrity(sources, integrity, :javascript, **kwargs) do |source, options|
|
23
45
|
super(source, options)
|
@@ -25,7 +47,7 @@ module Rails::Assets::Manifest
|
|
25
47
|
end
|
26
48
|
|
27
49
|
def stylesheet_link_tag(*sources, integrity: nil, **kwargs)
|
28
|
-
return super(*sources, **kwargs) unless
|
50
|
+
return super(*sources, **kwargs) unless manifest_use_integrity?(integrity)
|
29
51
|
|
30
52
|
with_integrity(sources, integrity, :stylesheet, **kwargs) do |source, options|
|
31
53
|
super(source, options)
|
@@ -34,38 +56,43 @@ module Rails::Assets::Manifest
|
|
34
56
|
|
35
57
|
private
|
36
58
|
|
37
|
-
def
|
38
|
-
return false unless
|
59
|
+
def manifest_use_integrity?(option)
|
60
|
+
return false unless secure_request_context?
|
39
61
|
|
40
62
|
option || option.nil?
|
41
63
|
end
|
42
64
|
|
65
|
+
# http://www.w3.org/TR/SRI/#non-secure-contexts-remain-non-secure
|
66
|
+
def secure_request_context?
|
67
|
+
respond_to?(:request) && request && (request.local? || request.ssl?)
|
68
|
+
end
|
69
|
+
|
43
70
|
def with_integrity(sources, required, type, **kwargs)
|
44
71
|
sources.map do |source|
|
45
72
|
path = path_with_extname(source, type: type, **kwargs)
|
46
73
|
|
47
74
|
# integrity hash passed directly
|
48
75
|
if required.is_a?(String)
|
49
|
-
next yield(source, integrity: required, **kwargs)
|
76
|
+
next yield(source, integrity: required, crossorigin: 'anonymous', **kwargs)
|
77
|
+
end
|
50
78
|
|
51
79
|
# Explicit passed `true` option
|
52
|
-
|
80
|
+
if required
|
53
81
|
integrity = asset_integrity(source, type: type, **kwargs)
|
54
82
|
|
55
|
-
|
56
|
-
raise IntegrityMissing.new "SRI missing for #{path}"
|
57
|
-
end
|
83
|
+
raise IntegrityMissing.new "SRI missing for #{path}" unless integrity
|
58
84
|
|
59
|
-
next yield(source, integrity: integrity, **kwargs)
|
85
|
+
next yield(source, integrity: integrity, crossorigin: 'anonymous', **kwargs)
|
86
|
+
end
|
60
87
|
|
61
88
|
# No integrity option passed or `nil` default from above
|
62
|
-
|
89
|
+
if required.nil?
|
63
90
|
entry = ::Rails::Assets::Manifest.lookup(path)
|
64
91
|
|
65
92
|
# Only if it is an asset from our manifest and there is an integrity
|
66
93
|
# we default to adding one
|
67
|
-
if
|
68
|
-
next yield(source, integrity: entry.integrity, **kwargs)
|
94
|
+
if entry && entry.integrity
|
95
|
+
next yield(source, integrity: entry.integrity, crossorigin: 'anonymous', **kwargs)
|
69
96
|
end
|
70
97
|
end
|
71
98
|
|
@@ -73,10 +100,6 @@ module Rails::Assets::Manifest
|
|
73
100
|
end.join.html_safe
|
74
101
|
end
|
75
102
|
|
76
|
-
def secure_subresource_integrity_context?
|
77
|
-
respond_to?(:request) && (request&.local? || request&.ssl?)
|
78
|
-
end
|
79
|
-
|
80
103
|
def path_with_extname(path, options)
|
81
104
|
path = path.to_s
|
82
105
|
"#{path}#{compute_asset_extname(path, options)}"
|
@@ -4,11 +4,9 @@ module Rails::Assets::Manifest
|
|
4
4
|
class Manifest
|
5
5
|
attr_reader :path
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(path, cache: true)
|
8
|
+
@path = Rails.root.join(path).to_s.freeze
|
9
9
|
@cache = cache
|
10
|
-
|
11
|
-
data if cache?
|
12
10
|
end
|
13
11
|
|
14
12
|
def cache?
|
@@ -22,7 +20,7 @@ module Rails::Assets::Manifest
|
|
22
20
|
def lookup!(name)
|
23
21
|
lookup(name) || begin
|
24
22
|
raise EntryMissing.new <<~ERROR
|
25
|
-
Can't find #{name} in #{path}. Your
|
23
|
+
Can't find #{name} in #{path}. Your manifest contain:
|
26
24
|
#{JSON.pretty_generate(data.keys)}
|
27
25
|
ERROR
|
28
26
|
end
|
@@ -32,6 +30,10 @@ module Rails::Assets::Manifest
|
|
32
30
|
data.key?(name.to_s)
|
33
31
|
end
|
34
32
|
|
33
|
+
def eager_load!
|
34
|
+
data
|
35
|
+
end
|
36
|
+
|
35
37
|
private
|
36
38
|
|
37
39
|
Entry = Struct.new(:src, :integrity) do
|
@@ -48,13 +50,9 @@ module Rails::Assets::Manifest
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
|
-
def files
|
52
|
-
@files.map {|path| Dir.glob(path) }.flatten
|
53
|
-
end
|
54
|
-
|
55
53
|
def load
|
56
|
-
|
57
|
-
JSON.parse(File.read(
|
54
|
+
{}.tap do |entries|
|
55
|
+
JSON.parse(File.read(path)).each_pair do |key, entry|
|
58
56
|
if entry.is_a?(String)
|
59
57
|
entries[key] = Entry.new(entry, nil)
|
60
58
|
elsif entry.is_a?(Hash) && entry.key?('src')
|
@@ -68,7 +66,7 @@ module Rails::Assets::Manifest
|
|
68
66
|
raise ManifestMissing.new <<~ERROR
|
69
67
|
Asset manifest does not exist: #{e}
|
70
68
|
ERROR
|
71
|
-
rescue => e
|
69
|
+
rescue StandardError => e
|
72
70
|
raise ManifestInvalid.new <<~ERROR
|
73
71
|
Asset manifest could not be loaded: #{e}
|
74
72
|
ERROR
|
@@ -4,48 +4,27 @@ module Rails
|
|
4
4
|
module Assets
|
5
5
|
module Manifest
|
6
6
|
class Railtie < ::Rails::Railtie
|
7
|
-
|
8
|
-
# already exists and must not be overriden. Otherwise
|
9
|
-
# all sprockets default options are removed breaking
|
10
|
-
# sprockets.
|
11
|
-
unless config.respond_to?(:assets)
|
12
|
-
config.assets = ::ActiveSupport::OrderedOptions.new
|
13
|
-
end
|
7
|
+
config.assets_manifest = ::ActiveSupport::OrderedOptions.new
|
14
8
|
|
15
|
-
# Path where the manifest
|
16
|
-
config.
|
9
|
+
# Path where the manifest file is loaded from.
|
10
|
+
config.assets_manifest.path = 'public/assets/assets-manifest.json'
|
17
11
|
|
18
|
-
# If set to true missing assets will not raise an
|
19
|
-
#
|
20
|
-
|
21
|
-
config.assets.passthrough = false
|
12
|
+
# If set to true missing assets will not raise an exception but are
|
13
|
+
# passed through to sprockets or rails own asset methods.
|
14
|
+
config.assets_manifest.passthrough = false
|
22
15
|
|
23
16
|
config.after_initialize do |_|
|
24
17
|
ActiveSupport.on_load(:action_view) do
|
25
|
-
|
18
|
+
prepend Helper
|
26
19
|
end
|
27
20
|
end
|
28
21
|
|
29
|
-
|
30
|
-
::Rails::Assets::Manifest.
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def server?
|
36
|
-
!(console? || generator? || rake?)
|
37
|
-
end
|
38
|
-
|
39
|
-
def console?
|
40
|
-
defined?(Rails::Console)
|
41
|
-
end
|
42
|
-
|
43
|
-
def generator?
|
44
|
-
defined?(Rails::Generators)
|
22
|
+
config.to_prepare do
|
23
|
+
::Rails::Assets::Manifest.prepare!
|
45
24
|
end
|
46
25
|
|
47
|
-
|
48
|
-
|
26
|
+
config.before_eager_load do
|
27
|
+
::Rails::Assets::Manifest.eager_load!
|
49
28
|
end
|
50
29
|
end
|
51
30
|
end
|
@@ -4,12 +4,12 @@ module Rails
|
|
4
4
|
module Assets
|
5
5
|
module Manifest
|
6
6
|
module VERSION
|
7
|
-
MAJOR =
|
7
|
+
MAJOR = 3
|
8
8
|
MINOR = 0
|
9
|
-
PATCH =
|
9
|
+
PATCH = 0
|
10
10
|
STAGE = nil
|
11
11
|
|
12
|
-
STRING = [MAJOR, MINOR, PATCH, STAGE].
|
12
|
+
STRING = [MAJOR, MINOR, PATCH, STAGE].compact.join('.')
|
13
13
|
|
14
14
|
def self.to_s
|
15
15
|
STRING
|
@@ -13,25 +13,37 @@ module Rails
|
|
13
13
|
require 'rails/assets/manifest/railtie' if defined?(Rails::Railtie)
|
14
14
|
|
15
15
|
class ManifestMissing < StandardError; end
|
16
|
+
|
16
17
|
class ManifestInvalid < StandardError; end
|
18
|
+
|
17
19
|
class EntryMissing < StandardError; end
|
20
|
+
|
18
21
|
class IntegrityMissing < StandardError; end
|
19
22
|
|
20
23
|
class << self
|
21
24
|
delegate :lookup, :lookup!, to: :instance
|
22
25
|
|
23
|
-
|
24
|
-
|
26
|
+
attr_reader :instance
|
27
|
+
|
28
|
+
def prepare!
|
29
|
+
@instance = begin
|
25
30
|
config = Rails.application.config
|
26
31
|
|
27
|
-
Manifest.new
|
28
|
-
|
29
|
-
cache: config.cache_classes
|
32
|
+
Manifest.new(
|
33
|
+
config.assets_manifest.path,
|
34
|
+
cache: config.cache_classes,
|
35
|
+
)
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
39
|
+
def eager_load!
|
40
|
+
return unless @instance
|
41
|
+
|
42
|
+
@instance.eager_load!
|
43
|
+
end
|
44
|
+
|
33
45
|
def passthrough?
|
34
|
-
Rails.application.config.
|
46
|
+
Rails.application.config.assets_manifest.passthrough
|
35
47
|
end
|
36
48
|
end
|
37
49
|
end
|
@@ -14,9 +14,10 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'Load all rails assets from an external manifest.'
|
15
15
|
spec.homepage = 'https://github.com/jgraichen/rails-assets-manifest'
|
16
16
|
|
17
|
-
spec.metadata['homepage_uri']
|
18
|
-
spec.metadata['source_code_uri']
|
19
|
-
spec.metadata['changelog_uri']
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/jgraichen/rails-assets-manifest'
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/jgraichen/rails-assets-manifest/blob/master/CHANGELOG.md'
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
21
|
|
21
22
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
23
|
`git ls-files -z`.split("\x0").reject do |f|
|
@@ -28,6 +29,8 @@ Gem::Specification.new do |spec|
|
|
28
29
|
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
29
30
|
spec.require_paths = ['lib']
|
30
31
|
|
32
|
+
spec.required_ruby_version = '>= 2.7.0'
|
33
|
+
|
31
34
|
spec.add_dependency 'activesupport', '> 4.2'
|
32
35
|
spec.add_dependency 'railties', '> 4.2'
|
33
36
|
|
data/renovate.json
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-assets-manifest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -60,10 +60,11 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".editorconfig"
|
63
|
+
- ".github/workflows/test.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".rspec"
|
65
66
|
- ".rubocop.yml"
|
66
|
-
-
|
67
|
+
- Appraisals
|
67
68
|
- CHANGELOG.md
|
68
69
|
- Gemfile
|
69
70
|
- LICENSE
|
@@ -71,23 +72,24 @@ files:
|
|
71
72
|
- Rakefile
|
72
73
|
- bin/console
|
73
74
|
- bin/setup
|
74
|
-
- gemfiles/
|
75
|
-
- gemfiles/
|
76
|
-
- gemfiles/
|
77
|
-
- gemfiles/
|
78
|
-
- gemfiles/rails-master.gemfile
|
75
|
+
- gemfiles/rails_5.2.gemfile
|
76
|
+
- gemfiles/rails_6.0.gemfile
|
77
|
+
- gemfiles/rails_6.1.gemfile
|
78
|
+
- gemfiles/rails_7.0.gemfile
|
79
79
|
- lib/rails/assets/manifest.rb
|
80
80
|
- lib/rails/assets/manifest/helper.rb
|
81
81
|
- lib/rails/assets/manifest/manifest.rb
|
82
82
|
- lib/rails/assets/manifest/railtie.rb
|
83
83
|
- lib/rails/assets/manifest/version.rb
|
84
84
|
- rails-assets-manifest.gemspec
|
85
|
+
- renovate.json
|
85
86
|
homepage: https://github.com/jgraichen/rails-assets-manifest
|
86
87
|
licenses: []
|
87
88
|
metadata:
|
88
89
|
homepage_uri: https://github.com/jgraichen/rails-assets-manifest
|
89
90
|
source_code_uri: https://github.com/jgraichen/rails-assets-manifest
|
90
91
|
changelog_uri: https://github.com/jgraichen/rails-assets-manifest/blob/master/CHANGELOG.md
|
92
|
+
rubygems_mfa_required: 'true'
|
91
93
|
post_install_message:
|
92
94
|
rdoc_options: []
|
93
95
|
require_paths:
|
@@ -96,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
98
|
requirements:
|
97
99
|
- - ">="
|
98
100
|
- !ruby/object:Gem::Version
|
99
|
-
version:
|
101
|
+
version: 2.7.0
|
100
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
103
|
requirements:
|
102
104
|
- - ">="
|
103
105
|
- !ruby/object:Gem::Version
|
104
106
|
version: '0'
|
105
107
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.3.3
|
107
109
|
signing_key:
|
108
110
|
specification_version: 4
|
109
111
|
summary: Load all rails assets from an external manifest.
|
data/.travis.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
dist: xenial
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
|
5
|
-
rvm:
|
6
|
-
- 2.6.3
|
7
|
-
- 2.5.5
|
8
|
-
|
9
|
-
gemfile:
|
10
|
-
- gemfiles/rails-5-2.gemfile
|
11
|
-
- gemfiles/rails-master.gemfile
|
12
|
-
|
13
|
-
before_install:
|
14
|
-
- gem update --system
|
15
|
-
- gem install bundler
|
16
|
-
|
17
|
-
script:
|
18
|
-
- bundle exec rspec spec
|
19
|
-
|
20
|
-
jobs:
|
21
|
-
allow_failures:
|
22
|
-
- gemfile: gemfiles/rails-master.gemfile
|
23
|
-
|
24
|
-
include:
|
25
|
-
- stage: Release
|
26
|
-
rvm: 2.6.3
|
27
|
-
env: []
|
28
|
-
script: skip
|
29
|
-
install: skip
|
30
|
-
deploy:
|
31
|
-
provider: rubygems
|
32
|
-
api_key:
|
33
|
-
secure: m5gUzb8J40lo4EJ2xE8XwoeHq4S3ZEDE+AyikDHzGKc5NEQQcCRoc469UlDO7fYfBHGKLh2eEe6+e/T+dyRE/C0qE/tfd6pVWf8xdyzt9+rB0zM3k7pR2Aud2hZ8NFF4bAQ28OvQ2y9pWWLVS9Bn/C0Xou951yZM+vufPVZpX7+08Aw+ZdPQrmg+v9SxsvWElm/is0CMjsHxpEy1vpyyBlF/DhNpHgd+69nupyTuZP8bg3lirZexek0xNaccNpflmrUeRwE7yofVGMfrRhvm5kOniYI+sQl/Zwru9+hK2WaSzfX/ou4ENihiLDGo5gdWeYcyLbS61yQARsRn21cN6SA0iYVuVnAruHC3uoxRh7ty1H8s3aUJnPTnnBj5cnfP9pqOyZI8zFi54CujkEFbRVLlWfGjKtCScgFBwkpXS5aB6CBplulMrX3kz/jYXFgodXLsV10WD725WGJ2Jkb52PoT5i2GyA/Ao746s7+wPIEV/l8NAurcroSHOzr9PcAUG/CwdzgidSnLfwl+qplMCGaUHtdHkPaRHqJL9j4BmcqoGVMaU0a4mAXsrlJG/drT2PMMrREKChtnQPtWg3L9HHDHBIKuXZCIQ7G9n2Dz7lpWnyKZKjJTcFyZWbbnKHLXlE1KDBUiG9qqrYbpky+IEPUt4jZ1W8hx4tKGjNlNwjU=
|
34
|
-
gem: rails-assets-manifest
|
35
|
-
on:
|
36
|
-
tags: true
|
37
|
-
repo: jgraichen/rails-assets-manifest
|
data/gemfiles/rails-4-2.gemfile
DELETED
data/gemfiles/rails-5-0.gemfile
DELETED
data/gemfiles/rails-5-1.gemfile
DELETED
data/gemfiles/rails-5-2.gemfile
DELETED