Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions scripts/cue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ cmd_fmt() {
list-docs-files | grep -v "${CUE_SOURCES}/reference/remap/functions/" | xargs cue fmt "$@"
}

cmd_vet() {
list-docs-files | xargs cue vet --concrete --all-errors "$@"
}

cmd_eval() {
list-docs-files | xargs cue eval --concrete --all-errors "$@"
}
Expand All @@ -53,15 +49,14 @@ cmd_build() {

usage() {
cat >&2 <<-EOF
Usage: $0 [build|check|fmt|list|vet|eval|export]
Usage: $0 [build|check|fmt|list|eval|export]

Modes:
build - build all of the CUE sources and export them into a Hugo-processable
JSON object
check - check for the CUE sources' correctness
fmt - format all CUE files using the built-in formatter
list - list all the documentation files
vet - check the documentation files and print errors
eval - print the evaluated documentation,
optionally pass the expression to evaluate via "-e EXPRESSION"
export - export the documentation,
Expand Down Expand Up @@ -92,7 +87,7 @@ EOF

MODE="${1:-}"
case "$MODE" in
build|check|fmt|list|vet|eval|export)
build|check|fmt|list|eval|export)
shift
"cmd_$MODE" "$@"
;;
Expand Down
32 changes: 27 additions & 5 deletions vdev/src/commands/check/docs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::app;
use crate::app::CommandExt;
use crate::utils::git;
use anyhow::{Result, bail};
use crate::utils::{git, paths};
use anyhow::{Context as _, Result, bail};
use glob::glob;
use std::env;
use std::path::PathBuf;
use std::process::Command;

#[derive(clap::Args, Debug)]
Expand All @@ -17,6 +20,12 @@ const CUE_DIR: &str = "website/cue";
/// 2. Ensuring that the .cue files can compile.
impl Cli {
pub fn exec(self) -> Result<()> {
// Resolve all `website/cue/**` globs against the repo root rather
// than the caller's CWD. Without this, running the binary from
// anywhere outside the repo root silently scans nothing and reports `0 error(s)`
let repo_root = paths::find_repo_root()?;
env::set_current_dir(&repo_root)?;

if Command::new("cue").arg("version").check_output().is_err() {
bail!("Error: cue is not installed");
}
Expand All @@ -35,9 +44,13 @@ impl Cli {

println!("Validating cue files correctness...");

if let Err(err) = app::exec(CUE_SCRIPT, ["vet"], true) {
bail!("CUE files validation failed:\n{err}");
}
let all_cue_files = Self::get_all_cue_files()?;

Command::new("cue")
.args(["vet", "--concrete", "--all-errors"])
.args(all_cue_files)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep CUE arguments below the Windows command limit

On native Windows, this fails before CUE starts: I checked the current checkout's 698 matched paths, and the constructed command is 42,918 UTF-16 characters, above CreateProcessW's 32,767-character limit. The previous scripts/cue.sh path fed names through xargs, which bounded each invocation; passing every path to one Command removes that protection, so Windows contributors cannot run cargo vdev check docs. Preserve a bounded invocation or input mechanism rather than placing every filename on one command line.

Useful? React with 👍 / 👎.

@Captain1653 Captain1653 Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the large number of files (~700), on native Windows this could hit the Win32 CreateProcessW command-line length limit (32,767 characters).

  • Splitting files into arbitrary chunks (chunks(...)) is not viable because CUE files share types across directories (e.g. definitions in urls.cue), which leads to unresolved references (reference not found) unless evaluated in a single session.
  • Standard CUE package evaluation (./...) currently fails because the directory lacks a root cue.mod module setup.

Details are here

.check_output()
.context("CUE files validation failed")?;

println!("Success! The contents of the sources in the './{CUE_DIR}' directory are valid");
Ok(())
Expand All @@ -55,4 +68,13 @@ impl Cli {

Ok(file_names)
}

fn get_all_cue_files() -> Result<Vec<PathBuf>> {
let pattern = &format!("{CUE_DIR}/**/*.cue");

// Paths are yielded in alphabetical order via glob
let files: Vec<PathBuf> = glob(pattern)?.collect::<Result<Vec<PathBuf>, _>>()?;

Ok(files)
}
}
Loading