@kolatts/pncli 1.25.1 → 2.0.0

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.
@@ -1,141 +1,14 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ ExitCode,
4
+ PncliError,
5
+ debug,
6
+ isDebugEnabled,
7
+ log
8
+ } from "./chunk-HZF6WQPU.js";
2
9
 
3
10
  // src/lib/http.ts
4
- import fs2 from "fs";
5
-
6
- // src/lib/errors.ts
7
- var PncliError = class extends Error {
8
- status;
9
- url;
10
- constructor(message, status = 1, url) {
11
- super(message);
12
- this.name = "PncliError";
13
- this.status = status;
14
- this.url = url;
15
- }
16
- };
17
-
18
- // src/lib/exitCodes.ts
19
- var ExitCode = {
20
- SUCCESS: 0,
21
- GENERAL_ERROR: 1,
22
- USAGE_ERROR: 2,
23
- NETWORK_ERROR: 69,
24
- // EX_UNAVAILABLE from sysexits.h
25
- AUTH_ERROR: 77,
26
- // EX_NOPERM from sysexits.h
27
- CONFIG_ERROR: 78
28
- // EX_CONFIG from sysexits.h
29
- };
30
- function exitCodeFromStatus(httpStatus) {
31
- if (httpStatus === 401 || httpStatus === 403) return ExitCode.AUTH_ERROR;
32
- if (httpStatus === 0) return ExitCode.NETWORK_ERROR;
33
- return ExitCode.GENERAL_ERROR;
34
- }
35
-
36
- // src/lib/output.ts
37
11
  import fs from "fs";
38
- import chalk from "chalk";
39
- var globalOptions = { pretty: false, verbose: false, debug: false };
40
- var globalUser = { email: void 0, userId: void 0 };
41
- var outputFile;
42
- function setGlobalOptions(opts) {
43
- globalOptions = { pretty: opts.pretty, verbose: opts.verbose, debug: opts.debug ?? false };
44
- outputFile = opts.outputFile;
45
- }
46
- function isDebugEnabled() {
47
- return globalOptions.debug;
48
- }
49
- function setGlobalUser(user) {
50
- globalUser = user;
51
- }
52
- function buildMeta(service, action, startTime, overrides) {
53
- return {
54
- service,
55
- action,
56
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
57
- duration_ms: Date.now() - startTime,
58
- user: globalUser.email ?? globalUser.userId ? globalUser : void 0,
59
- overrides: overrides && overrides.length > 0 ? overrides : void 0
60
- };
61
- }
62
- function writeToFile(filePath, content) {
63
- try {
64
- fs.writeFileSync(filePath, content, "utf8");
65
- } catch (writeErr) {
66
- process.stderr.write(
67
- `Warning: could not write to output file "${filePath}": ${writeErr.message}
68
- `
69
- );
70
- process.exitCode = ExitCode.GENERAL_ERROR;
71
- }
72
- }
73
- function success(data, service, action, startTime, overrides) {
74
- const envelope = {
75
- ok: true,
76
- data,
77
- meta: buildMeta(service, action, startTime, overrides)
78
- };
79
- const out = (globalOptions.pretty ? JSON.stringify(envelope, null, 2) : JSON.stringify(envelope)) + "\n";
80
- if (outputFile) {
81
- writeToFile(outputFile, out);
82
- } else {
83
- process.stdout.write(out);
84
- }
85
- }
86
- function fail(err, service, action, startTime) {
87
- const errorDetail = {
88
- status: err instanceof PncliError ? err.status : 1,
89
- message: err instanceof Error ? err.message : String(err),
90
- url: err instanceof PncliError ? err.url ?? null : null
91
- };
92
- const envelope = {
93
- ok: false,
94
- error: errorDetail,
95
- meta: buildMeta(service, action, startTime)
96
- };
97
- const msg = globalOptions.pretty ? chalk.red("\u2717 Error: ") + errorDetail.message : null;
98
- if (msg) process.stderr.write(msg + "\n");
99
- const output = (globalOptions.pretty ? JSON.stringify(envelope, null, 2) : JSON.stringify(envelope)) + "\n";
100
- const exitCode = err instanceof PncliError ? exitCodeFromStatus(err.status) : ExitCode.GENERAL_ERROR;
101
- if (outputFile) {
102
- writeToFile(outputFile, output);
103
- } else {
104
- try {
105
- fs.writeSync(process.stdout.fd, output);
106
- } catch (writeErr) {
107
- if (writeErr.code !== "EPIPE") throw writeErr;
108
- }
109
- }
110
- process.exitCode = exitCode;
111
- throw new PncliError(errorDetail.message, errorDetail.status);
112
- }
113
- function writeRawOutput(content) {
114
- if (outputFile) {
115
- writeToFile(outputFile, content);
116
- } else {
117
- process.stdout.write(content);
118
- }
119
- }
120
- function log(message) {
121
- if (globalOptions.verbose) {
122
- process.stderr.write(
123
- (globalOptions.pretty ? chalk.gray("\u25B8 ") : "") + message + "\n"
124
- );
125
- }
126
- }
127
- function debug(message) {
128
- if (globalOptions.debug) {
129
- process.stderr.write(
130
- (globalOptions.pretty ? chalk.cyan("\u2B21 ") : "") + message + "\n"
131
- );
132
- }
133
- }
134
- function warn(message) {
135
- process.stderr.write(
136
- (globalOptions.pretty ? chalk.yellow("\u26A0 ") : "") + message + "\n"
137
- );
138
- }
139
12
 
140
13
  // src/lib/adoFetch.ts
141
14
  async function buildAdoFetcher(config) {
@@ -237,7 +110,7 @@ function getApiKeyClientId(apiKey) {
237
110
  }
238
111
 
239
112
  // src/lib/http.ts
240
- var SENSITIVE_HEADERS = /* @__PURE__ */ new Set(["authorization", "api-key"]);
113
+ var SENSITIVE_HEADERS = /* @__PURE__ */ new Set(["authorization", "api-key", "x-figma-token"]);
241
114
  function redactHeaders(headers) {
242
115
  if (!headers) return {};
243
116
  let entries;
@@ -263,6 +136,9 @@ function buildUrl(base, path, params) {
263
136
  }
264
137
  }
265
138
  }
139
+ if (url.search) {
140
+ url.search = url.search.replace(/%2C/gi, ",");
141
+ }
266
142
  return url.toString();
267
143
  }
268
144
  async function fetchWithTimeout(url, init, timeoutMs, fetcher = fetch) {
@@ -404,7 +280,7 @@ var HttpClient = class {
404
280
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
405
281
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
406
282
  ` : "");
407
- fs2.writeSync(process.stderr.fd, msg);
283
+ fs.writeSync(process.stderr.fd, msg);
408
284
  process.exitCode = ExitCode.SUCCESS;
409
285
  throw new PncliError("dry-run", 0);
410
286
  }
@@ -420,7 +296,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
420
296
  const msg = `DRY RUN: GET ${absoluteUrl}
421
297
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
422
298
  `;
423
- fs2.writeSync(process.stderr.fd, msg);
299
+ fs.writeSync(process.stderr.fd, msg);
424
300
  process.exitCode = ExitCode.SUCCESS;
425
301
  throw new PncliError("dry-run", 0);
426
302
  }
@@ -435,7 +311,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
435
311
  if (!baseUrl) throw new PncliError("Azure DevOps baseUrl not configured. Run: pncli config init");
436
312
  const url = buildUrl(baseUrl, path);
437
313
  if (this.dryRun) {
438
- fs2.writeSync(process.stderr.fd, `DRY RUN: POST ${url}
314
+ fs.writeSync(process.stderr.fd, `DRY RUN: POST ${url}
439
315
  Body: <binary ${buffer.length} bytes>
440
316
  `);
441
317
  process.exitCode = ExitCode.SUCCESS;
@@ -450,7 +326,7 @@ Body: <binary ${buffer.length} bytes>
450
326
  }
451
327
  async adoBuffer(absoluteUrl, opts = {}) {
452
328
  if (this.dryRun) {
453
- fs2.writeSync(process.stderr.fd, `DRY RUN: GET ${absoluteUrl}
329
+ fs.writeSync(process.stderr.fd, `DRY RUN: GET ${absoluteUrl}
454
330
  `);
455
331
  process.exitCode = ExitCode.SUCCESS;
456
332
  throw new PncliError("dry-run", 0);
@@ -483,7 +359,7 @@ Body: <binary ${buffer.length} bytes>
483
359
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
484
360
  Body: <multipart/form-data>
485
361
  `;
486
- fs2.writeSync(process.stderr.fd, msg);
362
+ fs.writeSync(process.stderr.fd, msg);
487
363
  process.exitCode = ExitCode.SUCCESS;
488
364
  throw new PncliError("dry-run", 0);
489
365
  }
@@ -505,7 +381,7 @@ Body: <multipart/form-data>
505
381
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
506
382
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
507
383
  ` : "");
508
- fs2.writeSync(process.stderr.fd, msg);
384
+ fs.writeSync(process.stderr.fd, msg);
509
385
  process.exitCode = ExitCode.SUCCESS;
510
386
  throw new PncliError("dry-run", 0);
511
387
  }
@@ -521,7 +397,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
521
397
  };
522
398
  if (this.dryRun) {
523
399
  const safeHeaders = { ...headers, Authorization: "[REDACTED]" };
524
- fs2.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
400
+ fs.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
525
401
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
526
402
  `);
527
403
  process.exitCode = ExitCode.SUCCESS;
@@ -555,7 +431,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
555
431
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
556
432
  Body: ${JSON.stringify({ query, variables }, null, 2)}
557
433
  `;
558
- fs2.writeSync(process.stderr.fd, msg);
434
+ fs.writeSync(process.stderr.fd, msg);
559
435
  process.exitCode = ExitCode.SUCCESS;
560
436
  throw new PncliError("dry-run", 0);
561
437
  }
@@ -604,7 +480,7 @@ Body: ${JSON.stringify({ query, variables }, null, 2)}
604
480
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
605
481
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
606
482
  ` : "");
607
- fs2.writeSync(process.stderr.fd, msg);
483
+ fs.writeSync(process.stderr.fd, msg);
608
484
  process.exitCode = ExitCode.SUCCESS;
609
485
  throw new PncliError("dry-run", 0);
610
486
  }
@@ -631,7 +507,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
631
507
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
632
508
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
633
509
  ` : "");
634
- fs2.writeSync(process.stderr.fd, msg);
510
+ fs.writeSync(process.stderr.fd, msg);
635
511
  process.exitCode = ExitCode.SUCCESS;
636
512
  throw new PncliError("dry-run", 0);
637
513
  }
@@ -666,7 +542,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
666
542
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
667
543
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
668
544
  ` : "");
669
- fs2.writeSync(process.stderr.fd, msg);
545
+ fs.writeSync(process.stderr.fd, msg);
670
546
  process.exitCode = ExitCode.SUCCESS;
671
547
  throw new PncliError("dry-run", 0);
672
548
  }
@@ -698,7 +574,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
698
574
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
699
575
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
700
576
  ` : "");
701
- fs2.writeSync(process.stderr.fd, msg);
577
+ fs.writeSync(process.stderr.fd, msg);
702
578
  process.exitCode = ExitCode.SUCCESS;
703
579
  throw new PncliError("dry-run", 0);
704
580
  }
@@ -730,7 +606,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
730
606
  const msg = `DRY RUN: ${opts.method ?? "GET"} ${url}
731
607
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
732
608
  ` : "");
733
- fs2.writeSync(process.stderr.fd, msg);
609
+ fs.writeSync(process.stderr.fd, msg);
734
610
  process.exitCode = ExitCode.SUCCESS;
735
611
  throw new PncliError("dry-run", 0);
736
612
  }
@@ -752,7 +628,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
752
628
  if (!baseUrl) throw new PncliError("Azure DevOps baseUrl not configured. Run: pncli config init");
753
629
  const url = buildUrl(baseUrl, path, opts.params);
754
630
  if (this.dryRun) {
755
- fs2.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
631
+ fs.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
756
632
  `);
757
633
  process.exitCode = ExitCode.SUCCESS;
758
634
  throw new PncliError("dry-run", 0);
@@ -778,7 +654,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
778
654
  if (!baseUrl) throw new PncliError("Azure DevOps baseUrl not configured. Run: pncli config init");
779
655
  const url = buildUrl(baseUrl, path, opts.params);
780
656
  if (this.dryRun) {
781
- fs2.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
657
+ fs.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
782
658
  `);
783
659
  process.exitCode = ExitCode.SUCCESS;
784
660
  throw new PncliError("dry-run", 0);
@@ -843,25 +719,6 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
843
719
  "Connection": "close"
844
720
  };
845
721
  }
846
- udeployHeaders() {
847
- const { pat, username, password } = this.config.udeploy;
848
- let encoded;
849
- if (username && password) {
850
- encoded = Buffer.from(`${username}:${password}`).toString("base64");
851
- } else if (username && pat) {
852
- encoded = Buffer.from(`${username}:${pat}`).toString("base64");
853
- } else if (pat) {
854
- encoded = Buffer.from(`PasswordIsAuthToken:${JSON.stringify({ token: pat })}`).toString("base64");
855
- } else {
856
- throw new PncliError("UDeploy credentials not configured. Run: pncli config init");
857
- }
858
- return {
859
- "Authorization": `Basic ${encoded}`,
860
- "Content-Type": "application/json",
861
- "Accept": "application/json",
862
- "Connection": "close"
863
- };
864
- }
865
722
  async jenkins(path, opts = {}) {
866
723
  const baseUrl = this.config.jenkins.baseUrl;
867
724
  if (!baseUrl) throw new PncliError("Jenkins baseUrl not configured. Run: pncli config init");
@@ -878,7 +735,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
878
735
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
879
736
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
880
737
  ` : "");
881
- fs2.writeSync(process.stderr.fd, msg);
738
+ fs.writeSync(process.stderr.fd, msg);
882
739
  process.exitCode = ExitCode.SUCCESS;
883
740
  throw new PncliError("dry-run", 0);
884
741
  }
@@ -895,7 +752,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
895
752
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
896
753
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
897
754
  ` : "");
898
- fs2.writeSync(process.stderr.fd, msg);
755
+ fs.writeSync(process.stderr.fd, msg);
899
756
  process.exitCode = ExitCode.SUCCESS;
900
757
  throw new PncliError("dry-run", 0);
901
758
  }
@@ -932,29 +789,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
932
789
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
933
790
  ` + (opts.body ? `Body: ${typeof opts.body === "string" ? opts.body : JSON.stringify(opts.body, null, 2)}
934
791
  ` : "");
935
- fs2.writeSync(process.stderr.fd, msg);
936
- process.exitCode = ExitCode.SUCCESS;
937
- throw new PncliError("dry-run", 0);
938
- }
939
- return request(url, init, opts.timeoutMs ?? 3e4);
940
- }
941
- async udeploy(path, opts = {}) {
942
- const baseUrl = this.config.udeploy.baseUrl;
943
- if (!baseUrl) throw new PncliError("UDeploy baseUrl not configured. Run: pncli config init");
944
- const url = buildUrl(baseUrl, path, opts.params);
945
- const headers = this.udeployHeaders();
946
- const init = {
947
- method: opts.method ?? "GET",
948
- headers,
949
- body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0
950
- };
951
- if (this.dryRun) {
952
- const safeHeaders = { ...headers, Authorization: "[REDACTED]" };
953
- const msg = `DRY RUN: ${init.method} ${url}
954
- Headers: ${JSON.stringify(safeHeaders, null, 2)}
955
- ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
956
- ` : "");
957
- fs2.writeSync(process.stderr.fd, msg);
792
+ fs.writeSync(process.stderr.fd, msg);
958
793
  process.exitCode = ExitCode.SUCCESS;
959
794
  throw new PncliError("dry-run", 0);
960
795
  }
@@ -967,7 +802,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
967
802
  const headers = { ...this.artifactoryHeaders(), Accept: "text/plain", ...opts.headers };
968
803
  if (this.dryRun) {
969
804
  const safeHeaders = { ...headers, Authorization: "[REDACTED]" };
970
- fs2.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
805
+ fs.writeSync(process.stderr.fd, `DRY RUN: ${opts.method ?? "GET"} ${url}
971
806
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
972
807
  `);
973
808
  process.exitCode = ExitCode.SUCCESS;
@@ -1014,7 +849,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1014
849
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1015
850
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1016
851
  ` : "");
1017
- fs2.writeSync(process.stderr.fd, msg);
852
+ fs.writeSync(process.stderr.fd, msg);
1018
853
  process.exitCode = ExitCode.SUCCESS;
1019
854
  throw new PncliError("dry-run", 0);
1020
855
  }
@@ -1045,7 +880,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1045
880
  const msg = `DRY RUN: GET ${url}
1046
881
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1047
882
  `;
1048
- fs2.writeSync(process.stderr.fd, msg);
883
+ fs.writeSync(process.stderr.fd, msg);
1049
884
  process.exitCode = ExitCode.SUCCESS;
1050
885
  throw new PncliError("dry-run", 0);
1051
886
  }
@@ -1071,7 +906,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1071
906
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1072
907
  Body: <multipart/form-data>
1073
908
  `;
1074
- fs2.writeSync(process.stderr.fd, msg);
909
+ fs.writeSync(process.stderr.fd, msg);
1075
910
  process.exitCode = ExitCode.SUCCESS;
1076
911
  throw new PncliError("dry-run", 0);
1077
912
  }
@@ -1155,7 +990,7 @@ Body: <multipart/form-data>
1155
990
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1156
991
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1157
992
  ` : "");
1158
- fs2.writeSync(process.stderr.fd, msg);
993
+ fs.writeSync(process.stderr.fd, msg);
1159
994
  process.exitCode = ExitCode.SUCCESS;
1160
995
  throw new PncliError("dry-run", 0);
1161
996
  }
@@ -1191,7 +1026,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1191
1026
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1192
1027
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1193
1028
  ` : "");
1194
- fs2.writeSync(process.stderr.fd, msg);
1029
+ fs.writeSync(process.stderr.fd, msg);
1195
1030
  process.exitCode = ExitCode.SUCCESS;
1196
1031
  throw new PncliError("dry-run", 0);
1197
1032
  }
@@ -1224,7 +1059,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1224
1059
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1225
1060
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1226
1061
  ` : "");
1227
- fs2.writeSync(process.stderr.fd, msg);
1062
+ fs.writeSync(process.stderr.fd, msg);
1228
1063
  process.exitCode = ExitCode.SUCCESS;
1229
1064
  throw new PncliError("dry-run", 0);
1230
1065
  }
@@ -1256,7 +1091,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1256
1091
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1257
1092
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1258
1093
  ` : "");
1259
- fs2.writeSync(process.stderr.fd, msg);
1094
+ fs.writeSync(process.stderr.fd, msg);
1260
1095
  process.exitCode = ExitCode.SUCCESS;
1261
1096
  throw new PncliError("dry-run", 0);
1262
1097
  }
@@ -1302,7 +1137,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1302
1137
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1303
1138
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1304
1139
  ` : "");
1305
- fs2.writeSync(process.stderr.fd, msg);
1140
+ fs.writeSync(process.stderr.fd, msg);
1306
1141
  process.exitCode = ExitCode.SUCCESS;
1307
1142
  throw new PncliError("dry-run", 0);
1308
1143
  }
@@ -1334,7 +1169,39 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1334
1169
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1335
1170
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1336
1171
  ` : "");
1337
- fs2.writeSync(process.stderr.fd, msg);
1172
+ fs.writeSync(process.stderr.fd, msg);
1173
+ process.exitCode = ExitCode.SUCCESS;
1174
+ throw new PncliError("dry-run", 0);
1175
+ }
1176
+ return request(url, init, opts.timeoutMs ?? 3e4);
1177
+ }
1178
+ splitioHeaders() {
1179
+ const { adminApiKey } = this.config.splitio;
1180
+ if (!adminApiKey) throw new PncliError("Split.IO credentials not configured. Run: pncli config init");
1181
+ return {
1182
+ "Authorization": `Bearer ${adminApiKey}`,
1183
+ "Content-Type": "application/json",
1184
+ "Accept": "application/json",
1185
+ "Connection": "close"
1186
+ };
1187
+ }
1188
+ async splitio(path, opts = {}) {
1189
+ const baseUrl = this.config.splitio.baseUrl;
1190
+ if (!baseUrl) throw new PncliError("Split.IO baseUrl not configured. Run: pncli config init");
1191
+ const url = buildUrl(baseUrl, path, opts.params);
1192
+ const headers = this.splitioHeaders();
1193
+ const init = {
1194
+ method: opts.method ?? "GET",
1195
+ headers,
1196
+ body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0
1197
+ };
1198
+ if (this.dryRun) {
1199
+ const safeHeaders = { ...headers, Authorization: "[REDACTED]" };
1200
+ const msg = `DRY RUN: ${init.method} ${url}
1201
+ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1202
+ ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1203
+ ` : "");
1204
+ fs.writeSync(process.stderr.fd, msg);
1338
1205
  process.exitCode = ExitCode.SUCCESS;
1339
1206
  throw new PncliError("dry-run", 0);
1340
1207
  }
@@ -1353,7 +1220,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1353
1220
  };
1354
1221
  if (this.dryRun) {
1355
1222
  const safeHeaders = { ...headers, Authorization: "[REDACTED]" };
1356
- fs2.writeSync(process.stderr.fd, `DRY RUN: GET ${url}
1223
+ fs.writeSync(process.stderr.fd, `DRY RUN: GET ${url}
1357
1224
  Headers: ${JSON.stringify(safeHeaders, null, 2)}
1358
1225
  `);
1359
1226
  process.exitCode = ExitCode.SUCCESS;
@@ -1379,7 +1246,7 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1379
1246
  const msg = `DRY RUN: ${opts.method ?? "GET"} ${url}
1380
1247
  ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1381
1248
  ` : "");
1382
- fs2.writeSync(process.stderr.fd, msg);
1249
+ fs.writeSync(process.stderr.fd, msg);
1383
1250
  process.exitCode = ExitCode.SUCCESS;
1384
1251
  throw new PncliError("dry-run", 0);
1385
1252
  }
@@ -1391,22 +1258,45 @@ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1391
1258
  };
1392
1259
  return request(url, init, opts.timeoutMs ?? 3e4, fetcher);
1393
1260
  }
1261
+ figmaHeaders() {
1262
+ const { token } = this.config.figma;
1263
+ if (!token) throw new PncliError("Figma credentials not configured. Run: pncli config set figma.token <token>");
1264
+ return {
1265
+ "X-Figma-Token": token,
1266
+ "Content-Type": "application/json",
1267
+ "Accept": "application/json",
1268
+ "Connection": "close"
1269
+ };
1270
+ }
1271
+ async figma(path, opts = {}) {
1272
+ const baseUrl = this.config.figma.baseUrl;
1273
+ if (!baseUrl) throw new PncliError("Figma baseUrl not configured. Run: pncli config set figma.baseUrl https://api.figma.com");
1274
+ const url = buildUrl(baseUrl, path, opts.params);
1275
+ const headers = this.figmaHeaders();
1276
+ const init = {
1277
+ method: opts.method ?? "GET",
1278
+ headers,
1279
+ body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0
1280
+ };
1281
+ if (this.dryRun) {
1282
+ const safeHeaders = { ...headers, "X-Figma-Token": "[REDACTED]" };
1283
+ const msg = `DRY RUN: ${init.method} ${url}
1284
+ Headers: ${JSON.stringify(safeHeaders, null, 2)}
1285
+ ` + (opts.body ? `Body: ${JSON.stringify(opts.body, null, 2)}
1286
+ ` : "");
1287
+ fs.writeSync(process.stderr.fd, msg);
1288
+ process.exitCode = ExitCode.SUCCESS;
1289
+ throw new PncliError("dry-run", 0);
1290
+ }
1291
+ return request(url, init, opts.timeoutMs ?? 3e4);
1292
+ }
1394
1293
  };
1395
1294
  function createHttpClient(config, dryRun = false) {
1396
1295
  return new HttpClient(config, dryRun);
1397
1296
  }
1398
1297
 
1399
1298
  export {
1400
- PncliError,
1401
- ExitCode,
1402
- setGlobalOptions,
1403
- setGlobalUser,
1404
- success,
1405
- fail,
1406
- writeRawOutput,
1407
- log,
1408
- warn,
1409
1299
  HttpClient,
1410
1300
  createHttpClient
1411
1301
  };
1412
- //# sourceMappingURL=chunk-ABHLES5M.js.map
1302
+ //# sourceMappingURL=chunk-ZDJYOI3W.js.map