mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
Fix template global.json under Windows (#4357)
# Description of Changes Make the `global.json` files under `templates` into literal copies of the root one, instead of symlinks. The symlinks were causing template breakage when the CLI was built under windows. # API and ABI breaking changes None # Expected complexity level and risk 1 # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [x] Changing a template's global.json causes `cargo ci global-json-policy` to fail - [x] Making a template's global.json into a symlink also causes `cargo ci global-json-policy` to fail --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
This commit is contained in:
@@ -1 +0,0 @@
|
||||
../../../global.json
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "8.0.100",
|
||||
"rollForward": "latestMinor"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../../../global.json
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "8.0.100",
|
||||
"rollForward": "latestMinor"
|
||||
}
|
||||
}
|
||||
+15
-16
@@ -46,7 +46,7 @@ fn check_global_json_policy() -> Result<()> {
|
||||
ensure_repo_root()?;
|
||||
|
||||
let root_json = Path::new("global.json");
|
||||
let root_real = fs::canonicalize(root_json)?;
|
||||
let root_contents = fs::read_to_string(root_json)?;
|
||||
|
||||
fn find_all_global_json(dir: &Path) -> Result<Vec<PathBuf>> {
|
||||
let mut out = Vec::new();
|
||||
@@ -67,25 +67,24 @@ fn check_global_json_policy() -> Result<()> {
|
||||
|
||||
let mut ok = true;
|
||||
for p in globals {
|
||||
let resolved = fs::canonicalize(&p)?;
|
||||
|
||||
// The root global.json itself is allowed.
|
||||
if resolved == root_real {
|
||||
println!("OK: {}", p.display());
|
||||
continue;
|
||||
}
|
||||
|
||||
let meta = fs::symlink_metadata(&p)?;
|
||||
if !meta.file_type().is_symlink() {
|
||||
eprintln!("Error: {} is not a symlink to root global.json", p.display());
|
||||
let is_symlink = meta.file_type().is_symlink();
|
||||
let is_template_global_json = p.strip_prefix(".").unwrap_or(&p).starts_with(Path::new("templates"));
|
||||
if is_template_global_json && is_symlink {
|
||||
eprintln!(
|
||||
"Error: {} is a symlink. Template files must not be symlinks; they are copied literally and this will break if the CLI is built under Windows where symlinks are not supported.",
|
||||
p.display()
|
||||
);
|
||||
ok = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
eprintln!("Error: {} does not resolve to root global.json", p.display());
|
||||
eprintln!(" resolved: {}", resolved.display());
|
||||
eprintln!(" expected: {}", root_real.display());
|
||||
ok = false;
|
||||
let contents = fs::read_to_string(&p)?;
|
||||
if contents != root_contents {
|
||||
eprintln!("Error: {} does not match the root global.json contents", p.display());
|
||||
ok = false;
|
||||
} else if !is_template_global_json || !is_symlink {
|
||||
println!("OK: {}", p.display());
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user