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 +4 -4
- data/lib/multiapi_cli/version.rb +1 -1
- data/lib/multiapi_cli.rb +59 -12
- 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: ab8d5fe82562d619f96696e87f4aedb3686a70ea1ccd32c9e1cf121b61d4ef09
|
4
|
+
data.tar.gz: b01ecafac479d55aebf7b9925a5138f8bf9b31824fa086e9f18eaf50e4127880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 864666cd3e00fa0452c4e19c85d224278c2a248b641d8181fd58c706cb6254cbc20b22e2dccf13b5b6ec32df4c26a62851b72dc65b423512738a520e3567668a
|
7
|
+
data.tar.gz: f2ced404cfa5e72634475feab912e11d3ea49b585b18a8ebd4f46a569f830079a96b2b6cd5b9386c70a7365010d4e1b3632a66b71d9330bf1062786ebbbea103
|
data/lib/multiapi_cli/version.rb
CHANGED
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
|
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
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
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
|
-
|
1057
|
+
console.log('[Edit] Item atualizado com sucesso')
|
1058
|
+
emit('success')
|
1015
1059
|
} catch (error) {
|
1016
|
-
console.error('Erro ao atualizar
|
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]
|