Skip to content

Commit

Permalink
Add more info to debug command (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer authored Jan 24, 2024
1 parent 957f1da commit 39b28a8
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-dolphins-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sumup/foundry": minor
---

Added a new `debug` command to inspect the detected configuration options.
5 changes: 5 additions & 0 deletions .changeset/silly-seals-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sumup/foundry": minor
---

Removed the obsolete `publish` option which hasn't been used since v6.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Alternatively, you can pass your answers to the `init` command directly as flags

```sh
-o, --openSource Whether the project is open-source [boolean]
--publish Whether to publish to NPM [boolean]
-c, --configDir The directory to write configs to [string] [default: "."]
--overwrite Whether to overwrite existing config files
[boolean] [default: false]
Expand Down
21 changes: 13 additions & 8 deletions src/cli/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
* limitations under the License.
*/

import { readPackageJson } from '../lib/files';
import {
warnAboutMissingPlugins,
warnAboutUnsupportedPlugins,
} from '../lib/options';
import { isArray, isEmpty, mapValues } from 'lodash/fp';

import { getOptions } from '../lib/options';
import * as logger from '../lib/logger';

export function debug(): void {
const packageJson = readPackageJson();
const options = getOptions();

const stringifiedOptions = mapValues(
(value) => (isArray(value) && !isEmpty(value) ? value.join(', ') : value),
options,
);

warnAboutUnsupportedPlugins(packageJson);
warnAboutMissingPlugins(packageJson);
logger.empty();
logger.info('Detected configuration:');
logger.table(stringifiedOptions);
}
1 change: 0 additions & 1 deletion src/cli/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ import { InitOptions } from '../types/shared';
export const DEFAULT_OPTIONS: InitOptions = {
configDir: '.',
openSource: false,
publish: false,
overwrite: false,
};
4 changes: 0 additions & 4 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ void yargs
desc: 'Whether the project is open-source',
type: 'boolean',
},
publish: {
desc: 'Whether to publish to NPM',
type: 'boolean',
},
configDir: {
alias: 'c',
desc: 'The directory to write configs to',
Expand Down
1 change: 0 additions & 1 deletion src/cli/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { DEFAULT_OPTIONS } from './defaults';
export interface InitParams {
configDir: string;
openSource?: boolean;
publish?: boolean;
overwrite?: boolean;
$0?: string;
_?: string[];
Expand Down
4 changes: 4 additions & 0 deletions src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ export const debug = (arg: LogMessage): void => {
export const empty = (): void => {
console.log('');
};

export const table = (obj: Record<string, unknown>): void => {
console.table(obj);
};
1 change: 0 additions & 1 deletion src/lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export function getOptions(): Required<Options> {
frameworks: pick(config.frameworks, detectFrameworks),
plugins: pick(config.plugins, detectPlugins),
openSource: pick(config.openSource, detectOpenSource),
publish: Boolean(config.publish),
};
}

Expand Down
1 change: 0 additions & 1 deletion src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export interface Options {
frameworks?: Framework[];
plugins?: Plugin[];
openSource?: boolean;
publish?: boolean;
}

export interface InitOptions extends Options {
Expand Down

0 comments on commit 39b28a8

Please sign in to comment.