psdk-cli 0.1.0 → 0.1.1

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.
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../cli/version'
4
+
5
+ module Psdk
6
+ module Cli
7
+ # Module holding the logic to update the psdk-cli gem
8
+ module VersionUpdate
9
+ module_function
10
+
11
+ # Check if the psdk-cli gem is up-to-date and update it if needed
12
+ def check_and_update
13
+ puts 'Checking for updates...'
14
+ local_version = Psdk::Cli::VERSION
15
+ remote_version = fetch_remote_version
16
+
17
+ compare_and_update_versions(local_version, remote_version)
18
+ rescue StandardError => e
19
+ $stderr.puts "Failed to update: #{e.message}"
20
+ exit(1)
21
+ end
22
+
23
+ # Compare local and remote versions and update if necessary
24
+ # @param local_version [String] The currently installed version
25
+ # @param remote_version [String] The latest version available
26
+ def compare_and_update_versions(local_version, remote_version)
27
+ if Gem::Version.new(remote_version) > Gem::Version.new(local_version)
28
+ puts "New version available: #{remote_version} (current: #{local_version})"
29
+ update_gem
30
+ else
31
+ puts 'psdk-cli is up-to-date.'
32
+ end
33
+ end
34
+
35
+ # Fetch the latest version of psdk-cli from rubygems
36
+ # @return [String]
37
+ def fetch_remote_version
38
+ output = `gem search -r psdk-cli`
39
+ match = output.match(/psdk-cli \(([\d.]+)\)/)
40
+ return match[1] if match
41
+
42
+ raise 'Could not find psdk-cli in remote gems'
43
+ end
44
+
45
+ # Update the psdk-cli gem
46
+ def update_gem
47
+ print 'Do you want to update psdk-cli? [Y/n] '
48
+ response = $stdin.gets.chomp
49
+ return unless response.empty? || response.casecmp('y').zero?
50
+
51
+ puts 'Updating psdk-cli...'
52
+ result = system('gem install psdk-cli')
53
+ raise 'gem install psdk-cli failed' unless result
54
+
55
+ puts 'Update complete.'
56
+ exit
57
+ end
58
+ end
59
+ end
60
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psdk-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pokémon Workshop
@@ -14,10 +14,12 @@ email:
14
14
  executables:
15
15
  - psdk-cli
16
16
  - psdk-plugin
17
+ - psdk-use
17
18
  extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
21
  - ".idea/# PSDK CLI.md"
22
+ - ".idea/plugin/PluginManager.md"
21
23
  - ".solargraph.yml"
22
24
  - CHANGELOG.md
23
25
  - LICENSE
@@ -25,9 +27,21 @@ files:
25
27
  - Rakefile
26
28
  - exe/psdk-cli
27
29
  - exe/psdk-plugin
30
+ - exe/psdk-use
28
31
  - lib/psdk/cli.rb
32
+ - lib/psdk/cli/configuration.rb
29
33
  - lib/psdk/cli/plugin.rb
34
+ - lib/psdk/cli/use.rb
30
35
  - lib/psdk/cli/version.rb
36
+ - lib/psdk/helpers/900 Yuki__VD.rb
37
+ - lib/psdk/helpers/plugin_manager.rb
38
+ - lib/psdk/helpers/plugin_manager/builder.rb
39
+ - lib/psdk/helpers/plugin_manager/config.rb
40
+ - lib/psdk/helpers/plugin_manager/list.rb
41
+ - lib/psdk/helpers/psdk.rb
42
+ - lib/psdk/helpers/studio.rb
43
+ - lib/psdk/helpers/version.rb
44
+ - lib/psdk/helpers/version_update.rb
31
45
  - sig/psdk/cli.rbs
32
46
  homepage: https://github.com/PokemonWorkshop/psdk-cli
33
47
  licenses: []