vite_ruby 3.2.4 → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/vite_ruby/build.rb +31 -22
- data/lib/vite_ruby/builder.rb +9 -11
- data/lib/vite_ruby/cli/install.rb +1 -1
- data/lib/vite_ruby/io.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: 375a421ac4d10bc65044065ae4a69147c500808a2271ee77ed33b6721c34ca85
|
4
|
+
data.tar.gz: 917e97be44a37ad99dd3b700959d00ff26420727867c64b06a2b22354a7d8199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: babcceadc14d4f40e038610c47f09d57f22f1c3a4e3ded4ec1749b18c8ff3d3bb82ca6eaaab2b0036c026b586c705d9916dc3f030475679e7ad77d74c98bdd9e
|
7
|
+
data.tar.gz: 90d786e851da59d09ce76bc1162162f0d2e0c6f2824cba5a1e4bc3848936767a1a56387a9daa6fc77ee65d60cfa92cbecb6bca87107869b69150200df26d9cfd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [3.2.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.4...vite_ruby@3.2.5) (2022-10-07)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* display last build errors in MissingEntrypointError ([#274](https://github.com/ElMassimo/vite_ruby/issues/274)) ([107c980](https://github.com/ElMassimo/vite_ruby/commit/107c980449546ef73c527b88f1db11a7201e4438))
|
7
|
+
|
8
|
+
|
9
|
+
|
1
10
|
## [3.2.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.3...vite_ruby@3.2.4) (2022-10-04)
|
2
11
|
|
3
12
|
|
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
@@ -14,7 +14,10 @@ class ViteRuby::Builder
|
|
14
14
|
last_build = last_build_metadata(ssr: args.include?('--ssr'))
|
15
15
|
|
16
16
|
if args.delete('--force') || last_build.stale?
|
17
|
-
|
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/io.rb
CHANGED
@@ -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.5
|
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.5/vite_ruby
|
206
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.2.5/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
|
- - ">="
|