refactor: 统一模板契约并修复预览版本
This commit is contained in:
1 parent
cd2992c00a
commit
50b87e48de
56 files changed
+7849
-5756
No files matched your search
@@ -17,7 +17,7 @@ const templates = fs
|
||||
const manifest = JSON.parse(
|
||||
fs.readFileSync(path.join(packageRoot, entry.name, "template.json"), "utf8"),
|
||||
);
|
||||
return { ...manifest, visualTemplateKey: manifest.packageKey };
|
||||
return manifest;
|
||||
})
|
||||
.sort((left, right) => left.packageKey.localeCompare(right.packageKey));
|
||||
|
||||
@@ -34,7 +34,7 @@ const fingerprint = crypto
|
||||
.createHash("sha256")
|
||||
.update(JSON.stringify(canonical(templates)))
|
||||
.digest("hex");
|
||||
const content = `// prettier-ignore\nimport type { TemplatePackageManifest } from "./index.js";\n\nexport const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[] = ${JSON.stringify(templates, null, 2)};\nexport const generatedTemplatePackageRegistryHash =\n "${fingerprint}";\n`;
|
||||
const content = `import type { TemplatePackageManifest } from "./index.js";\n\n// prettier-ignore\nexport const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[] = ${JSON.stringify(templates, null, 2)};\nexport const generatedTemplatePackageRegistryHash =\n "${fingerprint}";\n`;
|
||||
const write = process.argv.includes("--write");
|
||||
if (write) {
|
||||
fs.writeFileSync(outputPath, content);
|
||||
|
||||
@@ -109,8 +109,8 @@ for (const { directory, manifest, package: packageMetadata } of packages) {
|
||||
const packageIndustries = Array.isArray(manifest.supportedIndustryTemplates)
|
||||
? manifest.supportedIndustryTemplates
|
||||
: [];
|
||||
const visualKey = manifest.visualTemplateKey ?? key;
|
||||
const visualRegistered = visualKeys.includes(visualKey);
|
||||
const visualKey = manifest.visualTemplateKey;
|
||||
const visualRegistered = typeof visualKey === "string" && visualKeys.includes(visualKey);
|
||||
const rendererPath = `${directory}/taro/index.tsx`;
|
||||
const rendererExists = fs.existsSync(path.join(packagesRoot, rendererPath));
|
||||
const rendererExport = rendererExists
|
||||
@@ -141,6 +141,7 @@ for (const { directory, manifest, package: packageMetadata } of packages) {
|
||||
errors.push("No capability definitions found in capability-contracts.ts");
|
||||
if (!rendererGlob) errors.push("Admin renderer package glob is not discoverable");
|
||||
if (!packageIndustries.length) errors.push(`${key}: supportedIndustryTemplates is empty`);
|
||||
if (!visualRegistered) errors.push(`${key}: visualTemplateKey is missing or unknown`);
|
||||
if (unknownCapabilities.length)
|
||||
errors.push(`${key}: unknown capabilities ${unknownCapabilities.join(", ")}`);
|
||||
if (!toolchainCompatible)
|
||||
|
||||
Reference in new issue
Block a user