instrumental-components 0.1.2 → 0.1.3

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: b092b9fca8b7f731aa1f239b408f7a02d6d48397a9d321f2078c684ba7957958
4
+ data.tar.gz: ede170f09e2d0adf91b7cd677f1f5c8392b4871f18026f53945b517c1f27aa85
5
5
  SHA512:
6
- metadata.gz: 9609e5ab398a77557e965e6183ddba2710d9fc6eb888733de87738a0d56bcc0ad72bf02f13ca86aa935b8e79b4867f8a2533881200e25bfbea4b97f981a7b6cf
7
- data.tar.gz: 26fe58b9a0e028ff4804a724d7706b1350466040b67d563da8b5ce83b921dc5a01d210d2b87996b8a7408b19d81c94a0c9eceead730a98a8afc8881c8dcd350b
6
+ metadata.gz: e8aefe9b530f390dff6a48074d049cc354dfee1540d6ac8dea0d646d72da1b1d4483efe5523e91ee56d70c9e9005b1f3de5e3a6d19f7776d6fcb0ef234f0a029
7
+ data.tar.gz: 25080945bc2f8afe3758231fe21243c2dc794381979eb56b160e68cbd92f8f847d79383ad4ca17c4e91eabf5e48aadc6aef48d4c5cc277ed27a1e534c2471c1c
@@ -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,20 @@ module InstrumentalComponents
46
57
 
47
58
  private
48
59
 
60
+ def updating?
61
+ gemfile_has_gem? && gemfile_lock_has_gem?
62
+ end
63
+
64
+ def gemfile_has_gem?
65
+ return false unless File.exist?('Gemfile')
66
+ File.read('Gemfile').include?("gem 'instrumental-components-library'")
67
+ end
68
+
69
+ def gemfile_lock_has_gem?
70
+ return false unless File.exist?('Gemfile.lock')
71
+ File.read('Gemfile.lock').include?('instrumental-components-library (')
72
+ end
73
+
49
74
  def download_gem
50
75
  # For local development, set INSTRUMENTAL_DOMAIN=http://localhost:3000 in .env
51
76
  # This allows testing against a local server while developing the gem
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.3
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