gdx 0.4.4 → 0.4.6
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/README.md +5 -4
- package/dist/index.js +628 -685
- package/dist/workers/generic.worker.min.js +1 -0
- package/package.json +29 -21
- package/scripts/launcher.cjs +10 -6
- package/scripts/postinstall.cjs +355 -272
package/scripts/postinstall.cjs
CHANGED
|
@@ -1,272 +1,355 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const { spawnSync, execFileSync } = require('child_process');
|
|
6
|
-
|
|
7
|
-
// Configuration
|
|
8
|
-
const PACKAGE_JSON_PATH = path.join(__dirname, '../package.json');
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
const
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
platform
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawnSync, execFileSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
// Configuration
|
|
8
|
+
const PACKAGE_JSON_PATH = path.join(__dirname, '../package.json');
|
|
9
|
+
const PACKAGE_DIR = path.join(__dirname, '..');
|
|
10
|
+
const BIN_DIR = path.join(__dirname, '../bin');
|
|
11
|
+
const NATIVE_DIR = path.join(BIN_DIR, 'native');
|
|
12
|
+
const PKG_SRC_PATH = path.join(__dirname, '../dist/index.js');
|
|
13
|
+
const INSTALL_INFO_PATH = path.join(NATIVE_DIR, 'install.json');
|
|
14
|
+
const PREBUILT_BASE_URL = process.env.GDX_PREBUILT_BASE_URL || 'https://github.com/Type-Delta/gdx/releases/download';
|
|
15
|
+
|
|
16
|
+
// Ensure native directory exists
|
|
17
|
+
function ensureBinDir() {
|
|
18
|
+
if (!fs.existsSync(NATIVE_DIR)) {
|
|
19
|
+
fs.mkdirSync(NATIVE_DIR, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getPackageVersion() {
|
|
24
|
+
const pkg = JSON.parse(fs.readFileSync(PACKAGE_JSON_PATH, 'utf8'));
|
|
25
|
+
return pkg.version;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function log(message) {
|
|
29
|
+
console.log(`[gdx-install] ${message}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function error(message) {
|
|
33
|
+
console.error(`[gdx-install] ERROR: ${message}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function writeInstallInfo(info) {
|
|
37
|
+
ensureBinDir();
|
|
38
|
+
fs.writeFileSync(INSTALL_INFO_PATH, JSON.stringify(info, null, 2));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isTruthy(v) {
|
|
42
|
+
return v === '1' || v === 'true' || v === 'yes';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getPrefixFromEnvOrNpm() {
|
|
46
|
+
if (process.env.npm_config_prefix) {
|
|
47
|
+
return process.env.npm_config_prefix;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Fallback: ask npm (works on modern npm)
|
|
51
|
+
const npmExecPath = process.env.npm_execpath;
|
|
52
|
+
if (!npmExecPath) return null;
|
|
53
|
+
|
|
54
|
+
const prefix = execFileSync(
|
|
55
|
+
`"${npmExecPath}"`,
|
|
56
|
+
['config', 'get', 'prefix'],
|
|
57
|
+
{ encoding: 'utf8', shell: true }
|
|
58
|
+
).trim();
|
|
59
|
+
|
|
60
|
+
return prefix || null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async function checkUrlExists(url) {
|
|
65
|
+
try {
|
|
66
|
+
const res = await fetch(url, { method: 'HEAD', redirect: 'follow' });
|
|
67
|
+
return res.ok;
|
|
68
|
+
} catch (err) {
|
|
69
|
+
throw new Error(`Network error while checking prebuilt availability: ${err.message} (${url})`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function downloadFile(url, tmpPath, destPath) {
|
|
74
|
+
const res = await fetch(url, { method: 'GET', redirect: 'follow' });
|
|
75
|
+
if (!res.ok) {
|
|
76
|
+
throw new Error(`Failed to download: ${res.statusText} (${url})`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const fileStream = fs.createWriteStream(destPath);
|
|
80
|
+
const stream = require('stream');
|
|
81
|
+
const { promisify } = require('util');
|
|
82
|
+
const pipeline = promisify(stream.pipeline);
|
|
83
|
+
|
|
84
|
+
await pipeline(res.body, fileStream);
|
|
85
|
+
fs.renameSync(tmpPath, destPath);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function setExecutable(filePath) {
|
|
89
|
+
if (process.platform !== 'win32') {
|
|
90
|
+
fs.chmodSync(filePath, 0o755);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function writeFileExecutable(filePath, content) {
|
|
95
|
+
// Remove any existing entry first. npm links bin entries as symlinks
|
|
96
|
+
// (e.g. <bindir>/gdx -> ../gdx/scripts/launcher.cjs); writing without
|
|
97
|
+
// unlinking would follow that symlink and overwrite its target
|
|
98
|
+
// (launcher.cjs) with shim content instead of replacing the bin entry.
|
|
99
|
+
// fs.rmSync unlinks the symlink itself; force ignores a missing path.
|
|
100
|
+
fs.rmSync(filePath, { force: true });
|
|
101
|
+
fs.writeFileSync(filePath, content, { encoding: 'utf8' });
|
|
102
|
+
setExecutable(filePath);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function buildNodeShimContents(nodeAbsPath, launcherAbsPath) {
|
|
106
|
+
return {
|
|
107
|
+
cmd: [
|
|
108
|
+
'@echo off',
|
|
109
|
+
'set "GDX_NODE_SHIM=1"',
|
|
110
|
+
`"${nodeAbsPath}" "${launcherAbsPath}" -- %*`,
|
|
111
|
+
'exit /b %ERRORLEVEL%',
|
|
112
|
+
''
|
|
113
|
+
].join('\r\n'),
|
|
114
|
+
ps1: [
|
|
115
|
+
'$env:GDX_NODE_SHIM = "1"',
|
|
116
|
+
`& "${nodeAbsPath}" "${launcherAbsPath}" -- @args`,
|
|
117
|
+
'exit $LASTEXITCODE',
|
|
118
|
+
''
|
|
119
|
+
].join('\r\n'),
|
|
120
|
+
sh: [
|
|
121
|
+
'#!/usr/bin/env sh',
|
|
122
|
+
'export GDX_NODE_SHIM=1',
|
|
123
|
+
`exec "${nodeAbsPath}" "${launcherAbsPath}" -- "$@"`,
|
|
124
|
+
''
|
|
125
|
+
].join('\n'),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getLocalNodeModulesBinDir() {
|
|
130
|
+
return path.resolve(PACKAGE_DIR, '..', '.bin');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function overwriteNodeShim(binDir, launcherAbsPath) {
|
|
134
|
+
if (!binDir || !fs.existsSync(binDir)) return false;
|
|
135
|
+
|
|
136
|
+
const nodeAbsPath = process.execPath;
|
|
137
|
+
const shims = buildNodeShimContents(nodeAbsPath, launcherAbsPath);
|
|
138
|
+
|
|
139
|
+
if (process.platform === 'win32') {
|
|
140
|
+
writeFileExecutable(path.join(binDir, 'gdx.cmd'), shims.cmd);
|
|
141
|
+
writeFileExecutable(path.join(binDir, 'gdx.ps1'), shims.ps1);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
writeFileExecutable(path.join(binDir, 'gdx'), shims.sh);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getNpmGlobalBinDir() {
|
|
150
|
+
if (!isTruthy(process.env.npm_config_global)) return null;
|
|
151
|
+
|
|
152
|
+
const prefix = getPrefixFromEnvOrNpm();
|
|
153
|
+
if (!prefix) return null;
|
|
154
|
+
|
|
155
|
+
if (process.platform === 'win32') {
|
|
156
|
+
// On Windows, shims are in the prefix dir itself
|
|
157
|
+
return prefix;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// On Unix, shims are in <prefix>/bin
|
|
161
|
+
return path.join(prefix, 'bin');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
function overwriteGlobalShim(nativeAbsPath) {
|
|
166
|
+
if (!isTruthy(process.env.npm_config_global))
|
|
167
|
+
return false;
|
|
168
|
+
|
|
169
|
+
if (!(process.env.npm_config_user_agent || '').includes('npm/')) {
|
|
170
|
+
log('Non-npm global install detected; skipping global shim overwrite.');
|
|
171
|
+
log('This may result in overhead introduced by the Node.js launch script.');
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const globalBin = getNpmGlobalBinDir();
|
|
176
|
+
if (!globalBin) return false;
|
|
177
|
+
|
|
178
|
+
if (process.platform === 'win32') {
|
|
179
|
+
const cmdPath = path.join(globalBin, 'gdx.cmd');
|
|
180
|
+
const ps1Path = path.join(globalBin, 'gdx.ps1');
|
|
181
|
+
|
|
182
|
+
const cmd = [
|
|
183
|
+
'@echo off',
|
|
184
|
+
`"${nativeAbsPath}" %*`,
|
|
185
|
+
'exit /b %ERRORLEVEL%',
|
|
186
|
+
''
|
|
187
|
+
].join('\r\n');
|
|
188
|
+
|
|
189
|
+
const ps1 = [
|
|
190
|
+
`& "${nativeAbsPath}" @args`,
|
|
191
|
+
'exit $LASTEXITCODE',
|
|
192
|
+
''
|
|
193
|
+
].join('\r\n');
|
|
194
|
+
|
|
195
|
+
writeFileExecutable(cmdPath, cmd);
|
|
196
|
+
writeFileExecutable(ps1Path, ps1);
|
|
197
|
+
} else {
|
|
198
|
+
const shPath = path.join(globalBin, 'gdx');
|
|
199
|
+
|
|
200
|
+
const sh = [
|
|
201
|
+
'#!/usr/bin/env sh',
|
|
202
|
+
`exec "${nativeAbsPath}" "$@"`,
|
|
203
|
+
''
|
|
204
|
+
].join('\n');
|
|
205
|
+
|
|
206
|
+
writeFileExecutable(shPath, sh);
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function installNodeFallbackShims() {
|
|
212
|
+
const launcherAbsPath = path.join(__dirname, 'launcher.cjs');
|
|
213
|
+
const localBin = getLocalNodeModulesBinDir();
|
|
214
|
+
const globalBin = getNpmGlobalBinDir();
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
local: overwriteNodeShim(localBin, launcherAbsPath),
|
|
218
|
+
global: overwriteNodeShim(globalBin, launcherAbsPath),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function tryDownloadPrebuilt() {
|
|
223
|
+
const version = getPackageVersion();
|
|
224
|
+
const platform = process.platform;
|
|
225
|
+
const arch = process.arch;
|
|
226
|
+
|
|
227
|
+
// Currently only supporting win32-x64
|
|
228
|
+
if (platform !== 'win32' || arch !== 'x64') {
|
|
229
|
+
throw new Error(`gdx: prebuilt binary not available for ${platform}/${arch} yet. Please reinstall without GDX_USE_PREBUILT=1 (unset GDX_USE_PREBUILT or use GDX_BUILD_NATIVE=1).`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const ext = platform === 'win32' ? '.exe' : '';
|
|
233
|
+
const assetName = `gdx-${platform}-${arch}${ext}`;
|
|
234
|
+
const url = `${PREBUILT_BASE_URL}/v${version}/${assetName}`;
|
|
235
|
+
|
|
236
|
+
log(`Checking availability of prebuilt binary: ${url}`);
|
|
237
|
+
const exists = await checkUrlExists(url);
|
|
238
|
+
if (!exists) {
|
|
239
|
+
throw new Error(`gdx: prebuilt binary not available for ${platform}/${arch} yet (404). Please reinstall without GDX_USE_PREBUILT=1 (unset GDX_USE_PREBUILT or use GDX_BUILD_NATIVE=1).`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
log(`Downloading prebuilt binary...`);
|
|
243
|
+
const tmpPath = path.join(NATIVE_DIR, `${assetName}.tmp`);
|
|
244
|
+
const finalPath = path.join(NATIVE_DIR, 'gdx' + ext);
|
|
245
|
+
|
|
246
|
+
ensureBinDir();
|
|
247
|
+
await downloadFile(url, tmpPath, finalPath);
|
|
248
|
+
setExecutable(finalPath);
|
|
249
|
+
|
|
250
|
+
log(`Prebuilt binary installed to ${finalPath}`);
|
|
251
|
+
|
|
252
|
+
writeInstallInfo({
|
|
253
|
+
mode: 'prebuilt',
|
|
254
|
+
platform,
|
|
255
|
+
arch,
|
|
256
|
+
version,
|
|
257
|
+
userAgent: process.env.npm_config_user_agent || null,
|
|
258
|
+
useNativeShim: overwriteGlobalShim(finalPath),
|
|
259
|
+
ts: (new Date).toLocaleString(),
|
|
260
|
+
binaryPath: finalPath
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function tryBuildNative() {
|
|
265
|
+
log('Attempting local native build with Bun...');
|
|
266
|
+
|
|
267
|
+
// Check for bun
|
|
268
|
+
const bunCheck = spawnSync('bun', ['--version'], { encoding: 'utf8', shell: true });
|
|
269
|
+
if (bunCheck.error || bunCheck.status !== 0) {
|
|
270
|
+
throw new Error('Bun is not installed or not found in PATH. Cannot build native binary. Please install Bun or reinstall without GDX_BUILD_NATIVE=1. (unset GDX_BUILD_NATIVE or set GDX_USE_PREBUILT to use prebuilt binary if available)');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const platform = process.platform;
|
|
274
|
+
const arch = process.arch;
|
|
275
|
+
const isWin = platform === 'win32';
|
|
276
|
+
const binaryName = isWin ? 'gdx.exe' : 'gdx';
|
|
277
|
+
const finalPath = path.join(NATIVE_DIR, binaryName);
|
|
278
|
+
|
|
279
|
+
// Build command
|
|
280
|
+
const args = [
|
|
281
|
+
'build',
|
|
282
|
+
PKG_SRC_PATH,
|
|
283
|
+
`--outfile=${finalPath}`,
|
|
284
|
+
'--compile',
|
|
285
|
+
'--bytecode',
|
|
286
|
+
'--production',
|
|
287
|
+
'--keep-names',
|
|
288
|
+
];
|
|
289
|
+
|
|
290
|
+
ensureBinDir();
|
|
291
|
+
log(`Running: bun ${args.join(' ')}`);
|
|
292
|
+
const build = spawnSync('bun', args, { stdio: 'inherit', shell: true });
|
|
293
|
+
|
|
294
|
+
if (build.status !== 0) {
|
|
295
|
+
throw new Error('Native build failed. Please check output above.');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
log(`Native binary built at ${finalPath}`);
|
|
299
|
+
|
|
300
|
+
writeInstallInfo({
|
|
301
|
+
mode: 'built',
|
|
302
|
+
platform,
|
|
303
|
+
arch,
|
|
304
|
+
version: getPackageVersion(),
|
|
305
|
+
userAgent: process.env.npm_config_user_agent || null,
|
|
306
|
+
useNativeShim: overwriteGlobalShim(finalPath),
|
|
307
|
+
ts: (new Date).toLocaleString(),
|
|
308
|
+
binaryPath: finalPath
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async function main() {
|
|
313
|
+
const ignoreScripts = isTruthy(process.env.npm_config_ignore_scripts) ||
|
|
314
|
+
isTruthy(process.env.NPM_CONFIG_IGNORE_SCRIPTS);
|
|
315
|
+
if (ignoreScripts) {
|
|
316
|
+
log('Scripts ignored by configuration. Skipping native setup.');
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
try {
|
|
321
|
+
if (isTruthy(process.env.GDX_USE_PREBUILT)) {
|
|
322
|
+
await tryDownloadPrebuilt();
|
|
323
|
+
} else if (isTruthy(process.env.GDX_BUILD_NATIVE)) {
|
|
324
|
+
tryBuildNative();
|
|
325
|
+
} else {
|
|
326
|
+
log('No native install requested (default). Using Node.js fallback.');
|
|
327
|
+
const shimInstall = installNodeFallbackShims();
|
|
328
|
+
writeInstallInfo({
|
|
329
|
+
mode: 'node',
|
|
330
|
+
platform: process.platform,
|
|
331
|
+
arch: process.arch,
|
|
332
|
+
version: getPackageVersion(),
|
|
333
|
+
userAgent: process.env.npm_config_user_agent || null,
|
|
334
|
+
useGlobalShim: shimInstall.global,
|
|
335
|
+
useLocalShim: shimInstall.local,
|
|
336
|
+
ts: (new Date).toLocaleString(),
|
|
337
|
+
launcherPath: path.join(__dirname, 'launcher.cjs')
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
} catch (err) {
|
|
341
|
+
error(err.message);
|
|
342
|
+
process.exit(1);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (require.main === module) {
|
|
347
|
+
main();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
module.exports = {
|
|
351
|
+
buildNodeShimContents,
|
|
352
|
+
getLocalNodeModulesBinDir,
|
|
353
|
+
installNodeFallbackShims,
|
|
354
|
+
overwriteNodeShim,
|
|
355
|
+
};
|