multiapi_cli 0.1.1 → 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: ba58867cff21cff7702def963eee6275af4d432cba2f8021debdd2e83e5cd838
4
- data.tar.gz: cdd3cd7a36d7a00163bef5620d43563237f70e5a5ed1530271fc25aa89aebd63
3
+ metadata.gz: 7f7df3e65178366a1b9ec58f83af286d436bc443b6bf26f032b6ae6cff6b0e70
4
+ data.tar.gz: 4b6e8800edc639c99e6e21d4a5a7a7e4e3b9e6c8fbc02e7afbe704ac34c8df74
5
5
  SHA512:
6
- metadata.gz: 6a163b2fbd168be63adf903ff1bd66a1080557e5c77ff7cf072109e72cc24c6187c2a1ca9ebc23d21ee8e20b46f6fc9fe9a5a9d0209328dd032c8b49351f5d8c
7
- data.tar.gz: 57495249fcb6dd80e457fffad7fdd5dbca7123758d56b8b32034e17d164e28869a86e9b83cc0080b1c58e48ee6e8be7286a27a2644e92fe345a1606f5ef9092e
6
+ metadata.gz: 542b7ae1fcadeb3d9d9413b488f30a4f4a61f6c791873dcdab9129f3d3356bbe54977319676b145206791ce283ec1d509f67f82ab5e4b73ba1a5a21af743e9e5
7
+ data.tar.gz: ed45d1beff89fec0b23ddc07d201aa0dd2e39b9a0ebaf809643782875f704ada55416dd80ee8524173be97996fb718c43bd7caf59a49e5f54a74cce52f2d0e4f
@@ -1,3 +1,3 @@
1
1
  module MultiapiCli
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/multiapi_cli.rb CHANGED
@@ -3,13 +3,15 @@ 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
9
10
 
10
11
  class CLI < Thor
11
- desc "generate COMPONENT", "Gera um novo componente na estrutura Multiapi"
12
- def generate
12
+ desc "generate [DIRECTORY]", "Gera um novo componente na estrutura Multiapi. Use '.' para o diretório atual"
13
+ def generate(directory = nil)
14
+ @working_directory = directory == '.' ? Dir.pwd : nil
13
15
  prompt = TTY::Prompt.new
14
16
 
15
17
  type = prompt.select("O que você deseja criar?") do |menu|
@@ -35,6 +37,30 @@ module MultiapiCli
35
37
  end
36
38
  end
37
39
 
40
+ desc "config", "Configura as preferências da CLI"
41
+ def config
42
+ prompt = TTY::Prompt.new
43
+
44
+ package_manager = prompt.select("Qual gerenciador de pacotes você usa?") do |menu|
45
+ menu.choice "Homebrew (brew)", :brew
46
+ menu.choice "asdf", :asdf
47
+ menu.choice "rbenv", :rbenv
48
+ menu.choice "rvm", :rvm
49
+ end
50
+
51
+ config = {
52
+ package_manager: package_manager
53
+ }
54
+
55
+ config_dir = File.join(Dir.home, '.multiapi')
56
+ FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
57
+
58
+ config_file = File.join(config_dir, 'config.yml')
59
+ File.write(config_file, config.to_yaml)
60
+
61
+ puts "✔ Configuração salva com sucesso!"
62
+ end
63
+
38
64
  private
39
65
 
40
66
  def generate_app_vue_content
@@ -397,11 +423,41 @@ module MultiapiCli
397
423
  end
398
424
 
399
425
  def api_path
400
- File.expand_path("../../api", __dir__)
426
+ return File.join(@working_directory, 'api') if @working_directory
427
+
428
+ config = load_config
429
+ ruby_path = get_ruby_path
430
+ case config[:package_manager]
431
+ when :brew
432
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
433
+ when :asdf
434
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
435
+ when :rbenv
436
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
437
+ when :rvm
438
+ File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/api")
439
+ else
440
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
441
+ end
401
442
  end
402
443
 
403
444
  def frontend_path
404
- File.expand_path("../../web", __dir__)
445
+ return File.join(@working_directory, 'web') if @working_directory
446
+
447
+ config = load_config
448
+ ruby_path = get_ruby_path
449
+ case config[:package_manager]
450
+ when :brew
451
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
452
+ when :asdf
453
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
454
+ when :rbenv
455
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
456
+ when :rvm
457
+ File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/web")
458
+ else
459
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
460
+ end
405
461
  end
406
462
 
407
463
  def generate_store_content(name, scope)
@@ -1037,5 +1093,66 @@ module MultiapiCli
1037
1093
  puts e.backtrace
1038
1094
  end
1039
1095
  end
1096
+
1097
+ def load_config
1098
+ config_file = File.join(Dir.home, '.multiapi', 'config.yml')
1099
+ if File.exist?(config_file)
1100
+ YAML.load_file(config_file)
1101
+ else
1102
+ { package_manager: :brew } # Default para Homebrew
1103
+ end
1104
+ end
1105
+
1106
+ def get_ruby_path
1107
+ config = load_config
1108
+ case config[:package_manager]
1109
+ when :brew
1110
+ "/usr/local/opt/ruby/bin"
1111
+ when :asdf
1112
+ File.join(Dir.home, '.asdf/installs/ruby')
1113
+ when :rbenv
1114
+ File.join(Dir.home, '.rbenv/versions')
1115
+ when :rvm
1116
+ File.join(Dir.home, '.rvm/rubies')
1117
+ else
1118
+ "/usr/local/opt/ruby/bin" # Default para Homebrew
1119
+ end
1120
+ end
1121
+
1122
+ def api_path
1123
+ return File.join(@working_directory, 'api') if @working_directory
1124
+
1125
+ config = load_config
1126
+ ruby_path = get_ruby_path
1127
+ case config[:package_manager]
1128
+ when :brew
1129
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
1130
+ when :asdf
1131
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
1132
+ when :rbenv
1133
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
1134
+ when :rvm
1135
+ File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/api")
1136
+ else
1137
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/api")
1138
+ end
1139
+ end
1140
+
1141
+ def web_path
1142
+ config = load_config
1143
+ ruby_path = get_ruby_path
1144
+ case config[:package_manager]
1145
+ when :brew
1146
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
1147
+ when :asdf
1148
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
1149
+ when :rbenv
1150
+ File.join(ruby_path, RUBY_VERSION, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
1151
+ when :rvm
1152
+ File.join(ruby_path, "ruby-#{RUBY_VERSION}/lib/ruby/gems/#{RUBY_VERSION}/gems/web")
1153
+ else
1154
+ File.join(ruby_path, "lib/ruby/gems/#{RUBY_VERSION}/gems/web")
1155
+ end
1156
+ end
1040
1157
  end
1041
1158
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiapi_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seu Nome