@nuelink/nuelink-cli 1.4.0 → 1.4.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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +51 -29
- package/SECURITY.md +70 -0
- package/package.json +22 -4
- package/src/cli.js +37 -13
- package/src/commands.js +109 -67
- package/src/config.js +107 -38
- package/src/errors.js +47 -0
- package/src/http.js +95 -54
- package/src/postPayload.js +187 -175
- package/src/validation.js +53 -14
- package/test/cli.test.mjs +1235 -0
- package/test/mock-fetch.cjs +261 -0
- package/test/mock-fetch.mjs +261 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.4.1 - 2026-08-18
|
|
4
|
+
|
|
5
|
+
- Emit structured machine-readable errors when `--json` is enabled.
|
|
6
|
+
- Reject blank required mutation fields and invalid runtime configuration.
|
|
7
|
+
- Harden saved credential writes and avoid reading media during dry runs.
|
|
8
|
+
- Include tests, security guidance, license, and repository metadata in the npm package.
|
|
9
|
+
|
|
10
|
+
## 1.4.0
|
|
11
|
+
|
|
12
|
+
- Add dry-run mutation previews, stricter request validation, retries, timeouts,
|
|
13
|
+
and expanded post creation options.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nuelink
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ The token is stored in:
|
|
|
78
78
|
- Windows: `%USERPROFILE%/.nuelink-cli/config.json`
|
|
79
79
|
- macOS/Linux: `$HOME/.nuelink-cli/config.json`
|
|
80
80
|
|
|
81
|
-
The file stores:
|
|
81
|
+
The file stores:
|
|
82
82
|
|
|
83
83
|
```json
|
|
84
84
|
{
|
|
@@ -86,14 +86,20 @@ The file stores:
|
|
|
86
86
|
"encryptedApiKey": "...",
|
|
87
87
|
"iv": "...",
|
|
88
88
|
"authTag": "..."
|
|
89
|
-
}
|
|
90
|
-
```
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Saved keys are written through a mode-`0700` config directory and an atomic
|
|
93
|
+
mode-`0600` file replacement where the operating system supports POSIX
|
|
94
|
+
permissions. The CLI refuses symbolic-link config paths. The bundled
|
|
95
|
+
encryption prevents casual disclosure but is not a substitute for filesystem
|
|
96
|
+
permissions; prefer `NUELINK_API_KEY` when a secret manager is available.
|
|
91
97
|
|
|
92
98
|
## Global Options
|
|
93
99
|
|
|
94
100
|
- `-a, --api-key <apiKey>`: Use API key for the current invocation only
|
|
95
101
|
- `--auth <apiKey>`: Deprecated alias for `--api-key`
|
|
96
|
-
- `--json`: Output
|
|
102
|
+
- `--json`: Output machine-readable JSON for successes and failures
|
|
97
103
|
- `-h, --help`: Show help
|
|
98
104
|
- `-V, --version`: Show version
|
|
99
105
|
|
|
@@ -139,7 +145,9 @@ Raw JSON mode:
|
|
|
139
145
|
nuelink-cli --json brands --per-page 5 --page 1
|
|
140
146
|
```
|
|
141
147
|
|
|
142
|
-
In `--json` mode, stdout contains
|
|
148
|
+
In `--json` mode, stdout contains one JSON value so it can be piped directly
|
|
149
|
+
into tools like `jq`. API successes retain the raw response shape. Failures use
|
|
150
|
+
`{"success":false,"error":{"code":"...","message":"...","httpStatus":null,"details":{}}}`.
|
|
143
151
|
|
|
144
152
|
### Collections
|
|
145
153
|
|
|
@@ -152,13 +160,14 @@ Example output includes collection title, status-related fields, and pagination
|
|
|
152
160
|
Create collection:
|
|
153
161
|
|
|
154
162
|
```bash
|
|
155
|
-
nuelink-cli collections:create \
|
|
163
|
+
nuelink-cli collections:create \
|
|
156
164
|
--brand-id 13493 \
|
|
157
165
|
--title "API Brand" \
|
|
158
166
|
--description "Collection from CLI" \
|
|
159
167
|
--max-republish 5 \
|
|
160
168
|
--channels "300294,60112" \
|
|
161
|
-
--queues "Mon 10:10,Mon 12:12"
|
|
169
|
+
--queues "Mon 10:10,Mon 12:12" \
|
|
170
|
+
--dry-run
|
|
162
171
|
```
|
|
163
172
|
|
|
164
173
|
### Automations
|
|
@@ -172,7 +181,7 @@ This table view is especially useful for quickly scanning automation status, sub
|
|
|
172
181
|
Create automation:
|
|
173
182
|
|
|
174
183
|
```bash
|
|
175
|
-
nuelink-cli automations:create \
|
|
184
|
+
nuelink-cli automations:create \
|
|
176
185
|
--brand-id 13493 \
|
|
177
186
|
--collection-id 720 \
|
|
178
187
|
--feed-url "https://www.nasa.gov/rss/dyn/breaking_news.rss" \
|
|
@@ -181,7 +190,8 @@ nuelink-cli automations:create \
|
|
|
181
190
|
--title "NASA Breaking News" \
|
|
182
191
|
--type FEED \
|
|
183
192
|
--dynamic-title "{{title}}" \
|
|
184
|
-
--dynamic-body "{title} {link}"
|
|
193
|
+
--dynamic-body "{title} {link}" \
|
|
194
|
+
--dry-run
|
|
185
195
|
```
|
|
186
196
|
|
|
187
197
|
### Channels
|
|
@@ -197,7 +207,7 @@ Channel list output highlights name, status, and platform type.
|
|
|
197
207
|
List media:
|
|
198
208
|
|
|
199
209
|
```bash
|
|
200
|
-
nuelink-cli media --brand-id 13493 --type IMAGE --per-page 5 --page 1
|
|
210
|
+
nuelink-cli media --brand-id 13493 --type IMAGE --per-page 5 --page 1
|
|
201
211
|
```
|
|
202
212
|
|
|
203
213
|
Media list output highlights file name, type, size, and timestamps.
|
|
@@ -205,7 +215,7 @@ Media list output highlights file name, type, size, and timestamps.
|
|
|
205
215
|
Upload media:
|
|
206
216
|
|
|
207
217
|
```bash
|
|
208
|
-
nuelink-cli media:upload --brand-id 13493 --file ./assets/image.jpg
|
|
218
|
+
nuelink-cli media:upload --brand-id 13493 --file ./assets/image.jpg --dry-run
|
|
209
219
|
```
|
|
210
220
|
|
|
211
221
|
### Posts
|
|
@@ -221,7 +231,7 @@ Post list output highlights the post ID, type, status, and publish date.
|
|
|
221
231
|
Create post from JSON payload file:
|
|
222
232
|
|
|
223
233
|
```bash
|
|
224
|
-
nuelink-cli posts:add-json --brand-id 13493 --collection-id 33273 --payload ./post.json
|
|
234
|
+
nuelink-cli posts:add-json --brand-id 13493 --collection-id 33273 --payload ./post.json --dry-run
|
|
225
235
|
```
|
|
226
236
|
|
|
227
237
|
You can also pipe JSON through stdin with `--payload -`.
|
|
@@ -254,26 +264,30 @@ nuelink-cli posts:create \
|
|
|
254
264
|
--media-urls "https://media.nuelink.com/media/abc" \
|
|
255
265
|
--poll-question "what is the new role?" \
|
|
256
266
|
--poll-options "iron,dudee" \
|
|
257
|
-
--poll-period 3d \
|
|
258
|
-
--poll-correct-option-index 0 \
|
|
267
|
+
--poll-period 3d \
|
|
268
|
+
--poll-correct-option-index 0 \
|
|
259
269
|
--poll-explanation "iwa ash idir lwaaa7ad" \
|
|
260
270
|
--instagram-collab "karim.chamlal" \
|
|
261
271
|
--instagram-location-id "abc123" \
|
|
262
272
|
--instagram-location-name "bentaib" \
|
|
263
273
|
--instagram-trial-reel MANUAL \
|
|
264
274
|
--instagram-share-to-feed true \
|
|
265
|
-
--facebook-location-id "abc123" \
|
|
266
|
-
--facebook-location-name "bentaib" \
|
|
267
|
-
--tiktok-send-to-inbox true \
|
|
268
|
-
--tiktok-auto-add-music false \
|
|
269
|
-
--youtube-tags "tag1,tag2,tag3" \
|
|
270
|
-
--youtube-playlists '[{"channelId":1,"playlistIds":["1","2"]}]' \
|
|
271
|
-
--googlemybusiness-upload-to-photos-section true
|
|
275
|
+
--facebook-location-id "abc123" \
|
|
276
|
+
--facebook-location-name "bentaib" \
|
|
277
|
+
--tiktok-send-to-inbox true \
|
|
278
|
+
--tiktok-auto-add-music false \
|
|
279
|
+
--youtube-tags "tag1,tag2,tag3" \
|
|
280
|
+
--youtube-playlists '[{"channelId":1,"playlistIds":["1","2"]}]' \
|
|
281
|
+
--googlemybusiness-upload-to-photos-section true \
|
|
282
|
+
--dry-run
|
|
272
283
|
```
|
|
273
284
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
285
|
+
Review each mutation preview, then repeat the same command without `--dry-run`
|
|
286
|
+
only when you intend to send it.
|
|
287
|
+
|
|
288
|
+
Supported publish modes are `DRAFT`, `QUEUE`, `SCHEDULE`, and `IMMEDIATE`. When using `SCHEDULE`, pass `--scheduled-at` in `YYYY-MM-DD HH:mm:ss` format. Poll correct-option indexes are zero-based.
|
|
289
|
+
|
|
290
|
+
Pagination uses `--page >= 1` and `--per-page` from 1 through 100. Media type filters are `IMAGE`, `VIDEO`, `GIF`, `APPLICATION`, `DOCUMENT`, and `CSV`.
|
|
277
291
|
|
|
278
292
|
## Output and Exit Codes
|
|
279
293
|
|
|
@@ -331,15 +345,20 @@ npm test
|
|
|
331
345
|
### Package validation
|
|
332
346
|
|
|
333
347
|
```bash
|
|
334
|
-
npm run check:pack
|
|
348
|
+
npm run check:pack
|
|
349
|
+
npm run check:pack:installed
|
|
335
350
|
```
|
|
336
351
|
|
|
337
352
|
## Release Checklist
|
|
338
353
|
|
|
339
354
|
1. Update version in `package.json`
|
|
340
355
|
2. Run `npm test`
|
|
341
|
-
3. Run `npm run check:pack`
|
|
342
|
-
4.
|
|
356
|
+
3. Run `npm run check:pack`
|
|
357
|
+
4. Run `npm run check:pack:installed`
|
|
358
|
+
5. Publish locally with `npm publish --access public`
|
|
359
|
+
|
|
360
|
+
Provenance is available when publishing from a supported cloud CI provider. Do
|
|
361
|
+
not enable it for a local publish.
|
|
343
362
|
|
|
344
363
|
## Troubleshooting
|
|
345
364
|
|
|
@@ -354,8 +373,11 @@ npm run check:pack
|
|
|
354
373
|
Increase timeout for slower operations:
|
|
355
374
|
|
|
356
375
|
```bash
|
|
357
|
-
NUELINK_TIMEOUT_MS=120000 nuelink-cli media --brand-id 13493
|
|
358
|
-
```
|
|
376
|
+
NUELINK_TIMEOUT_MS=120000 nuelink-cli media --brand-id 13493
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
`NUELINK_TIMEOUT_MS` must be 1–600000. `NUELINK_GET_RETRIES` must be 0–10;
|
|
380
|
+
retry delay variables must be non-negative integers no greater than 600000.
|
|
359
381
|
|
|
360
382
|
### Command help
|
|
361
383
|
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Security fixes are applied to the latest published version of `nuelink-cli`.
|
|
6
|
+
|
|
7
|
+
If you are on an older version, upgrade first and verify the issue still exists.
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
Please do not open public issues for security vulnerabilities.
|
|
12
|
+
|
|
13
|
+
Instead, report privately to the Nuelink team through your internal security channel or official support/security contact.
|
|
14
|
+
|
|
15
|
+
Include the following details:
|
|
16
|
+
|
|
17
|
+
1. Affected version (`nuelink-cli --version`)
|
|
18
|
+
2. Environment details (OS, Node version)
|
|
19
|
+
3. Clear reproduction steps
|
|
20
|
+
4. Impact assessment
|
|
21
|
+
5. Proof-of-concept (sanitized)
|
|
22
|
+
6. Suggested mitigation, if available
|
|
23
|
+
|
|
24
|
+
## Response Process
|
|
25
|
+
|
|
26
|
+
The team will:
|
|
27
|
+
|
|
28
|
+
1. Acknowledge receipt
|
|
29
|
+
2. Triage severity and scope
|
|
30
|
+
3. Work on remediation
|
|
31
|
+
4. Coordinate disclosure timing
|
|
32
|
+
5. Publish patched release notes
|
|
33
|
+
|
|
34
|
+
## Handling Secrets Safely
|
|
35
|
+
|
|
36
|
+
When using this CLI:
|
|
37
|
+
|
|
38
|
+
- Treat API keys as sensitive credentials
|
|
39
|
+
- Prefer environment variables in CI/CD
|
|
40
|
+
- Prefer `auth:login` over passing secrets on the command line when persisting local auth
|
|
41
|
+
- Avoid printing tokens in logs and screenshots
|
|
42
|
+
- Rotate keys immediately if exposure is suspected
|
|
43
|
+
|
|
44
|
+
The CLI stores saved auth in the user config file:
|
|
45
|
+
|
|
46
|
+
- Windows: `%USERPROFILE%/.nuelink-cli/config.json`
|
|
47
|
+
- macOS/Linux: `$HOME/.nuelink-cli/config.json`
|
|
48
|
+
|
|
49
|
+
The config directory and file are permission-restricted where supported,
|
|
50
|
+
written through atomic replacement, and rejected when either config path is an
|
|
51
|
+
unsafe filesystem object. Bundled encryption is defense in depth, not a
|
|
52
|
+
replacement for operating-system access controls. Prefer `NUELINK_API_KEY`
|
|
53
|
+
backed by a secret manager for automated environments.
|
|
54
|
+
|
|
55
|
+
If you suspect compromise:
|
|
56
|
+
|
|
57
|
+
1. Revoke and rotate the key
|
|
58
|
+
2. Clear local saved auth with `nuelink-cli auth:clear`
|
|
59
|
+
3. Re-authenticate with a new key
|
|
60
|
+
|
|
61
|
+
## Scope
|
|
62
|
+
|
|
63
|
+
This policy covers:
|
|
64
|
+
|
|
65
|
+
- CLI auth handling
|
|
66
|
+
- Request construction and transport behavior
|
|
67
|
+
- Sensitive output/logging concerns
|
|
68
|
+
- Packaging and release integrity
|
|
69
|
+
|
|
70
|
+
Out-of-scope items include vulnerabilities in third-party services beyond this repository's control.
|
package/package.json
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuelink/nuelink-cli",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.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",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Nuelink/nuelink-cli.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Nuelink/nuelink-cli#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Nuelink/nuelink-cli/issues"
|
|
14
|
+
},
|
|
7
15
|
"type": "module",
|
|
8
16
|
"main": "./src/cli.js",
|
|
9
17
|
"scripts": {
|
|
10
18
|
"test": "node --test test/cli.test.mjs",
|
|
11
19
|
"smoke:auth": "node src/cli.js auth:status",
|
|
12
|
-
"check:pack": "npm pack --dry-run"
|
|
20
|
+
"check:pack": "npm pack --dry-run",
|
|
21
|
+
"check:pack:installed": "node scripts/check-packed-package.mjs"
|
|
13
22
|
},
|
|
14
23
|
"engines": {
|
|
15
24
|
"node": ">=18.17"
|
|
16
25
|
},
|
|
17
26
|
"files": [
|
|
18
|
-
"src"
|
|
27
|
+
"src",
|
|
28
|
+
"test",
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"README.md",
|
|
31
|
+
"SECURITY.md",
|
|
32
|
+
"LICENSE"
|
|
19
33
|
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
20
37
|
"keywords": [
|
|
21
38
|
"nuelink",
|
|
22
39
|
"cli",
|
|
@@ -24,10 +41,11 @@
|
|
|
24
41
|
"automation"
|
|
25
42
|
],
|
|
26
43
|
"dependencies": {
|
|
44
|
+
"@nuelink/nuelink-cli": "^1.4.1",
|
|
27
45
|
"chalk": "^5.6.2",
|
|
28
46
|
"commander": "^13.1.0"
|
|
29
47
|
},
|
|
30
48
|
"bin": {
|
|
31
|
-
"nuelink-cli": "
|
|
49
|
+
"nuelink-cli": "src/cli.js"
|
|
32
50
|
}
|
|
33
51
|
}
|
package/src/cli.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
-
import { program } from "commander";
|
|
5
|
-
import { extractApiKeyArg, registerCommands } from "./commands.js";
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import { extractApiKeyArg, registerCommands } from "./commands.js";
|
|
6
|
+
import { CliError, printCliError } from "./errors.js";
|
|
6
7
|
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
8
9
|
const { version: cliVersion } = require("../package.json");
|
|
9
10
|
|
|
10
11
|
const parsedAuth = extractApiKeyArg(process.argv.slice(2));
|
|
11
12
|
const runtimeApiKey = parsedAuth.apiKey;
|
|
12
|
-
const parseArgv = [process.argv[0], process.argv[1], ...parsedAuth.sanitizedArgs];
|
|
13
|
+
const parseArgv = [process.argv[0], process.argv[1], ...parsedAuth.sanitizedArgs];
|
|
14
|
+
const jsonMode = parsedAuth.sanitizedArgs.includes("--json");
|
|
15
|
+
|
|
16
|
+
if (jsonMode) {
|
|
17
|
+
program.exitOverride();
|
|
18
|
+
program.configureOutput({
|
|
19
|
+
writeErr: () => {},
|
|
20
|
+
outputError: () => {},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
13
23
|
|
|
14
24
|
registerCommands(program, runtimeApiKey, cliVersion);
|
|
15
25
|
|
|
@@ -18,13 +28,27 @@ const hasHelpFlag = parsedAuth.sanitizedArgs.includes("--help") || parsedAuth.sa
|
|
|
18
28
|
const hasVersionFlag = parsedAuth.sanitizedArgs.includes("--version") || parsedAuth.sanitizedArgs.includes("-V");
|
|
19
29
|
|
|
20
30
|
if (!argvHasCommand && !hasHelpFlag && !hasVersionFlag) {
|
|
21
|
-
if (runtimeApiKey) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
if (runtimeApiKey) {
|
|
32
|
+
printCliError(
|
|
33
|
+
new CliError("USAGE_ERROR", "Missing command. Provide a command such as 'me' or 'auth:login'."),
|
|
34
|
+
{ json: jsonMode },
|
|
35
|
+
);
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
} else {
|
|
38
|
+
program.outputHelp();
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
try {
|
|
42
|
+
await program.parseAsync(parseArgv);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error?.exitCode === 0) {
|
|
45
|
+
process.exitCode = 0;
|
|
46
|
+
} else {
|
|
47
|
+
printCliError(
|
|
48
|
+
new CliError("USAGE_ERROR", error?.message || "Invalid command usage."),
|
|
49
|
+
{ json: jsonMode },
|
|
50
|
+
);
|
|
51
|
+
process.exitCode = error?.exitCode || 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|