Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/thatstupidcomputer / scripts/generate-search.ts |
| Date | Not specified in source |
| Repository | Janady13/thatstupidcomputer |
| Revision | 57555cde46910102dd25d6c1c1fb2c359e9655bd |
| Branch | main |
| Path or archive member | scripts/generate-search.ts |
| Original SHA-256 | 1262db71a9fcca505ec384bbf4bca171edd2f4d2b52f31158313f89c29ddc6dc |
| Git blob SHA | dd5b9cf1da9c44ce346b83a7d026072dde2d8e7e |
| Reading-copy SHA-256 | 1262db71a9fcca505ec384bbf4bca171edd2f4d2b52f31158313f89c29ddc6dc |
Recovered source transcript
Download complete source text ↓18 lines · 1.1 KB
import { mkdir, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { robotsTxt, sitemapXml } from '../packages/site/search.ts';
import { loadSiteConfig, type PublicSiteConfig } from '../packages/site/truth.ts';
export async function generateSearch({ outDir, config }: { outDir: string; config: PublicSiteConfig }): Promise<void> {
if (config.deployment === 'production' && config.truthStatus !== 'approved-projection') throw new Error('Production search assets require the approved public truth projection');
await mkdir(outDir, { recursive: true });
await writeFile(resolve(outDir, 'robots.txt'), robotsTxt(config));
await writeFile(resolve(outDir, 'sitemap.xml'), sitemapXml(config));
}
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
const deployment = process.argv.includes('--production') ? 'production' : 'preview';
const outArg = process.argv.find((arg) => arg.startsWith('--out='));
await generateSearch({ outDir: outArg?.slice(6) ?? 'apps/web/dist', config: loadSiteConfig({ deployment }) });
}