Skip to main content

离线下载 VSCode 二进制文件和扩展。

项目描述

VSCOD

执照:麻省理工学院 PyPI 版本 PyPI 版本 fury.io 代码风格:黑色

VSCODV isual S tudio Code Offline D下载器的缩写。该工具将允许您下载批量扩展以及 VSCode 二进制文件,以便您以后可以使用它们来安装您喜欢的编辑器及其扩展。如果您是一个需要更新本地工件存储库的沮丧管理员,如果您无法从您的工作站访问官方存储库并且需要手动传递东西,或者您只是自动化,则此工具可以提供很大帮助怪胎,出于某种原因想要搞砸 Visual Studio 市场。

我试图找到一个工具来做到这一点,当我失败时,我试图至少找到一个方便的 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

from vscod import extensions_downloader, vscode_downloader
from vscod.vscode_downloader import BUILDS, PLATFORMS, LATEST_VERSION
import asyncio
import aiohttp

async def vscod_demo():
    async with aiohttp.ClientSession() as session:  # It's all asynchronous!
        # Download the latest version of the official Python extension to the path.
        await extensions_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 = await extensions_downloader.get_extension_version(session, 'vscodevim.vim')
        # Download the latest stable Linux deb version to the path.
        await vscode_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)。然后解析过程如下:

  • 对于扩展:
    1. 递归地浏览加载字典的项目:
      • 如果值是一个字符串,我们得到了扩展 ID。
      • 如果该值是一个字典,请深入研究。
    2. 使用键作为目录构建目录层次结构。
    3. 将每个扩展 ID 下载到其指定位置。
  • 对于 VSCode 二进制文件:
    1. 浏览已加载的规范字典列表。如果顶级"vscode"键的值是 dict,则将其视为具有单个 dict 的列表。
    2. 对于它们中的每一个,根据 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

执照

麻省理工学院

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

vscod-0.1.0.tar.gz (11.6 kB 查看哈希)

已上传 source

内置分布

vscod-0.1.0-py3-none-any.whl (12.3 kB 查看哈希)

已上传 py3