
create_rocrate <- function(recipe){

    library(yaml)
    library(jsonlite)
    
    #TODO: Add checks for orcid and Info entries in the recipe!

    #Also have to add create action entity having each file as "result"
    json_content <- list(
        "@graph" = list(
        list(
            "@id" = "./",
            "license" = "Apache-2.0",
            "creator" = list(
            "@id" = recipe$Run$auto_conf$orcid
            )
        ),
        list(
            "@id" = recipe$Run$auto_conf$orcid,
            "@type" = "Person",
            "affiliation" = list(
            "@id" = "https://ror.org/05sd8tv96"
            )
        ),
        list(
            "@id" = "#metaclip-create-action",
            "@type" = "CreateAction",
            "instrument" = list(
            "@id" = paste0("file://", recipe$Run$code_dir)
            ),
            "name" = recipe$Description$Info,
            "description" = "SUNSET provenance based on METACLIP", 
            "isPartOf" = list(
            "@id" = "#create-action"
            ),
            "endTime" = format(Sys.time(), "%Y-%m-%d %H:%M"),
            "object" = list(),
            "result" = list()
        )
        )
    )

    rocrate <- list(
        ROCRATE = list(
        INPUTS = list(), 
        OUTPUTS = list("*/*.gif"),  
        PATCH = list("|") 
        )
    )

    out_dir <-  paste0(recipe$Run$output_dir, "/outputs/provenance")

    # Create the directory if it does not exist
    if (!dir.exists(out_dir)) {
        dir.create(out_dir, recursive = TRUE)
    }
    
    if (!dir.exists(paste0(recipe$Run$output_dir, "/logs/recipes"))) {
        dir.create(out_dir, recursive = TRUE)
    }

    rocrate$ROCRATE$PATCH <- json_content
    output_file_name <- paste0(out_dir, "/rocrate", ".yml")
    write_yaml(rocrate, output_file_name)
}
     