hanami-assets 2.1.0.rc2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/hanami/assets/base_url.rb +2 -5
- data/lib/hanami/assets/config.rb +2 -9
- data/lib/hanami/assets/errors.rb +0 -7
- data/lib/hanami/assets/version.rb +1 -1
- data/lib/hanami/assets.rb +27 -9
- metadata +6 -8
- data/bin/hanami-assets +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a0f74ce24868eb7966c76d648440874d7379feec8a0dcf54cc2b2ec041b1e68
|
4
|
+
data.tar.gz: 70224e7d218a8ce723f33a6472e45864c49867816e96faf73efdeb0ae5693bd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3843017a4e9ba13f467858ec0bc697ac89ee414c709a5a33cbd7f5b6d6a977b07d84961cb611983b4e2d0175e393354907de10d1191df396b64806913eee27ce
|
7
|
+
data.tar.gz: 4c60284918e679b1be855867bbcecc3b31901e3acf98c515cbda4c2d2cdd378c15ec988d43ce4346e03372966cc2bad7204b932a83027d7749bbacaa3729bdb9
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# Hanami::Assets
|
2
2
|
Assets management for Ruby web applications
|
3
3
|
|
4
|
+
## v2.1.0 - 2024-02-27
|
5
|
+
|
6
|
+
## v2.1.0.rc3 - 2024-02-16
|
7
|
+
### Changed
|
8
|
+
- [Tim Riley] Require a `root:` argument when initializing `Hanami::Assets`. This should be the directory containing the compiled assets and their `assets.json` manifest file.
|
9
|
+
- [Tim Riley] Removed `manifest_path` setting; the manifest path is no longer user-configurable.
|
10
|
+
- [Tim Riley] Replaced `package_manager_run_command` setting with `node_command` setting.
|
11
|
+
- [Tim Riley] Removed unused `sources`, `entry_point_patterns` and `destination` settings.
|
12
|
+
- [Tim Riley] Removed `bin/hanami-assets` executable.
|
13
|
+
|
4
14
|
## v2.1.0.rc2 - 2023-11-08
|
5
15
|
|
6
16
|
## v2.1.0.rc1 - 2023-11-01
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "uri"
|
4
|
+
|
3
5
|
module Hanami
|
4
6
|
class Assets
|
5
7
|
# Base URL
|
@@ -7,11 +9,6 @@ module Hanami
|
|
7
9
|
# @since 2.1.0
|
8
10
|
# @api private
|
9
11
|
class BaseUrl
|
10
|
-
# @since 2.1.0
|
11
|
-
# @api private
|
12
|
-
SEPARATOR = "/"
|
13
|
-
private_constant :SEPARATOR
|
14
|
-
|
15
12
|
# @since 2.1.0
|
16
13
|
# @api private
|
17
14
|
attr_reader :url
|
data/lib/hanami/assets/config.rb
CHANGED
@@ -17,12 +17,12 @@ module Hanami
|
|
17
17
|
BASE_URL = ""
|
18
18
|
private_constant :BASE_URL
|
19
19
|
|
20
|
-
# @!attribute [rw]
|
20
|
+
# @!attribute [rw] node_command
|
21
21
|
# @return [String]
|
22
22
|
#
|
23
23
|
# @api public
|
24
24
|
# @since 2.1.0
|
25
|
-
setting :
|
25
|
+
setting :node_command, default: "node"
|
26
26
|
|
27
27
|
# @!attribute [rw] path_prefix
|
28
28
|
# @return [String]
|
@@ -51,13 +51,6 @@ module Hanami
|
|
51
51
|
# @since 2.1.0
|
52
52
|
setting :base_url, constructor: -> url { BaseUrl.new(url.to_s) }
|
53
53
|
|
54
|
-
# @!attribute [rw] manifest_path
|
55
|
-
# @return [String, nil]
|
56
|
-
#
|
57
|
-
# @api public
|
58
|
-
# @since 2.1.0
|
59
|
-
setting :manifest_path
|
60
|
-
|
61
54
|
# @api public
|
62
55
|
# @since 2.1.0
|
63
56
|
def initialize(**values)
|
data/lib/hanami/assets/errors.rb
CHANGED
@@ -9,13 +9,6 @@ module Hanami
|
|
9
9
|
class Error < ::StandardError
|
10
10
|
end
|
11
11
|
|
12
|
-
# Error raised when assets config is not valid.
|
13
|
-
#
|
14
|
-
# @api public
|
15
|
-
# @since 2.1.0
|
16
|
-
class ConfigError < Error
|
17
|
-
end
|
18
|
-
|
19
12
|
# Error returned when the assets manifest file is missing.
|
20
13
|
#
|
21
14
|
# @api public
|
data/lib/hanami/assets.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "json"
|
4
|
+
require "pathname"
|
4
5
|
require "zeitwerk"
|
5
6
|
|
6
7
|
module Hanami
|
@@ -28,19 +29,38 @@ module Hanami
|
|
28
29
|
require_relative "assets/version"
|
29
30
|
require_relative "assets/errors"
|
30
31
|
|
32
|
+
# Returns the directory (under `public/assets/`) to be used for storing a slice's compiled
|
33
|
+
# assets.
|
34
|
+
#
|
35
|
+
# This is shared logic used by both Hanami (for the assets provider) and Hanami::CLI (for the
|
36
|
+
# assets commands).
|
37
|
+
#
|
38
|
+
# @since 2.1.0
|
39
|
+
# @api private
|
40
|
+
def self.public_assets_dir(slice)
|
41
|
+
return nil if slice.app.eql?(slice)
|
42
|
+
|
43
|
+
slice.slice_name.to_s.split("/").map { |name| "_#{name}" }.join("/")
|
44
|
+
end
|
45
|
+
|
31
46
|
# @api private
|
32
47
|
# @since 2.1.0
|
33
|
-
|
34
|
-
private_constant :
|
48
|
+
MANIFEST_PATH = "assets.json"
|
49
|
+
private_constant :MANIFEST_PATH
|
35
50
|
|
36
51
|
# @api private
|
37
52
|
# @since 2.1.0
|
38
53
|
attr_reader :config
|
39
54
|
|
55
|
+
# @api private
|
56
|
+
# @since 2.1.0
|
57
|
+
attr_reader :root
|
58
|
+
|
40
59
|
# @api public
|
41
60
|
# @since 2.1.0
|
42
|
-
def initialize(config:)
|
61
|
+
def initialize(config:, root:)
|
43
62
|
@config = config
|
63
|
+
@root = Pathname(root)
|
44
64
|
end
|
45
65
|
|
46
66
|
# Returns the asset at the given path.
|
@@ -92,15 +112,13 @@ module Hanami
|
|
92
112
|
def manifest
|
93
113
|
return @manifest if instance_variable_defined?(:@manifest)
|
94
114
|
|
95
|
-
|
96
|
-
raise ConfigError, "no manifest_path configured"
|
97
|
-
end
|
115
|
+
full_manifest_path = root.join(MANIFEST_PATH)
|
98
116
|
|
99
|
-
unless
|
100
|
-
raise ManifestMissingError.new(
|
117
|
+
unless full_manifest_path.exist?
|
118
|
+
raise ManifestMissingError.new(full_manifest_path.to_s)
|
101
119
|
end
|
102
120
|
|
103
|
-
@manifest = JSON.parse(File.read(
|
121
|
+
@manifest = JSON.parse(File.read(full_manifest_path))
|
104
122
|
end
|
105
123
|
end
|
106
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -145,15 +145,13 @@ dependencies:
|
|
145
145
|
description: Assets management for Ruby web applications
|
146
146
|
email:
|
147
147
|
- me@lucaguidi.com
|
148
|
-
executables:
|
149
|
-
- hanami-assets
|
148
|
+
executables: []
|
150
149
|
extensions: []
|
151
150
|
extra_rdoc_files: []
|
152
151
|
files:
|
153
152
|
- CHANGELOG.md
|
154
153
|
- LICENSE.md
|
155
154
|
- README.md
|
156
|
-
- bin/hanami-assets
|
157
155
|
- hanami-assets.gemspec
|
158
156
|
- lib/hanami-assets.rb
|
159
157
|
- lib/hanami/assets.rb
|
@@ -178,11 +176,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
176
|
version: '3.0'
|
179
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
178
|
requirements:
|
181
|
-
- - "
|
179
|
+
- - ">="
|
182
180
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
181
|
+
version: '0'
|
184
182
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
183
|
+
rubygems_version: 3.5.6
|
186
184
|
signing_key:
|
187
185
|
specification_version: 4
|
188
186
|
summary: Assets management
|
data/bin/hanami-assets
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "optparse"
|
5
|
-
require "pathname"
|
6
|
-
|
7
|
-
options = {}
|
8
|
-
OptionParser.new do |opts|
|
9
|
-
opts.banner = "Usage: hanami-assets --config=path/to/config.rb"
|
10
|
-
|
11
|
-
opts.on("-c", "--config FILE", "Path to config") do |c|
|
12
|
-
options[:config] = c
|
13
|
-
end
|
14
|
-
end.parse!
|
15
|
-
|
16
|
-
config = options.fetch(:config) { raise ArgumentError.new("You must specify a configuration file") }
|
17
|
-
config = Pathname.new(config)
|
18
|
-
config.exist? or raise ArgumentError.new("Cannot find configuration file: #{config}")
|
19
|
-
|
20
|
-
require "hanami/assets"
|
21
|
-
load config
|
22
|
-
|
23
|
-
Hanami::Assets.deploy
|