@sovovs/bycli 2.1.35 → 2.1.36

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/cli-manifest.json CHANGED
@@ -28297,7 +28297,7 @@
28297
28297
  "example": "bycli weixin create-draft --title \"文章标题\" --content-file article.html --content-format html --cover-image cover.jpg",
28298
28298
  "domain": "mp.weixin.qq.com",
28299
28299
  "strategy": "cookie",
28300
- "browser": true,
28300
+ "browser": "conditional",
28301
28301
  "args": [
28302
28302
  {
28303
28303
  "name": "title",
@@ -41,6 +41,20 @@ function validateCoverImage(value) {
41
41
  return coverPath;
42
42
  }
43
43
 
44
+ function readApiCredentials(kwargs) {
45
+ const appid = kwargs.appid == null ? '' : String(kwargs.appid).trim();
46
+ const appsecret = kwargs.appsecret == null ? '' : String(kwargs.appsecret).trim();
47
+ if (Boolean(appid) !== Boolean(appsecret)) {
48
+ throw new ArgumentError('appid and appsecret must be provided together');
49
+ }
50
+ return { appid: appid || null, appsecret: appsecret || null };
51
+ }
52
+
53
+ function requiresBrowser(kwargs) {
54
+ const { appid, appsecret } = readApiCredentials(kwargs);
55
+ return !(appid && appsecret);
56
+ }
57
+
44
58
  function normalizeCreateDraftArgs(kwargs) {
45
59
  const title = requiredText(kwargs.title, 'title');
46
60
  if (codePointLength(title) > MAX_TITLE_LENGTH) {
@@ -55,11 +69,7 @@ function normalizeCreateDraftArgs(kwargs) {
55
69
  contentFile: kwargs['content-file'],
56
70
  contentFormat: kwargs['content-format'],
57
71
  });
58
- const appid = kwargs.appid == null ? '' : String(kwargs.appid).trim();
59
- const appsecret = kwargs.appsecret == null ? '' : String(kwargs.appsecret).trim();
60
- if (Boolean(appid) !== Boolean(appsecret)) {
61
- throw new ArgumentError('appid and appsecret must be provided together');
62
- }
72
+ const { appid, appsecret } = readApiCredentials(kwargs);
63
73
  return {
64
74
  title,
65
75
  ...draftContent,
@@ -67,8 +77,8 @@ function normalizeCreateDraftArgs(kwargs) {
67
77
  summary: kwargs.summary == null ? null : String(kwargs.summary).trim(),
68
78
  coverImage: validateCoverImage(kwargs['cover-image']),
69
79
  dryRun: kwargs['dry-run'] === true,
70
- appid: appid || null,
71
- appsecret: appsecret || null,
80
+ appid,
81
+ appsecret,
72
82
  };
73
83
  }
74
84
 
@@ -361,7 +371,7 @@ export const createDraftCommand = cli({
361
371
  example: 'bycli weixin create-draft --title "文章标题" --content-file article.html --content-format html --cover-image cover.jpg',
362
372
  domain: WEIXIN_DOMAIN,
363
373
  strategy: Strategy.COOKIE,
364
- browser: true,
374
+ browser: requiresBrowser,
365
375
  navigateBefore: false,
366
376
  args: [
367
377
  { name: 'title', required: true, help: '文章标题(最长 64 字)' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sovovs/bycli",
3
- "version": "2.1.35",
3
+ "version": "2.1.36",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },