{"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,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,aAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,YAAaH,CAAAA,UAAAA,CAAAA,CAAYI,IAAI,EAAA;IAE/CF,GAAIG,CAAAA,KAAK,EAAGC,CAAAA,IAAI,CAAC,IAAA;AACf,QAAA,MAAMC,IAAOC,GAAAA,IAAAA,CAAKH,KAAK,CAACH,GAAIO,CAAAA,MAAM,CAACC,IAAI,CAACC,IAAI,GAAG,KAAA,IAAS;QAExDJ,IAAKK,CAAAA,EAAE,CAAC,MAAA,EAAQ,CAACC,GAAAA,GAAAA;AACf,YAAA,IAAIA,GAAK,EAAA;gBACPX,GAAIY,CAAAA,GAAG,CAACC,KAAK,CAACF,GAAAA,CAAAA;AACdG,gBAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf;YAEAf,GAAIgB,CAAAA,MAAM,CAACC,OAAO,EAAA;AAClBH,YAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,SAAA,CAAA;AACF,KAAA,CAAA;AACF;AAEA;;AAEC,UACKG,OAAyB,GAAA,IAAA;IAC7B,OAAOC,aAAAA,CAAc,WAClBC,WAAW,CAAC,qCACZvB,MAAM,CAACwB,UAAU,SAAWxB,EAAAA,MAAAA,CAAAA,CAAAA;AACjC;;;;"}