-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
refactor(cli): make the CLI an even thinner wrapper around command functions #7583
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: +79 B (0%) Total Size: 801 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
siteDir: string, | ||
): Promise<void> { | ||
export async function externalCommand(cli: CommanderStatic): Promise<void> { | ||
const siteDir = await fs.realpath('.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 that looks different from the other cli commands 🤪
But same as before so maybe a different issue
Pre-flight checklist
Motivation
The reason is because the commander functions are very weakly typed: basically
action(fn: (...args: any[]) => void | Promise<void>)
. This makes TS-ESLint whine about unsafe arguments when we pass theseany
into our actual function, even when it's actually safe.This also means people who try to use these functions on Node side do not immediately get feature parity with the CLI: they have to resolve site directory, they have to apply default values (see also #7220), they have to even change the order of parameters.
We should just handle these ourselves. The CLI is just a very thin wrapper that automatically invokes these functions. Now users can do
await docusaurus.build();
without passing any arguments.Test Plan
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs