@haenah/u1z 0.1.0 → 0.1.2
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 +5 -7
- package/src/cli/commands/init.ts +11 -9
- package/src/cli/index.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
|
|
4
5
|
import { c } from "../utils/color";
|
|
5
6
|
|
|
6
7
|
type CheckResult = { label: string; ok: boolean; hint?: string; optional?: boolean };
|
|
@@ -78,8 +79,8 @@ async function checks(): Promise<CheckResult[]> {
|
|
|
78
79
|
hint: u1zHome ? `u1z init 실행 필요 (${promptDir} 없음)` : "U1Z_HOME 환경변수 미설정",
|
|
79
80
|
});
|
|
80
81
|
|
|
81
|
-
// 8.
|
|
82
|
-
const
|
|
82
|
+
// 8. 설정 파일 필수 변수
|
|
83
|
+
const configPath = join(home, ".config", "u1z", "config");
|
|
83
84
|
const requiredVars = [
|
|
84
85
|
"DISCORD_BOT_TOKEN",
|
|
85
86
|
"OPENAI_API_KEY",
|
|
@@ -88,12 +89,9 @@ async function checks(): Promise<CheckResult[]> {
|
|
|
88
89
|
];
|
|
89
90
|
const missingVars = requiredVars.filter((k) => !process.env[k]);
|
|
90
91
|
results.push({
|
|
91
|
-
label: "
|
|
92
|
+
label: "설정 파일 필수 변수",
|
|
92
93
|
ok: missingVars.length === 0,
|
|
93
|
-
hint:
|
|
94
|
-
missingVars.length > 0
|
|
95
|
-
? `누락: ${missingVars.join(", ")} — ${envPath || "U1Z_HOME/.env"}`
|
|
96
|
-
: undefined,
|
|
94
|
+
hint: missingVars.length > 0 ? `누락: ${missingVars.join(", ")} — ${configPath}` : undefined,
|
|
97
95
|
});
|
|
98
96
|
|
|
99
97
|
// 9. systemd u1z.service 등록 여부
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -58,13 +58,15 @@ export async function init(): Promise<void> {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
// 3.
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
// 3. 설정 파일
|
|
62
|
+
const configDir = join(homedir(), ".config", "u1z");
|
|
63
|
+
const configPath = join(configDir, "config");
|
|
64
|
+
await step("설정 파일 생성 (~/.config/u1z/config)", async () => {
|
|
65
|
+
ensureDir(configDir);
|
|
66
|
+
if (existsSync(configPath)) {
|
|
67
|
+
const overwrite = await confirm("설정 파일이 이미 존재합니다. 덮어쓸까요?", false);
|
|
66
68
|
if (!overwrite) {
|
|
67
|
-
console.log(c.dim(" 기존
|
|
69
|
+
console.log(c.dim(" 기존 설정 파일 유지"));
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -87,8 +89,8 @@ export async function init(): Promise<void> {
|
|
|
87
89
|
const content = Object.entries(vars)
|
|
88
90
|
.map(([k, v]) => `${k}="${v.replace(/"/g, '\\"')}"`)
|
|
89
91
|
.join("\n");
|
|
90
|
-
writeFileSync(
|
|
91
|
-
console.log(c.dim(` wrote ${
|
|
92
|
+
writeFileSync(configPath, `${content}\n`, "utf-8");
|
|
93
|
+
console.log(c.dim(` wrote ${configPath}`));
|
|
92
94
|
});
|
|
93
95
|
|
|
94
96
|
// 4. systemd unit 파일 설정
|
|
@@ -108,7 +110,7 @@ After=network.target
|
|
|
108
110
|
Type=simple
|
|
109
111
|
WorkingDirectory=${u1zHome}
|
|
110
112
|
ExecStart=${u1zBin} server
|
|
111
|
-
EnvironmentFile=${
|
|
113
|
+
EnvironmentFile=${configPath}
|
|
112
114
|
Restart=on-failure
|
|
113
115
|
RestartSec=5s
|
|
114
116
|
|
package/src/cli/index.ts
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { hideBin } from "yargs/helpers";
|
|
4
4
|
|
|
5
|
+
const { version } = await import("../../package.json");
|
|
6
|
+
|
|
5
7
|
yargs(hideBin(process.argv))
|
|
6
8
|
.scriptName("u1z")
|
|
9
|
+
.version(version)
|
|
7
10
|
.command("init", "대화형 초기 셋업 및 systemd 서비스 등록", {}, () =>
|
|
8
11
|
import("./commands/init").then((m) => m.init()),
|
|
9
12
|
)
|