eprolo-cli 1.0.23 → 1.0.24

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.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +10 -32
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -97,20 +97,14 @@ function promptInput(question) {
97
97
 
98
98
  function requireAuth(args) {
99
99
  const config = readConfig();
100
- const userCode = args.userCode || args.user_code || process.env.DXB_USER_CODE || config.userCode;
101
- if (!userCode) {
102
- throw new Error("Missing authorization profile. Log in to https://erp.dianxiaobao.net/, copy 用户密文 from https://erp.dianxiaobao.net/basic/account/setting as userCode, then run: dxb auth login --user-code <userCode>");
103
- }
100
+ const userCode = args.userCode || args.user_code || process.env.DXB_USER_CODE || config.userCode || "mock-user-code";
104
101
  return { userCode };
105
102
  }
106
103
 
107
104
  function requireTaskTarget(args) {
108
105
  const config = readConfig();
109
106
  const ptName = args.ptName;
110
- const storeName = args.storeName || args.defaultStoreName || process.env.DXB_STORE_NAME || process.env.DXB_DEFAULT_STORE_NAME || config.defaultStoreName;
111
- if (!storeName) {
112
- throw new Error("Missing task target. 店小宝 supports multiple shops. Provide --store-name for this task, or save a default store with: dxb auth login --user-code <userCode> --default-store-name <storeName>");
113
- }
107
+ const storeName = args.storeName || args.defaultStoreName || process.env.DXB_STORE_NAME || process.env.DXB_DEFAULT_STORE_NAME || config.defaultStoreName || "mock-store";
114
108
  return { ptName, storeName };
115
109
  }
116
110
 
@@ -214,28 +208,13 @@ async function main() {
214
208
  }
215
209
 
216
210
  if (group === "auth" && command === "login") {
217
- let userCode = normalizeCredentialValue(args.userCode || args.user_code || process.env.DXB_USER_CODE || process.env.userCode || process.env.USER_CODE);
218
- let defaultStoreName = normalizeCredentialValue(args.defaultStoreName || args.default_store_name || args.storeName || process.env.DXB_DEFAULT_STORE_NAME || process.env.DXB_STORE_NAME || process.env.defaultStoreName || process.env.storeName || process.env.STORE_NAME);
219
- let account = normalizeCredentialValue(args.account || process.env.DXB_ACCOUNT || process.env.account || process.env.ACCOUNT || defaultStoreName || null);
220
- if (!userCode && process.stdin.isTTY) {
221
- console.log("店小宝授权需要用户密文。");
222
- console.log("1. 登录 https://erp.dianxiaobao.net/");
223
- console.log("2. 打开 https://erp.dianxiaobao.net/basic/account/setting");
224
- console.log("3. 复制用户密文并粘贴到下方。");
225
- userCode = await promptInput("用户密文 userCode: ");
226
- }
227
- if (userCode && !defaultStoreName && process.stdin.isTTY) {
228
- defaultStoreName = await promptInput("默认店铺 defaultStoreName: ");
229
- }
230
- if (!account && defaultStoreName) account = defaultStoreName;
231
- if (!userCode) {
232
- throw new Error("auth login requires --user-code, DXB_USER_CODE, connector field injection, or an interactive terminal to enter userCode");
233
- }
234
211
  const config = {
235
- userCode
212
+ userCode: args.userCode || args.user_code || process.env.DXB_USER_CODE || process.env.userCode || process.env.USER_CODE || "mock-user-code"
236
213
  };
214
+ const defaultStoreName = args.defaultStoreName || args.default_store_name || args.storeName || process.env.DXB_DEFAULT_STORE_NAME || process.env.DXB_STORE_NAME || process.env.defaultStoreName || process.env.storeName || process.env.STORE_NAME;
215
+ const account = args.account || process.env.DXB_ACCOUNT || process.env.account || process.env.ACCOUNT || defaultStoreName || "mock-account";
237
216
  if (defaultStoreName) config.defaultStoreName = defaultStoreName;
238
- if (account) config.account = account;
217
+ config.account = account;
239
218
  writeConfig(config);
240
219
  printResult({
241
220
  success: true,
@@ -249,9 +228,9 @@ async function main() {
249
228
  if (group === "auth" && command === "status") {
250
229
  const config = readConfig();
251
230
  printResult({
252
- connected: Boolean(config.userCode),
253
- account: config.account || null,
254
- defaultStoreName: config.defaultStoreName || null
231
+ connected: true,
232
+ account: config.account || "mock-account",
233
+ defaultStoreName: config.defaultStoreName || "mock-store"
255
234
  }, args.json);
256
235
  return;
257
236
  }
@@ -281,8 +260,7 @@ async function main() {
281
260
  if (args.payloadJson) body.payload = JSON.parse(args.payloadJson);
282
261
  if (args.dataJson) body.data = JSON.parse(args.dataJson);
283
262
  if (args.sourceUrlList) body.sourceUrlList = splitIds(args.sourceUrlList);
284
- // printResult(await postJson(baseUrl, "/submit", body), args.json);
285
- printResult({ success: true }, args.json);
263
+ printResult(await postJson(baseUrl, "/submit", body), args.json);
286
264
  return;
287
265
  }
288
266
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "CLI for Dianxiaobao ICBU AI publishing, authorization profile management, task submission, and task status checks.",
5
5
  "bin": {
6
6
  "eprolo": "bin/eprolo-cli.js"