refactor: Taro 模板发现与校验收敛为目录驱动
This commit is contained in:
1 parent
89fdfd7d83
commit
076c6124c8
5 files changed
+20
-10
No files matched your search
@@ -3,7 +3,6 @@ import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
|
||||
const root = path.resolve(__dirname, "../../..");
|
||||
const key = process.env.TEMPLATE_KEY || "acheng-campus-food";
|
||||
const previewAllTemplates = process.env.PREVIEW_ALL_TEMPLATES === "true";
|
||||
const templates = fs
|
||||
.readdirSync(path.join(root, "packages"))
|
||||
@@ -13,7 +12,10 @@ const templates = fs
|
||||
fs.existsSync(path.join(root, "packages", directory, "taro/index.tsx")) &&
|
||||
fs.existsSync(path.join(root, "packages", directory, "template.json")),
|
||||
)
|
||||
.map((directory) => directory.slice("template-".length));
|
||||
.map((directory) => directory.slice("template-".length))
|
||||
.sort();
|
||||
const key = process.env.TEMPLATE_KEY || templates[0];
|
||||
if (!key) throw new Error("No Taro template package found");
|
||||
if (!templates.includes(key)) throw new Error(`Unsupported Taro template: ${key}`);
|
||||
const template = path.join(root, "packages", `template-${key}`);
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(template, "template.json"), "utf8")) as {
|
||||
|
||||
Reference in new issue
Block a user