@nuelink/nuelink-cli 1.3.0 → 1.3.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/package.json +1 -1
- package/src/commands.js +15 -0
- package/src/postPayload.js +5 -5
- package/src/validation.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuelink/nuelink-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "The official Nuelink CLI for automating social media workflows from your terminal. Schedule posts, upload media, manage brands, and integrate Nuelink into scripts, CI/CD pipelines, and AI agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nuelink",
|
package/src/commands.js
CHANGED
|
@@ -75,14 +75,28 @@ async function promptHidden(promptText) {
|
|
|
75
75
|
const stdout = process.stdout;
|
|
76
76
|
const wasRaw = stdin.isTTY ? stdin.isRaw : false;
|
|
77
77
|
let value = "";
|
|
78
|
+
let settled = false;
|
|
79
|
+
|
|
80
|
+
const onError = (error) => {
|
|
81
|
+
cleanup();
|
|
82
|
+
reject(error);
|
|
83
|
+
};
|
|
78
84
|
|
|
79
85
|
const cleanup = () => {
|
|
86
|
+
if (settled) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
settled = true;
|
|
80
91
|
stdin.removeListener("keypress", onKeypress);
|
|
92
|
+
stdin.removeListener("error", onError);
|
|
81
93
|
|
|
82
94
|
if (stdin.isTTY) {
|
|
83
95
|
stdin.setRawMode(Boolean(wasRaw));
|
|
84
96
|
}
|
|
85
97
|
|
|
98
|
+
stdin.pause();
|
|
99
|
+
|
|
86
100
|
stdout.write("\n");
|
|
87
101
|
};
|
|
88
102
|
|
|
@@ -117,6 +131,7 @@ async function promptHidden(promptText) {
|
|
|
117
131
|
}
|
|
118
132
|
|
|
119
133
|
stdin.resume();
|
|
134
|
+
stdin.on("error", onError);
|
|
120
135
|
stdin.on("keypress", onKeypress);
|
|
121
136
|
});
|
|
122
137
|
}
|
package/src/postPayload.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
splitCsv,
|
|
6
6
|
validateHttpUrl,
|
|
7
7
|
validatePollOptions,
|
|
8
|
-
|
|
8
|
+
validateScheduledAt,
|
|
9
9
|
} from "./validation.js";
|
|
10
10
|
|
|
11
11
|
const VALID_PUBLISH_MODES = ["DRAFT", "QUEUE", "SCHEDULE", "IMMEDIATE"];
|
|
@@ -60,10 +60,10 @@ function normalizePublishMode(value) {
|
|
|
60
60
|
function buildPostPayload(options) {
|
|
61
61
|
const media = mergeMedia(options.mediaIds, options.mediaUrls);
|
|
62
62
|
const publishMode = normalizePublishMode(options.publishMode);
|
|
63
|
-
const
|
|
63
|
+
const scheduledAt = validateScheduledAt(options.scheduledAt);
|
|
64
64
|
|
|
65
|
-
if (publishMode === "SCHEDULE" && !
|
|
66
|
-
throw new Error("
|
|
65
|
+
if (publishMode === "SCHEDULE" && !scheduledAt) {
|
|
66
|
+
throw new Error("scheduledAt is required when publishMode is SCHEDULE.");
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const pollOptions = options.pollOptions ? parseCsv(options.pollOptions) : [];
|
|
@@ -135,7 +135,7 @@ function buildPostPayload(options) {
|
|
|
135
135
|
...(options.link ? { link: validateHttpUrl(options.link, "link") } : {}),
|
|
136
136
|
...(options.postType ? { postType: options.postType } : {}),
|
|
137
137
|
publishMode,
|
|
138
|
-
|
|
138
|
+
scheduledAt,
|
|
139
139
|
...(parseBooleanStrict(options.postAsStory, "post-as-story") !== undefined
|
|
140
140
|
? { postAsStory: parseBooleanStrict(options.postAsStory, "post-as-story") }
|
|
141
141
|
: {}),
|
package/src/validation.js
CHANGED
|
@@ -106,7 +106,7 @@ function validateQueueSlots(queueSlots) {
|
|
|
106
106
|
return queueSlots;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function
|
|
109
|
+
function validateScheduledAt(value) {
|
|
110
110
|
if (value === undefined || value === null || value === "" || value === "null") {
|
|
111
111
|
return null;
|
|
112
112
|
}
|
|
@@ -180,7 +180,7 @@ export {
|
|
|
180
180
|
validateHttpUrl,
|
|
181
181
|
validateMediaFile,
|
|
182
182
|
validatePollOptions,
|
|
183
|
-
|
|
183
|
+
validateScheduledAt,
|
|
184
184
|
validateQueueSlots,
|
|
185
185
|
normalizeEnum,
|
|
186
186
|
};
|