vite_ruby 1.2.11 → 1.2.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4580c673ebdae305421db8a2ccc22fd8683302d22c24db85f63d4c2f6638400
4
- data.tar.gz: 52ea04d44b7f05c734a6011d4e66408135922e6fd0410cbc5d15a1b68c82140a
3
+ metadata.gz: 7965194ea235189606dac388c19d8b624f54622a666644f93a6ec3ac3bf4dc48
4
+ data.tar.gz: f9996a594e4c34d0283e498411e71d37d83b7cd793fc8f76a426f84588f5a7f4
5
5
  SHA512:
6
- metadata.gz: 389377989a3dd2db2188c05814a26526ee3fab5647863d7ab42df5dceef737c9f63c9ed71bee59339662338f16c7594bdeaea8ebd4cfd043de2d3a9297194b3e
7
- data.tar.gz: 75345348dfef36343eb44150d1162725f58171cd9e6a24d6eb6f3bfd29ce4861d74910ffb140ed2f0fef106df839097a17e569610321cd939fce1be2a05da2ba
6
+ metadata.gz: bfa35cd809b3034cba60919967a5af1a720ea7c8497e6722d8ebf25a23847c274ebe4da216b79c0f8cadf712c16a20b070514d4bf1b23bb813457e492ddf7cbb
7
+ data.tar.gz: 5f35583a17581e6b0fc2f27b068df7420956b6069d5a85447caaa6f3f056ee41d80f8ad6f813836caf8b0a897581c5dee430f0327c634b51d16975c61f010079
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
+ ## <small>1.2.16 (2021-07-07)</small>
2
+
3
+ * feat: Enable usage in engines by using `run` from the current instance ([023a61d](https://github.com/ElMassimo/vite_ruby/commit/023a61d))
4
+
5
+
6
+
7
+ ## [1.2.15](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.14...vite_ruby@1.2.15) (2021-07-01)
8
+
9
+
10
+
11
+ ## [1.2.14](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.13...vite_ruby@1.2.14) (2021-07-01)
12
+
13
+
14
+ ### Features
15
+
16
+ * Add support for Jekyll installer ([7b942ec](https://github.com/ElMassimo/vite_ruby/commit/7b942ec745eb28092d684056b02df675ad6ececa))
17
+
18
+
19
+
20
+ ## [1.2.13](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.12...vite_ruby@1.2.13) (2021-06-30)
21
+
22
+
23
+ ### Features
24
+
25
+ * Improve the error message when npm packages are missing ([9159557](https://github.com/ElMassimo/vite_ruby/commit/9159557e5152547554cfe519fae8dbefe26686fb))
26
+
27
+
28
+
29
+ ## [1.2.12](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.11...vite_ruby@1.2.12) (2021-06-08)
30
+
31
+
32
+ ### Features
33
+
34
+ * Support Ruby 2.4 ([#87](https://github.com/ElMassimo/vite_ruby/issues/87)) ([8fc4d49](https://github.com/ElMassimo/vite_ruby/commit/8fc4d49c82817623df81d6f9f94654ea726eb050))
35
+
36
+
37
+
1
38
  ## [1.2.11](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.10...vite_ruby@1.2.11) (2021-05-10)
2
39
 
40
+ ### Refactor
41
+
42
+ * Upgrade to dry-cli 0.7 while avoiding dependency on `dry-files` ([f5b87e](https://github.com/ElMassimo/vite_ruby/commit/f5b87e69790e48397d15e609b44118e399c9493d))
3
43
 
4
44
 
5
45
  ## [1.2.10](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.9...vite_ruby@1.2.10) (2021-05-09)
data/lib/vite_ruby.rb CHANGED
@@ -18,28 +18,28 @@ class ViteRuby
18
18
  ENV_PREFIX = 'VITE_RUBY'
19
19
 
20
20
  # Internal: Versions used by default when running `vite install`.
21
- DEFAULT_VITE_VERSION = '^2.2.3'
22
- DEFAULT_PLUGIN_VERSION = '^2.0.2'
23
-
24
- # Internal: Ruby Frameworks that have a companion library for Vite Ruby.
25
- SUPPORTED_FRAMEWORKS = %w[rails hanami roda padrino sinatra].freeze
21
+ DEFAULT_VITE_VERSION = '^2.3.8'
22
+ DEFAULT_PLUGIN_VERSION = '^2.0.4'
23
+
24
+ # Internal: Companion libraries for Vite Ruby, and their target framework.
25
+ COMPANION_LIBRARIES = {
26
+ 'vite_rails' => 'rails',
27
+ 'vite_hanami' => 'hanami',
28
+ 'vite_roda' => 'roda',
29
+ 'vite_padrino' => 'padrino',
30
+ 'vite_sinatra' => 'sinatra',
31
+ 'jekyll-vite' => 'jekyll',
32
+ 'vite_rails_legacy' => 'rails',
33
+ }
26
34
 
27
35
  class << self
28
36
  extend Forwardable
29
37
 
30
- def_delegators :instance, :config, :commands, :run_proxy?
38
+ def_delegators :instance, :config, :commands, :env, :run, :run_proxy?
31
39
  def_delegators :config, :mode
32
40
 
33
41
  def instance
34
- @instance ||= ViteRuby.new
35
- end
36
-
37
- # Public: Additional environment variables to pass to Vite.
38
- #
39
- # Example:
40
- # ViteRuby.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
41
- def env
42
- @env ||= load_env_variables
42
+ @instance ||= new
43
43
  end
44
44
 
45
45
  # Internal: Refreshes the manifest.
@@ -52,28 +52,16 @@ class ViteRuby
52
52
  load File.expand_path('tasks/vite.rake', __dir__)
53
53
  end
54
54
 
55
- # Internal: Executes the vite binary.
56
- def run(argv, **options)
57
- ViteRuby::Runner.new(instance).run(argv, **options)
58
- end
59
-
60
- # Internal: Refreshes the config after setting the env vars.
61
- def reload_with(env_vars)
62
- env.update(env_vars)
63
- @instance = nil
64
- config
65
- end
66
-
67
- # Internal: Allows to obtain any env variables for configuration options.
68
- def load_env_variables
69
- ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
55
+ # Internal: Creates a new instance with the specified options.
56
+ def reload_with(**config_options)
57
+ @instance = new(**config_options)
70
58
  end
71
59
 
72
60
  # Internal: Detects if the application has installed a framework-specific
73
61
  # variant of Vite Ruby.
74
62
  def framework_libraries
75
- SUPPORTED_FRAMEWORKS.map { |framework|
76
- if library = Gem.loaded_specs["vite_#{ framework }"]
63
+ COMPANION_LIBRARIES.map { |name, framework|
64
+ if library = Gem.loaded_specs[name]
77
65
  [framework, library]
78
66
  end
79
67
  }.compact
@@ -82,6 +70,10 @@ class ViteRuby
82
70
 
83
71
  attr_writer :logger
84
72
 
73
+ def initialize(**config_options)
74
+ @config_options = config_options
75
+ end
76
+
85
77
  def logger
86
78
  @logger ||= Logger.new($stdout)
87
79
  end
@@ -99,6 +91,14 @@ class ViteRuby
99
91
  @running_at = false
100
92
  end
101
93
 
94
+ # Public: Additional environment variables to pass to Vite.
95
+ #
96
+ # Example:
97
+ # ViteRuby.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
98
+ def env
99
+ @env ||= ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
100
+ end
101
+
102
102
  # Public: The proxy for assets should only run in development mode.
103
103
  def run_proxy?
104
104
  config.mode == 'development'
@@ -107,6 +107,11 @@ class ViteRuby
107
107
  false
108
108
  end
109
109
 
110
+ # Internal: Executes the vite binary.
111
+ def run(argv, **options)
112
+ (@runner ||= ViteRuby::Runner.new(self)).run(argv, **options)
113
+ end
114
+
110
115
  # Public: Keeps track of watched files and triggers builds as needed.
111
116
  def builder
112
117
  @builder ||= ViteRuby::Builder.new(self)
@@ -119,7 +124,7 @@ class ViteRuby
119
124
 
120
125
  # Public: Current instance configuration for Vite.
121
126
  def config
122
- @config ||= ViteRuby::Config.resolve_config
127
+ @config ||= ViteRuby::Config.resolve_config(**@config_options)
123
128
  end
124
129
 
125
130
  # Public: Enables looking up assets managed by Vite using name and type.
@@ -33,7 +33,7 @@ private
33
33
 
34
34
  extend Forwardable
35
35
 
36
- def_delegators :@vite_ruby, :config, :logger
36
+ def_delegators :@vite_ruby, :config, :logger, :run
37
37
 
38
38
  # Internal: Reads metadata recorded on the last build, if it exists.
39
39
  def last_build_attrs
@@ -69,7 +69,7 @@ private
69
69
  def build_with_vite(*args)
70
70
  logger.info 'Building with Vite ⚡️'
71
71
 
72
- stdout, stderr, status = ViteRuby.run(['build', *args])
72
+ stdout, stderr, status = run(['build', *args])
73
73
  log_build_result(stdout, stderr.to_s, status)
74
74
 
75
75
  status.success?
@@ -28,6 +28,14 @@ class ViteRuby::CLI::Install < Dry::CLI::Command
28
28
 
29
29
  protected
30
30
 
31
+ # Internal: The JS packages that should be added to the app.
32
+ def js_dependencies
33
+ [
34
+ "vite@#{ ViteRuby::DEFAULT_VITE_VERSION }",
35
+ "vite-plugin-ruby@#{ ViteRuby::DEFAULT_PLUGIN_VERSION }",
36
+ ]
37
+ end
38
+
31
39
  # Internal: Setup for a plain Rack application.
32
40
  def setup_app_files
33
41
  copy_template 'config/vite.json', to: config.config_path
@@ -64,7 +72,7 @@ private
64
72
  def create_configuration_files
65
73
  copy_template 'config/vite.config.ts', to: root.join('vite.config.ts')
66
74
  setup_app_files
67
- ViteRuby.reload_with('VITE_RUBY_CONFIG_PATH' => config.config_path)
75
+ ViteRuby.reload_with(config_path: config.config_path)
68
76
  end
69
77
 
70
78
  # Internal: Installs vite and vite-plugin-ruby at the project level.
@@ -73,7 +81,7 @@ private
73
81
  write(package_json, '{}') unless package_json.exist?
74
82
 
75
83
  Dir.chdir(root) do
76
- deps = "vite@#{ ViteRuby::DEFAULT_VITE_VERSION } vite-plugin-ruby@#{ ViteRuby::DEFAULT_PLUGIN_VERSION }"
84
+ deps = js_dependencies.join(' ')
77
85
  _, stderr, status = ViteRuby::IO.capture("npx --package @antfu/ni -- ni -D #{ deps }", stdin_data: "\n")
78
86
  _, stderr, = ViteRuby::IO.capture("yarn add -D #{ deps }") unless status.success?
79
87
  say("Could not install JS dependencies.\n", stderr) unless stderr.to_s.empty?
@@ -117,5 +125,5 @@ end
117
125
 
118
126
  # NOTE: This allows framework-specific variants to extend the installation.
119
127
  ViteRuby.framework_libraries.each do |_framework, library|
120
- require "#{ library.name }/installation"
128
+ require "#{ library.name.tr('-', '/') }/installation"
121
129
  end
@@ -4,7 +4,7 @@
4
4
  class ViteRuby::MissingExecutableError < ViteRuby::Error
5
5
  def initialize(error = nil)
6
6
  super <<~MSG
7
- ❌ The vite binary is not available. Have you installed Vite?
7
+ ❌ The vite binary is not available. Have you installed the npm packages?
8
8
 
9
9
  :troubleshooting:
10
10
  #{ error }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '1.2.11'
4
+ VERSION = '1.2.16'
5
5
  end
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.11
4
+ version: 1.2.16
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-10 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -142,48 +142,6 @@ dependencies:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
144
  version: '13.0'
145
- - !ruby/object:Gem::Dependency
146
- name: rubocop
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '1.9'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '1.9'
159
- - !ruby/object:Gem::Dependency
160
- name: rubocop-minitest
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - "~>"
164
- - !ruby/object:Gem::Version
165
- version: '0.10'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: '0.10'
173
- - !ruby/object:Gem::Dependency
174
- name: rubocop-performance
175
- requirement: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - "~>"
178
- - !ruby/object:Gem::Version
179
- version: '1.9'
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: '1.9'
187
145
  - !ruby/object:Gem::Dependency
188
146
  name: simplecov
189
147
  requirement: !ruby/object:Gem::Requirement
@@ -240,8 +198,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
240
198
  licenses:
241
199
  - MIT
242
200
  metadata:
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
201
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.16/vite_ruby
202
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.16/vite_ruby/CHANGELOG.md
245
203
  post_install_message:
246
204
  rdoc_options: []
247
205
  require_paths:
@@ -250,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
208
  requirements:
251
209
  - - ">="
252
210
  - !ruby/object:Gem::Version
253
- version: '2.5'
211
+ version: '2.4'
254
212
  required_rubygems_version: !ruby/object:Gem::Requirement
255
213
  requirements:
256
214
  - - ">="