Skip to content

Commit 41232e4

Browse files
committed
using colors from cliffy instead of npm:chalk
1 parent e655a34 commit 41232e4

File tree

7 files changed

+22
-114
lines changed

7 files changed

+22
-114
lines changed

deno.lock

Lines changed: 1 addition & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-mirror.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import { Command } from "jsr:@cliffy/command@^1.0.0-rc.7";
33
import { Confirm } from "jsr:@cliffy/[email protected]/confirm";
44
import { exists } from "jsr:@std/fs";
5-
import chalk from "npm:chalk";
5+
// import colors from "npm:colors";
6+
import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
67
import { HOME_DIR } from "./utils/constants.ts";
78
import {
89
cloneRepo,
@@ -19,26 +20,26 @@ interface CloneOptions {
1920
}
2021

2122
const cloneAction = async (options: CloneOptions, repo: string) => {
22-
console.log(chalk.bgYellow('Dry run mode ... none of the commands will actually be run.'));
23+
console.log(colors.bgYellow('Dry run mode ... none of the commands will actually be run.'));
2324

2425
const localRepo = getLocalPath(
2526
repo,
2627
options.rootDir ?? `${HOME_DIR}/Projects`,
2728
);
2829
console.log(
29-
`Cloning repository: ${chalk.green(repo)} to ${chalk.green(localRepo)}`,
30+
`Cloning repository: ${colors.green(repo)} to ${colors.green(localRepo)}`,
3031
);
3132

3233
const dirAlreadyExists = await exists(localRepo);
3334
if (dirAlreadyExists) {
3435
if (options.dryRun) {
35-
console.log(chalk.yellow(`> Dry run: Fetching repository: ${localRepo}`));
36+
console.log(colors.yellow(`> Dry run: Fetching repository: ${localRepo}`));
3637
} else {
3738
await fetchRepo(localRepo);
3839
}
3940
} else {
4041
if (options.dryRun) {
41-
console.log(chalk.yellow(`> Dry run: Cloning repository: ${repo}`));
42+
console.log(colors.yellow(`> Dry run: Cloning repository: ${repo}`));
4243
} else {
4344
await cloneRepo(repo, localRepo);
4445
}
@@ -53,7 +54,7 @@ const cloneAction = async (options: CloneOptions, repo: string) => {
5354
if (openVsCode) {
5455
if (options.dryRun) {
5556
console.log(
56-
chalk.yellow(`> Dry run: Opening repository in VS Code: ${localRepo}`),
57+
colors.yellow(`> Dry run: Opening repository in VS Code: ${localRepo}`),
5758
);
5859
} else {
5960
const vscode = await findExecutable("code");
@@ -63,7 +64,7 @@ const cloneAction = async (options: CloneOptions, repo: string) => {
6364

6465
console.log(
6566
`To move to the project's directory, please run: "cd ${
66-
chalk.green(
67+
colors.green(
6768
localRepo,
6869
)
6970
}"`,
@@ -72,7 +73,7 @@ const cloneAction = async (options: CloneOptions, repo: string) => {
7273

7374
await new Command()
7475
.name("clone")
75-
.version("0.1.4")
76+
.version("0.1.5")
7677
.description("Clone/Fetch a Git repository into a 'Projects' directory")
7778
.arguments("<repo:string>")
7879
.option("-r, --root <rootDir>", "The root directory.", {

utils/exec/find-exec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from "npm:chalk";
1+
import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
22

33
export const findExecutable = async (executable: string): Promise<string> => {
44
try {
@@ -10,7 +10,7 @@ export const findExecutable = async (executable: string): Promise<string> => {
1010

1111
return new TextDecoder().decode(stdout).trim();
1212
} catch (error) {
13-
console.error(chalk.bgRedBright(`Error finding git path: ${error}`));
13+
console.error(colors.bgBrightRed(`Error finding git path: ${error}`));
1414
Deno.exit(1);
1515
}
1616
};

utils/file/get-dir-path-from-repo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from "npm:chalk";
1+
import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
22

33
export const getDirPathFromRepo = (repo: string): string => {
44
let dirPath: string;
@@ -10,7 +10,7 @@ export const getDirPathFromRepo = (repo: string): string => {
1010
const repoParts = repo.split("/");
1111
dirPath = repoParts.slice(3).join("/").replace(".git", "");
1212
} else {
13-
console.error(chalk.bgRedBright(`Invalid Git repository URL: ${repo}`));
13+
console.error(colors.bgBrightRed(`Invalid Git repository URL: ${repo}`));
1414
Deno.exit(1);
1515
}
1616

utils/file/get-host-from-repo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from "npm:chalk";
1+
import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
22

33
export const getHostFromRepo = (repo: string): string => {
44
let host: string;
@@ -10,7 +10,7 @@ export const getHostFromRepo = (repo: string): string => {
1010
const repoParts = repo.split("/");
1111
host = repoParts[2].split(".")[0];
1212
} else {
13-
console.error(chalk.bgRedBright(`Invalid Git repository URL: ${repo}`));
13+
console.error(colors.bgBrightRed(`Invalid Git repository URL: ${repo}`));
1414
Deno.exit(1);
1515
}
1616

utils/git/clone-repo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from "npm:chalk";
1+
import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
22
import { findExecutable } from "../exec/find-exec.ts";
33

44
export const cloneRepo = async (
@@ -15,10 +15,10 @@ export const cloneRepo = async (
1515
const status = await child.status;
1616

1717
if (!status.success) {
18-
console.error(chalk.bgRedBright(`Error cloning repository`));
18+
console.error(colors.bgBrightRed(`Error cloning repository`));
1919
} else {
2020
console.log(
21-
chalk.bgGreenBright(`Repository cloned successfully to ${localRepo}`),
21+
colors.bgBrightGreen(`Repository cloned successfully to ${localRepo}`),
2222
);
2323
}
2424
};

utils/git/fetch-repo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from "npm:chalk";
1+
import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
22
import { findExecutable } from "../exec/find-exec.ts";
33

44
export const fetchRepo = async (localRepo: string): Promise<void> => {
@@ -13,8 +13,8 @@ export const fetchRepo = async (localRepo: string): Promise<void> => {
1313
const status = await child.status;
1414

1515
if (!status.success) {
16-
console.error(chalk.bgRedBright(`Error fetching repository`));
16+
console.error(colors.bgBrightRed(`Error fetching repository`));
1717
} else {
18-
console.log(chalk.bgGreenBright(`Repository fetching successfully`));
18+
console.log(colors.bgBrightGreen(`Repository fetching successfully`));
1919
}
2020
};

0 commit comments

Comments
 (0)