@ysicing/plane-cli 1.0.0 → 1.0.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ysicing/plane-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "description": "Node.js CLI for managing Plane via the external API",
6
6
  "license": "UNLICENSED",
@@ -49,7 +49,7 @@ function resolveWorkspaceToSave({ explicitWorkspace, existingWorkspace, userWork
49
49
  export async function runAuthCommand(args, context) {
50
50
  const [subcommand, ...rest] = args;
51
51
 
52
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
52
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
53
53
  printHelp();
54
54
  return;
55
55
  }
@@ -58,7 +58,7 @@ export async function runAuthCommand(args, context) {
58
58
  throw new CliError(`Unknown auth subcommand: ${subcommand}`);
59
59
  }
60
60
 
61
- if (rest.includes("--help") || rest.includes("help")) {
61
+ if (rest.includes("--help") || rest.includes("-h") || rest.includes("help")) {
62
62
  printHelp();
63
63
  return;
64
64
  }
@@ -1,6 +1,6 @@
1
1
  import { loadConfig, maskApiKey, resolveConfigPath, saveConfig } from "../core/config.js";
2
2
  import { CliError } from "../core/errors.js";
3
- import { parseCommandArgs } from "../core/options.js";
3
+ import { parseCommandArgs, pickDefined } from "../core/options.js";
4
4
  import { printData } from "../core/output.js";
5
5
 
6
6
  function configSnapshot(config, path) {
@@ -25,7 +25,7 @@ export async function runConfigCommand(args, context) {
25
25
  const [subcommand = "list", ...rest] = args;
26
26
  const path = resolveConfigPath();
27
27
 
28
- if (subcommand === "--help" || subcommand === "help") {
28
+ if (subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
29
29
  printHelp();
30
30
  return;
31
31
  }
@@ -37,6 +37,11 @@ export async function runConfigCommand(args, context) {
37
37
  }
38
38
 
39
39
  if (subcommand === "get") {
40
+ if (rest.includes("--help") || rest.includes("-h") || rest.includes("help")) {
41
+ printHelp();
42
+ return;
43
+ }
44
+
40
45
  const [key] = rest;
41
46
  const config = await loadConfig();
42
47
  const snapshot = configSnapshot(config, path);
@@ -55,6 +60,11 @@ export async function runConfigCommand(args, context) {
55
60
  }
56
61
 
57
62
  if (subcommand === "set") {
63
+ if (rest.includes("--help") || rest.includes("-h") || rest.includes("help")) {
64
+ printHelp();
65
+ return;
66
+ }
67
+
58
68
  const parsed = parseCommandArgs(
59
69
  rest,
60
70
  {
@@ -65,11 +75,11 @@ export async function runConfigCommand(args, context) {
65
75
  false
66
76
  );
67
77
 
68
- const update = {
78
+ const update = pickDefined({
69
79
  baseUrl: parsed.values["base-url"],
70
80
  apiKey: parsed.values["api-key"],
71
81
  workspace: parsed.values.workspace,
72
- };
82
+ });
73
83
 
74
84
  if (!update.baseUrl && !update.apiKey && !update.workspace) {
75
85
  throw new CliError("Nothing to update. Pass at least one of --base-url, --api-key, or --workspace.");
@@ -8,6 +8,10 @@ import { printData, printTable } from "../core/output.js";
8
8
  import { basename, extname } from "node:path";
9
9
  import { readFile, stat } from "node:fs/promises";
10
10
 
11
+ function hasHelpFlag(args) {
12
+ return args.includes("--help") || args.includes("-h") || args.includes("help");
13
+ }
14
+
11
15
  function renderIssueList(data) {
12
16
  const rows = Array.isArray(data) ? data : data.results || [];
13
17
  printTable(rows, [
@@ -294,7 +298,12 @@ function printHelp() {
294
298
  async function runIssueLabelsCommand(issueClient, args, context) {
295
299
  const [subcommand, ...rest] = args;
296
300
 
297
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
301
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
302
+ printHelp();
303
+ return;
304
+ }
305
+
306
+ if (hasHelpFlag(rest)) {
298
307
  printHelp();
299
308
  return;
300
309
  }
@@ -353,7 +362,12 @@ async function runIssueLabelsCommand(issueClient, args, context) {
353
362
  async function runIssueCommentsCommand(issueClient, args, context) {
354
363
  const [subcommand, ...rest] = args;
355
364
 
356
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
365
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
366
+ printHelp();
367
+ return;
368
+ }
369
+
370
+ if (hasHelpFlag(rest)) {
357
371
  printHelp();
358
372
  return;
359
373
  }
@@ -439,7 +453,12 @@ async function runIssueCommentsCommand(issueClient, args, context) {
439
453
  async function runIssueActivitiesCommand(issueClient, args, context) {
440
454
  const [subcommand, ...rest] = args;
441
455
 
442
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
456
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
457
+ printHelp();
458
+ return;
459
+ }
460
+
461
+ if (hasHelpFlag(rest)) {
443
462
  printHelp();
444
463
  return;
445
464
  }
@@ -478,7 +497,12 @@ async function runIssueActivitiesCommand(issueClient, args, context) {
478
497
  async function runIssueLinksCommand(issueClient, args, context) {
479
498
  const [subcommand, ...rest] = args;
480
499
 
481
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
500
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
501
+ printHelp();
502
+ return;
503
+ }
504
+
505
+ if (hasHelpFlag(rest)) {
482
506
  printHelp();
483
507
  return;
484
508
  }
@@ -553,7 +577,12 @@ async function runIssueLinksCommand(issueClient, args, context) {
553
577
  async function runIssueRelationsCommand(issueClient, args, context) {
554
578
  const [subcommand, ...rest] = args;
555
579
 
556
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
580
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
581
+ printHelp();
582
+ return;
583
+ }
584
+
585
+ if (hasHelpFlag(rest)) {
557
586
  printHelp();
558
587
  return;
559
588
  }
@@ -625,7 +654,12 @@ async function uploadAttachmentBinary(uploadData, filePath, fileName, mimeType)
625
654
  async function runIssueAttachmentsCommand(issueClient, args, context) {
626
655
  const [subcommand, ...rest] = args;
627
656
 
628
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
657
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
658
+ printHelp();
659
+ return;
660
+ }
661
+
662
+ if (hasHelpFlag(rest)) {
629
663
  printHelp();
630
664
  return;
631
665
  }
@@ -699,7 +733,12 @@ async function runIssueAttachmentsCommand(issueClient, args, context) {
699
733
  export async function runIssueCommand(args, context) {
700
734
  const [subcommand, ...rest] = args;
701
735
 
702
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
736
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
737
+ printHelp();
738
+ return;
739
+ }
740
+
741
+ if (hasHelpFlag(rest)) {
703
742
  printHelp();
704
743
  return;
705
744
  }
@@ -5,7 +5,7 @@ import { PlaneClient } from "../core/http.js";
5
5
  import { printData } from "../core/output.js";
6
6
 
7
7
  export async function runMeCommand(args, context) {
8
- if (args.includes("--help") || args.includes("help")) {
8
+ if (args.includes("--help") || args.includes("-h") || args.includes("help")) {
9
9
  console.log("Usage:\n plane me");
10
10
  return;
11
11
  }
@@ -5,6 +5,10 @@ import { PlaneClient } from "../core/http.js";
5
5
  import { ensureValue, parseCommandArgs, pickDefined } from "../core/options.js";
6
6
  import { printData, printTable } from "../core/output.js";
7
7
 
8
+ function hasHelpFlag(args) {
9
+ return args.includes("--help") || args.includes("-h") || args.includes("help");
10
+ }
11
+
8
12
  function createProjectRender(data) {
9
13
  const rows = Array.isArray(data) ? data : data.results || [];
10
14
  printTable(rows, [
@@ -128,7 +132,12 @@ function printHelp() {
128
132
  async function runProjectMembersCommand(projectClient, args, context) {
129
133
  const [subcommand, ...rest] = args;
130
134
 
131
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
135
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
136
+ printHelp();
137
+ return;
138
+ }
139
+
140
+ if (hasHelpFlag(rest)) {
132
141
  printHelp();
133
142
  return;
134
143
  }
@@ -189,7 +198,12 @@ async function runProjectMembersCommand(projectClient, args, context) {
189
198
  async function runProjectFeaturesCommand(projectClient, args, context) {
190
199
  const [subcommand, ...rest] = args;
191
200
 
192
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
201
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
202
+ printHelp();
203
+ return;
204
+ }
205
+
206
+ if (hasHelpFlag(rest)) {
193
207
  printHelp();
194
208
  return;
195
209
  }
@@ -270,7 +284,12 @@ async function runProjectFeaturesCommand(projectClient, args, context) {
270
284
  export async function runProjectCommand(args, context) {
271
285
  const [subcommand, ...rest] = args;
272
286
 
273
- if (!subcommand || subcommand === "--help" || subcommand === "help") {
287
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
288
+ printHelp();
289
+ return;
290
+ }
291
+
292
+ if (hasHelpFlag(rest)) {
274
293
  printHelp();
275
294
  return;
276
295
  }
@@ -22,12 +22,12 @@ function workspaceRows(config) {
22
22
  export async function runWorkspaceCommand(args, context) {
23
23
  const [subcommand = "ls", ...rest] = args;
24
24
 
25
- if (subcommand === "--help" || subcommand === "help") {
25
+ if (subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
26
26
  printHelp();
27
27
  return;
28
28
  }
29
29
 
30
- if (rest.includes("--help") || rest.includes("help")) {
30
+ if (rest.includes("--help") || rest.includes("-h") || rest.includes("help")) {
31
31
  printHelp();
32
32
  return;
33
33
  }
@@ -51,6 +51,9 @@ export async function loadConfig() {
51
51
 
52
52
  try {
53
53
  const raw = await readFile(configPath, "utf8");
54
+ if (!raw.trim()) {
55
+ return {};
56
+ }
54
57
  return sanitizeConfig(JSON.parse(raw));
55
58
  } catch (error) {
56
59
  if (error && error.code === "ENOENT") {