-
-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make work with pnpm and git, use pnpm-lock.yaml #302
Conversation
This comment has been minimized.
This comment has been minimized.
@milahu Awesome work! I was just about to look into this myself when I found your PR. |
@ds300 Is it possible to take a look into this PR? thank you |
thx for the keepalive ; ) thing is, the main patch-package repo is slightly undermaintained ... i never really came to use my patch, let me catch up on that: install patch-package branch pnpm-support-2cd /my/fancy/node/project
mkdir patched_packages
cd patched_packages
git clone --depth 1 https://github.com/milahu/patch-package.git --branch pnpm-support-2
cd patch-package
pnpm install
pnpm run build
cd ../../
node patched_modules/patch-package/dist/index.js some-node-package testsedit: github CI says tests passed 0__o let me run tests again ... # if you have some minutes to waste ...
pnpm run test
# jest --runInBand
# ts-jest[config] (WARN) Unable to find the root of the project where ts-jest has been installed.
# ts-jest[versions] (WARN) Version 4.2.4 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
# FAIL src/packageIsDevDependency.test.ts
# ● packageIsDevDependency › returns false if package is a transitive dependency of a dev dependency
# [ may be related to my patch ]
# Test Suites: 1 failed, 35 passed, 36 total
# Tests: 1 failed, 5 skipped, 804 passed, 810 total
# Snapshots: 65 passed, 65 total
# Time: 438.918s one problem i found: another problem, also
... then that opinions on this? when i do when i do (
cd /tmp; git clone --depth 1 https://github.com/ds300/patch-package.git
cd patch-package; pnpm install; pnpm run build
)
pnpm install /tmp/patch-package then the so ... imho the only solution is to make pnpm clone the git repo ideally, following runs of |
I feel like using patch-package on a locally linked package is way too niche, and if it takes way too much work or maintenance in the future just to keep it working, it should just throw, I'm pretty sure the 99% of the usage of patch-package is just for npm packages. |
agree, linked packages are not portable
... but some changes are non-trivial my workflow can be solved with 1. in the npm project, install step 3 could be automated with a file watcher, e.g. chokidar.watch another detail (see next comment) |
done: restore the old when the package is installed from git, patch-package will require to pin the version in {
"dependencies": {
"some-package": "git://some/where#fullcommithash"
}
} todo: automate the version-pinning with a discuss: is this "version-pinning in package.json" too pedantic? todo: fix fixed: the tests: to test npm packages, we could run a local npm registry done: add header comments to the generated patch files. sample: # generated by patch-package 6.4.7 on 2021-05-12 20:07:53
#
# command:
# npx patch-package --exclude '^test/stubs.*' @11ty/eleventy
#
# declared package:
# @11ty/eleventy: github:11ty/eleventy#8a5162785c58864ef65308c0f0d890cade0b407f
#
# header comments also make room for custom "patch messages", like ...
#
# this patch will
#
# * add feature xyz
# * fix bug 123
#
diff --git a/node_modules/@11ty/eleventy/src/Engines/Txt.js b/node_modules/@11ty/eleventy/src/Engines/Txt.js
new file mode 100644
index 0000000..aef38ca
--- /dev/null
+++ b/node_modules/@11ty/eleventy/src/Engines/Txt.js
@@ -0,0 +1,34 @@
+// based on Html.js
+
+const TemplateEngine = require("./TemplateEngine");
... todo: when package is a git repo, add commit messages as diff header comments todo: when an old patch exists, prepend the old header comments to the new patch done: add
todo: emulate |
hi @ds300 can you review this? thanks! |
// TODO dont use lockfiles at all? | ||
// package versions should be pinned in /package.json, so it works with all package managers at all times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discuss ... pinning versions in /package.json
is the simplest and most portable solution.
lockfiles are only needed for nested/recursive/deep/secondary dependencies
so ... maintainer is gone, nobody wants to maintain a fork,
its not perfect, but it works : ) |
@ds300 can you please review this? |
thanks for reporting, fixed
note: some tests are failing |
…electron-updater`. This is to reduce noise on tags being pushed. (Note: Must use custom fork of patch-package until ds300/patch-package#302 is released.) Activating additional Updater tests
* Patching changesets to only publish tags for `electron-builder` and `electron-updater`. This is to reduce noise on tags being pushed. (Note: Must use custom fork of patch-package until ds300/patch-package#302 is released.) Activating additional Updater tests
what's the hold up here ? |
patch-package != pnpm
patch-package is unmaintained. if you allow upstream packages to block your workflow, youre doing something wrong |
The solution is here: remix-run/remix#1193 (comment) And for patching a npm package is this package: https://www.npmjs.com/package/patch-package Which doesn'r work with pnpm LOL. Patched itself here: ds300/patch-package#302 (comment)
we can run this code on Remix example apps. The way it works is you add the package in `/packages` folder. And if you want a new remix app example add it to `/examples`. It's explained in the README. Please follow the instructions Patch @remix-run/dev to allow watching changes on packages The solution is here: remix-run/remix#1193 (comment) And for patching a npm package is this package: https://www.npmjs.com/package/patch-package Which doesn't work with pnpm LOL. Patched itself here: ds300/patch-package#302 (comment)
Thank you! Any reason why you didn't merge it into |
this PR is merged in https://github.com/milahu/patch-package-with-pnpm-support |
Thank you! Switching over to your version :> |
Hey @milahu thanks for your work
I tried to use it in mono-repo setup but this does not work if I install at root and execute If I instead install it on the sub folder, it cannot find |
thanks for reporting. pnpm workspaces (monorepos) are not implemented |
@milahu I found a fork of your repo that adds the pnpm lock file detection for workspaces... in case that is something you could easily roll back into your repo. |
You're perfectly welcome. I mulled issuing a pull request back then but wasn't sure if it was up to code standards. Glad to have been of help :) Thanks for the great work on the package in general! |
bugfix for pnpm workspaces published as |
renamed to
|
How do people use |
Good news!! PNPM now has official support for yarn style patch! We just need to wait for its next release. The benefit of the official support in PNPM is that you won't corrupt the global store (they're shared!) Also thanks for @milahu, your PR helped us go through the hard time before the official support! |
pnpm has a |
Yeah, I think using the built in pnpm patch command is the right call here. Especially considering the inherent trickiness of editing global package repo which this changes. I think the right call is for us to have a README edit which links to the docs for |
Shipped the README change 6fc78ff - and I'm closing this PR. Folks involved, you did great work and this is not me dismissing that work as not useful - if there are people who can't upgrade to a version of pnpm with support for patching can use @milahu's fork referenced here: #302 (comment) |
part of issue #35 (comment)
error was
install
to install my patched version of
patch-package
why is this PR still open?
the author of
patch-package
has abandoned the project,so nobody has write access to the repo. feel free to fork my fork
changes
pnpm-lock.yaml
to get the resolvedVersionpnpm-lock.yaml
was found)npm install
etc (todo: add a--verbose
flag to CLI)patch-package --exclude '^dist/.*'
tslint --fix
andprettier --write
(sorry for the diff noise)link:../../../some/relative/path
origin/HEAD
commitpackage.json
node_packages
folders from local packagetodo
are git patches applied correctly? we must install the exact commit
fixme
when we install packages from git (pinned to commit), patch-package will say
Warning: patch-package detected a patch file version mismatch
cos the patch version is the "declared" version from /package.json = commit hash
= for example
8a5162785c58864ef65308c0f0d890cade0b407f
and the "applied to" version ("resolved" version) is from node_modules/pkg/package.json
= for example 1.0.0-canary.10
both versions (declared and resolved) could be stored in the comment header of the patch file