Skip to content

Commit

Permalink
(1password) Change to meta package
Browse files Browse the repository at this point in the history
This updates the 1password package to be a meta package that will have a
dependency on the installation packages of the different 1password major
version packages.

This has been written in a way to attempt to make it easy to add
additional major version packages without having to make any changes to
the meta package manually.
  • Loading branch information
AdmiringWorm committed Sep 26, 2024
1 parent 88ba50c commit 01e39c4
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 143 deletions.
6 changes: 3 additions & 3 deletions automatic/1password/1password.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"OPW": "7.9.835",
"OPW4": "4.6.2.626"
{
"OPW4": "4.6.2.62600",
"OPW7": "7.9.835"
}
11 changes: 4 additions & 7 deletions automatic/1password/1password.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@
- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**
]]></description>
<summary>1Password - Have you ever forgotten a password?</summary>
<copyright2021 AgileBits, Inc. All rights reserved.</copyright>
<tags>1password password keystore keys saver admin trial cross-platform</tags>
<copyright 2024 1Password. All rights reserved.</copyright>
<tags>1password utility trial cross-platform password keystore keys</tags>
<packageSourceUrl>https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/1password</packageSourceUrl>
<dependencies>
<dependency id="dotnet4.7.2" version="4.7.2.20180712" />
<dependency id="chocolatey-core.extension" version="1.3.3" />
<dependency id="1password" version="0.0" />
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
<files />
</package>
11 changes: 0 additions & 11 deletions automatic/1password/Readme.md

This file was deleted.

Binary file removed automatic/1password/screenshot.png
Binary file not shown.
39 changes: 0 additions & 39 deletions automatic/1password/tools/chocolateyInstall.ps1

This file was deleted.

28 changes: 0 additions & 28 deletions automatic/1password/tools/chocolateyUninstall.ps1

This file was deleted.

93 changes: 44 additions & 49 deletions automatic/1password/update.ps1
Original file line number Diff line number Diff line change
@@ -1,70 +1,65 @@
Import-Module Chocolatey-AU
import-module $PSScriptRoot\..\..\extensions\chocolatey-core.extension\extensions\chocolatey-core.psm1
param($IncludeStream = $global:au_IncludeStream, $Force)

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(?i)^(\s*url\s*=\s*)'.*'" = "`${1}'$($Latest.URL32)'"
"(?i)^(\s*checksum\s*=\s*)'.*'" = "`${1}'$($Latest.Checksum32)'"
"(?i)^(\s*checksumType\s*=\s*)'.*'" = "`${1}'$($Latest.ChecksumType32)'"
"(?i)^(\s*silentArgs\s*=\s*)['`"].*['`"]" = "`${1}`"$($Latest.SilentArgs)`""
}
}
}
Import-Module Chocolatey-AU

function global:au_AfterUpdate {
. "$PSScriptRoot/update_helper.ps1"
if ($Latest.PackageName -eq '1password4') {
removeDependencies ".\*.nuspec"
addDependency ".\*.nuspec" "chocolatey-core.extension" "1.3.3"
if (($IncludeStream -match "^OPW(?<major>\d+)") -and (Test-Path "$PSScriptRoot\..\..\manual\1password$($Matches['major'])")) {
# Since this is a manual package, we will assume that the package itself needs to be updated.
Push-Location "$PSScriptRoot\..\..\manual\1password$($Matches['major'])"
try {
$oldVersion = $global:au_Version
. "./update.ps1" -NoUpdateCheck

if ($oldVersion) {
$global:au_Version = $oldVersion
} else {
$global:au_Version = $global:Latest.Version.ToString()
}
$global:au_Latest = $null
$global:Latest = $null
}
else {
addDependency ".\*.nuspec" 'dotnet4.7.2' '4.7.2.20180712'
finally {
Pop-Location
}
}

function global:au_BeforeUpdate {
if ($Latest.PackageName -eq '1password4') {
$Latest.SilentArgs = '/VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /LOG=`"$($env:TEMP)\$($env:chocolateyPackageName).$($env:chocolateyPackageVersion).InnoInstall.log`"'
}
else {
$Latest.SilentArgs = '--silent'
else {
Get-ChildItem "$PSScriptRoot\..\1password*" | Where-Object { $_.Name -ne '1password' } | ForEach-Object {
. "$_\update.ps1"
}
}

function Get-LatestOPW {
param (
[string]$url,
[string]$kind
function global:au_BeforeUpdate($Package) {
# This is done in the before update, otherwise the dependency is not updated.
$readmePath = $Latest.Readme

)

$url32 = Get-RedirectedUrl $url
$verRe = 'Setup-|word-|\.exe$'
$version = $url32 -split $verRe | Select-Object -last 1 -skip 1
$version = $version -replace ('\.BETA', ' beta')
$version = Get-Version $version
$major = $version.ToString(1)
if ($readmePath -and (Test-Path $readmePath)) {
Set-DescriptionFromReadme $Package -SkipFirst 2 -ReadmePath $readmePath
}
}

function global:au_SearchReplace {
@{
URL32 = $url32
Version = $version.ToString()
PackageName = $kind
"$($Latest.PackageName).nuspec" = @{
"(?i)(\<dependency .+?)`"1password\d*(`" version=)`"([^`"]+)`"" = "`$1`"$($Latest.DependencyName)`$2`"[$($Latest.Version)]`""
}
}
}

$releases_opw4 = 'https://app-updates.agilebits.com/download/OPW4'
$kind_opw4 = '1password4'
$releases_opw = 'https://app-updates.agilebits.com/download/OPW7/Y'
$kind_opw = '1password'
function global:au_AfterUpdate {
. "$PSScriptRoot\..\..\scripts\Update-IconUrl.ps1" -Name '1password' -IconName $Latest.DependencyName -ThrowErrorOnIconNotFound
}


function global:au_GetLatest {
$streams = [ordered] @{
OPW4 = Get-LatestOPW -url $releases_opw4 -kind $kind_opw4
OPW = Get-LatestOPW -url $releases_opw -kind $kind_opw
$commands = Get-Command "Find-1Password*"

$streams = @{}

$null = $commands | ForEach-Object {
$result = & $_
$streams.Add('OPW' + $result.VersionMajor, $result)
}

return @{ Streams = $streams }
}

update -ChecksumFor 32 -IncludeStream $IncludeStream -Force:$Force
update -ChecksumFor None -IncludeStream $IncludeStream -Force:$Force
7 changes: 1 addition & 6 deletions automatic/1password/update_helper.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
function Get-LatestOPW {
param (
[Parameter(Mandatory)]
[string]$url,
[string]$PackageName = $null
[string]$url

)

Expand All @@ -20,10 +19,6 @@
RemoteVersion = $version
}

if ($PackageName) {
$result['PackageName'] = $PackageName
}

$result
}

Expand Down

0 comments on commit 01e39c4

Please sign in to comment.