Skip to content

Commit b8a6dde

Browse files
wan9chiGemini 4 Neon
andauthored
feat(cache): unhide remote caching config types and CLI help (#1046)
## Motivation Remote caching is ready to be documented and validated in Vite+, so its configuration fields (`cache.remote` at the workspace root and per task) and the `--remote-cache` CLI flag should be visible in the generated TypeScript types and `vp run --help` output instead of hidden (reverting the hiding done in #820). ## Changes - Remove `hide = true` from `--remote-cache` in `crates/vt/src/cli/mod.rs`. - Remove `ts(skip)` from `EnabledCacheConfig.remote` and `UserGlobalCacheConfig::Detailed.remote`, derive `TS` (`RemoteCacheConfig`) on `UserRemoteCacheConfig` (typing `headers` as `{ [key in string]: string | undefined }`), and regenerate `crates/vt_graph/run-config.ts`. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation and type-export changes only; remote cache runtime behavior is unchanged. > > **Overview** > Makes **remote caching** discoverable in user-facing surfaces now that it is ready to document: the `--remote-cache` flag appears in `vp run --help`, and generated `run-config.ts` exposes **`RemoteCacheConfig`** (URL, headers), **`cache.remote`** on the workspace root, and per-task **`cache.remote`** booleans. > > Rust config types drop the prior `ts(skip)` / hidden-CLI guards and wire **`UserRemoteCacheConfig`** into the TypeScript export pipeline (including typed `headers`). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 68fdd4d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Gemini 4 Neon <noreply@google.com>
1 parent 3541c0c commit b8a6dde

3 files changed

Lines changed: 53 additions & 8 deletions

File tree

‎crates/vt/src/cli/mod.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ pub struct RunFlags {
7575
///
7676
/// If you don't pass this flag, `VP_REMOTE_CACHE` selects the mode. If neither
7777
/// is set, the mode is `read` when an endpoint is configured, or `off` otherwise.
78-
// Accepted but hidden from help while remote caching is unreleased.
79-
#[clap(long, hide = true)]
78+
#[clap(long)]
8079
pub remote_cache: Option<RemoteCacheMode>,
8180

8281
/// Maximum number of tasks to run concurrently. Defaults to 4.

‎crates/vt_graph/run-config.ts‎

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ base: InputBase, };
2626

2727
export type InputBase = "package" | "workspace";
2828

29+
export type RemoteCacheConfig = {
30+
/**
31+
* Optional HTTP or HTTPS namespace endpoint. Overridden by
32+
* `VP_REMOTE_CACHE_URL`; can be omitted when the endpoint is supplied via
33+
* `VP_REMOTE_CACHE_URL` (for example, when configuring only `headers`).
34+
*
35+
* In a GitHub Actions job with `permissions: id-token: write`, uploads
36+
* authenticate with a GitHub Actions OIDC token whose audience is the
37+
* endpoint without a trailing slash.
38+
*/
39+
url?: string,
40+
/**
41+
* Custom HTTP headers sent on every remote cache request (`fetch`,
42+
* `download`, and `store`) to whichever remote cache endpoint is active
43+
* (including values configured in `vite.config.*` when the endpoint is
44+
* overridden via `VP_REMOTE_CACHE_URL`), never on GitHub Actions OIDC
45+
* token requests.
46+
*
47+
* Empty string values are preserved as valid HTTP header values (to omit a
48+
* header when an env var is unset in `vite.config.*`, omit the key or set
49+
* it to `undefined`).
50+
* Overridden per header by `VP_REMOTE_CACHE_HEADER_<NAME>` env vars
51+
* (because `_` maps to `-` in env var suffixes, configured headers
52+
* containing literal `_` cannot be overridden via env).
53+
* Setting an `Authorization` header suppresses automatic GitHub Actions
54+
* OIDC.
55+
*/
56+
headers?: { [key in string]: string | undefined }, };
57+
2958
export type Task = {
3059
/**
3160
* Command to run, or an array of commands to run in order.
@@ -87,7 +116,18 @@ input?: Array<string | GlobWithBase | AutoTracking>,
87116
* - `{auto: true}` enables automatic output tracking
88117
* - Negative patterns (e.g. `"!dist/cache/**"`) exclude matched files
89118
*/
90-
output?: Array<string | GlobWithBase | AutoTracking>, };
119+
output?: Array<string | GlobWithBase | AutoTracking>,
120+
/**
121+
* Whether this task can use the remote cache. Defaults to `true`.
122+
*
123+
* The remote cache is used only when these also hold:
124+
* - Caching isn't turned off by `--no-cache` or the workspace root's `cache` setting.
125+
* - An endpoint is set with `cache.remote.url` in the workspace root config or with
126+
* `VP_REMOTE_CACHE_URL`.
127+
* - Remote access isn't set to `off` with `--remote-cache` or `VP_REMOTE_CACHE`. It
128+
* defaults to `read`, which downloads cached results without uploading new ones.
129+
*/
130+
remote?: boolean, };
91131

92132
export type TaskDefinition = Task | Command;
93133

@@ -111,7 +151,11 @@ scripts?: boolean,
111151
*
112152
* Default: `true`
113153
*/
114-
tasks?: boolean, };
154+
tasks?: boolean,
155+
/**
156+
* Remote cache shared by tasks in the workspace.
157+
*/
158+
remote?: RemoteCacheConfig, };
115159

116160
export type UserPackageDependency = {
117161
/**

‎crates/vt_graph/src/config/user.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ pub struct EnabledCacheConfig {
253253
/// `VP_REMOTE_CACHE_URL`.
254254
/// - Remote access isn't set to `off` with `--remote-cache` or `VP_REMOTE_CACHE`. It
255255
/// defaults to `read`, which downloads cached results without uploading new ones.
256-
// Parsed but left out of the public types while remote caching is unreleased.
257-
#[cfg_attr(all(test, not(clippy)), ts(skip))]
258256
pub remote: Option<bool>,
259257
}
260258

@@ -395,8 +393,6 @@ pub enum UserGlobalCacheConfig {
395393
tasks: Option<bool>,
396394

397395
/// Remote cache shared by tasks in the workspace.
398-
// Parsed but left out of the public types while remote caching is unreleased.
399-
#[cfg_attr(all(test, not(clippy)), ts(skip))]
400396
remote: Option<UserRemoteCacheConfig>,
401397
},
402398
}
@@ -475,6 +471,8 @@ impl ResolvedGlobalCacheConfig {
475471

476472
/// Remote cache settings in the workspace root's `cache` config.
477473
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
474+
// TS derive macro generates code using std types that clippy disallows; skip derive during linting
475+
#[cfg_attr(all(test, not(clippy)), derive(TS), ts(optional_fields, rename = "RemoteCacheConfig"))]
478476
#[serde(deny_unknown_fields, rename_all = "camelCase")]
479477
pub struct UserRemoteCacheConfig {
480478
/// Optional HTTP or HTTPS namespace endpoint. Overridden by
@@ -500,6 +498,10 @@ pub struct UserRemoteCacheConfig {
500498
/// containing literal `_` cannot be overridden via env).
501499
/// Setting an `Authorization` header suppresses automatic GitHub Actions
502500
/// OIDC.
501+
#[cfg_attr(
502+
all(test, not(clippy)),
503+
ts(optional, type = "{ [key in string]: string | undefined }")
504+
)]
503505
pub headers: Option<FxHashMap<Str, Secret>>,
504506
}
505507

0 commit comments

Comments
 (0)