{"version":3,"file":"console.mjs","sources":["../../../../src/cli/commands/console.ts"],"sourcesContent":["import REPL from 'repl';\nimport { createCommand } from 'commander';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../types';\nimport { runAction } from '../utils/helpers';\n\nconst action = async () => {\n  const appContext = await compileStrapi();\n  const app = await createStrapi(appContext).load();\n\n  app.start().then(() => {\n    const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template\n\n    repl.on('exit', (err: Error) => {\n      if (err) {\n        app.log.error(err);\n        process.exit(1);\n      }\n\n      app.server.destroy();\n      process.exit(0);\n    });\n  });\n};\n\n/**\n * `$ strapi console`\n */\nconst command: StrapiCommand = () => {\n  return createCommand('console')\n    .description('Open the Strapi framework console')\n    .action(runAction('console', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","load","start","then","repl","REPL","config","info","name","on","err","log","error","process","exit","server","destroy","command","createCommand","description","runAction"],"mappings":";;;;;AAOA,MAAMA,MAAAA,GAAS,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,aAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAAA,GAAM,MAAMC,YAAAA,CAAaH,UAAAA,CAAAA,CAAYI,IAAI,EAAA;IAE/CF,GAAAA,CAAIG,KAAK,EAAA,CAAGC,IAAI,CAAC,IAAA;AACf,QAAA,MAAMC,IAAAA,GAAOC,IAAAA,CAAKH,KAAK,CAACH,GAAAA,CAAIO,MAAM,CAACC,IAAI,CAACC,IAAI,GAAG,KAAA,IAAS;QAExDJ,IAAAA,CAAKK,EAAE,CAAC,MAAA,EAAQ,CAACC,GAAAA,GAAAA;AACf,YAAA,IAAIA,GAAAA,EAAK;gBACPX,GAAAA,CAAIY,GAAG,CAACC,KAAK,CAACF,GAAAA,CAAAA;AACdG,gBAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,YAAA;YAEAf,GAAAA,CAAIgB,MAAM,CAACC,OAAO,EAAA;AAClBH,YAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,QAAA,CAAA,CAAA;AACF,IAAA,CAAA,CAAA;AACF;AAEA;;AAEC,UACKG,OAAAA,GAAyB,IAAA;IAC7B,OAAOC,aAAAA,CAAc,WAClBC,WAAW,CAAC,qCACZvB,MAAM,CAACwB,UAAU,SAAA,EAAWxB,MAAAA,CAAAA,CAAAA;AACjC;;;;"}