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,10 @@ 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 (
33+ error ( 'Git directory is not clean. Please stash or commit your changes before migrating.' )
34+ info (
3935 `You may use the ${ highlight ( '--force' ) } flag to silence this warning and perform the migration.` ,
40- process . stderr . columns - 2 - 4 ,
41- ) . map ( ( line ) => eprintln ( `${ pc . red ( '\u2502' ) } ${ line } ` ) )
42- eprintln ( )
36+ )
4337 process . exit ( 1 )
4438 }
4539 }
@@ -49,11 +43,9 @@ async function run() {
4943
5044 // Discover CSS files in case no files were provided
5145 if ( files . length === 0 ) {
52- wordWrap (
46+ info (
5347 '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 ( )
48+ )
5749
5850 files = await fastGlob ( [ '**/*.css' ] , {
5951 absolute : true ,
@@ -70,17 +62,9 @@ async function run() {
7062 // Figure out if we made any changes
7163 let stdout = execSync ( 'git status --porcelain' , { encoding : 'utf-8' } )
7264 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 ( )
65+ success ( 'Migration complete. Verify the changes and commit them to your repository.' )
7866 } 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 ( )
67+ success ( 'Migration complete. No changes were made to your repository.' )
8468 }
8569}
8670
0 commit comments