houdini-core 2.0.0-go.3 → 2.0.0-go.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -7
- package/postInstall.js +38 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-core",
|
|
3
|
-
"version": "2.0.0-go.
|
|
3
|
+
"version": "2.0.0-go.5",
|
|
4
4
|
"description": "The core GraphQL client for Houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -21,14 +21,19 @@
|
|
|
21
21
|
"minimatch": "^5.1.0"
|
|
22
22
|
},
|
|
23
23
|
"optionalDependencies": {
|
|
24
|
-
"houdini-core-darwin-x64": "2.0.0-go.
|
|
25
|
-
"houdini-core-darwin-arm64": "2.0.0-go.
|
|
26
|
-
"houdini-core-linux-x64": "2.0.0-go.
|
|
27
|
-
"houdini-core-linux-arm64": "2.0.0-go.
|
|
28
|
-
"houdini-core-win32-x64": "2.0.0-go.
|
|
29
|
-
"houdini-core-win32-arm64": "2.0.0-go.
|
|
24
|
+
"houdini-core-darwin-x64": "2.0.0-go.5",
|
|
25
|
+
"houdini-core-darwin-arm64": "2.0.0-go.5",
|
|
26
|
+
"houdini-core-linux-x64": "2.0.0-go.5",
|
|
27
|
+
"houdini-core-linux-arm64": "2.0.0-go.5",
|
|
28
|
+
"houdini-core-win32-x64": "2.0.0-go.5",
|
|
29
|
+
"houdini-core-win32-arm64": "2.0.0-go.5"
|
|
30
30
|
},
|
|
31
31
|
"bin": "./shim.cjs",
|
|
32
|
+
"files": [
|
|
33
|
+
"postInstall.js",
|
|
34
|
+
"runtime",
|
|
35
|
+
"shim.cjs"
|
|
36
|
+
],
|
|
32
37
|
"scripts": {
|
|
33
38
|
"compile": "scripts build-go",
|
|
34
39
|
"typedefs": "scripts typedefs --go-package",
|
package/postInstall.js
CHANGED
|
@@ -4,7 +4,7 @@ const zlib = require('zlib')
|
|
|
4
4
|
const https = require('https')
|
|
5
5
|
|
|
6
6
|
// Adjust the version you want to install. You can also make this dynamic.
|
|
7
|
-
const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.
|
|
7
|
+
const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.5'
|
|
8
8
|
|
|
9
9
|
// Windows binaries end with .exe so we need to special case them.
|
|
10
10
|
const binaryName = process.platform === 'win32' ? 'houdini-core.exe' : 'houdini-core'
|
|
@@ -87,11 +87,14 @@ async function downloadBinaryFromNpm() {
|
|
|
87
87
|
|
|
88
88
|
function isPlatformSpecificPackageInstalled() {
|
|
89
89
|
try {
|
|
90
|
-
//
|
|
91
|
-
require.resolve(`${platformSpecificPackageName}/
|
|
90
|
+
// Try to resolve the platform package itself
|
|
91
|
+
require.resolve(`${platformSpecificPackageName}/package.json`)
|
|
92
92
|
return true
|
|
93
93
|
} catch (e) {
|
|
94
|
-
|
|
94
|
+
// Also check if it exists as a sibling directory
|
|
95
|
+
const siblingPath = path.join(__dirname, '..', platformSpecificPackageName)
|
|
96
|
+
const siblingBinaryPath = path.join(siblingPath, 'bin', binaryName)
|
|
97
|
+
return fs.existsSync(siblingBinaryPath)
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -100,17 +103,44 @@ if (!platformSpecificPackageName) {
|
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
// once we've confirmed the required package is installed we want to overwrite the bin entry of our package.json
|
|
103
|
-
// to point to the correct binary
|
|
106
|
+
// to point to the correct binary for optimal performance (skip Node.js overhead)
|
|
104
107
|
function overwriteBinary() {
|
|
105
108
|
const packageJsonPath = path.join(__dirname, 'package.json')
|
|
106
109
|
const packageJson = require(packageJsonPath)
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
|
|
111
|
+
let binaryPath = null
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
// Method 1: Use require.resolve to find the actual path to the platform-specific package
|
|
115
|
+
// This works with pnpm and other package managers that use symlinks
|
|
116
|
+
const platformPackagePath = require.resolve(`${platformSpecificPackageName}/package.json`)
|
|
117
|
+
const platformPackageDir = path.dirname(platformPackagePath)
|
|
118
|
+
binaryPath = path.join(platformPackageDir, 'bin', binaryName)
|
|
119
|
+
} catch (error) {
|
|
120
|
+
// Method 2: Check if platform package is installed as a sibling directory
|
|
121
|
+
// This works with npm and local installs
|
|
122
|
+
const siblingPath = path.join(__dirname, '..', platformSpecificPackageName)
|
|
123
|
+
const siblingBinaryPath = path.join(siblingPath, 'bin', binaryName)
|
|
124
|
+
|
|
125
|
+
if (fs.existsSync(siblingBinaryPath)) {
|
|
126
|
+
binaryPath = siblingBinaryPath
|
|
127
|
+
} else {
|
|
128
|
+
// Use shim as fallback
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (binaryPath) {
|
|
134
|
+
// Make the path relative to the main package directory
|
|
135
|
+
const relativeBinaryPath = path.relative(__dirname, binaryPath)
|
|
136
|
+
packageJson.bin = relativeBinaryPath
|
|
137
|
+
|
|
138
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
139
|
+
}
|
|
109
140
|
}
|
|
110
141
|
|
|
111
142
|
// Skip downloading the binary if it was already installed via optionalDependencies
|
|
112
143
|
if (!isPlatformSpecificPackageInstalled()) {
|
|
113
|
-
console.log('Platform specific package not found. Will manually download binary.')
|
|
114
144
|
downloadBinaryFromNpm().then(overwriteBinary)
|
|
115
145
|
} else {
|
|
116
146
|
overwriteBinary()
|