1- import chalk from "chalk "
1+ import picocolors from "picocolors "
22import { writeFileSync } from "fs"
33import { existsSync } from "fs-extra"
44import { posix } from "path"
@@ -45,16 +45,17 @@ function getInstalledPackageVersion({
4545 }
4646
4747 let err =
48- `${ chalk . red ( "Error:" ) } Patch file found for package ${ posix . basename (
49- pathSpecifier ,
50- ) } ` + ` which is not present at ${ relative ( "." , packageDir ) } `
48+ `${ picocolors . red (
49+ "Error:" ,
50+ ) } Patch file found for package ${ posix . basename ( pathSpecifier ) } ` +
51+ ` which is not present at ${ relative ( "." , packageDir ) } `
5152
5253 if ( ! isDevOnly && process . env . NODE_ENV === "production" ) {
5354 err += `
5455
5556 If this package is a dev dependency, rename the patch file to
5657
57- ${ chalk . bold ( patchFilename . replace ( ".patch" , ".dev.patch" ) ) }
58+ ${ picocolors . bold ( patchFilename . replace ( ".patch" , ".dev.patch" ) ) }
5859`
5960 }
6061 throw new PatchApplicationError ( err )
@@ -65,7 +66,7 @@ function getInstalledPackageVersion({
6566 const result = semver . valid ( version )
6667 if ( result === null ) {
6768 throw new PatchApplicationError (
68- `${ chalk . red (
69+ `${ picocolors . red (
6970 "Error:" ,
7071 ) } Version string '${ version } ' cannot be parsed from ${ join (
7172 packageDir ,
@@ -85,9 +86,9 @@ function logPatchApplication(patchDetails: PatchedPackageDetails) {
8586 } )`
8687 : ""
8788 console . log (
88- `${ chalk . bold ( patchDetails . pathSpecifier ) } @${
89+ `${ picocolors . bold ( patchDetails . pathSpecifier ) } @${
8990 patchDetails . version
90- } ${ sequenceString } ${ chalk . green ( "✔" ) } `,
91+ } ${ sequenceString } ${ picocolors . green ( "✔" ) } `,
9192 )
9293}
9394
@@ -110,7 +111,7 @@ export function applyPatchesForApp({
110111 const groupedPatches = getGroupedPatches ( patchesDirectory )
111112
112113 if ( groupedPatches . numPatchFiles === 0 ) {
113- console . log ( chalk . blueBright ( "No patch files found" ) )
114+ console . log ( picocolors . blue ( "No patch files found" ) )
114115 return
115116 }
116117
@@ -140,10 +141,10 @@ export function applyPatchesForApp({
140141
141142 const problemsSummary = [ ]
142143 if ( warnings . length ) {
143- problemsSummary . push ( chalk . yellow ( `${ warnings . length } warning(s)` ) )
144+ problemsSummary . push ( picocolors . yellow ( `${ warnings . length } warning(s)` ) )
144145 }
145146 if ( errors . length ) {
146- problemsSummary . push ( chalk . red ( `${ errors . length } error(s)` ) )
147+ problemsSummary . push ( picocolors . red ( `${ errors . length } error(s)` ) )
147148 }
148149
149150 if ( problemsSummary . length ) {
@@ -201,8 +202,8 @@ export function applyPatchesForPackage({
201202 appliedPatches . push ( unappliedPatches . shift ( ) ! )
202203 } else {
203204 console . log (
204- chalk . red ( "Error:" ) ,
205- `The patches for ${ chalk . bold ( pathSpecifier ) } have changed.` ,
205+ picocolors . red ( "Error:" ) ,
206+ `The patches for ${ picocolors . bold ( pathSpecifier ) } have changed.` ,
206207 `You should reinstall your node_modules folder to make sure the package is up to date` ,
207208 )
208209 process . exit ( 1 )
@@ -249,9 +250,9 @@ export function applyPatchesForPackage({
249250 if ( ! installedPackageVersion ) {
250251 // it's ok we're in production mode and this is a dev only package
251252 console . log (
252- `Skipping dev-only ${ chalk . bold (
253+ `Skipping dev-only ${ picocolors . bold (
253254 pathSpecifier ,
254- ) } @${ version } ${ chalk . blue ( "✔" ) } `,
255+ ) } @${ version } ${ picocolors . blue ( "✔" ) } `,
255256 )
256257 continue
257258 }
@@ -429,7 +430,7 @@ export function applyPatch({
429430 if ( errors ?. length ) {
430431 console . log (
431432 "Saving errors to" ,
432- chalk . cyan . bold ( "./patch-package-errors.log" ) ,
433+ picocolors . cyan ( picocolors . bold ( "./patch-package-errors.log" ) ) ,
433434 )
434435 writeFileSync ( "patch-package-errors.log" , errors . join ( "\n\n" ) )
435436 process . exit ( 0 )
@@ -464,18 +465,20 @@ function createVersionMismatchWarning({
464465 path : string
465466} ) {
466467 return `
467- ${ chalk . yellow ( "Warning:" ) } patch-package detected a patch file version mismatch
468+ ${ picocolors . yellow (
469+ "Warning:" ,
470+ ) } patch-package detected a patch file version mismatch
468471
469472 Don't worry! This is probably fine. The patch was still applied
470473 successfully. Here's the deets:
471474
472475 Patch file created for
473476
474- ${ packageName } @${ chalk . bold ( originalVersion ) }
477+ ${ packageName } @${ picocolors . bold ( originalVersion ) }
475478
476479 applied to
477480
478- ${ packageName } @${ chalk . bold ( actualVersion ) }
481+ ${ packageName } @${ picocolors . bold ( actualVersion ) }
479482
480483 At path
481484
@@ -485,7 +488,7 @@ ${chalk.yellow("Warning:")} patch-package detected a patch file version mismatch
485488 breakage even though the patch was applied successfully. Make sure the package
486489 still behaves like you expect (you wrote tests, right?) and then run
487490
488- ${ chalk . bold ( `patch-package ${ pathSpecifier } ` ) }
491+ ${ picocolors . bold ( `patch-package ${ pathSpecifier } ` ) }
489492
490493 to update the version in the patch file name and make this warning go away.
491494`
@@ -503,8 +506,8 @@ function createBrokenPatchFileError({
503506 pathSpecifier : string
504507} ) {
505508 return `
506- ${ chalk . red . bold ( "**ERROR**" ) } ${ chalk . red (
507- `Failed to apply patch for package ${ chalk . bold ( packageName ) } at path` ,
509+ ${ picocolors . red ( picocolors . bold ( "**ERROR**" ) ) } ${ picocolors . red (
510+ `Failed to apply patch for package ${ picocolors . bold ( packageName ) } at path` ,
508511 ) }
509512
510513 ${ path }
@@ -543,13 +546,15 @@ function createPatchApplicationFailureError({
543546 pathSpecifier : string
544547} ) {
545548 return `
546- ${ chalk . red . bold ( "**ERROR**" ) } ${ chalk . red (
547- `Failed to apply patch for package ${ chalk . bold ( packageName ) } at path` ,
549+ ${ picocolors . red ( picocolors . bold ( "**ERROR**" ) ) } ${ picocolors . red (
550+ `Failed to apply patch for package ${ picocolors . bold ( packageName ) } at path` ,
548551 ) }
549552
550553 ${ path }
551554
552- This error was caused because ${ chalk . bold ( packageName ) } has changed since you
555+ This error was caused because ${ picocolors . bold (
556+ packageName ,
557+ ) } has changed since you
553558 made the patch file for it. This introduced conflicts with your patch,
554559 just like a merge conflict in Git when separate incompatible changes are
555560 made to the same piece of code.
@@ -568,8 +573,10 @@ ${chalk.red.bold("**ERROR**")} ${chalk.red(
568573
569574 Info:
570575 Patch file: patches/${ patchFilename }
571- Patch was made for version: ${ chalk . green . bold ( originalVersion ) }
572- Installed version: ${ chalk . red . bold ( actualVersion ) }
576+ Patch was made for version: ${ picocolors . green (
577+ picocolors . bold ( originalVersion ) ,
578+ ) }
579+ Installed version: ${ picocolors . red ( picocolors . bold ( actualVersion ) ) }
573580`
574581}
575582
@@ -581,8 +588,8 @@ function createUnexpectedError({
581588 error : Error
582589} ) {
583590 return `
584- ${ chalk . red . bold ( "**ERROR**" ) } ${ chalk . red (
585- `Failed to apply patch file ${ chalk . bold ( filename ) } ` ,
591+ ${ picocolors . red ( picocolors . bold ( "**ERROR**" ) ) } ${ picocolors . red (
592+ `Failed to apply patch file ${ picocolors . bold ( filename ) } ` ,
586593 ) }
587594
588595${ error . stack }
0 commit comments