instrumental-components 0.1.2 → 0.1.31

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: e9d7b4164eab29cdccb4586188c0480cba5f4834d65089e35f08f59c1b064500
4
- data.tar.gz: 67e0a39edfd96ce115499b540f68b3b131edff234a74437cc306c0e3a84df3a5
3
+ metadata.gz: fe12474095d5a24ed6024f13ad07fc09a1c06ff1975cc593ca1143c957b78203
4
+ data.tar.gz: be82faed7a3f4873cf1050d68b154614f3154b4b2a611a261a0385d92814694d
5
5
  SHA512:
6
- metadata.gz: 9609e5ab398a77557e965e6183ddba2710d9fc6eb888733de87738a0d56bcc0ad72bf02f13ca86aa935b8e79b4867f8a2533881200e25bfbea4b97f981a7b6cf
7
- data.tar.gz: 26fe58b9a0e028ff4804a724d7706b1350466040b67d563da8b5ce83b921dc5a01d210d2b87996b8a7408b19d81c94a0c9eceead730a98a8afc8881c8dcd350b
6
+ metadata.gz: 83d8efe650aee61417a7655a759c4010270c6caf1dff170a7db7cb29ae3c72171ae455a3fa1ace78c0a7ede0018fb205c5a894211e83ed5653388813c70099dc
7
+ data.tar.gz: 69d5beb80cf48f029ede27496e16fedb7cc96eec8a026444c4dd339bb190d1073adf382a4f6890a1ebedeb1f6cc46bc48e950e5ffc6de895d3d9b8cdad3a03f0
@@ -2,10 +2,11 @@
2
2
 
3
3
  require 'instrumental-components'
4
4
  require 'optparse'
5
+ require 'yaml'
5
6
 
6
7
  options = {}
7
8
  OptionParser.new do |opts|
8
- opts.banner = "Usage: install-instrumental --license_key=LICENSE_KEY --email=EMAIL"
9
+ opts.banner = "Usage: install-instrumental [--license_key=LICENSE_KEY] [--email=EMAIL]"
9
10
 
10
11
  opts.on("--license_key=LICENSE_KEY", "License key for Instrumental Components") do |key|
11
12
  options[:license_key] = key
@@ -16,9 +17,38 @@ OptionParser.new do |opts|
16
17
  end
17
18
  end.parse!
18
19
 
20
+ # Check for license.yml file if flags are not provided
19
21
  unless options[:license_key] && options[:email]
20
- puts "Error: Both --license_key and --email are required"
21
- exit 1
22
+ license_yml_path = '.instrumental/license.yml'
23
+ if File.exist?(license_yml_path)
24
+ begin
25
+ license_data = YAML.load_file(license_yml_path)
26
+ options[:license_key] ||= license_data['license_key']
27
+ options[:email] ||= license_data['email']
28
+ rescue => e
29
+ puts "Error reading license.yml: #{e.message}"
30
+ end
31
+ end
32
+ end
33
+
34
+ # Prompt for any missing information
35
+ unless options[:license_key] && options[:email]
36
+
37
+ unless options[:license_key]
38
+ print "Enter your Instrumental Components license key (find this in your account at https://instrumental.dev): "
39
+ options[:license_key] = gets.chomp.strip
40
+ end
41
+
42
+ unless options[:email]
43
+ print "Enter your the email address you used for your account on https://instrumental.dev: "
44
+ options[:email] = gets.chomp.strip
45
+ end
46
+
47
+ # Validate that we got non-empty values
48
+ if options[:license_key].empty? || options[:email].empty?
49
+ puts "\nError: Both license key and email are required."
50
+ exit 1
51
+ end
22
52
  end
23
53
 
24
54
  installer = InstrumentalComponents::Installer.new(options[:license_key], options[:email])
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'instrumental-components'
4
+ require 'optparse'
5
+ require 'yaml'
6
+ require 'json'
7
+ require 'open-uri'
8
+
9
+ options = {}
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: latest-instrumental-version"
12
+ end.parse!
13
+
14
+ version_checker = InstrumentalComponents::VersionChecker.new
15
+ version_checker.check
@@ -0,0 +1,49 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+ require 'dotenv'
4
+
5
+ module InstrumentalComponents
6
+ class VersionChecker
7
+ def check
8
+ # Load .env file if it exists (for local development only)
9
+ if File.exist?('.env')
10
+ Dotenv.load
11
+ end
12
+
13
+ latest_version = fetch_latest_version
14
+ current_version = get_current_version
15
+
16
+ if current_version == latest_version
17
+ puts "You're on the latest version!"
18
+ else
19
+ puts "You're running version #{current_version}. To update to the latest version (#{latest_version}), run:\nbundle exec install-instrumental"
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def fetch_latest_version
26
+ domain = ENV['INSTRUMENTAL_DOMAIN'] || 'https://instrumental.dev'
27
+ unless 'https://instrumental.dev' == domain
28
+ puts "Using domain: #{domain}" # Confirm that we're in local development mode
29
+ end
30
+ response = URI.open("#{domain}/gem_downloads/get_current_version")
31
+ data = JSON.parse(response.read)
32
+ data['version']
33
+ rescue => e
34
+ puts "Error fetching latest version: #{e.message}"
35
+ exit 1
36
+ end
37
+
38
+ def get_current_version
39
+ return nil unless File.exist?('Gemfile.lock')
40
+
41
+ content = File.read('Gemfile.lock')
42
+ if match = content.match(/instrumental-components-library\s*\(([^)]+)\)/)
43
+ match[1]
44
+ else
45
+ nil
46
+ end
47
+ end
48
+ end
49
+ end
@@ -2,6 +2,7 @@ require 'open-uri'
2
2
  require 'fileutils'
3
3
  require 'json'
4
4
  require 'dotenv'
5
+ require 'instrumental-components/version_checker'
5
6
 
6
7
  module InstrumentalComponents
7
8
  class Installer
@@ -11,7 +12,11 @@ module InstrumentalComponents
11
12
  end
12
13
 
13
14
  def install
14
- puts "📥 Downloading the latest version of Instrumental Components..."
15
+ if updating?
16
+ puts "📥 Updating to the latest version of Instrumental Components..."
17
+ else
18
+ puts "📥 Downloading the latest version of Instrumental Components..."
19
+ end
15
20
 
16
21
  begin
17
22
  # Load .env file if it exists (for local development only)
@@ -32,9 +37,15 @@ module InstrumentalComponents
32
37
  puts "Running 'bundle install'..."
33
38
  run_bundle_install
34
39
 
35
- puts ""
36
- puts "🚀 Running the Instrumental Components installer..."
37
- run_installer
40
+ if updating?
41
+ puts ""
42
+ puts "🔄 Updating Instrumental Components..."
43
+ system("bundle update instrumental-components-library")
44
+ else
45
+ puts ""
46
+ puts "🚀 Running the Instrumental Components installer..."
47
+ run_installer
48
+ end
38
49
 
39
50
  puts ""
40
51
  rescue => e
@@ -46,6 +57,23 @@ module InstrumentalComponents
46
57
 
47
58
  private
48
59
 
60
+ def updating?
61
+ # Only consider it updating if the gem is in the current project's Gemfile
62
+ # and Gemfile.lock, not just installed system-wide
63
+ gemfile_has_gem? && gemfile_lock_has_gem? && File.exist?('Gemfile.lock')
64
+ end
65
+
66
+ def gemfile_has_gem?
67
+ return false unless File.exist?('Gemfile')
68
+ # Use a more precise regex to match the gem declaration
69
+ File.read('Gemfile').match?(/^\s*gem\s+['"]instrumental-components-library['"]/)
70
+ end
71
+
72
+ def gemfile_lock_has_gem?
73
+ return false unless File.exist?('Gemfile.lock')
74
+ File.read('Gemfile.lock').include?('instrumental-components-library (')
75
+ end
76
+
49
77
  def download_gem
50
78
  # For local development, set INSTRUMENTAL_DOMAIN=http://localhost:3000 in .env
51
79
  # This allows testing against a local server while developing the gem
@@ -102,11 +130,16 @@ module InstrumentalComponents
102
130
 
103
131
  gemfile_content = File.read(gemfile_path)
104
132
 
105
- unless gemfile_content.include?("gem 'instrumental-components-library'")
133
+ # Check if the gem is already in any development group
134
+ unless gemfile_content.match?(/^\s*gem\s+['"]instrumental-components-library['"]/)
106
135
  if gemfile_content.include?("group :development")
107
- # Add to existing development group
108
- gemfile_content.gsub!(/group :development\s+do/) do |match|
109
- "#{match}\n gem 'instrumental-components-library'"
136
+ # Find the last development group and add the gem there
137
+ gemfile_content.gsub!(/(group :development\s+do.*?)(?=group|$)/m) do |match|
138
+ if match.end_with?("end")
139
+ match.sub(/end\s*$/, " gem 'instrumental-components-library'\nend")
140
+ else
141
+ match + " gem 'instrumental-components-library'\n"
142
+ end
110
143
  end
111
144
  else
112
145
  # Create new development group
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instrumental-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Casel
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-13 00:00:00.000000000 Z
10
+ date: 2025-05-20 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: open-uri
@@ -42,11 +42,14 @@ email:
42
42
  - support@instrumental.dev
43
43
  executables:
44
44
  - install-instrumental
45
+ - latest-instrumental-version
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
48
49
  - bin/install-instrumental
50
+ - bin/latest-instrumental-version
49
51
  - lib/instrumental-components.rb
52
+ - lib/instrumental-components/version_checker.rb
50
53
  homepage: https://instrumental.dev
51
54
  licenses:
52
55
  - Nonstandard