@optima-chat/tiktok-cli 0.10.1 → 0.10.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/README.md +17 -1
- package/dist/index.js +35 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,12 +44,28 @@ tiktok <domain> <verb> --shop <shopId> [--flags]
|
|
|
44
44
|
| `delivery-options --warehouse <id>` | 仓库交付方式 |
|
|
45
45
|
| `images upload --file <path> --use-case MAIN_IMAGE [--out <f>]` | 上传本地图 → 返回 TikTok CDN `uri`(multipart,供拼 `main_images` 用) |
|
|
46
46
|
|
|
47
|
+
## 传参写法
|
|
48
|
+
|
|
49
|
+
`--key value` 与 `--key=value` 等价,随便用哪种:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
tiktok promotions create-flashsale --shop <id> --price 11.9 # 空格式
|
|
53
|
+
tiktok promotions create-flashsale --shop=<id> --price=11.9 # 等号式
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
(0.10.2 之前只认空格式,等号式会让那一格参数**静默消失**而命令照报成功,见 #11。)
|
|
57
|
+
|
|
58
|
+
**开关型 flag**(`--apply` / `--enable` / `--default` / `--unprocessed`)除了裸传,也能带值:
|
|
59
|
+
`true`/`1`/`yes`/`on` 为真,`false`/`0`/`no`/`off`/空串为假(大小写不敏感),
|
|
60
|
+
给它别的值**当场报错**而不是猜。同一个 flag 写两次以后者为准(`--apply=false --apply` 会真发)。
|
|
61
|
+
|
|
47
62
|
## 写操作(Phase 2,安全护栏)
|
|
48
63
|
|
|
49
64
|
写命令三道阀,把 A 轨「填完回读」纪律做进 CLI:
|
|
50
65
|
|
|
51
66
|
1. **默认 dry-run** —— 不加 `--apply` 只打印将提交的 payload,不碰真实店铺
|
|
52
|
-
2. `--apply`
|
|
67
|
+
2. `--apply` 才真发。它是开关,写成 `--apply=false` / `=0` / `=no` / `=off` 一样停在 dry-run;
|
|
68
|
+
`--apply=true` / `=1` / `=yes` / `=on` 才真发;给它一个看不懂的值(`--apply=maybe`)当场报错、不猜
|
|
53
69
|
3. **成功后自动回读** —— 写完 GET 回资源,输出 `readback` 供 agent/人核对是否生效
|
|
54
70
|
|
|
55
71
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -1045,7 +1045,7 @@ var COMMANDS = [
|
|
|
1045
1045
|
// ── 多 App 管理(admin 配置操作,鉴权走 x-admin-token,不走商家 --shop,也不走三道阀 dry-run/--apply)──
|
|
1046
1046
|
{
|
|
1047
1047
|
name: "apps add",
|
|
1048
|
-
summary: "\u767B\u8BB0\u4E00\u4E2A TikTok App\uFF08--service-id --app-key --app-secret --type --label\uFF0C[--markets a,b] [--redirect] [--owner-entity]\uFF09",
|
|
1048
|
+
summary: "\u767B\u8BB0\u4E00\u4E2A TikTok App\uFF08--service-id --app-key --app-secret --type --label\uFF0C[--markets a,b] [--redirect] [--owner-entity] [--default]\uFF09",
|
|
1049
1049
|
run: ({ args: args2 }) => adminApps("POST", {
|
|
1050
1050
|
body: {
|
|
1051
1051
|
serviceId: args2["service-id"],
|
|
@@ -1165,7 +1165,13 @@ function parseFlags(tokens) {
|
|
|
1165
1165
|
const positional2 = [];
|
|
1166
1166
|
for (let i = 0; i < tokens.length; i++) {
|
|
1167
1167
|
const t = tokens[i];
|
|
1168
|
+
if (t === "--") continue;
|
|
1168
1169
|
if (t.startsWith("--")) {
|
|
1170
|
+
const eq = t.indexOf("=");
|
|
1171
|
+
if (eq !== -1) {
|
|
1172
|
+
args2[t.slice(2, eq)] = t.slice(eq + 1);
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1169
1175
|
const key = t.slice(2);
|
|
1170
1176
|
const next = tokens[i + 1];
|
|
1171
1177
|
if (next && !next.startsWith("--")) {
|
|
@@ -1176,6 +1182,33 @@ function parseFlags(tokens) {
|
|
|
1176
1182
|
}
|
|
1177
1183
|
return { args: args2, positional: positional2 };
|
|
1178
1184
|
}
|
|
1185
|
+
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["apply", "default", "unprocessed", "enable"]);
|
|
1186
|
+
var FLAG_TRUE = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
|
|
1187
|
+
var FLAG_FALSE = /* @__PURE__ */ new Set(["false", "0", "no", "off", ""]);
|
|
1188
|
+
function normalizeBooleanFlags(args2) {
|
|
1189
|
+
for (const key of BOOLEAN_FLAGS) {
|
|
1190
|
+
if (!(key in args2)) continue;
|
|
1191
|
+
const raw = args2[key];
|
|
1192
|
+
const v = raw.toLowerCase();
|
|
1193
|
+
if (FLAG_TRUE.has(v)) {
|
|
1194
|
+
args2[key] = "true";
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
if (FLAG_FALSE.has(v)) {
|
|
1198
|
+
delete args2[key];
|
|
1199
|
+
continue;
|
|
1200
|
+
}
|
|
1201
|
+
out({
|
|
1202
|
+
ok: false,
|
|
1203
|
+
error: {
|
|
1204
|
+
code: "VALIDATION",
|
|
1205
|
+
message: `--${key} \u662F\u5F00\u5173\uFF0C\u53EA\u63A5\u53D7 true/1/yes/on \u6216 false/0/no/off\uFF0C\u6536\u5230\u300C${raw}\u300D`,
|
|
1206
|
+
retryable: false
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
process.exit(1);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1179
1212
|
function out(obj) {
|
|
1180
1213
|
process.stdout.write(JSON.stringify(obj, null, 2) + "\n");
|
|
1181
1214
|
}
|
|
@@ -1221,6 +1254,7 @@ if (wantsHelp) {
|
|
|
1221
1254
|
else usage();
|
|
1222
1255
|
process.exit(0);
|
|
1223
1256
|
}
|
|
1257
|
+
normalizeBooleanFlags(args);
|
|
1224
1258
|
if (!match) {
|
|
1225
1259
|
out({ ok: false, error: { code: "VALIDATION", message: `\u672A\u77E5\u547D\u4EE4: ${positional.join(" ")}`, retryable: false } });
|
|
1226
1260
|
usage();
|