@@ -2,9 +2,9 @@ import fs from 'node:fs'
22import fsp from 'node:fs/promises'
33import path from 'node:path'
44import process from 'node:process'
5+ import { styleText } from 'node:util'
56// @ts -expect-error missing types
67import parse from 'parse-gitignore'
7- import c from 'picocolors'
88
99import prompts from 'prompts'
1010import {
@@ -36,7 +36,8 @@ export async function run(options: RuleOptions = {}): Promise<void> {
3636
3737 if ( fs . existsSync ( pathFlatConfig ) ) {
3838 console . log (
39- c . yellow (
39+ styleText (
40+ 'yellow' ,
4041 `${ WARN } eslint.config.js already exists, migration wizard exited.` ,
4142 ) ,
4243 )
@@ -55,7 +56,12 @@ export async function run(options: RuleOptions = {}): Promise<void> {
5556 }
5657
5758 // Update package.json
58- console . log ( c . cyan ( `${ ARROW } bumping @coderwyd/eslint-config to v${ version } ` ) )
59+ console . log (
60+ styleText (
61+ 'cyan' ,
62+ `${ ARROW } bumping @coderwyd/eslint-config to v${ version } ` ,
63+ ) ,
64+ )
5965 const pkgContent = await fsp . readFile ( pathPackageJSON , 'utf-8' )
6066 const pkg : Record < string , any > = JSON . parse ( pkgContent )
6167
@@ -65,13 +71,13 @@ export async function run(options: RuleOptions = {}): Promise<void> {
6571 if ( ! pkg . devDependencies . eslint ) pkg . devDependencies . eslint = eslintVersion
6672
6773 await fsp . writeFile ( pathPackageJSON , JSON . stringify ( pkg , null , 2 ) )
68- console . log ( c . green ( `${ CHECK } changes wrote to package.json` ) )
74+ console . log ( styleText ( 'green' , `${ CHECK } changes wrote to package.json` ) )
6975
7076 // End update package.json
7177 // Update eslint files
7278 const eslintIgnores : string [ ] = [ ]
7379 if ( fs . existsSync ( pathESLintIngore ) ) {
74- console . log ( c . cyan ( `${ ARROW } migrating existing .eslintignore` ) )
80+ console . log ( styleText ( 'cyan' , `${ ARROW } migrating existing .eslintignore` ) )
7581 const content = await fsp . readFile ( pathESLintIngore , 'utf-8' )
7682 const parsed = parse ( content )
7783 const globs = parsed . globs ( )
@@ -105,7 +111,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
105111 }
106112
107113 await fsp . writeFile ( pathFlatConfig , eslintConfigContent )
108- console . log ( c . green ( `${ CHECK } created eslint.config.js` ) )
114+ console . log ( styleText ( 'green' , `${ CHECK } created eslint.config.js` ) )
109115
110116 const files = fs . readdirSync ( cwd )
111117 const legacyConfig : string [ ] = [ ]
@@ -115,7 +121,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
115121 } )
116122 if ( legacyConfig . length > 0 ) {
117123 console . log ( `${ WARN } you can now remove those files manually:` )
118- console . log ( ` ${ c . dim ( legacyConfig . join ( ', ' ) ) } ` )
124+ console . log ( ` ${ styleText ( 'dim' , legacyConfig . join ( ', ' ) ) } ` )
119125 }
120126
121127 // End update eslint files
@@ -155,7 +161,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
155161
156162 if ( ! fs . existsSync ( settingsPath ) ) {
157163 await fsp . writeFile ( settingsPath , `{${ vscodeSettingsString } }\n` , 'utf-8' )
158- console . log ( c . green ( `${ CHECK } created .vscode/settings.json` ) )
164+ console . log ( styleText ( 'green' , `${ CHECK } created .vscode/settings.json` ) )
159165 } else {
160166 let settingsContent = await fsp . readFile ( settingsPath , 'utf8' )
161167
@@ -167,13 +173,13 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
167173 settingsContent += `${ vscodeSettingsString } }\n`
168174
169175 await fsp . writeFile ( settingsPath , settingsContent , 'utf-8' )
170- console . log ( c . green ( `${ CHECK } updated .vscode/settings.json` ) )
176+ console . log ( styleText ( 'green' , `${ CHECK } updated .vscode/settings.json` ) )
171177 }
172178 }
173179
174180 // End update .vscode/settings.json
175- console . log ( c . green ( `${ CHECK } migration completed` ) )
181+ console . log ( styleText ( 'green' , `${ CHECK } migration completed` ) )
176182 console . log (
177- `Now you can update the dependencies and run ${ c . blue ( 'eslint . --fix' ) } \n` ,
183+ `Now you can update the dependencies and run ${ styleText ( 'blue' , 'eslint . --fix' ) } \n` ,
178184 )
179185}
0 commit comments