diff --git a/src/cli/debug.ts b/src/cli/debug.ts new file mode 100644 index 00000000..801b0e71 --- /dev/null +++ b/src/cli/debug.ts @@ -0,0 +1,27 @@ +/** + * Copyright 2024, SumUp Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { readPackageJson } from '../lib/files'; +import { + warnAboutMissingPlugins, + warnAboutUnsupportedPlugins, +} from '../lib/options'; + +export function debug(): void { + const packageJson = readPackageJson(); + + warnAboutUnsupportedPlugins(packageJson); + warnAboutMissingPlugins(packageJson); +} diff --git a/src/cli/index.ts b/src/cli/index.ts index 0b3738fb..f1220538 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -19,6 +19,7 @@ import yargs from 'yargs'; import { run, RunParams } from './run'; import { init, InitParams } from './init'; +import { debug } from './debug'; import { DEFAULT_OPTIONS } from './defaults'; // eslint-disable-next-line no-void @@ -55,19 +56,28 @@ void yargs 'Run any of the bundled tools.', execute('run'), ) + .command( + 'debug', + 'See which frameworks and plugins Foundry has detected in your project', + execute('debug'), + ) .showHelpOnFail(true) .demandCommand(1, '') .help() .version().argv; -type CommandType = 'init' | 'run'; +type CommandType = 'init' | 'run' | 'debug'; function execute(command: CommandType) { - const commands = { run, init }; + const commands = { run, init, debug }; const commandFn = commands[command]; - return (args: unknown): void => { - // eslint-disable-next-line no-console - commandFn(args as RunParams & InitParams).catch(console.error); + return async (args: unknown): Promise<void> => { + try { + await commandFn(args as RunParams & InitParams); + } catch (error) { + // eslint-disable-next-line no-console + console.error(error); + } }; }