Skip to content

Commit

Permalink
feat: change chalk by picocolors
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-ub committed Sep 24, 2024
1 parent 72e3fdb commit 72f0365
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
},
"dependencies": {
"@antfu/ni": "^0.23.0",
"chalk": "5.2.0",
"citty": "^0.1.6",
"cosmiconfig": "^8.1.3",
"diff": "^5.1.0",
Expand All @@ -64,6 +63,7 @@
"lodash.template": "^4.5.0",
"node-fetch": "^3.3.0",
"ora": "^6.1.2",
"picocolors": "^1.1.0",
"prompts": "^2.4.2",
"ts-morph": "^18.0.0",
"tsconfig-paths": "^4.2.0",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { existsSync, promises as fs } from 'node:fs'
import path from 'node:path'
import process from 'node:process'

import chalk from 'chalk'
import { defineCommand } from 'citty'
import { execa } from 'execa'
import ora from 'ora'
import pc from 'picocolors'
import prompts from 'prompts'
import { z } from 'zod'

Expand Down Expand Up @@ -89,7 +89,7 @@ export const add = defineCommand({
const config = await getConfig(cwd)
if (!config) {
logger.warn(
`Configuration is missing. Please run ${chalk.green(
`Configuration is missing. Please run ${pc.green(
`init`,
)} to create a components.json file.`,
)
Expand Down Expand Up @@ -179,7 +179,7 @@ export const add = defineCommand({

if (!overwrite) {
logger.info(
`Skipped ${item.name}. To overwrite, run with the ${chalk.green(
`Skipped ${item.name}. To overwrite, run with the ${pc.green(
'--overwrite',
)} flag.`,
)
Expand Down
12 changes: 6 additions & 6 deletions src/commands/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { existsSync, promises as fs } from 'node:fs'
import path from 'node:path'
import process from 'node:process'

import chalk from 'chalk'
import { defineCommand } from 'citty'
import { type Change, diffLines } from 'diff'
import pc from 'picocolors'
import { z } from 'zod'

import { getConfig } from '../utils/get-config'
Expand Down Expand Up @@ -66,7 +66,7 @@ export const diff = defineCommand({
const config = await getConfig(cwd)
if (!config) {
logger.warn(
`Configuration is missing. Please run ${chalk.green(
`Configuration is missing. Please run ${pc.green(
`init`,
)} to create a components.json file.`,
)
Expand Down Expand Up @@ -116,7 +116,7 @@ export const diff = defineCommand({
}
logger.break()
logger.info(
`Run ${chalk.green(`diff <component>`)} to see the changes.`,
`Run ${pc.green(`diff <component>`)} to see the changes.`,
)
process.exit(0)
}
Expand All @@ -128,7 +128,7 @@ export const diff = defineCommand({

if (!component) {
logger.error(
`The component ${chalk.green(options.component)} does not exist.`,
`The component ${pc.green(options.component)} does not exist.`,
)
process.exit(1)
}
Expand Down Expand Up @@ -202,10 +202,10 @@ async function printDiff(diff: Change[]): Promise<void> {
diff.forEach((part) => {
if (part) {
if (part.added) {
return process.stdout.write(chalk.green(part.value))
return process.stdout.write(pc.green(part.value))
}
if (part.removed) {
return process.stdout.write(chalk.red(part.value))
return process.stdout.write(pc.red(part.value))
}

return process.stdout.write(part.value)
Expand Down
8 changes: 4 additions & 4 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { existsSync, promises as fs } from 'node:fs'
import path from 'node:path'
import process from 'node:process'

import chalk from 'chalk'
import { defineCommand } from 'citty'
import { execa } from 'execa'
import template from 'lodash.template'
import ora from 'ora'
import pc from 'picocolors'
import prompts from 'prompts'
import { z } from 'zod'

Expand Down Expand Up @@ -101,7 +101,7 @@ export const init = defineCommand({

logger.info('')
logger.info(
`${chalk.green(
`${pc.green(
'Success!',
)} Project initialization completed. You may now add components.`,
)
Expand All @@ -118,7 +118,7 @@ export async function promptForConfig(
defaultConfig: Config | null = null,
skip = false,
): Promise<{ style: string, tailwind: { config: string, css: string, baseColor: string, cssVariables: boolean, prefix?: string | undefined }, aliases: { components: string, utils: string, ui?: string | undefined }, resolvedPaths: { components: string, utils: string, ui: string, tailwindConfig: string, tailwindCss: string }, $schema?: string | undefined }> {
const highlight = (text: string): string => chalk.cyan(text)
const highlight = (text: string): string => pc.cyan(text)

const styles = await getRegistryStyles()
const baseColors = await getRegistryBaseColors()
Expand Down Expand Up @@ -234,7 +234,7 @@ export async function promptForMinimalConfig(
defaultConfig: Config,
defaults = false,
): Promise<{ style: string, tailwind: { config: string, css: string, baseColor: string, cssVariables: boolean, prefix?: string | undefined }, aliases: { components: string, utils: string, ui?: string | undefined }, resolvedPaths: { components: string, utils: string, ui: string, tailwindConfig: string, tailwindCss: string }, $schema?: string | undefined }> {
const highlight = (text: string): string => chalk.cyan(text)
const highlight = (text: string): string => pc.cyan(text)
let style = defaultConfig.style
let baseColor = defaultConfig.tailwind.baseColor
let cssVariables = defaultConfig.tailwind.cssVariables
Expand Down
18 changes: 9 additions & 9 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* eslint-disable no-console */
import chalk from 'chalk'
import pc from 'picocolors'

export const logger = {
error(...args: unknown[]) {
console.log(chalk.red(...args))
error(args: string) {
console.log(pc.red(args))
},
warn(...args: unknown[]) {
console.log(chalk.yellow(...args))
warn(args: string) {
console.log(pc.yellow(args))
},
info(...args: unknown[]) {
console.log(chalk.cyan(...args))
info(args: string) {
console.log(pc.cyan(args))
},
success(...args: unknown[]) {
console.log(chalk.green(...args))
success(args: string) {
console.log(pc.green(args))
},
break() {
console.log('')
Expand Down

0 comments on commit 72f0365

Please sign in to comment.