@skills-store/rednote 0.1.1 → 0.1.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/dist/rednote/publish.js +18 -6
- package/package.json +1 -1
package/dist/rednote/publish.js
CHANGED
|
@@ -21,7 +21,7 @@ Usage:
|
|
|
21
21
|
|
|
22
22
|
Options:
|
|
23
23
|
--instance NAME Optional. Defaults to the saved lastConnect instance
|
|
24
|
-
--type TYPE
|
|
24
|
+
--type TYPE 可选。video | image | article;不传时会按参数自动推断
|
|
25
25
|
--title TEXT Required. 发布标题
|
|
26
26
|
--content TEXT 必填。视频/图文时为描述,长文时为 Markdown 内容
|
|
27
27
|
--tag TEXT 可选。重复传入多个标签,例如 --tag 穿搭 --tag OOTD
|
|
@@ -117,11 +117,23 @@ export function parsePublishCliArgs(argv) {
|
|
|
117
117
|
help: values.help
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
function hasPublishInputs(values) {
|
|
121
|
+
return Boolean(values.type || values.title?.trim() || values.content?.trim() || values.videoPath?.trim() || values.imagePaths.length > 0 || values.tags.length > 0 || values.publishNow);
|
|
122
|
+
}
|
|
123
|
+
function resolvePublishType(values) {
|
|
124
|
+
if (values.type) {
|
|
125
|
+
return values.type;
|
|
126
|
+
}
|
|
127
|
+
if (values.videoPath?.trim()) {
|
|
128
|
+
return 'video';
|
|
129
|
+
}
|
|
130
|
+
if (values.imagePaths.length > 0) {
|
|
131
|
+
return 'image';
|
|
124
132
|
}
|
|
133
|
+
return 'article';
|
|
134
|
+
}
|
|
135
|
+
export function resolvePublishPayload(values) {
|
|
136
|
+
const type = resolvePublishType(values);
|
|
125
137
|
const title = ensureNonEmpty(values.title, '--title');
|
|
126
138
|
const tags = normalizeTags(values.tags);
|
|
127
139
|
const draft = !values.publishNow;
|
|
@@ -338,7 +350,7 @@ export async function openRednotePublish(target, session, payload) {
|
|
|
338
350
|
});
|
|
339
351
|
}
|
|
340
352
|
export async function runPublishCommand(values) {
|
|
341
|
-
if (values.help) {
|
|
353
|
+
if (values.help || !hasPublishInputs(values)) {
|
|
342
354
|
printPublishHelp();
|
|
343
355
|
return;
|
|
344
356
|
}
|