gitlocker 1.0.6 → 1.0.7

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Project: gitlocker
4
4
 
5
- Version: 1.0.6
5
+ Version: 1.0.7
6
6
 
7
7
  Resolved vcpkg triplet: `x64-linux-static`
8
8
 
package/bin/gitlocker.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { spawnSync } = require('child_process');
4
+ const fs = require('fs');
4
5
  const os = require('os');
5
6
  const path = require('path');
6
7
 
@@ -11,79 +12,78 @@ function getPlatformPackage() {
11
12
  if (platform === 'win32') {
12
13
  if (arch === 'x64') {
13
14
  return '@git-braints/cli-win32-x64';
14
- } else {
15
- console.error(`[GitLocker] Unsupported architecture on Windows: ${arch}. GitLocker currently only supports Windows x64.`);
16
- process.exit(1);
17
15
  }
16
+ console.error(`[GitLocker] Unsupported architecture on Windows: ${arch}. GitLocker currently only supports Windows x64.`);
17
+ process.exit(1);
18
18
  }
19
19
 
20
20
  if (platform === 'linux') {
21
21
  if (arch === 'x64') {
22
22
  return '@git-braints/cli-linux-x64';
23
- } else {
24
- console.error(`[GitLocker] Unsupported architecture on Linux: ${arch}. GitLocker currently only supports Linux x64.`);
25
- process.exit(1);
26
23
  }
24
+ console.error(`[GitLocker] Unsupported architecture on Linux: ${arch}. GitLocker currently only supports Linux x64.`);
25
+ process.exit(1);
27
26
  }
28
27
 
29
28
  if (platform === 'darwin') {
30
29
  if (arch === 'arm64') {
31
30
  return '@git-braints/cli-darwin-arm64';
32
- } else {
33
- console.error(`[GitLocker] Unsupported architecture on macOS: ${arch}. GitLocker currently only supports macOS arm64.`);
34
- process.exit(1);
35
31
  }
32
+ console.error(`[GitLocker] Unsupported architecture on macOS: ${arch}. GitLocker currently only supports macOS arm64.`);
33
+ process.exit(1);
36
34
  }
37
35
 
38
36
  console.error(`[GitLocker] Unsupported platform: ${platform}.`);
39
- console.error(`GitLocker npm distribution currently only supports Windows (win32-x64), Linux (linux-x64) and macOS (darwin-arm64) in this build.`);
40
- console.error(`For other platforms, please compile GitLocker from source or download from GitHub Releases.`);
37
+ console.error('GitLocker npm distribution currently only supports Windows (win32-x64), Linux (linux-x64) and macOS (darwin-arm64).');
38
+ console.error('For other platforms, compile GitLocker from source or download GitHub Release archives.');
41
39
  process.exit(1);
42
40
  }
43
41
 
44
- try {
45
- const packageName = getPlatformPackage();
46
-
47
- // 获取子包中二进制的绝对路径
48
- let packageDir;
42
+ function resolvePackageDir(packageName) {
49
43
  try {
50
- packageDir = path.dirname(require.resolve(`${packageName}/package.json`));
44
+ return path.dirname(require.resolve(`${packageName}/package.json`));
51
45
  } catch (resolveErr) {
52
46
  console.error(`[GitLocker] Error: Platform binary package "${packageName}" is not found.`);
53
- console.error(`This may occur if optional dependencies were skipped during installation.`);
54
- console.error(`Please reinstall with optional dependencies enabled:`);
55
- console.error(` npm install -g gitlocker --include=optional\n`);
47
+ console.error('This may occur if optional dependencies were skipped during installation.');
48
+ console.error('Reinstall with optional dependencies enabled:');
49
+ console.error(' npm install -g gitlocker --include=optional');
56
50
  process.exit(1);
57
51
  }
52
+ }
58
53
 
59
- const isWin = os.platform() === 'win32';
60
- const binaryName = isWin ? 'gitl.exe' : 'gitl';
61
- const binaryPath = path.join(packageDir, binaryName);
54
+ const packageName = getPlatformPackage();
55
+ const packageDir = resolvePackageDir(packageName);
56
+ const binaryName = os.platform() === 'win32' ? 'gitl.exe' : 'gitl';
57
+ const binaryPath = path.join(packageDir, binaryName);
62
58
 
63
- const fs = require('fs');
64
- if (!fs.existsSync(binaryPath)) {
65
- console.error(`[GitLocker] Error: Native binary not found at "${binaryPath}".`);
66
- process.exit(1);
67
- }
59
+ if (!fs.existsSync(binaryPath)) {
60
+ console.error(`[GitLocker] Error: Native binary not found at "${binaryPath}".`);
61
+ console.error('The platform package installed, but gitl was missing from it.');
62
+ console.error('On Windows, Windows Defender may quarantine gitl.exe after npm extract.');
63
+ console.error('Restore the file from quarantine, or reinstall:');
64
+ console.error(' npm uninstall -g gitlocker && npm install -g gitlocker@latest');
65
+ console.error('You can also run the signed GitHub Release archive for your platform.');
66
+ process.exit(1);
67
+ }
68
68
 
69
- // 非 Windows 平台需要赋予执行权限
70
- if (!isWin) {
71
- try {
72
- fs.chmodSync(binaryPath, 0o755);
73
- } catch (e) {
74
- // 忽略可能的权限变更失败
75
- }
69
+ if (os.platform() !== 'win32') {
70
+ try {
71
+ fs.chmodSync(binaryPath, 0o755);
72
+ } catch (chmodErr) {
73
+ // The publish step already marks the Unix binary executable.
76
74
  }
75
+ }
77
76
 
78
- // 透传执行
79
- const args = process.argv.slice(2);
80
- const result = spawnSync(binaryPath, args, {
81
- stdio: 'inherit',
82
- windowsHide: true
83
- });
84
-
85
- process.exit(result.status ?? 0);
86
- } catch (err) {
87
- console.error('[GitLocker] Failed to run native CLI:', err.message);
77
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
78
+ stdio: 'inherit'
79
+ });
80
+
81
+ if (result.error) {
82
+ console.error(`[GitLocker] Failed to start "${binaryPath}": ${result.error.message}`);
83
+ process.exit(1);
84
+ }
85
+ if (result.signal) {
86
+ console.error(`[GitLocker] Native CLI terminated by signal ${result.signal}.`);
88
87
  process.exit(1);
89
88
  }
89
+ process.exit(result.status === null ? 1 : result.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlocker",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Git repository encryption with pluggable key providers for Windows, Linux, and macOS",
5
5
  "homepage": "https://gitbraints.com/products/gitlocker",
6
6
  "repository": {
@@ -43,8 +43,8 @@
43
43
  "author": "GitBraints",
44
44
  "license": "MIT",
45
45
  "optionalDependencies": {
46
- "@git-braints/cli-darwin-arm64": "1.0.6",
47
- "@git-braints/cli-linux-x64": "1.0.6",
48
- "@git-braints/cli-win32-x64": "1.0.6"
46
+ "@git-braints/cli-darwin-arm64": "1.0.7",
47
+ "@git-braints/cli-linux-x64": "1.0.7",
48
+ "@git-braints/cli-win32-x64": "1.0.7"
49
49
  }
50
50
  }