ones-fetch 1.4.2 → 1.4.4
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 +3 -3
- package/bin/cli.js +36 -0
- package/bin/install.mjs +8 -33
- package/package.json +3 -4
- package/CHANGELOG.md +0 -21
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
策划电脑上已有 Node.js,执行一条命令即可:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npx ones-fetch
|
|
10
|
+
npx ones-fetch@latest
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
或者使用 npm 安装:
|
|
@@ -60,7 +60,7 @@ npm start
|
|
|
60
60
|
npm run dev
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
启动后会自动打开浏览器访问 `http://localhost:
|
|
63
|
+
启动后会自动打开浏览器访问 `http://localhost:36781`。
|
|
64
64
|
|
|
65
65
|
### 使用流程
|
|
66
66
|
|
|
@@ -132,7 +132,7 @@ npm run dev
|
|
|
132
132
|
|
|
133
133
|
| 变量 | 说明 |
|
|
134
134
|
|---|---|
|
|
135
|
-
| `PORT` | 服务端口(默认
|
|
135
|
+
| `PORT` | 服务端口(默认 36781) |
|
|
136
136
|
| `ONES_BASE_URL` | ONES 基础 URL |
|
|
137
137
|
| `ONES_TEAM_ID` | 团队 UUID(通常自动检测) |
|
|
138
138
|
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const command = process.argv[2] || '';
|
|
4
|
+
|
|
5
|
+
function printHelp() {
|
|
6
|
+
console.log('ONES Fetch\n');
|
|
7
|
+
console.log('用法:');
|
|
8
|
+
console.log(' ones-fetch 一次性启动工具');
|
|
9
|
+
console.log(' ones-fetch install 安装到本地并创建桌面快捷方式');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
if (command === 'install') {
|
|
14
|
+
const { runInstallFlow } = await import('./install.mjs');
|
|
15
|
+
await runInstallFlow();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (command === '--help' || command === '-h' || command === 'help') {
|
|
20
|
+
printHelp();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (command) {
|
|
25
|
+
console.error(`不支持的命令: ${command}`);
|
|
26
|
+
printHelp();
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await import('../src/server.mjs');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main().catch((error) => {
|
|
34
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
package/bin/install.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { homedir, platform } from 'node:os';
|
|
6
6
|
import { writeFile, mkdir, cp, access, rm, readFile } from 'node:fs/promises';
|
|
@@ -155,39 +155,9 @@ Categories=Utility;
|
|
|
155
155
|
console.log(`✓ 桌面快捷方式已创建: ${desktopFile}`);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
async function
|
|
159
|
-
// 检测是否是通过 npx 或 postinstall 运行
|
|
160
|
-
const isPostInstall = process.env.npm_lifecycle_event === 'postinstall';
|
|
161
|
-
|
|
162
|
-
// 确保安装目录存在
|
|
158
|
+
export async function runInstallFlow() {
|
|
163
159
|
await ensureInstallDir();
|
|
164
160
|
|
|
165
|
-
if (isPostInstall) {
|
|
166
|
-
// postinstall 时只创建快捷方式,不安装依赖
|
|
167
|
-
console.log('ONES Fetch 安装后配置\n');
|
|
168
|
-
console.log('正在创建桌面快捷方式...');
|
|
169
|
-
try {
|
|
170
|
-
const os = platform();
|
|
171
|
-
if (os === 'win32') {
|
|
172
|
-
await createWindowsShortcut();
|
|
173
|
-
} else if (os === 'darwin') {
|
|
174
|
-
await createMacShortcut();
|
|
175
|
-
} else {
|
|
176
|
-
await createLinuxShortcut();
|
|
177
|
-
}
|
|
178
|
-
} catch (err) {
|
|
179
|
-
console.error('✗ 快捷方式创建失败:', err.message);
|
|
180
|
-
// 不退出,允许安装继续
|
|
181
|
-
}
|
|
182
|
-
console.log('\n✓ 配置完成!');
|
|
183
|
-
console.log('\n使用方法:');
|
|
184
|
-
console.log(' 1. 双击桌面上的 "ONES 采集工具" 图标');
|
|
185
|
-
console.log(' 2. 浏览器会自动打开工具页面');
|
|
186
|
-
console.log(`\n项目位置:${installDir}`);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// npx 运行时的完整安装流程
|
|
191
161
|
console.log('ONES Fetch 安装程序\n');
|
|
192
162
|
|
|
193
163
|
// 安装依赖
|
|
@@ -223,4 +193,9 @@ async function main() {
|
|
|
223
193
|
console.log(`\n项目位置:${installDir}`);
|
|
224
194
|
}
|
|
225
195
|
|
|
226
|
-
|
|
196
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
197
|
+
runInstallFlow().catch((error) => {
|
|
198
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
199
|
+
process.exit(1);
|
|
200
|
+
});
|
|
201
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ones-fetch",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ONES Fetch — Web app for recursive ONES subtask crawling",
|
|
6
6
|
"bin": {
|
|
7
|
-
"ones-fetch": "./bin/
|
|
7
|
+
"ones-fetch": "./bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node src/server.mjs",
|
|
11
|
-
"dev": "node --watch src/server.mjs"
|
|
12
|
-
"postinstall": "node bin/install.mjs"
|
|
11
|
+
"dev": "node --watch src/server.mjs"
|
|
13
12
|
},
|
|
14
13
|
"dependencies": {
|
|
15
14
|
"playwright-core": "^1.58.2"
|
package/CHANGELOG.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# 更新日志
|
|
2
|
-
|
|
3
|
-
## [1.5.0] - 2024-04-03
|
|
4
|
-
|
|
5
|
-
### 新增
|
|
6
|
-
- 页面加载时自动检测认证状态,无凭据时自动显示"连接 ONES"按钮
|
|
7
|
-
- 安装新版本时自动清理旧文件,同时保留用户凭据和依赖包
|
|
8
|
-
|
|
9
|
-
### 修复
|
|
10
|
-
- 修复使用 playwright-core 后无法打开登录窗口的问题(现使用系统 Edge 浏览器)
|
|
11
|
-
- 修复 Windows 下 `start` 命令无法正确处理 URL 特殊字符的问题
|
|
12
|
-
- 修复前端"Assignment to constant variable"错误
|
|
13
|
-
- 修复解析按钮在无凭据时未置灰的问题
|
|
14
|
-
|
|
15
|
-
### 优化
|
|
16
|
-
- 复制按钮固定宽度,避免文字变化时按钮大小改变
|
|
17
|
-
- 默认只解析任务编号(#数字格式),不再解析 URL 中的 UUID
|
|
18
|
-
- 改进错误提示信息,提供更清晰的浏览器安装指引
|
|
19
|
-
|
|
20
|
-
## [1.4.1] - 之前版本
|
|
21
|
-
- 基础功能实现
|