@nuelink/nuelink-cli 1.6.4 → 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 CHANGED
@@ -1,5 +1,15 @@
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
+
9
+ ## 1.6.5
10
+
11
+ - Use minutes, with a minimum of 1, for delayed-comment values in post creation.
12
+
3
13
  ## 1.6.4
4
14
 
5
15
  - Default `posts:create --auto-thread-text` to true, with false available to disable automatic splitting.
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
@@ -327,14 +331,25 @@ nuelink-cli posts:create \
327
331
  --dry-run
328
332
  ```
329
333
 
334
+ `--comment-delay` is measured in minutes after publishing and must be a positive
335
+ integer (minimum `1`). Provide it together with `--comment`; the JSON/API field
336
+ is `comment.delay` and uses the same minutes unit.
337
+
330
338
  Review each mutation preview, then repeat the same command without `--dry-run`
331
339
  only when you intend to send it. `--dry-run` is supported for mutations; GET
332
- commands reject it instead of silently suppressing the read. Post creation and
333
- update schedule values are brand-local and must be at least 10 minutes ahead;
334
- date filters and returned `postDate` values are UTC.
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.
335
344
 
336
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.
337
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
+
338
353
  Preview a post lifecycle update or sensitive deletion before executing it:
339
354
 
340
355
  ```bash
@@ -349,7 +364,12 @@ nuelink-cli posts:move --brand-id 13493 --source-collection-id 33273 \
349
364
  nuelink-cli posts:delete --brand-id 13493 --post-id 8801 --dry-run
350
365
  ```
351
366
 
352
- `posts:update` accepts `--caption` (1–3000 characters) alongside or instead of a scheduling change. Caption edits are not available for poll or published posts. Moving is atomic: all supplied posts (at most 100) must belong to the source collection. Deletion is permanent and the API rejects it unless sensitive AI actions are enabled for the account.
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.
353
373
 
354
374
  Published-post results are returned unchanged in `--json` mode. Each per-channel
355
375
  record includes `likes`, `comments`, `shares`, `views`, `saves`, `engagement`,
@@ -436,6 +456,11 @@ npm test
436
456
 
437
457
  ### Package validation
438
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
+
439
464
  ```bash
440
465
  npm run check:pack
441
466
  npm run check:pack:installed
@@ -444,9 +469,9 @@ npm run check:pack:installed
444
469
  ## Release Checklist
445
470
 
446
471
  1. Update the version in package.json and package-lock.json, and add a matching entry at the top of CHANGELOG.md
447
- 2. Run `npm test`
448
- 3. Run `npm run check:pack`
449
- 4. Run `npm run check:pack:installed`
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`
450
475
  5. Publish locally with `npm publish --access public`
451
476
 
452
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.4",
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
- "repository": {
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://github.com/kreatinc/nuelink-cli/issues"
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
@@ -886,11 +886,11 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
886
886
  .option("--scheduled-at <value>", "Publish datetime (YYYY-MM-DD HH:mm:ss) or null")
887
887
  .option("--post-as-story <boolean>", "Post as story: true/false")
888
888
  .option("--comment <text>", "First comment")
889
- .option("--comment-delay <seconds>", "First comment delay seconds")
889
+ .option("--comment-delay <minutes>", "First comment delay in minutes (minimum 1)")
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>", "Comma-separated poll options")
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")
@@ -2,6 +2,7 @@ import {
2
2
  parseBooleanStrict,
3
3
  parseJsonString,
4
4
  parseOptionalNonNegativeInteger,
5
+ parseOptionalPositiveInteger,
5
6
  splitCsv,
6
7
  validateHttpUrl,
7
8
  validatePollOptions,
@@ -275,10 +276,10 @@ function buildPostPayload(options) {
275
276
  : options.caption === undefined
276
277
  ? undefined
277
278
  : String(options.caption).trim();
278
- if (hasPoll && (!poll.question || poll.options?.length < 2 || !poll.period)) {
279
+ if (hasPoll && (!poll.question || pollOptions.length < 2 || !poll.period)) {
279
280
  throw new Error("poll requires question, 2 to 4 options, and period.");
280
281
  }
281
- if (poll.options?.length > 4) {
282
+ if (pollOptions.length > 4) {
282
283
  throw new Error("Polls allow at most four options.");
283
284
  }
284
285
 
@@ -297,8 +298,8 @@ function buildPostPayload(options) {
297
298
  ? {
298
299
  comment: {
299
300
  comment: options.comment,
300
- ...(parseOptionalNonNegativeInteger(options.commentDelay, "comment-delay") !== undefined
301
- ? { delay: parseOptionalNonNegativeInteger(options.commentDelay, "comment-delay") }
301
+ ...(parseOptionalPositiveInteger(options.commentDelay, "comment-delay") !== undefined
302
+ ? { delay: parseOptionalPositiveInteger(options.commentDelay, "comment-delay") }
302
303
  : {}),
303
304
  },
304
305
  }
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
 
@@ -1529,6 +1583,28 @@ test("posts:create requires comment and comment-delay as a pair", async () => {
1529
1583
  }
1530
1584
  });
1531
1585
 
1586
+ test("posts:create requires a positive comment delay in minutes", async () => {
1587
+ const homeDir = await setupTempHome();
1588
+ const capturePath = path.join(homeDir, "capture-comment-zero.json");
1589
+ const result = runCli({
1590
+ args: [
1591
+ "posts:create",
1592
+ "--brand-id", "1",
1593
+ "--collection-id", "2",
1594
+ "--caption", "Post body",
1595
+ "--comment", "First comment",
1596
+ "--comment-delay", "0",
1597
+ "--dry-run",
1598
+ ],
1599
+ homeDir,
1600
+ capturePath,
1601
+ });
1602
+
1603
+ assert.equal(result.status, 1);
1604
+ assert.match(result.stderr, /Invalid comment-delay\. Expected a positive integer/);
1605
+ await assert.rejects(readFile(capturePath, "utf8"));
1606
+ });
1607
+
1532
1608
  test("JSON mode without a command returns a structured usage error", async () => {
1533
1609
  const homeDir = await setupTempHome();
1534
1610
  const result = runCli({