propshaft 0.9.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -6
- data/lib/propshaft/assembly.rb +3 -8
- data/lib/propshaft/asset.rb +11 -2
- data/lib/propshaft/output_path.rb +2 -9
- data/lib/propshaft/processor.rb +5 -5
- data/lib/propshaft/railtie.rb +5 -0
- data/lib/propshaft/resolver/dynamic.rb +2 -2
- data/lib/propshaft/resolver/static.rb +2 -2
- data/lib/propshaft/server.rb +1 -3
- data/lib/propshaft/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14ffc5b071d45f08f18e5f52fa2668f4630debf23d501c08e000d309c3a9b8fd
|
4
|
+
data.tar.gz: c210e3cd12d58e3df3c2a20c2b42d182ee66e13ae3d6653fd05272b3ad513e37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea78212ba31154621e6878b7e721abbc787e0594da6dadf6d6e587b213c9f587d6d554e74f5b79d361944ae43514c82efa30b49978d4faa776e21774ceb4fd6
|
7
|
+
data.tar.gz: 46de0996122fe99868d6a74a1d4f3c37c8897c6b760e0a7de9db36cc8794995ea6c753d792fd21ddde22d2d9fa1fd599aef055d94a42da49b36e1badeb5f5ca9
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ So that's what Propshaft doesn't do. Here's what it does provide:
|
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
15
|
-
With Rails 7
|
15
|
+
With Rails 8, Propshaft is the default asset pipeline for new applications. With Rails 7, you can start a new application with propshaft using `rails new myapp -a propshaft`. For existing applications, check the [upgrade guide](https://github.com/rails/propshaft/blob/main/UPGRADING.md) which contains step-by-step instructions.
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
@@ -47,11 +47,6 @@ On the other hand, if you're already bundling JavaScript and CSS through a Node-
|
|
47
47
|
But for greenfield apps using the default import-map approach, Propshaft can also work well, if you're able to deal with vanilla CSS.
|
48
48
|
|
49
49
|
|
50
|
-
## Will Propshaft replace Sprockets as the Rails default?
|
51
|
-
|
52
|
-
Most likely, but Sprockets needs to be supported as well for a long time to come. Plenty of apps and gems were built on Sprocket features, and they won't be migrating soon. Still working out the compatibility story. This is very much beta software at the moment.
|
53
|
-
|
54
|
-
|
55
50
|
## License
|
56
51
|
|
57
52
|
Propshaft is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/propshaft/assembly.rb
CHANGED
@@ -19,8 +19,8 @@ class Propshaft::Assembly
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def resolver
|
22
|
-
@resolver ||= if manifest_path.exist?
|
23
|
-
Propshaft::Resolver::Static.new manifest_path: manifest_path, prefix: config.prefix
|
22
|
+
@resolver ||= if config.manifest_path.exist?
|
23
|
+
Propshaft::Resolver::Static.new manifest_path: config.manifest_path, prefix: config.prefix
|
24
24
|
else
|
25
25
|
Propshaft::Resolver::Dynamic.new load_path: load_path, prefix: config.prefix
|
26
26
|
end
|
@@ -32,7 +32,7 @@ class Propshaft::Assembly
|
|
32
32
|
|
33
33
|
def processor
|
34
34
|
Propshaft::Processor.new \
|
35
|
-
load_path: load_path, output_path: config.output_path, compilers: compilers
|
35
|
+
load_path: load_path, output_path: config.output_path, compilers: compilers, manifest_path: config.manifest_path
|
36
36
|
end
|
37
37
|
|
38
38
|
def compilers
|
@@ -51,9 +51,4 @@ class Propshaft::Assembly
|
|
51
51
|
asset.send(path_type)
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
private
|
56
|
-
def manifest_path
|
57
|
-
config.output_path.join(Propshaft::Processor::MANIFEST_FILENAME)
|
58
|
-
end
|
59
54
|
end
|
data/lib/propshaft/asset.rb
CHANGED
@@ -4,12 +4,21 @@ require "action_dispatch/http/mime_type"
|
|
4
4
|
class Propshaft::Asset
|
5
5
|
attr_reader :path, :logical_path, :load_path
|
6
6
|
|
7
|
+
class << self
|
8
|
+
def extract_path_and_digest(digested_path)
|
9
|
+
digest = digested_path[/-([0-9a-zA-Z]{7,128})\.(?!digested)([^.]|.map)+\z/, 1]
|
10
|
+
path = digest ? digested_path.sub("-#{digest}", "") : digested_path
|
11
|
+
|
12
|
+
[path, digest]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
7
16
|
def initialize(path, logical_path:, load_path:)
|
8
17
|
@path, @logical_path, @load_path = path, Pathname.new(logical_path), load_path
|
9
18
|
end
|
10
19
|
|
11
|
-
def content
|
12
|
-
File.
|
20
|
+
def content(encoding: "ASCII-8BIT")
|
21
|
+
File.read(path, encoding: encoding)
|
13
22
|
end
|
14
23
|
|
15
24
|
def content_type
|
@@ -26,7 +26,7 @@ class Propshaft::OutputPath
|
|
26
26
|
Hash.new.tap do |files|
|
27
27
|
all_files_from_tree(path).each do |file|
|
28
28
|
digested_path = file.relative_path_from(path)
|
29
|
-
logical_path, digest = extract_path_and_digest(digested_path)
|
29
|
+
logical_path, digest = Propshaft::Asset.extract_path_and_digest(digested_path.to_s)
|
30
30
|
|
31
31
|
files[digested_path.to_s] = {
|
32
32
|
logical_path: logical_path.to_s,
|
@@ -42,7 +42,7 @@ class Propshaft::OutputPath
|
|
42
42
|
modified_at = [ 0, Time.now - mtime ].max
|
43
43
|
modified_at < expires_at || limit < count
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def remove(path)
|
47
47
|
FileUtils.rm(@path.join(path))
|
48
48
|
Propshaft.logger.info "Removed #{path}"
|
@@ -51,11 +51,4 @@ class Propshaft::OutputPath
|
|
51
51
|
def all_files_from_tree(path)
|
52
52
|
path.children.flat_map { |child| child.directory? ? all_files_from_tree(child) : child }
|
53
53
|
end
|
54
|
-
|
55
|
-
def extract_path_and_digest(digested_path)
|
56
|
-
digest = digested_path.to_s[/-([0-9a-f]{7,128})\.(?!digested)[^.]+\z/, 1]
|
57
|
-
path = digest ? digested_path.sub("-#{digest}", "") : digested_path
|
58
|
-
|
59
|
-
[path, digest]
|
60
|
-
end
|
61
54
|
end
|
data/lib/propshaft/processor.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require "propshaft/output_path"
|
2
2
|
|
3
3
|
class Propshaft::Processor
|
4
|
-
|
4
|
+
attr_reader :load_path, :output_path, :compilers, :manifest_path
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(load_path:, output_path:, compilers:)
|
6
|
+
def initialize(load_path:, output_path:, compilers:, manifest_path:)
|
9
7
|
@load_path, @output_path = load_path, output_path
|
8
|
+
@manifest_path = manifest_path
|
10
9
|
@compilers = compilers
|
11
10
|
end
|
12
11
|
|
@@ -31,7 +30,8 @@ class Propshaft::Processor
|
|
31
30
|
|
32
31
|
|
33
32
|
def write_manifest
|
34
|
-
|
33
|
+
FileUtils.mkdir_p(File.dirname(manifest_path))
|
34
|
+
File.open(manifest_path, "wb+") do |manifest|
|
35
35
|
manifest.write load_path.manifest.to_json
|
36
36
|
end
|
37
37
|
end
|
data/lib/propshaft/railtie.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rails"
|
2
2
|
require "active_support/ordered_options"
|
3
|
+
require "propshaft"
|
3
4
|
require "propshaft/quiet_assets"
|
4
5
|
|
5
6
|
module Propshaft
|
@@ -31,9 +32,13 @@ module Propshaft
|
|
31
32
|
end
|
32
33
|
|
33
34
|
config.after_initialize do |app|
|
35
|
+
# Prioritize assets from within the application over assets of the same path from engines/gems.
|
36
|
+
config.assets.paths.sort_by! { |path| path.to_s.start_with?(Rails.root.to_s) ? 0 : 1 }
|
37
|
+
|
34
38
|
config.assets.relative_url_root ||= app.config.relative_url_root
|
35
39
|
config.assets.output_path ||=
|
36
40
|
Pathname.new(File.join(app.config.paths["public"].first, app.config.assets.prefix))
|
41
|
+
config.assets.manifest_path ||= config.assets.output_path.join(".manifest.json")
|
37
42
|
|
38
43
|
app.assets = Propshaft::Assembly.new(app.config.assets)
|
39
44
|
|
@@ -12,9 +12,9 @@ module Propshaft::Resolver
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def read(logical_path)
|
15
|
+
def read(logical_path, encoding: "ASCII-8BIT")
|
16
16
|
if asset_path = parsed_manifest[logical_path]
|
17
|
-
manifest_path.dirname.join(asset_path)
|
17
|
+
File.read(manifest_path.dirname.join(asset_path), encoding: encoding)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/propshaft/server.rb
CHANGED
@@ -35,10 +35,8 @@ class Propshaft::Server
|
|
35
35
|
private
|
36
36
|
def extract_path_and_digest(env)
|
37
37
|
full_path = Rack::Utils.unescape(env["PATH_INFO"].to_s.sub(/^\//, ""))
|
38
|
-
digest = full_path[/-([0-9a-zA-Z]{7,128})\.(?!digested)([^.]|.map)+\z/, 1]
|
39
|
-
path = digest ? full_path.sub("-#{digest}", "") : full_path
|
40
38
|
|
41
|
-
|
39
|
+
Propshaft::Asset.extract_path_and_digest(full_path)
|
42
40
|
end
|
43
41
|
|
44
42
|
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3")
|
data/lib/propshaft/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propshaft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
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: 2024-
|
11
|
+
date: 2024-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.5.
|
117
|
+
rubygems_version: 3.5.16
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Deliver assets for Rails.
|