@monoedge/jdu-cli 0.6.0 → 0.6.1
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/dist/cli.js +16 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4091,7 +4091,7 @@ async function browserAuthorize(input) {
|
|
|
4091
4091
|
server.close();
|
|
4092
4092
|
fn(value);
|
|
4093
4093
|
};
|
|
4094
|
-
const fail = finish((msg) => reject(new CliError(msg, "重新执行 jdu login;不想开浏览器就带 --token")));
|
|
4094
|
+
const fail = finish((msg) => reject(new CliError(msg, input.failHint ?? "重新执行 jdu login;不想开浏览器就带 --token")));
|
|
4095
4095
|
const handler = callbackHandler(state, finish(resolve));
|
|
4096
4096
|
const server = createServer((req, res) => {
|
|
4097
4097
|
if (new URL(req.url ?? "/", "http://localhost").pathname !== "/callback") {
|
|
@@ -4237,7 +4237,8 @@ async function runLogin(opts) {
|
|
|
4237
4237
|
server,
|
|
4238
4238
|
token: await (opts.authorize ?? browserAuthorize)({
|
|
4239
4239
|
server,
|
|
4240
|
-
authorizeUrl
|
|
4240
|
+
authorizeUrl,
|
|
4241
|
+
...cfAccess ? { failHint: `重新执行 jdu login --server ${server},用 Cloudflare 账号授权` } : {}
|
|
4241
4242
|
}),
|
|
4242
4243
|
...cfAccess ? { cfAccess: true } : {}
|
|
4243
4244
|
});
|
|
@@ -4541,10 +4542,15 @@ async function runDeploy(opts) {
|
|
|
4541
4542
|
if (health === null) throw new CliError(`${siteUrl} 起来了但 /healthz 一直不通(等了 ${HEALTH_TIMEOUT_MS / 1e3}s)`, `跑 npx ${WRANGLER} tail --name ${name} 看 Worker 日志;Access 策略已经配好,修完不用重跑 jdu deploy`);
|
|
4542
4543
|
if (health.authProvider !== "cloudflare-access") throw new CliError(`${siteUrl} 的 authProvider 是 ${health.authProvider ?? "未知"},不是 cloudflare-access`, "确认 wrangler 变量写进去了(wrangler deploy 会打印绑定列表)");
|
|
4543
4544
|
let loggedIn = false;
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4545
|
+
let warning;
|
|
4546
|
+
if (opts.login !== false) try {
|
|
4547
|
+
loggedIn = (await (opts.loginFn ?? runLogin)({
|
|
4548
|
+
server: siteUrl,
|
|
4549
|
+
browser: true
|
|
4550
|
+
})).loggedIn;
|
|
4551
|
+
} catch (err) {
|
|
4552
|
+
warning = `自动 jdu login 没走完:${err instanceof Error ? err.message : String(err)}`;
|
|
4553
|
+
}
|
|
4548
4554
|
return {
|
|
4549
4555
|
name,
|
|
4550
4556
|
url: siteUrl,
|
|
@@ -4553,7 +4559,8 @@ async function runDeploy(opts) {
|
|
|
4553
4559
|
emails,
|
|
4554
4560
|
accessAppId: app.id,
|
|
4555
4561
|
upgraded: existed,
|
|
4556
|
-
loggedIn
|
|
4562
|
+
loggedIn,
|
|
4563
|
+
...warning === void 0 ? {} : { warning }
|
|
4557
4564
|
};
|
|
4558
4565
|
} finally {
|
|
4559
4566
|
cleanup();
|
|
@@ -6618,7 +6625,7 @@ async function client() {
|
|
|
6618
6625
|
function collectTag(value, previous) {
|
|
6619
6626
|
return [...previous ?? [], value];
|
|
6620
6627
|
}
|
|
6621
|
-
var VERSION = "0.6.
|
|
6628
|
+
var VERSION = "0.6.1";
|
|
6622
6629
|
var program = new Command();
|
|
6623
6630
|
program.name("jdu").description("jiandu 命令行").version(VERSION).showHelpAfterError();
|
|
6624
6631
|
program.command("deploy").description("把一台简牍部署到你自己的 Cloudflare 账号(Worker + Durable Object,Free 计划够用)").option("--name <name>", "Worker 名字,决定 workers.dev 的子域名前缀", "jiandu").option("--dist <dir>", "用本地构建的产物代替 npm 包(开发用,指向 server/dist-cf)").option("--cf-token <token>", "带 Access 权限的 Cloudflare API token(不给就走浏览器 OAuth / 本地缓存)").option("--no-login", "部署完不自动 jdu login(之后手动跑一次即可)").option("--dry-run", "只校验配置与产物,不上传、不碰你的账号", false).option("--json", "机器可读输出(agent 联动用)", false).action(async (opts) => {
|
|
@@ -6639,6 +6646,7 @@ program.command("deploy").description("把一台简牍部署到你自己的 Clou
|
|
|
6639
6646
|
process.stdout.write(`加人:jdu access allow <邮箱>\n`);
|
|
6640
6647
|
if (result.loggedIn) process.stdout.write("\njdu 已经连上它了,可以直接 jdu push\n");
|
|
6641
6648
|
else process.stdout.write(`\n下一步:jdu login --server ${result.url}\n`);
|
|
6649
|
+
if (result.warning) process.stderr.write(`jdu: ${result.warning}\n`);
|
|
6642
6650
|
});
|
|
6643
6651
|
var access = program.command("access").description("Cloudflare 形态的准入(Access 策略里的邮箱列表)");
|
|
6644
6652
|
access.command("list").description("列出能登录这台实例的邮箱").option("--server <url>", "目标站点(缺省用 jdu login 时定下的那台)").option("--cf-token <token>", "带 Access 权限的 Cloudflare API token").option("--json", "机器可读输出", false).action(async (opts) => {
|