diff --git a/.github/workflows/delete-issues.ps1 b/.github/workflows/delete-issues.ps1 new file mode 100644 index 00000000..5ad1ac41 --- /dev/null +++ b/.github/workflows/delete-issues.ps1 @@ -0,0 +1,24 @@ +const issueTitle = context.payload.issue.title.trim(); +const isSingleWord = /^\S+$/.test(issueTitle); + +if (isSingleWord) { +const issueNumber = context.payload.issue.number; +const repo = context.repo.repo; + +// Close the issue and add the invalid label +github.rest.issues.update({ +owner: context.repo.owner, +repo: repo, +issue_number: issueNumber, +labels: ['invalid'], +state: 'closed' +}); + +// Comment on the issue +await github.rest.issues.createComment({ +owner: context.repo.owner, +repo: repo, +issue_number: issueNumber, +body: `This issue may have been opened accidentally. I'm going to close it now, but feel free to open a new issue with a more descriptive title.` +}); +} \ No newline at end of file diff --git a/.github/workflows/wingetcreate.ps1 b/.github/workflows/wingetcreate.ps1 new file mode 100644 index 00000000..412b8c3b --- /dev/null +++ b/.github/workflows/wingetcreate.ps1 @@ -0,0 +1,46 @@ +# Set the package ID based on the release info +$packageId = if ('${{ !github.event.release.prerelease }}' -eq 'true') { 'GitHub.Copilot' } else { 'GitHub.Copilot.Prerelease' } + +# Get installer info from release event +$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json +$packageVersion = (${{ toJSON(github.event.release.tag_name) }}) + +# Find the download URLs for the x64 and arm64 installers separately +# This allows overrides to be used so that wingetcreate does not have to guess the architecture from the filename +$installerUrlx64 = $assets | Where-Object -Property name -like '*win32-x64.zip' | Select-Object -ExpandProperty browser_download_url +$installerUrlarm64 = $assets | Where-Object -Property name -like '*win32-arm64.zip' | Select-Object -ExpandProperty browser_download_url + +# Update package using wingetcreate +curl.exe -JLO https://aka.ms/wingetcreate/latest +.\wingetcreate.exe update $packageId ` +--version $packageVersion ` +--urls "$installerUrlx64|x64" "$installerUrlarm64|arm64" ` +--out manifests + +# Add PowerShell dependency to installer manifest + +$installerManifest = Get-ChildItem -Path manifests -Filter "*.installer.yaml" -Recurse | Select-Object -First 1 -ExpandProperty FullName +if (-not $installerManifest) { +Write-Error "No installer manifest (*.installer.yaml) was found in the 'manifests' directory." +exit 1 +} +$content = Get-Content -Path $installerManifest -Raw +$dependency = @" + Dependencies: + PackageDependencies: + - PackageIdentifier: Microsoft.PowerShell + MinimumVersion: "7.0.0" + "@ + +# Remove existing top-level Dependencies block (if any), then insert ours + +$content = $content -replace '(?m)^Dependencies:\r?\n([ ]+.+\r?\n)*', '' +$content = $content -replace '(?m)^Installers:', "$dependency`nInstallers:" + +Set-Content -Path $installerManifest -Value $content + +# Submit the modified manifest + +$manifestPath = Split-Path $installerManifest + +.\wingetcreate.exe submit $manifestPath \ No newline at end of file diff --git a/Activate.ps1 b/Activate.ps1 new file mode 100644 index 00000000..bd30e2ee --- /dev/null +++ b/Activate.ps1 @@ -0,0 +1,61 @@ +$script:THIS_PATH = $myinvocation.mycommand.path +$script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent + +function global:deactivate([switch] $NonDestructive) { + if (Test-Path variable:_OLD_VIRTUAL_PATH) { + $env:PATH = $variable:_OLD_VIRTUAL_PATH + Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global + } + + if (Test-Path function:_old_virtual_prompt) { + $function:prompt = $function:_old_virtual_prompt + Remove-Item function:\_old_virtual_prompt + } + + if ($env:VIRTUAL_ENV) { + Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue + } + + if ($env:VIRTUAL_ENV_PROMPT) { + Remove-Item env:VIRTUAL_ENV_PROMPT -ErrorAction SilentlyContinue + } + + if (!$NonDestructive) { + # Self destruct! + Remove-Item function:deactivate + Remove-Item function:pydoc + } +} + +function global:pydoc { + python -m pydoc $args +} + +# unset irrelevant variables +deactivate -nondestructive + +$VIRTUAL_ENV = $BASE_DIR +$env:VIRTUAL_ENV = $VIRTUAL_ENV + +if (__VIRTUAL_PROMPT__ -ne "") { + $env:VIRTUAL_ENV_PROMPT = __VIRTUAL_PROMPT__ +} +else { + $env:VIRTUAL_ENV_PROMPT = $( Split-Path $env:VIRTUAL_ENV -Leaf ) +} + +New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH + +$env:PATH = "$env:VIRTUAL_ENV/" + __BIN_NAME__ + __PATH_SEP__ + $env:PATH +if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) { + function global:_old_virtual_prompt { + "" + } + $function:_old_virtual_prompt = $function:prompt + + function global:prompt { + # Add the custom prefix to the existing prompt + $previous_prompt_value = & $function:_old_virtual_prompt + ("(" + $env:VIRTUAL_ENV_PROMPT + ") " + $previous_prompt_value) + } +}