{"version":3,"file":"is-package-json.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/is-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAEjD,OAAO,EAAE,uBAAuB,EAAE,0BAAsB;AACxD,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,wBAAoB;AAGzE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CACtB,KAAK,CAAC,WAAW,CAAC,MAAM,EACxB,wBAAwB,CACzB,CAAC;QACF,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACvC,OAAO,CAAC,MAAM,CACZ,mBAAmB,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAC3D,IACE,gBAAgB,CAAC,WACnB,iBAAiB,uBAAuB,CACtC,wBAAwB,EACxB,OAAO,EACP,KAAK,CACN,EAAE,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { validate } from '@metamask/superstruct';\n\nimport { getStructFailureMessage } from '../../structs';\nimport { NpmSnapFileNames, NpmSnapPackageJsonStruct } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the structure of package.json.\n */\nexport const isPackageJson: ValidatorMeta = {\n  severity: 'error',\n  structureCheck(files, context) {\n    if (!files.packageJson) {\n      return;\n    }\n    const [error] = validate(\n      files.packageJson.result,\n      NpmSnapPackageJsonStruct,\n    );\n    if (error) {\n      for (const failure of error.failures()) {\n        context.report(\n          `is-package-json-${failure.type}-${failure.path.join('-')}`,\n          `\"${\n            NpmSnapFileNames.PackageJson\n          }\" is invalid: ${getStructFailureMessage(\n            NpmSnapPackageJsonStruct,\n            failure,\n            false,\n          )}`,\n        );\n      }\n    }\n  },\n};\n"]}