@@ -29,6 +29,15 @@ pub struct AppCache {
2929 pub apps : BTreeMap < String , CachedApp > ,
3030}
3131
32+
33+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
34+ pub struct AppLibIncludeFile {
35+ pub input : String ,
36+ pub output : String ,
37+ pub dir : Option < String > ,
38+ }
39+
40+
3241fn get_cache_file_path ( ) -> Option < PathBuf > {
3342 let pimmy_data_path = utils:: pimmy_data_path ( ) ?;
3443 Some (
@@ -791,6 +800,55 @@ pub fn create_bins(bins: HashMap<String, String>, install_path: &PathBuf) -> std
791800 Ok ( ( ) )
792801}
793802
803+ pub async fn install_into ( app_path : PathBuf , resolve_path : PathBuf ) {
804+ let app_yaml_path = resolve_path. join ( "app.yaml" ) ;
805+ if !app_yaml_path. exists ( ) {
806+ logger:: error ( "app.yaml not found" . into ( ) ) ;
807+ return ;
808+ }
809+
810+ let content = match fs:: read_to_string ( & app_yaml_path) {
811+ Ok ( s) => s,
812+ Err ( e) => {
813+ logger:: error ( & format ! (
814+ "Unable to read app.yaml at {}: {}" ,
815+ app_yaml_path. display( ) ,
816+ e
817+ ) ) ;
818+ return ;
819+ }
820+ } ;
821+ let manifest: Value = match serde_yaml:: from_str ( & content) . ok ( ) {
822+ Some ( s) => s,
823+ _ => {
824+ logger:: error ( & format ! (
825+ "Unable to read app.yaml at {}" ,
826+ app_yaml_path. display( )
827+ ) ) ;
828+ return ;
829+ }
830+ } ;
831+
832+
833+ if let Some ( libs) = manifest
834+ . get ( "libattachments" )
835+ . and_then ( |p| serde_yaml:: from_value :: < Vec < AppLibIncludeFile > > ( p. clone ( ) ) . ok ( ) )
836+ {
837+ for lib in libs {
838+ let inputfile = resolve_path. join ( lib. input ) ;
839+ let mut outputfile = app_path. join ( lib. output . clone ( ) ) ;
840+
841+ if let Some ( dir) = lib. dir {
842+ fs:: create_dir_all ( & app_path. join ( dir. clone ( ) ) ) . ok ( ) ;
843+ outputfile = app_path. join ( dir) . join ( lib. output ) ;
844+ }
845+
846+ fs:: copy ( inputfile, outputfile) . ok ( ) ;
847+ }
848+ }
849+
850+ }
851+
794852pub async fn install_from ( app_path : PathBuf , sync : Option < bool > , ignore_deps : bool ) {
795853 let mut cache = load_app_cache ( ) ;
796854
0 commit comments