Skip to content

Commit

Permalink
feat(cli): add hints to commands (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Jan 30, 2024
1 parent a4f5834 commit 854cf4b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion packages/cli/src/lib/autorun/autorun-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ export function yargsAutorunCommandObject() {
if (options.upload) {
await upload(options);
} else {
console.warn('Upload skipped because configuration is not set.'); // @TODO log verbose
console.warn('Upload skipped because configuration is not set.');
console.info(
[
'💡 Integrate the portal:',
'- npx code-pushup upload - Run upload to upload the created report to the server',
' https://github.com/code-pushup/cli/tree/main/packages/cli#upload-command',
'- Portal Integration - https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#portal-integration',
'- Upload Command - https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#portal-integration',
].join('\n'),
);
}
},
} satisfies CommandModule;
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/src/lib/collect/collect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ export function yargsCollectCommandObject(): CommandModule {
console.info(chalk.bold(CLI_NAME));
console.info(chalk.gray(`Run ${command}...`));
await collectAndPersistReports(options);
const { upload = {} } = args as unknown as Record<
'upload',
object | undefined
>;
if (Object.keys(upload).length === 0) {
console.info(
[
'💡 Visualize your reports:',
'- npx code-pushup upload - Run upload to upload the created report to the server',
' https://github.com/code-pushup/cli/tree/main/packages/cli#upload-command',
'- npx code-pushup autorun - Run collect & upload',
' https://github.com/code-pushup/cli/tree/main/packages/cli#autorun-command',
].join('\n'),
);
}
},
} satisfies CommandModule;
}
9 changes: 9 additions & 0 deletions packages/cli/src/lib/upload/upload-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export function yargsUploadCommandObject() {

const options = args as unknown as UploadOptions;
if (!options.upload) {
console.info(
[
'💡 Integrate the portal:',
'- npx code-pushup upload - Run upload to upload the created report to the server',
' https://github.com/code-pushup/cli/tree/main/packages/cli#upload-command',
'- Portal Integration - https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#portal-integration',
'- Upload Command - https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#portal-integration',
].join('\n'),
);
throw new Error('Upload configuration not set');
}
await upload(options);
Expand Down

0 comments on commit 854cf4b

Please sign in to comment.