Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more info to debug command #931

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
export interface InitParams {
configDir: string;
openSource?: boolean;
publish?: boolean;
overwrite?: boolean;
$0?: string;
_?: string[];
Expand Down Expand Up @@ -287,7 +286,7 @@

const resolvedPath = resolve(path);

if (!existsSync(resolvedPath)) {

Check warning on line 289 in src/cli/init.ts

View workflow job for this annotation

GitHub Actions / ci (18)

Found existsSync from package "fs" with non literal argument at index 0

Check warning on line 289 in src/cli/init.ts

View workflow job for this annotation

GitHub Actions / ci (20)

Found existsSync from package "fs" with non literal argument at index 0
return `The path "${resolvedPath}" doesn't exist. Please try another one.`;
}

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