11BeginPackage ["JerryI`LPM`" ]
22
3- PacletRepositories ::usage = "PacletRepositories[{Github -> \" URL to the repo\" , ...}] specify the wolfram packages to be synced via remote url"
4- Github ::usage = "internal name to specify the source of the package"
3+ PacletRepositories ::usage = "depricated"
4+ LPMRepositories ::usage = "LPMRepositories[{\" Github\" -> \" URL to the repo\" , ...}] specify the wolfram packages to be synced via remote url"
5+ LPMLoad ::usage = ""
6+ Github ::usage = "depricated"
57
68
79Begin ["`Private`" ]
810
9- System ` $Env ;
10- electronConfirmed = System ` $Env ["ElectronCode" ] === 1 ;
11-
12- JerryI ` LPM ` Private ` Version = 15
1311pacletDirectoryLoad = PacletDirectoryLoad
1412
1513urlImport = Import ;
@@ -38,6 +36,10 @@ inspectPackages[dir_String, cbk_] := Module[{
3836 ] & /@ packages ;
3937]
4038
39+ LPMRepositories = PacletRepositories ;
40+
41+ LPMLoad [projectDir_ String ] := If [FileExistsQ [FileNameJoin [{projectDir , "wl_packages" }] ], Map [pacletDirectoryLoad ] @ Map [DirectoryName ] @ DeleteDuplicatesBy [FileNames ["PacletInfo.wl" | "PacletInfo.m" , {# }, {2 }], DirectoryName ]& @ FileNameJoin [{projectDir , "wl_packages" }], $Failed ];
42+
4143PacletRepositories [list_ List , OptionsPattern []] := Module [{projectDir , strictMode = OptionValue ["StrictMode" ], info , repos , cache , updated , removed , new , current , updatable , skipUpdates = OptionValue ["Passive" ], automaticUpdates = OptionValue ["AutomaticUpdates" ], versionControl , maxVersionDiff = OptionValue ["MaxVersionDiff" ]},
4244 (* making key-values pairs *)
4345 repos = (# -> < |"key" -> # |> )& /@ list // Association ;
@@ -63,6 +65,10 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
6365 If [Now - time < OptionValue ["UpdateInterval" ] || strictMode ,
6466 skipUpdates = True ;
6567
68+ With [{c = CacheLoad [projectDir ]}, If [AssociationQ [c ] && ! TrueQ [strictMode ],
69+ If [Length [Complement [Keys [repos ], Keys [c ] ] ] > 0 , skipUpdates = False ];
70+ ] ];
71+
6672 ];
6773 ]
6874 ];
@@ -77,7 +83,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
7783 Echo ["LPM >> fetching packages info" ];
7884
7985 If [FailureQ [ URLFetch ["https://github.com" ] ],
80- If [! electronConfirmed ,
8186 Echo ["LPM >> ERROR! no connection to github.com!" ];
8287
8388 If [! MissingQ [cache ],
@@ -89,12 +94,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
8994 Echo ["LPM >> ERROR! no cache found ;()" ];
9095 Abort [];
9196 ];
92- ,
93- Echo ["LPM >> URLRead or proxy connection failed" ];
94- Echo ["@Electron, fetch me libraries" ];
95-
96- Exit [- 1 ];
97- ];
9897 ];
9998
10099 (* fetching new information from Github for each repo in the list *)
@@ -132,7 +131,7 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
132131 If [automaticUpdates ,
133132 updatable = Select [current , CheckUpdates ];
134133 ,
135- Echo ["LPM >> Automatic updates are suppressed by default since 2.7.6 " ];
134+ Echo ["LPM >> Automatic updates are suppressed by default" ];
136135 updatable = < ||> ;
137136 ];
138137
@@ -206,7 +205,7 @@ CheckUpdates[a_Association] := Module[{result},
206205convertVersion [str_ String ] := ToExpression [StringReplace [str , "." -> "" ]]
207206
208207(* general function work for both Releases & Branches *)
209- CheckUpdates [a_ Association , Rule [Github , _ ]] := Module [{package , new , now },
208+ CheckUpdates [a_ Association , Rule [Github | "Github" , _ ]] := Module [{package , new , now },
210209 (* fetch any *)
211210 package = FetchInfo [a ];
212211 If [! AssociationQ [package ], Echo ["LPM >> cannot check. Skipping..." ]; Return [False , Module ]];
@@ -239,7 +238,7 @@ FetchInfo[a_Association] := Module[{result},
239238]
240239
241240(* for releases *)
242- FetchInfo [a_ Association , Rule [Github , url_ String ]] := Module [{new , data },
241+ FetchInfo [a_ Association , Rule [Github | "Github" , url_ String ]] := Module [{new , data },
243242 (* extracting from given url *)
244243 new = StringCases [url , RegularExpression [".com\\ /(.*).git" ]-> "$1" ]// First // Quiet ;
245244 If [! StringQ [new ], new = StringCases [url , RegularExpression [".com\\ /(.*)" ]-> "$1" ]// First ];
@@ -252,15 +251,15 @@ FetchInfo[a_Association, Rule[Github, url_String]] := Module[{new, data},
252251 If [! StringQ [data ["zipball_url" ]],
253252 Print ["Releases are not available. Taking a master branch" ];
254253 (* TAKE MASTER Branch *)
255- Return [FetchInfo [a , Rule [Github , Rule [url , "master" ]]]];
254+ Return [FetchInfo [a , Rule [" Github" , Rule [url , "master" ]]]];
256255 ];
257256
258257 (* merge new and old data together *)
259258 Join [a , data , < |"git-url" -> new |> ]
260259]
261260
262261(* for branches *)
263- FetchInfo [a_ Association , Rule [Github , Rule [url_ String , branch_ String ]]] :=
262+ FetchInfo [a_ Association , Rule [Github | "Github" , Rule [url_ String , branch_ String ]]] :=
264263Module [{new , data },
265264 (* extracting from given url *)
266265 new = StringCases [url , RegularExpression [".com\\ /(.*).git" ]-> "$1" ]// First // Quiet ;
@@ -290,15 +289,15 @@ Module[{new, data},
290289InstallPaclet [dir_ String ][a_ Association ] := InstallPaclet [dir ][a , a ["key" ]]
291290
292291(* releases *)
293- InstallPaclet [dir_ String ][a_ Association , Rule [Github , url_ String ]] := Module [{dirName , pacletPath },
292+ InstallPaclet [dir_ String ][a_ Association , Rule [Github | "Github" , url_ String ]] := Module [{dirName , pacletPath },
294293 dirName = FileNameJoin [{dir , "wl_packages" }];
295294 If [! FileExistsQ [dirName ], CreateDirectory [dirName ]];
296295
297296 (* check if there is no data on releases -> *)
298297 If [MissingQ [a ["zipball_url" ]],
299298 (* TAKE Master branch instead *)
300299 Echo ["LPM >> Releases are not available. Taking a master branch" ];
301- Return [InstallPaclet [dir ][a , Rule [Github , Rule [url , "master" ]]]];
300+ Return [InstallPaclet [dir ][a , Rule [" Github" , Rule [url , "master" ]]]];
302301 ];
303302
304303 (* make a name from the git url provided *)
@@ -336,7 +335,7 @@ InstallPaclet[dir_String][a_Association, Rule[Github, url_String]] := Module[{di
336335]
337336
338337(* for branch *)
339- InstallPaclet [dir_ String ][a_ Association , Rule [Github , Rule [url_ String , branch_ String ]]] := Module [{dirName , pacletPath },
338+ InstallPaclet [dir_ String ][a_ Association , Rule [Github | "Github" , Rule [url_ String , branch_ String ]]] := Module [{dirName , pacletPath },
340339 dirName = FileNameJoin [{dir , "wl_packages" }];
341340 If [! FileExistsQ [dirName ], CreateDirectory [dirName ]];
342341
@@ -379,11 +378,11 @@ InstallPaclet[dir_String][a_Association, Rule[Github, Rule[url_String, branch_St
379378RemovePaclet [dir_ String ][a_ Association ] := RemovePaclet [dir ][a , a ["key" ]]
380379
381380(* releases *)
382- RemovePaclet [dir_ String ][a_ Association , Rule [Github , url_ String ]] := (
381+ RemovePaclet [dir_ String ][a_ Association , Rule [Github | "Github" , url_ String ]] := (
383382
384383 If [MissingQ [a ["zipball_url" ]],
385384 Echo ["LPM >> Releases are not available. Removing master" ];
386- Return [RemovePaclet [dir ][a , Rule [Github , Rule [url , "master" ]]]];
385+ Return [RemovePaclet [dir ][a , Rule [" Github" , Rule [url , "master" ]]]];
387386 ];
388387
389388 dirName = FileNameJoin [{dir , "wl_packages" }];
@@ -402,7 +401,7 @@ RemovePaclet[dir_String][a_Association, Rule[Github, url_String]] := (
402401)
403402
404403(* branches *)
405- RemovePaclet [dir_ String ][a_ Association , Rule [Github , Rule [url_ String , branch_ String ]]] := Module [{dirName , pacletPath },
404+ RemovePaclet [dir_ String ][a_ Association , Rule [Github | "Github" , Rule [url_ String , branch_ String ]]] := Module [{dirName , pacletPath },
406405 dirName = FileNameJoin [{dir , "wl_packages" }];
407406 dirName = FileNameJoin [{dirName , StringReplace [a ["Name" ], "/" -> "_" ]}];
408407
0 commit comments