markpdfdown 0.1.3-t01 → 0.1.3-tfour
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/cli.js +37 -1
- package/package.json +11 -3
package/bin/cli.js
CHANGED
|
@@ -14,6 +14,40 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
14
14
|
const __dirname = dirname(__filename);
|
|
15
15
|
const projectRoot = join(__dirname, '..');
|
|
16
16
|
|
|
17
|
+
// 从 package.json 读取 electron 版本要求
|
|
18
|
+
function getElectronVersion() {
|
|
19
|
+
const require = createRequire(import.meta.url);
|
|
20
|
+
const pkg = require('../package.json');
|
|
21
|
+
// 优先从 dependencies 读取,其次从 devDependencies,最后使用默认值
|
|
22
|
+
return pkg.dependencies?.electron
|
|
23
|
+
|| pkg.devDependencies?.electron
|
|
24
|
+
|| pkg.peerDependencies?.electron
|
|
25
|
+
|| '^35.0.0';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 确保 Electron 已安装
|
|
29
|
+
async function ensureElectron() {
|
|
30
|
+
const electronBin = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
|
31
|
+
const electronPath = join(projectRoot, 'node_modules', '.bin', electronBin);
|
|
32
|
+
|
|
33
|
+
if (!existsSync(electronPath)) {
|
|
34
|
+
const electronVersion = getElectronVersion();
|
|
35
|
+
console.log(`📦 Electron not found. Installing electron@${electronVersion}...`);
|
|
36
|
+
try {
|
|
37
|
+
execSync(`npm install electron@"${electronVersion}" --no-save`, {
|
|
38
|
+
cwd: projectRoot,
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
shell: true
|
|
41
|
+
});
|
|
42
|
+
console.log('✅ Electron installed successfully.');
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('❌ Failed to install Electron:', error.message);
|
|
45
|
+
console.error(' Please try manually: npm install electron');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
17
51
|
// 确保 Prisma client 存在
|
|
18
52
|
async function ensurePrismaClient() {
|
|
19
53
|
const prismaClientPath = join(projectRoot, 'node_modules', '.prisma', 'client', 'index.js');
|
|
@@ -54,7 +88,8 @@ function launchElectron(args) {
|
|
|
54
88
|
const mainPath = join(projectRoot, 'dist', 'main', 'index.js');
|
|
55
89
|
|
|
56
90
|
if (!existsSync(mainPath)) {
|
|
57
|
-
console.error('❌ Application not built.
|
|
91
|
+
console.error('❌ Application not built. Main file not found at:', mainPath);
|
|
92
|
+
console.error(' Please run: npm run build');
|
|
58
93
|
process.exit(1);
|
|
59
94
|
}
|
|
60
95
|
|
|
@@ -115,6 +150,7 @@ async function main() {
|
|
|
115
150
|
switch (command) {
|
|
116
151
|
case 'gui':
|
|
117
152
|
case 'start':
|
|
153
|
+
await ensureElectron();
|
|
118
154
|
await ensurePrismaClient();
|
|
119
155
|
launchElectron(args.slice(1));
|
|
120
156
|
break;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markpdfdown",
|
|
3
|
-
"version": "0.1.3-
|
|
3
|
+
"version": "0.1.3-tfour",
|
|
4
4
|
"description": "A high-quality PDF to Markdown tool based on large language model visual recognition.",
|
|
5
5
|
"author": "MarkPDFdown",
|
|
6
6
|
"main": "dist/main/index.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"markpdfdown": "
|
|
8
|
+
"markpdfdown": "bin/cli.js"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"engines": {
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"dependencies": {
|
|
107
107
|
"@ant-design/icons": "^5.6.1",
|
|
108
108
|
"@prisma/client": "^6.5.0",
|
|
109
|
+
"prisma": "^6.5.0",
|
|
109
110
|
"@types/sharp": "^0.31.1",
|
|
110
111
|
"antd": "^5.24.4",
|
|
111
112
|
"electron-is-dev": "^3.0.1",
|
|
@@ -125,6 +126,14 @@
|
|
|
125
126
|
"sharp": "^0.34.1",
|
|
126
127
|
"uuid": "^11.1.0"
|
|
127
128
|
},
|
|
129
|
+
"peerDependencies": {
|
|
130
|
+
"electron": "^35.0.0"
|
|
131
|
+
},
|
|
132
|
+
"peerDependenciesMeta": {
|
|
133
|
+
"electron": {
|
|
134
|
+
"optional": true
|
|
135
|
+
}
|
|
136
|
+
},
|
|
128
137
|
"devDependencies": {
|
|
129
138
|
"@eslint/js": "^9.21.0",
|
|
130
139
|
"@testing-library/jest-dom": "^6.1.5",
|
|
@@ -146,7 +155,6 @@
|
|
|
146
155
|
"husky": "^9.1.7",
|
|
147
156
|
"jsdom": "^25.0.1",
|
|
148
157
|
"nodemon": "^3.1.9",
|
|
149
|
-
"prisma": "^6.5.0",
|
|
150
158
|
"typescript": "~5.7.2",
|
|
151
159
|
"typescript-eslint": "^8.24.1",
|
|
152
160
|
"vite": "^6.2.0",
|