PDInstallPaclet
PDInstallPaclet::usage= "Installs a paclet from a site";
Begin["`Private`"];
PDInstallPaclet::howdo="Unsure how to pack a paclet from file type ``";PDInstallPaclet::laywha="Couldn't detect package layout from directory ``";
PDpacletInfo
PDpacletDocsInfo
PDpacletExtensionData
PDpacletExpression
PDpacletExpressionBundle
PDpacletLookup
PDpacletOpen
PDpacletBundle
⌈installPacletGenerate⌋
gitHubPathQ
gitHubPathParse
gitHubReleaseQ
gitHubRepoQ
⌈gitPacletPull⌋
gitPacletPull[loc:(_String|_URL|_File)]:= IfStringContainsQ[URLParse[loc,"PathString"],"releases"], Block release= SelectFirst Flatten@ Import URLBuild@ ReplacePart#, "Domain""api.github.com", "Path" With{cleanpath=DeleteCases[#["Path"],""]}, Ifcleanpath[[1]]==="repos", cleanpath, Prepend[cleanpath,"repos"] &@URLParse[loc], "RawJSON", KeyMemberQ[#,"assets"]||KeyMemberQ[#,"zipball_url"]&& (#["prerelease"]=!=True)& , IfAssociationQ@release, With{tmp=CreateDirectory[]}, First@MinimalBy[FileNameDepth]@Select[DirectoryQ]@ IfKeyMemberQ[release,"assets"]&&Length@release["assets"]>0, Withurl= release[["assets",-1,"browser_download_url"]] , ExtractArchive URLDownloadurl, FileNameJoin@ $TemporaryDirectory, URLParse[url,"Path"][[-1]] , tmp , ExtractArchive URLDownload release["zipball_url"], FileNameJoin@ $TemporaryDirectory, URLParse[release["zipball_url"],"Path"][[-1]] , tmp , $Failed , With dir= FileNameJoin@ $TemporaryDirectory, DeleteCases[URLParse[loc,"Path"],""][[2]] , Quiet DeleteDirectory[dir,DeleteContentsTrue]; CreateDirectory[dir] ; RunProcess[{"git","clone",loc,dir}]; dir ;
⌈wolframLibraryPull⌋
⌈downloadURLIfExists⌋
PDInstallPaclet
Options[PDInstallPaclet]= "Verbose"True, "InstallSite"True, "InstallDependencies"-> Automatic, "Log"True ;PDInstallPaclet loc:(_String|_File)?FileExistsQ, ops:OptionsPattern[] :=Replace installPacletGenerate[loc,ops], File[f_](f_String?FileExistsQ):> ReplacePacletManager`PacletInstall@f, p_PacletManager`Paclet Withdeps= ReplaceOptionValue["InstallDependencies"], Automatic{"Standard"}, TrueAll , IfMatchQ[deps,_List|All], Flatten@ p, With{l=PDpacletLookup[p,"Location"]}, IfFileExistsQ@FileNameJoin@{l,"DependencyInfo.m"}, ReplaceImport["DependencyInfo.m"], a_Association:> Switchdeps, All, Flatten@ Map[Map[PDInstallPaclet,#]&,a], _, Flatten@ MapPDInstallPaclet, Flatten@Lookup[a,deps,{}] , l_List:> Map[PDInstallPaclet,l] , {} , p ;PDInstallPaclet loc:(_String?(URLParse[#,"Scheme"]=!=None&)|_URL), ops:OptionsPattern[] :=Which URLParse[loc,"Domain"]==="github.com", Withdir= IfOptionValue@"Verbose"//TrueQ, Monitor gitPacletPull[loc], WhichPDgitHubRepoQ@loc, Internal`LoadingPanel TemplateApply["Cloning repository at ``",loc] , PDgitHubReleaseQ@loc, Internal`LoadingPanel TemplateApply["Pulling release at ``",loc] , True, Internal`LoadingPanel TemplateApply["Downloading from ``",loc] , gitPacletPull[loc] , PDInstallPaclet@dir , URLParse[loc,"Domain"]==="library.wolfram.com", Withdir= IfOptionValue@"Verbose"//TrueQ, Monitor wolframLibraryPull[loc], Internal`LoadingPanel TemplateApply["Downloading from library.wolfram.com ``",loc] , gitPacletPull[loc] , PDInstallPaclet@dir , True, If And OptionValue["InstallSite"]//TrueQ, MatchQ Quiet@PDpacletSiteInfo[loc], PacletManager`PacletSite[__PacletManager`Paclet] , PDpacletSiteInstall[loc], SwitchURLParse[loc,"Path"][[-1]], _?(FileExtension[#]"PDpaclet"&), PDInstallPaclet@URLDownload[loc], _?(MatchQ[FileExtension[#],"m"|"wl"]&), PDInstallPaclet@ downloadURLIfExists URLBuild ReplacePart#, "Path"-> Drop[#Path,-1] &@URLParse[loc] , URLParse[loc,"Path"][[-1]], "DependencyInfo.m", "PacletInfo.m" , _, Replace Quiet@Normal@PDpacletSiteInfoDataset[loc], Except[{__Association}]:> Message[PDInstallPaclet::nopac,loc]; $Failed , a:{__Association}:> PDInstallPaclet URLBuild@ Flatten@ loc, StringJoin@ LookupLast@SortBy[a,#Version&], "Name", "Version" , ".paclet" , ops ;