roda-vite 0.1.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: 33001869926d3f0cf306e9152f9adde9f77cf445289905d6df44c5efd6f08217
4
- data.tar.gz: 1fec4bd57cad226150384a8c3ccc76d5c54b6ad598023336f8acce6b1c647e47
3
+ metadata.gz: baacd4f5b199ed697cc5ac19f952b61c2c3852048a44e41d3f644299dbdbd509
4
+ data.tar.gz: 281aeea9ef2e4ecc85cf8c0bf36156e53cb9ac5f51ed6ac4396ed054c9b719c8
5
5
  SHA512:
6
- metadata.gz: 2e9e0047c810b8449fe3edb764ea320698f45b17307e30d1eaac22445df319aedf9ca3a6ac24579ad24d1fd36785ad613be80ae738dc5b268c999c3416b511f8
7
- data.tar.gz: e3ad7673a231b2ea14401ddf9507bba08d09c7c38c6082c60742b60f4eb183f73710cf363cc215e509f994eb4633cfa2c4a4825b4e922950d74beb18de7952ad
6
+ metadata.gz: 7e8e77a7503276004f2390c290b3d19fd09e06d2d6ad8ad4aa937b32bb7bc0547a32537ab261bb102e313fcb540d1bf96cf39ac71964b9e631cd3be512f5981e
7
+ data.tar.gz: b06a90e6a2125f7fbe058265de17de952e9a2514d498ae8979e7fef0df2989c0c647e7d328d296a94668c0d2f1bd1e5731ff9b206665a5bf51de294f7ed51b5e
data/lib/roda-vite.rb CHANGED
@@ -6,9 +6,9 @@ rescue Gem::LoadError
6
6
  end
7
7
 
8
8
  begin
9
- require 'vite_ruby/roda'
9
+ require 'vite_ruby-roda'
10
10
  rescue LoadError => e
11
- raise unless e.path == 'vite_ruby/roda'
11
+ raise unless e.path == 'vite_ruby-roda'
12
12
  if gem_installed?('vite_ruby')
13
13
  raise "Missing dependency: vite_ruby-roda is required by roda-vite. Please add it to your Gemfile.\n" +
14
14
  'Found vite_ruby, however roda-vite requires vite_ruby-roda. If vite_ruby is in your Gemfile, you may replace it.'
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RodaVite
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -49,7 +49,7 @@ module ViteRoda::Installation
49
49
 
50
50
  # say "\nVite ⚡️ Ruby successfully installed! 🎉"
51
51
 
52
- MESSAGE = <<~DOC
52
+ puts <<~POST_INSTALL_MESSAGE
53
53
  \e[2mIf you have your css in \e[36massets/css/app.css\e[0;2m, you'll want to add the following to your html:
54
54
 
55
55
  \e[2m <head>\e[m
@@ -61,16 +61,31 @@ module ViteRoda::Installation
61
61
  To install \e[36mnode_modules/\e[0;2m, run:
62
62
 
63
63
  \e[0;1;36m #{js_command}\e[m
64
- DOC
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.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avi Sternlieb