1
- import chalk from "chalk "
1
+ import picocolors from "picocolors "
2
2
import { writeFileSync } from "fs"
3
3
import { existsSync } from "fs-extra"
4
4
import { posix } from "path"
@@ -45,16 +45,17 @@ function getInstalledPackageVersion({
45
45
}
46
46
47
47
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 ) } `
51
52
52
53
if ( ! isDevOnly && process . env . NODE_ENV === "production" ) {
53
54
err += `
54
55
55
56
If this package is a dev dependency, rename the patch file to
56
57
57
- ${ chalk . bold ( patchFilename . replace ( ".patch" , ".dev.patch" ) ) }
58
+ ${ picocolors . bold ( patchFilename . replace ( ".patch" , ".dev.patch" ) ) }
58
59
`
59
60
}
60
61
throw new PatchApplicationError ( err )
@@ -65,7 +66,7 @@ function getInstalledPackageVersion({
65
66
const result = semver . valid ( version )
66
67
if ( result === null ) {
67
68
throw new PatchApplicationError (
68
- `${ chalk . red (
69
+ `${ picocolors . red (
69
70
"Error:" ,
70
71
) } Version string '${ version } ' cannot be parsed from ${ join (
71
72
packageDir ,
@@ -85,9 +86,9 @@ function logPatchApplication(patchDetails: PatchedPackageDetails) {
85
86
} )`
86
87
: ""
87
88
console . log (
88
- `${ chalk . bold ( patchDetails . pathSpecifier ) } @${
89
+ `${ picocolors . bold ( patchDetails . pathSpecifier ) } @${
89
90
patchDetails . version
90
- } ${ sequenceString } ${ chalk . green ( "✔" ) } `,
91
+ } ${ sequenceString } ${ picocolors . green ( "✔" ) } `,
91
92
)
92
93
}
93
94
@@ -110,7 +111,7 @@ export function applyPatchesForApp({
110
111
const groupedPatches = getGroupedPatches ( patchesDirectory )
111
112
112
113
if ( groupedPatches . numPatchFiles === 0 ) {
113
- console . log ( chalk . blueBright ( "No patch files found" ) )
114
+ console . log ( picocolors . blue ( "No patch files found" ) )
114
115
return
115
116
}
116
117
@@ -140,10 +141,10 @@ export function applyPatchesForApp({
140
141
141
142
const problemsSummary = [ ]
142
143
if ( warnings . length ) {
143
- problemsSummary . push ( chalk . yellow ( `${ warnings . length } warning(s)` ) )
144
+ problemsSummary . push ( picocolors . yellow ( `${ warnings . length } warning(s)` ) )
144
145
}
145
146
if ( errors . length ) {
146
- problemsSummary . push ( chalk . red ( `${ errors . length } error(s)` ) )
147
+ problemsSummary . push ( picocolors . red ( `${ errors . length } error(s)` ) )
147
148
}
148
149
149
150
if ( problemsSummary . length ) {
@@ -201,8 +202,8 @@ export function applyPatchesForPackage({
201
202
appliedPatches . push ( unappliedPatches . shift ( ) ! )
202
203
} else {
203
204
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.` ,
206
207
`You should reinstall your node_modules folder to make sure the package is up to date` ,
207
208
)
208
209
process . exit ( 1 )
@@ -249,9 +250,9 @@ export function applyPatchesForPackage({
249
250
if ( ! installedPackageVersion ) {
250
251
// it's ok we're in production mode and this is a dev only package
251
252
console . log (
252
- `Skipping dev-only ${ chalk . bold (
253
+ `Skipping dev-only ${ picocolors . bold (
253
254
pathSpecifier ,
254
- ) } @${ version } ${ chalk . blue ( "✔" ) } `,
255
+ ) } @${ version } ${ picocolors . blue ( "✔" ) } `,
255
256
)
256
257
continue
257
258
}
@@ -429,7 +430,7 @@ export function applyPatch({
429
430
if ( errors ?. length ) {
430
431
console . log (
431
432
"Saving errors to" ,
432
- chalk . cyan . bold ( "./patch-package-errors.log" ) ,
433
+ picocolors . cyan ( picocolors . bold ( "./patch-package-errors.log" ) ) ,
433
434
)
434
435
writeFileSync ( "patch-package-errors.log" , errors . join ( "\n\n" ) )
435
436
process . exit ( 0 )
@@ -464,18 +465,20 @@ function createVersionMismatchWarning({
464
465
path : string
465
466
} ) {
466
467
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
468
471
469
472
Don't worry! This is probably fine. The patch was still applied
470
473
successfully. Here's the deets:
471
474
472
475
Patch file created for
473
476
474
- ${ packageName } @${ chalk . bold ( originalVersion ) }
477
+ ${ packageName } @${ picocolors . bold ( originalVersion ) }
475
478
476
479
applied to
477
480
478
- ${ packageName } @${ chalk . bold ( actualVersion ) }
481
+ ${ packageName } @${ picocolors . bold ( actualVersion ) }
479
482
480
483
At path
481
484
@@ -485,7 +488,7 @@ ${chalk.yellow("Warning:")} patch-package detected a patch file version mismatch
485
488
breakage even though the patch was applied successfully. Make sure the package
486
489
still behaves like you expect (you wrote tests, right?) and then run
487
490
488
- ${ chalk . bold ( `patch-package ${ pathSpecifier } ` ) }
491
+ ${ picocolors . bold ( `patch-package ${ pathSpecifier } ` ) }
489
492
490
493
to update the version in the patch file name and make this warning go away.
491
494
`
@@ -503,8 +506,8 @@ function createBrokenPatchFileError({
503
506
pathSpecifier : string
504
507
} ) {
505
508
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` ,
508
511
) }
509
512
510
513
${ path }
@@ -543,13 +546,15 @@ function createPatchApplicationFailureError({
543
546
pathSpecifier : string
544
547
} ) {
545
548
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` ,
548
551
) }
549
552
550
553
${ path }
551
554
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
553
558
made the patch file for it. This introduced conflicts with your patch,
554
559
just like a merge conflict in Git when separate incompatible changes are
555
560
made to the same piece of code.
@@ -568,8 +573,10 @@ ${chalk.red.bold("**ERROR**")} ${chalk.red(
568
573
569
574
Info:
570
575
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 ) ) }
573
580
`
574
581
}
575
582
@@ -581,8 +588,8 @@ function createUnexpectedError({
581
588
error : Error
582
589
} ) {
583
590
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 ) } ` ,
586
593
) }
587
594
588
595
${ error . stack }
0 commit comments