@nuelink/nuelink-cli 1.6.5 → 1.6.6
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 +6 -0
- package/CONTRIBUTING.md +7 -2
- package/README.md +28 -7
- package/package.json +4 -7
- package/scripts/check-pack.mjs +30 -0
- package/scripts/check-packed-package.mjs +60 -0
- package/src/commands.js +1 -1
- package/src/postPayload.js +2 -2
- package/test/cli.test.mjs +54 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.6.6
|
|
4
|
+
|
|
5
|
+
- Reject polls with missing or empty options before requests and dry-run previews; every poll requires a question, 2 to 4 options, and a supported period.
|
|
6
|
+
- Point package documentation and bug reports to the public Nuelink documentation and support pages; remove the inaccessible source-repository link.
|
|
7
|
+
- Include the package-check scripts in the npm package and verify their presence and execution after installation.
|
|
8
|
+
|
|
3
9
|
## 1.6.5
|
|
4
10
|
|
|
5
11
|
- Use minutes, with a minimum of 1, for delayed-comment values in post creation.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -50,11 +50,13 @@ Conventional commit style is recommended:
|
|
|
50
50
|
|
|
51
51
|
## Quality Gates
|
|
52
52
|
|
|
53
|
-
Run before pushing
|
|
53
|
+
Run before pushing from the `nuelink-cli/` source checkout. The package checks
|
|
54
|
+
are also shipped in the npm package for validation from its installed directory:
|
|
54
55
|
|
|
55
56
|
```bash
|
|
56
57
|
npm test
|
|
57
58
|
npm run check:pack
|
|
59
|
+
npm run check:pack:installed
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
## Code Style
|
|
@@ -88,6 +90,8 @@ When adding commands, include tests for:
|
|
|
88
90
|
|
|
89
91
|
## Reporting Bugs
|
|
90
92
|
|
|
93
|
+
Report bugs through [Nuelink support](https://nuelink.com/contact).
|
|
94
|
+
|
|
91
95
|
Include:
|
|
92
96
|
|
|
93
97
|
1. CLI version (`nuelink-cli --version`)
|
|
@@ -108,12 +112,13 @@ Provide:
|
|
|
108
112
|
## Release Process (Maintainers)
|
|
109
113
|
|
|
110
114
|
1. Ensure CI is passing.
|
|
111
|
-
2. Bump version in `package.json
|
|
115
|
+
2. Bump the version in `package.json` and `package-lock.json`, and add a matching changelog entry.
|
|
112
116
|
3. Validate with:
|
|
113
117
|
|
|
114
118
|
```bash
|
|
115
119
|
npm test
|
|
116
120
|
npm run check:pack
|
|
121
|
+
npm run check:pack:installed
|
|
117
122
|
```
|
|
118
123
|
|
|
119
124
|
4. Publish:
|
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@ Official command-line interface for the Nuelink Public API.
|
|
|
4
4
|
|
|
5
5
|
Published by the Nuelink organization as the scoped npm package `@nuelink/nuelink-cli`.
|
|
6
6
|
|
|
7
|
+
See the [CLI documentation](https://docs.nuelink.com/cli/) for usage and
|
|
8
|
+
[Nuelink support](https://nuelink.com/contact) for bug reports.
|
|
9
|
+
|
|
7
10
|
Use this CLI to manage brands, collections, automations, channels, media, and posts from local scripts, CI/CD pipelines, and terminal workflows.
|
|
8
11
|
|
|
9
12
|
## Features
|
|
@@ -15,6 +18,7 @@ Use this CLI to manage brands, collections, automations, channels, media, and po
|
|
|
15
18
|
- Dry-run request preview for mutation commands
|
|
16
19
|
- Strict local validation for common CLI input mistakes
|
|
17
20
|
- Built-in timeout support for safer production usage
|
|
21
|
+
- Redirect protection introduced in CLI 1.6.1, so API requests do not forward credentials or mutation bodies to redirect destinations
|
|
18
22
|
- Command coverage for key Nuelink Public API resources
|
|
19
23
|
|
|
20
24
|
## Requirements
|
|
@@ -333,12 +337,19 @@ is `comment.delay` and uses the same minutes unit.
|
|
|
333
337
|
|
|
334
338
|
Review each mutation preview, then repeat the same command without `--dry-run`
|
|
335
339
|
only when you intend to send it. `--dry-run` is supported for mutations; GET
|
|
336
|
-
commands reject it instead of silently suppressing the read.
|
|
337
|
-
|
|
338
|
-
|
|
340
|
+
commands reject it instead of silently suppressing the read. Before executing a
|
|
341
|
+
scheduled mutation, confirm an absolute date and time in the brand's timezone;
|
|
342
|
+
it must be at least 10 minutes ahead. Date filters and returned `postDate`
|
|
343
|
+
values are UTC.
|
|
339
344
|
|
|
340
345
|
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.
|
|
341
346
|
|
|
347
|
+
Polls require `--poll-question`, `--poll-options` with 2 to 4 choices, and
|
|
348
|
+
`--poll-period` set to `1d`, `3d`, or `7d`. Missing or empty options fail local
|
|
349
|
+
validation, including during `--dry-run`. JSON payloads use the same required
|
|
350
|
+
`question`, `options`, and `period` fields inside `poll`; `poll: null` is accepted
|
|
351
|
+
when a caption is supplied.
|
|
352
|
+
|
|
342
353
|
Preview a post lifecycle update or sensitive deletion before executing it:
|
|
343
354
|
|
|
344
355
|
```bash
|
|
@@ -353,7 +364,12 @@ nuelink-cli posts:move --brand-id 13493 --source-collection-id 33273 \
|
|
|
353
364
|
nuelink-cli posts:delete --brand-id 13493 --post-id 8801 --dry-run
|
|
354
365
|
```
|
|
355
366
|
|
|
356
|
-
`posts:update`
|
|
367
|
+
`posts:update` requires at least one of `--caption`, `--publish-mode`, or
|
|
368
|
+
`--queue-position`. A caption-only update does not require changing the
|
|
369
|
+
publishing mode. Captions must contain 1–3000 characters; caption edits are not
|
|
370
|
+
available for poll or published posts. Moving is atomic: all supplied posts (at
|
|
371
|
+
most 100) must belong to the source collection. Deletion is permanent and the
|
|
372
|
+
API rejects it unless sensitive AI actions are enabled for the account.
|
|
357
373
|
|
|
358
374
|
Published-post results are returned unchanged in `--json` mode. Each per-channel
|
|
359
375
|
record includes `likes`, `comments`, `shares`, `views`, `saves`, `engagement`,
|
|
@@ -440,6 +456,11 @@ npm test
|
|
|
440
456
|
|
|
441
457
|
### Package validation
|
|
442
458
|
|
|
459
|
+
Run these checks from the `nuelink-cli/` source checkout before a release.
|
|
460
|
+
The scripts are also included in the npm package and can run from the installed
|
|
461
|
+
package directory. The installed-package check creates a temporary package
|
|
462
|
+
installation and needs access to the npm registry.
|
|
463
|
+
|
|
443
464
|
```bash
|
|
444
465
|
npm run check:pack
|
|
445
466
|
npm run check:pack:installed
|
|
@@ -448,9 +469,9 @@ npm run check:pack:installed
|
|
|
448
469
|
## Release Checklist
|
|
449
470
|
|
|
450
471
|
1. Update the version in package.json and package-lock.json, and add a matching entry at the top of CHANGELOG.md
|
|
451
|
-
2.
|
|
452
|
-
3.
|
|
453
|
-
4.
|
|
472
|
+
2. From the source checkout, run `npm test`
|
|
473
|
+
3. From the source checkout, run `npm run check:pack`
|
|
474
|
+
4. From the source checkout, run `npm run check:pack:installed`
|
|
454
475
|
5. Publish locally with `npm publish --access public`
|
|
455
476
|
|
|
456
477
|
Provenance is available when publishing from a supported cloud CI provider. Do
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuelink/nuelink-cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
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
|
-
"
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/kreatinc/nuelink-cli.git"
|
|
10
|
-
},
|
|
11
|
-
"homepage": "https://github.com/kreatinc/nuelink-cli#readme",
|
|
7
|
+
"homepage": "https://docs.nuelink.com/cli/",
|
|
12
8
|
"bugs": {
|
|
13
|
-
"url": "https://
|
|
9
|
+
"url": "https://nuelink.com/contact"
|
|
14
10
|
},
|
|
15
11
|
"type": "module",
|
|
16
12
|
"main": "./src/cli.js",
|
|
@@ -26,6 +22,7 @@
|
|
|
26
22
|
"files": [
|
|
27
23
|
"src",
|
|
28
24
|
"test",
|
|
25
|
+
"scripts",
|
|
29
26
|
"CHANGELOG.md",
|
|
30
27
|
"README.md",
|
|
31
28
|
"CONTRIBUTING.md",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
const npmCli = process.env.npm_execpath;
|
|
7
|
+
const cacheDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "nuelink-cli-npm-cache-"));
|
|
8
|
+
|
|
9
|
+
if (!npmCli || !fs.existsSync(npmCli)) {
|
|
10
|
+
throw new Error("Run this check through `npm run check:pack`.");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const result = spawnSync(process.execPath, [npmCli, "pack", "--dry-run", "--json"], {
|
|
15
|
+
encoding: "utf8",
|
|
16
|
+
env: { ...process.env, CI: "1", npm_config_cache: cacheDirectory },
|
|
17
|
+
});
|
|
18
|
+
if (result.status !== 0) {
|
|
19
|
+
throw new Error(`npm pack --dry-run failed:\n${result.stdout}\n${result.stderr}`);
|
|
20
|
+
}
|
|
21
|
+
const [packed] = JSON.parse(result.stdout);
|
|
22
|
+
for (const script of ["scripts/check-pack.mjs", "scripts/check-packed-package.mjs"]) {
|
|
23
|
+
if (!packed.files.some((file) => file.path === script)) {
|
|
24
|
+
throw new Error(`Package advertises a check command but omits ${script}.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
process.stdout.write(result.stdout);
|
|
28
|
+
} finally {
|
|
29
|
+
fs.rmSync(cacheDirectory, { recursive: true, force: true });
|
|
30
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
const root = process.cwd();
|
|
7
|
+
const npmCli = process.env.npm_execpath;
|
|
8
|
+
const temporaryRoot = fs.mkdtempSync(path.join(os.tmpdir(), "nuelink-cli-pack-"));
|
|
9
|
+
const cacheDirectory = path.join(temporaryRoot, "npm-cache");
|
|
10
|
+
const packDirectory = path.join(temporaryRoot, "pack");
|
|
11
|
+
const installDirectory = path.join(temporaryRoot, "install");
|
|
12
|
+
|
|
13
|
+
if (!npmCli || !fs.existsSync(npmCli)) {
|
|
14
|
+
throw new Error("Run this check through `npm run check:pack:installed`.");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fs.mkdirSync(packDirectory);
|
|
18
|
+
fs.mkdirSync(installDirectory);
|
|
19
|
+
|
|
20
|
+
function runNpm(args, cwd = root) {
|
|
21
|
+
const result = spawnSync(process.execPath, [npmCli, ...args], {
|
|
22
|
+
cwd,
|
|
23
|
+
encoding: "utf8",
|
|
24
|
+
env: { ...process.env, CI: "1", npm_config_cache: cacheDirectory },
|
|
25
|
+
});
|
|
26
|
+
if (result.status !== 0) {
|
|
27
|
+
throw new Error(`npm ${args.join(" ")} failed:\n${result.stdout}\n${result.stderr}`);
|
|
28
|
+
}
|
|
29
|
+
return result.stdout;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const packed = JSON.parse(runNpm(["pack", "--json", "--pack-destination", packDirectory]));
|
|
34
|
+
const tarball = path.join(packDirectory, packed[0].filename);
|
|
35
|
+
runNpm(["install", tarball, "--ignore-scripts", "--prefix", installDirectory], installDirectory);
|
|
36
|
+
|
|
37
|
+
const installedPackage = path.join(installDirectory, "node_modules", "@nuelink", "nuelink-cli");
|
|
38
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(installedPackage, "package.json"), "utf8"));
|
|
39
|
+
const runtimeDependencies = Object.keys(manifest.dependencies || {}).sort();
|
|
40
|
+
if (JSON.stringify(runtimeDependencies) !== JSON.stringify(["chalk", "commander"])) {
|
|
41
|
+
throw new Error(`Unexpected runtime dependencies in the packed CLI: ${runtimeDependencies.join(", ")}.`);
|
|
42
|
+
}
|
|
43
|
+
if (!fs.existsSync(path.join(installedPackage, "CONTRIBUTING.md"))) {
|
|
44
|
+
throw new Error("Packed README links to CONTRIBUTING.md, but the package omitted that file.");
|
|
45
|
+
}
|
|
46
|
+
if (!fs.readFileSync(path.join(installedPackage, "CHANGELOG.md"), "utf8").includes(`## ${manifest.version}`)) {
|
|
47
|
+
throw new Error(`Packed changelog does not contain package version ${manifest.version}.`);
|
|
48
|
+
}
|
|
49
|
+
for (const script of ["scripts/check-pack.mjs", "scripts/check-packed-package.mjs"]) {
|
|
50
|
+
if (!fs.existsSync(path.join(installedPackage, script))) {
|
|
51
|
+
throw new Error(`Installed package omits advertised check script ${script}.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
runNpm(["test", "--prefix", installedPackage], installedPackage);
|
|
55
|
+
runNpm(["run", "check:pack", "--prefix", installedPackage], installedPackage);
|
|
56
|
+
|
|
57
|
+
console.log("Packed-package test passed (fresh install, npm test, and installed packaging scripts).");
|
|
58
|
+
} finally {
|
|
59
|
+
fs.rmSync(temporaryRoot, { recursive: true, force: true });
|
|
60
|
+
}
|
package/src/commands.js
CHANGED
|
@@ -890,7 +890,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
|
|
|
890
890
|
.option("--media-ids <ids>", "Comma-separated media IDs")
|
|
891
891
|
.option("--media-urls <urls>", "Comma-separated media URLs")
|
|
892
892
|
.option("--poll-question <text>", "Poll question")
|
|
893
|
-
.option("--poll-options <items>", "
|
|
893
|
+
.option("--poll-options <items>", "2 to 4 comma-separated options; required with a poll")
|
|
894
894
|
.option("--poll-period <value>", "Poll period (e.g. 3d)")
|
|
895
895
|
.option("--poll-correct-option-index <number>", "Zero-based poll correct option index")
|
|
896
896
|
.option("--poll-explanation <text>", "Poll explanation")
|
package/src/postPayload.js
CHANGED
|
@@ -276,10 +276,10 @@ function buildPostPayload(options) {
|
|
|
276
276
|
: options.caption === undefined
|
|
277
277
|
? undefined
|
|
278
278
|
: String(options.caption).trim();
|
|
279
|
-
if (hasPoll && (!poll.question ||
|
|
279
|
+
if (hasPoll && (!poll.question || pollOptions.length < 2 || !poll.period)) {
|
|
280
280
|
throw new Error("poll requires question, 2 to 4 options, and period.");
|
|
281
281
|
}
|
|
282
|
-
if (
|
|
282
|
+
if (pollOptions.length > 4) {
|
|
283
283
|
throw new Error("Polls allow at most four options.");
|
|
284
284
|
}
|
|
285
285
|
|
package/test/cli.test.mjs
CHANGED
|
@@ -1050,6 +1050,60 @@ test("posts:create builds full payload from options", async () => {
|
|
|
1050
1050
|
assert.equal(capture.body.platforms.googlemybusiness.uploadToPhotosSection, true);
|
|
1051
1051
|
});
|
|
1052
1052
|
|
|
1053
|
+
test("posts:create rejects missing, empty, or out-of-range poll options before preview or request", async () => {
|
|
1054
|
+
const homeDir = await setupTempHome();
|
|
1055
|
+
const invalidOptions = [[], ["--poll-options", ""], ["--poll-options", " , "],
|
|
1056
|
+
["--poll-options", "One"], ["--poll-options", "1,2,3,4,5"]];
|
|
1057
|
+
|
|
1058
|
+
for (const [index, options] of invalidOptions.entries()) {
|
|
1059
|
+
for (const dryRun of [false, true]) {
|
|
1060
|
+
const capturePath = path.join(homeDir, `capture-invalid-poll-${index}-${dryRun}.json`);
|
|
1061
|
+
const result = runCli({
|
|
1062
|
+
args: ["--json", ...(dryRun ? ["--dry-run"] : []), "posts:create",
|
|
1063
|
+
"--brand-id", "10", "--collection-id", "20",
|
|
1064
|
+
"--poll-question", "Which one?", "--poll-period", "1d", ...options],
|
|
1065
|
+
homeDir,
|
|
1066
|
+
capturePath,
|
|
1067
|
+
});
|
|
1068
|
+
const error = assertJsonError(result, "VALIDATION_ERROR");
|
|
1069
|
+
assert.match(error.message, /poll/i);
|
|
1070
|
+
await assert.rejects(readFile(capturePath, "utf8"));
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
test("posts:create previews polls with two or four options", async () => {
|
|
1076
|
+
const homeDir = await setupTempHome();
|
|
1077
|
+
for (const options of [["One", "Two"], ["One", "Two", "Three", "Four"]]) {
|
|
1078
|
+
const result = runCli({
|
|
1079
|
+
args: ["--dry-run", "posts:create", "--brand-id", "10", "--collection-id", "20",
|
|
1080
|
+
"--poll-question", "Which one?", "--poll-period", "1d", "--poll-options", options.join(",")],
|
|
1081
|
+
homeDir,
|
|
1082
|
+
capturePath: path.join(homeDir, `capture-valid-poll-${options.length}.json`),
|
|
1083
|
+
});
|
|
1084
|
+
assert.equal(result.status, 0, result.stderr);
|
|
1085
|
+
assert.deepEqual(JSON.parse(result.stdout).body.poll, { question: "Which one?", options, period: "1d" });
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
test("posts:add-json rejects polls with missing or empty options before preview or request", async () => {
|
|
1090
|
+
const homeDir = await setupTempHome();
|
|
1091
|
+
for (const options of [undefined, []]) {
|
|
1092
|
+
for (const dryRun of [false, true]) {
|
|
1093
|
+
const capturePath = path.join(homeDir, `capture-invalid-json-poll-${options ? "empty" : "missing"}-${dryRun}.json`);
|
|
1094
|
+
const result = runCli({
|
|
1095
|
+
args: ["--json", ...(dryRun ? ["--dry-run"] : []), "posts:add-json",
|
|
1096
|
+
"--brand-id", "10", "--collection-id", "20", "--payload", "-"],
|
|
1097
|
+
homeDir,
|
|
1098
|
+
capturePath,
|
|
1099
|
+
input: JSON.stringify({ publishMode: "DRAFT", poll: { question: "Which one?", period: "1d", options } }),
|
|
1100
|
+
});
|
|
1101
|
+
assertJsonError(result, "VALIDATION_ERROR");
|
|
1102
|
+
await assert.rejects(readFile(capturePath, "utf8"));
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1053
1107
|
test("posts:create defaults autoThreadText to true and accepts false override", async () => {
|
|
1054
1108
|
const homeDir = await setupTempHome();
|
|
1055
1109
|
|