脱机下载vscode二进制文件和扩展。
vscod的Python项目详细描述
vscod
vscod缩写为visualstudiocodeofflinedownloader。此工具将允许您下载批扩展以及vscode二进制文件,以便以后可以使用它们安装您喜爱的编辑器及其扩展。 如果您是一个沮丧的管理员,需要更新本地工件存储库,如果您没有从您的站点访问官方存储库的权限,并且需要手动传递东西,或者如果您是一个自动化怪胎,并且出于某种原因想搅乱visual studio市场,则此工具可能会有很大帮助。
我试图找到一个工具来实现这一点,当我失败时,我试图至少找到一个方便的api来使用,但令我惊讶的是,在写这几行的时候,市场上还没有一个api(如果你找到了,请随意发送一个pr!),所以我最后写了vscod!
安装
使用python包管理器pip安装vscod
。
pip install vscod
用法
外壳
# Display the help vscod --help # Download the insider binaries for Linux (64bit deb), Windows (32bit) and Mac to the 'downloads' dir. vscod download editor --output 'downloads' --build insider linux-deb-x64 win32-archive darwin # Download the official Python extension and the Vim keymap to the 'extensions' dir. vscod download extensions --output 'extensions' ms-python.python vscodevim.vim # Download the requested config data (see below) to the current directory (the default path if none is specified btw). vscod download config --output '.' /path/to/config.json # List all the supported platform and build strings. vscod list-opts
Python
fromvscodimportextensions_downloader,vscode_downloaderfromvscod.vscode_downloaderimportBUILDS,PLATFORMS,LATEST_VERSIONimportasyncioimportaiohttpasyncdefvscod_demo():asyncwithaiohttp.ClientSession()assession:# It's all asynchronous!# Download the latest version of the official Python extension to the path.awaitextensions_downloader.download_extension_by_id(session,'ms-python.python','latest','/path/to/save')# Find what the latest version of the Vim keymap is.vim_version=awaitextensions_downloader.get_extension_version(session,'vscodevim.vim')# Download the latest stable Linux deb version to the path.awaitvscode_downloader.download_vscode(session,PLATFORMS.LINUX64_DEB,'/path/to/save',build=BUILDS.STABLE,version=LATEST_VERSION)asyncio.run(vscod_demo())
配置
您还可以提供类似如下的json配置:
{"vscode":[{"platform":"linux-deb-x64"},{"platform":"win32-x64-user","version":"latest","build":"stable"}],"extensions":{"gitlens":"eamodio.gitlens","languages":{"go":"ms-vscode.go","python":{"python":"ms-python.python","auto_docstring":"njpwerner.autodocstring"}}}}
顶层"vscode"
和"extensions"
分别表示这些是编辑器和扩展下载设置(duh)。
然后,解析过程如下:
- 对于扩展:
- 递归地检查加载的词典项:
- 如果值是字符串,则得到扩展名id。
- 如果值是dict,请深入研究。
- 使用键作为目录构建目录层次结构。
- 将每个扩展标识下载到其指定位置。
- 递归地检查加载的词典项:
- 对于vscode二进制文件:
- 查看已加载的规范指令列表。如果顶级
"vscode"
键的值是dict,则将其视为具有单个dict的列表。 - 根据dict中给出的规范将二进制文件下载到指定的目录中。
- 查看已加载的规范指令列表。如果顶级
因此它将生成以下层次结构:
|-- root_path |-- gitlens | |-- eamodio.gitlens-9.9.3.vsix |-- languages | |-- go | | |-- ms-vscode.go-0.11.4.vsix | |-- python | |-- auto_docstring | | |-- njpwerner.autodocstring-0.3.0.vsix | |-- python | |-- ms-python.python-2019.8.30787.vsix |-- linux-deb-x64 | |-- code_1.37.1-1565886362_amd64.deb |-- win32-x64-user |-- VSCodeUserSetup-x64-1.37.1.exe