mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix: stabilize windows project metadata assertions
This commit is contained in:
@@ -57,6 +57,27 @@ function fromBashPath(filePath) {
|
|||||||
return rawPath;
|
return rawPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeComparablePath(filePath) {
|
||||||
|
const nativePath = fromBashPath(filePath);
|
||||||
|
if (!nativePath) {
|
||||||
|
return nativePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
let comparablePath = nativePath;
|
||||||
|
try {
|
||||||
|
comparablePath = fs.realpathSync.native ? fs.realpathSync.native(nativePath) : fs.realpathSync(nativePath);
|
||||||
|
} catch {
|
||||||
|
comparablePath = path.resolve(nativePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
comparablePath = comparablePath.replace(/[\\/]+/g, '/');
|
||||||
|
if (comparablePath.length > 1 && !/^[A-Za-z]:\/$/.test(comparablePath)) {
|
||||||
|
comparablePath = comparablePath.replace(/\/+$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return process.platform === 'win32' ? comparablePath.toLowerCase() : comparablePath;
|
||||||
|
}
|
||||||
|
|
||||||
function sleepMs(ms) {
|
function sleepMs(ms) {
|
||||||
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
||||||
}
|
}
|
||||||
@@ -2361,7 +2382,12 @@ async function runTests() {
|
|||||||
const shellCommand = [`cd "${toBashPath(repoDir)}"`, `source "${toBashPath(detectProjectPath)}" >/dev/null 2>&1`, 'printf "%s\\n" "$PROJECT_ID"', 'printf "%s\\n" "$PROJECT_DIR"'].join('; ');
|
const shellCommand = [`cd "${toBashPath(repoDir)}"`, `source "${toBashPath(detectProjectPath)}" >/dev/null 2>&1`, 'printf "%s\\n" "$PROJECT_ID"', 'printf "%s\\n" "$PROJECT_DIR"'].join('; ');
|
||||||
|
|
||||||
const proc = spawn('bash', ['-lc', shellCommand], {
|
const proc = spawn('bash', ['-lc', shellCommand], {
|
||||||
env: { ...process.env, HOME: homeDir, USERPROFILE: homeDir },
|
env: {
|
||||||
|
...process.env,
|
||||||
|
HOME: homeDir,
|
||||||
|
USERPROFILE: homeDir,
|
||||||
|
CLAUDE_PROJECT_DIR: ''
|
||||||
|
},
|
||||||
stdio: ['ignore', 'pipe', 'pipe']
|
stdio: ['ignore', 'pipe', 'pipe']
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2395,19 +2421,26 @@ async function runTests() {
|
|||||||
|
|
||||||
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
||||||
const metadata = JSON.parse(fs.readFileSync(projectMetadataPath, 'utf8'));
|
const metadata = JSON.parse(fs.readFileSync(projectMetadataPath, 'utf8'));
|
||||||
const nativeMetadataRoot = fromBashPath(metadata.root);
|
const comparableMetadataRoot = normalizeComparablePath(metadata.root);
|
||||||
const nativeProjectDir = fromBashPath(projectDir);
|
const comparableRepoDir = normalizeComparablePath(repoDir);
|
||||||
|
const comparableProjectDir = normalizeComparablePath(projectDir);
|
||||||
|
const comparableExpectedProjectDir = normalizeComparablePath(expectedProjectDir);
|
||||||
|
|
||||||
assert.ok(registry[projectId], 'registry should contain the detected project');
|
assert.ok(registry[projectId], 'registry should contain the detected project');
|
||||||
assert.strictEqual(metadata.id, projectId, 'project.json should include the detected id');
|
assert.strictEqual(metadata.id, projectId, 'project.json should include the detected id');
|
||||||
assert.strictEqual(metadata.name, path.basename(repoDir), 'project.json should include the repo name');
|
assert.strictEqual(metadata.name, path.basename(repoDir), 'project.json should include the repo name');
|
||||||
assert.strictEqual(fs.realpathSync(nativeMetadataRoot), fs.realpathSync(repoDir), 'project.json should include the repo root');
|
assert.strictEqual(
|
||||||
|
comparableMetadataRoot,
|
||||||
|
comparableRepoDir,
|
||||||
|
`project.json should include the repo root (expected ${comparableRepoDir}, got ${comparableMetadataRoot})`
|
||||||
|
);
|
||||||
assert.strictEqual(metadata.remote, 'https://github.com/example/ecc-test.git', 'project.json should include the sanitized remote');
|
assert.strictEqual(metadata.remote, 'https://github.com/example/ecc-test.git', 'project.json should include the sanitized remote');
|
||||||
assert.ok(metadata.created_at, 'project.json should include created_at');
|
assert.ok(metadata.created_at, 'project.json should include created_at');
|
||||||
assert.ok(metadata.last_seen, 'project.json should include last_seen');
|
assert.ok(metadata.last_seen, 'project.json should include last_seen');
|
||||||
assert.ok(
|
assert.strictEqual(
|
||||||
nativeProjectDir.endsWith(path.join('projects', projectId)),
|
comparableProjectDir,
|
||||||
`PROJECT_DIR should point at the project storage directory, got: ${projectDir}`
|
comparableExpectedProjectDir,
|
||||||
|
`PROJECT_DIR should point at the project storage directory (expected ${comparableExpectedProjectDir}, got ${comparableProjectDir})`
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
cleanupTestDir(testRoot);
|
cleanupTestDir(testRoot);
|
||||||
|
|||||||
Reference in New Issue
Block a user