1- import  chalk  from  "chalk" 
2- import  {  writeFileSync  }  from  "fs" 
3- import  {  existsSync  }  from  "fs-extra" 
1+ import  colors  from  "chalk" 
2+ import  {  existsSync ,  writeFileSync  }  from  "fs-extra" 
43import  {  posix  }  from  "path" 
54import  semver  from  "semver" 
65import  {  hashFile  }  from  "./hash" 
@@ -45,7 +44,7 @@ function getInstalledPackageVersion({
4544 } 
4645
4746 let  err  = 
48-  `${ chalk . red ( "Error:" ) } ${ posix . basename (  
47+  `${ colors . red ( "Error:" ) } ${ posix . basename (  
4948 pathSpecifier ,  
5049 ) }  `+  ` which is not present at ${ relative ( "." ,  packageDir ) }  
5150
@@ -54,7 +53,7 @@ function getInstalledPackageVersion({
5453
5554 If this package is a dev dependency, rename the patch file to 
5655  
57-  ${ chalk . bold ( patchFilename . replace ( ".patch" ,  ".dev.patch" ) ) }  
56+  ${ colors . bold ( patchFilename . replace ( ".patch" ,  ".dev.patch" ) ) }  
5857` 
5958 } 
6059 throw  new  PatchApplicationError ( err ) 
@@ -65,7 +64,7 @@ function getInstalledPackageVersion({
6564 const  result  =  semver . valid ( version ) 
6665 if  ( result  ===  null )  { 
6766 throw  new  PatchApplicationError ( 
68-  `${ chalk . red (  
67+  `${ colors . red (  
6968 "Error:" ,  
7069 ) }   Version string '${ version } ${ join ( 
7170 packageDir ,  
@@ -85,9 +84,9 @@ function logPatchApplication(patchDetails: PatchedPackageDetails) {
8584 }  )`
8685 : "" 
8786 console . log ( 
88-  `${ chalk . bold ( patchDetails . pathSpecifier ) } ${  
87+  `${ colors . bold ( patchDetails . pathSpecifier ) } ${  
8988 patchDetails . version  
90-  }  ${ sequenceString } ${ chalk . green ( "✔" ) } , 
89+  }  ${ sequenceString } ${ colors . green ( "✔" ) } , 
9190 ) 
9291} 
9392
@@ -110,7 +109,7 @@ export function applyPatchesForApp({
110109 const  groupedPatches  =  getGroupedPatches ( patchesDirectory ) 
111110
112111 if  ( groupedPatches . numPatchFiles  ===  0 )  { 
113-  console . log ( chalk . blueBright ( "No patch files found" ) ) 
112+  console . log ( colors . blue ( "No patch files found" ) ) 
114113 return 
115114 } 
116115
@@ -140,10 +139,10 @@ export function applyPatchesForApp({
140139
141140 const  problemsSummary  =  [ ] 
142141 if  ( warnings . length )  { 
143-  problemsSummary . push ( chalk . yellow ( `${ warnings . length }  ) ) 
142+  problemsSummary . push ( colors . yellow ( `${ warnings . length }  ) ) 
144143 } 
145144 if  ( errors . length )  { 
146-  problemsSummary . push ( chalk . red ( `${ errors . length }  ) ) 
145+  problemsSummary . push ( colors . red ( `${ errors . length }  ) ) 
147146 } 
148147
149148 if  ( problemsSummary . length )  { 
@@ -201,8 +200,8 @@ export function applyPatchesForPackage({
201200 appliedPatches . push ( unappliedPatches . shift ( ) ! ) 
202201 }  else  { 
203202 console . log ( 
204-  chalk . red ( "Error:" ) , 
205-  `The patches for ${ chalk . bold ( pathSpecifier ) }  , 
203+  colors . red ( "Error:" ) , 
204+  `The patches for ${ colors . bold ( pathSpecifier ) }  , 
206205 `You should reinstall your node_modules folder to make sure the package is up to date` , 
207206 ) 
208207 process . exit ( 1 ) 
@@ -249,9 +248,9 @@ export function applyPatchesForPackage({
249248 if  ( ! installedPackageVersion )  { 
250249 // it's ok we're in production mode and this is a dev only package 
251250 console . log ( 
252-  `Skipping dev-only ${ chalk . bold (  
251+  `Skipping dev-only ${ colors . bold (  
253252 pathSpecifier ,  
254-  ) }  @${ version } ${ chalk . blue ( "✔" ) } , 
253+  ) }  @${ version } ${ colors . blue ( "✔" ) } , 
255254 ) 
256255 continue 
257256 } 
@@ -429,7 +428,7 @@ export function applyPatch({
429428 if  ( errors ?. length )  { 
430429 console . log ( 
431430 "Saving errors to" , 
432-  chalk . cyan . bold ( "./patch-package-errors.log" ) , 
431+  colors . cyan ( colors . bold ( "./patch-package-errors.log" ) ) , 
433432 ) 
434433 writeFileSync ( "patch-package-errors.log" ,  errors . join ( "\n\n" ) ) 
435434 process . exit ( 0 ) 
@@ -464,18 +463,20 @@ function createVersionMismatchWarning({
464463 path : string 
465464} )  { 
466465 return  ` 
467- ${ chalk . yellow ( "Warning:" ) } 
466+ ${ colors . yellow ( 
467+  "Warning:" ,  
468+ ) } 
468469
469470 Don't worry! This is probably fine. The patch was still applied 
470471 successfully. Here's the deets: 
471472
472473 Patch file created for 
473474
474-  ${ packageName } ${ chalk . bold ( originalVersion ) }  
475+  ${ packageName } ${ colors . bold ( originalVersion ) }  
475476
476477 applied to 
477478
478-  ${ packageName } ${ chalk . bold ( actualVersion ) }  
479+  ${ packageName } ${ colors . bold ( actualVersion ) }  
479480  
480481 At path 
481482  
@@ -485,7 +486,7 @@ ${chalk.yellow("Warning:")} patch-package detected a patch file version mismatch
485486 breakage even though the patch was applied successfully. Make sure the package 
486487 still behaves like you expect (you wrote tests, right?) and then run 
487488
488-  ${ chalk . bold ( `patch-package ${ pathSpecifier }  ) }  
489+  ${ colors . bold ( `patch-package ${ pathSpecifier }  ) }  
489490
490491 to update the version in the patch file name and make this warning go away. 
491492` 
@@ -503,8 +504,8 @@ function createBrokenPatchFileError({
503504 pathSpecifier : string 
504505} )  { 
505506 return  ` 
506- ${ chalk . red . bold ( "**ERROR**" ) } ${ chalk . red ( 
507-  `Failed to apply patch for package ${ chalk . bold ( packageName ) }  ,  
507+ ${ colors . red ( colors . bold ( "**ERROR**" ) ) } ${ colors . red ( 
508+  `Failed to apply patch for package ${ colors . bold ( packageName ) }  ,  
508509 ) }  
509510  
510511 ${ path }  
@@ -543,13 +544,15 @@ function createPatchApplicationFailureError({
543544 pathSpecifier : string 
544545} )  { 
545546 return  ` 
546- ${ chalk . red . bold ( "**ERROR**" ) } ${ chalk . red ( 
547-  `Failed to apply patch for package ${ chalk . bold ( packageName ) }  ,  
547+ ${ colors . red ( colors . bold ( "**ERROR**" ) ) } ${ colors . red ( 
548+  `Failed to apply patch for package ${ colors . bold ( packageName ) }  ,  
548549 ) }  
549550  
550551 ${ path }  
551552
552-  This error was caused because ${ chalk . bold ( packageName ) }  
553+  This error was caused because ${ colors . bold (  
554+  packageName ,  
555+  ) }   has changed since you
553556 made the patch file for it. This introduced conflicts with your patch, 
554557 just like a merge conflict in Git when separate incompatible changes are 
555558 made to the same piece of code. 
@@ -568,8 +571,8 @@ ${chalk.red.bold("**ERROR**")} ${chalk.red(
568571
569572 Info: 
570573 Patch file: patches/${ patchFilename }  
571-  Patch was made for version: ${ chalk . green . bold ( originalVersion ) }  
572-  Installed version: ${ chalk . red . bold ( actualVersion ) }  
574+  Patch was made for version: ${ colors . green ( colors . bold ( originalVersion ) ) }  
575+  Installed version: ${ colors . red ( colors . bold ( actualVersion ) ) }  
573576` 
574577} 
575578
@@ -581,8 +584,8 @@ function createUnexpectedError({
581584 error : Error 
582585} )  { 
583586 return  ` 
584- ${ chalk . red . bold ( "**ERROR**" ) } ${ chalk . red ( 
585-  `Failed to apply patch file ${ chalk . bold ( filename ) }  ,  
587+ ${ colors . red ( colors . bold ( "**ERROR**" ) ) } ${ colors . red ( 
588+  `Failed to apply patch file ${ colors . bold ( filename ) }  ,  
586589 ) }  
587590  
588591${ error . stack } 
0 commit comments