resources.ts•2.36 kB
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export interface UsageResource {
uri: string;
name: string;
description: string;
mimeType: string;
}
export const USAGE_RESOURCES: UsageResource[] = [
{
uri: 'infracost://usage/small',
name: 'Infracost Usage Defaults - Small ($5/month)',
description:
'Small usage defaults for Infracost. Sets each usage-based cost to approximately $5/month for common configurations. Useful for development and small-scale environments.',
mimeType: 'text/yaml',
},
{
uri: 'infracost://usage/medium',
name: 'Infracost Usage Defaults - Medium ($10/month)',
description:
'Medium usage defaults for Infracost. Sets each usage-based cost to approximately $10/month for common configurations. Useful for staging and medium-scale environments.',
mimeType: 'text/yaml',
},
{
uri: 'infracost://usage/large',
name: 'Infracost Usage Defaults - Large ($20/month)',
description:
'Large usage defaults for Infracost. Sets each usage-based cost to approximately $20/month for common configurations. Useful for production and large-scale environments.',
mimeType: 'text/yaml',
},
{
uri: 'infracost://usage/example',
name: 'Infracost Usage Example',
description:
'Example infracost-usage.yml file showing how to customize usage values for specific resources. Can be used as a template for creating custom usage files.',
mimeType: 'text/yaml',
},
];
export function getUsageResourceContent(uri: string): string {
const resourcesDir = join(__dirname, '..', 'resources');
switch (uri) {
case 'infracost://usage/small':
return readFileSync(join(resourcesDir, 'infracost-usage-defaults.small.yml'), 'utf-8');
case 'infracost://usage/medium':
return readFileSync(join(resourcesDir, 'infracost-usage-defaults.medium.yml'), 'utf-8');
case 'infracost://usage/large':
return readFileSync(join(resourcesDir, 'infracost-usage-defaults.large.yml'), 'utf-8');
case 'infracost://usage/example':
return readFileSync(join(resourcesDir, 'infracost-usage-example.yml'), 'utf-8');
default:
throw new Error(`Unknown resource URI: ${uri}`);
}
}