roda-vite 0.2.0 → 0.4.0

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: 51e00d93e8bc7e9056589ba297027ad2cafb51553bd7bcb2d2e558626f545b8c
4
- data.tar.gz: 3de2c888fe6852b6ef5d75d6f07b87bff83903469472cbd97ab5f3d49af86462
3
+ metadata.gz: 6864daee0925a1e81ab534655fa8d1ed70d539be7cbd8e528672960a32c1f099
4
+ data.tar.gz: ed4f38b88404153306f3286f912374bcd776c46d88f7ba157ff9539b3c95094a
5
5
  SHA512:
6
- metadata.gz: 747763c56aa86fb1b6c29695aba74c7b0cffbb19143e0116415be6bc30797de4d1dd64bf28b041e971d4eba71270bee136c4c139f54f2a9a0e09d15675c95bfb
7
- data.tar.gz: f7d6d5afa2c0d3ed22aafe70ad516f8536209bdbcbf37cdef378f62febc7bc89be8eb1bcf90af8b00fe06666dbb4c03985437e8708778a0ca08ba88aed79ca1e
6
+ metadata.gz: 2f28f886399c794f6780895f781b34ea93702e932b893d8686a63789b61394c4fbffd38af5055551429be51e947c1d951dfd45dfa1939bd648468767e2110be9
7
+ data.tar.gz: 5e31e65cd17862fc47a309e54c50989095ca35fb83116a2a6e4c9d665fc89cc5bd6ccd8feca7b88d87f5975e4e4027063f843c891d77c5acf8d1131a23dbeb40
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RodaVite
2
- VERSION = "0.2.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -21,9 +21,14 @@ module ViteRoda::Installation
21
21
  # super
22
22
  # end
23
23
 
24
- def call(package_manager: nil, **)
24
+ # Add additional options
25
+ def self.prepended(base)
26
+ base.option :force, type: :flag, aliases: ['-f'], desc: "Force installation, skip checking that 'plugin :vite' was added."
27
+ end
28
+
29
+ def call(package_manager: nil, **options)
25
30
 
26
- ensure_roda_plugin_added
31
+ ensure_roda_plugin_added unless options[:force]
27
32
 
28
33
  ENV["VITE_RUBY_PACKAGE_MANAGER"] ||= package_manager if package_manager
29
34
 
@@ -64,13 +69,26 @@ module ViteRoda::Installation
64
69
  POST_INSTALL_MESSAGE
65
70
  end
66
71
 
67
- # Internal: Ensures the Vite plugin is loaded in app.rb
72
+ # Internal: Ensures the Vite plugin is loaded in app.rb, or [app_name].rb
73
+ # This check is skipped if the -f or --force flag is passed
68
74
  def ensure_roda_plugin_added
69
- unless line_with_prefix_exists? root.join("app.rb"), "plugin :vite"
70
- abort "Add plugin :vite to your app.rb before installing"
75
+ unless line_with_prefix_exists?(root.join('app.rb'), 'plugin :vite') ||
76
+ line_with_prefix_exists?(root.join("#{app_name}.rb"), 'plugin :vite')
77
+ abort "Add plugin :vite to your Roda app (found in app.rb or #{app_name}.rb) before installing, or pass -f to force."
71
78
  end
72
79
  end
73
80
 
81
+ # Internal: Get probable app_name for checking if plugin :vite has been loaded.
82
+ # If this is wrong, the install subcommand can always be forced with -f.
83
+ def app_name
84
+
85
+ # Return the name of current working directory, for now. More complex logic may be added
86
+ # here, including returning a list of probable app_names for use with #any? like:
87
+ # unless files.any? { |file| line_with_prefix_exists?(file, 'plugin :vite') }
88
+
89
+ File.basename(Dir.pwd)
90
+ end
91
+
74
92
  # Using String#lstrip and String#start_with? is supposedly faster than using Regex as:
75
93
  # File.readlines(file).any? { |line| line.match?(/^\s*plugin :vite/) } if File.exist?(file)
76
94
  def line_with_prefix_exists?(file, string)
@@ -146,6 +164,6 @@ module ViteRoda::Installation
146
164
 
147
165
  end
148
166
 
149
- puts "VITE RODA CLI"
167
+ puts "VITE RODA CLI" if ARGV.include?('--debug')
150
168
 
151
169
  ViteRuby::CLI::Install.prepend(ViteRoda::Installation)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-vite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avi Sternlieb