figmanage 1.2.9 → 1.3.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.
Files changed (60) hide show
  1. package/README.md +10 -8
  2. package/dist/cli/analytics.js +3 -2
  3. package/dist/cli/branching.js +9 -3
  4. package/dist/cli/comments.js +10 -4
  5. package/dist/cli/components.js +21 -4
  6. package/dist/cli/compound-commands.js +13 -12
  7. package/dist/cli/export.js +3 -2
  8. package/dist/cli/files.js +14 -8
  9. package/dist/cli/helpers.d.ts +1 -0
  10. package/dist/cli/helpers.js +10 -0
  11. package/dist/cli/libraries.js +2 -1
  12. package/dist/cli/navigate.js +11 -10
  13. package/dist/cli/org.js +13 -12
  14. package/dist/cli/permissions.js +13 -7
  15. package/dist/cli/projects.js +12 -6
  16. package/dist/cli/reading.js +3 -2
  17. package/dist/cli/teams.js +9 -3
  18. package/dist/cli/variables.js +29 -7
  19. package/dist/cli/versions.js +3 -2
  20. package/dist/cli/webhooks.js +14 -4
  21. package/dist/helpers.d.ts +11 -0
  22. package/dist/helpers.js +41 -0
  23. package/dist/mcp.js +18 -6
  24. package/dist/operations/analytics.js +1 -1
  25. package/dist/operations/components.d.ts +8 -2
  26. package/dist/operations/components.js +4 -2
  27. package/dist/operations/compound-manager.js +8 -9
  28. package/dist/operations/compound.d.ts +3 -0
  29. package/dist/operations/compound.js +14 -8
  30. package/dist/operations/files.js +1 -1
  31. package/dist/operations/libraries.js +1 -1
  32. package/dist/operations/org.js +1 -1
  33. package/dist/operations/reading.js +2 -0
  34. package/dist/operations/teams.js +1 -1
  35. package/dist/operations/variables.js +11 -0
  36. package/dist/operations/webhooks.d.ts +4 -1
  37. package/dist/operations/webhooks.js +2 -1
  38. package/dist/tools/analytics.js +6 -5
  39. package/dist/tools/branching.js +7 -6
  40. package/dist/tools/comments.js +14 -9
  41. package/dist/tools/components.js +24 -15
  42. package/dist/tools/compound-manager.js +10 -7
  43. package/dist/tools/compound.js +34 -22
  44. package/dist/tools/export.js +6 -5
  45. package/dist/tools/files.js +13 -12
  46. package/dist/tools/libraries.js +6 -3
  47. package/dist/tools/navigate.js +29 -18
  48. package/dist/tools/org.js +25 -24
  49. package/dist/tools/permissions.js +14 -11
  50. package/dist/tools/projects.js +10 -9
  51. package/dist/tools/reading.js +11 -7
  52. package/dist/tools/register.d.ts +8 -2
  53. package/dist/tools/register.js +9 -14
  54. package/dist/tools/setup.d.ts +10 -0
  55. package/dist/tools/setup.js +181 -0
  56. package/dist/tools/teams.js +7 -6
  57. package/dist/tools/variables.js +12 -8
  58. package/dist/tools/versions.js +6 -5
  59. package/dist/tools/webhooks.js +15 -12
  60. package/package.json +1 -1
package/README.md CHANGED
@@ -49,23 +49,25 @@ figmanage runs as an MCP server for Claude, ChatGPT, Cursor, and other AI assist
49
49
 
50
50
  ```bash
51
51
  # Claude Code
52
- claude mcp add figmanage -- npx -y figmanage --mcp
52
+ claude mcp add figmanage -- npx -y figmanage
53
53
 
54
- # Claude Desktop / Cowork
55
- # Add to claude_desktop_config.json:
54
+ # Claude Desktop / Cursor / other clients
55
+ # Add to your MCP config:
56
56
  {
57
57
  "mcpServers": {
58
58
  "figmanage": {
59
59
  "command": "npx",
60
- "args": ["-y", "figmanage", "--mcp"]
60
+ "args": ["-y", "figmanage"]
61
61
  }
62
62
  }
63
63
  }
64
64
  ```
65
65
 
66
- Credentials are read from `~/.config/figmanage/` (set up via `figmanage login`). Env vars (`FIGMA_PAT`, `FIGMA_AUTH_COOKIE`, etc.) override the config file for backwards compatibility.
66
+ On first run, figmanage walks you through setup right in the conversation -- extracts your Chrome session cookie, asks you to create a PAT, and stores credentials locally. No env vars, no JSON editing, no separate terminal step.
67
67
 
68
- MCP mode exposes all 85 tools to the AI assistant. HTTP transport available via `--mcp --http <port>`.
68
+ If you prefer CLI setup or need to reconfigure: `npx figmanage login`.
69
+
70
+ Env vars (`FIGMA_PAT`, `FIGMA_AUTH_COOKIE`, etc.) override the config file for backwards compatibility. HTTP transport available via `--mcp --http <port>`.
69
71
 
70
72
  ### toolset presets (MCP only)
71
73
 
@@ -87,9 +89,9 @@ figmanage uses two Figma API surfaces:
87
89
  | Internal API | Session cookie | Workspace management, search, permissions, org admin, seats, billing |
88
90
  | Public API | Personal Access Token | Comments, export, file reading, components, versions, webhooks, variables |
89
91
 
90
- Cookie auth unlocks all 85 tools. PAT-only gives ~30 (reading, comments, export, components). Both together is recommended.
92
+ Both together give full access to all 85 tools. Cookie-only or PAT-only work but limit available tools.
91
93
 
92
- Auth resolution: env vars > config file > prompt to run `figmanage login`.
94
+ Auth resolution: env vars > config file > interactive setup (MCP) or `figmanage login` (CLI).
93
95
 
94
96
  ## commands
95
97
 
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { libraryUsage, componentUsage } from '../operations/analytics.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requireCookie } from './helpers.js';
5
6
  export function analyticsCommand() {
6
7
  const analytics = new Command('analytics')
@@ -20,7 +21,7 @@ export function analyticsCommand() {
20
21
  output(result, options);
21
22
  }
22
23
  catch (e) {
23
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
24
+ error(formatApiError(e));
24
25
  process.exit(1);
25
26
  }
26
27
  });
@@ -39,7 +40,7 @@ export function analyticsCommand() {
39
40
  output(result, options);
40
41
  }
41
42
  catch (e) {
42
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
43
+ error(formatApiError(e));
43
44
  process.exit(1);
44
45
  }
45
46
  });
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { listBranches, createBranch, deleteBranch } from '../operations/branching.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requireAuth, requireCookie } from './helpers.js';
5
6
  export function branchingCommand() {
6
7
  const branching = new Command('branches')
@@ -16,7 +17,7 @@ export function branchingCommand() {
16
17
  output(result, options);
17
18
  }
18
19
  catch (e) {
19
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
20
+ error(formatApiError(e));
20
21
  process.exit(1);
21
22
  }
22
23
  });
@@ -32,7 +33,7 @@ export function branchingCommand() {
32
33
  output(result, options);
33
34
  }
34
35
  catch (e) {
35
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
36
+ error(formatApiError(e));
36
37
  process.exit(1);
37
38
  }
38
39
  });
@@ -43,11 +44,16 @@ export function branchingCommand() {
43
44
  .action(async (branchKey, options) => {
44
45
  try {
45
46
  const config = requireCookie();
47
+ const { confirmAction } = await import('./helpers.js');
48
+ if (!await confirmAction(`Delete branch ${branchKey}?`)) {
49
+ console.log('Cancelled.');
50
+ return;
51
+ }
46
52
  await deleteBranch(config, { branch_key: branchKey });
47
53
  output({ archived: branchKey }, options);
48
54
  }
49
55
  catch (e) {
50
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
56
+ error(formatApiError(e));
51
57
  process.exit(1);
52
58
  }
53
59
  });
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { listComments, formatCommentsAsMarkdown, postComment, deleteComment, listCommentReactions, } from '../operations/comments.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requirePat } from './helpers.js';
5
6
  export function commentsCommand() {
6
7
  const comments = new Command('comments')
@@ -21,7 +22,7 @@ export function commentsCommand() {
21
22
  output(result, options);
22
23
  }
23
24
  catch (e) {
24
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
25
+ error(formatApiError(e));
25
26
  process.exit(1);
26
27
  }
27
28
  });
@@ -44,7 +45,7 @@ export function commentsCommand() {
44
45
  output(result, options);
45
46
  }
46
47
  catch (e) {
47
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
48
+ error(formatApiError(e));
48
49
  process.exit(1);
49
50
  }
50
51
  });
@@ -55,11 +56,16 @@ export function commentsCommand() {
55
56
  .action(async (fileKey, commentId, options) => {
56
57
  try {
57
58
  const config = requirePat();
59
+ const { confirmAction } = await import('./helpers.js');
60
+ if (!await confirmAction(`Delete comment ${commentId}? For top-level comments, the entire thread is removed.`)) {
61
+ console.log('Cancelled.');
62
+ return;
63
+ }
58
64
  await deleteComment(config, { file_key: fileKey, comment_id: commentId });
59
65
  output({ deleted: commentId }, options);
60
66
  }
61
67
  catch (e) {
62
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
68
+ error(formatApiError(e));
63
69
  process.exit(1);
64
70
  }
65
71
  });
@@ -77,7 +83,7 @@ export function commentsCommand() {
77
83
  output(result, options);
78
84
  }
79
85
  catch (e) {
80
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
86
+ error(formatApiError(e));
81
87
  process.exit(1);
82
88
  }
83
89
  });
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { listFileComponents, listFileStyles, listTeamComponents, listTeamStyles, } from '../operations/components.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requirePat } from './helpers.js';
5
6
  export function componentsCommand() {
6
7
  const components = new Command('components')
@@ -13,10 +14,14 @@ export function componentsCommand() {
13
14
  try {
14
15
  const config = requirePat();
15
16
  const result = await listFileComponents(config, { file_key: fileKey });
17
+ if (result.components.length === 0) {
18
+ console.log('No components found.');
19
+ return;
20
+ }
16
21
  output(result, options);
17
22
  }
18
23
  catch (e) {
19
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
24
+ error(formatApiError(e));
20
25
  process.exit(1);
21
26
  }
22
27
  });
@@ -28,10 +33,14 @@ export function componentsCommand() {
28
33
  try {
29
34
  const config = requirePat();
30
35
  const result = await listFileStyles(config, { file_key: fileKey });
36
+ if (result.styles.length === 0) {
37
+ console.log('No styles found.');
38
+ return;
39
+ }
31
40
  output(result, options);
32
41
  }
33
42
  catch (e) {
34
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
43
+ error(formatApiError(e));
35
44
  process.exit(1);
36
45
  }
37
46
  });
@@ -49,10 +58,14 @@ export function componentsCommand() {
49
58
  page_size: options.pageSize ? parseInt(options.pageSize, 10) : undefined,
50
59
  cursor: options.cursor,
51
60
  });
61
+ if (result.components.length === 0) {
62
+ console.log('No components found.');
63
+ return;
64
+ }
52
65
  output(result, options);
53
66
  }
54
67
  catch (e) {
55
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
68
+ error(formatApiError(e));
56
69
  process.exit(1);
57
70
  }
58
71
  });
@@ -70,10 +83,14 @@ export function componentsCommand() {
70
83
  page_size: options.pageSize ? parseInt(options.pageSize, 10) : undefined,
71
84
  cursor: options.cursor,
72
85
  });
86
+ if (result.styles.length === 0) {
87
+ console.log('No styles found.');
88
+ return;
89
+ }
73
90
  output(result, options);
74
91
  }
75
92
  catch (e) {
76
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
93
+ error(formatApiError(e));
77
94
  process.exit(1);
78
95
  }
79
96
  });
@@ -2,6 +2,7 @@ import { Command } from 'commander';
2
2
  import { fileSummary, workspaceOverview, openComments, cleanupStaleFiles, organizeProject, setupProjectStructure, seatOptimization, permissionAudit, branchCleanup, } from '../operations/compound.js';
3
3
  import { offboardUser, onboardUser, quarterlyDesignOpsReport, } from '../operations/compound-manager.js';
4
4
  import { output, error } from './format.js';
5
+ import { formatApiError } from '../helpers.js';
5
6
  import { requireAuth, requirePat, requireCookie, validateId, parsePositiveInt } from './helpers.js';
6
7
  // -- compound.ts tools --
7
8
  export function fileSummaryCommand() {
@@ -17,7 +18,7 @@ export function fileSummaryCommand() {
17
18
  output(result, options);
18
19
  }
19
20
  catch (e) {
20
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
21
+ error(formatApiError(e));
21
22
  process.exit(1);
22
23
  }
23
24
  });
@@ -33,7 +34,7 @@ export function workspaceOverviewCommand() {
33
34
  output(result, options);
34
35
  }
35
36
  catch (e) {
36
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
37
+ error(formatApiError(e));
37
38
  process.exit(1);
38
39
  }
39
40
  });
@@ -51,7 +52,7 @@ export function openCommentsCommand() {
51
52
  output(result, options);
52
53
  }
53
54
  catch (e) {
54
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
55
+ error(formatApiError(e));
55
56
  process.exit(1);
56
57
  }
57
58
  });
@@ -76,7 +77,7 @@ export function cleanupStaleFilesCommand() {
76
77
  output(result, options);
77
78
  }
78
79
  catch (e) {
79
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
80
+ error(formatApiError(e));
80
81
  process.exit(1);
81
82
  }
82
83
  });
@@ -100,7 +101,7 @@ export function organizeProjectCommand() {
100
101
  output(result, options);
101
102
  }
102
103
  catch (e) {
103
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
104
+ error(formatApiError(e));
104
105
  process.exit(1);
105
106
  }
106
107
  });
@@ -131,7 +132,7 @@ export function setupProjectStructureCommand() {
131
132
  output(result, options);
132
133
  }
133
134
  catch (e) {
134
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
135
+ error(formatApiError(e));
135
136
  process.exit(1);
136
137
  }
137
138
  });
@@ -153,7 +154,7 @@ export function seatOptimizationCommand() {
153
154
  output(result, options);
154
155
  }
155
156
  catch (e) {
156
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
157
+ error(formatApiError(e));
157
158
  process.exit(1);
158
159
  }
159
160
  });
@@ -181,7 +182,7 @@ export function permissionAuditCommand() {
181
182
  output(result, options);
182
183
  }
183
184
  catch (e) {
184
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
185
+ error(formatApiError(e));
185
186
  process.exit(1);
186
187
  }
187
188
  });
@@ -206,7 +207,7 @@ export function branchCleanupCommand() {
206
207
  output(result, options);
207
208
  }
208
209
  catch (e) {
209
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
210
+ error(formatApiError(e));
210
211
  process.exit(1);
211
212
  }
212
213
  });
@@ -230,7 +231,7 @@ export function offboardUserCommand() {
230
231
  output(result, options);
231
232
  }
232
233
  catch (e) {
233
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
234
+ error(formatApiError(e));
234
235
  process.exit(1);
235
236
  }
236
237
  });
@@ -265,7 +266,7 @@ export function onboardUserCommand() {
265
266
  output(result, options);
266
267
  }
267
268
  catch (e) {
268
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
269
+ error(formatApiError(e));
269
270
  process.exit(1);
270
271
  }
271
272
  });
@@ -283,7 +284,7 @@ export function quarterlyReportCommand() {
283
284
  output(result, options);
284
285
  }
285
286
  catch (e) {
286
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
287
+ error(formatApiError(e));
287
288
  process.exit(1);
288
289
  }
289
290
  });
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { exportNodes, getImageFills } from '../operations/export.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requirePat } from './helpers.js';
5
6
  export function exportCommand() {
6
7
  const exp = new Command('export')
@@ -23,7 +24,7 @@ export function exportCommand() {
23
24
  output(result, options);
24
25
  }
25
26
  catch (e) {
26
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
27
+ error(formatApiError(e));
27
28
  process.exit(1);
28
29
  }
29
30
  });
@@ -42,7 +43,7 @@ export function exportCommand() {
42
43
  output(result, options);
43
44
  }
44
45
  catch (e) {
45
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
46
+ error(formatApiError(e));
46
47
  process.exit(1);
47
48
  }
48
49
  });
package/dist/cli/files.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { createFile, renameFile, moveFiles, duplicateFile, trashFiles, restoreFiles, favoriteFile, setLinkAccess, } from '../operations/files.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requireCookie } from './helpers.js';
5
6
  export function filesCommand() {
6
7
  const files = new Command('files')
@@ -22,7 +23,7 @@ export function filesCommand() {
22
23
  output(result, options);
23
24
  }
24
25
  catch (e) {
25
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
26
+ error(formatApiError(e));
26
27
  process.exit(1);
27
28
  }
28
29
  });
@@ -38,7 +39,7 @@ export function filesCommand() {
38
39
  output({ renamed: fileKey, name: options.name }, options);
39
40
  }
40
41
  catch (e) {
41
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
42
+ error(formatApiError(e));
42
43
  process.exit(1);
43
44
  }
44
45
  });
@@ -58,7 +59,7 @@ export function filesCommand() {
58
59
  output(result, options);
59
60
  }
60
61
  catch (e) {
61
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
62
+ error(formatApiError(e));
62
63
  process.exit(1);
63
64
  }
64
65
  });
@@ -77,7 +78,7 @@ export function filesCommand() {
77
78
  output(result, options);
78
79
  }
79
80
  catch (e) {
80
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
81
+ error(formatApiError(e));
81
82
  process.exit(1);
82
83
  }
83
84
  });
@@ -89,11 +90,16 @@ export function filesCommand() {
89
90
  .action(async (options) => {
90
91
  try {
91
92
  const config = requireCookie();
93
+ const { confirmAction } = await import('./helpers.js');
94
+ if (!await confirmAction(`Trash ${options.fileKeys.length} file(s)?`)) {
95
+ console.log('Cancelled.');
96
+ return;
97
+ }
92
98
  const result = await trashFiles(config, { file_keys: options.fileKeys });
93
99
  output(result, options);
94
100
  }
95
101
  catch (e) {
96
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
102
+ error(formatApiError(e));
97
103
  process.exit(1);
98
104
  }
99
105
  });
@@ -109,7 +115,7 @@ export function filesCommand() {
109
115
  output(result, options);
110
116
  }
111
117
  catch (e) {
112
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
118
+ error(formatApiError(e));
113
119
  process.exit(1);
114
120
  }
115
121
  });
@@ -128,7 +134,7 @@ export function filesCommand() {
128
134
  output(result, options);
129
135
  }
130
136
  catch (e) {
131
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
137
+ error(formatApiError(e));
132
138
  process.exit(1);
133
139
  }
134
140
  });
@@ -147,7 +153,7 @@ export function filesCommand() {
147
153
  output(result, options);
148
154
  }
149
155
  catch (e) {
150
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
156
+ error(formatApiError(e));
151
157
  process.exit(1);
152
158
  }
153
159
  });
@@ -4,4 +4,5 @@ export declare function parsePositiveInt(value: string, label: string, fallback:
4
4
  export declare function requireAuth(): AuthConfig;
5
5
  export declare function requirePat(): AuthConfig;
6
6
  export declare function requireCookie(): AuthConfig;
7
+ export declare function confirmAction(message: string): Promise<boolean>;
7
8
  //# sourceMappingURL=helpers.d.ts.map
@@ -1,3 +1,4 @@
1
+ import * as readline from 'node:readline';
1
2
  import { loadAuthConfig, hasPat, hasCookie } from '../auth/client.js';
2
3
  import { error } from './format.js';
3
4
  const ID_PATTERN = /^[\w.:-]+$/;
@@ -40,4 +41,13 @@ export function requireCookie() {
40
41
  }
41
42
  return config;
42
43
  }
44
+ export async function confirmAction(message) {
45
+ const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
46
+ return new Promise((resolve) => {
47
+ rl.question(`${message} [y/N] `, (answer) => {
48
+ rl.close();
49
+ resolve(answer.trim().toLowerCase() === 'y');
50
+ });
51
+ });
52
+ }
43
53
  //# sourceMappingURL=helpers.js.map
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { listOrgLibraries } from '../operations/libraries.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requireCookie } from './helpers.js';
5
6
  export function librariesCommand() {
6
7
  const libraries = new Command('libraries')
@@ -17,7 +18,7 @@ export function librariesCommand() {
17
18
  output(result, options);
18
19
  }
19
20
  catch (e) {
20
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
21
+ error(formatApiError(e));
21
22
  process.exit(1);
22
23
  }
23
24
  });
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { checkAuthStatus, listOrgs, switchOrg, listTeams, listProjects, listFiles, listRecentFiles, search, getFileInfo, listFavorites, } from '../operations/navigate.js';
3
3
  import { output, error } from './format.js';
4
+ import { formatApiError } from '../helpers.js';
4
5
  import { requireAuth, requireCookie } from './helpers.js';
5
6
  export function navigateCommand() {
6
7
  const nav = new Command('navigate')
@@ -21,7 +22,7 @@ export function navigateCommand() {
21
22
  }
22
23
  }
23
24
  catch (e) {
24
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
25
+ error(formatApiError(e));
25
26
  process.exit(1);
26
27
  }
27
28
  });
@@ -40,7 +41,7 @@ export function navigateCommand() {
40
41
  output(orgs, options);
41
42
  }
42
43
  catch (e) {
43
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
44
+ error(formatApiError(e));
44
45
  process.exit(1);
45
46
  }
46
47
  });
@@ -58,7 +59,7 @@ export function navigateCommand() {
58
59
  }, options);
59
60
  }
60
61
  catch (e) {
61
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
62
+ error(formatApiError(e));
62
63
  process.exit(1);
63
64
  }
64
65
  });
@@ -73,7 +74,7 @@ export function navigateCommand() {
73
74
  output(teams, options);
74
75
  }
75
76
  catch (e) {
76
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
77
+ error(formatApiError(e));
77
78
  process.exit(1);
78
79
  }
79
80
  });
@@ -88,7 +89,7 @@ export function navigateCommand() {
88
89
  output(projects, options);
89
90
  }
90
91
  catch (e) {
91
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
92
+ error(formatApiError(e));
92
93
  process.exit(1);
93
94
  }
94
95
  });
@@ -109,7 +110,7 @@ export function navigateCommand() {
109
110
  output(result, options);
110
111
  }
111
112
  catch (e) {
112
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
113
+ error(formatApiError(e));
113
114
  process.exit(1);
114
115
  }
115
116
  });
@@ -124,7 +125,7 @@ export function navigateCommand() {
124
125
  output(files, options);
125
126
  }
126
127
  catch (e) {
127
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
128
+ error(formatApiError(e));
128
129
  process.exit(1);
129
130
  }
130
131
  });
@@ -149,7 +150,7 @@ export function navigateCommand() {
149
150
  output(results, options);
150
151
  }
151
152
  catch (e) {
152
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
153
+ error(formatApiError(e));
153
154
  process.exit(1);
154
155
  }
155
156
  });
@@ -164,7 +165,7 @@ export function navigateCommand() {
164
165
  output(info, options);
165
166
  }
166
167
  catch (e) {
167
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
168
+ error(formatApiError(e));
168
169
  process.exit(1);
169
170
  }
170
171
  });
@@ -183,7 +184,7 @@ export function navigateCommand() {
183
184
  output(favorites, options);
184
185
  }
185
186
  catch (e) {
186
- error(e.response?.status ? `API error: ${e.response.status}` : e.message);
187
+ error(formatApiError(e));
187
188
  process.exit(1);
188
189
  }
189
190
  });