import { resolve } from "./state" ; import path from "path" ; import fs from "fs-extra" ; import { Runtime } from "../runtime" ; const FILE_NAME = "functions.jsonl" ; export function reset ( root ) { fs . removeSync ( definitionsPath ( root ) ) ; } export function append ( root , def ) { fs . appendFileSync ( definitionsPath ( root ) , JSON . stringify ( { ... def , root , } ) + "\n" ) ; } export function read ( root ) { if ( ! fs . existsSync ( definitionsPath ( root ) ) ) return [ ] ; const data = fs . readFileSync ( definitionsPath ( root ) , "utf8" ) ; return data . split ( "\n" ) . filter ( Boolean ) . map ( ( line ) => JSON . parse ( line ) ) ; } function definitionsPath ( root ) { return resolve ( root , FILE_NAME ) ; } export function artifactsPath ( root , target ) { return resolve ( root , path . join ( "artifacts" , target ) ) ; }