vite_ruby 3.2.4 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/vite_ruby/build.rb +31 -22
- data/lib/vite_ruby/builder.rb +10 -12
- data/lib/vite_ruby/cli/install.rb +1 -1
- data/lib/vite_ruby/config.rb +5 -0
- data/lib/vite_ruby/io.rb +1 -1
- data/lib/vite_ruby/manifest.rb +1 -1
- data/lib/vite_ruby/missing_entrypoint_error.rb +15 -7
- data/lib/vite_ruby/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61362606d0cc4c30a9194954b8d017a8fd7f929be21d99f4030a39fe32b01c8b
|
4
|
+
data.tar.gz: 4b30fcb2f8683dd3ae69aa6b9324ee0b5a947c2b82bda4003bfe5bc330c22d4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a8f10aed93a2b6b8272f00404f6689f5252a459ae8a6c23151b2b577e20781d19051914d2a77125d820264683aa5f695bfbc86d11e29a750a7f740aa4fae7f8
|
7
|
+
data.tar.gz: afb33c544dc8e9a52e5c0cec38bd49be6c22ca64f2e60fcc4af4074291e30c5e789e75f26336b878a61e868c765fb3363b932d85e1ed514da67ec846680a1a68
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## [3.2.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.5...vite_ruby@3.2.6) (2022-10-07)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* always trigger a build if the manifest is missing ([#275](https://github.com/ElMassimo/vite_ruby/issues/275)) ([53ffdb9](https://github.com/ElMassimo/vite_ruby/commit/53ffdb9559409cb813198b4fd8a7a5ccb0c3cd21))
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
## [3.2.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.4...vite_ruby@3.2.5) (2022-10-07)
|
11
|
+
|
12
|
+
|
13
|
+
### Features
|
14
|
+
|
15
|
+
* display last build errors in MissingEntrypointError ([#274](https://github.com/ElMassimo/vite_ruby/issues/274)) ([107c980](https://github.com/ElMassimo/vite_ruby/commit/107c980449546ef73c527b88f1db11a7201e4438))
|
16
|
+
|
17
|
+
|
18
|
+
|
1
19
|
## [3.2.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.3...vite_ruby@3.2.4) (2022-10-04)
|
2
20
|
|
3
21
|
|
data/lib/vite_ruby/build.rb
CHANGED
@@ -4,24 +4,32 @@ require 'json'
|
|
4
4
|
require 'time'
|
5
5
|
|
6
6
|
# Internal: Value object with information about the last build.
|
7
|
-
ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current_digest, :last_build_path) do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current_digest, :last_build_path, :errors, keyword_init: true) do
|
8
|
+
class << self
|
9
|
+
# Internal: Combines information from a previous build with the current digest.
|
10
|
+
def from_previous(last_build_path, current_digest)
|
11
|
+
new(
|
12
|
+
**parse_metadata(last_build_path),
|
13
|
+
current_digest: current_digest,
|
14
|
+
last_build_path: last_build_path,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Internal: Reads metadata recorded on the last build, if it exists.
|
21
|
+
def parse_metadata(pathname)
|
22
|
+
return default_metadata unless pathname.exist?
|
23
|
+
|
24
|
+
JSON.parse(pathname.read.to_s).transform_keys(&:to_sym).slice(*members)
|
13
25
|
rescue JSON::JSONError, Errno::ENOENT, Errno::ENOTDIR
|
14
|
-
|
26
|
+
default_metadata
|
15
27
|
end
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
attrs['digest'] || 'none',
|
22
|
-
current_digest,
|
23
|
-
last_build_path,
|
24
|
-
)
|
29
|
+
# Internal: To make it evident that there's no last build in error messages.
|
30
|
+
def default_metadata
|
31
|
+
{ timestamp: 'never', digest: 'none' }
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
# Internal: A build is considered stale when watched files have changed since
|
@@ -45,14 +53,14 @@ ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current
|
|
45
53
|
end
|
46
54
|
|
47
55
|
# Internal: Returns a new build with the specified result.
|
48
|
-
def with_result(
|
56
|
+
def with_result(**attrs)
|
49
57
|
self.class.new(
|
50
|
-
|
51
|
-
Time.now.strftime('%F %T'),
|
52
|
-
ViteRuby::VERSION,
|
53
|
-
current_digest,
|
54
|
-
current_digest,
|
55
|
-
last_build_path,
|
58
|
+
**attrs,
|
59
|
+
timestamp: Time.now.strftime('%F %T'),
|
60
|
+
vite_ruby: ViteRuby::VERSION,
|
61
|
+
digest: current_digest,
|
62
|
+
current_digest: current_digest,
|
63
|
+
last_build_path: last_build_path,
|
56
64
|
)
|
57
65
|
end
|
58
66
|
|
@@ -65,6 +73,7 @@ ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current
|
|
65
73
|
def to_json(*_args)
|
66
74
|
JSON.pretty_generate(
|
67
75
|
success: success,
|
76
|
+
errors: errors,
|
68
77
|
timestamp: timestamp,
|
69
78
|
vite_ruby: vite_ruby,
|
70
79
|
digest: digest,
|
data/lib/vite_ruby/builder.rb
CHANGED
@@ -13,8 +13,11 @@ class ViteRuby::Builder
|
|
13
13
|
def build(*args)
|
14
14
|
last_build = last_build_metadata(ssr: args.include?('--ssr'))
|
15
15
|
|
16
|
-
if args.delete('--force') || last_build.stale?
|
17
|
-
|
16
|
+
if args.delete('--force') || last_build.stale? || config.manifest_paths.empty?
|
17
|
+
stdout, stderr, success = build_with_vite(*args)
|
18
|
+
log_build_result(stdout, stderr, success)
|
19
|
+
record_build_metadata(last_build, errors: stderr, success: success)
|
20
|
+
success
|
18
21
|
elsif last_build.success
|
19
22
|
logger.debug "Skipping vite build. Watched files have not changed since the last build at #{ last_build.timestamp }"
|
20
23
|
true
|
@@ -36,9 +39,9 @@ private
|
|
36
39
|
def_delegators :@vite_ruby, :config, :logger, :run
|
37
40
|
|
38
41
|
# Internal: Writes a digest of the watched files to disk for future checks.
|
39
|
-
def record_build_metadata(
|
42
|
+
def record_build_metadata(build, **attrs)
|
40
43
|
config.build_cache_dir.mkpath
|
41
|
-
build.with_result(
|
44
|
+
build.with_result(**attrs).write_to_cache
|
42
45
|
end
|
43
46
|
|
44
47
|
# Internal: The file path where metadata of the last build is stored.
|
@@ -57,24 +60,19 @@ private
|
|
57
60
|
end
|
58
61
|
|
59
62
|
# Public: Initiates a Vite build command to generate assets.
|
60
|
-
#
|
61
|
-
# Returns true if the build is successful, or false if it failed.
|
62
63
|
def build_with_vite(*args)
|
63
64
|
logger.info 'Building with Vite ⚡️'
|
64
65
|
|
65
|
-
|
66
|
-
log_build_result(stdout, stderr.to_s, status)
|
67
|
-
|
68
|
-
status.success?
|
66
|
+
run(['build', *args])
|
69
67
|
end
|
70
68
|
|
71
69
|
# Internal: Outputs the build results.
|
72
70
|
#
|
73
71
|
# NOTE: By default it also outputs the manifest entries.
|
74
72
|
def log_build_result(_stdout, stderr, status)
|
75
|
-
if status
|
73
|
+
if status
|
76
74
|
logger.info "Build with Vite complete: #{ config.build_output_dir }"
|
77
|
-
logger.error stderr
|
75
|
+
logger.error stderr unless stderr.empty?
|
78
76
|
else
|
79
77
|
logger.error stderr
|
80
78
|
logger.error 'Build with Vite failed! ❌'
|
@@ -111,7 +111,7 @@ private
|
|
111
111
|
def run_with_capture(*args, **options)
|
112
112
|
Dir.chdir(root) do
|
113
113
|
_, stderr, status = ViteRuby::IO.capture(*args, **options)
|
114
|
-
say(stderr) unless status
|
114
|
+
say(stderr) unless status || stderr.empty?
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
data/lib/vite_ruby/config.rb
CHANGED
@@ -23,6 +23,11 @@ class ViteRuby::Config
|
|
23
23
|
build_output_dir.join('manifest-assets.json')
|
24
24
|
end
|
25
25
|
|
26
|
+
# Internal: Path to the manifest files generated by Vite and vite-plugin-ruby.
|
27
|
+
def manifest_paths
|
28
|
+
[manifest_path, assets_manifest_path].select(&:exist?)
|
29
|
+
end
|
30
|
+
|
26
31
|
# Public: The directory where Vite will store the built assets.
|
27
32
|
def build_output_dir
|
28
33
|
root.join(public_dir, public_output_dir)
|
data/lib/vite_ruby/io.rb
CHANGED
data/lib/vite_ruby/manifest.rb
CHANGED
@@ -119,7 +119,7 @@ private
|
|
119
119
|
|
120
120
|
# Internal: Loads and merges the manifest files, resolving the asset paths.
|
121
121
|
def load_manifest
|
122
|
-
files =
|
122
|
+
files = config.manifest_paths
|
123
123
|
files.map { |path| JSON.parse(path.read) }.inject({}, &:merge).tap(&method(:resolve_references))
|
124
124
|
end
|
125
125
|
|
@@ -17,19 +17,27 @@ class ViteRuby::MissingEntrypointError < ViteRuby::Error
|
|
17
17
|
#{ possible_causes(last_build) }
|
18
18
|
:troubleshooting:
|
19
19
|
#{ "\nContent in your manifests:\n#{ JSON.pretty_generate(manifest) }\n" if last_build.success }
|
20
|
-
#{ "Last build in #{ config.mode } mode:\n#{ last_build.to_json }\n"
|
20
|
+
#{ "Last build in #{ config.mode } mode:\n#{ last_build.to_json }\n" if last_build.success }
|
21
21
|
MSG
|
22
22
|
end
|
23
23
|
|
24
24
|
def possible_causes(last_build)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
if last_build.success == false
|
26
|
+
FAILED_BUILD_CAUSES
|
27
|
+
.sub(':mode:', config.mode)
|
28
|
+
.sub(':errors:', last_build.errors.to_s.gsub(/^(?!$)/, ' '))
|
29
|
+
elsif config.auto_build
|
30
|
+
DEFAULT_CAUSES
|
31
|
+
else
|
32
|
+
DEFAULT_CAUSES + NO_AUTO_BUILD_CAUSES
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
|
-
FAILED_BUILD_CAUSES =
|
32
|
-
|
36
|
+
FAILED_BUILD_CAUSES = <<~MSG
|
37
|
+
- The last build failed. Try running `bin/vite build --clear --mode=:mode:` manually and check for errors.
|
38
|
+
|
39
|
+
Errors:
|
40
|
+
:errors:
|
33
41
|
MSG
|
34
42
|
|
35
43
|
DEFAULT_CAUSES = <<-MSG
|
data/lib/vite_ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vite_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -202,8 +202,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
202
202
|
licenses:
|
203
203
|
- MIT
|
204
204
|
metadata:
|
205
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.2.
|
206
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.2.
|
205
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.2.6/vite_ruby
|
206
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.2.6/vite_ruby/CHANGELOG.md
|
207
207
|
post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
|
208
208
|
manually, please run:\n\tbundle exec vite upgrade"
|
209
209
|
rdoc_options: []
|
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
requirements:
|
214
214
|
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version: '2.
|
216
|
+
version: '2.5'
|
217
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
219
|
- - ">="
|