11import androidx.compose.foundation.layout.Column
2+ import androidx.compose.foundation.layout.Row
23import androidx.compose.foundation.layout.Spacer
34import androidx.compose.foundation.layout.fillMaxWidth
45import androidx.compose.foundation.layout.height
@@ -12,25 +13,22 @@ import androidx.compose.ui.Alignment
1213import androidx.compose.ui.Modifier
1314import androidx.compose.ui.text.font.FontWeight
1415import androidx.compose.ui.unit.dp
15- import com.charleskorn.kaml.Yaml
1616import io.ktor.client.HttpClient
17- import io.ktor.client.call.body
18- import io.ktor.client.request.get
19- import kotlinx.serialization.Serializable
20- import kotlinx.serialization.decodeFromString
2117
2218val client = HttpClient ()
2319
2420@Composable
2521fun App () {
2622 MaterialTheme {
2723 var actionCoords by remember { mutableStateOf(" actions/checkout@v4" ) }
28- var manifestYaml by remember { mutableStateOf(" <manifest>" ) }
24+ var manifest: Metadata ? by remember { mutableStateOf(null ) }
25+ var typingFromAction: Typing ? by remember { mutableStateOf(null ) }
26+ var typingFromCatalog: Typing ? by remember { mutableStateOf(null ) }
2927
3028 LaunchedEffect (actionCoords) {
31- val actionManifestYaml = client.get(urlString = " https://raw.githubusercontent.com/ ${ actionCoords.replace( " @ " , " / " )} /action.yml " )
32- .body< String >( )
33- manifestYaml = actionManifestYaml
29+ manifest = fetchManifest( actionCoords)
30+ typingFromAction = fetchTypingFromAction(actionCoords )
31+ typingFromCatalog = fetchTypingFromCatalog(actionCoords)
3432 }
3533
3634 Column (Modifier .fillMaxWidth(), horizontalAlignment = Alignment .CenterHorizontally ) {
@@ -41,54 +39,59 @@ fun App() {
4139 )
4240 Spacer (Modifier .height(10 .dp))
4341
44- val myYaml = Yaml (configuration = Yaml .default.configuration.copy(strictMode = false ))
45- val parsedYaml = try {
46- myYaml.decodeFromString<Metadata >(manifestYaml)
47- } catch (e: Exception ) {
48- println (" Exception: $e " )
49- null
42+ Row {
43+ manifest(manifest)
44+ typing(typingFromAction, source = " action" )
45+ typing(typingFromCatalog, source = " catalog" )
5046 }
47+ }
48+ }
49+ }
5150
52- Column (Modifier .verticalScroll(rememberScrollState())) {
53- Text (" Inputs" , fontWeight = FontWeight .Bold )
54- if (parsedYaml?.inputs?.isEmpty() == true ) {
55- Text (" <none>" )
56- }
57- parsedYaml?.inputs?.forEach {
58- Text (it.key)
59- }
51+ @Composable
52+ private fun manifest (manifest : Metadata ? ) {
53+ Column (Modifier .verticalScroll(rememberScrollState())) {
54+ Text (" Manifest:" )
55+ Text (" Inputs" , fontWeight = FontWeight .Bold )
56+ if (manifest?.inputs?.isEmpty() == true ) {
57+ Text (" <none>" )
58+ }
59+ manifest?.inputs?.forEach {
60+ Text (it.key)
61+ }
6062
61- Spacer (Modifier .height(10 .dp))
63+ Spacer (Modifier .height(10 .dp))
6264
63- Text (" Outputs" , fontWeight = FontWeight .Bold )
64- if (parsedYaml?.outputs?.isEmpty() == true ) {
65- Text (" <none>" )
66- }
67- parsedYaml?.outputs?.forEach {
68- Text (it.key)
69- }
70- }
65+ Text (" Outputs" , fontWeight = FontWeight .Bold )
66+ if (manifest?.outputs?.isEmpty() == true ) {
67+ Text (" <none>" )
68+ }
69+ manifest?.outputs?.forEach {
70+ Text (it.key)
7171 }
7272 }
7373}
7474
75- @Serializable
76- data class Metadata (
77- val name : String ,
78- val description : String ,
79- val inputs : Map <String , Input > = emptyMap(),
80- val outputs : Map <String , Output > = emptyMap(),
81- )
75+ @Composable
76+ private fun typing (typing : Typing ? , source : String ) {
77+ Column (Modifier .verticalScroll(rememberScrollState())) {
78+ Text (" Typing from $source :" )
79+ Text (" Inputs" , fontWeight = FontWeight .Bold )
80+ if (typing?.inputs?.isEmpty() == true ) {
81+ Text (" <none>" )
82+ }
83+ typing?.inputs?.forEach {
84+ Text (" ${it.key} : ${it.value.type} " )
85+ }
8286
83- @Serializable
84- data class Input (
85- val description : String = " " ,
86- val default : String? = null ,
87- val required : Boolean? = null ,
88- val deprecationMessage : String? = null ,
89- )
87+ Spacer (Modifier .height(10 .dp))
9088
91- @Serializable
92- data class Output (
93- val description : String = " " ,
94- )
89+ Text (" Outputs" , fontWeight = FontWeight .Bold )
90+ if (typing?.outputs?.isEmpty() == true ) {
91+ Text (" <none>" )
92+ }
93+ typing?.outputs?.forEach {
94+ Text (" ${it.key} : ${it.value.type} " )
95+ }
96+ }
97+ }
0 commit comments