Skip to content

Commit 6ad9999

Browse files
committed
Move githubREST constants and update cache generation
Signed-off-by: paulober <[email protected]>
1 parent d8e9a0a commit 6ad9999

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

scripts/genCache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
os.chdir(f"{dir_path}/..")
1111

1212
# Extract js for variables
13-
with open("dist/extension.cjs", "r") as f:
13+
with open("dist/utils/sharedConstants.mjs", "r") as f:
1414
keep = False
1515
txt = ""
1616
for line in f.readlines():

src/utils/download.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,9 @@ import {
2626
GithubRepository,
2727
getGithubReleaseByTag,
2828
getAuthorizationHeaders,
29-
EXT_USER_AGENT,
30-
GITHUB_API_BASE_URL,
3129
ownerOfRepository,
3230
repoNameOfRepository,
33-
GITHUB_API_VERSION,
34-
HTTP_STATUS_UNAUTHORIZED,
3531
githubApiUnauthorized,
36-
HTTP_STATUS_FORBIDDEN,
37-
HTTP_STATUS_OK,
3832
} from "./githubREST.mjs";
3933
import { unxzFile, unzipFile } from "./downloadHelpers.mjs";
4034
import type { Writable } from "stream";
@@ -43,6 +37,12 @@ import { got, type Progress } from "got";
4337
import { pipeline as streamPipeline } from "node:stream/promises";
4438
import {
4539
CURRENT_PYTHON_VERSION,
40+
EXT_USER_AGENT,
41+
GITHUB_API_BASE_URL,
42+
GITHUB_API_VERSION,
43+
HTTP_STATUS_FORBIDDEN,
44+
HTTP_STATUS_OK,
45+
HTTP_STATUS_UNAUTHORIZED,
4646
WINDOWS_ARM64_PYTHON_DOWNLOAD_URL,
4747
WINDOWS_X86_PYTHON_DOWNLOAD_URL,
4848
} from "./sharedConstants.mjs";

src/utils/downloadGit.mts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import { get } from "https";
77
import { exec } from "child_process";
88
import { HOME_VAR } from "../settings.mjs";
99
import { unxzFile, unzipFile } from "./downloadHelpers.mjs";
10-
import { EXT_USER_AGENT } from "./githubREST.mjs";
1110
import { unknownErrorToString } from "./errorHelper.mjs";
12-
import { WINDOWS_X86_GIT_DOWNLOAD_URL } from "./sharedConstants.mjs";
11+
import {
12+
EXT_USER_AGENT,
13+
WINDOWS_X86_GIT_DOWNLOAD_URL,
14+
} from "./sharedConstants.mjs";
1315

1416
/**
1517
* Downloads and installs a portable version of Git.

src/utils/githubREST.mts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import GithubApiCache, {
66
import { type RequestOptions, request } from "https";
77
import { unknownErrorToString, unknownToError } from "./errorHelper.mjs";
88
import { window } from "vscode";
9-
10-
// TODO: move into web consts
11-
export const HTTP_STATUS_OK = 200;
12-
export const HTTP_STATUS_NOT_MODIFIED = 304;
13-
export const HTTP_STATUS_UNAUTHORIZED = 401;
14-
export const HTTP_STATUS_FORBIDDEN = 403;
15-
export const EXT_USER_AGENT = "Raspberry Pi Pico VS Code Extension";
16-
export const GITHUB_API_BASE_URL = "https://api.github.com";
17-
export const GITHUB_API_VERSION = "2022-11-28";
9+
import {
10+
EXT_USER_AGENT,
11+
GITHUB_API_BASE_URL,
12+
GITHUB_API_VERSION,
13+
HTTP_STATUS_FORBIDDEN,
14+
HTTP_STATUS_NOT_MODIFIED,
15+
HTTP_STATUS_OK,
16+
HTTP_STATUS_UNAUTHORIZED,
17+
} from "./sharedConstants.mjs";
1818

1919
/**
2020
* Enum containing supported repositories on GitHub.

src/utils/sharedConstants.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ export const LICENSE_URL_7ZIP = "https://7-zip.org/license.txt";
4040
export const WINDOWS_X86_7ZIP_DOWNLOAD_URL = "https://www.7-zip.org/a/7zr.exe";
4141

4242
export const CMAKELISTS_ZEPHYR_HEADER = "#pico-zephyr-project";
43+
44+
export const HTTP_STATUS_OK = 200;
45+
export const HTTP_STATUS_NOT_MODIFIED = 304;
46+
export const HTTP_STATUS_UNAUTHORIZED = 401;
47+
export const HTTP_STATUS_FORBIDDEN = 403;
48+
export const EXT_USER_AGENT = "Raspberry Pi Pico VS Code Extension";
49+
export const GITHUB_API_BASE_URL = "https://api.github.com";
50+
export const GITHUB_API_VERSION = "2022-11-28";

0 commit comments

Comments
 (0)