gitlocker 1.0.0 → 1.0.1

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/bin/gitlocker.js CHANGED
@@ -17,20 +17,54 @@ function getPlatformPackage() {
17
17
  }
18
18
  }
19
19
 
20
+ if (platform === 'linux') {
21
+ if (arch === 'x64') {
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
+ }
27
+ }
28
+
20
29
  console.error(`[GitLocker] Unsupported platform: ${platform}.`);
21
- console.error(`GitLocker npm distribution currently only supports Windows (win32-x64) in this build.`);
30
+ console.error(`GitLocker npm distribution currently only supports Windows (win32-x64) and Linux (linux-x64) in this build.`);
22
31
  console.error(`For other platforms, please compile GitLocker from source or download from GitHub Releases.`);
23
32
  process.exit(1);
24
33
  }
25
34
 
26
- try {
27
35
  const packageName = getPlatformPackage();
28
36
 
29
37
  // 获取子包中二进制的绝对路径
30
- const packageDir = path.dirname(require.resolve(`${packageName}/package.json`));
31
- const binaryName = 'gitl.exe';
38
+ let packageDir;
39
+ try {
40
+ packageDir = path.dirname(require.resolve(`${packageName}/package.json`));
41
+ } catch (resolveErr) {
42
+ console.error(`[GitLocker] Error: Platform binary package "${packageName}" is not found.`);
43
+ console.error(`This may occur if optional dependencies were skipped during installation.`);
44
+ console.error(`Please reinstall with optional dependencies enabled:`);
45
+ console.error(` npm install -g gitlocker --include=optional\n`);
46
+ process.exit(1);
47
+ }
48
+
49
+ const isWin = os.platform() === 'win32';
50
+ const binaryName = isWin ? 'gitl.exe' : 'gitl';
32
51
  const binaryPath = path.join(packageDir, binaryName);
33
52
 
53
+ const fs = require('fs');
54
+ if (!fs.existsSync(binaryPath)) {
55
+ console.error(`[GitLocker] Error: Native binary not found at "${binaryPath}".`);
56
+ process.exit(1);
57
+ }
58
+
59
+ // 非 Windows 平台需要赋予执行权限
60
+ if (!isWin) {
61
+ try {
62
+ fs.chmodSync(binaryPath, '755');
63
+ } catch (e) {
64
+ // 忽略可能的权限变更失败
65
+ }
66
+ }
67
+
34
68
  // 透传执行
35
69
  const args = process.argv.slice(2);
36
70
  const result = spawnSync(binaryPath, args, {
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "gitlocker",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Git repository encryption with pluggable key providers",
5
5
  "main": "bin/gitlocker.js",
6
6
  "bin": {
7
- "gitlocker": "./bin/gitlocker.js",
8
- "gitl": "./bin/gitlocker.js"
7
+ "gitlocker": "bin/gitlocker.js",
8
+ "gitl": "bin/gitlocker.js"
9
9
  },
10
10
  "files": [
11
11
  "bin/",
12
- "README.md"
12
+ "README.md",
13
+ "LICENSE",
14
+ "THIRD_PARTY_NOTICES.md"
13
15
  ],
14
16
  "engines": {
15
17
  "node": ">=16.0.0"
@@ -22,8 +24,9 @@
22
24
  "gitlocker"
23
25
  ],
24
26
  "author": "GitBraints",
25
- "license": "AGPL-3.0-only",
27
+ "license": "AGPL-3.0-or-later",
26
28
  "optionalDependencies": {
27
- "@git-braints/cli-win32-x64": "1.0.0"
29
+ "@git-braints/cli-linux-x64": "1.0.1",
30
+ "@git-braints/cli-win32-x64": "1.0.1"
28
31
  }
29
32
  }