Skip to content

Commit

Permalink
Add debug command
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Jan 23, 2024
1 parent b5f5457 commit 832a1d4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
27 changes: 27 additions & 0 deletions src/cli/debug.ts
Original file line number Diff line number Diff line change
@@ -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);
}

Check warning on line 27 in src/cli/debug.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/debug.ts#L2-L27

Added lines #L2 - L27 were not covered by tests
20 changes: 15 additions & 5 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import yargs from 'yargs';

import { run, RunParams } from './run';
import { init, InitParams } from './init';
import { debug } from './debug';

Check warning on line 22 in src/cli/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/index.ts#L22

Added line #L22 was not covered by tests
import { DEFAULT_OPTIONS } from './defaults';

// eslint-disable-next-line no-void
Expand Down Expand Up @@ -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'),
)

Check warning on line 63 in src/cli/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/index.ts#L59-L63

Added lines #L59 - L63 were not covered by tests
.showHelpOnFail(true)
.demandCommand(1, '')
.help()
.version().argv;

type CommandType = 'init' | 'run';
type CommandType = 'init' | 'run' | 'debug';

Check warning on line 69 in src/cli/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/index.ts#L69

Added line #L69 was not covered by tests

function execute(command: CommandType) {
const commands = { run, init };
const commands = { run, init, debug };

Check warning on line 72 in src/cli/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/index.ts#L72

Added line #L72 was not covered by tests
const commandFn = commands[command];

Check warning on line 73 in src/cli/index.ts

View workflow job for this annotation

GitHub Actions / ci (18)

Variable Assigned to Object Injection Sink

Check warning on line 73 in src/cli/index.ts

View workflow job for this annotation

GitHub Actions / ci (20)

Variable Assigned to Object Injection Sink

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);
}

Check warning on line 81 in src/cli/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/index.ts#L75-L81

Added lines #L75 - L81 were not covered by tests
};
}

0 comments on commit 832a1d4

Please sign in to comment.