@legna-lnc/legnacode 1.1.8 → 1.1.9
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/CHANGELOG.md +7 -0
- package/README.md +1 -0
- package/npm/bin/legna.cjs +8 -29
- package/npm/postinstall.cjs +82 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to LegnaCode CLI will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.1.8] - 2026-04-03
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **Windows npm 全局安装平台包缺失** — bin wrapper 检测到平台包未安装时自动执行 `npm install -g` 安装对应平台包,不再需要用户手动操作
|
|
10
|
+
- **bin wrapper 路径查找优化** — 修正全局 node_modules 扁平布局下 scope 目录的路径拼接
|
|
11
|
+
|
|
5
12
|
## [1.1.7] - 2026-04-03
|
|
6
13
|
|
|
7
14
|
### Fixed
|
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ LegnaCode 是一个基于 Anthropic Claude 的智能终端编程助手,让你
|
|
|
10
10
|
|
|
11
11
|
| 版本 | 日期 | 摘要 |
|
|
12
12
|
|------|------|------|
|
|
13
|
+
| [1.1.8](./CHANGELOG.md#118---2026-04-03) | 2026-04-03 | bin wrapper 自动安装缺失平台包,修复 Windows npm 全局安装问题 |
|
|
13
14
|
| [1.1.7](./CHANGELOG.md#117---2026-04-03) | 2026-04-03 | 彻底修复 Windows external module 报错,清空 external 列表 |
|
|
14
15
|
| [1.1.6](./CHANGELOG.md#116---2026-04-03) | 2026-04-03 | 修复 Windows external module 报错、全平台发版流程自动化、版本号统一 |
|
|
15
16
|
| [1.1.5](./CHANGELOG.md#115---2026-04-03) | 2026-04-03 | WebUI 管理面板 (`legna admin`)、双目录管理、配置迁移、npm 全平台发布 |
|
package/npm/bin/legna.cjs
CHANGED
|
@@ -28,21 +28,19 @@ if (!pkg) {
|
|
|
28
28
|
var binName = process.platform === "win32" ? "legna.exe" : "bin/legna";
|
|
29
29
|
|
|
30
30
|
function findBin() {
|
|
31
|
-
// Strategy 1: require.resolve
|
|
31
|
+
// Strategy 1: require.resolve
|
|
32
32
|
try {
|
|
33
33
|
var p = path.resolve(require.resolve(pkg + "/package.json"), "..", binName);
|
|
34
34
|
if (fs.existsSync(p)) return p;
|
|
35
35
|
} catch (e) {}
|
|
36
36
|
|
|
37
|
-
// Strategy 2: sibling
|
|
38
|
-
// __dirname = .../node_modules/@legna-lnc/legnacode/npm/bin
|
|
39
|
-
// target = .../node_modules/@legna-lnc/legnacode-<platform>/...
|
|
37
|
+
// Strategy 2: sibling scope dir (global flat layout)
|
|
40
38
|
var scopeDir = path.resolve(__dirname, "..", "..", "..");
|
|
41
|
-
var pkgName = pkg.split("/")[1];
|
|
39
|
+
var pkgName = pkg.split("/")[1];
|
|
42
40
|
var flat = path.resolve(scopeDir, pkgName, binName);
|
|
43
41
|
if (fs.existsSync(flat)) return flat;
|
|
44
42
|
|
|
45
|
-
// Strategy 3: nested node_modules inside our
|
|
43
|
+
// Strategy 3: nested node_modules inside our package (postinstall puts it here)
|
|
46
44
|
var nested = path.resolve(__dirname, "..", "..", "node_modules", pkg, binName);
|
|
47
45
|
if (fs.existsSync(nested)) return nested;
|
|
48
46
|
|
|
@@ -51,31 +49,12 @@ function findBin() {
|
|
|
51
49
|
|
|
52
50
|
var bin = findBin();
|
|
53
51
|
|
|
54
|
-
// Strategy 4: auto-install the platform package if missing
|
|
55
52
|
if (!bin) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
version = ourPkg.version || version;
|
|
60
|
-
} catch (e) {}
|
|
61
|
-
|
|
62
|
-
console.error("legna: platform package " + pkg + " not found, installing...");
|
|
63
|
-
var install = childProcess.spawnSync(
|
|
64
|
-
"npm", ["install", "-g", pkg + "@" + version],
|
|
65
|
-
{ stdio: "inherit", shell: true }
|
|
53
|
+
console.error(
|
|
54
|
+
"legna: platform binary not found.\n" +
|
|
55
|
+
"Run: npm install -g " + pkg + " --registry https://registry.npmjs.org"
|
|
66
56
|
);
|
|
67
|
-
|
|
68
|
-
if (install.status === 0) {
|
|
69
|
-
bin = findBin();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!bin) {
|
|
73
|
-
console.error(
|
|
74
|
-
"legna: could not find or install platform package " + pkg + "\n" +
|
|
75
|
-
"Try manually: npm install -g " + pkg + "@" + version
|
|
76
|
-
);
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
57
|
+
process.exit(1);
|
|
79
58
|
}
|
|
80
59
|
|
|
81
60
|
var result = childProcess.spawnSync(bin, process.argv.slice(2), {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* postinstall: ensure the correct platform binary package is installed.
|
|
6
|
+
* npm's optionalDependencies with os/cpu filters often fails on Windows
|
|
7
|
+
* and with non-standard registries. This script fixes that.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var os = require("os");
|
|
11
|
+
var path = require("path");
|
|
12
|
+
var fs = require("fs");
|
|
13
|
+
var childProcess = require("child_process");
|
|
14
|
+
|
|
15
|
+
var PLATFORMS = {
|
|
16
|
+
"darwin-arm64": "@legna-lnc/legnacode-darwin-arm64",
|
|
17
|
+
"darwin-x64": "@legna-lnc/legnacode-darwin-x64",
|
|
18
|
+
"linux-x64": "@legna-lnc/legnacode-linux-x64",
|
|
19
|
+
"linux-arm64": "@legna-lnc/legnacode-linux-arm64",
|
|
20
|
+
"win32-x64": "@legna-lnc/legnacode-win32-x64",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var key = process.platform + "-" + os.arch();
|
|
24
|
+
var pkg = PLATFORMS[key];
|
|
25
|
+
if (!pkg) process.exit(0); // unsupported platform, skip silently
|
|
26
|
+
|
|
27
|
+
var binName = process.platform === "win32" ? "legna.exe" : "bin/legna";
|
|
28
|
+
|
|
29
|
+
// Check if platform package is already available
|
|
30
|
+
function isInstalled() {
|
|
31
|
+
try {
|
|
32
|
+
var p = path.resolve(require.resolve(pkg + "/package.json"), "..", binName);
|
|
33
|
+
if (fs.existsSync(p)) return true;
|
|
34
|
+
} catch (e) {}
|
|
35
|
+
|
|
36
|
+
// Check sibling in global/local node_modules
|
|
37
|
+
var scopeDir = path.resolve(__dirname, "..", "..");
|
|
38
|
+
var pkgName = pkg.split("/")[1];
|
|
39
|
+
if (fs.existsSync(path.resolve(scopeDir, pkgName, binName))) return true;
|
|
40
|
+
|
|
41
|
+
// Check nested
|
|
42
|
+
var nested = path.resolve(__dirname, "..", "node_modules", pkg, binName);
|
|
43
|
+
if (fs.existsSync(nested)) return true;
|
|
44
|
+
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (isInstalled()) process.exit(0);
|
|
49
|
+
|
|
50
|
+
// Not installed — fetch it from official npm registry
|
|
51
|
+
var version;
|
|
52
|
+
try {
|
|
53
|
+
version = JSON.parse(fs.readFileSync(path.resolve(__dirname, "..", "package.json"), "utf-8")).version;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
version = "latest";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
console.log("Installing platform binary " + pkg + "@" + version + "...");
|
|
59
|
+
|
|
60
|
+
// Use official registry to avoid mirror sync delays
|
|
61
|
+
var result = childProcess.spawnSync(
|
|
62
|
+
"npm",
|
|
63
|
+
["install", "--no-save", pkg + "@" + version, "--registry", "https://registry.npmjs.org"],
|
|
64
|
+
{
|
|
65
|
+
cwd: path.resolve(__dirname, ".."),
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
shell: true,
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (result.status !== 0) {
|
|
72
|
+
// Try global install as fallback
|
|
73
|
+
var result2 = childProcess.spawnSync(
|
|
74
|
+
"npm",
|
|
75
|
+
["install", "-g", pkg + "@" + version, "--registry", "https://registry.npmjs.org"],
|
|
76
|
+
{ stdio: "inherit", shell: true }
|
|
77
|
+
);
|
|
78
|
+
if (result2.status !== 0) {
|
|
79
|
+
console.error("Warning: could not install " + pkg + ". Run manually:");
|
|
80
|
+
console.error(" npm install -g " + pkg + "@" + version + " --registry https://registry.npmjs.org");
|
|
81
|
+
}
|
|
82
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legna-lnc/legnacode",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "LegnaCode — legna.lnc's official CLI for coding assistance",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"anthropic"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
+
"postinstall": "node npm/postinstall.cjs",
|
|
29
30
|
"build": "bun run scripts/build.ts && python3 scripts/postbuild-fix.py",
|
|
30
31
|
"compile": "bun run scripts/compile.ts",
|
|
31
32
|
"compile:all": "bun run scripts/compile-all.ts",
|
|
@@ -141,10 +142,10 @@
|
|
|
141
142
|
"bun": ">=1.2.0"
|
|
142
143
|
},
|
|
143
144
|
"optionalDependencies": {
|
|
144
|
-
"@legna-lnc/legnacode-darwin-arm64": "1.1.
|
|
145
|
-
"@legna-lnc/legnacode-darwin-x64": "1.1.
|
|
146
|
-
"@legna-lnc/legnacode-linux-x64": "1.1.
|
|
147
|
-
"@legna-lnc/legnacode-linux-arm64": "1.1.
|
|
148
|
-
"@legna-lnc/legnacode-win32-x64": "1.1.
|
|
145
|
+
"@legna-lnc/legnacode-darwin-arm64": "1.1.9",
|
|
146
|
+
"@legna-lnc/legnacode-darwin-x64": "1.1.9",
|
|
147
|
+
"@legna-lnc/legnacode-linux-x64": "1.1.9",
|
|
148
|
+
"@legna-lnc/legnacode-linux-arm64": "1.1.9",
|
|
149
|
+
"@legna-lnc/legnacode-win32-x64": "1.1.9"
|
|
149
150
|
}
|
|
150
151
|
}
|