@co0ontty/wand 2.0.4 → 2.1.0
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/README.md +12 -2
- package/dist/build-info.json +3 -3
- package/dist/cli.js +35 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,10 +39,15 @@ If you install with `npm`, initialize and start Wand manually:
|
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
wand init
|
|
42
|
+
wand config:password # Print the login password
|
|
42
43
|
wand web
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
The install script already runs `wand init
|
|
46
|
+
The install script already runs `wand init`, prints the login password, and lets you choose whether to install a background service or start Wand manually. To view the password later, run:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
wand config:password
|
|
50
|
+
```
|
|
46
51
|
|
|
47
52
|
### Features
|
|
48
53
|
|
|
@@ -168,10 +173,15 @@ npm install -g @co0ontty/wand
|
|
|
168
173
|
|
|
169
174
|
```bash
|
|
170
175
|
wand init
|
|
176
|
+
wand config:password # 查看登录密码
|
|
171
177
|
wand web
|
|
172
178
|
```
|
|
173
179
|
|
|
174
|
-
一键安装脚本会自动执行 `wand init
|
|
180
|
+
一键安装脚本会自动执行 `wand init`、显示登录密码,并让你选择安装为后台服务或之后手动运行 `wand web`。之后如需再次查看密码,运行:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
wand config:password
|
|
184
|
+
```
|
|
175
185
|
|
|
176
186
|
### 功能
|
|
177
187
|
|
package/dist/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
3
|
-
"builtAt": "2026-06-
|
|
4
|
-
"version": "2.0
|
|
2
|
+
"commit": "7e50c09c87555c62932b1408e23b613e01c33645",
|
|
3
|
+
"builtAt": "2026-06-28T07:19:26.564Z",
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"channel": "stable"
|
|
6
6
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
|
2
|
+
import crypto from "node:crypto";
|
|
2
3
|
import { spawnSync } from "node:child_process";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
import { request as httpRequest } from "node:http";
|
|
@@ -115,6 +116,11 @@ async function main() {
|
|
|
115
116
|
}
|
|
116
117
|
break;
|
|
117
118
|
}
|
|
119
|
+
case "config:password": {
|
|
120
|
+
const { config } = await loadConfigForCli(configPath, { ensureInitialPassword: true });
|
|
121
|
+
process.stdout.write(`${config.password}\n`);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
118
124
|
case "config:set": {
|
|
119
125
|
const key = args[1];
|
|
120
126
|
const value = args[2];
|
|
@@ -186,6 +192,7 @@ Commands:
|
|
|
186
192
|
wand web Start web console server (or attach to running one)
|
|
187
193
|
wand config:path Print resolved config path
|
|
188
194
|
wand config:show Print current config
|
|
195
|
+
wand config:password Print current login password
|
|
189
196
|
wand config:set Update a simple config value
|
|
190
197
|
|
|
191
198
|
System service (default = system-wide; pass --user for user-level):
|
|
@@ -206,19 +213,9 @@ Options:
|
|
|
206
213
|
`);
|
|
207
214
|
}
|
|
208
215
|
async function ensureRequiredFiles(configPath, opts = {}) {
|
|
209
|
-
const {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// 先建 DB 文件,再加载 config(loadConfigWithStorage 需要 storage 来迁移老 JSON 偏好字段并应用 DB 覆盖)。
|
|
213
|
-
const createdDb = ensureDatabaseFile(dbPath);
|
|
214
|
-
const storage = new WandStorage(dbPath);
|
|
215
|
-
let config;
|
|
216
|
-
try {
|
|
217
|
-
config = await loadConfigWithStorage(configPath, storage);
|
|
218
|
-
}
|
|
219
|
-
finally {
|
|
220
|
-
storage.close();
|
|
221
|
-
}
|
|
216
|
+
const { config, dbPath, hadConfig, createdDb, generatedPassword } = await loadConfigForCli(configPath, {
|
|
217
|
+
ensureInitialPassword: true,
|
|
218
|
+
});
|
|
222
219
|
// 已存在的 ready 信息在 TUI 模式下由启动 banner 统一展示,此处静默;
|
|
223
220
|
// 但 created 是首次创建事件,无论 TUI 与否都值得提示。
|
|
224
221
|
if (!hadConfig) {
|
|
@@ -233,8 +230,33 @@ async function ensureRequiredFiles(configPath, opts = {}) {
|
|
|
233
230
|
else if (!opts.silentReady) {
|
|
234
231
|
process.stdout.write(`[wand] SQLite database ready at ${dbPath}\n`);
|
|
235
232
|
}
|
|
233
|
+
if (generatedPassword) {
|
|
234
|
+
process.stdout.write(`[wand] Created initial login password: ${generatedPassword}\n`);
|
|
235
|
+
}
|
|
236
236
|
return config;
|
|
237
237
|
}
|
|
238
|
+
async function loadConfigForCli(configPath, opts = {}) {
|
|
239
|
+
const { ensureDatabaseFile, resolveDatabasePath, WandStorage } = await import("./storage.js");
|
|
240
|
+
const dbPath = resolveDatabasePath(configPath);
|
|
241
|
+
const hadConfig = hasConfigFile(configPath);
|
|
242
|
+
// 先建 DB 文件,再加载 config(loadConfigWithStorage 需要 storage 来迁移老 JSON 偏好字段并应用 DB 覆盖)。
|
|
243
|
+
const createdDb = ensureDatabaseFile(dbPath);
|
|
244
|
+
const storage = new WandStorage(dbPath);
|
|
245
|
+
let config;
|
|
246
|
+
let generatedPassword = null;
|
|
247
|
+
try {
|
|
248
|
+
config = await loadConfigWithStorage(configPath, storage);
|
|
249
|
+
if (opts.ensureInitialPassword && !hadConfig && !storage.hasCustomPassword() && config.password === "change-me") {
|
|
250
|
+
generatedPassword = crypto.randomBytes(18).toString("base64url");
|
|
251
|
+
storage.setPassword(generatedPassword);
|
|
252
|
+
config.password = generatedPassword;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
finally {
|
|
256
|
+
storage.close();
|
|
257
|
+
}
|
|
258
|
+
return { config, dbPath, hadConfig, createdDb, generatedPassword };
|
|
259
|
+
}
|
|
238
260
|
function shouldUseTui() {
|
|
239
261
|
if (process.env.WAND_NO_TUI)
|
|
240
262
|
return false;
|