@@ -8,14 +8,14 @@ import { spawn } from 'node:child_process'
88import { existsSync , promises as fs } from 'node:fs'
99import path from 'node:path'
1010import readline from 'node:readline'
11- import { fileURLToPath } from 'node:url'
1211import { parseArgs } from 'node:util'
1312
1413import semver from 'semver'
1514import colors from 'yoctocolors-cjs'
1615
17- const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
18- const rootPath = path . join ( __dirname , '..' )
16+ import { getRootPath , log , printFooter , printHeader } from './utils/common.mjs'
17+
18+ const rootPath = getRootPath ( import . meta. url )
1919const WIN32 = process . platform === 'win32'
2020
2121// Check if prompts are available for interactive mode
@@ -42,38 +42,6 @@ if (hasInteractivePrompts) {
4242 }
4343}
4444
45- // Simple inline logger
46- const log = {
47- info : msg => console . log ( msg ) ,
48- error : msg => console . error ( `${ colors . red ( '✗' ) } ${ msg } ` ) ,
49- success : msg => console . log ( `${ colors . green ( '✓' ) } ${ msg } ` ) ,
50- step : msg => console . log ( `\n${ msg } ` ) ,
51- substep : msg => console . log ( ` ${ msg } ` ) ,
52- progress : msg => process . stdout . write ( ` ∴ ${ msg } ` ) ,
53- done : msg => {
54- process . stdout . write ( '\r\x1b[K' )
55- console . log ( ` ${ colors . green ( '✓' ) } ${ msg } ` )
56- } ,
57- failed : msg => {
58- process . stdout . write ( '\r\x1b[K' )
59- console . log ( ` ${ colors . red ( '✗' ) } ${ msg } ` )
60- } ,
61- warn : msg => console . log ( `${ colors . yellow ( '⚠' ) } ${ msg } ` )
62- }
63-
64- function printHeader ( title ) {
65- console . log ( `\n${ '─' . repeat ( 60 ) } ` )
66- console . log ( ` ${ title } ` )
67- console . log ( `${ '─' . repeat ( 60 ) } ` )
68- }
69-
70- function printFooter ( message ) {
71- console . log ( `\n${ '─' . repeat ( 60 ) } ` )
72- if ( message ) {
73- console . log ( ` ${ colors . green ( '✓' ) } ${ message } ` )
74- }
75- }
76-
7745/**
7846 * Create readline interface for user input.
7947 */
0 commit comments