-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(*): fix gatsby-cli dep in source-filesystem & plugin-sharp (#14881)
Bring back progressbar functionality in ink and npm fixes.
- Loading branch information
Showing
30 changed files
with
517 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/gatsby-cli/src/reporter/reporters/ink/components/progress-bar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from "react" | ||
import { Box } from "ink" | ||
import calcElapsedTime from "../../../../util/calc-elapsed-time" | ||
|
||
const maxWidth = 30 | ||
const minWidth = 10 | ||
|
||
const getLength = prop => String(prop).length | ||
|
||
export default function ProgressBar({ message, current, total, startTime }) { | ||
const percentage = total ? Math.round((current / total) * 100) : 0 | ||
const terminalWidth = process.stdout.columns || 80 | ||
const availableWidth = | ||
terminalWidth - | ||
getLength(message) - | ||
getLength(current) - | ||
getLength(total) - | ||
getLength(percentage) - | ||
11 // margins + extra characters | ||
|
||
const progressBarWidth = Math.max( | ||
minWidth, | ||
Math.min(maxWidth, availableWidth) | ||
) | ||
|
||
return ( | ||
<Box flexDirection="row"> | ||
<Box marginRight={3} width={progressBarWidth}> | ||
[ | ||
<Box width={progressBarWidth - 2}> | ||
{`=`.repeat(((progressBarWidth - 2) * percentage) / 100)} | ||
</Box> | ||
] | ||
</Box> | ||
<Box marginRight={1}>{calcElapsedTime(startTime)} s</Box> | ||
<Box marginRight={1}> | ||
{current}/{total} | ||
</Box> | ||
<Box marginRight={1}>{`` + percentage}%</Box> | ||
<Box textWrap="truncate">{message}</Box> | ||
</Box> | ||
) | ||
} |
7 changes: 0 additions & 7 deletions
7
...rter/reporters/ink/components/activity.js → ...orter/reporters/ink/components/spinner.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.