@nuelink/nuelink-cli 1.1.0 → 1.3.0
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 +61 -12
- package/package.json +4 -4
- package/src/cli.js +29 -0
- package/src/commands.js +497 -0
- package/src/config.js +121 -0
- package/src/http.js +176 -0
- package/src/output.js +183 -0
- package/src/postPayload.js +174 -0
- package/src/validation.js +186 -0
- package/src/main.js +0 -734
package/README.md
CHANGED
|
@@ -8,9 +8,12 @@ Use this CLI to manage brands, collections, automations, channels, media, and po
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
11
|
+
- Runtime auth for single-command usage
|
|
12
|
+
- Optional permission-protected local token persistence
|
|
13
|
+
- Bearer auth support via runtime flag, env var, or saved config
|
|
13
14
|
- JSON output for easy piping into automation
|
|
15
|
+
- Dry-run request preview for mutation commands
|
|
16
|
+
- Strict local validation for common CLI input mistakes
|
|
14
17
|
- Built-in timeout support for safer production usage
|
|
15
18
|
- Command coverage for key Nuelink Public API resources
|
|
16
19
|
|
|
@@ -37,7 +40,7 @@ npx @nuelink/nuelink-cli --help
|
|
|
37
40
|
### 1. Save your API key
|
|
38
41
|
|
|
39
42
|
```bash
|
|
40
|
-
nuelink-cli
|
|
43
|
+
printf '%s' "$NUELINK_API_KEY" | nuelink-cli auth:login --stdin
|
|
41
44
|
```
|
|
42
45
|
|
|
43
46
|
### 2. Verify auth source
|
|
@@ -56,11 +59,11 @@ nuelink-cli me
|
|
|
56
59
|
|
|
57
60
|
The CLI resolves auth in this order:
|
|
58
61
|
|
|
59
|
-
1. CLI flag: `--
|
|
62
|
+
1. CLI flag: `--api-key <api_key>`
|
|
60
63
|
2. Environment variable: `NUELINK_API_KEY`
|
|
61
64
|
3. Saved config file in your user home
|
|
62
65
|
|
|
63
|
-
|
|
66
|
+
Use `auth:login` when you want to persist a key explicitly. Prefer `NUELINK_API_KEY` in CI/CD. The legacy `--auth` flag is still accepted as a runtime-only alias for `--api-key`.
|
|
64
67
|
|
|
65
68
|
### Clear saved auth
|
|
66
69
|
|
|
@@ -79,13 +82,18 @@ The file stores:
|
|
|
79
82
|
|
|
80
83
|
```json
|
|
81
84
|
{
|
|
82
|
-
"
|
|
85
|
+
"version": 1,
|
|
86
|
+
"encryptedApiKey": "...",
|
|
87
|
+
"iv": "...",
|
|
88
|
+
"authTag": "..."
|
|
83
89
|
}
|
|
84
90
|
```
|
|
85
91
|
|
|
86
92
|
## Global Options
|
|
87
93
|
|
|
88
|
-
- `-a, --
|
|
94
|
+
- `-a, --api-key <apiKey>`: Use API key for the current invocation only
|
|
95
|
+
- `--auth <apiKey>`: Deprecated alias for `--api-key`
|
|
96
|
+
- `--json`: Output raw JSON instead of table mode for list commands
|
|
89
97
|
- `-h, --help`: Show help
|
|
90
98
|
- `-V, --version`: Show version
|
|
91
99
|
|
|
@@ -100,6 +108,7 @@ nuelink-cli me
|
|
|
100
108
|
### Auth
|
|
101
109
|
|
|
102
110
|
```bash
|
|
111
|
+
printf '%s' "$NUELINK_API_KEY" | nuelink-cli auth:login --stdin
|
|
103
112
|
nuelink-cli auth:status
|
|
104
113
|
nuelink-cli auth:clear
|
|
105
114
|
```
|
|
@@ -110,12 +119,36 @@ nuelink-cli auth:clear
|
|
|
110
119
|
nuelink-cli brands --per-page 5 --page 1
|
|
111
120
|
```
|
|
112
121
|
|
|
122
|
+
List-style commands now print a readable table by default with a pagination summary at the bottom. Use `--json` when you want the raw API payload instead.
|
|
123
|
+
|
|
124
|
+
Example table output:
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
+------+-----------+-------------+------------+----------------------------+
|
|
128
|
+
| Id | Title | Description | Timezone | Updated At |
|
|
129
|
+
+------+-----------+-------------+------------+----------------------------+
|
|
130
|
+
| 13493| new brand | new brand | Europe/... | 2026-04-15T13:45:23.000000Z|
|
|
131
|
+
| 9682 | zapier | zapier | Europe/... | 2026-03-30T01:07:43.000000Z|
|
|
132
|
+
+------+-----------+-------------+------------+----------------------------+
|
|
133
|
+
Pagination: Page 1 of 1 | 25 per page | 2 total
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Raw JSON mode:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
nuelink-cli --json brands --per-page 5 --page 1
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
In `--json` mode, stdout contains only the JSON response so it can be piped directly into tools like `jq`.
|
|
143
|
+
|
|
113
144
|
### Collections
|
|
114
145
|
|
|
115
146
|
```bash
|
|
116
147
|
nuelink-cli collections --brand-id 13493 --per-page 5 --page 1
|
|
117
148
|
```
|
|
118
149
|
|
|
150
|
+
Example output includes collection title, status-related fields, and pagination summary in the same table format.
|
|
151
|
+
|
|
119
152
|
Create collection:
|
|
120
153
|
|
|
121
154
|
```bash
|
|
@@ -131,9 +164,11 @@ nuelink-cli collections:create \
|
|
|
131
164
|
### Automations
|
|
132
165
|
|
|
133
166
|
```bash
|
|
134
|
-
nuelink-cli automations --brand-id 13493
|
|
167
|
+
nuelink-cli automations --brand-id 13493 --per-page 5 --page 1
|
|
135
168
|
```
|
|
136
169
|
|
|
170
|
+
This table view is especially useful for quickly scanning automation status, sub-type, and feed URL.
|
|
171
|
+
|
|
137
172
|
Create automation:
|
|
138
173
|
|
|
139
174
|
```bash
|
|
@@ -155,14 +190,18 @@ nuelink-cli automations:create \
|
|
|
155
190
|
nuelink-cli channels --brand-id 13493 --per-page 5 --page 1
|
|
156
191
|
```
|
|
157
192
|
|
|
193
|
+
Channel list output highlights name, status, and platform type.
|
|
194
|
+
|
|
158
195
|
### Media
|
|
159
196
|
|
|
160
197
|
List media:
|
|
161
198
|
|
|
162
199
|
```bash
|
|
163
|
-
nuelink-cli media --brand-id 13493
|
|
200
|
+
nuelink-cli media --brand-id 13493 --per-page 5 --page 1
|
|
164
201
|
```
|
|
165
202
|
|
|
203
|
+
Media list output highlights file name, type, size, and timestamps.
|
|
204
|
+
|
|
166
205
|
Upload media:
|
|
167
206
|
|
|
168
207
|
```bash
|
|
@@ -174,15 +213,19 @@ nuelink-cli media:upload --brand-id 13493 --file ./assets/image.jpg
|
|
|
174
213
|
List posts:
|
|
175
214
|
|
|
176
215
|
```bash
|
|
177
|
-
nuelink-cli posts --brand-id 13493 --collection-id 33273
|
|
216
|
+
nuelink-cli posts --brand-id 13493 --collection-id 33273 --per-page 5 --page 1
|
|
178
217
|
```
|
|
179
218
|
|
|
219
|
+
Post list output highlights the post ID, type, status, and publish date.
|
|
220
|
+
|
|
180
221
|
Create post from JSON payload file:
|
|
181
222
|
|
|
182
223
|
```bash
|
|
183
224
|
nuelink-cli posts:add-json --brand-id 13493 --collection-id 33273 --payload ./post.json
|
|
184
225
|
```
|
|
185
226
|
|
|
227
|
+
You can also pipe JSON through stdin with `--payload -`.
|
|
228
|
+
|
|
186
229
|
Example `post.json`:
|
|
187
230
|
|
|
188
231
|
```json
|
|
@@ -227,15 +270,21 @@ nuelink-cli posts:create \
|
|
|
227
270
|
--youtube-playlists '[{"channelId":"1","playlistIds":["1","2"]}]'
|
|
228
271
|
```
|
|
229
272
|
|
|
273
|
+
Supported publish modes are `DRAFT`, `QUEUE`, `SCHEDULE`, and `IMMEDIATE`. When using `SCHEDULE`, pass `--publish-at`.
|
|
274
|
+
|
|
230
275
|
## Output and Exit Codes
|
|
231
276
|
|
|
232
|
-
-
|
|
277
|
+
- Table-mode list requests print `OK <METHOD> <PATH>` plus formatted output
|
|
278
|
+
- JSON output mode prints only the JSON response body to stdout
|
|
279
|
+
- `--quiet` suppresses success banners while keeping the response output
|
|
280
|
+
- `--dry-run` prints the validated request without sending it
|
|
233
281
|
- Failed requests print HTTP status and response payload when available
|
|
234
282
|
- Exit code is non-zero on failure
|
|
235
283
|
|
|
236
284
|
## Environment Variables
|
|
237
285
|
|
|
238
286
|
- `NUELINK_API_KEY`: API key fallback if not passed via CLI flag
|
|
287
|
+
- `NUELINK_BASE_URL`: Override API base URL for testing or documented self-hosted scenarios
|
|
239
288
|
- `NUELINK_TIMEOUT_MS`: request timeout in milliseconds (default: `30000`)
|
|
240
289
|
|
|
241
290
|
Example:
|
|
@@ -294,7 +343,7 @@ npm run check:pack
|
|
|
294
343
|
### Invalid Token
|
|
295
344
|
|
|
296
345
|
- Run `nuelink-cli auth:status` to confirm active auth source
|
|
297
|
-
- Re-save your token with `nuelink-cli
|
|
346
|
+
- Re-save your token with `printf '%s' "$NUELINK_API_KEY" | nuelink-cli auth:login --stdin`
|
|
298
347
|
- Ensure no stale `NUELINK_API_KEY` is overriding your saved config
|
|
299
348
|
|
|
300
349
|
### Request timeout
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuelink/nuelink-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "./src/
|
|
8
|
+
"main": "./src/cli.js",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "node --test test/cli.test.mjs",
|
|
11
|
-
"smoke:auth": "node src/
|
|
11
|
+
"smoke:auth": "node src/cli.js auth:status",
|
|
12
12
|
"check:pack": "npm pack --dry-run"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"commander": "^15.0.0"
|
|
29
29
|
},
|
|
30
30
|
"bin": {
|
|
31
|
-
"nuelink-cli": "./src/
|
|
31
|
+
"nuelink-cli": "./src/cli.js"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import { extractApiKeyArg, registerCommands } from "./commands.js";
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const { version: cliVersion } = require("../package.json");
|
|
9
|
+
|
|
10
|
+
const parsedAuth = extractApiKeyArg(process.argv.slice(2));
|
|
11
|
+
const runtimeApiKey = parsedAuth.apiKey;
|
|
12
|
+
const parseArgv = [process.argv[0], process.argv[1], ...parsedAuth.sanitizedArgs];
|
|
13
|
+
|
|
14
|
+
if (!process.env.NUELINK_API_KEY && runtimeApiKey) {
|
|
15
|
+
process.env.NUELINK_API_KEY = runtimeApiKey;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
registerCommands(program, runtimeApiKey, cliVersion);
|
|
19
|
+
|
|
20
|
+
const argvHasCommand = parsedAuth.sanitizedArgs.some((arg) => !arg.startsWith("-"));
|
|
21
|
+
const hasHelpFlag = parsedAuth.sanitizedArgs.includes("--help") || parsedAuth.sanitizedArgs.includes("-h");
|
|
22
|
+
const hasVersionFlag = parsedAuth.sanitizedArgs.includes("--version") || parsedAuth.sanitizedArgs.includes("-V");
|
|
23
|
+
|
|
24
|
+
if (!argvHasCommand && !hasHelpFlag && !hasVersionFlag) {
|
|
25
|
+
program.outputHelp();
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await program.parseAsync(parseArgv);
|