museflow-cli 0.0.0-stage → 0.1.2
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 +50 -3
- package/bin/muse.js +100 -0
- package/muse.exe +0 -0
- package/package.json +25 -6
package/README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# museflow-cli
|
|
2
|
+
|
|
3
|
+
MuseFlow 命令行客户端的 npm 分发包包装器。
|
|
4
|
+
|
|
5
|
+
## 安装指南(面向设计师)
|
|
6
|
+
|
|
7
|
+
设计师电脑只需安装有 Node.js(v14 及以上)。在终端中全局安装即可:
|
|
8
|
+
|
|
9
|
+
### 1. 本地安装(开发或内网共享时)
|
|
10
|
+
|
|
11
|
+
在安装前,请确保已将编译好的二进制文件放入 `npm` 目录:
|
|
12
|
+
- Windows: `npm/muse.exe`
|
|
13
|
+
- macOS / Linux: `npm/muse`
|
|
14
|
+
|
|
15
|
+
然后在 `npm` 目录下执行全局安装:
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g .
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
安装完成后,在终端直接输入命令即可使用:
|
|
21
|
+
```bash
|
|
22
|
+
muse --help
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 2. 从 npm 仓库安装(发布后)
|
|
26
|
+
|
|
27
|
+
当包发布到 npm 仓库后,设计师只需在终端运行:
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g museflow-cli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
即可全局使用 `muse` 命令。
|
|
33
|
+
|
|
34
|
+
## 二进制构建说明
|
|
35
|
+
|
|
36
|
+
本 npm 包为轻量启动器,不包含 Rust 编译过程(npm install 时不会编译 Rust)。
|
|
37
|
+
构建与准备二进制:
|
|
38
|
+
1. 在仓库根目录运行:
|
|
39
|
+
```bash
|
|
40
|
+
cargo build --release
|
|
41
|
+
```
|
|
42
|
+
2. 将输出复制到本目录:
|
|
43
|
+
- Windows:
|
|
44
|
+
```cmd
|
|
45
|
+
copy target\release\muse.exe npm\
|
|
46
|
+
```
|
|
47
|
+
- macOS / Linux:
|
|
48
|
+
```bash
|
|
49
|
+
cp target/release/muse npm/
|
|
50
|
+
```
|
package/bin/muse.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
|
+
|
|
9
|
+
const isWindows = process.platform === 'win32';
|
|
10
|
+
const expectedBinaryName = isWindows ? 'muse.exe' : 'muse';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 寻找可执行文件。
|
|
14
|
+
* 优先级:
|
|
15
|
+
* 1. 同目录下 (即本脚本所在目录)
|
|
16
|
+
* 2. npm 包根目录 (即 bin 的上一级)
|
|
17
|
+
* 3. bin 子目录
|
|
18
|
+
*/
|
|
19
|
+
function findBinary() {
|
|
20
|
+
const candidateNames = isWindows
|
|
21
|
+
? ['muse.exe', 'muse.cmd', 'muse.bat']
|
|
22
|
+
: ['muse'];
|
|
23
|
+
|
|
24
|
+
const candidateDirs = [
|
|
25
|
+
__dirname,
|
|
26
|
+
path.join(__dirname, '..'),
|
|
27
|
+
path.join(__dirname, 'bin'),
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
for (const name of candidateNames) {
|
|
31
|
+
for (const dir of candidateDirs) {
|
|
32
|
+
const candidatePath = path.resolve(dir, name);
|
|
33
|
+
if (fs.existsSync(candidatePath)) {
|
|
34
|
+
try {
|
|
35
|
+
const stat = fs.statSync(candidatePath);
|
|
36
|
+
if (stat.isFile()) {
|
|
37
|
+
return {
|
|
38
|
+
path: candidatePath,
|
|
39
|
+
isScript: isWindows && (name.endsWith('.cmd') || name.endsWith('.bat')),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
// 忽略并继续查找
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const resolved = findBinary();
|
|
53
|
+
|
|
54
|
+
if (!resolved) {
|
|
55
|
+
console.error(`[muse] 错误: 未能在 npm 包中找到可执行文件 "${expectedBinaryName}"。`);
|
|
56
|
+
console.error('');
|
|
57
|
+
console.error('请先在仓库根目录执行以下命令编译 Rust 二进制文件:');
|
|
58
|
+
console.error(' cargo build --release');
|
|
59
|
+
console.error('');
|
|
60
|
+
console.error(`然后将 target/release/ 目录中的 ${expectedBinaryName} 复制到 npm 目录:`);
|
|
61
|
+
if (isWindows) {
|
|
62
|
+
console.error(' copy target\\release\\muse.exe npm\\');
|
|
63
|
+
} else {
|
|
64
|
+
console.error(' cp target/release/muse npm/');
|
|
65
|
+
}
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// POSIX 系统确保可执行权限
|
|
70
|
+
if (!isWindows) {
|
|
71
|
+
try {
|
|
72
|
+
fs.accessSync(resolved.path, fs.constants.X_OK);
|
|
73
|
+
} catch {
|
|
74
|
+
try {
|
|
75
|
+
fs.chmodSync(resolved.path, 0o755);
|
|
76
|
+
} catch {
|
|
77
|
+
// 忽略 chmod 失败,spawn 自行报错
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 转发命令行参数、stdio 与退出码
|
|
83
|
+
const child = spawn(resolved.path, process.argv.slice(2), {
|
|
84
|
+
stdio: 'inherit',
|
|
85
|
+
shell: resolved.isScript,
|
|
86
|
+
windowsHide: false,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
child.on('error', (err) => {
|
|
90
|
+
console.error(`[muse] 执行失败: ${err.message}`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
child.on('exit', (code, signal) => {
|
|
95
|
+
if (signal) {
|
|
96
|
+
process.kill(process.pid, signal);
|
|
97
|
+
} else {
|
|
98
|
+
process.exit(code ?? 0);
|
|
99
|
+
}
|
|
100
|
+
});
|
package/muse.exe
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "museflow-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "museflow-cli",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "CLI launcher for MuseFlow",
|
|
5
|
+
"bin": {
|
|
6
|
+
"muse": "bin/muse.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"muse.exe",
|
|
11
|
+
"muse",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "node test.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"museflow",
|
|
19
|
+
"cli"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=14.0.0"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT"
|
|
25
|
+
}
|