trim: remove dead code and move large spec docs to attic

- Remove unused exports: renderProgress, formatTripleBoundaryCounterexample, clearCapturedRoutes
- Remove dead BUILTIN_PLUGIN_CONTRACTS constant (auto-registration removed earlier)
- Fix app-loader error messages to mention multiple export patterns
- Move to attic: protocol-extensions-spec, OUTBOUND_CONTRACT_MOCKING_SPEC, PLUGIN_CONTRACTS_SPEC, fastify-structure
- Build: clean | Tests: 849 pass, 0 fail
This commit is contained in:
John Dvorak
2026-04-30 12:47:40 -07:00
parent 115d3465b1
commit 5921b1437f
14 changed files with 7 additions and 120 deletions
+2 -2
View File
@@ -116,8 +116,8 @@ export async function checkRouteDiscovery(options: RouteCheckOptions): Promise<R
name: 'route-discovery',
status: 'fail',
message: `App file ${appFile} does not export a valid object.`,
detail: 'Ensure the app file exports a Fastify instance as default.',
remediation: 'Export your Fastify instance as default: export default app;',
detail: 'Ensure the app file exports a Fastify instance or a factory function.',
remediation: 'Export your Fastify instance: export default app; or export const createApp = () => app; or module.exports = app;',
mode: 'all',
};
}
+1 -1
View File
@@ -642,7 +642,7 @@ export async function qualifyCommand(
}
return {
exitCode: USAGE_ERROR,
message: 'No Fastify app found. Ensure app.js exports a Fastify instance.',
message: 'No Fastify app found. Ensure app.js exports a Fastify instance or a factory function.\n\nSupported patterns:\n export default app\n export const createApp = () => app\n module.exports = app',
}
}
+1 -1
View File
@@ -468,7 +468,7 @@ export async function verifyCommand(
const errorMessage = err instanceof Error ? err.message : String(err)
return {
exitCode: USAGE_ERROR,
message: `No Fastify app found. Ensure app.js exports a Fastify instance.\n\nError: ${errorMessage}\n\nNext:\n Run \`apophis init\` to scaffold a working app.js and config.`,
message: `No Fastify app found. Ensure app.js exports a Fastify instance or a factory function.\n\nSupported patterns:\n export default app\n export const createApp = () => app\n module.exports = app\n\nError: ${errorMessage}\n\nNext:\n Run \`apophis init\` to scaffold a working app.js and config.`,
}
}
-23
View File
@@ -183,29 +183,6 @@ function generateNextSteps(failure: FailureRecord): string {
// Progress and summary rendering
// ---------------------------------------------------------------------------
/**
* Render progress for a running command.
* Safe for CI (no spinners, just text updates).
*/
export function renderProgress(
current: number,
total: number,
label: string,
ctx: OutputContext,
): string {
const c = getColorizer(ctx);
const pct = total > 0 ? Math.round((current / total) * 100) : 0;
if (ctx.isCI || !ctx.isTTY) {
// CI mode: simple text, no spinner
return `${label} [${current}/${total}] ${pct}%`;
}
// TTY mode: with color
const bar = renderProgressBar(current, total, 20, ctx);
return `${c.dim(label)} ${bar} ${c.bold(`${pct}%`)}`;
}
/**
* Render a simple ASCII progress bar.
*/
-6
View File
@@ -87,9 +87,3 @@ export const discoverRoutes = (instance: { routes?: Array<{ method: string; url:
// Fastify 5 fallback: routes registered before plugin
return discoverRoutesFallback(instance)
}
/**
* Clear captured routes for an instance (useful for testing).
*/
export const clearCapturedRoutes = (instance: object): void => {
capturedRoutes.delete(instance)
}
-40
View File
@@ -143,46 +143,6 @@ export class PluginContractRegistry {
}
}
// ============================================================================
// Built-in Plugin Contracts
// ============================================================================
export const BUILTIN_PLUGIN_CONTRACTS: Record<string, PluginContractSpec> = {
'@fastify/auth': {
appliesTo: '**',
hooks: {
onRequest: {
requires: ['request_headers(this).authorization != null'],
},
},
},
'@fastify/compress': {
appliesTo: '**',
hooks: {
onSend: {
ensures: ['response_headers(this).content-encoding != null'],
},
},
},
'@fastify/cors': {
appliesTo: '**',
hooks: {
onRequest: {
ensures: ['response_headers(this).access-control-allow-origin != null'],
},
},
},
'@fastify/rate-limit': {
appliesTo: '**',
hooks: {
onRequest: {
ensures: [
'response_headers(this).x-ratelimit-limit != null',
'response_headers(this).x-ratelimit-remaining != null',
],
},
},
},
}
// ============================================================================
// Factory
// ============================================================================
export function createPluginContractRegistry(): PluginContractRegistry {
-44
View File
@@ -360,47 +360,3 @@ export function applyChaosToAllResponses(
)
})
}
// ============================================================================
// Formatting
// ============================================================================
export function formatTripleBoundaryCounterexample(result: TripleBoundaryResult): string {
const lines: string[] = []
lines.push('Triple-boundary counterexample:')
lines.push('')
lines.push(`Route: ${result.command.route.method} ${result.command.route.path}`)
lines.push('')
lines.push('Request:')
lines.push(JSON.stringify(result.command.request, null, 2))
lines.push('')
if (result.command.dependencyResponses.length > 0) {
lines.push('Dependency responses:')
for (const dep of result.command.dependencyResponses) {
lines.push(` ${dep.contractName}: ${dep.statusCode}`)
lines.push(` ${JSON.stringify(dep.body)}`)
}
lines.push('')
}
if (result.command.chaosEvents.length > 0) {
lines.push('Chaos events:')
for (const chaos of result.command.chaosEvents) {
if (chaos.type === 'none') continue
lines.push(` ${chaos.type}`)
if (chaos.contractName) lines.push(` Target: ${chaos.contractName}`)
if (chaos.delayMs) lines.push(` Delay: ${chaos.delayMs}ms`)
if (chaos.statusCode) lines.push(` Status: ${chaos.statusCode}`)
if (chaos.corruptionStrategy) lines.push(` Corruption: ${chaos.corruptionStrategy}`)
if (chaos.corruptionField) lines.push(` Field: ${chaos.corruptionField}`)
}
lines.push('')
}
if (result.failureBoundary) {
lines.push(`Failure boundary: ${result.failureBoundary}`)
}
if (result.failureDescription) {
lines.push(`Description: ${result.failureDescription}`)
}
if (result.error) {
lines.push(`Error: ${result.error}`)
}
return lines.join('\n')
}