multiapi_cli 0.1.0 → 0.1.2
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 +4 -4
- data/lib/multiapi_cli/version.rb +1 -1
- data/lib/multiapi_cli.rb +112 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c5057b14e3caf00dc2d7cef380053d4e8cc054ca6f5c6cede32e24c9c3efc37
|
4
|
+
data.tar.gz: ae144cd21569b53e4ac18085d40a068ba64859e53ca87cc203ec6cab16318a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcb1427dcdb10dc4ce8c76d9b06104f20e81056bbf98c52dd76f0e77170987c399ca55b518fe6b2eb43f88d2e6076a6c30599c43014c33465b27899ffb277ad1
|
7
|
+
data.tar.gz: 0c9b6aede72f8550830bac3a44d81c4417154a0e9e45eac515c8a8832e1f65a45f5c16c8f98a97d584c48e7dd2def35bed71ee865165af293b08dce1a091e7ca
|
data/lib/multiapi_cli/version.rb
CHANGED
data/lib/multiapi_cli.rb
CHANGED
@@ -3,6 +3,7 @@ require "tty-prompt"
|
|
3
3
|
require "tty-spinner"
|
4
4
|
require "active_support/core_ext/string/inflections"
|
5
5
|
require "fileutils"
|
6
|
+
require "yaml"
|
6
7
|
|
7
8
|
module MultiapiCli
|
8
9
|
class Error < StandardError; end
|
@@ -35,6 +36,30 @@ module MultiapiCli
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
desc "config", "Configura as preferências da CLI"
|
40
|
+
def config
|
41
|
+
prompt = TTY::Prompt.new
|
42
|
+
|
43
|
+
package_manager = prompt.select("Qual gerenciador de pacotes você usa?") do |menu|
|
44
|
+
menu.choice "Homebrew (brew)", :brew
|
45
|
+
menu.choice "asdf", :asdf
|
46
|
+
menu.choice "rbenv", :rbenv
|
47
|
+
menu.choice "rvm", :rvm
|
48
|
+
end
|
49
|
+
|
50
|
+
config = {
|
51
|
+
package_manager: package_manager
|
52
|
+
}
|
53
|
+
|
54
|
+
config_dir = File.join(Dir.home, '.multiapi')
|
55
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
56
|
+
|
57
|
+
config_file = File.join(config_dir, 'config.yml')
|
58
|
+
File.write(config_file, config.to_yaml)
|
59
|
+
|
60
|
+
puts "✔ Configuração salva com sucesso!"
|
61
|
+
end
|
62
|
+
|
38
63
|
private
|
39
64
|
|
40
65
|
def generate_app_vue_content
|
@@ -397,11 +422,37 @@ module MultiapiCli
|
|
397
422
|
end
|
398
423
|
|
399
424
|
def api_path
|
400
|
-
|
425
|
+
config = load_config
|
426
|
+
ruby_path = get_ruby_path
|
427
|
+
case config[:package_manager]
|
428
|
+
when :brew
|
429
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
430
|
+
when :asdf
|
431
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
432
|
+
when :rbenv
|
433
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
434
|
+
when :rvm
|
435
|
+
File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
436
|
+
else
|
437
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
438
|
+
end
|
401
439
|
end
|
402
440
|
|
403
441
|
def frontend_path
|
404
|
-
|
442
|
+
config = load_config
|
443
|
+
ruby_path = get_ruby_path
|
444
|
+
case config[:package_manager]
|
445
|
+
when :brew
|
446
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
447
|
+
when :asdf
|
448
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
449
|
+
when :rbenv
|
450
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
451
|
+
when :rvm
|
452
|
+
File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
453
|
+
else
|
454
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
455
|
+
end
|
405
456
|
end
|
406
457
|
|
407
458
|
def generate_store_content(name, scope)
|
@@ -1037,5 +1088,64 @@ module MultiapiCli
|
|
1037
1088
|
puts e.backtrace
|
1038
1089
|
end
|
1039
1090
|
end
|
1091
|
+
|
1092
|
+
def load_config
|
1093
|
+
config_file = File.join(Dir.home, '.multiapi', 'config.yml')
|
1094
|
+
if File.exist?(config_file)
|
1095
|
+
YAML.load_file(config_file)
|
1096
|
+
else
|
1097
|
+
{ package_manager: :brew } # Default para Homebrew
|
1098
|
+
end
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
def get_ruby_path
|
1102
|
+
config = load_config
|
1103
|
+
case config[:package_manager]
|
1104
|
+
when :brew
|
1105
|
+
"/usr/local/opt/ruby/bin"
|
1106
|
+
when :asdf
|
1107
|
+
File.join(Dir.home, '.asdf/installs/ruby')
|
1108
|
+
when :rbenv
|
1109
|
+
File.join(Dir.home, '.rbenv/versions')
|
1110
|
+
when :rvm
|
1111
|
+
File.join(Dir.home, '.rvm/rubies')
|
1112
|
+
else
|
1113
|
+
"/usr/local/opt/ruby/bin" # Default para Homebrew
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
def api_path
|
1118
|
+
config = load_config
|
1119
|
+
ruby_path = get_ruby_path
|
1120
|
+
case config[:package_manager]
|
1121
|
+
when :brew
|
1122
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
1123
|
+
when :asdf
|
1124
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
1125
|
+
when :rbenv
|
1126
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
1127
|
+
when :rvm
|
1128
|
+
File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
1129
|
+
else
|
1130
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
|
1131
|
+
end
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
def web_path
|
1135
|
+
config = load_config
|
1136
|
+
ruby_path = get_ruby_path
|
1137
|
+
case config[:package_manager]
|
1138
|
+
when :brew
|
1139
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
1140
|
+
when :asdf
|
1141
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
1142
|
+
when :rbenv
|
1143
|
+
File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
1144
|
+
when :rvm
|
1145
|
+
File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
1146
|
+
else
|
1147
|
+
File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
|
1148
|
+
end
|
1149
|
+
end
|
1040
1150
|
end
|
1041
1151
|
end
|