From 17d3498f2afd8b0c99bfae9a1ef9ba816516de9d Mon Sep 17 00:00:00 2001 From: leoleoleo Date: Fri, 8 Sep 2023 09:59:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9vscode=20insiders?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscode-remote.sh | 10 ++++++++-- vscode.bat | 23 +++++++++++++++-------- vscode.sh | 19 +++++++++++++------ 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/vscode-remote.sh b/vscode-remote.sh index c79c7f2..e24c9a4 100755 --- a/vscode-remote.sh +++ b/vscode-remote.sh @@ -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) diff --git a/vscode.bat b/vscode.bat index 9f2dcaa..058dfca 100644 --- a/vscode.bat +++ b/vscode.bat @@ -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 diff --git a/vscode.sh b/vscode.sh index 17c2b61..545eb81 100755 --- a/vscode.sh +++ b/vscode.sh @@ -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"