Patch oclif@4 just like oclif@3 (#5834)

This commit is contained in:
Kamil Kisiela 2024-10-28 15:05:59 +01:00 committed by GitHub
parent 9ae5a6692a
commit cd05a00fcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 5 deletions

View file

@ -121,7 +121,8 @@
"oclif@4.13.6": "patches/oclif@4.13.6.patch",
"@graphiql/react@1.0.0-alpha.3": "patches/@graphiql__react@1.0.0-alpha.3.patch",
"@theguild/components": "patches/@theguild__components.patch",
"countup.js": "patches/countup.js.patch"
"countup.js": "patches/countup.js.patch",
"@oclif/core@4.0.6": "patches/@oclif__core@4.0.6.patch"
}
}
}

View file

@ -0,0 +1,26 @@
diff --git a/lib/module-loader.js b/lib/module-loader.js
index 6162032e60f1e44ecfa19525ee07eecee1186208..52e99df36c28ad3603ab4e669f0c30181e6b1335 100644
--- a/lib/module-loader.js
+++ b/lib/module-loader.js
@@ -155,7 +155,20 @@ async function resolvePath(config, modulePath) {
let isESM;
let filePath;
try {
- filePath = require.resolve(modulePath);
+ try {
+ // We wrap it with try/catch and fallback to custom path if it fails to make it compatible with Hive.
+ // Due to some weird behavior in tsup/esbuild, it fails to resolve the path to the module.
+ filePath = require.resolve(modulePath);
+ } catch (error) {
+ const customPath = process.env.OCLIF_CLI_CUSTOM_PATH;
+ if (typeof customPath !== "string") {
+ throw error;
+ }
+ modulePath = modulePath.replace('/src/', '/dist/').replace('\\src\\', '\\dist\\');
+ filePath = require.resolve(
+ path.resolve(customPath, modulePath) + ".js"
+ );
+ }
isESM = isPathModule(filePath);
}
catch {

View file

@ -25,6 +25,9 @@ patchedDependencies:
'@oclif/core@3.26.6':
hash: rmd5oidpiuzwrwylcphsrfavay
path: patches/@oclif__core@3.26.6.patch
'@oclif/core@4.0.6':
hash: y5acwfkubqiafo3iitlwsynmki
path: patches/@oclif__core@4.0.6.patch
'@theguild/buddy@0.1.0':
hash: ryylgra5xglhidfoiaxehn22hq
path: patches/@theguild__buddy@0.1.0.patch
@ -20252,7 +20255,7 @@ snapshots:
wordwrap: 1.0.0
wrap-ansi: 7.0.0
'@oclif/core@4.0.6':
'@oclif/core@4.0.6(patch_hash=y5acwfkubqiafo3iitlwsynmki)':
dependencies:
ansi-escapes: 4.3.2
ansis: 3.2.0
@ -20278,12 +20281,12 @@ snapshots:
'@oclif/plugin-help@6.2.2':
dependencies:
'@oclif/core': 4.0.6
'@oclif/core': 4.0.6(patch_hash=y5acwfkubqiafo3iitlwsynmki)
'@oclif/plugin-not-found@3.2.4':
dependencies:
'@inquirer/confirm': 3.1.9
'@oclif/core': 4.0.6
'@oclif/core': 4.0.6(patch_hash=y5acwfkubqiafo3iitlwsynmki)
ansis: 3.2.0
fast-levenshtein: 3.0.0
@ -30152,7 +30155,7 @@ snapshots:
'@inquirer/confirm': 3.1.9
'@inquirer/input': 2.1.9
'@inquirer/select': 2.3.5
'@oclif/core': 4.0.6
'@oclif/core': 4.0.6(patch_hash=y5acwfkubqiafo3iitlwsynmki)
'@oclif/plugin-help': 6.2.2
'@oclif/plugin-not-found': 3.2.4
'@oclif/plugin-warn-if-update-available': 3.0.19