@haenah/u1z 0.1.2 → 0.1.4
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 +1 -1
- package/src/cli/commands/doctor.ts +11 -3
- package/src/cli/commands/init.ts +30 -33
package/package.json
CHANGED
|
@@ -80,18 +80,26 @@ 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",
|
|
87
87
|
"GOOGLE_GENERATIVE_AI_API_KEY",
|
|
88
88
|
"TAVILY_API_KEY",
|
|
89
89
|
];
|
|
90
|
-
const
|
|
90
|
+
const configVars: Record<string, string> = {};
|
|
91
|
+
if (existsSync(configPath)) {
|
|
92
|
+
const content = await Bun.file(configPath).text();
|
|
93
|
+
for (const line of content.split("\n")) {
|
|
94
|
+
const match = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
95
|
+
if (match) configVars[match[1]] = match[2];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const missingVars = requiredVars.filter((k) => !configVars[k] && !process.env[k]);
|
|
91
99
|
results.push({
|
|
92
100
|
label: "설정 파일 필수 변수",
|
|
93
101
|
ok: missingVars.length === 0,
|
|
94
|
-
hint: missingVars.length > 0 ? `누락: ${missingVars.join(", ")}
|
|
102
|
+
hint: missingVars.length > 0 ? `누락: ${missingVars.join(", ")} (~/.config/u1z)` : undefined,
|
|
95
103
|
});
|
|
96
104
|
|
|
97
105
|
// 9. systemd u1z.service 등록 여부
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { 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 () => {
|