Skip to content

Commit 30224e1

Browse files
committed
fix(cli): 🐛 improve npx execution reliability (#3)
1 parent 6481afd commit 30224e1

8 files changed

Lines changed: 47 additions & 21 deletions

File tree

README.ar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
التشغيل مباشرة باستخدام npx (يتطلب Node.js 18+):
2929

3030
```bash
31-
npx markpdfdown
31+
npx -y markpdfdown
3232
```
3333

3434
### تحميل المثبت
3535

36-
قم بتحميل أحدث إصدار لمنصتك من صفحة [Releases](https://github.com/MarkPDFdown/desktop/releases):
36+
قم بتحميل أحدث إصدار لمنصتك من صفحة [Releases](https://github.com/MarkPDFdown/markpdfdown-desktop/releases):
3737

3838
- **Windows**: `MarkPDFdown-{version}-x64.exe`
3939
- **macOS**: `MarkPDFdown-{version}-arm64.dmg` / `MarkPDFdown-{version}-x64.dmg`

README.fa.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
اجرای مستقیم با npx (نیاز به Node.js 18+):
2929

3030
```bash
31-
npx markpdfdown
31+
npx -y markpdfdown
3232
```
3333

3434
### دانلود نصب‌کننده
3535

36-
آخرین نسخه را برای پلتفرم خود از صفحه [Releases](https://github.com/MarkPDFdown/desktop/releases) دانلود کنید:
36+
آخرین نسخه را برای پلتفرم خود از صفحه [Releases](https://github.com/MarkPDFdown/markpdfdown-desktop/releases) دانلود کنید:
3737

3838
- **Windows**: `MarkPDFdown-{version}-x64.exe`
3939
- **macOS**: `MarkPDFdown-{version}-arm64.dmg` / `MarkPDFdown-{version}-x64.dmg`

README.ja.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
npxで直接実行(Node.js 18+が必要):
2727

2828
```bash
29-
npx markpdfdown
29+
npx -y markpdfdown
3030
```
3131

3232
### インストーラーのダウンロード
3333

34-
[Releases](https://github.com/MarkPDFdown/desktop/releases)ページからお使いのプラットフォーム用の最新版をダウンロードしてください:
34+
[Releases](https://github.com/MarkPDFdown/markpdfdown-desktop/releases)ページからお使いのプラットフォーム用の最新版をダウンロードしてください:
3535

3636
- **Windows**`MarkPDFdown-{version}-x64.exe`
3737
- **macOS**`MarkPDFdown-{version}-arm64.dmg` / `MarkPDFdown-{version}-x64.dmg`

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ A desktop application that converts PDF documents to Markdown format using Large
2626
Run directly with npx (requires Node.js 18+):
2727

2828
```bash
29-
npx markpdfdown
29+
npx -y markpdfdown
3030
```
3131

3232
### Download Installer
3333

34-
Download the latest release for your platform from the [Releases](https://github.com/MarkPDFdown/desktop/releases) page:
34+
Download the latest release for your platform from the [Releases](https://github.com/MarkPDFdown/markpdfdown-desktop/releases) page:
3535

3636
- **Windows**: `MarkPDFdown-{version}-x64.exe`
3737
- **macOS**: `MarkPDFdown-{version}-arm64.dmg` / `MarkPDFdown-{version}-x64.dmg`

README.ru.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
Запуск напрямую через npx (требуется Node.js 18+):
2727

2828
```bash
29-
npx markpdfdown
29+
npx -y markpdfdown
3030
```
3131

3232
### Скачать установщик
3333

34-
Скачайте последнюю версию для вашей платформы со страницы [Releases](https://github.com/MarkPDFdown/desktop/releases):
34+
Скачайте последнюю версию для вашей платформы со страницы [Releases](https://github.com/MarkPDFdown/markpdfdown-desktop/releases):
3535

3636
- **Windows**: `MarkPDFdown-{version}-x64.exe`
3737
- **macOS**: `MarkPDFdown-{version}-arm64.dmg` / `MarkPDFdown-{version}-x64.dmg`

README.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
使用 npx 直接运行(需要 Node.js 18+):
2727

2828
```bash
29-
npx markpdfdown
29+
npx -y markpdfdown
3030
```
3131

3232
### 下载安装包
3333

34-
[Releases](https://github.com/MarkPDFdown/desktop/releases) 页面下载适合您平台的最新版本:
34+
[Releases](https://github.com/MarkPDFdown/markpdfdown-desktop/releases) 页面下载适合您平台的最新版本:
3535

3636
- **Windows**`MarkPDFdown-{version}-x64.exe`
3737
- **macOS**`MarkPDFdown-{version}-arm64.dmg` / `MarkPDFdown-{version}-x64.dmg`

bin/cli.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,23 @@ async function ensurePrismaClient() {
2121
if (!existsSync(prismaClientPath)) {
2222
console.log('🔧 Prisma client not found. Generating...');
2323
try {
24-
execSync('npx prisma generate --schema=./src/core/infrastructure/db/schema.prisma', {
24+
// 使用项目本地的 prisma CLI
25+
const prismaBin = process.platform === 'win32' ? 'prisma.cmd' : 'prisma';
26+
const prismaPath = join(projectRoot, 'node_modules', '.bin', prismaBin);
27+
const prismaCmd = existsSync(prismaPath)
28+
? `"${prismaPath}"`
29+
: 'npx prisma';
30+
31+
// 设置临时的 DATABASE_URL,prisma generate 需要此变量存在
32+
// 实际的数据库路径在运行时由 db/index.ts 动态决定
33+
execSync(`${prismaCmd} generate --schema=./src/core/infrastructure/db/schema.prisma`, {
2534
cwd: projectRoot,
26-
stdio: 'inherit'
35+
stdio: 'inherit',
36+
shell: true,
37+
env: {
38+
...process.env,
39+
DATABASE_URL: 'file:./placeholder.db'
40+
}
2741
});
2842
console.log('✅ Prisma client generated successfully.');
2943
} catch (error) {
@@ -33,14 +47,26 @@ async function ensurePrismaClient() {
3347
}
3448
}
3549

50+
// 获取 Electron 可执行文件路径
51+
function getElectronPath() {
52+
const require = createRequire(import.meta.url);
53+
try {
54+
// 使用 electron 包导出的路径(最可靠的方式)
55+
return require('electron');
56+
} catch (e) {
57+
console.error('❌ Electron not found. Please ensure the package is installed correctly.');
58+
process.exit(1);
59+
}
60+
}
61+
3662
// 启动 Electron
3763
function launchElectron(args) {
38-
const electronBin = process.platform === 'win32' ? 'electron.cmd' : 'electron';
39-
const electronPath = join(projectRoot, 'node_modules', '.bin', electronBin);
64+
const electronPath = getElectronPath();
4065
const mainPath = join(projectRoot, 'dist', 'main', 'index.js');
4166

4267
if (!existsSync(mainPath)) {
43-
console.error('❌ Application not built. Please run: npm run build');
68+
console.error('❌ Application not built. Main file not found at:', mainPath);
69+
console.error(' Please run: npm run build');
4470
process.exit(1);
4571
}
4672

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "markpdfdown",
3-
"version": "0.1.3",
3+
"version": "0.1.3-tfive",
44
"description": "A high-quality PDF to Markdown tool based on large language model visual recognition.",
55
"author": "MarkPDFdown",
66
"main": "dist/main/index.js",
77
"bin": {
8-
"markpdfdown": "./bin/cli.js"
8+
"markpdfdown": "bin/cli.js"
99
},
1010
"type": "module",
1111
"engines": {
@@ -106,6 +106,8 @@
106106
"dependencies": {
107107
"@ant-design/icons": "^5.6.1",
108108
"@prisma/client": "^6.5.0",
109+
"prisma": "^6.5.0",
110+
"electron": "^35.0.2",
109111
"@types/sharp": "^0.31.1",
110112
"antd": "^5.24.4",
111113
"electron-is-dev": "^3.0.1",
@@ -135,7 +137,6 @@
135137
"@vitejs/plugin-react": "^4.3.4",
136138
"@vitest/coverage-v8": "^2.1.8",
137139
"concurrently": "^9.1.2",
138-
"electron": "^35.0.2",
139140
"electron-builder": "^25.1.8",
140141
"electron-icon-builder": "^2.0.1",
141142
"electron-vite": "^3.1.0",
@@ -146,7 +147,6 @@
146147
"husky": "^9.1.7",
147148
"jsdom": "^25.0.1",
148149
"nodemon": "^3.1.9",
149-
"prisma": "^6.5.0",
150150
"typescript": "~5.7.2",
151151
"typescript-eslint": "^8.24.1",
152152
"vite": "^6.2.0",

0 commit comments

Comments
 (0)