Compare commits

..

No commits in common. "d10cee65d58ed71996b48a2bbee89e67f8fdb5c2" and "d6de2f94115a637a32b965697b7b670c48f246cc" have entirely different histories.

View file

@ -1,7 +1,6 @@
Param( Param(
[string]$Java = 'java', [string]$Java = 'java',
[switch]$NoDeploy, [switch]$NoDeploy
[switch]$NoUpdate
) )
Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Windows.Forms
@ -65,22 +64,6 @@ class FormItems : System.Collections.ArrayList<#FormItem#> {
} }
return $rvalue return $rvalue
} }
FormItems() {}
FormItems([System.Collections.IEnumerable] $list) {
<#
.Description
Creates FormItems list with all items in list
where values are those items
and displaytext as string representation of them
TLDR it converts any list to FormItems
#>
foreach ($i in $list) {
[void] $this.Add([FormItem]::new($i, $i.ToString()))
}
}
} }
function renderForm([FormItems]$items, [String]$label, [String]$title, [System.Windows.Forms.SelectionMode]$mode) { function renderForm([FormItems]$items, [String]$label, [String]$title, [System.Windows.Forms.SelectionMode]$mode) {
@ -142,8 +125,8 @@ function renderForm([FormItems]$items, [String]$label, [String]$title, [System.W
} }
class config { class config {
[System.Collections.SortedList]$version [hashtable]$version = @{}
[System.Collections.SortedList]$included [System.Collections.ArrayList]$included = [System.Collections.ArrayList]::new()
} }
class configFile { class configFile {
@ -153,30 +136,19 @@ class configFile {
[void] load() { [void] load() {
$fileContent = ConvertFrom-Json ((Get-Content $this.path) -Join ' ').ToString() $fileContent = ConvertFrom-Json ((Get-Content $this.path) -Join ' ').ToString()
$version = [System.Collections.SortedList]::new() $version = @{}
foreach ($prop in $fileContent.version.PsObject.Properties) { foreach ($prop in $fileContent.version.PsObject.Properties) {
$version.Add($prop.Name, $prop.Value) $version.Add($prop.Name, $prop.Value)
} }
$this.config.version = $version $fileContent.version = $null
$included = [System.Collections.SortedList]::new() $this.config = $fileContent
foreach ($prop in $fileContent.included.PsObject.Properties) { $this.config.version = $version
$included.Add($prop.Name, $prop.Value)
}
$this.config.included = $included
} }
[void] save() { [void] save() {
Out-File $this.path -InputObject (ConvertTo-Json $this.config) Out-File $this.path -InputObject (ConvertTo-Json $this.config)
} }
[void] setIncludeForPackage([String] $packageName, [System.Collections.IEnumerable] $integrationNames) {
$this.config.included[$packageName] = $integrationNames.Clone()
}
[System.Collections.ArrayList] getIncludesForPackage([String] $packageName) {
return $this.config.included[$packageName].Clone()
}
} }
function UpdateFromGithub { function UpdateFromGithub {
@ -262,14 +234,6 @@ class Integration {
if ($compatiblePackage.length -eq 0 ) { return $false } if ($compatiblePackage.length -eq 0 ) { return $false }
return $compatiblePackage.Contains($version) return $compatiblePackage.Contains($version)
} }
[System.Collections.ArrayList] compatiblePackageNames() {
$rvalue =[System.Collections.ArrayList]::new($this.compatiblePackages.Count)
foreach ($i in $this.compatiblePackages) {
[void] $rvalue.Add($i.name)
}
return $rvalue
}
} }
class IntegrationList : System.Collections.ArrayList<#Integration#> { class IntegrationList : System.Collections.ArrayList<#Integration#> {
@ -321,26 +285,6 @@ class IntegrationList : System.Collections.ArrayList<#Integration#> {
} }
return $rvalue return $rvalue
} }
[FormItems] getForm([String] $packageName) {
$rvalue = [FormItems]::new()
foreach ($i in $this) {
if (-not $i.compatiblePackageNames().Contains($packageName)) { continue }
[void] $rvalue.Add([FormItem]::new($i.name, "$($i.name) - $($i.description)"))
}
return $rvalue
}
[System.Collections.ArrayList] getAllCompatiblePackagesNames() {
$rvalue = [System.Collections.ArrayList]::new()
foreach ($i in $this) {
foreach ($j in $i.compatiblePackages) {
if ($rvalue.Contains($j.name)) { continue }
[void] $rvalue.Add($j.name)
}
}
return $rvalue
}
} }
function main { function main {
@ -355,16 +299,14 @@ function main {
# Update # Update
if (-not $NoUpdate) { $updatedPatches = UpdateFromGithub -Repository "revanced/revanced-patches" -Config $config -AssetsFilter {$_.content_type -like "application/java-archive"} -OutFile ".\app\revanced-patches.jar"
$updatedPatches = UpdateFromGithub -Repository "revanced/revanced-patches" -Config $config -AssetsFilter {$_.content_type -like "application/java-archive"} -OutFile ".\app\revanced-patches.jar" if ($updatedPatches) {
if ($updatedPatches) { Invoke-WebRequest "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json" -OutFile ".\app\revanced-patches.json"
Invoke-WebRequest "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json" -OutFile ".\app\revanced-patches.json"
}
UpdateFromGithub -Repository "revanced/revanced-integrations" -Config $config -AssetsFilter {$_.content_type -like "application/*"} -OutFile ".\app\app-release-unsigned.apk" | Out-Null
UpdateFromGithub -Repository "revanced/revanced-cli" -Config $config -AssetsFilter {$_.content_type -like "application/*"} -OutFile ".\app\revanced-cli.jar" | Out-Null
} }
UpdateFromGithub -Repository "revanced/revanced-integrations" -Config $config -AssetsFilter {$_.content_type -like "application/*"} -OutFile ".\app\app-release-unsigned.apk" | Out-Null
UpdateFromGithub -Repository "revanced/revanced-cli" -Config $config -AssetsFilter {$_.content_type -like "application/*"} -OutFile ".\app\revanced-cli.jar" | Out-Null
if ($NoDeploy) {return} if ($NoDeploy) {return}
# Select apk to patch # Select apk to patch
@ -387,25 +329,18 @@ function main {
$integrations = [IntegrationList]::new(".\app\revanced-patches.json") $integrations = [IntegrationList]::new(".\app\revanced-patches.json")
# get package name
# FIXME: How to extract package name from its apk file?
$packageNamesForm = [FormItems]::new($integrations.getAllCompatiblePackagesNames())
$packageName = renderForm -items $packageNamesForm -label "Which package is it?" -title "Installer for ReVanced - package name" -mode One
# integrations selector # integrations selector
$integrationsToInclude = [System.Collections.ArrayList]::new() $integrationsToInclude = [System.Collections.ArrayList]::new()
$integrationsForm = $integrations.getForm($packageName) $integrationsForm = $integrations.getForm()
for ($i = 0; $i -lt $integrationsForm.Count; $i++) { for ($i = 0; $i -lt $integrationsForm.Count; $i++) {
if (-not $config.getIncludesForPackage($packageName).Contains(($integrationsForm[$i].value))) { continue } if (-not $config.config.included.Contains($integrationsForm[$i].value)) { continue }
$integrationsForm[$i].selected = $true $integrationsForm[$i].selected = $true
} }
$integrationsToInclude = renderForm -items $integrationsForm -label "Select integrations to include" -title "Installer for ReVanced - integrations" -mode MultiExtended $integrationsToInclude = renderForm -items $integrationsForm -label "Select integrations to include" -title "Installer for ReVanced - integrations" -mode MultiExtended
$config.setIncludeForPackage($packageName, $integrationsToInclude) $config.config.included = $integrationsToInclude
$config.save() $config.save()
# We save only what user selected, but we still need to include integrations that depends on selected # We save only what user selected, but we still need to include integrations that depends on selected