Comparing version 3.7.3 to 3.7.4
@@ -21,6 +21,9 @@ import { FormattedStatus } from "../../format-transfer-status.js"; | ||
protected options: BaseCliOptions; | ||
protected minNameLength: number; | ||
constructor(options: BaseCliOptions); | ||
switchTransferToShortText(): string; | ||
protected get showETA(): boolean; | ||
protected get nameSize(): number; | ||
protected getNameAndCommentDataParts(): DataPart[]; | ||
protected getETA(spacer?: string): DataLine; | ||
protected getETA(spacer?: string, formatter?: (text: string, size: number, type: "spacer" | "time") => string): DataLine; | ||
protected createProgressBarLine(length: number): string; | ||
@@ -27,0 +30,0 @@ protected renderProgressLine(): string; |
@@ -18,8 +18,26 @@ import chalk from "chalk"; | ||
options; | ||
minNameLength = MIN_NAME_LENGTH; | ||
constructor(options) { | ||
this.options = options; | ||
} | ||
switchTransferToShortText() { | ||
switch (this.status.transferAction) { | ||
case "Downloading": | ||
return "Pull"; | ||
case "Copying": | ||
return "Copy"; | ||
} | ||
return this.status.transferAction; | ||
} | ||
get showETA() { | ||
return this.status.startTime < Date.now() - SKIP_ETA_START_TIME; | ||
} | ||
get nameSize() { | ||
const { fileName } = this.status; | ||
return this.options.truncateName === false | ||
? fileName.length | ||
: typeof this.options.truncateName === "number" | ||
? this.options.truncateName | ||
: Math.min(fileName.length, this.minNameLength); | ||
} | ||
getNameAndCommentDataParts() { | ||
@@ -39,7 +57,3 @@ const { fileName, comment, downloadStatus } = this.status; | ||
fullText: fileName, | ||
size: this.options.truncateName === false | ||
? fileName.length | ||
: typeof this.options.truncateName === "number" | ||
? this.options.truncateName | ||
: Math.min(fileName.length, MIN_NAME_LENGTH), | ||
size: this.nameSize, | ||
flex: typeof this.options.truncateName === "number" | ||
@@ -73,3 +87,3 @@ ? undefined | ||
} | ||
getETA(spacer = " | ") { | ||
getETA(spacer = " | ", formatter = text => text) { | ||
const formatedTimeLeft = this.status.timeLeft < 1_000 ? "0s" : this.status.formatTimeLeft; | ||
@@ -82,7 +96,12 @@ const timeLeft = `${formatedTimeLeft.padStart("10s".length)} left`; | ||
size: spacer.length, | ||
formatter: (text) => text | ||
formatter(text, size) { | ||
return formatter(text, size, "spacer"); | ||
} | ||
}, { | ||
type: "timeLeft", | ||
fullText: timeLeft, | ||
size: timeLeft.length | ||
size: timeLeft.length, | ||
formatter(text, size) { | ||
return formatter(text, size, "time"); | ||
} | ||
}]; | ||
@@ -93,14 +112,16 @@ } | ||
createProgressBarLine(length) { | ||
const fileName = truncateText(this.status.fileName, length); | ||
const percentage = clamp(this.status.transferredBytes / this.status.totalBytes, 0, 1); | ||
const fullLength = Math.floor(percentage * length); | ||
const emptyLength = length - fullLength; | ||
return `${"=".repeat(fullLength)}>${" ".repeat(emptyLength)}`; | ||
return chalk.cyan(fileName.slice(0, fullLength)) + chalk.dim(fileName.slice(fullLength, fullLength + emptyLength)); | ||
} | ||
renderProgressLine() { | ||
const { formattedPercentage, formattedSpeed, formatTransferredOfTotal, formatTotal } = this.status; | ||
const status = this.switchTransferToShortText(); | ||
return renderDataLine([ | ||
{ | ||
type: "status", | ||
fullText: this.status.transferAction, | ||
size: this.status.transferAction.length, | ||
fullText: status, | ||
size: status.length, | ||
formatter: (text) => chalk.cyan(text) | ||
@@ -111,13 +132,5 @@ }, | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
...this.getNameAndCommentDataParts(), | ||
{ | ||
type: "spacer", | ||
fullText: "\n", | ||
size: 1, | ||
formatter: (text) => text | ||
}, | ||
{ | ||
type: "percentage", | ||
@@ -131,9 +144,8 @@ fullText: formattedPercentage, | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
{ | ||
type: "progressBar", | ||
size: "[=====>]".length, | ||
fullText: this.createProgressBarLine(10), | ||
size: this.nameSize, | ||
fullText: "", | ||
flex: 4, | ||
@@ -143,3 +155,3 @@ addEndPadding: 4, | ||
formatter: (_, size) => { | ||
return `[${chalk.cyan(this.createProgressBarLine(size))}]`; | ||
return `[${this.createProgressBarLine(size)}]`; | ||
} | ||
@@ -150,4 +162,3 @@ }, | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
@@ -157,9 +168,8 @@ { | ||
fullText: formatTransferredOfTotal, | ||
size: `1024.00MB/${formatTotal}`.length | ||
size: `999.99MB/${formatTotal}`.length | ||
}, | ||
{ | ||
type: "spacer", | ||
fullText: " | ", | ||
size: " | ".length, | ||
formatter: (text) => text | ||
fullText: " (", | ||
size: " (".length | ||
}, | ||
@@ -169,5 +179,11 @@ { | ||
fullText: formattedSpeed, | ||
size: Math.max("00.00kB/s".length, formattedSpeed.length) | ||
size: Math.max("00.00kB/s".length, formattedSpeed.length), | ||
formatter: text => chalk.ansi256(31)(text) | ||
}, | ||
...this.getETA() | ||
{ | ||
type: "spacer", | ||
fullText: ")", | ||
size: ")".length | ||
}, | ||
...this.getETA(" ~ ", text => chalk.dim(text)) | ||
]); | ||
@@ -187,4 +203,3 @@ } | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
@@ -205,4 +220,3 @@ ...this.getNameAndCommentDataParts() | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
@@ -213,4 +227,3 @@ ...this.getNameAndCommentDataParts(), | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
@@ -217,0 +230,0 @@ { |
@@ -5,2 +5,3 @@ import SummaryTransferCliProgressBar from "./summary-transfer-cli-progress-bar.js"; | ||
multiProgressBar: typeof CIMultiProgressBar; | ||
minNameLength: number; | ||
} |
import SummaryTransferCliProgressBar from "./summary-transfer-cli-progress-bar.js"; | ||
import { CIMultiProgressBar } from "../multiProgressBars/CIMultiProgressBar.js"; | ||
const MIN_NAME_LENGTH = 80; | ||
export default class CiTransferCliProgressBar extends SummaryTransferCliProgressBar { | ||
multiProgressBar = CIMultiProgressBar; | ||
minNameLength = MIN_NAME_LENGTH; | ||
} | ||
//# sourceMappingURL=ci-transfer-cli-progress-bar.js.map |
@@ -18,2 +18,3 @@ import chalk from "chalk"; | ||
const progressBarText = ` ${formattedPercentageWithPadding} (${formatTransferred}/${formatTotal}) `; | ||
const dimEta = this.getETA(" | ", text => chalk.dim(text)); | ||
return renderDataLine([{ | ||
@@ -27,9 +28,7 @@ type: "status", | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, ...this.getNameAndCommentDataParts(), { | ||
type: "spacer", | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, { | ||
@@ -56,4 +55,3 @@ type: "progressBar", | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, { | ||
@@ -63,3 +61,3 @@ type: "speed", | ||
size: Math.max("00.00kB/s".length, formattedSpeed.length) | ||
}, ...this.getETA(" ")]); | ||
}, ...dimEta]); | ||
} | ||
@@ -66,0 +64,0 @@ renderFinishedLine() { |
@@ -31,9 +31,7 @@ import chalk from "chalk"; | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, ...this.getNameAndCommentDataParts(), { | ||
type: "spacer", | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, { | ||
@@ -59,4 +57,3 @@ type: "description", | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
@@ -72,4 +69,3 @@ { | ||
fullText: " ", | ||
size: " ".length, | ||
formatter: (text) => text | ||
size: " ".length | ||
}, | ||
@@ -79,4 +75,3 @@ { | ||
fullText: progressBar, | ||
size: progressBar.length, | ||
formatter: (text) => text | ||
size: progressBar.length | ||
}, | ||
@@ -92,4 +87,3 @@ { | ||
fullText: comment || "", | ||
size: (comment || "").length, | ||
formatter: (text) => text | ||
size: (comment || "").length | ||
}, | ||
@@ -96,0 +90,0 @@ { |
{ | ||
"name": "ipull", | ||
"version": "3.7.3", | ||
"version": "3.7.4", | ||
"description": "The only file downloader you'll ever need. For node.js and the browser, CLI and library for fast and reliable file downloads.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
307326
4072