gdx 0.4.5 → 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 +4 -4
- package/dist/index.js +629 -692
- package/package.json +10 -3
- package/scripts/launcher.cjs +10 -6
- package/scripts/postinstall.cjs +85 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdx",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Git, but with better DX. The raw power of Git, aligned with human workflows.",
|
|
5
5
|
"homepage": "https://github.com/Type-Delta/gdx#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"test": "bun test",
|
|
43
43
|
"build": "bun run transpile-esm && bun build ./src/index.ts --outfile=./bin/gdx --compile --bytecode --production --keep-names",
|
|
44
44
|
"ts-check": "bunx tsc --noEmit",
|
|
45
|
-
"package:node": "bun run transpile-esm && bun build ./src/index.ts --outdir=./dist --target=node --external=keytar --external=cspell-lib --external=@shikijs/cli --external=yaml --external=openai --external=fflate --format=esm --production --keep-names && bun build ./src/workers/generic.worker.ts --outfile=./dist/workers/generic.worker.min.js --target=node --external=@shikijs/cli --format=esm --production --minify --keep-names",
|
|
45
|
+
"package:node": "bun run transpile-esm && bun build ./src/index.ts --outdir=./dist --target=node --external=keytar --external=cspell-lib --external=@shikijs/cli --external=shiki --external=yaml --external=openai --external=fflate --external=diff --format=esm --production --keep-names && bun build ./src/workers/generic.worker.ts --outfile=./dist/workers/generic.worker.min.js --target=node --external=@shikijs/cli --format=esm --production --minify --keep-names",
|
|
46
46
|
"prepack": "bun run package:node",
|
|
47
47
|
"postinstall": "node scripts/postinstall.cjs",
|
|
48
48
|
"prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"./*.md\"",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@sinclair/typebox": "^0.34.49",
|
|
61
61
|
"@types/chai": "^5.2.3",
|
|
62
62
|
"@types/ini": "^4.1.1",
|
|
63
|
+
"@types/which": "^3.0.4",
|
|
63
64
|
"@typescript-eslint/eslint-plugin": "^8.59.4",
|
|
64
65
|
"@typescript-eslint/parser": "^8.59.4",
|
|
65
66
|
"bun-types": "latest",
|
|
@@ -73,9 +74,11 @@
|
|
|
73
74
|
"smol-toml": "^1.6.1",
|
|
74
75
|
"tinybench": "^6.0.2",
|
|
75
76
|
"tsx": "^4.22.3",
|
|
77
|
+
"tty-strings": "^1.5.2",
|
|
76
78
|
"typescript": "^6.0.3",
|
|
77
79
|
"typescript-eslint": "^8.59.4",
|
|
78
|
-
"unicode-animations": "^1.0.3"
|
|
80
|
+
"unicode-animations": "^1.0.3",
|
|
81
|
+
"which": "2.0.2"
|
|
79
82
|
},
|
|
80
83
|
"dependencies": {
|
|
81
84
|
"@shikijs/cli": "^4.1.0",
|
|
@@ -85,5 +88,9 @@
|
|
|
85
88
|
"keytar": "^7.9.0",
|
|
86
89
|
"openai": "^6.38.0",
|
|
87
90
|
"yaml": "^2.9.0"
|
|
91
|
+
},
|
|
92
|
+
"patchedDependencies": {
|
|
93
|
+
"tty-strings@1.5.2": "patches/tty-strings@1.5.2.patch",
|
|
94
|
+
"execa@9.6.1": "patches/execa@9.6.1.patch"
|
|
88
95
|
}
|
|
89
96
|
}
|
package/scripts/launcher.cjs
CHANGED
|
@@ -8,12 +8,16 @@ const { spawn } = require('child_process');
|
|
|
8
8
|
|
|
9
9
|
const DIST_DIR = path.join(__dirname, '../dist');
|
|
10
10
|
const NATIVE_DIR = path.join(DIST_DIR, 'native');
|
|
11
|
-
const isWin = process.platform === 'win32';
|
|
12
|
-
const binaryName = isWin ? 'gdx.exe' : 'gdx';
|
|
13
|
-
const binaryPath = path.join(NATIVE_DIR, binaryName);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const isWin = process.platform === 'win32';
|
|
12
|
+
const binaryName = isWin ? 'gdx.exe' : 'gdx';
|
|
13
|
+
const binaryPath = path.join(NATIVE_DIR, binaryName);
|
|
14
|
+
|
|
15
|
+
if (process.env.GDX_NODE_SHIM === '1' && process.argv[2] === '--') {
|
|
16
|
+
process.argv.splice(2, 1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Check if native binary exists
|
|
20
|
+
if (fs.existsSync(binaryPath)) {
|
|
17
21
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
18
22
|
stdio: 'inherit'
|
|
19
23
|
});
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const { spawnSync, execFileSync } = require('child_process');
|
|
|
6
6
|
|
|
7
7
|
// Configuration
|
|
8
8
|
const PACKAGE_JSON_PATH = path.join(__dirname, '../package.json');
|
|
9
|
+
const PACKAGE_DIR = path.join(__dirname, '..');
|
|
9
10
|
const BIN_DIR = path.join(__dirname, '../bin');
|
|
10
11
|
const NATIVE_DIR = path.join(BIN_DIR, 'native');
|
|
11
12
|
const PKG_SRC_PATH = path.join(__dirname, '../dist/index.js');
|
|
@@ -33,6 +34,7 @@ function error(message) {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
function writeInstallInfo(info) {
|
|
37
|
+
ensureBinDir();
|
|
36
38
|
fs.writeFileSync(INSTALL_INFO_PATH, JSON.stringify(info, null, 2));
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -90,10 +92,60 @@ function setExecutable(filePath) {
|
|
|
90
92
|
}
|
|
91
93
|
|
|
92
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 });
|
|
93
101
|
fs.writeFileSync(filePath, content, { encoding: 'utf8' });
|
|
94
102
|
setExecutable(filePath);
|
|
95
103
|
}
|
|
96
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
|
+
|
|
97
149
|
function getNpmGlobalBinDir() {
|
|
98
150
|
if (!isTruthy(process.env.npm_config_global)) return null;
|
|
99
151
|
|
|
@@ -156,6 +208,17 @@ function overwriteGlobalShim(nativeAbsPath) {
|
|
|
156
208
|
return true;
|
|
157
209
|
}
|
|
158
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
|
+
|
|
159
222
|
async function tryDownloadPrebuilt() {
|
|
160
223
|
const version = getPackageVersion();
|
|
161
224
|
const platform = process.platform;
|
|
@@ -261,7 +324,18 @@ async function main() {
|
|
|
261
324
|
tryBuildNative();
|
|
262
325
|
} else {
|
|
263
326
|
log('No native install requested (default). Using Node.js fallback.');
|
|
264
|
-
|
|
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
|
+
});
|
|
265
339
|
}
|
|
266
340
|
} catch (err) {
|
|
267
341
|
error(err.message);
|
|
@@ -269,4 +343,13 @@ async function main() {
|
|
|
269
343
|
}
|
|
270
344
|
}
|
|
271
345
|
|
|
272
|
-
main
|
|
346
|
+
if (require.main === module) {
|
|
347
|
+
main();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
module.exports = {
|
|
351
|
+
buildNodeShimContents,
|
|
352
|
+
getLocalNodeModulesBinDir,
|
|
353
|
+
installNodeFallbackShims,
|
|
354
|
+
overwriteNodeShim,
|
|
355
|
+
};
|