feat: zod schemas for app metadata in config.json (#21231)
* feat: add config metadata validation and update app store metadata parsing * fix: update config metadata import to use parseconfigMetadata * Create configType.ts * fix: update app store metadata parsing to use parseconfigMetadata * feat: enhance generateFiles to handle metadata imports * Update build.ts * Updated build file --------- Co-authored-by: Tushar Bhatt <[email protected]> Co-authored-by: Kartik Saini <[email protected]> Co-authored-by: Devanshu Sharma <[email protected]> Co-authored-by: Volnei Munhoz <[email protected]>
This commit is contained in:
2 files changed
+127
-1
No files matched your search
@@ -9,6 +9,7 @@ import prettier from "prettier";
|
||||
//@ts-ignore
|
||||
import prettierConfig from "@calcom/config/prettier-preset";
|
||||
import type { AppMeta } from "@calcom/types/App";
|
||||
import { AppMetaSchema } from "@calcom/types/AppMetaSchema";
|
||||
|
||||
import { APP_STORE_PATH } from "./constants";
|
||||
import { getAppName } from "./utils/getAppName";
|
||||
@@ -72,7 +73,14 @@ function generateFiles() {
|
||||
let app;
|
||||
|
||||
if (fs.existsSync(configPath)) {
|
||||
app = JSON.parse(fs.readFileSync(configPath).toString());
|
||||
try {
|
||||
const rawConfig = fs.readFileSync(configPath, "utf8");
|
||||
const parsedConfig = JSON.parse(rawConfig);
|
||||
app = AppMetaSchema.parse(parsedConfig);
|
||||
} catch (error) {
|
||||
const prefix = `Config error in ${path.join(APP_STORE_PATH, appDirs[i].path, "config.json")}`;
|
||||
throw new Error(`${prefix}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
} else if (fs.existsSync(metadataPath)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
app = require(metadataPath).metadata;
|
||||
|
||||
Reference in new issue
Block a user