25 lines
742 B
JavaScript
25 lines
742 B
JavaScript
import { readdir, readFile } from "node:fs/promises";
|
|
|
|
const files = [
|
|
"packages/template-acheng-campus-food/template.json",
|
|
"packages/template-linjing-editorial/template.json",
|
|
"apps/api/prisma/seed.ts",
|
|
];
|
|
|
|
const remoteImagePattern = /https?:\/\/[^\s"']+/gi;
|
|
|
|
for (const file of files) {
|
|
const content = await readFile(file, "utf8");
|
|
const matches = content.match(remoteImagePattern) ?? [];
|
|
if (matches.length > 0) {
|
|
console.error(`${file} contains remote media:\n${matches.join("\n")}`);
|
|
process.exitCode = 1;
|
|
}
|
|
}
|
|
|
|
const assetDirectory = "apps/api/prisma/assets";
|
|
for (const file of await readdir(assetDirectory)) {
|
|
if (!/\.(?:jpe?g|png|webp|avif)$/i.test(file)) continue;
|
|
await readFile(`media/seed/${file}`);
|
|
}
|