storkit: merge 457_bug_store_json_created_at_project_root_instead_of_inside_storkit
This commit is contained in:
@@ -168,7 +168,6 @@ pub(crate) fn is_bare_project(project_root: &Path) -> bool {
|
|||||||
|| n == "LICENSE"
|
|| n == "LICENSE"
|
||||||
|| n == "README.md"
|
|| n == "README.md"
|
||||||
|| n == "script"
|
|| n == "script"
|
||||||
|| n == "store.json"
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
|
|||||||
@@ -294,6 +294,7 @@ fn write_story_kit_gitignore(root: &Path) -> Result<(), String> {
|
|||||||
"logs/",
|
"logs/",
|
||||||
"token_usage.jsonl",
|
"token_usage.jsonl",
|
||||||
"wizard_state.json",
|
"wizard_state.json",
|
||||||
|
"store.json",
|
||||||
];
|
];
|
||||||
|
|
||||||
let gitignore_path = root.join(".storkit").join(".gitignore");
|
let gitignore_path = root.join(".storkit").join(".gitignore");
|
||||||
@@ -330,11 +331,13 @@ fn write_story_kit_gitignore(root: &Path) -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Append root-level Story Kit entries to the project `.gitignore`.
|
/// Append root-level Story Kit entries to the project `.gitignore`.
|
||||||
/// Only `store.json` and `.storkit_port` remain here because they live at
|
/// Only `.storkit_port` and `.mcp.json` remain here because they live at
|
||||||
/// the project root and git does not support `../` patterns in `.gitignore`
|
/// the project root and git does not support `../` patterns in `.gitignore`
|
||||||
/// files, so they cannot be expressed in `.storkit/.gitignore`.
|
/// files, so they cannot be expressed in `.storkit/.gitignore`.
|
||||||
|
/// `store.json` is excluded via `.storkit/.gitignore` since it now lives
|
||||||
|
/// inside the `.storkit/` directory.
|
||||||
fn append_root_gitignore_entries(root: &Path) -> Result<(), String> {
|
fn append_root_gitignore_entries(root: &Path) -> Result<(), String> {
|
||||||
let entries = [".storkit_port", "store.json", ".mcp.json"];
|
let entries = [".storkit_port", ".mcp.json"];
|
||||||
|
|
||||||
let gitignore_path = root.join(".gitignore");
|
let gitignore_path = root.join(".gitignore");
|
||||||
let existing = if gitignore_path.exists() {
|
let existing = if gitignore_path.exists() {
|
||||||
@@ -705,11 +708,14 @@ mod tests {
|
|||||||
// Root .gitignore must contain root-level storkit entries
|
// Root .gitignore must contain root-level storkit entries
|
||||||
let root_content = fs::read_to_string(dir.path().join(".gitignore")).unwrap();
|
let root_content = fs::read_to_string(dir.path().join(".gitignore")).unwrap();
|
||||||
assert!(root_content.contains(".storkit_port"));
|
assert!(root_content.contains(".storkit_port"));
|
||||||
assert!(root_content.contains("store.json"));
|
// store.json now lives inside .storkit/ and must NOT appear in root .gitignore
|
||||||
|
assert!(!root_content.contains("store.json"));
|
||||||
// Root .gitignore must NOT contain .storkit/ sub-directory patterns
|
// Root .gitignore must NOT contain .storkit/ sub-directory patterns
|
||||||
assert!(!root_content.contains(".storkit/worktrees/"));
|
assert!(!root_content.contains(".storkit/worktrees/"));
|
||||||
assert!(!root_content.contains(".storkit/merge_workspace/"));
|
assert!(!root_content.contains(".storkit/merge_workspace/"));
|
||||||
assert!(!root_content.contains(".storkit/coverage/"));
|
assert!(!root_content.contains(".storkit/coverage/"));
|
||||||
|
// store.json must be in .storkit/.gitignore instead
|
||||||
|
assert!(sk_content.contains("store.json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
+11
-1
@@ -139,8 +139,18 @@ async fn main() -> Result<(), std::io::Error> {
|
|||||||
|
|
||||||
let app_state = Arc::new(SessionState::default());
|
let app_state = Arc::new(SessionState::default());
|
||||||
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
|
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
|
||||||
|
// Migrate legacy root-level store.json into .storkit/ if the new path does
|
||||||
|
// not yet exist. This keeps existing deployments working after upgrade.
|
||||||
|
let legacy_store_path = cwd.join("store.json");
|
||||||
|
let store_path = cwd.join(".storkit").join("store.json");
|
||||||
|
if legacy_store_path.exists() && !store_path.exists() {
|
||||||
|
if let Some(parent) = store_path.parent() {
|
||||||
|
let _ = std::fs::create_dir_all(parent);
|
||||||
|
}
|
||||||
|
let _ = std::fs::rename(&legacy_store_path, &store_path);
|
||||||
|
}
|
||||||
let store = Arc::new(
|
let store = Arc::new(
|
||||||
JsonFileStore::from_path(PathBuf::from("store.json")).map_err(std::io::Error::other)?,
|
JsonFileStore::from_path(store_path).map_err(std::io::Error::other)?,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Collect CLI args, skipping the binary name (argv[0]).
|
// Collect CLI args, skipping the binary name (argv[0]).
|
||||||
|
|||||||
Reference in New Issue
Block a user