multiapi_cli 0.1.2 → 0.1.4

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: 2c5057b14e3caf00dc2d7cef380053d4e8cc054ca6f5c6cede32e24c9c3efc37
4
- data.tar.gz: ae144cd21569b53e4ac18085d40a068ba64859e53ca87cc203ec6cab16318a74
3
+ metadata.gz: ab8d5fe82562d619f96696e87f4aedb3686a70ea1ccd32c9e1cf121b61d4ef09
4
+ data.tar.gz: b01ecafac479d55aebf7b9925a5138f8bf9b31824fa086e9f18eaf50e4127880
5
5
  SHA512:
6
- metadata.gz: bcb1427dcdb10dc4ce8c76d9b06104f20e81056bbf98c52dd76f0e77170987c399ca55b518fe6b2eb43f88d2e6076a6c30599c43014c33465b27899ffb277ad1
7
- data.tar.gz: 0c9b6aede72f8550830bac3a44d81c4417154a0e9e45eac515c8a8832e1f65a45f5c16c8f98a97d584c48e7dd2def35bed71ee865165af293b08dce1a091e7ca
6
+ metadata.gz: 864666cd3e00fa0452c4e19c85d224278c2a248b641d8181fd58c706cb6254cbc20b22e2dccf13b5b6ec32df4c26a62851b72dc65b423512738a520e3567668a
7
+ data.tar.gz: f2ced404cfa5e72634475feab912e11d3ea49b585b18a8ebd4f46a569f830079a96b2b6cd5b9386c70a7365010d4e1b3632a66b71d9330bf1062786ebbbea103
@@ -1,3 +1,3 @@
1
1
  module MultiapiCli
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/multiapi_cli.rb CHANGED
@@ -9,8 +9,9 @@ module MultiapiCli
9
9
  class Error < StandardError; end
10
10
 
11
11
  class CLI < Thor
12
- desc "generate COMPONENT", "Gera um novo componente na estrutura Multiapi"
13
- 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
14
15
  prompt = TTY::Prompt.new
15
16
 
16
17
  type = prompt.select("O que você deseja criar?") do |menu|
@@ -422,6 +423,8 @@ module MultiapiCli
422
423
  end
423
424
 
424
425
  def api_path
426
+ return File.join(@working_directory, 'api') if @working_directory
427
+
425
428
  config = load_config
426
429
  ruby_path = get_ruby_path
427
430
  case config[:package_manager]
@@ -439,6 +442,8 @@ module MultiapiCli
439
442
  end
440
443
 
441
444
  def frontend_path
445
+ return File.join(@working_directory, 'web') if @working_directory
446
+
442
447
  config = load_config
443
448
  ruby_path = get_ruby_path
444
449
  case config[:package_manager]
@@ -981,10 +986,17 @@ module MultiapiCli
981
986
  id: string | number
982
987
  }>()
983
988
 
989
+ console.log('[Edit] Componente inicializado com ID:', props.id)
990
+
991
+ const emit = defineEmits(['success', 'cancel'])
992
+
984
993
  const store = use#{plural_name.camelize}Store()
985
994
  const isSubmitting = ref(false)
986
995
  const isLoading = ref(true)
987
- const formData = ref({})
996
+ const formData = ref({
997
+ id: null,
998
+ #{fields.map { |f| "#{f[:name]}: ''" }.join(",\n ")}
999
+ })
988
1000
 
989
1001
  const fields = [
990
1002
  #{field_definitions}
@@ -996,25 +1008,58 @@ module MultiapiCli
996
1008
  })
997
1009
  )
998
1010
 
999
- onMounted(async () => {
1000
- try {
1001
- const data = await store.fetch#{singular_name.camelize}(props.id)
1002
- formData.value = data
1003
- } catch (error) {
1004
- console.error('Erro ao carregar #{singular_name}:', error)
1005
- } finally {
1011
+ const loadData = () => {
1012
+ console.log('[Edit] ============ CICLO DE CARREGAMENTO ============')
1013
+ console.log('[Edit] Estado atual:', {
1014
+ id: props.id,
1015
+ channels: store.#{plural_name}.length
1016
+ })
1017
+
1018
+ if (!props.id) {
1019
+ console.log('[Edit] Nenhum ID fornecido, interrompendo ciclo')
1020
+ isLoading.value = false
1021
+ return
1022
+ }
1023
+
1024
+ // Buscar o registro diretamente do array no store
1025
+ const item = store.#{plural_name}.find(c => c.id === props.id)
1026
+
1027
+ if (!item) {
1028
+ console.error('[Edit] Item não encontrado no store')
1006
1029
  isLoading.value = false
1030
+ return
1031
+ }
1032
+
1033
+ console.log('[Edit] Item encontrado no store:', item)
1034
+
1035
+ const formattedData = {
1036
+ id: item.id,
1037
+ #{fields.map { |f| "#{f[:name]}: String(item.#{f[:name]} || '')" }.join(",\n ")}
1007
1038
  }
1039
+
1040
+ console.log('[Edit] Atualizando formData:', formattedData)
1041
+ formData.value = formattedData
1042
+ isLoading.value = false
1043
+ }
1044
+
1045
+ onMounted(() => {
1046
+ console.log('[Edit] Componente montado, carregando dados do store')
1047
+ loadData()
1008
1048
  })
1009
1049
 
1010
1050
  const onSubmit = async (values) => {
1051
+ if (!props.id) return
1052
+
1011
1053
  try {
1054
+ console.log('[Edit] Iniciando submissão do formulário com valores:', values)
1012
1055
  isSubmitting.value = true
1013
1056
  await store.update#{singular_name.camelize}(props.id, values)
1014
- $emit('success')
1057
+ console.log('[Edit] Item atualizado com sucesso')
1058
+ emit('success')
1015
1059
  } catch (error) {
1016
- console.error('Erro ao atualizar #{singular_name}:', error)
1060
+ console.error('[Edit] Erro ao atualizar item:', error)
1017
1061
  } finally {
1062
+ console.log('[Edit] Finalizando submissão do formulário')
1018
1063
  isSubmitting.value = false
1019
1064
  }
1020
1065
  }
@@ -1115,6 +1160,8 @@ module MultiapiCli
1115
1160
  end
1116
1161
 
1117
1162
  def api_path
1163
+ return File.join(@working_directory, 'api') if @working_directory
1164
+
1118
1165
  config = load_config
1119
1166
  ruby_path = get_ruby_path
1120
1167
  case config[:package_manager]
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.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seu Nome