blockmine 1.0.8 → 1.0.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/backend/cli.js +7 -6
- package/package.json +1 -1
package/backend/cli.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
|
|
2
4
|
const fs = require('fs');
|
|
3
5
|
const os = require('os');
|
|
@@ -5,7 +7,6 @@ const path = require('path');
|
|
|
5
7
|
const { execSync } = require('child_process');
|
|
6
8
|
const { startServer } = require('./src/server.js');
|
|
7
9
|
|
|
8
|
-
|
|
9
10
|
const DATA_DIR = path.join(os.homedir(), '.blockmine');
|
|
10
11
|
if (!fs.existsSync(DATA_DIR)) {
|
|
11
12
|
console.log(`[BlockMine] Создание папки для данных: ${DATA_DIR}`);
|
|
@@ -13,14 +14,13 @@ if (!fs.existsSync(DATA_DIR)) {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
process.env.DATABASE_URL = `file:${path.join(DATA_DIR, 'blockmine.db')}`;
|
|
16
|
-
|
|
17
17
|
const prismaSchemaPath = path.join(__dirname, 'prisma', 'schema.prisma');
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
function runCommand(command) {
|
|
21
20
|
try {
|
|
22
21
|
console.log(`> ${command}`);
|
|
23
|
-
|
|
22
|
+
const shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';
|
|
23
|
+
execSync(command, { stdio: 'inherit', cwd: __dirname, shell: shell });
|
|
24
24
|
} catch (e) {
|
|
25
25
|
console.error(`Команда "${command}" не удалась:`, e);
|
|
26
26
|
process.exit(1);
|
|
@@ -31,8 +31,9 @@ async function main() {
|
|
|
31
31
|
console.log('Запуск панели управления BlockMine...');
|
|
32
32
|
console.log(`[BlockMine] Хранилище данных: ${DATA_DIR}`);
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const dbPath = path.join(DATA_DIR, 'blockmine.db');
|
|
35
|
+
|
|
36
|
+
if (!fs.existsSync(dbPath)) {
|
|
36
37
|
console.log('База данных не найдена. Создаем и применяем все миграции...');
|
|
37
38
|
runCommand(`npx prisma migrate deploy --schema=${prismaSchemaPath}`);
|
|
38
39
|
console.log('Первоначальная настройка базы данных завершена.');
|