@zentodo/cli 0.1.5 → 0.1.6
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/bin.cjs +39 -7
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -5555,7 +5555,10 @@ function buildFormData(spec, input, context = {}) {
|
|
|
5555
5555
|
};
|
|
5556
5556
|
const hasUsrKey = spec.params.some((p) => (p.backendName ?? snakeToCamel(p.name)) === "usrKey");
|
|
5557
5557
|
if (!hasUsrKey && context.usrKey !== void 0 && context.usrKey !== null) {
|
|
5558
|
-
|
|
5558
|
+
const keyStr = String(context.usrKey);
|
|
5559
|
+
if (keyStr !== "[object Object]" && keyStr.length > 0) {
|
|
5560
|
+
append("usrKey", keyStr);
|
|
5561
|
+
}
|
|
5559
5562
|
}
|
|
5560
5563
|
for (const p of spec.params) {
|
|
5561
5564
|
const value = input[p.name] ?? p.default;
|
|
@@ -6630,13 +6633,22 @@ function registerAuth(root) {
|
|
|
6630
6633
|
});
|
|
6631
6634
|
}
|
|
6632
6635
|
function extractUsrKey(data) {
|
|
6633
|
-
if (
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
+
if (data === null || data === void 0) return void 0;
|
|
6637
|
+
if (typeof data === "number") return data;
|
|
6638
|
+
if (typeof data === "string") {
|
|
6639
|
+
const n = Number(data);
|
|
6640
|
+
return Number.isNaN(n) ? data : n;
|
|
6636
6641
|
}
|
|
6642
|
+
if (typeof data !== "object") return void 0;
|
|
6637
6643
|
const d = data;
|
|
6638
6644
|
for (const key of ["usrKey", "userKey", "id", "user_key"]) {
|
|
6639
|
-
|
|
6645
|
+
const v = d[key];
|
|
6646
|
+
if (v === void 0 || v === null) continue;
|
|
6647
|
+
if (typeof v === "number") return v;
|
|
6648
|
+
if (typeof v === "string" && v.length > 0) {
|
|
6649
|
+
const n = Number(v);
|
|
6650
|
+
return Number.isNaN(n) ? v : n;
|
|
6651
|
+
}
|
|
6640
6652
|
}
|
|
6641
6653
|
if (d["data"] && typeof d["data"] === "object") return extractUsrKey(d["data"]);
|
|
6642
6654
|
return void 0;
|
|
@@ -6711,7 +6723,7 @@ async function buildContext(flags) {
|
|
|
6711
6723
|
if (flags.server) effective.server = flags.server;
|
|
6712
6724
|
const secrets = await createSecretStore();
|
|
6713
6725
|
const tokenRaw = flags.token ?? process.env["ZENTODO_TOKEN"] ?? await secrets.get(name) ?? "";
|
|
6714
|
-
let usrKey = effective.user_key;
|
|
6726
|
+
let usrKey = toScalarKey(effective.user_key);
|
|
6715
6727
|
let grantedScopes = [];
|
|
6716
6728
|
if (tokenRaw) {
|
|
6717
6729
|
const secretMaterial = await secrets.get(`${name}:hmac-secret`);
|
|
@@ -6747,6 +6759,26 @@ function requireAuth(ctx) {
|
|
|
6747
6759
|
});
|
|
6748
6760
|
}
|
|
6749
6761
|
}
|
|
6762
|
+
function toScalarKey(v) {
|
|
6763
|
+
if (v === void 0 || v === null) return void 0;
|
|
6764
|
+
if (typeof v === "number") return v;
|
|
6765
|
+
if (typeof v === "string" && v.length > 0) {
|
|
6766
|
+
const n = Number(v);
|
|
6767
|
+
return Number.isNaN(n) ? v : n;
|
|
6768
|
+
}
|
|
6769
|
+
if (typeof v === "object") {
|
|
6770
|
+
const obj = v;
|
|
6771
|
+
for (const key of ["usrKey", "userKey", "id", "user_key"]) {
|
|
6772
|
+
const inner = obj[key];
|
|
6773
|
+
if (typeof inner === "number") return inner;
|
|
6774
|
+
if (typeof inner === "string" && inner.length > 0) {
|
|
6775
|
+
const n = Number(inner);
|
|
6776
|
+
return Number.isNaN(n) ? inner : n;
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6779
|
+
}
|
|
6780
|
+
return void 0;
|
|
6781
|
+
}
|
|
6750
6782
|
|
|
6751
6783
|
// src/commands/data.ts
|
|
6752
6784
|
function registerData(root) {
|
|
@@ -7978,7 +8010,7 @@ function describeGroup(name) {
|
|
|
7978
8010
|
}
|
|
7979
8011
|
|
|
7980
8012
|
// src/program.ts
|
|
7981
|
-
var CLI_VERSION = true ? "0.1.
|
|
8013
|
+
var CLI_VERSION = true ? "0.1.6" : "0.0.0";
|
|
7982
8014
|
function buildProgram() {
|
|
7983
8015
|
const program3 = new Command();
|
|
7984
8016
|
program3.name("zentodo").description("ZenTodo \u547D\u4EE4\u884C\u5DE5\u5177 \u2014 \u57FA\u4E8E\u6E05\u5355\u9A71\u52A8,\u8FDE\u63A5 ZenTodo \u540E\u7AEF\u3002\u6240\u6709\u8BF7\u6C42\u4F7F\u7528 FormData\u3002").version(CLI_VERSION, "-V, --version", "\u6253\u5370 CLI \u7248\u672C").helpOption("-h, --help", "\u663E\u793A\u5E2E\u52A9\u4FE1\u606F").addHelpCommand("help [command]", "\u67E5\u770B\u547D\u4EE4\u5E2E\u52A9").option("--profile <name>", "\u4F7F\u7528\u6307\u5B9A Profile(\u9ED8\u8BA4\u4F7F\u7528 current_profile)").option("--server <url>", "\u8986\u76D6\u540E\u7AEF\u5730\u5740").option("--token <token>", "\u8986\u76D6\u672C\u5730 Token").option("--log-level <level>", "\u65E5\u5FD7\u7EA7\u522B:trace|debug|info|warn|error", "info").option("--log-file <path>", "\u8FFD\u52A0\u65E5\u5FD7\u5230\u6307\u5B9A\u6587\u4EF6").option("--no-retry", "\u7981\u7528\u81EA\u52A8\u91CD\u8BD5").option("--no-color", "\u5173\u95ED\u5F69\u8272\u8F93\u51FA").option("--dry-run", "\u53EA\u6253\u5370\u5C06\u53D1\u9001\u7684\u8BF7\u6C42,\u4E0D\u771F\u6B63\u8C03\u7528\u540E\u7AEF").option("--yes", "\u8DF3\u8FC7\u7834\u574F\u6027\u64CD\u4F5C\u7684\u786E\u8BA4\u63D0\u793A").option("--local", "\u4F18\u5148\u4F7F\u7528\u672C\u5730 SQLite(\u82E5\u53EF\u7528)").option("--remote", "\u5F3A\u5236\u4F7F\u7528\u8FDC\u7A0B HTTP \u6A21\u5F0F").option("--json", "JSON \u8F93\u51FA").option("--ndjson", "\u6309\u884C\u8F93\u51FA JSON(\u9002\u5408\u6D41\u5F0F\u5904\u7406)").option("--yaml", "YAML \u8F93\u51FA").option("--quiet", "\u9690\u85CF\u975E\u5FC5\u8981\u8F93\u51FA");
|