Skip to content

Commit ec161c4

Browse files
authored
Merge branch 'master' into patch-1
2 parents 90f0429 + 542eea4 commit ec161c4

File tree

79 files changed

+2238
-540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2238
-540
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [ds300]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.travis.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# Changelog
22

3+
## 6.4.7
4+
5+
- Use npm i --force when creating patches
6+
7+
## 6.4.6
8+
9+
- Update find-yarn-workspace-root (contribution from @sarimarton in #282)
10+
- Fix rare npm crash when creating patches (contribution from @kf6kjg in #271)
11+
12+
## 6.4.5
13+
14+
- Increase max pipe buffer size when creating patch. (contribution from @nomi9995 in #287)
15+
16+
## 6.4.4
17+
18+
- Refine --create-issue template
19+
20+
## 6.4.3
21+
22+
- Ensure real path is used when copying package contents. Potentially adds pnpm support (contribution from @milahu in #252)
23+
24+
## 6.4.2
25+
26+
- Add package version to --create-issue template
27+
28+
## 6.4.1
29+
30+
- Add backlink to patch-package repo to collect public usage of --create-issue
31+
32+
## 6.4.0
33+
34+
- Add --create-issue option
35+
36+
## 6.3.1
37+
38+
- Fix another createPatch bug involving .git folder hygiene (contribution from @gomain in #258)
39+
40+
## 6.3.0
41+
42+
- Add --error-on-fail cli option
43+
- Collate errors and warnings to avoid exiting early (with help from @akwodkiewicz in #217)
44+
- Fix .dev.patch suffix bug (with help from @pdcastro in #224)
45+
- Support build metadata in package.json version strings (with help from @snowystinger in #213)
46+
- Change 'no patch files found' message from red to blue (contribution from @dmhalejr in #211)
47+
- Fix environment variable propogation for spawned tasks (contribution from @chpio in #223)
48+
- Add --patch-dir option to readme (contribution from @mikehardy in #225)
49+
- Fix createPatch bug involving .git folder hygiene (contribution from @haroenv in #231)
50+
351
## 6.2.2
452

553
- Take config from .yarnrc when making patches (contribution from @NMinhNguyen in #222)

README.md

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,46 @@ files.
6161

6262
### Heroku
6363

64-
For `patch-package` to work on Heroku applications, you must specify [`NPM_CONFIG_PRODUCTION=false` or `YARN_PRODUCTION=false`](https://devcenter.heroku.com/articles/nodejs-support#package-installation). See [this issue](https://github.com/ds300/patch-package/issues/130) for more details.
64+
For `patch-package` to work on Heroku applications, you must specify
65+
[`NPM_CONFIG_PRODUCTION=false` or `YARN_PRODUCTION=false`](https://devcenter.heroku.com/articles/nodejs-support#package-installation).
66+
See [this issue](https://github.com/ds300/patch-package/issues/130) for more
67+
details.
6568

6669
### Docker and CI
6770

6871
- If having errors about working directory ("cannot run in wd [...]") when
6972
building in Docker, you might need to adjust configuration in `.npmrc`. See
7073
[#185](https://github.com/ds300/patch-package/issues/185).
71-
- In your `Dockerfile`, remember to copy over the patch files *before* running
74+
- In your `Dockerfile`, remember to copy over the patch files _before_ running
7275
`[npm|yarn] install`
7376
- If you cache `node_modules` rather than running `yarn install` every time,
7477
make sure that the `patches` dir is included in your cache key somehow.
7578
Otherwise if you update a patch then the change may not be reflected on
7679
subsequent CI runs.
80+
7781

78-
#### CircleCI example
79-
Create a hash of your patches before loading/saving your cache. If using a Linux machine, run `md5sum patches/* > patches.hash`. If running on a macOS machine, use `md5 patches/* > patches.hash`
80-
```yaml
81-
- run:
82-
name: patch-package hash
83-
command: md5sum patches/* > patches.hash
84-
```
85-
86-
Then, update your hash key to include a checksum of that file:
87-
```yaml
88-
- restore_cache:
89-
key: app-node_modules-v1-{{ checksum "yarn.lock" }}-{{ checksum "patches.hash" }}
90-
```
91-
92-
As well as the save_cache
93-
```yaml
94-
- save_cache:
95-
key: app-node_modules-v1-{{ checksum "yarn.lock" }}-{{ checksum "patches.hash" }}
96-
paths:
97-
- ./node_modules
98-
```
82+
### CircleCI
83+
Create a hash of your patches before loading/saving your cache. If using a Linux machine, run `md5sum patches/* > patches.hash`. If running on a macOS machine, use `md5 patches/* > patches.hash`
84+
```yaml
85+
- run:
86+
name: patch-package hash
87+
command: md5sum patches/* > patches.hash
88+
```
89+
90+
Then, update your hash key to include a checksum of that file:
91+
```yaml
92+
- restore_cache:
93+
key: app-node_modules-v1-{{ checksum "yarn.lock" }}-{{ checksum "patches.hash" }}
94+
```
95+
96+
As well as the save_cache
97+
```yaml
98+
- save_cache:
99+
key: app-node_modules-v1-{{ checksum "yarn.lock" }}-{{ checksum "patches.hash" }}
100+
paths:
101+
- ./node_modules
102+
```
103+
99104
100105
## Usage
101106
@@ -120,6 +125,11 @@ team.
120125

121126
#### Options
122127

128+
- `--create-issue`
129+
130+
For packages whose source is hosted on GitHub this option opens a web browser
131+
with a draft issue based on your diff.
132+
123133
- `--use-yarn`
124134

125135
By default, patch-package checks whether you use npm or yarn based on which
@@ -171,6 +181,19 @@ Run `patch-package` without arguments to apply all patches in your project.
171181

172182
#### Options
173183

184+
- `--error-on-fail`
185+
186+
Forces patch-package to exit with code 1 after failing.
187+
188+
When running locally patch-package always exits with 0 by default. This
189+
happens even after failing to apply patches because otherwise yarn.lock and
190+
package.json might get out of sync with node_modules, which can be very
191+
confusing.
192+
193+
`--error-on-fail` is **switched on** by default on CI.
194+
195+
See https://github.com/ds300/patch-package/issues/86 for background.
196+
174197
- `--reverse`
175198

176199
Un-applies all patches.

integration-tests/adding-and-deleting-files/adding-and-deleting-files.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "add a file"
89
echo "this is a new file" > node_modules/lodash/newFile.md
@@ -11,14 +12,14 @@ echo "remove a file"
1112
rm node_modules/lodash/fp/__.js
1213

1314
echo "generate patch file"
14-
npx patch-package lodash
15+
patch-package lodash
1516

1617
echo "remove node_modules"
1718
rm -rf node_modules
1819

1920
echo "resintall and patch node_modules"
2021
yarn
21-
npx patch-package
22+
patch-package
2223

2324
echo "check that the file was added"
2425
ls node_modules/lodash/newFile.md

integration-tests/broken-patch-file/__snapshots__/broken-patch-file.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ exports[`Test broken-patch-file: patch-package fails when patch file is invalid
2323
https://github.com/ds300/patch-package/issues
2424
2525
26+
---
27+
patch-package finished with 1 error(s).
2628
END SNAPSHOT"
2729
`;

integration-tests/broken-patch-file/broken-patch-file.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
(>&2 echo "SNAPSHOT: patch-package fails when patch file is invalid")
8-
if npx patch-package
9+
if patch-package
910
then
1011
exit 1
1112
fi
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Test collate-errors: left-pad, lodash, and zfs apply 1`] = `
4+
"SNAPSHOT: left-pad, lodash, and zfs apply
5+
patch-package 0.0.0
6+
Applying patches...
7+
8+
9+
10+
END SNAPSHOT"
11+
`;
12+
13+
exports[`Test collate-errors: underscore does not apply, left-pad warns 1`] = `
14+
"SNAPSHOT: underscore does not apply, left-pad warns
15+
16+
Warning: patch-package detected a patch file version mismatch
17+
18+
Don't worry! This is probably fine. The patch was still applied
19+
successfully. Here's the deets:
20+
21+
Patch file created for
22+
23+
24+
25+
applied to
26+
27+
28+
29+
At path
30+
31+
node_modules/left-pad
32+
33+
This warning is just to give you a heads-up. There is a small chance of
34+
breakage even though the patch was applied successfully. Make sure the package
35+
still behaves like you expect (you wrote tests, right?) and then run
36+
37+
patch-package left-pad
38+
39+
to update the version in the patch file name and make this warning go away.
40+
41+
42+
**ERROR** Failed to apply patch for package underscore at path
43+
44+
node_modules/underscore
45+
46+
This error was caused because underscore has changed since you
47+
made the patch file for it. This introduced conflicts with your patch,
48+
just like a merge conflict in Git when separate incompatible changes are
49+
made to the same piece of code.
50+
51+
Maybe this means your patch file is no longer necessary, in which case
52+
hooray! Just delete it!
53+
54+
Otherwise, you need to generate a new patch file.
55+
56+
To generate a new one, just repeat the steps you made to generate the first
57+
one.
58+
59+
i.e. manually make the appropriate file changes, then run
60+
61+
patch-package underscore
62+
63+
Info:
64+
Patch file: patches/underscore+1.0.3.patch
65+
Patch was made for version: 1.0.3
66+
Installed version: 1.12.0
67+
68+
---
69+
patch-package finished with 1 warning(s), 1 error(s).
70+
END SNAPSHOT"
71+
`;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# make sure errors stop the script
2+
set -e
3+
4+
echo "add patch-package"
5+
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
7+
8+
echo "SNAPSHOT: left-pad, lodash, and zfs apply"
9+
(>&2 echo "SNAPSHOT: underscore does not apply, left-pad warns")
10+
if patch-package;
11+
then
12+
exit 1
13+
fi
14+
(>&2 echo "END SNAPSHOT")
15+
echo "END SNAPSHOT"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { runIntegrationTest } from "../runIntegrationTest"
2+
runIntegrationTest({
3+
projectName: "collate-errors",
4+
shouldProduceSnapshots: true,
5+
})

0 commit comments

Comments
 (0)