@@ -2,7 +2,7 @@ BeginPackage["JerryI`LPM`"]
22
33PacletRepositories ::usage = "depricated"
44LPMRepositories ::usage = "LPMRepositories[{\" Github\" -> \" URL to the repo\" , ...}] specify the wolfram packages to be synced via remote url"
5- LPMLoad ::usage = ""
5+ LPMLoad ::usage = "LPMLoad[ \" Directory \" ->...] loads paclets stored by LPMRepositories[] without checking updates and etc "
66Github ::usage = "depricated"
77
88
@@ -38,7 +38,20 @@ inspectPackages[dir_String, cbk_] := Module[{
3838
3939LPMRepositories = PacletRepositories ;
4040
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 ];
41+ LPMLoad [OptionsPattern [] ] := Module [{projectDir },
42+ If [OptionValue ["Directory" ]// StringQ ,
43+ projectDir = OptionValue ["Directory" ];
44+ If [! StringQ [projectDir ], Echo ["LPM >> Sorry. This is a wrong folder!" ]; Abort []];
45+ ,
46+ projectDir = NotebookDirectory [] // Quiet ;
47+ If [! StringQ [projectDir ], projectDir = DirectoryName [$InputFileName ]];
48+ If [! StringQ [projectDir ], Echo ["LPM >> Sorry. We cannot work without a project directory. Save your notebook / script first" ]; Abort []];
49+ ];
50+
51+ If [FileExistsQ [FileNameJoin [{projectDir , "wl_packages" }] ], Map [pacletDirectoryLoad ] @ Map [DirectoryName ] @ DeleteDuplicatesBy [FileNames ["PacletInfo.wl" | "PacletInfo.m" , {# }, {2 }], DirectoryName ]& @ FileNameJoin [{projectDir , "wl_packages" }], $Failed ]
52+ ]
53+
54+ Options [LPMLoad ] = {"Directory" -> None }
4255
4356PacletRepositories [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" ]},
4457 (* making key-values pairs *)
@@ -49,7 +62,7 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
4962 projectDir = OptionValue ["Directory" ];
5063 If [! StringQ [projectDir ], Echo ["LPM >> Sorry. This is a wrong folder!" ]; Abort []];
5164 ,
52- projectDir = NotebookDirectory [];
65+ projectDir = NotebookDirectory [] // Quiet ;
5366 If [! StringQ [projectDir ], projectDir = DirectoryName [$InputFileName ]];
5467 If [! StringQ [projectDir ], Echo ["LPM >> Sorry. We cannot work without a project directory. Save your notebook / script first" ]; Abort []];
5568 ];
@@ -58,20 +71,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
5871 CreateDirectory [projectDir , CreateIntermediateDirectories -> True ];
5972 If [! FileExistsQ [projectDir ], Echo ["LPM >> Cannot create project directory by path " <> projectDir <> " !!!" ]; Abort [] ];
6073 ];
61-
62-
63- If [FileExistsQ [FileNameJoin [{projectDir , ".wl_timestamp" }] ] && ! OptionValue ["ForceUpdates" ],
64- With [{time = Get [ FileNameJoin [{projectDir , ".wl_timestamp" }] ]},
65- If [Now - time < OptionValue ["UpdateInterval" ] || strictMode ,
66- skipUpdates = True ;
67-
68- With [{c = CacheLoad [projectDir ]}, If [AssociationQ [c ] && ! TrueQ [strictMode ],
69- If [Length [Complement [Keys [repos ], Keys [c ] ] ] > 0 , skipUpdates = False ];
70- ] ];
71-
72- ];
73- ]
74- ];
7574
7675 (* PASSIVE mode :: skips all checks and just loads wl_package folder *)
7776 If [skipUpdates ,
@@ -137,30 +136,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
137136
138137 (* will be updated *)
139138 updated = ((# -> repos [# ])& /@ Keys [updatable ]) // Association ;
140-
141- If [maxVersionDiff =!= None ,
142- (* filter if the version is too high *)
143- versionControl = VersionsLoad [projectDir ];
144- If [versionControl =!= None ,
145- (* apply filter *)
146-
147- updated = Table [ With [{
148- lookupVersion = Lookup [versionControl , key , Missing [] ]
149- },
150-
151- If [
152- MissingQ [lookupVersion ] || (
153- convertVersion [ updated [key ]["Version" ] ] - convertVersion [lookupVersion ] <= maxVersionDiff
154- ),
155-
156- key -> updated [key ],
157-
158- Echo ["LPM >> Version difference is too high. Bundled: " <> lookupVersion <> " vs Remote: " <> updated [key ]["Version" ] ];
159- Echo ["Skipping..." ];
160- Nothing
161- ] ], {key , Keys [updated ]}] // Association ;
162- ];
163- ];
164139
165140 Echo [StringTemplate ["LPM >> will be UPDATED: ``" ][Length [updatable ]]];
166141
@@ -171,13 +146,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
171146 (* update local cache file aka packages.json *)
172147 CacheStore [projectDir , repos ];
173148
174- (* store version (if applicable) *)
175- If [maxVersionDiff =!= None && versionControl === None ,
176- VersionsStore [projectDir , repos ]
177- ];
178-
179- Put [Now , FileNameJoin [{projectDir , ".wl_timestamp" }] ];
180-
181149 (* finally load dirs *)
182150 inspectPackages [FileNameJoin [{projectDir , "wl_packages" }], OptionValue ["ConflictResolutionFunction" ] ];
183151 Map [pacletDirectoryLoad ] @ Map [DirectoryName ] @ DeleteDuplicatesBy [FileNames ["PacletInfo.wl" | "PacletInfo.m" , {# }, {2 }], DirectoryName ]& @ FileNameJoin [{projectDir , "wl_packages" }];
@@ -194,10 +162,6 @@ Options[PacletRepositories] = {"Directory"->None, "StrictMode"->False, "Passive"
194162CacheStore [dir_ String , repos_ Association ] := Export [FileNameJoin [{dir , "wl_packages_lock.wl" }], repos ]
195163CacheLoad [dir_ String ] := If [! FileExistsQ [FileNameJoin [{dir , "wl_packages_lock.wl" }]], Missing [], Import [FileNameJoin [{dir , "wl_packages_lock.wl" }]]];
196164
197- VersionsStore [dir_ String , repos_ Association ] := Export [FileNameJoin [{dir , "wl_packages_version.wl" }], Map [Function [data , data ["Version" ] ], repos ] ]
198- VersionsLoad [dir_ String ] := If [FileExistsQ [FileNameJoin [{dir , "wl_packages_version.wl" }] ], Import [FileNameJoin [{dir , "wl_packages_version.wl" }] ], None ]
199-
200-
201165CheckUpdates [a_ Association ] := Module [{result },
202166 CheckUpdates [a , a ["key" ]]
203167]
0 commit comments