mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-08-28 05:25:25 +00:00
* feat: configure prettier with pre-commit hook integration Add prettier, lint-staged, and prettier-plugin-tailwindcss at the repo root with husky pre-commit hook integration. Moves husky from gitnexus/ to root package.json for reliable hook installation. - Root package.json with prepare/format/format:check scripts - .prettierrc with endOfLine:lf and tailwindStylesheet for TW v4 - .prettierignore excluding fixtures, vendor, generated, *.d.ts, *.md - .gitattributes enforcing LF line endings for Windows consistency - Pre-commit hook uses direct node_modules/.bin/ paths (no npx) * style: apply prettier formatting to entire codebase One-time bulk format. No logic changes. Use .git-blame-ignore-revs to skip this commit in git blame. * chore: add .git-blame-ignore-revs for prettier format commit * perf: pre-commit hook runs only tests related to staged files Use vitest --related to scope test execution to tests that import the changed files, instead of running the full suite on every commit. * perf: remove vitest from pre-commit hook, keep in CI only Pre-commit now runs lint-staged + tsc only. Tests run in CI (ci-tests.yml) where they belong — keeps commits fast. * ci: add prettier format check to quality workflow PRs will now fail if code isn't formatted with prettier.
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
// ...existing code...
|
|
import { describe, it, expect } from 'vitest';
|
|
import { isWriteQuery as isWriteQueryAdapter } from '../../src/mcp/core/lbug-adapter';
|
|
import { isWriteQuery as isWriteQueryBackend } from '../../src/mcp/local/local-backend';
|
|
|
|
describe('isWriteQuery regex tests', () => {
|
|
const writeQueries = [
|
|
'CREATE (n:Test {name: "x"})',
|
|
'MATCH (n) SET n.x = 1',
|
|
'MERGE (n:Foo {id: 1})',
|
|
'DELETE n',
|
|
'DROP INDEX ON :Foo(prop)',
|
|
'ALTER TABLE Something',
|
|
'COPY TO something',
|
|
'DETACH DELETE n',
|
|
];
|
|
|
|
const readQueries = [
|
|
'MATCH (n:CreateHelpers) RETURN n',
|
|
'MATCH (a)-[:CALLS]->(b) RETURN a, b',
|
|
'MATCH (f:File)-[r:DEFINES]->(n) RETURN n',
|
|
"MATCH (n) WHERE n.name = 'MERGEHelper' RETURN n", // word present as data
|
|
'MATCH (n) RETURN n',
|
|
'MATCH (n) WHERE n.content CONTAINS ":CREATE" RETURN n',
|
|
'MATCH (n:SomethingWithSET) RETURN n',
|
|
];
|
|
|
|
it('adapter isWriteQuery should detect real write queries', () => {
|
|
for (const q of writeQueries) {
|
|
expect(isWriteQueryAdapter(q), `adapter should detect write for: ${q}`).toBe(true);
|
|
}
|
|
});
|
|
|
|
it('adapter isWriteQuery should not false-positive on label/rel or data', () => {
|
|
for (const q of readQueries) {
|
|
expect(isWriteQueryAdapter(q), `adapter false-positive on: ${q}`).toBe(false);
|
|
}
|
|
});
|
|
|
|
it('backend isWriteQuery should detect real write queries', () => {
|
|
for (const q of writeQueries) {
|
|
expect(isWriteQueryBackend(q), `backend should detect write for: ${q}`).toBe(true);
|
|
}
|
|
});
|
|
|
|
it('backend isWriteQuery should not false-positive on label/rel or data', () => {
|
|
for (const q of readQueries) {
|
|
expect(isWriteQueryBackend(q), `backend false-positive on: ${q}`).toBe(false);
|
|
}
|
|
});
|
|
});
|