MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / validateManifest

Function validateManifest

source code/utils/plugins/validatePlugin.ts:816–905  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

814 * Validate a manifest file or directory (auto-detects type)
815 */
816export async function validateManifest(
817 filePath: string,
818): Promise<ValidationResult> {
819 const absolutePath = path.resolve(filePath)
820
821 // Stat path to check if it's a directory — handle ENOENT inline
822 let stats: Stats | null = null
823 try {
824 stats = await stat(absolutePath)
825 } catch (e: unknown) {
826 if (!isENOENT(e)) {
827 throw e
828 }
829 }
830
831 if (stats?.isDirectory()) {
832 // Look for manifest files in .claude-plugin directory
833 // Prefer marketplace.json over plugin.json
834 const marketplacePath = path.join(
835 absolutePath,
836 '.claude-plugin',
837 'marketplace.json',
838 )
839 const marketplaceResult = await validateMarketplaceManifest(marketplacePath)
840 // Only fall through if the marketplace file was not found (ENOENT)
841 if (marketplaceResult.errors[0]?.code !== 'ENOENT') {
842 return marketplaceResult
843 }
844
845 const pluginPath = path.join(absolutePath, '.claude-plugin', 'plugin.json')
846 const pluginResult = await validatePluginManifest(pluginPath)
847 if (pluginResult.errors[0]?.code !== 'ENOENT') {
848 return pluginResult
849 }
850
851 return {
852 success: false,
853 errors: [
854 {
855 path: 'directory',
856 message: `No manifest found in directory. Expected .claude-plugin/marketplace.json or .claude-plugin/plugin.json`,
857 },
858 ],
859 warnings: [],
860 filePath: absolutePath,
861 fileType: 'plugin',
862 }
863 }
864
865 const manifestType = detectManifestType(filePath)
866
867 switch (manifestType) {
868 case 'plugin':
869 return validatePluginManifest(filePath)
870 case 'marketplace':
871 return validateMarketplaceManifest(filePath)
872 case 'unknown': {
873 // Try to parse and guess based on content

Callers

nothing calls this directly

Calls 9

statFunction · 0.85
isENOENTFunction · 0.85
validatePluginManifestFunction · 0.85
detectManifestTypeFunction · 0.85
readFileFunction · 0.85
jsonParseFunction · 0.85
getErrnoCodeFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected