@haenah/u1z 0.1.3 → 0.1.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/package.json
CHANGED
|
@@ -80,7 +80,7 @@ async function checks(): Promise<CheckResult[]> {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
// 8. 설정 파일 필수 변수
|
|
83
|
-
const configPath = join(home, ".config", "u1z"
|
|
83
|
+
const configPath = join(home, ".config", "u1z");
|
|
84
84
|
const requiredVars = [
|
|
85
85
|
"DISCORD_BOT_TOKEN",
|
|
86
86
|
"OPENAI_API_KEY",
|
|
@@ -99,7 +99,7 @@ async function checks(): Promise<CheckResult[]> {
|
|
|
99
99
|
results.push({
|
|
100
100
|
label: "설정 파일 필수 변수",
|
|
101
101
|
ok: missingVars.length === 0,
|
|
102
|
-
hint: missingVars.length > 0 ? `누락: ${missingVars.join(", ")}
|
|
102
|
+
hint: missingVars.length > 0 ? `누락: ${missingVars.join(", ")} (~/.config/u1z)` : undefined,
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
// 9. systemd u1z.service 등록 여부
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
4
|
import { c } from "../utils/color";
|
|
5
|
-
import { ask
|
|
5
|
+
import { ask } from "../utils/prompt";
|
|
6
6
|
|
|
7
7
|
async function run(args: string[]): Promise<void> {
|
|
8
8
|
const proc = Bun.spawn(args, { stdout: "inherit", stderr: "inherit" });
|
|
@@ -59,39 +59,36 @@ export async function init(): Promise<void> {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// 3. 설정 파일
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
const configPath = join(homedir(), ".config", "u1z");
|
|
63
|
+
if (existsSync(configPath)) {
|
|
64
|
+
console.log(`\n${c.bold("▶ 설정 파일 생성 (~/.config/u1z)")}`);
|
|
65
|
+
console.log(c.dim(" 기존 설정 파일 유지 (u1z doctor로 상태 확인)"));
|
|
66
|
+
} else {
|
|
67
|
+
await step("설정 파일 생성 (~/.config/u1z)", async () => {
|
|
68
|
+
ensureDir(join(homedir(), ".config"));
|
|
69
|
+
|
|
70
|
+
const vars: Record<string, string> = {};
|
|
71
|
+
for (const key of [
|
|
72
|
+
"DISCORD_BOT_TOKEN",
|
|
73
|
+
"OPENAI_API_KEY",
|
|
74
|
+
"GOOGLE_GENERATIVE_AI_API_KEY",
|
|
75
|
+
"TAVILY_API_KEY",
|
|
76
|
+
]) {
|
|
77
|
+
vars[key] = await ask(key);
|
|
78
|
+
if (!vars[key]) {
|
|
79
|
+
throw new Error(`${key}는 필수 항목입니다.`);
|
|
80
|
+
}
|
|
71
81
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!vars[key]) {
|
|
83
|
-
throw new Error(`${key}는 필수 항목입니다.`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
vars.U1Z_HOME = u1zHome;
|
|
87
|
-
vars.PORT = (await ask("PORT", "3000")) || "3000";
|
|
88
|
-
|
|
89
|
-
const content = Object.entries(vars)
|
|
90
|
-
.map(([k, v]) => `${k}="${v.replace(/"/g, '\\"')}"`)
|
|
91
|
-
.join("\n");
|
|
92
|
-
writeFileSync(configPath, `${content}\n`, "utf-8");
|
|
93
|
-
console.log(c.dim(` wrote ${configPath}`));
|
|
94
|
-
});
|
|
82
|
+
vars.U1Z_HOME = u1zHome;
|
|
83
|
+
vars.PORT = (await ask("PORT", "3000")) || "3000";
|
|
84
|
+
|
|
85
|
+
const content = Object.entries(vars)
|
|
86
|
+
.map(([k, v]) => `${k}="${v.replace(/"/g, '\\"')}"`)
|
|
87
|
+
.join("\n");
|
|
88
|
+
writeFileSync(configPath, `${content}\n`, "utf-8");
|
|
89
|
+
console.log(c.dim(` wrote ${configPath}`));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
95
92
|
|
|
96
93
|
// 4. systemd unit 파일 설정
|
|
97
94
|
await step("systemd user 서비스 설정", async () => {
|
|
@@ -101,6 +98,8 @@ export async function init(): Promise<void> {
|
|
|
101
98
|
ensureDir(serviceDir);
|
|
102
99
|
|
|
103
100
|
const u1zBin = Bun.which("u1z") ?? join(homedir(), ".bun", "bin", "u1z");
|
|
101
|
+
const bunBinDir = dirname(process.execPath);
|
|
102
|
+
const envPath = `${bunBinDir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`;
|
|
104
103
|
|
|
105
104
|
const serviceContent = `[Unit]
|
|
106
105
|
Description=u1z AI 집 비서
|
|
@@ -109,6 +108,7 @@ After=network.target
|
|
|
109
108
|
[Service]
|
|
110
109
|
Type=simple
|
|
111
110
|
WorkingDirectory=${u1zHome}
|
|
111
|
+
Environment=PATH=${envPath}
|
|
112
112
|
ExecStart=${u1zBin} server
|
|
113
113
|
EnvironmentFile=${configPath}
|
|
114
114
|
Restart=on-failure
|
package/src/cli/index.ts
CHANGED
|
@@ -22,6 +22,9 @@ yargs(hideBin(process.argv))
|
|
|
22
22
|
{ n: { type: "number", describe: "최근 N줄" } },
|
|
23
23
|
(argv) => import("./commands/logs").then((m) => m.logs(argv)),
|
|
24
24
|
)
|
|
25
|
+
.command("restart", "서비스 재시작", {}, () =>
|
|
26
|
+
import("./commands/restart").then((m) => m.restart()),
|
|
27
|
+
)
|
|
25
28
|
.command("update", "최신 버전으로 업데이트", {}, () =>
|
|
26
29
|
import("./commands/update").then((m) => m.update()),
|
|
27
30
|
)
|