{"version":3,"sources":["jsdelivr-header.js","/npm/ts-query-cli@1.0.3/ts-query.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;ACJA,MAAM,QAAU,QAAQ,aAClB,MAAQ,QAAQ,aAAa,SAC7B,GAAK,QAAQ,MAAM,UACnB,QAAE,SAAY,QAAQ,8BACpB,QAAS,QAAW,QAAQ,WAC9B,IAAM,QAAQ,cACd,OAAS,QAAQ,UACjB,KAAO,QAAQ,QACf,MAAQ,QAAQ,SAEhB,MAAQ,IAAI,OAAO,CAAE,YAAa,IAElC,UAAY,CAAC,EAAc,EAAM,EAAO,IAC5C,GAAG,SAAS,EAAM,QAAQ,MAAK,IAC7B,MAAM,EAAM,QAAQ,IAAI,GACxB,IAAI,EAAQ,QAAQ,EAAK,GACrB,IACF,EAAQ,EAAM,KAAI,GAAQ,IAAI,EAAM,MAElC,EAAM,OAAS,IACjB,QAAQ,IAAI,MAAM;gBACR,MAAM,KACZ,KAAK,KAAK,EAAc,KAAK,SAAS,EAAc;UAEpD,EAAM,KAAI,GAAK,KAAK,MAAM,OAAO,OAAM,KAAK;SAEhD,QAAQ,IAAI,IACd,IAGJ,QACG,QAAQ,QAAQ,kBAAkB,SAClC,YACC,MAAM;;;;;;;KASP,UAAU,6BACV,QAAO,MAAO,EAAM,EAAO,KAC1B,QAAQ,IAAI,GACZ,MACG,MAAM,GACN,IAAI,CAAC,KAAM,QACX,OACA,MAAK,IACJ,MAAM,KAAI,IAAM,UAAU,EAAM,EAAM,EAAO,IAAU,GACvD,IAGR,QAAQ,MAAM,QAAQ,MAEM,IAAxB,QAAQ,KAAK,SACf,QAAQ,WAAW,MAAM,KACzB,QAAQ,KAAK","file":"/npm/ts-query-cli@1.0.3/ts-query.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ts-query-cli@1.0.3/ts-query.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n\nconst program = require(\"commander\");\nconst files = require(\"filehound\").create();\nconst fs = require(\"fs\").promises;\nconst { tsquery } = require(\"@phenomnomnominal/tsquery\");\nconst { default: PQueue } = require(\"p-queue\");\nconst get = require(\"lodash.get\");\nconst dedent = require(\"dedent\");\nconst path = require(\"path\");\nconst chalk = require(\"chalk\");\n\nconst queue = new PQueue({ concurrency: 5 });\n\nconst queryFile = (originalPath, file, query, selector) =>\n  fs.readFile(file, \"utf8\").then(contents => {\n    const ast = tsquery.ast(contents);\n    let nodes = tsquery(ast, query);\n    if (selector) {\n      nodes = nodes.map(node => get(node, selector));\n    }\n    if (nodes.length > 0) {\n      console.log(dedent`\n        file: ${chalk.blue(\n          path.join(originalPath, path.relative(originalPath, file))\n        )}\n        ${nodes.map(n => `- ${chalk.yellow(n)}`).join(\"\\n\")}\n      `);\n      console.log(\"\");\n    }\n  });\n\nprogram\n  .version(require(\"./package.json\").version)\n  .description(\n    dedent`\n    Takes in <path> and recursively parses all .ts and .tsx files. Returns any AST node\n    that matches the tsquery (see below) <query> given. Optionally provide a [selector]\n    which is a string based key selection like a.b.c to return a value from the AST node.\n\n    For more info about building queries, see tsquery's repo:\n    https://github.com/phenomnomnominal/tsquery\n  `\n  )\n  .arguments(\"<path> <query> [selector]\")\n  .action(async (path, query, selector) => {\n    console.log(query);\n    files\n      .paths(path)\n      .ext([\"ts\", \"tsx\"])\n      .find()\n      .each(file => {\n        queue.add(() => queryFile(path, file, query, selector));\n      });\n  });\n\nprogram.parse(process.argv);\n\nif (process.argv.length === 2) {\n  program.outputHelp(chalk.red);\n  process.exit(1);\n}\n"]}