feat(03-01): add createTempGitProject helper to tests/helpers.cjs
- Creates temp dir with .planning/phases structure - Initializes git repo with user config - Writes initial PROJECT.md and commits it - Exports createTempGitProject alongside existing helpers
This commit is contained in:
@@ -33,8 +33,28 @@ function createTempProject() {
|
||||
return tmpDir;
|
||||
}
|
||||
|
||||
// Create temp directory with initialized git repo and at least one commit
|
||||
function createTempGitProject() {
|
||||
const tmpDir = fs.mkdtempSync(path.join(require('os').tmpdir(), 'gsd-test-'));
|
||||
fs.mkdirSync(path.join(tmpDir, '.planning', 'phases'), { recursive: true });
|
||||
|
||||
execSync('git init', { cwd: tmpDir, stdio: 'pipe' });
|
||||
execSync('git config user.email "test@test.com"', { cwd: tmpDir, stdio: 'pipe' });
|
||||
execSync('git config user.name "Test"', { cwd: tmpDir, stdio: 'pipe' });
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(tmpDir, '.planning', 'PROJECT.md'),
|
||||
'# Project\n\nTest project.\n'
|
||||
);
|
||||
|
||||
execSync('git add -A', { cwd: tmpDir, stdio: 'pipe' });
|
||||
execSync('git commit -m "initial commit"', { cwd: tmpDir, stdio: 'pipe' });
|
||||
|
||||
return tmpDir;
|
||||
}
|
||||
|
||||
function cleanup(tmpDir) {
|
||||
fs.rmSync(tmpDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
module.exports = { runGsdTools, createTempProject, cleanup, TOOLS_PATH };
|
||||
module.exports = { runGsdTools, createTempProject, createTempGitProject, cleanup, TOOLS_PATH };
|
||||
|
||||
Reference in New Issue
Block a user