vite_ruby 1.2.10 → 1.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/vite_ruby/cli/build.rb +3 -15
- data/lib/vite_ruby/cli/dev.rb +1 -1
- data/lib/vite_ruby/cli/file_utils.rb +123 -0
- data/lib/vite_ruby/cli/install.rb +2 -3
- data/lib/vite_ruby/cli/vite.rb +20 -0
- data/lib/vite_ruby/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4580c673ebdae305421db8a2ccc22fd8683302d22c24db85f63d4c2f6638400
|
4
|
+
data.tar.gz: 52ea04d44b7f05c734a6011d4e66408135922e6fd0410cbc5d15a1b68c82140a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 389377989a3dd2db2188c05814a26526ee3fab5647863d7ab42df5dceef737c9f63c9ed71bee59339662338f16c7594bdeaea8ebd4cfd043de2d3a9297194b3e
|
7
|
+
data.tar.gz: 75345348dfef36343eb44150d1162725f58171cd9e6a24d6eb6f3bfd29ce4861d74910ffb140ed2f0fef106df839097a17e569610321cd939fce1be2a05da2ba
|
data/CHANGELOG.md
CHANGED
data/lib/vite_ruby/cli/build.rb
CHANGED
@@ -1,25 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class ViteRuby::CLI::Build <
|
4
|
-
CURRENT_ENV = ENV['RACK_ENV'] || ENV['RAILS_ENV']
|
3
|
+
class ViteRuby::CLI::Build < ViteRuby::CLI::Vite
|
5
4
|
DEFAULT_ENV = CURRENT_ENV || 'production'
|
6
5
|
|
7
|
-
def self.shared_options
|
8
|
-
option(:mode, default: self::DEFAULT_ENV, values: %w[development production test], aliases: ['m'], desc: 'The build mode for Vite')
|
9
|
-
option(:clobber, desc: 'Clear cache and previous builds', type: :boolean, aliases: %w[clean clear])
|
10
|
-
option(:debug, desc: 'Run Vite in verbose mode, printing all debugging output', aliases: ['verbose'], type: :boolean)
|
11
|
-
option(:inspect, desc: 'Run Vite in a debugging session with node --inspect-brk', aliases: ['inspect-brk'], type: :boolean)
|
12
|
-
option(:trace_deprecation, desc: 'Run Vite in debugging mode with node --trace-deprecation', aliases: ['trace-deprecation'], type: :boolean)
|
13
|
-
end
|
14
|
-
|
15
6
|
desc 'Bundle all entrypoints using Vite.'
|
16
7
|
shared_options
|
17
8
|
option(:force, desc: 'Force the build even if assets have not changed', type: :boolean)
|
18
9
|
|
19
|
-
def call(
|
20
|
-
ViteRuby.
|
21
|
-
ViteRuby.commands.clobber if clobber
|
22
|
-
boolean_opts.map { |name, value| args << "--#{ name }" if value }
|
23
|
-
block_given? ? yield(args) : ViteRuby.commands.build_from_task(*args)
|
10
|
+
def call(**options)
|
11
|
+
super { |args| ViteRuby.commands.build_from_task(*args) }
|
24
12
|
end
|
25
13
|
end
|
data/lib/vite_ruby/cli/dev.rb
CHANGED
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
# NOTE: Extracted from dry-cli version 0.6.0, which later removed this file as
|
7
|
+
# it was refactored and extracted into the more complete (and complex) dry-files.
|
8
|
+
module ViteRuby::CLI::FileUtils
|
9
|
+
class << self
|
10
|
+
# Creates a new file or rewrites the contents of an existing file.
|
11
|
+
#
|
12
|
+
# @since 1.2.11
|
13
|
+
# @api private
|
14
|
+
def write(path, *content)
|
15
|
+
mkdir_p(path)
|
16
|
+
File.open(path, File::CREAT | File::WRONLY | File::TRUNC) do |file|
|
17
|
+
file.write(Array(content).flatten.join)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Copies source into destination.
|
22
|
+
#
|
23
|
+
# @since 1.2.11
|
24
|
+
# @api private
|
25
|
+
def cp(source, destination)
|
26
|
+
mkdir_p(destination)
|
27
|
+
FileUtils.cp(source, destination)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Adds a new line at the bottom of the file.
|
31
|
+
#
|
32
|
+
# @since 1.2.11
|
33
|
+
# @api private
|
34
|
+
def append(path, contents)
|
35
|
+
mkdir_p(path)
|
36
|
+
|
37
|
+
content = File.readlines(path)
|
38
|
+
content << "\n" unless content.last.end_with?("\n")
|
39
|
+
content << "#{ contents }\n"
|
40
|
+
|
41
|
+
write(path, content)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Replace first line in `path` that contains `target` with `replacement`.
|
45
|
+
#
|
46
|
+
# @since 1.2.11
|
47
|
+
# @api private
|
48
|
+
def replace_first_line(path, target, replacement)
|
49
|
+
content = File.readlines(path)
|
50
|
+
content[index(content, path, target)] = "#{ replacement }\n"
|
51
|
+
|
52
|
+
write(path, content)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Inject `contents` in `path` before `target`.
|
56
|
+
#
|
57
|
+
# @since 1.2.11
|
58
|
+
# @api private
|
59
|
+
def inject_line_before(path, target, contents)
|
60
|
+
_inject_line_before(path, target, contents, method(:index))
|
61
|
+
end
|
62
|
+
|
63
|
+
# Inject `contents` in `path` after `target`.
|
64
|
+
#
|
65
|
+
# @since 1.2.11
|
66
|
+
# @api private
|
67
|
+
def inject_line_after(path, target, contents)
|
68
|
+
_inject_line_after(path, target, contents, method(:index))
|
69
|
+
end
|
70
|
+
|
71
|
+
# Inject `contents` in `path` after last `target`.
|
72
|
+
#
|
73
|
+
# @since 1.2.11
|
74
|
+
# @api private
|
75
|
+
def inject_line_after_last(path, target, contents)
|
76
|
+
_inject_line_after(path, target, contents, method(:rindex))
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
# Creates all parent directories for the given file path.
|
82
|
+
#
|
83
|
+
# @since 1.2.11
|
84
|
+
# @api private
|
85
|
+
def mkdir_p(path)
|
86
|
+
Pathname.new(path).dirname.mkpath
|
87
|
+
end
|
88
|
+
|
89
|
+
# @since 1.2.11
|
90
|
+
# @api private
|
91
|
+
def index(content, path, target)
|
92
|
+
content.index { |line| line.include?(target) } ||
|
93
|
+
raise(ArgumentError, "Cannot find `#{ target }' inside `#{ path }'.")
|
94
|
+
end
|
95
|
+
|
96
|
+
# @since 1.2.11
|
97
|
+
# @api private
|
98
|
+
def rindex(content, path, target)
|
99
|
+
content.rindex { |line| line.include?(target) } ||
|
100
|
+
raise(ArgumentError, "Cannot find `#{ target }' inside `#{ path }'.")
|
101
|
+
end
|
102
|
+
|
103
|
+
# @since 1.2.11
|
104
|
+
# @api private
|
105
|
+
def _inject_line_before(path, target, contents, finder)
|
106
|
+
content = File.readlines(path)
|
107
|
+
i = finder.call(content, path, target)
|
108
|
+
|
109
|
+
content.insert(i, "#{ contents }\n")
|
110
|
+
write(path, content)
|
111
|
+
end
|
112
|
+
|
113
|
+
# @since 1.2.11
|
114
|
+
# @api private
|
115
|
+
def _inject_line_after(path, target, contents, finder)
|
116
|
+
content = File.readlines(path)
|
117
|
+
i = finder.call(content, path, target)
|
118
|
+
|
119
|
+
content.insert(i + 1, "#{ contents }\n")
|
120
|
+
write(path, content)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'dry/cli/utils/files'
|
4
3
|
require 'stringio'
|
5
4
|
|
6
5
|
class ViteRuby::CLI::Install < Dry::CLI::Command
|
@@ -49,9 +48,9 @@ private
|
|
49
48
|
|
50
49
|
def_delegators 'ViteRuby', :config
|
51
50
|
|
52
|
-
%i[append cp inject_line_after inject_line_after_last inject_line_before write].each do |util|
|
51
|
+
%i[append cp inject_line_after inject_line_after_last inject_line_before replace_first_line write].each do |util|
|
53
52
|
define_method(util) { |*args|
|
54
|
-
|
53
|
+
ViteRuby::CLI::FileUtils.send(util, *args) rescue nil
|
55
54
|
}
|
56
55
|
end
|
57
56
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ViteRuby::CLI::Vite < Dry::CLI::Command
|
4
|
+
CURRENT_ENV = ENV['RACK_ENV'] || ENV['RAILS_ENV']
|
5
|
+
|
6
|
+
def self.shared_options
|
7
|
+
option(:mode, default: self::DEFAULT_ENV, values: %w[development production test], aliases: ['m'], desc: 'The build mode for Vite')
|
8
|
+
option(:clobber, desc: 'Clear cache and previous builds', type: :boolean, aliases: %w[clean clear])
|
9
|
+
option(:debug, desc: 'Run Vite in verbose mode, printing all debugging output', aliases: ['verbose'], type: :boolean)
|
10
|
+
option(:inspect, desc: 'Run Vite in a debugging session with node --inspect-brk', aliases: ['inspect-brk'], type: :boolean)
|
11
|
+
option(:trace_deprecation, desc: 'Run Vite in debugging mode with node --trace-deprecation', aliases: ['trace-deprecation'], type: :boolean)
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(mode:, args: [], clobber: false, **boolean_opts)
|
15
|
+
ViteRuby.env['VITE_RUBY_MODE'] = mode
|
16
|
+
ViteRuby.commands.clobber if clobber
|
17
|
+
boolean_opts.map { |name, value| args << "--#{ name }" if value }
|
18
|
+
yield(args)
|
19
|
+
end
|
20
|
+
end
|
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: 1.2.
|
4
|
+
version: 1.2.11
|
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: 2021-05-
|
11
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.7.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack-proxy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,8 +219,10 @@ files:
|
|
219
219
|
- lib/vite_ruby/cli/build.rb
|
220
220
|
- lib/vite_ruby/cli/clobber.rb
|
221
221
|
- lib/vite_ruby/cli/dev.rb
|
222
|
+
- lib/vite_ruby/cli/file_utils.rb
|
222
223
|
- lib/vite_ruby/cli/install.rb
|
223
224
|
- lib/vite_ruby/cli/version.rb
|
225
|
+
- lib/vite_ruby/cli/vite.rb
|
224
226
|
- lib/vite_ruby/commands.rb
|
225
227
|
- lib/vite_ruby/config.rb
|
226
228
|
- lib/vite_ruby/dev_server_proxy.rb
|
@@ -238,8 +240,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
238
240
|
licenses:
|
239
241
|
- MIT
|
240
242
|
metadata:
|
241
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.
|
242
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.
|
243
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.11/vite_ruby
|
244
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.11/vite_ruby/CHANGELOG.md
|
243
245
|
post_install_message:
|
244
246
|
rdoc_options: []
|
245
247
|
require_paths:
|