Skip to content

Commit

Permalink
Update readme.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaray committed Dec 20, 2024
1 parent 41c61d3 commit 9970753
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions readme.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
import { checkpoints, services, ratings } from './data';
import { readFile } from "./utils.ts";
import { services } from "./data/services.ts";
import { checkpoints } from "./data/checkpoints.ts";
import templates from "./data/templates.json" with { type: "json" };

let readme = await Bun.file('src/README.md').text();
let readme = await readFile("src/README.md");

console.log(readme);

process.exit(0);

const link = (service: string, templateId: string) => {
const { name, url, logo } = services[service];
return `<a href="${url}${templateId}"><img src="${logo}" alt="${name}" width="42" height="42"></a>`;
};

const rating = (x: (typeof checkpoints)[0]) => {
// if (!x.rating) return ratings.u[0];
if (!x.rating) return '-';
const [emoji, comment] = ratings[x.rating];
// Not sure how to display ratings yet. For now it's just the emoji
return `${emoji}`;
};

const tableRow = (x: (typeof checkpoints)[0]) => {
const vastai = x.vastaiTemplateId ? link('vastai', x.vastaiTemplateId) : 'todo';
const runpodio = x.runpodioTemplateId ? link('runpodio', x.runpodioTemplateId) : 'todo';
const vastai = x.vastaiTemplateId ? link("vastai", x.vastaiTemplateId) : "todo";
const runpodio = x.runpodioTemplateId ? link("runpodio", x.runpodioTemplateId) : "todo";
return `| ${rating(x)} | [${x.name}](${x.homepage}) | \`V${x.version}\` | ${vastai} | ${runpodio} |`;
};

readme = readme.replace(
/^.+{{sdxlStarters}}.*$/gm,
`${checkpoints
.filter((x) => x.base === 'sdxl')
.map((x) => tableRow(x))
.join('\n')}`,
`${
checkpoints
.filter((x) => x.base === "sdxl")
.map((x) => tableRow(x))
.join("\n")
}`,
);

readme = readme.replace(
/^.+{{pdxlStarters}}.*$/gm,
`${checkpoints
.filter((x) => x.base === 'pdxl')
.map((x) => tableRow(x))
.join('\n')}`,
`${
checkpoints
.filter((x) => x.base === "pdxl")
.map((x) => tableRow(x))
.join("\n")
}`,
);

await Bun.write('README.md', readme);
await Bun.write("README.md", readme);

0 comments on commit 9970753

Please sign in to comment.