@shumai-one/shumai 0.0.4 → 0.0.5
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/shumai.js +86 -15
- package/package.json +9 -8
- package/prisma.config.ts +11 -0
package/bin/shumai.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawn } from 'node:child_process'
|
|
3
3
|
import { join, dirname } from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
|
-
import { existsSync } from 'node:fs'
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
6
6
|
|
|
7
7
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
8
8
|
const platform = process.platform
|
|
@@ -54,19 +54,90 @@ if (!binaryPath) {
|
|
|
54
54
|
|
|
55
55
|
const appJsPath = join(__dirname, 'shumai-app.js')
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
57
|
+
function startApp() {
|
|
58
|
+
const child = spawn(binaryPath, ['run', appJsPath, ...process.argv.slice(2)], {
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
env: {
|
|
61
|
+
...process.env,
|
|
62
|
+
BUN_BE_BUN: '1',
|
|
63
|
+
},
|
|
64
|
+
})
|
|
64
65
|
|
|
65
|
-
child.on('close', (code) => {
|
|
66
|
-
|
|
67
|
-
})
|
|
66
|
+
child.on('close', (code) => {
|
|
67
|
+
process.exit(code ?? 0)
|
|
68
|
+
})
|
|
68
69
|
|
|
69
|
-
child.on('error', (err) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
70
|
+
child.on('error', (err) => {
|
|
71
|
+
console.error(`Failed to start child process:`, err)
|
|
72
|
+
process.exit(1)
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Simple .env parser to load env files from process.cwd()
|
|
77
|
+
function loadEnv() {
|
|
78
|
+
const envFiles = ['.env.production.local', '.env.local', '.env.production', '.env']
|
|
79
|
+
for (const file of envFiles) {
|
|
80
|
+
const envPath = join(process.cwd(), file)
|
|
81
|
+
if (existsSync(envPath)) {
|
|
82
|
+
try {
|
|
83
|
+
const content = readFileSync(envPath, 'utf8')
|
|
84
|
+
const lines = content.split(/\r?\n/)
|
|
85
|
+
for (const line of lines) {
|
|
86
|
+
const trimmed = line.trim()
|
|
87
|
+
if (!trimmed || trimmed.startsWith('#')) continue
|
|
88
|
+
const match = trimmed.match(/^([^=]+)=(.*)$/)
|
|
89
|
+
if (match) {
|
|
90
|
+
const key = match[1].trim()
|
|
91
|
+
let value = match[2].trim()
|
|
92
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
93
|
+
value = value.substring(1, value.length - 1)
|
|
94
|
+
}
|
|
95
|
+
if (process.env[key] === undefined) {
|
|
96
|
+
process.env[key] = value
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
console.error('⚠️ [shumai] Error reading env file:', err)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Load env files on startup
|
|
108
|
+
loadEnv()
|
|
109
|
+
|
|
110
|
+
console.log(`ℹ️ [shumai] Running from CWD: ${process.cwd()}`)
|
|
111
|
+
console.log(`ℹ️ [shumai] DATABASE_URL is: ${process.env.DATABASE_URL ? '(defined)' : '(undefined)'}`)
|
|
112
|
+
|
|
113
|
+
const prismaSchemaPath = join(__dirname, '..', 'prisma', 'schema.prisma')
|
|
114
|
+
if (existsSync(prismaSchemaPath)) {
|
|
115
|
+
console.log('🔄 Running database migrations...')
|
|
116
|
+
const migrationProcess = spawn(
|
|
117
|
+
binaryPath,
|
|
118
|
+
['run', 'prisma', 'migrate', 'deploy', '--schema', './prisma/schema.prisma'],
|
|
119
|
+
{
|
|
120
|
+
stdio: 'inherit',
|
|
121
|
+
cwd: join(__dirname, '..'),
|
|
122
|
+
env: {
|
|
123
|
+
...process.env,
|
|
124
|
+
BUN_BE_BUN: '1',
|
|
125
|
+
},
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
migrationProcess.on('close', (code) => {
|
|
130
|
+
if (code !== 0) {
|
|
131
|
+
console.error(`❌ Database migration failed with code ${code}. Exiting.`)
|
|
132
|
+
process.exit(code ?? 1)
|
|
133
|
+
}
|
|
134
|
+
startApp()
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
migrationProcess.on('error', (err) => {
|
|
138
|
+
console.error('❌ Failed to run database migrations:', err)
|
|
139
|
+
process.exit(1)
|
|
140
|
+
})
|
|
141
|
+
} else {
|
|
142
|
+
startApp()
|
|
143
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shumai-one/shumai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A fullstack AI-powered media workspace and workflow engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin",
|
|
11
|
-
"prisma"
|
|
11
|
+
"prisma",
|
|
12
|
+
"prisma.config.ts"
|
|
12
13
|
],
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"@prisma/client": "7.8.0",
|
|
@@ -24,12 +25,12 @@
|
|
|
24
25
|
"prisma": "7.8.0"
|
|
25
26
|
},
|
|
26
27
|
"optionalDependencies": {
|
|
27
|
-
"@shumai-one/shumai-darwin-arm64": "0.0.
|
|
28
|
-
"@shumai-one/shumai-darwin-x64": "0.0.
|
|
29
|
-
"@shumai-one/shumai-linux-arm64": "0.0.
|
|
30
|
-
"@shumai-one/shumai-linux-x64": "0.0.
|
|
31
|
-
"@shumai-one/shumai-win32-arm64": "0.0.
|
|
32
|
-
"@shumai-one/shumai-win32-x64": "0.0.
|
|
28
|
+
"@shumai-one/shumai-darwin-arm64": "0.0.5",
|
|
29
|
+
"@shumai-one/shumai-darwin-x64": "0.0.5",
|
|
30
|
+
"@shumai-one/shumai-linux-arm64": "0.0.5",
|
|
31
|
+
"@shumai-one/shumai-linux-x64": "0.0.5",
|
|
32
|
+
"@shumai-one/shumai-win32-arm64": "0.0.5",
|
|
33
|
+
"@shumai-one/shumai-win32-x64": "0.0.5"
|
|
33
34
|
},
|
|
34
35
|
"repository": {
|
|
35
36
|
"type": "git",
|