mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 22:46:32 +00:00
style(server): format the files the health lanes added or moved
Prettier on every new or moved file that was not formatted, so lint:format holds them; the files taken off the format baseline are the ones that moved or were formatted on the way.
This commit is contained in:
@@ -180,20 +180,31 @@ describe('import-boundaries.mjs', () => {
|
||||
|
||||
it('BOUND-012: a provider may not import the orchestrator above it, type-only included', () => {
|
||||
const dir = serverRoot({
|
||||
'nest/maps/maps.service.ts': "import { Osm } from './providers/osm.client';\nexport class MapsService { o = Osm; }\n",
|
||||
'nest/maps/providers/osm.client.ts': "import type { MapsService } from '../maps.service';\nexport class Osm { m?: MapsService; }\n",
|
||||
'nest/maps/maps.service.ts':
|
||||
"import { Osm } from './providers/osm.client';\nexport class MapsService { o = Osm; }\n",
|
||||
'nest/maps/providers/osm.client.ts':
|
||||
"import type { MapsService } from '../maps.service';\nexport class Osm { m?: MapsService; }\n",
|
||||
'nest/docs/docs.service.ts': 'export class DocsService {}\n',
|
||||
'nest/docs/providers/webdav/client.ts': "import { DocsService } from '../../docs.service';\nexport const c = DocsService;\n",
|
||||
'nest/trips/providers/geo.ts': "import { MapsService } from '../../maps/maps.service';\nexport const g = MapsService;\n",
|
||||
'nest/docs/providers/webdav/client.ts':
|
||||
"import { DocsService } from '../../docs.service';\nexport const c = DocsService;\n",
|
||||
'nest/trips/providers/geo.ts':
|
||||
"import { MapsService } from '../../maps/maps.service';\nexport const g = MapsService;\n",
|
||||
// A provider importing another service of its own domain is not the orchestrator.
|
||||
'nest/docs/docs-cache.service.ts': 'export class DocsCacheService {}\n',
|
||||
'nest/docs/providers/cached.ts': "import { DocsCacheService } from '../docs-cache.service';\nexport const k = DocsCacheService;\n",
|
||||
'nest/docs/providers/cached.ts':
|
||||
"import { DocsCacheService } from '../docs-cache.service';\nexport const k = DocsCacheService;\n",
|
||||
});
|
||||
const { status, out } = run(dir);
|
||||
expect(status).toBe(1);
|
||||
expect(out).toContain('FAIL providersImportOrchestrator: nest/maps/providers/osm.client.ts -> nest/maps/maps.service.ts');
|
||||
expect(out).toContain('FAIL providersImportOrchestrator: nest/docs/providers/webdav/client.ts -> nest/docs/docs.service.ts');
|
||||
expect(out).toContain('FAIL providersImportOrchestrator: nest/trips/providers/geo.ts -> nest/maps/maps.service.ts');
|
||||
expect(out).toContain(
|
||||
'FAIL providersImportOrchestrator: nest/maps/providers/osm.client.ts -> nest/maps/maps.service.ts',
|
||||
);
|
||||
expect(out).toContain(
|
||||
'FAIL providersImportOrchestrator: nest/docs/providers/webdav/client.ts -> nest/docs/docs.service.ts',
|
||||
);
|
||||
expect(out).toContain(
|
||||
'FAIL providersImportOrchestrator: nest/trips/providers/geo.ts -> nest/maps/maps.service.ts',
|
||||
);
|
||||
expect(out).not.toContain('providers/cached.ts');
|
||||
});
|
||||
|
||||
@@ -257,7 +268,8 @@ describe('import-boundaries.mjs', () => {
|
||||
const owners = JSON.stringify({ Trips: 'trips', Todos: 'todo' });
|
||||
const files = {
|
||||
'nest/trips/trips.service.ts': '@InjectRepository(Trips) class S {}\nexport { S };\n',
|
||||
'nest/todo/todo.service.ts': '@InjectRepository(Todos) class T {}\n@InjectRepository(Trips) class U {}\nexport { T, U };\n',
|
||||
'nest/todo/todo.service.ts':
|
||||
'@InjectRepository(Todos) class T {}\n@InjectRepository(Trips) class U {}\nexport { T, U };\n',
|
||||
};
|
||||
const withOwners = (baseline: unknown) => {
|
||||
const dir = serverRoot(files, baseline);
|
||||
|
||||
@@ -30,14 +30,20 @@ function serverRoot(files: Record<string, string>, baseline: unknown = { counts:
|
||||
writeFileSync(path.join(dir, file), text);
|
||||
}
|
||||
if (baseline !== null) {
|
||||
writeFileSync(path.join(dir, 'scripts/query-api-baseline.json'), typeof baseline === 'string' ? baseline : JSON.stringify(baseline));
|
||||
writeFileSync(
|
||||
path.join(dir, 'scripts/query-api-baseline.json'),
|
||||
typeof baseline === 'string' ? baseline : JSON.stringify(baseline),
|
||||
);
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
function run(dir: string, ...args: string[]): { status: number | null; out: string } {
|
||||
try {
|
||||
const stdout = execFileSync(process.execPath, [SCRIPT, `--dir=${dir}`, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
const stdout = execFileSync(process.execPath, [SCRIPT, `--dir=${dir}`, ...args], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
return { status: 0, out: stdout };
|
||||
} catch (err) {
|
||||
const { status, stdout, stderr } = err as { status: number | null; stdout: string; stderr: string };
|
||||
@@ -57,9 +63,13 @@ describe('query-api-ratchet.mjs', () => {
|
||||
});
|
||||
|
||||
it('QAPI-002: fails a new file holding one, and counts createQueryBuilder too', () => {
|
||||
const { status, out } = run(serverRoot({ [`${REPOS}/New.repository.ts`]: `${calls(1)}em.createQueryBuilder(X);\n` }));
|
||||
const { status, out } = run(
|
||||
serverRoot({ [`${REPOS}/New.repository.ts`]: `${calls(1)}em.createQueryBuilder(X);\n` }),
|
||||
);
|
||||
expect(status).toBe(1);
|
||||
expect(out).toContain(`FAIL ${REPOS}/New.repository.ts: 2 QueryBuilder call(s), a file without a baseline entry may hold none.`);
|
||||
expect(out).toContain(
|
||||
`FAIL ${REPOS}/New.repository.ts: 2 QueryBuilder call(s), a file without a baseline entry may hold none.`,
|
||||
);
|
||||
});
|
||||
|
||||
it('QAPI-003: holds a baselined file to its entry', () => {
|
||||
@@ -77,7 +87,13 @@ describe('query-api-ratchet.mjs', () => {
|
||||
it('QAPI-005: an entry above its file fails until --update lowers it, and --update never raises or adds one', () => {
|
||||
const dir = serverRoot(
|
||||
{ [`${REPOS}/A.repository.ts`]: calls(1), [`${REPOS}/B.repository.ts`]: calls(4) },
|
||||
{ counts: { [`${REPOS}/A.repository.ts`]: 3, [`${REPOS}/Gone.repository.ts`]: 1, [`${REPOS}/B.repository.ts`]: 2 } },
|
||||
{
|
||||
counts: {
|
||||
[`${REPOS}/A.repository.ts`]: 3,
|
||||
[`${REPOS}/Gone.repository.ts`]: 1,
|
||||
[`${REPOS}/B.repository.ts`]: 2,
|
||||
},
|
||||
},
|
||||
);
|
||||
const stale = run(dir);
|
||||
expect(stale.status).toBe(1);
|
||||
@@ -85,7 +101,9 @@ describe('query-api-ratchet.mjs', () => {
|
||||
expect(stale.out).toContain(`FAIL ${REPOS}/Gone.repository.ts is held at 1`);
|
||||
|
||||
run(dir, '--update');
|
||||
const lowered = JSON.parse(readFileSync(path.join(dir, 'scripts/query-api-baseline.json'), 'utf8')) as { counts: Record<string, number> };
|
||||
const lowered = JSON.parse(readFileSync(path.join(dir, 'scripts/query-api-baseline.json'), 'utf8')) as {
|
||||
counts: Record<string, number>;
|
||||
};
|
||||
expect(lowered.counts).toEqual({ [`${REPOS}/A.repository.ts`]: 1, [`${REPOS}/B.repository.ts`]: 2 });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user