Skip to content

Commit

Permalink
fix(cli): change texts
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrgm committed Oct 17, 2023
1 parent 8d24da9 commit 34900c5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-terms-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@datatruck/cli": patch
---

Fix texts
24 changes: 12 additions & 12 deletions packages/cli/src/Action/BackupAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ export class BackupAction<TRequired extends boolean = true> {
keyIndex: pkg.name,
data: { taskName: pkg.task.name, packageName: pkg.name },
title: {
initial: `Execute task: ${pkg.task?.name}`,
started: `Executing task: ${pkg.task?.name}`,
failed: `Task execute failed: ${pkg.task?.name}`,
completed: `Task executed: ${pkg.task?.name}`,
initial: `Execute task: ${pkg.name} (${pkg.task.name})`,
started: `Executing task: ${pkg.name} (${pkg.task.name})`,
failed: `Task execute failed: ${pkg.name} (${pkg.task.name})`,
completed: `Task executed: ${pkg.name} (${pkg.task.name})`,
},
exitOnError: false,
runWrapper: gc.cleanupIfFail.bind(gc),
Expand All @@ -318,10 +318,10 @@ export class BackupAction<TRequired extends boolean = true> {
repositoryName: repositoryName,
},
title: {
initial: `Create backup: ${repositoryName}`,
started: `Creating backup: ${repositoryName}`,
completed: `Backup created: ${repositoryName}`,
failed: `Backup create failed: ${repositoryName}`,
initial: `Create backup: ${pkg.name} (${repositoryName})`,
started: `Creating backup: ${pkg.name} (${repositoryName})`,
completed: `Backup created: ${pkg.name} (${repositoryName})`,
failed: `Backup create failed: ${pkg.name} (${repositoryName})`,
},
exitOnError: false,
runWrapper: gc.cleanupOnFinish.bind(gc),
Expand Down Expand Up @@ -365,10 +365,10 @@ export class BackupAction<TRequired extends boolean = true> {
mirrorRepositoryName: mirror,
},
title: {
initial: `Copy snapshot: ${mirror}`,
started: `Copying snapshot: ${mirror}`,
completed: `Snapshot copied: ${mirror}`,
failed: `Snapshot copy failed: ${mirror}`,
initial: `Copy snapshot: ${pkg.name} (${mirror})`,
started: `Copying snapshot: ${pkg.name} (${mirror})`,
completed: `Snapshot copied: ${pkg.name} (${mirror})`,
failed: `Snapshot copy failed: ${pkg.name} (${mirror})`,
},
exitOnError: false,
runWrapper: gc.cleanup.bind(gc),
Expand Down
22 changes: 14 additions & 8 deletions packages/cli/src/Action/RestoreAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ export class RestoreAction<TRequired extends boolean = true> {
keyIndex: snapshot.packageName,
data: snapshot,
title: {
initial: `Restore ${snapshot.packageName} snapshot`,
started: `Restoring ${snapshot.packageName} snapshot`,
completed: `Snapshot restored: ${snapshot.packageName}`,
failed: `Snapshot restore failed: ${snapshot.packageName}`,
initial: `Restore snapshot: ${snapshot.packageName} (${snapshot.repositoryName})`,
started: `Restoring snapshot: ${snapshot.packageName} (${snapshot.repositoryName})`,
completed: `Snapshot restored: ${snapshot.packageName} (${snapshot.repositoryName})`,
failed: `Snapshot restore failed: ${snapshot.packageName} (${snapshot.repositoryName})`,
},
exitOnError: false,
run: async (listTask) => {
Expand Down Expand Up @@ -290,10 +290,16 @@ export class RestoreAction<TRequired extends boolean = true> {
keyIndex: pkg.name,
data: { taskName: pkg.task!.name, packageName: pkg.name },
title: {
initial: `Execute ${pkg.task?.name} task`,
started: `Executing ${pkg.task?.name} task`,
completed: `Task executed: ${pkg.task?.name}`,
failed: `Task execute failed: ${pkg.task?.name}`,
initial: `Execute task: ${pkg.name} (${pkg.task!.name})`,
started: `Executing task: ${pkg.name} (${
pkg.task!.name
})`,
completed: `Task executed: ${pkg.name} (${
pkg.task!.name
})`,
failed: `Task execute failed: ${pkg.name} (${
pkg.task!.name
})`,
},
exitOnError: false,
runWrapper: gc.cleanup.bind(gc),
Expand Down
16 changes: 11 additions & 5 deletions packages/cli/src/utils/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,24 @@ export function renderProgressStats(
const text: string[] = [];
if (typeof stats.percent === "number") {
if (progressBar) text.push(renderProgressBar(stats.percent));
text.push(`${stats.percent.toFixed(2)}%`);
text.push(`${stats.percent.toFixed(2).padStart(5, " ")}%`);
}
if (typeof stats.current === "number" || typeof stats.total === "number") {
const format = (value: number) =>
stats.format === "size" ? bytes(value) : value;
stats.format === "size" ? bytes(value) : value.toString();
const pad = 8;
let values: string[] = [];
if (typeof stats.current === "number" && typeof stats.total === "number") {
text.push(`${format(stats.current)}/${format(stats.total)}`);
values = [
format(stats.current).padStart(pad, " "),
format(stats.total).padEnd(pad, " "),
];
} else if (typeof stats.current === "number") {
text.push(`${format(stats.current)}`);
values = [format(stats.current).padStart(pad * 2 + 1)];
} else if (typeof stats.total === "number") {
text.push(`?/${format(stats.total)}`);
values = ["?".padStart(pad, " "), format(stats.total).padEnd(pad, " ")];
}
if (values.length) text.push(values.join("/"));
}
if (stats.description && stats.payload) {
text.push(`${stats.description}: ${stats.payload}`);
Expand Down

0 comments on commit 34900c5

Please sign in to comment.