@strapi/strapi
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
1 lines • 6.34 kB
Source Map (JSON)
{"version":3,"file":"cli.mjs","sources":["../src/cli/index.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport { commands as strapiCommands } from './commands';\n\nimport { createLogger } from './utils/logger';\nimport { loadTsConfig, type TsConfig } from './utils/tsconfig';\nimport { CLIContext } from './types';\nimport { version } from '../../package.json';\n\nconst createCLI = async (argv: string[], command = new Command()) => {\n // Initial program setup\n command.storeOptionsAsProperties(false).allowUnknownOption(true);\n\n // Help command\n command.helpOption('-h, --help', 'Display help for command');\n command.addHelpCommand('help [command]', 'Display help for command');\n\n command.version(version, '-v, --version', 'Output the version number');\n\n const cwd = process.cwd();\n\n const hasDebug = argv.includes('--debug');\n const hasSilent = argv.includes('--silent');\n\n const logger = createLogger({ debug: hasDebug, silent: hasSilent, timestamp: false });\n\n // Lazy: defer `loadTsConfig` (which loads `typescript`) until first read\n let tsconfig: TsConfig | undefined;\n let loaded = false;\n const ctx = { cwd, logger } as CLIContext;\n Object.defineProperty(ctx, 'tsconfig', {\n enumerable: true,\n get() {\n if (!loaded) {\n loaded = true;\n tsconfig = loadTsConfig({ cwd, path: 'tsconfig.json', logger });\n }\n return tsconfig;\n },\n });\n\n // Load all commands\n for (const commandFactory of strapiCommands) {\n try {\n const subCommand = await commandFactory({ command, argv, ctx });\n\n // Add this command to the Commander command object\n if (subCommand) {\n command.addCommand(subCommand);\n }\n } catch (e) {\n console.error(`Failed to load command`, e);\n }\n }\n\n // TODO v6: remove these deprecation notices\n const deprecatedCommands = [\n { name: 'plugin:init', message: 'Please use `npx @strapi/sdk-plugin init` instead.' },\n {\n name: 'plugin:verify',\n message: 'After migrating your plugin to v5, use `strapi-plugin verify`',\n },\n {\n name: 'plugin:watch',\n message: 'After migrating your plugin to v5, use `strapi-plugin watch`',\n },\n {\n name: 'plugin:watch:link',\n message: 'After migrating your plugin to v5, use `strapi-plugin watch:link`',\n },\n {\n name: 'plugin:build',\n message: 'After migrating your plugin to v5, use `strapi-plugin build`',\n },\n ];\n\n // Add hidden commands for deprecatedCommands that output a warning that the command has been removed.\n deprecatedCommands.forEach(({ name, message }) => {\n const deprecated = new Command(name)\n .command(name)\n .description('(deprecated)')\n .action(() => {\n console.warn(\n `The command ${name} has been deprecated. See the Strapi 5 migration guide for more information.`\n );\n if (message) {\n console.warn(message);\n }\n });\n command.addCommand(deprecated, { hidden: true });\n });\n return command;\n};\n\nconst runCLI = async (argv = process.argv, command = new Command()) => {\n const commands = await createCLI(argv, command);\n await commands.parseAsync(argv);\n};\n\nexport { runCLI, createCLI };\n"],"names":["createCLI","argv","command","Command","storeOptionsAsProperties","allowUnknownOption","helpOption","addHelpCommand","version","cwd","process","hasDebug","includes","hasSilent","logger","createLogger","debug","silent","timestamp","tsconfig","loaded","ctx","Object","defineProperty","enumerable","get","loadTsConfig","path","commandFactory","strapiCommands","subCommand","addCommand","e","console","error","deprecatedCommands","name","message","forEach","deprecated","description","action","warn","hidden","runCLI","commands","parseAsync"],"mappings":";;;;;;AASA,MAAMA,SAAAA,GAAY,OAAOC,IAAAA,EAAgBC,OAAAA,GAAU,IAAIC,OAAAA,EAAS,GAAA;;AAE9DD,IAAAA,OAAAA,CAAQE,wBAAwB,CAAC,KAAA,CAAA,CAAOC,kBAAkB,CAAC,IAAA,CAAA;;IAG3DH,OAAAA,CAAQI,UAAU,CAAC,YAAA,EAAc,0BAAA,CAAA;IACjCJ,OAAAA,CAAQK,cAAc,CAAC,gBAAA,EAAkB,0BAAA,CAAA;IAEzCL,OAAAA,CAAQM,OAAO,CAACA,OAAAA,EAAS,eAAA,EAAiB,2BAAA,CAAA;IAE1C,MAAMC,GAAAA,GAAMC,QAAQD,GAAG,EAAA;IAEvB,MAAME,QAAAA,GAAWV,IAAAA,CAAKW,QAAQ,CAAC,SAAA,CAAA;IAC/B,MAAMC,SAAAA,GAAYZ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