Skip to content

Commit

Permalink
build: replace patch-package with git apply
Browse files Browse the repository at this point in the history
- yarn patch-commit is used to generate patches. patch-package cannot be used to apply those patches on install due to directory mismatches (e.g. a/index.js vs a/node_modules/globby/index.js). patches cannot be created with patch-package either
- ds300/patch-package#272
- https://git-scm.com/docs/git-apply
- https://yarnpkg.com/cli/patch-commit
- https://yarnpkg.com/cli/patch

Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Sep 5, 2022
1 parent a7209bf commit bfa7a1e
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 192 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

# shellscript
[*.sh]
max_line_length = 100

# yaml
[*.yml]
max_line_length = 100
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[shellscript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.rulers": [100],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 100,
"rewrap.wrappingColumn": 100
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand Down
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ defaultSemverRangePrefix: ''

enableInlineBuilds: true

enableInlineHunks: true

nmHoistingLimits: none

nodeLinker: node-modules
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"fs-extra": "10.1.0",
"globby": "13.1.2",
"mlly": "0.5.14",
"patch-package": "6.4.7",
"pathe": "0.3.5",
"postinstall-postinstall": "2.1.0"
},
Expand Down Expand Up @@ -176,7 +175,9 @@
},
"resolutions": {
"@ardatan/sync-fetch": "larsgw/sync-fetch#head=worker_threads",
"graphql-config": "patch:[email protected]#patches/graphql-config+4.3.5.dev.patch"
"globby@npm:13.1.2": "patch:globby@npm%3A13.1.2#patches/globby+13.1.2.patch",
"graphql-config": "patch:graphql-config@npm%3A4.3.5#patches/graphql-config+4.3.5.dev.patch",
"mlly": "patch:mlly@npm%3A0.5.14#patches/mlly+0.5.14.patch"
},
"engines": {
"yarn": "4.0.0-rc.14"
Expand Down
13 changes: 13 additions & 0 deletions patches/globby+13.1.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/index.js b/index.js
index ce5a65639d49b3fc665b35d4b0d162e092c9d612..445bbadf62a85b4aab4728c3aafa34fd30c3caf9 100644
--- a/index.js
+++ b/index.js
@@ -29,7 +29,7 @@ const checkCwdOption = options => {

let stat;
try {
- stat = fs.statSync(options.cwd);
+ stat = (options?.fs ?? fs).statSync(options.cwd);
} catch {
return;
}
30 changes: 30 additions & 0 deletions patches/mlly+0.5.14.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/dist/index.cjs b/dist/index.cjs
index 887890308b948028ddde32ae180f3d0ca4519f39..7fc5b3459971de6cf6ada18934f676717badcf24 100644
--- a/dist/index.cjs
+++ b/dist/index.cjs
@@ -1096,8 +1096,8 @@ function createResolve(defaults) {

const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][\s;]*/gm;
const DYNAMIC_IMPORT_RE = /import\s*\((?<expression>(?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gm;
-const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(async function|function|let|const enum|const|enum|var|class))\s+(?<name>[\w$_]+)/g;
-const EXPORT_NAMED_RE = /\bexport\s+{(?<exports>[^}]+?)(?:[,\s]*)}(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][^\n;]*)?/g;
+const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(async function|function|let|const enum|const|enum|var|class|type))\s+(?<name>[\w$_]+)/g;
+const EXPORT_NAMED_RE = /\bexport( type)?\s+{(?<exports>[^}]+?)(?:[,\s]*)}(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][^\n;]*)?/g;
const EXPORT_STAR_RE = /\bexport\s*(\*)(\s*as\s+(?<name>[\w$_]+)\s+)?\s*(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][^\n;]*)?/g;
const EXPORT_DEFAULT_RE = /\bexport\s+default\s+/g;
function findStaticImports(code) {
diff --git a/dist/index.mjs b/dist/index.mjs
index 2114bf00092fc74642243b3ded5a718183a01039..e9409fc1187a9579eeb5129113f226625798b95c 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -1086,8 +1086,8 @@ function createResolve(defaults) {

const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][\s;]*/gm;
const DYNAMIC_IMPORT_RE = /import\s*\((?<expression>(?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gm;
-const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(async function|function|let|const enum|const|enum|var|class))\s+(?<name>[\w$_]+)/g;
-const EXPORT_NAMED_RE = /\bexport\s+{(?<exports>[^}]+?)(?:[,\s]*)}(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][^\n;]*)?/g;
+const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(async function|function|let|const enum|const|enum|var|class|type))\s+(?<name>[\w$_]+)/g;
+const EXPORT_NAMED_RE = /\bexport( type)?\s+{(?<exports>[^}]+?)(?:[,\s]*)}(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][^\n;]*)?/g;
const EXPORT_STAR_RE = /\bexport\s*(\*)(\s*as\s+(?<name>[\w$_]+)\s+)?\s*(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][^\n;]*)?/g;
const EXPORT_DEFAULT_RE = /\bexport\s+default\s+/g;
function findStaticImports(code) {
5 changes: 3 additions & 2 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
#
# References:
#
# - https://github.com/ds300/patch-package
# - https://git-scm.com/docs/git-apply
# - https://typicode.github.io/husky

if [ -f node_modules/.bin/husky ]; then
chmod +x .husky/* && husky install
else
patch-package
git apply --directory=node_modules/globby --reject patches/globby+13.1.2.patch
git apply --directory=node_modules/mlly --reject patches/mlly+0.5.14.patch
fi
Loading

0 comments on commit bfa7a1e

Please sign in to comment.