@@ -2,9 +2,52 @@ import * as readline from 'node:readline';
22
33import chalk from 'chalk' ;
44
5+ const gradientColors = [ '#5ee7df' , '#b490ca' ] ;
6+
7+ const hexToRgb = hex => {
8+ const value = hex . replace ( '#' , '' ) ;
9+ const chunk = value . length === 3 ? value . split ( '' ) . map ( char => char + char ) : value . match ( / .{ 2 } / g) ;
10+ return chunk . map ( part => parseInt ( part , 16 ) ) ;
11+ } ;
12+
13+ const interpolate = ( start , end , t ) => Math . round ( start + ( end - start ) * t ) ;
14+
15+ const applyGradient = text => {
16+ if ( ! text ) {
17+ return '' ;
18+ }
19+
20+ const rgb = gradientColors . map ( hexToRgb ) ;
21+ const maxIndex = text . length - 1 || 1 ;
22+ const segmentCount = rgb . length - 1 ;
23+
24+ return text
25+ . split ( '' )
26+ . map ( ( char , index ) => {
27+ const progress = index / maxIndex ;
28+ const segment = Math . min ( Math . floor ( progress * segmentCount ) , segmentCount - 1 ) ;
29+ const localT = segmentCount === 0 ? 0 : progress * segmentCount - segment ;
30+ const [ r1 , g1 , b1 ] = rgb [ segment ] ;
31+ const [ r2 , g2 , b2 ] = rgb [ segment + 1 ] || rgb [ segment ] ;
32+ const r = interpolate ( r1 , r2 , localT ) ;
33+ const g = interpolate ( g1 , g2 , localT ) ;
34+ const b = interpolate ( b1 , b2 , localT ) ;
35+ return chalk . rgb ( r , g , b ) ( char ) ;
36+ } )
37+ . join ( '' ) ;
38+ } ;
39+
540export function renderHeader ( ) {
641 console . log ( '' ) ;
7- console . log ( chalk . magenta . bold ( '>> Clerk Upgrade CLI <<' ) ) ;
42+ const heading = [
43+ ' █▀▀ █ █▀▀ █▀█ █▄▀ █ █ █▀█ █▀▀ █▀█ ▄▀█ █▀▄ █▀▀' ,
44+ ' █▄▄ █▄▄ ██▄ █▀▄ █ █ █▄█ █▀▀ █▄█ █▀▄ █▀█ █▄▀ ██▄' ,
45+ ] ;
46+
47+ heading . forEach ( line => console . log ( applyGradient ( line ) ) ) ;
48+ console . log ( '' ) ;
49+ console . log ( "Hello friend! We're excited to help you upgrade Clerk modules. Before we get started, a couple" ) ;
50+ console . log ( 'questions...' ) ;
851 console . log ( '' ) ;
952}
1053
0 commit comments