feat: 迁移示例媒体到本地存储
This commit is contained in:
1 parent
6ac2d9421b
commit
03f947e9b8
10 files changed
+225
-22
No files matched your search
@@ -0,0 +1,24 @@
|
||||
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}`);
|
||||
}
|
||||
Reference in new issue
Block a user