Skip to content

Commit 0e71ab7

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

File tree

10 files changed

+36
-29
lines changed

10 files changed

+36
-29
lines changed

src/commands/switchSDK.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
import type UI from "../ui.mjs";
1010
import { updateVSCodeStaticConfigs } from "../utils/vscodeConfigUtil.mjs";
1111
import {
12-
SDK_REPOSITORY_URL,
1312
getCmakeReleases,
1413
getNinjaReleases,
1514
getSDKReleases,
@@ -39,6 +38,7 @@ import { NINJA_AUTO_INSTALL_DISABLED } from "../webview/newProjectPanel.mjs";
3938
import Logger from "../logger.mjs";
4039
import type { Progress as GotProgress } from "got";
4140
import { SWITCH_SDK } from "./cmdIds.mjs";
41+
import { SDK_REPOSITORY_URL } from "../utils/sharedConstants.mjs";
4242

4343
const DEFAULT_PICOTOOL_VERSION = "2.2.0-a4";
4444

src/extension.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import {
6464
downloadAndInstallPicotool,
6565
downloadAndInstallOpenOCD,
6666
} from "./utils/download.mjs";
67-
import { SDK_REPOSITORY_URL } from "./utils/githubREST.mjs";
6867
import { getSupportedToolchains } from "./utils/toolchainUtil.mjs";
6968
import {
7069
NewProjectPanel,
@@ -103,6 +102,7 @@ import { NewRustProjectPanel } from "./webview/newRustProjectPanel.mjs";
103102
import {
104103
CMAKELISTS_ZEPHYR_HEADER,
105104
OPENOCD_VERSION,
105+
SDK_REPOSITORY_URL,
106106
} from "./utils/sharedConstants.mjs";
107107
import VersionBundlesLoader from "./utils/versionBundles.mjs";
108108
import { unknownErrorToString } from "./utils/errorHelper.mjs";

src/utils/download.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import which from "which";
2323
import { Uri, window, workspace } from "vscode";
2424
import {
2525
type GithubReleaseAssetData,
26-
GithubRepository,
2726
getGithubReleaseByTag,
2827
getAuthorizationHeaders,
2928
ownerOfRepository,
@@ -40,6 +39,7 @@ import {
4039
EXT_USER_AGENT,
4140
GITHUB_API_BASE_URL,
4241
GITHUB_API_VERSION,
42+
GithubRepository,
4343
HTTP_STATUS_FORBIDDEN,
4444
HTTP_STATUS_OK,
4545
HTTP_STATUS_UNAUTHORIZED,

src/utils/githubApiCache.mts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// TODO: put defaults into json file, to prevent need for these disables
22
import type { ExtensionContext, Memento, Uri } from "vscode";
3-
import type { GithubReleaseResponse, GithubRepository } from "./githubREST.mjs";
3+
import type { GithubReleaseResponse } from "./githubREST.mjs";
44
import Logger, { LoggerSource } from "../logger.mjs";
55
import { getDataRoot } from "./downloadHelpers.mjs";
66
import { get } from "https";
77
import { isInternetConnected } from "./downloadHelpers.mjs";
88
import { join as joinPosix } from "path/posix";
99
import { readFileSync } from "fs";
1010
import { unknownErrorToString } from "./errorHelper.mjs";
11-
import { CURRENT_DATA_VERSION } from "./sharedConstants.mjs";
11+
import {
12+
CURRENT_DATA_VERSION,
13+
type GithubRepository,
14+
} from "./sharedConstants.mjs";
1215

1316
/**
1417
* Tells if the stored data is a GithubReleaseResponse (data of a specific release)

src/utils/githubREST.mts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,13 @@ import {
1010
EXT_USER_AGENT,
1111
GITHUB_API_BASE_URL,
1212
GITHUB_API_VERSION,
13+
GithubRepository,
1314
HTTP_STATUS_FORBIDDEN,
1415
HTTP_STATUS_NOT_MODIFIED,
1516
HTTP_STATUS_OK,
1617
HTTP_STATUS_UNAUTHORIZED,
1718
} from "./sharedConstants.mjs";
1819

19-
/**
20-
* Enum containing supported repositories on GitHub.
21-
*/
22-
export enum GithubRepository {
23-
picoSDK = 0,
24-
cmake = 1,
25-
ninja = 2,
26-
tools = 3,
27-
picotool = 4,
28-
}
29-
3020
/**
3121
* Interface for a response from the GitHub REST API
3222
* release endpoint.
@@ -46,12 +36,6 @@ export type GithubReleaseAssetData = {
4636
id: number;
4737
};
4838

49-
// NOTE: The primary rate limit for unauthenticated requests is 60 requests per hour.
50-
export const SDK_REPOSITORY_URL = "https://github.com/raspberrypi/pico-sdk.git";
51-
export const NINJA_REPOSITORY_URL = "https://github.com/ninja-build/ninja.git";
52-
export const CMAKE_REPOSITORY_URL = "https://github.com/Kitware/CMake.git";
53-
export const PYENV_REPOSITORY_URL = "https://github.com/pyenv/pyenv.git";
54-
5539
/**
5640
* Get the url friendly owner of a repository on GitHub.
5741
*

src/utils/pyenvUtil.mts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { homedir } from "os";
22
import { cloneRepository } from "./gitUtil.mjs";
3-
import { PYENV_REPOSITORY_URL } from "./githubREST.mjs";
43
import { join as joinPosix } from "path/posix";
54
import { exec } from "child_process";
65
import { buildPython3Path } from "./download.mjs";
76
import { HOME_VAR } from "../settings.mjs";
87
import { existsSync, mkdirSync, symlinkSync } from "fs";
9-
import { CURRENT_PYTHON_VERSION } from "./sharedConstants.mjs";
8+
import {
9+
CURRENT_PYTHON_VERSION,
10+
PYENV_REPOSITORY_URL,
11+
} from "./sharedConstants.mjs";
1012

1113
export function buildPyenvPath(): string {
1214
// TODO: maybe replace . with _

src/utils/rustUtil.mts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ import {
1212
downloadAndInstallToolchain,
1313
} from "./download.mjs";
1414
import { getSupportedToolchains } from "./toolchainUtil.mjs";
15-
import { SDK_REPOSITORY_URL } from "./githubREST.mjs";
1615
import findPython, { showPythonNotFoundError } from "./pythonHelper.mjs";
1716
import VersionBundlesLoader from "./versionBundles.mjs";
1817
import { HOME_VAR } from "../settings.mjs";
1918
import { homedir } from "os";
2019
import type { Progress } from "got";
21-
import { OPENOCD_VERSION } from "./sharedConstants.mjs";
20+
import { OPENOCD_VERSION, SDK_REPOSITORY_URL } from "./sharedConstants.mjs";
2221

2322
/*const STABLE_INDEX_DOWNLOAD_URL =
2423
"https://static.rust-lang.org/dist/channel-rust-stable.toml";*/

src/utils/setupZephyr.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ import {
2929
CURRENT_WGET_VERSION,
3030
LICENSE_URL_7ZIP,
3131
OPENOCD_VERSION,
32+
SDK_REPOSITORY_URL,
3233
WINDOWS_X86_7ZIP_DOWNLOAD_URL,
3334
WINDOWS_X86_DTC_DOWNLOAD_URL,
3435
WINDOWS_X86_GPERF_DOWNLOAD_URL,
3536
WINDOWS_X86_WGET_DOWNLOAD_URL,
3637
} from "./sharedConstants.mjs";
37-
import { SDK_REPOSITORY_URL } from "./githubREST.mjs";
3838
import { vsExists } from "./vsHelpers.mjs";
3939
import which from "which";
4040
import { stdoutToString, unknownErrorToString } from "./errorHelper.mjs";

src/utils/sharedConstants.mts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,20 @@ export const HTTP_STATUS_FORBIDDEN = 403;
4848
export const EXT_USER_AGENT = "Raspberry Pi Pico VS Code Extension";
4949
export const GITHUB_API_BASE_URL = "https://api.github.com";
5050
export const GITHUB_API_VERSION = "2022-11-28";
51+
52+
/**
53+
* Enum containing supported repositories on GitHub.
54+
*/
55+
export enum GithubRepository {
56+
picoSDK = 0,
57+
cmake = 1,
58+
ninja = 2,
59+
tools = 3,
60+
picotool = 4,
61+
}
62+
63+
// NOTE: The primary rate limit for unauthenticated requests is 60 requests per hour.
64+
export const SDK_REPOSITORY_URL = "https://github.com/raspberrypi/pico-sdk.git";
65+
export const NINJA_REPOSITORY_URL = "https://github.com/ninja-build/ninja.git";
66+
export const CMAKE_REPOSITORY_URL = "https://github.com/Kitware/CMake.git";
67+
export const PYENV_REPOSITORY_URL = "https://github.com/pyenv/pyenv.git";

src/webview/newProjectPanel.mts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
getSupportedToolchains,
2626
} from "../utils/toolchainUtil.mjs";
2727
import {
28-
SDK_REPOSITORY_URL,
2928
getCmakeReleases,
3029
getNinjaReleases,
3130
getPicotoolReleases,
@@ -60,7 +59,10 @@ import {
6059
import { stdoutToString, unknownErrorToString } from "../utils/errorHelper.mjs";
6160
import type { Progress as GotProgress } from "got";
6261
import findPython, { showPythonNotFoundError } from "../utils/pythonHelper.mjs";
63-
import { OPENOCD_VERSION } from "../utils/sharedConstants.mjs";
62+
import {
63+
OPENOCD_VERSION,
64+
SDK_REPOSITORY_URL,
65+
} from "../utils/sharedConstants.mjs";
6466
import { BoardType } from "./sharedEnums.mjs";
6567
import { getSystemNinjaVersion } from "../utils/ninjaUtil.mjs";
6668
import { getSystemCmakeVersion } from "../utils/cmakeUtil.mjs";

0 commit comments

Comments
 (0)