Skip to content

Commit ac58180

Browse files
authored
Merge pull request #77 from EUCPilots/updates
Replace Mendeley Desktop with Reference Manager
2 parents 7e84a3d + 528dcf3 commit ac58180

File tree

4 files changed

+155
-56
lines changed

4 files changed

+155
-56
lines changed

Apps/Get-MendeleyDesktop.ps1

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
function Get-MendeleyReferenceManager {
2+
<#
3+
.SYNOPSIS
4+
Get the current version and download URL for Mendeley Reference Manager.
5+
#>
6+
[OutputType([System.Management.Automation.PSObject])]
7+
[CmdletBinding(SupportsShouldProcess = $false)]
8+
param (
9+
[Parameter(Mandatory = $false, Position = 0)]
10+
[ValidateNotNull()]
11+
[System.Management.Automation.PSObject]
12+
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
13+
)
14+
15+
# Get the latest update info
16+
$UpdateYaml = Invoke-EvergreenRestMethod -Uri $res.Get.Update.Uri
17+
18+
# Build a PSCustomObject from the YAML content
19+
if ($null -ne $UpdateYaml) {
20+
Write-Verbose -Message "$($MyInvocation.MyCommand): Converting YAML content to object."
21+
22+
$lines = $UpdateYaml -split "`r?`n"
23+
$result = @{
24+
Version = $null
25+
ReleaseDate = $null
26+
Downloads = @()
27+
}
28+
$currentDownload = $null
29+
$inDownloadsSection = $false
30+
foreach ($line in $lines) {
31+
# Skip empty lines and comments
32+
if ([System.String]::IsNullOrWhiteSpace($line) -or $line.TrimStart() -match '^#') {
33+
continue
34+
}
35+
36+
# Extract version (various common formats)
37+
if ($line -match '^\s*version\s*:\s*[''"]?([^''"]+)[''"]?\s*$') {
38+
$result.Version = $matches[1].Trim()
39+
}
40+
41+
# Extract release date (various common formats)
42+
if ($line -match '^\s*(?:release_?date|releaseDate|date)\s*:\s*[''"]?([^''"]+)[''"]?\s*$') {
43+
$result.ReleaseDate = $matches[1].Trim()
44+
}
45+
46+
# Detect downloads section
47+
if ($line -match '^\s*files\s*:\s*$') {
48+
$inDownloadsSection = $true
49+
continue
50+
}
51+
52+
if ($inDownloadsSection) {
53+
# New download entry (starts with dash or hyphen at specific indentation)
54+
if ($line -match '^\s*-\s*(?:url\s*:\s*(.+)|$)') {
55+
# Save previous download if exists
56+
if ($currentDownload -and ($currentDownload.url -or $currentDownload.sha512 -or $currentDownload.size)) {
57+
$result.Downloads += [PSCustomObject]$currentDownload
58+
}
59+
60+
# Start new download
61+
$currentDownload = @{
62+
url = $null
63+
sha512 = $null
64+
size = $null
65+
}
66+
67+
# Check if url is on the same line
68+
if ($matches[1]) {
69+
$currentDownload.url = $matches[1].Trim(' ''"`t')
70+
}
71+
}
72+
# URL property
73+
elseif ($line -match '^\s+url\s*:\s*(.+)$') {
74+
if ($currentDownload) {
75+
$currentDownload.url = $matches[1].Trim(' ''"`t')
76+
}
77+
}
78+
# SHA512 property
79+
elseif ($line -match '^\s+sha512\s*:\s*(.+)$') {
80+
if ($currentDownload) {
81+
$currentDownload.sha512 = $matches[1].Trim(' ''"`t')
82+
}
83+
}
84+
# Size property
85+
elseif ($line -match '^\s+size\s*:\s*(.+)$') {
86+
if ($currentDownload) {
87+
$sizeValue = $matches[1].Trim(' ''"`t')
88+
# Try to convert to number if possible
89+
if ($sizeValue -match '^\d+$') {
90+
$currentDownload.size = [int64]$sizeValue
91+
}
92+
else {
93+
$currentDownload.size = $sizeValue
94+
}
95+
}
96+
}
97+
# End of downloads section (non-indented key or end of indented section)
98+
elseif ($line -match '^\S' -and $line -notmatch '^\s*-') {
99+
# Save the last download entry
100+
if ($currentDownload -and ($currentDownload.url -or $currentDownload.sha512 -or $currentDownload.size)) {
101+
$result.Downloads += [PSCustomObject]$currentDownload
102+
}
103+
$inDownloadsSection = $false
104+
$currentDownload = $null
105+
}
106+
}
107+
}
108+
109+
# Save the last download entry if still in downloads section
110+
if ($inDownloadsSection -and $currentDownload -and ($currentDownload.url -or $currentDownload.sha512 -or $currentDownload.size)) {
111+
$result.Downloads += [PSCustomObject]$currentDownload
112+
}
113+
114+
# Return the final object that we can use to build the output
115+
Write-Verbose -Message "$($MyInvocation.MyCommand): Converted YAML to PSCustomObject."
116+
$YamlObject = [PSCustomObject]$result
117+
118+
# Build output objects, filtering the .Downloads to unique entries
119+
foreach ($File in ($YamlObject.Downloads | Select-Object -Unique -Property "size", "sha512", "url")) {
120+
[PSCustomObject]@{
121+
Version = $YamlObject.Version
122+
Date = ConvertTo-DateTime -DateTime $YamlObject.ReleaseDate -Pattern $res.Get.Update.DateTimeFormat
123+
Size = $File.size
124+
Sha512 = $File.sha512
125+
Architecture = Get-Architecture -String $File.url
126+
Type = Get-FileType -File $File.url
127+
URI = $res.Get.Download.Uri -replace "#filename", $File.url
128+
}
129+
}
130+
}
131+
}

Manifests/MendeleyDesktop.json

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"Name": "Mendeley Reference Manager",
3+
"Source": "https://www.mendeley.com/reference-management/reference-manager",
4+
"Get": {
5+
"Update": {
6+
"Uri": "https://static.mendeley.com/bin/desktop/latest.yml",
7+
"DateTimeFormat": "yyyy-MM-ddTHH:mm:ss.fffZ"
8+
},
9+
"Download": {
10+
"Uri": "https://static.mendeley.com/bin/desktop/#filename"
11+
}
12+
},
13+
"Install": {
14+
"Setup": "Mendeley-Reference-Manager*.exe",
15+
"Physical": {
16+
"Arguments": "/S",
17+
"PostInstall": []
18+
},
19+
"Virtual": {
20+
"Arguments": "/S",
21+
"PostInstall": []
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)