Check all nested KCL samples (#6880)
This commit is contained in:
7
Makefile
7
Makefile
@ -44,15 +44,15 @@ endif
|
|||||||
# BUILD
|
# BUILD
|
||||||
|
|
||||||
CARGO_SOURCES := rust/.cargo/config.toml $(wildcard rust/Cargo.*) $(wildcard rust/**/Cargo.*)
|
CARGO_SOURCES := rust/.cargo/config.toml $(wildcard rust/Cargo.*) $(wildcard rust/**/Cargo.*)
|
||||||
|
KCL_SOURCES := $(wildcard public/kcl-samples/**/*.kcl)
|
||||||
RUST_SOURCES := $(wildcard rust/**/*.rs)
|
RUST_SOURCES := $(wildcard rust/**/*.rs)
|
||||||
|
|
||||||
REACT_SOURCES := $(wildcard src/*.tsx) $(wildcard src/**/*.tsx)
|
REACT_SOURCES := $(wildcard src/*.tsx) $(wildcard src/**/*.tsx)
|
||||||
TYPESCRIPT_SOURCES := tsconfig.* $(wildcard src/*.ts) $(wildcard src/**/*.ts)
|
TYPESCRIPT_SOURCES := tsconfig.* $(wildcard src/*.ts) $(wildcard src/**/*.ts)
|
||||||
VITE_SOURCES := $(wildcard vite.*) $(wildcard vite/**/*.tsx)
|
VITE_SOURCES := $(wildcard vite.*) $(wildcard vite/**/*.tsx)
|
||||||
|
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: install public/kcl_wasm_lib_bg.wasm .vite/build/main.js
|
build: install public/kcl_wasm_lib_bg.wasm public/kcl-samples/manifest.json .vite/build/main.js
|
||||||
|
|
||||||
public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES) $(RUST_SOURCES)
|
public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES) $(RUST_SOURCES)
|
||||||
ifdef WINDOWS
|
ifdef WINDOWS
|
||||||
@ -61,6 +61,9 @@ else
|
|||||||
npm run build:wasm:dev
|
npm run build:wasm:dev
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
public/kcl-samples/manifest.json: $(KCL_SOURCES)
|
||||||
|
cd rust/kcl-lib && EXPECTORATE=overwrite cargo test generate_manifest
|
||||||
|
|
||||||
.vite/build/main.js: $(REACT_SOURCES) $(TYPESCRIPT_SOURCES) $(VITE_SOURCES)
|
.vite/build/main.js: $(REACT_SOURCES) $(TYPESCRIPT_SOURCES) $(VITE_SOURCES)
|
||||||
npm run tronb:vite:dev
|
npm run tronb:vite:dev
|
||||||
|
|
||||||
|
@ -122,7 +122,6 @@
|
|||||||
"files:invalidate-bucket:nightly": "./scripts/invalidate-files-bucket.sh --nightly",
|
"files:invalidate-bucket:nightly": "./scripts/invalidate-files-bucket.sh --nightly",
|
||||||
"postinstall": "electron-rebuild",
|
"postinstall": "electron-rebuild",
|
||||||
"generate:machine-api": "npx openapi-typescript ./openapi/machine-api.json -o src/lib/machine-api.d.ts",
|
"generate:machine-api": "npx openapi-typescript ./openapi/machine-api.json -o src/lib/machine-api.d.ts",
|
||||||
"generate:samples-manifest": "cd public/kcl-samples && node generate-manifest.js",
|
|
||||||
"tron:start": "electron-forge start",
|
"tron:start": "electron-forge start",
|
||||||
"chrome:test": "PLATFORM=web NODE_ENV=development playwright test --config=playwright.config.ts --project='Google Chrome' --grep-invert=@snapshot",
|
"chrome:test": "PLATFORM=web NODE_ENV=development playwright test --config=playwright.config.ts --project='Google Chrome' --grep-invert=@snapshot",
|
||||||
"tronb:vite:dev": "vite build -c vite.main.config.ts -m development && vite build -c vite.preload.config.ts -m development && vite build -c vite.renderer.config.ts -m development",
|
"tronb:vite:dev": "vite build -c vite.main.config.ts -m development && vite build -c vite.preload.config.ts -m development && vite build -c vite.renderer.config.ts -m development",
|
||||||
|
1
rust/Cargo.lock
generated
1
rust/Cargo.lock
generated
@ -1959,6 +1959,7 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
"validator",
|
"validator",
|
||||||
|
"walkdir",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
|
@ -85,6 +85,7 @@ tynm = "0.1.10"
|
|||||||
url = { version = "2.5.4", features = ["serde"] }
|
url = { version = "2.5.4", features = ["serde"] }
|
||||||
uuid = { workspace = true, features = ["v4", "v5", "js", "serde"] }
|
uuid = { workspace = true, features = ["v4", "v5", "js", "serde"] }
|
||||||
validator = { version = "0.20.0", features = ["derive"] }
|
validator = { version = "0.20.0", features = ["derive"] }
|
||||||
|
walkdir = "2.5.0"
|
||||||
web-time = "1.1"
|
web-time = "1.1"
|
||||||
winnow = "=0.6.24"
|
winnow = "=0.6.24"
|
||||||
zip = { workspace = true }
|
zip = { workspace = true }
|
||||||
|
@ -8,6 +8,7 @@ use std::{
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use fnv::FnvHashSet;
|
use fnv::FnvHashSet;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use super::Test;
|
use super::Test;
|
||||||
|
|
||||||
@ -250,19 +251,12 @@ fn get_kcl_metadata(project_path: &Path, files: &[String]) -> Option<KclMetadata
|
|||||||
let title = lines[0].trim_start_matches(COMMENT_PREFIX).trim().to_string();
|
let title = lines[0].trim_start_matches(COMMENT_PREFIX).trim().to_string();
|
||||||
let description = lines[1].trim_start_matches(COMMENT_PREFIX).trim().to_string();
|
let description = lines[1].trim_start_matches(COMMENT_PREFIX).trim().to_string();
|
||||||
|
|
||||||
// Get the path components
|
// Get the relative path from the project directory to the primary KCL file
|
||||||
let path_components: Vec<String> = full_path_to_primary_kcl
|
let path_from_project_dir = full_path_to_primary_kcl
|
||||||
.components()
|
.strip_prefix(INPUTS_DIR.as_path())
|
||||||
.map(|comp| comp.as_os_str().to_string_lossy().to_string())
|
.unwrap_or(&full_path_to_primary_kcl)
|
||||||
.collect();
|
.to_string_lossy()
|
||||||
|
.to_string();
|
||||||
// Get the last two path components
|
|
||||||
let len = path_components.len();
|
|
||||||
let path_from_project_dir = if len >= 2 {
|
|
||||||
format!("{}/{}", path_components[len - 2], path_components[len - 1])
|
|
||||||
} else {
|
|
||||||
primary_kcl_file.clone()
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut files = files.to_vec();
|
let mut files = files.to_vec();
|
||||||
files.sort();
|
files.sort();
|
||||||
@ -281,21 +275,23 @@ fn get_kcl_metadata(project_path: &Path, files: &[String]) -> Option<KclMetadata
|
|||||||
fn generate_kcl_manifest(dir: &Path) -> Result<()> {
|
fn generate_kcl_manifest(dir: &Path) -> Result<()> {
|
||||||
let mut manifest = Vec::new();
|
let mut manifest = Vec::new();
|
||||||
|
|
||||||
// Collect all directory entries first and sort them by name for consistent ordering
|
// Collect all directory entries first
|
||||||
let mut entries: Vec<_> = fs::read_dir(dir)?
|
let mut entries: Vec<_> = WalkDir::new(dir)
|
||||||
.filter_map(Result::ok)
|
.follow_links(true)
|
||||||
.filter(|e| e.path().is_dir())
|
.into_iter()
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Sort directories by name for consistent ordering
|
// Sort directories by name for consistent ordering
|
||||||
entries.sort_by_key(|a| a.file_name());
|
entries.sort_by_key(|a| a.file_name().to_string_lossy().to_string());
|
||||||
|
|
||||||
|
// Loop through all directories and add to manifest if KCL sample
|
||||||
for entry in entries {
|
for entry in entries {
|
||||||
let project_path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
if project_path.is_dir() {
|
if path.is_dir() {
|
||||||
// Get all .kcl files in the directory
|
// Get all .kcl files in the directory
|
||||||
let files: Vec<String> = fs::read_dir(&project_path)?
|
let files: Vec<String> = fs::read_dir(path)?
|
||||||
.filter_map(Result::ok)
|
.filter_map(Result::ok)
|
||||||
.filter(|e| {
|
.filter(|e| {
|
||||||
if let Some(ext) = e.path().extension() {
|
if let Some(ext) = e.path().extension() {
|
||||||
@ -311,7 +307,7 @@ fn generate_kcl_manifest(dir: &Path) -> Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(metadata) = get_kcl_metadata(&project_path, &files) {
|
if let Some(metadata) = get_kcl_metadata(path, &files) {
|
||||||
manifest.push(metadata);
|
manifest.push(metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user