@@ -78,10 +78,10 @@ param(
7878
7979if ($App -ne ' *' -and (Test-Path $App - PathType Leaf)) {
8080 $Dir = Split-Path $App
81- $files = Get-ChildItem $Dir (Split-Path $App - Leaf)
81+ $files = Get-ChildItem $Dir - Filter (Split-Path $App - Leaf)
8282} elseif ($Dir ) {
83- $Dir = Resolve -Path $Dir
84- $files = Get-ChildItem $Dir " $App .json"
83+ $Dir = Convert -Path $Dir
84+ $files = Get-ChildItem $Dir - Filter " $App .json" - Recurse
8585} else {
8686 throw " '-Dir' parameter required if '-App' is not a filepath!"
8787}
@@ -97,9 +97,10 @@ if ($App -eq '*' -and $Version -ne '') {
9797$Queue = @ ()
9898$json = ' '
9999$files | ForEach-Object {
100- $json = parse_json " $Dir \$ ( $_.Name ) "
100+ $file = $_.FullName
101+ $json = parse_json $file
101102 if ($json.checkver ) {
102- $Queue += , @ ($_.Name , $json )
103+ $Queue += , @ ($_.BaseName , $json , $file )
103104 }
104105}
105106
@@ -109,7 +110,7 @@ Get-EventSubscriber | Unregister-Event
109110
110111# start all downloads
111112$Queue | ForEach-Object {
112- $name , $json = $_
113+ $name , $json , $file = $_
113114
114115 $substitutions = Get-VersionSubstitution $json.version # 'autoupdate.ps1'
115116
@@ -121,18 +122,32 @@ $Queue | ForEach-Object {
121122 }
122123 Register-ObjectEvent $wc downloadDataCompleted - ErrorAction Stop | Out-Null
123124
124- $githubRegex = ' \/releases\/tag\/(?:v|V)?([\d.]+)'
125-
126- $url = $json.homepage
125+ # Not Specified
127126 if ($json.checkver.url ) {
128127 $url = $json.checkver.url
128+ } else {
129+ $url = $json.homepage
130+ }
131+
132+ if ($json.checkver.re ) {
133+ $regex = $json.checkver.re
134+ } elseif ($json.checkver.regex ) {
135+ $regex = $json.checkver.regex
136+ } else {
137+ $regex = ' '
129138 }
130- $regex = ' '
139+
131140 $jsonpath = ' '
132141 $xpath = ' '
133142 $replace = ' '
134143 $useGithubAPI = $false
135144
145+ # GitHub
146+ if ($regex ) {
147+ $githubRegex = $regex
148+ } else {
149+ $githubRegex = ' /releases/tag/(?:v|V)?([\d.]+)'
150+ }
136151 if ($json.checkver -eq ' github' ) {
137152 if (! $json.homepage.StartsWith (' https://github.com/' )) {
138153 error " $name checkver expects the homepage to be a github repository"
@@ -148,11 +163,38 @@ $Queue | ForEach-Object {
148163 if ($json.checkver.PSObject.Properties.Count -eq 1 ) { $useGithubAPI = $true }
149164 }
150165
151- if ($json.checkver.re ) {
152- $regex = $json.checkver.re
166+ # SourceForge
167+ if ($regex ) {
168+ $sourceforgeRegex = $regex
169+ } else {
170+ $sourceforgeRegex = ' (?!\.)([\d.]+)(?<=\d)'
153171 }
154- if ($json.checkver.regex ) {
155- $regex = $json.checkver.regex
172+ if ($json.checkver -eq ' sourceforge' ) {
173+ if ($json.homepage -match ' //(sourceforge|sf)\.net/projects/(?<project>[^/]+)(/files/(?<path>[^/]+))?|//(?<project>[^.]+)\.(sourceforge\.(net|io)|sf\.net)' ) {
174+ $project = $Matches [' project' ]
175+ $path = $Matches [' path' ]
176+ } else {
177+ $project = strip_ext $name
178+ }
179+ $url = " https://sourceforge.net/projects/$project /rss"
180+ if ($path ) {
181+ $url = $url + ' ?path=/' + $path.TrimStart (' /' )
182+ }
183+ $regex = " CDATA\[/$path /.*?$sourceforgeRegex .*?\]" .Replace(' //' , ' /' )
184+ }
185+ if ($json.checkver.sourceforge ) {
186+ if ($json.checkver.sourceforge -is [System.String ] -and $json.checkver.sourceforge -match ' (?<project>[\w-]*)(/(?<path>.*))?' ) {
187+ $project = $Matches [' project' ]
188+ $path = $Matches [' path' ]
189+ } else {
190+ $project = $json.checkver.sourceforge.project
191+ $path = $json.checkver.sourceforge.path
192+ }
193+ $url = " https://sourceforge.net/projects/$project /rss"
194+ if ($path ) {
195+ $url = $url + ' ?path=/' + $path.TrimStart (' /' )
196+ }
197+ $regex = " CDATA\[/$path /.*?$sourceforgeRegex .*?\]" .Replace(' //' , ' /' )
156198 }
157199
158200 if ($json.checkver.jp ) {
@@ -165,7 +207,7 @@ $Queue | ForEach-Object {
165207 $xpath = $json.checkver.xpath
166208 }
167209
168- if ($json.checkver.replace -and $json .checkver.replace.GetType () -eq [System.String ]) {
210+ if ($json.checkver.replace -is [ System.String ]) { # If `checkver` is [System.String], it has a method called `Replace`
169211 $replace = $json.checkver.replace
170212 }
171213
@@ -185,7 +227,8 @@ $Queue | ForEach-Object {
185227 $url = substitute $url $substitutions
186228
187229 $state = New-Object psobject @ {
188- app = (strip_ext $name );
230+ app = $name ;
231+ file = $file ;
189232 url = $url ;
190233 regex = $regex ;
191234 json = $json ;
@@ -213,6 +256,7 @@ while ($in_progress -gt 0) {
213256
214257 $state = $ev.SourceEventArgs.UserState
215258 $app = $state.app
259+ $file = $state.file
216260 $json = $state.json
217261 $url = $state.url
218262 $regexp = $state.regex
@@ -319,7 +363,7 @@ while ($in_progress -gt 0) {
319363 # Skip actual only if versions are same and there is no -f
320364 if (($ver -eq $expected_ver ) -and ! $ForceUpdate -and $SkipUpdated ) { continue }
321365
322- Write-Host " $App `: " - NoNewline
366+ Write-Host " $app `: " - NoNewline
323367
324368 # version hasn't changed (step over if forced update)
325369 if ($ver -eq $expected_ver -and ! $ForceUpdate ) {
@@ -345,7 +389,7 @@ while ($in_progress -gt 0) {
345389 Write-Host ' Forcing autoupdate!' - ForegroundColor DarkMagenta
346390 }
347391 try {
348- Invoke-AutoUpdate $App $Dir $json $ver $matchesHashtable # 'autoupdate.ps1'
392+ Invoke-AutoUpdate $app $file $json $ver $matchesHashtable # 'autoupdate.ps1'
349393 } catch {
350394 if ($ThrowError ) {
351395 throw $_
0 commit comments