summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-03 15:43:31 +0800
committerGitHub <[email protected]>2023-03-03 15:43:31 +0800
commit9f5e98c4cc256d3321d4d5e23037304e723cdb93 (patch)
treeba75b96a4ea3dff980046258eccaf2bc6dc81218
parent7f879ef2a71a81b4d5ca10c22422cab59f9dff2e (diff)
parent0a572a391ef0519577474c8b9c22b8dcf8c2441b (diff)
Merge pull request #3450 from xq114/dev
update get.ps1
-rwxr-xr-xscripts/get.ps179
-rwxr-xr-xscripts/register-completions.ps143
2 files changed, 16 insertions, 106 deletions
diff --git a/scripts/get.ps1 b/scripts/get.ps1
index d117bfc45..a1fa1fa7d 100755
--- a/scripts/get.ps1
+++ b/scripts/get.ps1
@@ -11,7 +11,7 @@ param (
)
& {
- $LastRelease = "v2.7.6"
+ $LastRelease = "v2.7.7"
$ErrorActionPreference = 'Stop'
function writeErrorTip($msg) {
@@ -32,9 +32,9 @@ param (
if ($IsLinux -or $IsMacOS) {
writeErrorTip 'Install on *nix is not supported, try '
- writeErrorTip '(Use curl) "bash <(curl -fsSL https://raw.githubusercontent.com/xmake-io/xmake/master/scripts/get.sh)"'
+ writeErrorTip '(Use curl) "curl -fsSL https://xmake.io/shget.text | bash"'
writeErrorTip 'or'
- writeErrorTip '(Use wget) "bash <(wget https://raw.githubusercontent.com/xmake-io/xmake/master/scripts/get.sh -O -)"'
+ writeErrorTip '(Use wget) "wget https://xmake.io/shget.text -O - | bash"'
throw 'Unsupported platform'
}
@@ -85,9 +85,12 @@ param (
function xmakeInstall {
$outfile = Join-Path $temppath "$pid-xmake-installer.exe"
- $x64arch = @('AMD64', 'IA64', 'ARM64')
+ $x64arch = @('AMD64', 'IA64')
$arch = if ($env:PROCESSOR_ARCHITECTURE -in $x64arch -or $env:PROCESSOR_ARCHITEW6432 -in $x64arch) { 'x64' } else { 'x86' }
$winarch = if ($env:PROCESSOR_ARCHITECTURE -in $x64arch -or $env:PROCESSOR_ARCHITEW6432 -in $x64arch) { 'win64' } else { 'win32' }
+ if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') {
+ Write-Host "Unsupported host architecture detected: ARM64."
+ }
$url = if ($v -is [version]) {
"https://github.com/xmake-io/xmake/releases/download/v$v/xmake-v$v.$winarch.exe"
} else {
@@ -131,66 +134,16 @@ param (
}
function registerTabCompletion {
-
- function writeDataToFile($file) {
- $content = ''
- if (Test-Path $file -PathType Leaf) {
- $content = Get-Content $file -Raw
- }
-
- try {
- New-Item $(Split-Path $file -Parent) -ItemType Directory -Force | Out-Null
- Set-Content $file $content -NoNewline
- } catch {
- writeErrorTip "Failed to append to profile!"
- writeErrorTip "Please try again as administrator"
- return
- }
-
- if ($content) {
- $content = $content -replace "`n# >>> xmake >>>`n[\S\s]*?`n# <<< xmake <<<`n", ""
- }
- try {
- $url = if ($v -is [version]) {
- "https://fastly.jsdelivr.net/gh/xmake-io/xmake@v$v/scripts/register-completions.ps1"
- } else {
- "https://fastly.jsdelivr.net/gh/xmake-io/xmake@$v/scripts/register-completions.ps1"
- }
- $appendcontent = (Invoke-Webrequest $url -UseBasicParsing).Content
- if ($appendcontent -is [byte[]]) {
- $appendcontent = [System.Text.Encoding]::UTF8.GetString($appendcontent)
- }
- } catch {
- writeErrorTip 'Download failed!'
- writeErrorTip 'Check your network or... the news of S3 break'
- return
- }
- Set-Content $file "$content`n# >>> xmake >>>`n$appendcontent`n# <<< xmake <<<`n" -NoNewline
- . $file
- Write-Host "Tab completion installed"
- }
- $message = 'Tab completion service'
- $question = 'Would you like to install tab completion service of xmake to your profile?'
-
- $choices = @(
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- 'For &all users',
- "Install for all users, writes to $($PROFILE.AllUsersAllHosts), admin privilege is needed.")),
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- 'Just for &me',
- "Install for current user, writes to $($PROFILE.CurrentUserAllHosts).")),
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- 'Just for this &host',
- "Install for current user current host, writes to $($PROFILE.CurrentUserCurrentHost).")),
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- '&No',
- "Do not install xmake's tab completion service."))
- )
- switch ($Host.UI.PromptForChoice($message, $question, $choices, 1)) {
- 0 { writeDataToFile($PROFILE.AllUsersAllHosts) }
- 1 { writeDataToFile($PROFILE.CurrentUserAllHosts) }
- 2 { writeDataToFile($PROFILE.CurrentUserCurrentHost) }
+ # TODO: add --global --user choice
+ Write-Host "Tab completion service"
+ try {
+ xmake update --integrate
+ } catch {
+ writeErrorTip "Failed to register tab completion!"
+ writeErrorTip 'Please try "xmake update --integrate" to register manually.'
+ return
}
+ Write-Host "Tab completion installed"
}
checkTempAccess
diff --git a/scripts/register-completions.ps1 b/scripts/register-completions.ps1
deleted file mode 100755
index 201f291cd..000000000
--- a/scripts/register-completions.ps1
+++ /dev/null
@@ -1,43 +0,0 @@
-# PowerShell parameter completion for xmake
-Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock {
- param($commandName, $wordToComplete, $cursorPosition)
- $complete = "$wordToComplete"
- if (-not $commandName) {
- $complete = $complete + " "
- }
- $oldenv = $env:XMAKE_SKIP_HISTORY
- $env:XMAKE_SKIP_HISTORY = 1
- $results = xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value
- $results | ForEach-Object {
- $hasdesc = [bool] $_.psobject.Properties['description']
- if ($hasdesc) {
- $desc = " - $($_.description)"
- } else {
- $desc = ""
- }
- [System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
- }
- $env:XMAKE_SKIP_HISTORY = $oldenv
-}
-
-# PowerShell parameter completion for xrepo
-Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock {
- param($commandName, $wordToComplete, $cursorPosition)
- $complete = "$wordToComplete"
- if (-not $commandName) {
- $complete = $complete + " "
- }
- $oldenv = $env:XMAKE_SKIP_HISTORY
- $env:XMAKE_SKIP_HISTORY = 1
- $results = xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value
- $results | ForEach-Object {
- $hasdesc = [bool] $_.psobject.Properties['description']
- if ($hasdesc) {
- $desc = " - $($_.description)"
- } else {
- $desc = ""
- }
- [System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
- }
- $env:XMAKE_SKIP_HISTORY = $oldenv
-} \ No newline at end of file