mirror of
https://github.com/pengzhile/cocopilot.git
synced 2025-01-19 03:15:52 +08:00
添加对vscode insiders的支持
This commit is contained in:
parent
63a1aa5134
commit
17d3498f2a
@ -3,9 +3,15 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
EXTENSIONS_DIR="$HOME/.vscode-server/extensions"
|
EXTENSIONS_DIR="$HOME/.vscode-server/extensions"
|
||||||
|
INSIDERS_EXTENSIONS_DIR="$HOME/.vscode-server-insiders/extensions"
|
||||||
|
|
||||||
if [ ! -d "$EXTENSIONS_DIR" ]; then
|
if [ ! -d "$EXTENSIONS_DIR" ]; then
|
||||||
echo "ERROR: VSCode extensions directory not found!"
|
if [ ! -d "$INSIDERS_EXTENSIONS_DIR" ]; then
|
||||||
exit 1
|
echo "ERROR: Both VSCode and VSCode Insiders extensions directories not found!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
EXTENSIONS_DIR="$INSIDERS_EXTENSIONS_DIR"
|
||||||
|
fi
|
||||||
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)
|
COPILOT_DIR=$(ls -lt "$EXTENSIONS_DIR" | grep '^d' | awk '{print $9}' | grep -E '^github\.copilot-[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
|
||||||
|
23
vscode.bat
23
vscode.bat
@ -2,15 +2,21 @@
|
|||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
set extensions_dir=%userprofile%\.vscode\extensions
|
set extensions_dir=%userprofile%\.vscode\extensions
|
||||||
|
set insiders_extensions_dir=%userprofile%\.vscode-insiders\extensions
|
||||||
|
|
||||||
if not exist "%extensions_dir%" (
|
if not exist "%extensions_dir%" (
|
||||||
echo ERROR: VSCode extensions directory not found!
|
if not exist "%insiders_extensions_dir%" (
|
||||||
pause
|
echo ERROR: Both VSCode and VSCode Insiders extensions directories not found!
|
||||||
exit /b 1
|
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 (
|
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
|
set copilot_dir=%%a
|
||||||
goto :found
|
goto :found
|
||||||
)
|
)
|
||||||
|
|
||||||
echo ERROR: Copilot extension not found!
|
echo ERROR: Copilot extension not found!
|
||||||
@ -21,11 +27,12 @@ exit /b 1
|
|||||||
set copilot_dir=%extensions_dir%\%copilot_dir%
|
set copilot_dir=%extensions_dir%\%copilot_dir%
|
||||||
set extension_file=%copilot_dir%\dist\extension.js
|
set extension_file=%copilot_dir%\dist\extension.js
|
||||||
if not exist "%extension_file%" (
|
if not exist "%extension_file%" (
|
||||||
echo ERROR: Copilot extension entry file not found!
|
echo ERROR: Copilot extension entry file not found!
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
echo please be patient...
|
echo please be patient...
|
||||||
|
|
||||||
set tmp_file=%copilot_dir%\dist\extension.js.tmp
|
set tmp_file=%copilot_dir%\dist\extension.js.tmp
|
||||||
|
19
vscode.sh
19
vscode.sh
@ -3,24 +3,31 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
EXTENSIONS_DIR="$HOME/.vscode/extensions"
|
EXTENSIONS_DIR="$HOME/.vscode/extensions"
|
||||||
|
INSIDERS_EXTENSIONS_DIR="$HOME/.vscode-insiders/extensions"
|
||||||
|
|
||||||
if [ ! -d "$EXTENSIONS_DIR" ]; then
|
if [ ! -d "$EXTENSIONS_DIR" ]; then
|
||||||
echo "ERROR: VSCode extensions directory not found!"
|
if [ ! -d "$INSIDERS_EXTENSIONS_DIR" ]; then
|
||||||
exit 1
|
echo "ERROR: Both VSCode and VSCode Insiders extensions directories not found!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
EXTENSIONS_DIR="$INSIDERS_EXTENSIONS_DIR"
|
||||||
|
fi
|
||||||
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)
|
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
|
if [ -z "$COPILOT_DIR" ]; then
|
||||||
echo "ERROR: Copilot extension not found!"
|
echo "ERROR: Copilot extension not found!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COPILOT_DIR="$EXTENSIONS_DIR/$COPILOT_DIR"
|
COPILOT_DIR="$EXTENSIONS_DIR/$COPILOT_DIR"
|
||||||
EXTENSION_FILE="$COPILOT_DIR/dist/extension.js"
|
EXTENSION_FILE="$COPILOT_DIR/dist/extension.js"
|
||||||
if [ ! -f "$EXTENSION_FILE" ]; then
|
if [ ! -f "$EXTENSION_FILE" ]; then
|
||||||
echo "ERROR: Copilot extension entry file not found!"
|
echo "ERROR: Copilot extension entry file not found!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
TMP_FILE="$COPILOT_DIR/dist/extension.js.tmp"
|
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"
|
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"
|
cat "$EXTENSION_FILE" >> "$TMP_FILE"
|
||||||
|
Loading…
Reference in New Issue
Block a user