添加对vscode insiders的支持

This commit is contained in:
leoleoleo 2023-09-08 09:59:36 +08:00
parent 63a1aa5134
commit 17d3498f2a
3 changed files with 36 additions and 16 deletions

View File

@ -3,9 +3,15 @@
set -e
EXTENSIONS_DIR="$HOME/.vscode-server/extensions"
INSIDERS_EXTENSIONS_DIR="$HOME/.vscode-server-insiders/extensions"
if [ ! -d "$EXTENSIONS_DIR" ]; then
echo "ERROR: VSCode extensions directory not found!"
exit 1
if [ ! -d "$INSIDERS_EXTENSIONS_DIR" ]; then
echo "ERROR: Both VSCode and VSCode Insiders extensions directories not found!"
exit 1
else
EXTENSIONS_DIR="$INSIDERS_EXTENSIONS_DIR"
fi
fi
COPILOT_DIR=$(ls -lt "$EXTENSIONS_DIR" | grep '^d' | awk '{print $9}' | grep -E '^github\.copilot-[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)

View File

@ -2,15 +2,21 @@
setlocal
set extensions_dir=%userprofile%\.vscode\extensions
set insiders_extensions_dir=%userprofile%\.vscode-insiders\extensions
if not exist "%extensions_dir%" (
echo ERROR: VSCode extensions directory not found!
pause
exit /b 1
if not exist "%insiders_extensions_dir%" (
echo ERROR: Both VSCode and VSCode Insiders extensions directories not found!
pause
exit /b 1
) else (
set extensions_dir=%insiders_extensions_dir%
)
)
for /f "tokens=*" %%a in ('dir /b /ad "%extensions_dir%" ^| findstr /r /c:"^github\.copilot-[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$"') do (
set copilot_dir=%%a
goto :found
set copilot_dir=%%a
goto :found
)
echo ERROR: Copilot extension not found!
@ -21,11 +27,12 @@ exit /b 1
set copilot_dir=%extensions_dir%\%copilot_dir%
set extension_file=%copilot_dir%\dist\extension.js
if not exist "%extension_file%" (
echo ERROR: Copilot extension entry file not found!
pause
exit /b 1
echo ERROR: Copilot extension entry file not found!
pause
exit /b 1
)
echo please be patient...
set tmp_file=%copilot_dir%\dist\extension.js.tmp

View File

@ -3,24 +3,31 @@
set -e
EXTENSIONS_DIR="$HOME/.vscode/extensions"
INSIDERS_EXTENSIONS_DIR="$HOME/.vscode-insiders/extensions"
if [ ! -d "$EXTENSIONS_DIR" ]; then
echo "ERROR: VSCode extensions directory not found!"
exit 1
if [ ! -d "$INSIDERS_EXTENSIONS_DIR" ]; then
echo "ERROR: Both VSCode and VSCode Insiders extensions directories not found!"
exit 1
else
EXTENSIONS_DIR="$INSIDERS_EXTENSIONS_DIR"
fi
fi
COPILOT_DIR=$(ls -lt "$EXTENSIONS_DIR" | grep '^d' | awk '{print $9}' | grep -E '^github\.copilot-[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ -z "$COPILOT_DIR" ]; then
echo "ERROR: Copilot extension not found!"
exit 1
echo "ERROR: Copilot extension not found!"
exit 1
fi
COPILOT_DIR="$EXTENSIONS_DIR/$COPILOT_DIR"
EXTENSION_FILE="$COPILOT_DIR/dist/extension.js"
if [ ! -f "$EXTENSION_FILE" ]; then
echo "ERROR: Copilot extension entry file not found!"
exit 1
echo "ERROR: Copilot extension entry file not found!"
exit 1
fi
TMP_FILE="$COPILOT_DIR/dist/extension.js.tmp"
echo 'process.env.CODESPACES="true";process.env.GITHUB_TOKEN="ghu_ThisIsARealFreeCopilotKeyByCoCopilot";process.env.GITHUB_SERVER_URL="https://github.com";process.env.GITHUB_API_URL="https://api.cocopilot.org";' > "$TMP_FILE"
cat "$EXTENSION_FILE" >> "$TMP_FILE"