Skip to content

Commit b26c3ce

Browse files
committed
chore: bump slash to v3 with definition
1 parent 5ada466 commit b26c3ce

13 files changed

+119
-159
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@
8686
"klaw-sync": "^6.0.0",
8787
"minimist": "^1.2.6",
8888
"open": "^7.4.2",
89-
"picocolors": "^1.0.0",
89+
"picocolors": "^1.1.1",
9090
"semver": "^7.5.3",
91-
"slash": "^2.0.0",
91+
"slash": "^3.0.0",
9292
"tmp": "^0.0.33",
9393
"yaml": "^2.2.2"
9494
},

src/applyPatches.ts

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import picocolors from "picocolors"
2-
import { writeFileSync, existsSync } from "fs"
1+
import { existsSync, writeFileSync } from "fs"
32
import { posix } from "path"
3+
import { blue, bold, cyan, green, red, yellow } from "picocolors"
44
import semver from "semver"
55
import { hashFile } from "./hash"
66
import { logPatchSequenceError } from "./makePatch"
@@ -44,17 +44,16 @@ function getInstalledPackageVersion({
4444
}
4545

4646
let err =
47-
`${picocolors.red(
48-
"Error:",
49-
)} Patch file found for package ${posix.basename(pathSpecifier)}` +
50-
` which is not present at ${relative(".", packageDir)}`
47+
`${red("Error:")} Patch file found for package ${posix.basename(
48+
pathSpecifier,
49+
)}` + ` which is not present at ${relative(".", packageDir)}`
5150

5251
if (!isDevOnly && process.env.NODE_ENV === "production") {
5352
err += `
5453
5554
If this package is a dev dependency, rename the patch file to
5655
57-
${picocolors.bold(patchFilename.replace(".patch", ".dev.patch"))}
56+
${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-
`${picocolors.red(
67+
`${red(
6968
"Error:",
7069
)} Version string '${version}' cannot be parsed from ${join(
7170
packageDir,
@@ -85,9 +84,9 @@ function logPatchApplication(patchDetails: PatchedPackageDetails) {
8584
})`
8685
: ""
8786
console.log(
88-
`${picocolors.bold(patchDetails.pathSpecifier)}@${
87+
`${bold(patchDetails.pathSpecifier)}@${
8988
patchDetails.version
90-
}${sequenceString} ${picocolors.green("✔")}`,
89+
}${sequenceString} ${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(picocolors.blue("No patch files found"))
112+
console.log(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(picocolors.yellow(`${warnings.length} warning(s)`))
142+
problemsSummary.push(yellow(`${warnings.length} warning(s)`))
144143
}
145144
if (errors.length) {
146-
problemsSummary.push(picocolors.red(`${errors.length} error(s)`))
145+
problemsSummary.push(red(`${errors.length} error(s)`))
147146
}
148147

149148
if (problemsSummary.length) {
@@ -201,8 +200,8 @@ export function applyPatchesForPackage({
201200
appliedPatches.push(unappliedPatches.shift()!)
202201
} else {
203202
console.log(
204-
picocolors.red("Error:"),
205-
`The patches for ${picocolors.bold(pathSpecifier)} have changed.`,
203+
red("Error:"),
204+
`The patches for ${bold(pathSpecifier)} have changed.`,
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,7 @@ 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 ${picocolors.bold(
253-
pathSpecifier,
254-
)}@${version} ${picocolors.blue("✔")}`,
251+
`Skipping dev-only ${bold(pathSpecifier)}@${version} ${blue("✔")}`,
255252
)
256253
continue
257254
}
@@ -427,10 +424,7 @@ export function applyPatch({
427424
const errors: string[] | undefined = bestEffort ? [] : undefined
428425
executeEffects(forward, { dryRun: false, cwd, bestEffort, errors })
429426
if (errors?.length) {
430-
console.log(
431-
"Saving errors to",
432-
picocolors.cyan(picocolors.bold("./patch-package-errors.log")),
433-
)
427+
console.log("Saving errors to", cyan(bold("./patch-package-errors.log")))
434428
writeFileSync("patch-package-errors.log", errors.join("\n\n"))
435429
process.exit(0)
436430
}
@@ -464,20 +458,18 @@ function createVersionMismatchWarning({
464458
path: string
465459
}) {
466460
return `
467-
${picocolors.yellow(
468-
"Warning:",
469-
)} patch-package detected a patch file version mismatch
461+
${yellow("Warning:")} patch-package detected a patch file version mismatch
470462
471463
Don't worry! This is probably fine. The patch was still applied
472464
successfully. Here's the deets:
473465
474466
Patch file created for
475467
476-
${packageName}@${picocolors.bold(originalVersion)}
468+
${packageName}@${bold(originalVersion)}
477469
478470
applied to
479471
480-
${packageName}@${picocolors.bold(actualVersion)}
472+
${packageName}@${bold(actualVersion)}
481473
482474
At path
483475
@@ -487,7 +479,7 @@ ${picocolors.yellow(
487479
breakage even though the patch was applied successfully. Make sure the package
488480
still behaves like you expect (you wrote tests, right?) and then run
489481
490-
${picocolors.bold(`patch-package ${pathSpecifier}`)}
482+
${bold(`patch-package ${pathSpecifier}`)}
491483
492484
to update the version in the patch file name and make this warning go away.
493485
`
@@ -505,8 +497,8 @@ function createBrokenPatchFileError({
505497
pathSpecifier: string
506498
}) {
507499
return `
508-
${picocolors.red(picocolors.bold("**ERROR**"))} ${picocolors.red(
509-
`Failed to apply patch for package ${picocolors.bold(packageName)} at path`,
500+
${red(bold("**ERROR**"))} ${red(
501+
`Failed to apply patch for package ${bold(packageName)} at path`,
510502
)}
511503
512504
${path}
@@ -545,15 +537,13 @@ function createPatchApplicationFailureError({
545537
pathSpecifier: string
546538
}) {
547539
return `
548-
${picocolors.red(picocolors.bold("**ERROR**"))} ${picocolors.red(
549-
`Failed to apply patch for package ${picocolors.bold(packageName)} at path`,
540+
${red(bold("**ERROR**"))} ${red(
541+
`Failed to apply patch for package ${bold(packageName)} at path`,
550542
)}
551543
552544
${path}
553545
554-
This error was caused because ${picocolors.bold(
555-
packageName,
556-
)} has changed since you
546+
This error was caused because ${bold(packageName)} has changed since you
557547
made the patch file for it. This introduced conflicts with your patch,
558548
just like a merge conflict in Git when separate incompatible changes are
559549
made to the same piece of code.
@@ -572,10 +562,8 @@ ${picocolors.red(picocolors.bold("**ERROR**"))} ${picocolors.red(
572562
573563
Info:
574564
Patch file: patches/${patchFilename}
575-
Patch was made for version: ${picocolors.green(
576-
picocolors.bold(originalVersion),
577-
)}
578-
Installed version: ${picocolors.red(picocolors.bold(actualVersion))}
565+
Patch was made for version: ${green(bold(originalVersion))}
566+
Installed version: ${red(bold(actualVersion))}
579567
`
580568
}
581569

@@ -587,9 +575,7 @@ function createUnexpectedError({
587575
error: Error
588576
}) {
589577
return `
590-
${picocolors.red(picocolors.bold("**ERROR**"))} ${picocolors.red(
591-
`Failed to apply patch file ${picocolors.bold(filename)}`,
592-
)}
578+
${red(bold("**ERROR**"))} ${red(`Failed to apply patch file ${bold(filename)}`)}
593579
594580
${error.stack}
595581

src/createIssue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import picocolors from "picocolors"
21
import open from "open"
2+
import { bold } from "picocolors"
33
import { stringify } from "querystring"
44
import { PackageManager } from "./detectPackageManager"
55
import { PackageDetails } from "./PackageDetails"
@@ -105,7 +105,7 @@ export function maybePrintIssueCreationPrompt(
105105
packageManager: PackageManager,
106106
) {
107107
if (vcs) {
108-
console.log(`💡 ${picocolors.bold(packageDetails.name)} is on ${
108+
console.log(`💡 ${bold(packageDetails.name)} is on ${
109109
vcs.provider
110110
}! To draft an issue based on your patch run
111111

src/detectPackageManager.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1+
import findWorkspaceRoot from "find-yarn-workspace-root"
12
import fs from "fs"
2-
import { join } from "./path"
3-
import picocolors from "picocolors"
3+
import { bold, red } from "picocolors"
44
import process from "process"
5-
import findWorkspaceRoot from "find-yarn-workspace-root"
5+
import { join } from "./path"
66

77
export type PackageManager = "yarn" | "npm" | "npm-shrinkwrap"
88

99
function printNoYarnLockfileError() {
1010
console.log(`
11-
${picocolors.red(picocolors.bold("**ERROR**"))} ${picocolors.red(
11+
${red(bold("**ERROR**"))} ${red(
1212
`The --use-yarn option was specified but there is no yarn.lock file`,
1313
)}
1414
`)
1515
}
1616

1717
function printNoLockfilesError() {
1818
console.log(`
19-
${picocolors.red(picocolors.bold("**ERROR**"))} ${picocolors.red(
19+
${red(bold("**ERROR**"))} ${red(
2020
`No package-lock.json, npm-shrinkwrap.json, or yarn.lock file.
2121
2222
You must use either npm@>=5, yarn, or npm-shrinkwrap to manage this project's
@@ -27,10 +27,8 @@ dependencies.`,
2727

2828
function printSelectingDefaultMessage() {
2929
console.info(
30-
`${picocolors.bold(
31-
"patch-package",
32-
)}: you have both yarn.lock and package-lock.json
33-
Defaulting to using ${picocolors.bold("npm")}
30+
`${bold("patch-package")}: you have both yarn.lock and package-lock.json
31+
Defaulting to using ${bold("npm")}
3432
You can override this setting by passing --use-yarn or deleting
3533
package-lock.json if you don't need it
3634
`,

0 commit comments

Comments
 (0)