roda-vite 0.2.0 → 0.3.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: baacd4f5b199ed697cc5ac19f952b61c2c3852048a44e41d3f644299dbdbd509
4
+ data.tar.gz: 281aeea9ef2e4ecc85cf8c0bf36156e53cb9ac5f51ed6ac4396ed054c9b719c8
5
5
  SHA512:
6
- metadata.gz: 747763c56aa86fb1b6c29695aba74c7b0cffbb19143e0116415be6bc30797de4d1dd64bf28b041e971d4eba71270bee136c4c139f54f2a9a0e09d15675c95bfb
7
- data.tar.gz: f7d6d5afa2c0d3ed22aafe70ad516f8536209bdbcbf37cdef378f62febc7bc89be8eb1bcf90af8b00fe06666dbb4c03985437e8708778a0ca08ba88aed79ca1e
6
+ metadata.gz: 7e8e77a7503276004f2390c290b3d19fd09e06d2d6ad8ad4aa937b32bb7bc0547a32537ab261bb102e313fcb540d1bf96cf39ac71964b9e631cd3be512f5981e
7
+ data.tar.gz: b06a90e6a2125f7fbe058265de17de952e9a2514d498ae8979e7fef0df2989c0c647e7d328d296a94668c0d2f1bd1e5731ff9b206665a5bf51de294f7ed51b5e
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RodaVite
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -64,13 +64,28 @@ module ViteRoda::Installation
64
64
  POST_INSTALL_MESSAGE
65
65
  end
66
66
 
67
- # Internal: Ensures the Vite plugin is loaded in app.rb
67
+ # Internal: Ensures the Vite plugin is loaded in app.rb, or [app_name].rb
68
+ # This check is skipped if the -f or --force flag is passed
68
69
  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"
70
+ return if ARGV.any? { |flag| ['-f', '--force'].include? flag }
71
+
72
+ unless line_with_prefix_exists? root.join('app.rb'), 'plugin :vite' ||
73
+ line_with_prefix_exists? root.join("#{app_name}.rb"), 'plugin :vite'
74
+ abort "Add plugin :vite to your Roda app (found in app.rb or #{app_name}.rb) before installing, or pass -f to force."
71
75
  end
72
76
  end
73
77
 
78
+ # Internal: Get probable app_name for checking if plugin :vite has been loaded.
79
+ # If this is wrong, the install subcommand can always be forced with -f.
80
+ def app_name
81
+
82
+ # Return the name of current working directory, for now. More complex logic may be added
83
+ # here, including returning a list of probable app_names for use with #any? like:
84
+ # unless files.any? { |file| line_with_prefix_exists?(file, 'plugin :vite') }
85
+
86
+ File.basename(Dir.pwd)
87
+ end
88
+
74
89
  # Using String#lstrip and String#start_with? is supposedly faster than using Regex as:
75
90
  # File.readlines(file).any? { |line| line.match?(/^\s*plugin :vite/) } if File.exist?(file)
76
91
  def line_with_prefix_exists?(file, string)
@@ -146,6 +161,6 @@ module ViteRoda::Installation
146
161
 
147
162
  end
148
163
 
149
- puts "VITE RODA CLI"
164
+ puts "VITE RODA CLI" if ARGV.include?('--debug')
150
165
 
151
166
  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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avi Sternlieb