33import fastGlob from 'fast-glob'
44import { execSync } from 'node:child_process'
55import path from 'node:path'
6- import pc from 'picocolors'
76import { help } from './commands/help'
87import { migrate } from './migrate'
98import { args , type Arg } from './utils/args'
10- import { eprintln , header , highlight , wordWrap } from './utils/renderer'
9+ import { eprintln , error , header , highlight , info , success } from './utils/renderer'
1110
1211const options = {
1312 '--help' : { type : 'boolean' , description : 'Display usage information' , alias : '-h' } ,
@@ -31,15 +30,8 @@ async function run() {
3130 if ( ! flags [ '--force' ] ) {
3231 let stdout = execSync ( 'git status --porcelain' , { encoding : 'utf-8' } )
3332 if ( stdout . trim ( ) ) {
34- wordWrap (
35- 'Git directory is not clean. Please stash or commit your changes before migrating.' ,
36- process . stderr . columns - 5 - 4 ,
37- ) . map ( ( line ) => eprintln ( `${ pc . red ( '\u2502' ) } ${ line } ` ) )
38- wordWrap (
39- `You may use the ${ highlight ( '--force' ) } flag to override this safety check.` ,
40- process . stderr . columns - 2 - 4 ,
41- ) . map ( ( line ) => eprintln ( `${ pc . red ( '\u2502' ) } ${ line } ` ) )
42- eprintln ( )
33+ error ( 'Git directory is not clean. Please stash or commit your changes before migrating.' )
34+ info ( `You may use the ${ highlight ( '--force' ) } flag to override this safety check.` )
4335 process . exit ( 1 )
4436 }
4537 }
@@ -49,11 +41,9 @@ async function run() {
4941
5042 // Discover CSS files in case no files were provided
5143 if ( files . length === 0 ) {
52- wordWrap (
44+ info (
5345 'No files provided. Searching for CSS files in the current directory and its subdirectories…' ,
54- process . stderr . columns - 5 - 4 ,
55- ) . map ( ( line ) => eprintln ( `${ pc . blue ( '\u2502' ) } ${ line } ` ) )
56- eprintln ( )
46+ )
5747
5848 files = await fastGlob ( [ '**/*.css' ] , {
5949 absolute : true ,
@@ -70,17 +60,9 @@ async function run() {
7060 // Figure out if we made any changes
7161 let stdout = execSync ( 'git status --porcelain' , { encoding : 'utf-8' } )
7262 if ( stdout . trim ( ) ) {
73- wordWrap (
74- 'Migration complete. Verify the changes and commit them to your repository.' ,
75- process . stderr . columns - 5 - 4 ,
76- ) . map ( ( line ) => eprintln ( `${ pc . green ( '\u2502' ) } ${ line } ` ) )
77- eprintln ( )
63+ success ( 'Migration complete. Verify the changes and commit them to your repository.' )
7864 } else {
79- wordWrap (
80- 'Migration complete. No changes were made to your repository.' ,
81- process . stderr . columns - 5 - 4 ,
82- ) . map ( ( line ) => eprintln ( `${ pc . green ( '\u2502' ) } ${ line } ` ) )
83- eprintln ( )
65+ success ( 'Migration complete. No changes were made to your repository.' )
8466 }
8567}
8668
0 commit comments