vscode-offline 0.1.7__tar.gz → 0.1.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/PKG-INFO +2 -2
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/README.md +1 -1
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/_version.py +2 -2
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/app.py +63 -62
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/download.py +3 -2
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/utils.py +69 -49
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/tests/test_utils.py +42 -1
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/.editorconfig +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/.github/workflows/build.yml +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/.gitignore +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/.python-version +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/.vscode/extensions.json +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/.vscode/settings.json +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/LICENSE +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/lefthook.yml +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/pyproject.toml +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/pyrightconfig.json +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/__init__.py +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/install.py +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/loggers.py +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/src/vscode_offline/py.typed +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/tests/test_install.py +0 -0
- {vscode_offline-0.1.7 → vscode_offline-0.1.9}/uv.lock +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: vscode-offline
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.9
|
4
4
|
Summary: Download and install VS Code for offline environments
|
5
5
|
Project-URL: Homepage, https://github.com/fanck0605/vscode-offline
|
6
6
|
Author-email: Chuck Fan <fanck0605@qq.com>
|
@@ -51,7 +51,7 @@ pip install -U vscode-offline
|
|
51
51
|
vscode-offline download-all --client-platform win32-x64 --server-platform linux-x64
|
52
52
|
```
|
53
53
|
|
54
|
-
(3)复制 `./vscode-offline-installer` 到内网 Windows 机器,安装
|
54
|
+
(3)复制 `./vscode-offline-installer` 到内网 Windows 机器,安装 `./vscode-offline-installer/<version>` 下的 VS Code,然后执行如下命令安装所有插件
|
55
55
|
|
56
56
|
```shell
|
57
57
|
vscode-offline install-extensions --installer ./vscode-offline-installer
|
@@ -28,7 +28,7 @@ pip install -U vscode-offline
|
|
28
28
|
vscode-offline download-all --client-platform win32-x64 --server-platform linux-x64
|
29
29
|
```
|
30
30
|
|
31
|
-
(3)复制 `./vscode-offline-installer` 到内网 Windows 机器,安装
|
31
|
+
(3)复制 `./vscode-offline-installer` 到内网 Windows 机器,安装 `./vscode-offline-installer/<version>` 下的 VS Code,然后执行如下命令安装所有插件
|
32
32
|
|
33
33
|
```shell
|
34
34
|
vscode-offline install-extensions --installer ./vscode-offline-installer
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
28
28
|
commit_id: COMMIT_ID
|
29
29
|
__commit_id__: COMMIT_ID
|
30
30
|
|
31
|
-
__version__ = version = '0.1.
|
32
|
-
__version_tuple__ = version_tuple = (0, 1,
|
31
|
+
__version__ = version = '0.1.9'
|
32
|
+
__version_tuple__ = version_tuple = (0, 1, 9)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -16,6 +16,9 @@ from vscode_offline.install import (
|
|
16
16
|
install_vscode_server,
|
17
17
|
)
|
18
18
|
from vscode_offline.utils import (
|
19
|
+
CLIENT_PLATFORMS,
|
20
|
+
EXTENSION_PLATFORMS,
|
21
|
+
SERVER_PLATFORMS,
|
19
22
|
get_client_platform,
|
20
23
|
get_default_code_version,
|
21
24
|
get_extension_platform,
|
@@ -23,7 +26,6 @@ from vscode_offline.utils import (
|
|
23
26
|
get_server_platform,
|
24
27
|
get_vscode_extensions_config,
|
25
28
|
get_vscode_version_from_server_installer,
|
26
|
-
validate_platform,
|
27
29
|
)
|
28
30
|
|
29
31
|
|
@@ -37,7 +39,7 @@ def cmd_download_server(args: Namespace) -> None:
|
|
37
39
|
|
38
40
|
download_vscode_server(
|
39
41
|
args.code_version,
|
40
|
-
output=args.installer /
|
42
|
+
output=args.installer / args.code_version.replace(":", "-"),
|
41
43
|
platform=get_server_platform(args.platform),
|
42
44
|
)
|
43
45
|
extensions_config = Path(args.extensions_config).expanduser()
|
@@ -63,7 +65,7 @@ def cmd_install_server(args: Namespace) -> None:
|
|
63
65
|
) from None
|
64
66
|
|
65
67
|
vscode_server_home = install_vscode_server(
|
66
|
-
server_installer=args.installer /
|
68
|
+
server_installer=args.installer / args.code_version.replace(":", "-"),
|
67
69
|
platform=get_server_platform(host_platform),
|
68
70
|
)
|
69
71
|
install_vscode_extensions(
|
@@ -104,7 +106,7 @@ def cmd_download_client(args: Namespace) -> None:
|
|
104
106
|
|
105
107
|
download_vscode_client(
|
106
108
|
args.code_version,
|
107
|
-
output=args.installer /
|
109
|
+
output=args.installer / args.code_version.replace(":", "-"),
|
108
110
|
platform=get_client_platform(args.platform),
|
109
111
|
)
|
110
112
|
extensions_config = Path(args.extensions_config).expanduser()
|
@@ -127,12 +129,12 @@ def cmd_download_all(args: Namespace) -> None:
|
|
127
129
|
|
128
130
|
download_vscode_server(
|
129
131
|
args.code_version,
|
130
|
-
output=args.installer /
|
132
|
+
output=args.installer / args.code_version.replace(":", "-"),
|
131
133
|
platform=get_server_platform(args.server_platform),
|
132
134
|
)
|
133
135
|
download_vscode_client(
|
134
136
|
args.code_version,
|
135
|
-
output=args.installer /
|
137
|
+
output=args.installer / args.code_version.replace(":", "-"),
|
136
138
|
platform=get_client_platform(args.client_platform),
|
137
139
|
)
|
138
140
|
extensions_config = Path(args.extensions_config).expanduser()
|
@@ -153,29 +155,28 @@ def cmd_version(args: Namespace) -> None:
|
|
153
155
|
|
154
156
|
def make_argparser() -> ArgumentParser:
|
155
157
|
parent_parser = ArgumentParser(add_help=False)
|
156
|
-
|
157
158
|
parent_parser.add_argument(
|
158
159
|
"--installer",
|
159
160
|
type=Path,
|
160
161
|
default="./vscode-offline-installer",
|
161
|
-
help="The output directory for downloaded files
|
162
|
+
help="The output directory for downloaded files, also used as the installer directory.",
|
162
163
|
)
|
163
164
|
|
164
|
-
|
165
|
-
subparsers =
|
165
|
+
main_parser = ArgumentParser(description="VS Code downloader and installer")
|
166
|
+
subparsers = main_parser.add_subparsers(required=True)
|
166
167
|
|
167
168
|
version_parser = subparsers.add_parser(
|
168
169
|
"version",
|
169
170
|
help="Show version information",
|
170
171
|
)
|
171
|
-
version_parser.set_defaults(
|
172
|
+
version_parser.set_defaults(command=cmd_version)
|
172
173
|
|
173
174
|
download_server_parser = subparsers.add_parser(
|
174
175
|
"download-server",
|
175
|
-
help="Download VS Code Server and extensions",
|
176
|
+
help="Download VS Code Server and its extensions",
|
176
177
|
parents=[parent_parser],
|
177
178
|
)
|
178
|
-
download_server_parser.set_defaults(
|
179
|
+
download_server_parser.set_defaults(command=cmd_download_server)
|
179
180
|
download_server_parser.add_argument(
|
180
181
|
"--code-version",
|
181
182
|
type=str,
|
@@ -183,7 +184,7 @@ def make_argparser() -> ArgumentParser:
|
|
183
184
|
)
|
184
185
|
download_server_parser.add_argument(
|
185
186
|
"--platform",
|
186
|
-
|
187
|
+
choices=SERVER_PLATFORMS,
|
187
188
|
required=True,
|
188
189
|
help="The target platform of the VS Code Server to download.",
|
189
190
|
)
|
@@ -194,68 +195,43 @@ def make_argparser() -> ArgumentParser:
|
|
194
195
|
help="Path to the extensions configuration file. Will search for extensions to download.",
|
195
196
|
)
|
196
197
|
|
197
|
-
|
198
|
-
"
|
199
|
-
help="
|
198
|
+
download_client_parser = subparsers.add_parser(
|
199
|
+
"download-client",
|
200
|
+
help="Download VS Code client and its extensions",
|
200
201
|
parents=[parent_parser],
|
201
202
|
)
|
202
|
-
|
203
|
-
|
203
|
+
download_client_parser.set_defaults(command=cmd_download_client)
|
204
|
+
download_client_parser.add_argument(
|
204
205
|
"--code-version",
|
205
206
|
type=str,
|
206
|
-
help="The version of the VS Code
|
207
|
-
)
|
208
|
-
|
209
|
-
download_extensions_parser = subparsers.add_parser(
|
210
|
-
"download-extensions",
|
211
|
-
help="Download VS Code Server and extensions",
|
212
|
-
parents=[parent_parser],
|
207
|
+
help="The version of the VS Code to download, must match the version of the VS Code Client.",
|
213
208
|
)
|
214
|
-
|
215
|
-
download_extensions_parser.add_argument(
|
209
|
+
download_client_parser.add_argument(
|
216
210
|
"--platform",
|
217
|
-
|
211
|
+
choices=CLIENT_PLATFORMS,
|
218
212
|
required=True,
|
219
|
-
help="The target platform of the VS Code
|
213
|
+
help="The target platform of the VS Code client to download.",
|
220
214
|
)
|
221
|
-
|
215
|
+
download_client_parser.add_argument(
|
222
216
|
"--extensions-config",
|
223
217
|
type=Path,
|
224
218
|
default=get_vscode_extensions_config(),
|
225
219
|
help="Path to the extensions configuration file. Will search for extensions to download.",
|
226
220
|
)
|
227
221
|
|
228
|
-
|
229
|
-
"
|
230
|
-
help="
|
231
|
-
parents=[parent_parser],
|
232
|
-
)
|
233
|
-
install_extensions_parser.set_defaults(func=cmd_install_extensions)
|
234
|
-
install_extensions_parser.add_argument(
|
235
|
-
"--code",
|
236
|
-
type=str,
|
237
|
-
default="code",
|
238
|
-
help="Path to the `code` binary.",
|
239
|
-
)
|
240
|
-
|
241
|
-
download_client_parser = subparsers.add_parser(
|
242
|
-
"download-client",
|
243
|
-
help="Download VS Code and extensions",
|
222
|
+
download_extensions_parser = subparsers.add_parser(
|
223
|
+
"download-extensions",
|
224
|
+
help="Download VS Code extensions only",
|
244
225
|
parents=[parent_parser],
|
245
226
|
)
|
246
|
-
|
247
|
-
|
248
|
-
"--code-version",
|
249
|
-
type=str,
|
250
|
-
help="The version of the VS Code to download, must match the version of the VS Code Client.",
|
251
|
-
)
|
252
|
-
download_client_parser.add_argument(
|
227
|
+
download_extensions_parser.set_defaults(command=cmd_download_extensions)
|
228
|
+
download_extensions_parser.add_argument(
|
253
229
|
"--platform",
|
254
|
-
|
230
|
+
choices=EXTENSION_PLATFORMS,
|
255
231
|
required=True,
|
256
|
-
help="The target platform of the VS Code to download.",
|
232
|
+
help="The target platform of the VS Code extensions to download.",
|
257
233
|
)
|
258
|
-
|
234
|
+
download_extensions_parser.add_argument(
|
259
235
|
"--extensions-config",
|
260
236
|
type=Path,
|
261
237
|
default=get_vscode_extensions_config(),
|
@@ -264,10 +240,10 @@ def make_argparser() -> ArgumentParser:
|
|
264
240
|
|
265
241
|
download_all_parser = subparsers.add_parser(
|
266
242
|
"download-all",
|
267
|
-
help="Download VS Code
|
243
|
+
help="Download VS Code Server, Client and its extensions, all in one command",
|
268
244
|
parents=[parent_parser],
|
269
245
|
)
|
270
|
-
download_all_parser.set_defaults(
|
246
|
+
download_all_parser.set_defaults(command=cmd_download_all)
|
271
247
|
download_all_parser.add_argument(
|
272
248
|
"--code-version",
|
273
249
|
type=str,
|
@@ -275,13 +251,13 @@ def make_argparser() -> ArgumentParser:
|
|
275
251
|
)
|
276
252
|
download_all_parser.add_argument(
|
277
253
|
"--server-platform",
|
278
|
-
|
254
|
+
choices=SERVER_PLATFORMS,
|
279
255
|
required=True,
|
280
256
|
help="The target platform of the VS Code Server to download, defaults to linux-x64.",
|
281
257
|
)
|
282
258
|
download_all_parser.add_argument(
|
283
259
|
"--client-platform",
|
284
|
-
|
260
|
+
choices=CLIENT_PLATFORMS,
|
285
261
|
required=True,
|
286
262
|
help="The target platform of the VS Code to download, defaults to win32-x64.",
|
287
263
|
)
|
@@ -292,7 +268,32 @@ def make_argparser() -> ArgumentParser:
|
|
292
268
|
help="Path to the extensions configuration file. Will search for extensions to download.",
|
293
269
|
)
|
294
270
|
|
295
|
-
|
271
|
+
install_server_parser = subparsers.add_parser(
|
272
|
+
"install-server",
|
273
|
+
help="Install VS Code Server and its extensions",
|
274
|
+
parents=[parent_parser],
|
275
|
+
)
|
276
|
+
install_server_parser.set_defaults(command=cmd_install_server)
|
277
|
+
install_server_parser.add_argument(
|
278
|
+
"--code-version",
|
279
|
+
type=str,
|
280
|
+
help="The version of the VS Code Server to install.",
|
281
|
+
)
|
282
|
+
|
283
|
+
install_extensions_parser = subparsers.add_parser(
|
284
|
+
"install-extensions",
|
285
|
+
help="Install VS Code extensions only",
|
286
|
+
parents=[parent_parser],
|
287
|
+
)
|
288
|
+
install_extensions_parser.set_defaults(command=cmd_install_extensions)
|
289
|
+
install_extensions_parser.add_argument(
|
290
|
+
"--code",
|
291
|
+
type=str,
|
292
|
+
default="code",
|
293
|
+
help="Path to the `code` binary.",
|
294
|
+
)
|
295
|
+
|
296
|
+
return main_parser
|
296
297
|
|
297
298
|
|
298
299
|
def main() -> None:
|
@@ -4,7 +4,6 @@ import json
|
|
4
4
|
import os
|
5
5
|
from collections.abc import Set as AbstractSet
|
6
6
|
from gzip import GzipFile
|
7
|
-
from io import DEFAULT_BUFFER_SIZE
|
8
7
|
from pathlib import Path
|
9
8
|
from urllib.error import HTTPError
|
10
9
|
from urllib.request import urlopen
|
@@ -12,6 +11,8 @@ from urllib.request import urlopen
|
|
12
11
|
from vscode_offline.loggers import logger
|
13
12
|
from vscode_offline.utils import extract_filename_from_headers, get_cli_platform
|
14
13
|
|
14
|
+
_DOWNLOAD_CHUNK_SIZE = 4 * 1024 * 1024 # 4 MiB
|
15
|
+
|
15
16
|
|
16
17
|
def _download_file_once(
|
17
18
|
url: str,
|
@@ -45,7 +46,7 @@ def _download_file_once(
|
|
45
46
|
tmp_file_path = Path(directory).joinpath(f"{filename}.tmp")
|
46
47
|
with reader, tmp_file_path.open("wb") as fp:
|
47
48
|
while True:
|
48
|
-
chunk = reader.read(
|
49
|
+
chunk = reader.read(_DOWNLOAD_CHUNK_SIZE)
|
49
50
|
if not chunk:
|
50
51
|
break
|
51
52
|
fp.write(chunk)
|
@@ -4,12 +4,11 @@ import os
|
|
4
4
|
import shutil
|
5
5
|
import subprocess
|
6
6
|
import sys
|
7
|
-
from argparse import ArgumentTypeError
|
8
7
|
from collections.abc import Mapping
|
9
8
|
from collections.abc import Set as AbstractSet
|
10
9
|
from email.parser import HeaderParser
|
11
10
|
from pathlib import Path
|
12
|
-
from typing import Final
|
11
|
+
from typing import Collection, Final
|
13
12
|
|
14
13
|
from vscode_offline.loggers import logger
|
15
14
|
|
@@ -38,9 +37,7 @@ def get_vscode_extensions_config() -> os.PathLike[str]:
|
|
38
37
|
def get_vscode_version_from_server_installer(
|
39
38
|
installer: os.PathLike[str], platform: str
|
40
39
|
) -> str:
|
41
|
-
directories = list(
|
42
|
-
Path(installer).glob(f"server-*/vscode-server-{platform}.tar.gz")
|
43
|
-
)
|
40
|
+
directories = list(Path(installer).glob(f"*/vscode-server-{platform}.tar.gz"))
|
44
41
|
if len(directories) > 1:
|
45
42
|
raise ValueError(
|
46
43
|
f"Multiple matching installers found in {installer} for platform {platform}"
|
@@ -50,9 +47,9 @@ def get_vscode_version_from_server_installer(
|
|
50
47
|
f"No matching installer found in {installer} for platform {platform}"
|
51
48
|
)
|
52
49
|
|
53
|
-
version = directories[0].parent.name
|
50
|
+
version = directories[0].parent.name
|
54
51
|
logger.info(f"Getting version from {platform} installer: {version}")
|
55
|
-
return version
|
52
|
+
return version.replace("commit-", "commit:")
|
56
53
|
|
57
54
|
|
58
55
|
def get_default_code_version() -> str | None:
|
@@ -86,11 +83,9 @@ def get_default_code_version() -> str | None:
|
|
86
83
|
# Mapping from other platforms to VS Code client platform used in download URLs
|
87
84
|
_client_platform_mapping: Final[Mapping[str, str]] = {
|
88
85
|
"linux-x64": "linux-x64",
|
89
|
-
"alpine-x64": "linux-x64",
|
90
86
|
"linux-deb-x64": "linux-deb-x64",
|
91
87
|
"linux-rpm-x64": "linux-rpm-x64",
|
92
88
|
"linux-arm64": "linux-arm64",
|
93
|
-
"alpine-arm64": "linux-arm64",
|
94
89
|
"linux-deb-arm64": "linux-deb-arm64",
|
95
90
|
"linux-rpm-arm64": "linux-rpm-arm64",
|
96
91
|
"linux-armhf": "linux-armhf",
|
@@ -102,19 +97,17 @@ _client_platform_mapping: Final[Mapping[str, str]] = {
|
|
102
97
|
"win32-arm64": "win32-arm64",
|
103
98
|
"win32-arm64-user": "win32-arm64-user",
|
104
99
|
"win32-arm64-archive": "win32-arm64-archive",
|
105
|
-
"darwin": "darwin",
|
106
100
|
"darwin-x64": "darwin",
|
107
101
|
"darwin-arm64": "darwin-arm64",
|
108
102
|
}
|
109
103
|
|
110
|
-
|
104
|
+
|
105
|
+
# Mapping from other platforms to VS Code Server platform used in download URLs
|
111
106
|
_server_platform_mapping: Final[Mapping[str, str]] = {
|
112
107
|
"linux-x64": "linux-x64",
|
113
|
-
"alpine-x64": "linux-x64",
|
114
108
|
"linux-deb-x64": "linux-x64",
|
115
109
|
"linux-rpm-x64": "linux-x64",
|
116
110
|
"linux-arm64": "linux-arm64",
|
117
|
-
"alpine-arm64": "linux-arm64",
|
118
111
|
"linux-deb-arm64": "linux-arm64",
|
119
112
|
"linux-rpm-arm64": "linux-arm64",
|
120
113
|
"linux-armhf": "linux-armhf",
|
@@ -126,7 +119,6 @@ _server_platform_mapping: Final[Mapping[str, str]] = {
|
|
126
119
|
"win32-arm64": "win32-arm64",
|
127
120
|
"win32-arm64-user": "win32-arm64",
|
128
121
|
"win32-arm64-archive": "win32-arm64",
|
129
|
-
"darwin": "darwin",
|
130
122
|
"darwin-x64": "darwin",
|
131
123
|
"darwin-arm64": "darwin-arm64",
|
132
124
|
}
|
@@ -135,11 +127,9 @@ _server_platform_mapping: Final[Mapping[str, str]] = {
|
|
135
127
|
# Mapping from other platforms to VS Code CLI platform used in download URLs
|
136
128
|
_cli_platform_mapping: Final[Mapping[str, str]] = {
|
137
129
|
"linux-x64": "alpine-x64",
|
138
|
-
"alpine-x64": "alpine-x64",
|
139
130
|
"linux-deb-x64": "alpine-x64",
|
140
131
|
"linux-rpm-x64": "alpine-x64",
|
141
132
|
"linux-arm64": "alpine-arm64",
|
142
|
-
"alpine-arm64": "alpine-arm64",
|
143
133
|
"linux-deb-arm64": "alpine-arm64",
|
144
134
|
"linux-rpm-arm64": "alpine-arm64",
|
145
135
|
"linux-armhf": "linux-armhf",
|
@@ -151,7 +141,6 @@ _cli_platform_mapping: Final[Mapping[str, str]] = {
|
|
151
141
|
"win32-arm64": "win32-arm64",
|
152
142
|
"win32-arm64-user": "win32-arm64",
|
153
143
|
"win32-arm64-archive": "win32-arm64",
|
154
|
-
"darwin": "darwin-x64",
|
155
144
|
"darwin-x64": "darwin-x64",
|
156
145
|
"darwin-arm64": "darwin-arm64",
|
157
146
|
}
|
@@ -160,11 +149,9 @@ _cli_platform_mapping: Final[Mapping[str, str]] = {
|
|
160
149
|
# Mapping from other platforms to extension target platform used in download URLs
|
161
150
|
_extension_platform_mapping: Final[Mapping[str, str]] = {
|
162
151
|
"linux-x64": "linux-x64",
|
163
|
-
"alpine-x64": "linux-x64",
|
164
152
|
"linux-deb-x64": "linux-x64",
|
165
153
|
"linux-rpm-x64": "linux-x64",
|
166
154
|
"linux-arm64": "linux-arm64",
|
167
|
-
"alpine-arm64": "linux-arm64",
|
168
155
|
"linux-deb-arm64": "linux-arm64",
|
169
156
|
"linux-rpm-arm64": "linux-arm64",
|
170
157
|
"linux-armhf": "linux-armhf",
|
@@ -176,44 +163,64 @@ _extension_platform_mapping: Final[Mapping[str, str]] = {
|
|
176
163
|
"win32-arm64": "win32-arm64",
|
177
164
|
"win32-arm64-user": "win32-arm64",
|
178
165
|
"win32-arm64-archive": "win32-arm64",
|
179
|
-
"darwin": "darwin-x64",
|
180
166
|
"darwin-x64": "darwin-x64",
|
181
167
|
"darwin-arm64": "darwin-arm64",
|
182
168
|
}
|
183
169
|
|
170
|
+
CLIENT_PLATFORMS: Final[Collection[str]] = {
|
171
|
+
"linux-x64": None,
|
172
|
+
"linux-deb-x64": None,
|
173
|
+
"linux-rpm-x64": None,
|
174
|
+
"linux-arm64": None,
|
175
|
+
"linux-deb-arm64": None,
|
176
|
+
"linux-rpm-arm64": None,
|
177
|
+
"linux-armhf": None,
|
178
|
+
"linux-deb-armhf": None,
|
179
|
+
"linux-rpm-armhf": None,
|
180
|
+
"win32-x64": None,
|
181
|
+
"win32-x64-user": None,
|
182
|
+
"win32-x64-archive": None,
|
183
|
+
"win32-arm64": None,
|
184
|
+
"win32-arm64-user": None,
|
185
|
+
"win32-arm64-archive": None,
|
186
|
+
"darwin-x64": None,
|
187
|
+
"darwin-arm64": None,
|
188
|
+
}
|
184
189
|
|
185
|
-
def get_client_platform(platform: str) -> str:
|
186
|
-
"""Get the VS Code platform for the given platform."""
|
187
|
-
return _client_platform_mapping.get(platform, platform)
|
188
|
-
|
189
|
-
|
190
|
-
def get_server_platform(platform: str) -> str:
|
191
|
-
"""Get the VS Code server platform for the given platform."""
|
192
|
-
return _server_platform_mapping.get(platform, platform)
|
193
|
-
|
194
|
-
|
195
|
-
def get_cli_platform(platform: str) -> str:
|
196
|
-
"""Get the VS Code CLI platform for the given platform."""
|
197
|
-
return _cli_platform_mapping.get(platform, platform)
|
198
190
|
|
191
|
+
SERVER_PLATFORMS: Final[Collection[str]] = {
|
192
|
+
"linux-x64": None,
|
193
|
+
"linux-arm64": None,
|
194
|
+
"linux-armhf": None,
|
195
|
+
"win32-x64": None,
|
196
|
+
"win32-arm64": None,
|
197
|
+
"darwin-x64": None,
|
198
|
+
"darwin-arm64": None,
|
199
|
+
}
|
199
200
|
|
200
|
-
def get_extension_platform(platform: str) -> str:
|
201
|
-
"""Get the VS Code extension target platform for the given platform."""
|
202
|
-
return _extension_platform_mapping.get(platform, platform)
|
203
201
|
|
202
|
+
EXTENSION_PLATFORMS: Final[Collection[str]] = {
|
203
|
+
"linux-x64": None,
|
204
|
+
"linux-arm64": None,
|
205
|
+
"linux-armhf": None,
|
206
|
+
"win32-x64": None,
|
207
|
+
"win32-arm64": None,
|
208
|
+
"darwin-x64": None,
|
209
|
+
"darwin-arm64": None,
|
210
|
+
}
|
204
211
|
|
205
212
|
_all_platforms: Final[AbstractSet[str]] = {
|
206
|
-
*
|
207
|
-
*
|
208
|
-
*
|
209
|
-
*_server_platform_mapping.values(),
|
210
|
-
*_cli_platform_mapping.keys(),
|
211
|
-
*_cli_platform_mapping.values(),
|
212
|
-
*_extension_platform_mapping.keys(),
|
213
|
-
*_extension_platform_mapping.values(),
|
213
|
+
*CLIENT_PLATFORMS,
|
214
|
+
*SERVER_PLATFORMS,
|
215
|
+
*EXTENSION_PLATFORMS,
|
214
216
|
}
|
215
217
|
|
216
218
|
|
219
|
+
assert set(SERVER_PLATFORMS).issubset(CLIENT_PLATFORMS)
|
220
|
+
assert set(EXTENSION_PLATFORMS).issubset(CLIENT_PLATFORMS)
|
221
|
+
assert SERVER_PLATFORMS == EXTENSION_PLATFORMS
|
222
|
+
|
223
|
+
|
217
224
|
assert (
|
218
225
|
_client_platform_mapping.keys()
|
219
226
|
== _server_platform_mapping.keys()
|
@@ -223,11 +230,24 @@ assert (
|
|
223
230
|
)
|
224
231
|
|
225
232
|
|
226
|
-
def
|
227
|
-
"""
|
228
|
-
|
229
|
-
|
230
|
-
|
233
|
+
def get_client_platform(platform: str) -> str:
|
234
|
+
"""Get the VS Code platform for the given platform."""
|
235
|
+
return _client_platform_mapping.get(platform, platform)
|
236
|
+
|
237
|
+
|
238
|
+
def get_server_platform(platform: str) -> str:
|
239
|
+
"""Get the VS Code Server platform for the given platform."""
|
240
|
+
return _server_platform_mapping.get(platform, platform)
|
241
|
+
|
242
|
+
|
243
|
+
def get_cli_platform(platform: str) -> str:
|
244
|
+
"""Get the VS Code CLI platform for the given platform."""
|
245
|
+
return _cli_platform_mapping.get(platform, platform)
|
246
|
+
|
247
|
+
|
248
|
+
def get_extension_platform(platform: str) -> str:
|
249
|
+
"""Get the VS Code extension target platform for the given platform."""
|
250
|
+
return _extension_platform_mapping.get(platform, platform)
|
231
251
|
|
232
252
|
|
233
253
|
def get_host_platform() -> str:
|
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
import tempfile
|
2
|
+
from pathlib import Path
|
3
|
+
|
4
|
+
import pytest
|
5
|
+
|
6
|
+
from vscode_offline.utils import (
|
7
|
+
extract_filename_from_headers,
|
8
|
+
get_vscode_version_from_server_installer,
|
9
|
+
)
|
2
10
|
|
3
11
|
|
4
12
|
def test_extract_filename_from_headers() -> None:
|
@@ -46,3 +54,36 @@ def test_get_filename_from_vsix_download_response() -> None:
|
|
46
54
|
extract_filename_from_headers(headers)
|
47
55
|
== "yzhang.markdown-all-in-one-3.6.3.vsix"
|
48
56
|
)
|
57
|
+
|
58
|
+
|
59
|
+
def test_get_vscode_version_from_server_installer_success() -> None:
|
60
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
61
|
+
base = Path(tmpdir)
|
62
|
+
version_dir = base / "commit-1234567890abcdef"
|
63
|
+
version_dir.mkdir()
|
64
|
+
(version_dir / "vscode-server-linux-x64.tar.gz").touch()
|
65
|
+
result = get_vscode_version_from_server_installer(base, "linux-x64")
|
66
|
+
assert result == "commit:1234567890abcdef"
|
67
|
+
|
68
|
+
|
69
|
+
def test_get_vscode_version_from_server_installer_multiple_found() -> None:
|
70
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
71
|
+
base = Path(tmpdir)
|
72
|
+
v1 = base / "commit-1111111111111111"
|
73
|
+
v2 = base / "commit-2222222222222222"
|
74
|
+
v1.mkdir()
|
75
|
+
v2.mkdir()
|
76
|
+
(v1 / "vscode-server-linux-x64.tar.gz").touch()
|
77
|
+
(v2 / "vscode-server-linux-x64.tar.gz").touch()
|
78
|
+
with pytest.raises(ValueError, match="Multiple matching installers found"):
|
79
|
+
get_vscode_version_from_server_installer(base, "linux-x64")
|
80
|
+
|
81
|
+
|
82
|
+
def test_get_vscode_version_from_server_installer_none_found() -> None:
|
83
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
84
|
+
base = Path(tmpdir)
|
85
|
+
version_dir = base / "commit-1234567890abcdef"
|
86
|
+
version_dir.mkdir()
|
87
|
+
(version_dir / "vscode-server-linux-arm64.tar.gz").touch()
|
88
|
+
with pytest.raises(ValueError, match="No matching installer found"):
|
89
|
+
get_vscode_version_from_server_installer(base, "linux-x64")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|