@zeroheight/adoption-cli 2.4.2 → 3.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.
@@ -8,48 +8,116 @@ import NoCredentialsOnboarding from "../auth/no-credentials-onboarding.js";
8
8
  import RepoNamePrompt from "../repo-name-prompt.js";
9
9
  import UsageTable from "../usage-table.js";
10
10
  import { configPath, writeConfig, readConfig, } from "../../common/config.js";
11
- import { ResponseStatus, getAuthDetails, getZeroheightURL, submitUsageData, } from "../../common/api.js";
12
- import { calculateNumberOfComponents } from "../../commands/analyze.utils.js";
11
+ import { ResponseStatus, getAuthDetails, getZeroheightURL, submitComponentUsageData, submitTokenLiteralUsageData, } from "../../common/api.js";
12
+ import { calculateNumberOfColors, calculateNumberOfComponents, } from "../../commands/analyze.utils.js";
13
13
  import { ApiError } from "../../common/errors.js";
14
- export default function Analyze({ onAnalyzeFiles, dryRun, repoName, }) {
14
+ import ColorUsageTable from "../color-usage-table.js";
15
+ var AnalyzeStage;
16
+ (function (AnalyzeStage) {
17
+ AnalyzeStage[AnalyzeStage["initial"] = 0] = "initial";
18
+ AnalyzeStage[AnalyzeStage["finished"] = 1] = "finished";
19
+ AnalyzeStage[AnalyzeStage["fetchCredentials"] = 2] = "fetchCredentials";
20
+ AnalyzeStage[AnalyzeStage["fetchRepoNames"] = 3] = "fetchRepoNames";
21
+ AnalyzeStage[AnalyzeStage["cuScanningFiles"] = 4] = "cuScanningFiles";
22
+ AnalyzeStage[AnalyzeStage["cuScanComplete"] = 5] = "cuScanComplete";
23
+ AnalyzeStage[AnalyzeStage["cuShowMoreDetails"] = 6] = "cuShowMoreDetails";
24
+ AnalyzeStage[AnalyzeStage["cuSendDataCheck"] = 7] = "cuSendDataCheck";
25
+ AnalyzeStage[AnalyzeStage["cuAuthSetUp"] = 8] = "cuAuthSetUp";
26
+ AnalyzeStage[AnalyzeStage["cuRepoSelection"] = 9] = "cuRepoSelection";
27
+ AnalyzeStage[AnalyzeStage["cuSendingData"] = 10] = "cuSendingData";
28
+ AnalyzeStage[AnalyzeStage["cuSendSuccess"] = 11] = "cuSendSuccess";
29
+ AnalyzeStage[AnalyzeStage["tuConfirmRun"] = 12] = "tuConfirmRun";
30
+ AnalyzeStage[AnalyzeStage["tuScanningFiles"] = 13] = "tuScanningFiles";
31
+ AnalyzeStage[AnalyzeStage["tuScanComplete"] = 14] = "tuScanComplete";
32
+ AnalyzeStage[AnalyzeStage["tuShowMoreDetails"] = 15] = "tuShowMoreDetails";
33
+ AnalyzeStage[AnalyzeStage["tuSendDataCheck"] = 16] = "tuSendDataCheck";
34
+ AnalyzeStage[AnalyzeStage["tuAuthSetUp"] = 17] = "tuAuthSetUp";
35
+ AnalyzeStage[AnalyzeStage["tuRepoSelection"] = 18] = "tuRepoSelection";
36
+ AnalyzeStage[AnalyzeStage["tuSendingData"] = 19] = "tuSendingData";
37
+ AnalyzeStage[AnalyzeStage["tuSendSuccess"] = 20] = "tuSendSuccess";
38
+ })(AnalyzeStage || (AnalyzeStage = {}));
39
+ export default function Analyze({ onAnalyzeFiles, onAnalyzeColorUsage, repoName, }) {
15
40
  const { exit } = useApp();
16
- const [usageResult, setUsageResult] = React.useState(null);
17
- const [isSendingData, setIsSendingData] = React.useState(false);
41
+ const [currentStage, setCurrentStage] = React.useState(AnalyzeStage.initial);
42
+ // Result states
43
+ const [componentUsageResult, setComponentUsageResult] = React.useState(new Map());
44
+ const [colorUsageResult, setColorUsageResult] = React.useState(new Map());
18
45
  const [errorList, setErrorList] = React.useState([]);
19
46
  const [errorFileLocation, setErrorFileLocation] = React.useState(null);
47
+ // Set up states
20
48
  const [credentials, setCredentials] = React.useState(null);
21
- const [resourceURL, setResourceURL] = React.useState(null);
49
+ const [resourceURL, setResourceURL] = React.useState(getZeroheightURL());
22
50
  const [repo, setRepo] = React.useState(repoName);
23
- const [promptRepo, setPromptRepo] = React.useState(repoName === undefined);
24
- const [showContinue, setShowContinue] = React.useState(false);
51
+ // Text input states
52
+ const [continueToTokenUsage, setContinueToTokenUsage] = React.useState("");
53
+ const [runComponentUsage, setRunComponentUsage] = React.useState("");
54
+ const [runTokenUsage, setRunTokenUsage] = React.useState("");
25
55
  const [showMoreResults, setShowMoreResults] = React.useState("");
26
- React.useEffect(() => {
27
- (async () => {
28
- try {
29
- const { errorFile, usage } = await onAnalyzeFiles();
30
- setErrorFileLocation(errorFile);
31
- setUsageResult(usage);
32
- }
33
- catch (e) {
34
- setErrorList((s) => [...s, e]);
56
+ // Component usage
57
+ function handleStartComponentUsage(shouldScan) {
58
+ if (shouldScan) {
59
+ setCurrentStage(AnalyzeStage.cuScanningFiles);
60
+ analyzeComponentUsage();
61
+ }
62
+ else {
63
+ setCurrentStage(AnalyzeStage.tuConfirmRun);
64
+ }
65
+ }
66
+ async function analyzeComponentUsage() {
67
+ try {
68
+ const { errorFile, usage } = await onAnalyzeFiles();
69
+ setErrorFileLocation(errorFile);
70
+ setComponentUsageResult(usage);
71
+ setCurrentStage(AnalyzeStage.cuScanComplete);
72
+ }
73
+ catch (e) {
74
+ setErrorList((s) => [...s, e]);
75
+ }
76
+ }
77
+ function handleShowMore(showMore) {
78
+ if (showMore) {
79
+ setCurrentStage(AnalyzeStage.cuShowMoreDetails);
80
+ }
81
+ else {
82
+ setCurrentStage(AnalyzeStage.cuSendDataCheck);
83
+ }
84
+ }
85
+ async function handleSendCuData(shouldSend) {
86
+ if (shouldSend) {
87
+ const creds = await fetchCredentials();
88
+ if (!creds) {
89
+ setCurrentStage(AnalyzeStage.cuAuthSetUp);
90
+ return;
35
91
  }
36
- if (dryRun)
92
+ if (!repo) {
93
+ setCurrentStage(AnalyzeStage.cuRepoSelection);
37
94
  return;
38
- try {
39
- const config = await readConfig();
40
- if (config) {
41
- setCredentials({ token: config.token, client: config.client });
42
- }
43
95
  }
44
- catch (e) {
45
- setErrorList((s) => [...s, "Failed to load credentials"]);
96
+ setCurrentStage(AnalyzeStage.cuSendingData);
97
+ sendCuData(componentUsageResult, repo, creds);
98
+ }
99
+ else {
100
+ setCurrentStage(AnalyzeStage.tuConfirmRun);
101
+ exit();
102
+ }
103
+ }
104
+ async function fetchCredentials() {
105
+ try {
106
+ const config = await readConfig();
107
+ if (config) {
108
+ setCredentials({ token: config.token, client: config.client });
109
+ return { token: config.token, client: config.client };
46
110
  }
47
- })();
48
- }, []);
49
- async function sendData(result, repoName, credentials) {
50
- setIsSendingData(true);
111
+ return null;
112
+ }
113
+ catch (e) {
114
+ setErrorList((s) => [...s, "Failed to load credentials"]);
115
+ return null;
116
+ }
117
+ }
118
+ async function sendCuData(result, repoName, credentials) {
51
119
  try {
52
- await submitUsageData(result, repoName, credentials);
120
+ await submitComponentUsageData(result, repoName, credentials);
53
121
  const authDetailsResponse = await getAuthDetails(credentials);
54
122
  if (authDetailsResponse.status !== ResponseStatus.Success) {
55
123
  throw new Error("Failed to get credentials");
@@ -60,6 +128,7 @@ export default function Analyze({ onAnalyzeFiles, dryRun, repoName, }) {
60
128
  ? `/project/${projectId}/adoption/`
61
129
  : "/adoption/";
62
130
  setResourceURL(resourceURL);
131
+ setCurrentStage(AnalyzeStage.cuSendSuccess);
63
132
  }
64
133
  catch (e) {
65
134
  let errorMessage = "Failed to send data to zeroheight";
@@ -68,23 +137,6 @@ export default function Analyze({ onAnalyzeFiles, dryRun, repoName, }) {
68
137
  }
69
138
  setErrorList((s) => [...s, errorMessage]);
70
139
  }
71
- finally {
72
- setIsSendingData(false);
73
- }
74
- }
75
- async function handleContinue(shouldContinue) {
76
- if (shouldContinue) {
77
- if (!dryRun && credentials && usageResult && !repo) {
78
- setPromptRepo(true);
79
- setRepo("");
80
- }
81
- else if (!dryRun && credentials && usageResult && repo) {
82
- sendData(usageResult, repo, credentials);
83
- }
84
- }
85
- else {
86
- exit();
87
- }
88
140
  }
89
141
  function handleOnRepoNameSelected(repoName) {
90
142
  setRepo(repoName);
@@ -93,14 +145,13 @@ export default function Analyze({ onAnalyzeFiles, dryRun, repoName, }) {
93
145
  [process.cwd()]: repoName,
94
146
  },
95
147
  });
96
- setPromptRepo(false);
97
- }
98
- function handleShowMore(showMore) {
99
- if (showMore) {
100
- setShowMoreResults("true");
148
+ if (currentStage === AnalyzeStage.cuRepoSelection) {
149
+ handleSendCuData(true);
150
+ setCurrentStage(AnalyzeStage.cuSendingData);
101
151
  }
102
152
  else {
103
- setShowContinue(true);
153
+ handleSendTuData(true);
154
+ setCurrentStage(AnalyzeStage.tuSendingData);
104
155
  }
105
156
  }
106
157
  async function handleCheckCredentials(newClient, newToken) {
@@ -112,6 +163,86 @@ export default function Analyze({ onAnalyzeFiles, dryRun, repoName, }) {
112
163
  return exit();
113
164
  }
114
165
  }
166
+ // Token usage
167
+ function startTokenUsageFlow(shouldContinue) {
168
+ if (shouldContinue) {
169
+ setCurrentStage(AnalyzeStage.tuConfirmRun);
170
+ }
171
+ else {
172
+ setCurrentStage(AnalyzeStage.finished);
173
+ }
174
+ }
175
+ function handleStartTokenUsage(shouldScan) {
176
+ if (shouldScan) {
177
+ setCurrentStage(AnalyzeStage.tuScanningFiles);
178
+ analyzeTokenUsage();
179
+ }
180
+ else {
181
+ setCurrentStage(AnalyzeStage.finished);
182
+ }
183
+ }
184
+ async function analyzeTokenUsage() {
185
+ try {
186
+ const { errorFile, usage } = await onAnalyzeColorUsage();
187
+ setErrorFileLocation(errorFile);
188
+ setColorUsageResult(usage);
189
+ setCurrentStage(AnalyzeStage.tuScanComplete);
190
+ }
191
+ catch (e) {
192
+ setErrorList((s) => [...s, e]);
193
+ }
194
+ }
195
+ function handleShowMoreTU(showMore) {
196
+ if (showMore) {
197
+ setCurrentStage(AnalyzeStage.tuShowMoreDetails);
198
+ }
199
+ else {
200
+ setCurrentStage(AnalyzeStage.tuSendDataCheck);
201
+ }
202
+ }
203
+ async function handleSendTuData(shouldSend) {
204
+ if (shouldSend) {
205
+ const creds = await fetchCredentials();
206
+ if (!creds) {
207
+ setCurrentStage(AnalyzeStage.tuAuthSetUp);
208
+ return;
209
+ }
210
+ if (!repo) {
211
+ setCurrentStage(AnalyzeStage.tuRepoSelection);
212
+ return;
213
+ }
214
+ setCurrentStage(AnalyzeStage.tuSendingData);
215
+ sendTuData(colorUsageResult, repo, creds);
216
+ }
217
+ else {
218
+ setCurrentStage(AnalyzeStage.finished);
219
+ exit();
220
+ }
221
+ }
222
+ async function sendTuData(result, repoName, credentials) {
223
+ try {
224
+ await submitTokenLiteralUsageData(result, repoName, credentials);
225
+ const authDetailsResponse = await getAuthDetails(credentials);
226
+ if (authDetailsResponse.status !== ResponseStatus.Success) {
227
+ throw new Error("Failed to get credentials");
228
+ }
229
+ const projectId = authDetailsResponse.data.project?.id;
230
+ const resourceURL = getZeroheightURL();
231
+ resourceURL.pathname = projectId
232
+ ? `/project/${projectId}/adoption/`
233
+ : "/adoption/";
234
+ setResourceURL(resourceURL);
235
+ setCurrentStage(AnalyzeStage.tuSendSuccess);
236
+ }
237
+ catch (e) {
238
+ let errorMessage = "Failed to send data to zeroheight";
239
+ if (e instanceof ApiError) {
240
+ errorMessage = e.message;
241
+ }
242
+ setErrorList((s) => [...s, errorMessage]);
243
+ }
244
+ }
245
+ // UI flow
115
246
  if (errorList.length > 0) {
116
247
  return (React.createElement(Box, { flexDirection: "column" },
117
248
  React.createElement(Text, { color: "red" }, "Error:"),
@@ -119,7 +250,69 @@ export default function Analyze({ onAnalyzeFiles, dryRun, repoName, }) {
119
250
  "- ",
120
251
  e))))));
121
252
  }
122
- if (!promptRepo && !credentials && !dryRun) {
253
+ if (currentStage === AnalyzeStage.initial) {
254
+ return (React.createElement(Box, { flexDirection: "column" },
255
+ React.createElement(Text, null,
256
+ "\uD83D\uDC4B Welcome to the ",
257
+ React.createElement(Text, { color: "#f63e7c" }, "zeroheight"),
258
+ " analyze tool"),
259
+ React.createElement(Newline, null),
260
+ React.createElement(Box, { flexDirection: "column" },
261
+ React.createElement(Text, null,
262
+ "\u2753 Would you like to us to scan the files in this project to understand how components are being used (React only)?",
263
+ " ",
264
+ React.createElement(Text, { dimColor: true }, "(Y/n)")),
265
+ React.createElement(ConfirmInput, { isChecked: true, value: runComponentUsage, onChange: setRunComponentUsage, onSubmit: handleStartComponentUsage }))));
266
+ }
267
+ if (currentStage === AnalyzeStage.cuScanningFiles) {
268
+ return (React.createElement(Text, null,
269
+ React.createElement(Text, { color: "green" },
270
+ React.createElement(Spinner, { type: "dots" })),
271
+ " Scanning files for component usage..."));
272
+ }
273
+ if (currentStage === AnalyzeStage.cuScanComplete) {
274
+ if (componentUsageResult?.size > 0) {
275
+ return (React.createElement(Box, { flexDirection: "column" },
276
+ React.createElement(Text, { color: "green" },
277
+ calculateNumberOfComponents(componentUsageResult),
278
+ " components found"),
279
+ errorFileLocation && (React.createElement(React.Fragment, null,
280
+ React.createElement(Newline, null),
281
+ React.createElement(Box, null,
282
+ React.createElement(Text, { color: "red" }, "Error:"),
283
+ React.createElement(Text, null,
284
+ " ",
285
+ "Some files could not be parsed. Errors can be found at",
286
+ " ",
287
+ React.createElement(Link, { url: errorFileLocation }, errorFileLocation))))),
288
+ React.createElement(Box, null,
289
+ React.createElement(Text, null,
290
+ "Show more details? ",
291
+ React.createElement(Text, { dimColor: true }, "(y/N)")),
292
+ React.createElement(ConfirmInput, { isChecked: false, value: showMoreResults, onChange: setShowMoreResults, onSubmit: handleShowMore }))));
293
+ }
294
+ else {
295
+ return (React.createElement(Box, { flexDirection: "column" },
296
+ React.createElement(Box, null,
297
+ React.createElement(Text, null, "No files found, try a different directory or change the file extensions you want to include.")),
298
+ React.createElement(Box, null,
299
+ React.createElement(Text, null,
300
+ "Continue to token usage analysis? ",
301
+ React.createElement(Text, { dimColor: true }, "(Y/n)")),
302
+ React.createElement(ConfirmInput, { isChecked: true, value: continueToTokenUsage, onChange: setContinueToTokenUsage, onSubmit: startTokenUsageFlow }))));
303
+ }
304
+ }
305
+ if (currentStage === AnalyzeStage.cuShowMoreDetails) {
306
+ return (React.createElement(Box, { flexDirection: "column" },
307
+ React.createElement(UsageTable, { usage: componentUsageResult }),
308
+ React.createElement(Newline, null),
309
+ React.createElement(ContinuePrompt, { onContinue: handleSendCuData })));
310
+ }
311
+ if (currentStage === AnalyzeStage.cuSendDataCheck) {
312
+ return React.createElement(ContinuePrompt, { onContinue: handleSendCuData });
313
+ }
314
+ if (currentStage === AnalyzeStage.cuAuthSetUp ||
315
+ currentStage === AnalyzeStage.tuAuthSetUp) {
123
316
  return (React.createElement(NoCredentialsOnboarding, { configPath: configPath(), onCheckCredentials: handleCheckCredentials, onSaveCredentials: async (persist, newClient, newToken) => {
124
317
  const newCredentials = { token: newToken, client: newClient };
125
318
  setCredentials(newCredentials);
@@ -129,83 +322,108 @@ export default function Analyze({ onAnalyzeFiles, dryRun, repoName, }) {
129
322
  token: newToken,
130
323
  });
131
324
  }
325
+ if (currentStage === AnalyzeStage.cuAuthSetUp) {
326
+ handleSendCuData(true);
327
+ setCurrentStage(AnalyzeStage.cuSendingData);
328
+ }
329
+ else {
330
+ handleSendTuData(true);
331
+ setCurrentStage(AnalyzeStage.tuSendingData);
332
+ }
132
333
  } }));
133
334
  }
134
- // Usage is being calculated
135
- if (usageResult === null) {
136
- return (React.createElement(Text, null,
137
- React.createElement(Text, { color: "green" },
138
- React.createElement(Spinner, { type: "dots" })),
139
- " Scanning files..."));
140
- }
141
- // No usage data found
142
- if (usageResult?.size === 0) {
143
- return (React.createElement(Text, null, "No files found, try a different directory or change the file extensions you want to include"));
335
+ if (currentStage === AnalyzeStage.cuRepoSelection ||
336
+ currentStage === AnalyzeStage.tuRepoSelection) {
337
+ return (React.createElement(RepoNamePrompt, { credentials: credentials, onRepoNameSelected: handleOnRepoNameSelected }));
144
338
  }
145
- // Posting usage data to zeroheight
146
- if (isSendingData) {
339
+ if (currentStage === AnalyzeStage.cuSendingData ||
340
+ currentStage === AnalyzeStage.tuSendingData) {
147
341
  return (React.createElement(Text, null,
148
342
  React.createElement(Text, { color: "green" },
149
343
  React.createElement(Spinner, { type: "dots" })),
150
- " Sending usage data to zeroheight..."));
344
+ " ",
345
+ "Sending usage data to ",
346
+ React.createElement(Text, { color: "#f63e7c" }, "zeroheight"),
347
+ "..."));
151
348
  }
152
- // Completed, usage data is ready to view on zeroheight
153
- if (resourceURL) {
154
- return (React.createElement(React.Fragment, null,
155
- React.createElement(Newline, null),
349
+ if (currentStage === AnalyzeStage.cuSendSuccess) {
350
+ return (React.createElement(Box, { flexDirection: "column" },
156
351
  React.createElement(Text, null,
157
- React.createElement(Text, { color: "green" }, "Successful:"),
352
+ React.createElement(Text, { color: "green" }, "Successfully sent:"),
158
353
  " View your",
159
354
  " ",
160
- React.createElement(Link, { url: resourceURL.toString() }, "usage data on zeroheight"))));
355
+ React.createElement(Link, { url: resourceURL.toString() },
356
+ React.createElement(Text, { underline: true, color: "#f63e7c" }, "usage data on zeroheight"))),
357
+ React.createElement(Newline, null),
358
+ React.createElement(Box, null,
359
+ React.createElement(Text, null,
360
+ "\u2753 Would you like to us to scan the files in this project to understand how colors are being used? ",
361
+ React.createElement(Text, { dimColor: true }, "(Y/n)")),
362
+ React.createElement(ConfirmInput, { isChecked: true, value: runTokenUsage, onChange: setRunTokenUsage, onSubmit: handleStartTokenUsage }))));
161
363
  }
162
- if (usageResult &&
163
- !promptRepo &&
164
- !(showMoreResults === "true" || showContinue)) {
364
+ if (currentStage === AnalyzeStage.tuConfirmRun) {
165
365
  return (React.createElement(Box, { flexDirection: "column" },
366
+ React.createElement(Box, null,
367
+ React.createElement(Text, null,
368
+ "\u2753 Would you like to us to scan the files in this project to understand how colors are being used? ",
369
+ React.createElement(Text, { dimColor: true }, "(Y/n)")),
370
+ React.createElement(ConfirmInput, { isChecked: true, value: runTokenUsage, onChange: setRunTokenUsage, onSubmit: handleStartTokenUsage }))));
371
+ }
372
+ if (currentStage === AnalyzeStage.tuScanningFiles) {
373
+ return (React.createElement(Text, null,
166
374
  React.createElement(Text, { color: "green" },
167
- calculateNumberOfComponents(usageResult),
168
- " components found"),
169
- errorFileLocation && (React.createElement(React.Fragment, null,
170
- React.createElement(Newline, null),
375
+ React.createElement(Spinner, { type: "dots" })),
376
+ " Scanning files for color usage..."));
377
+ }
378
+ if (currentStage === AnalyzeStage.tuScanComplete) {
379
+ if (colorUsageResult?.size > 0) {
380
+ return (React.createElement(Box, { flexDirection: "column" },
381
+ React.createElement(Text, { color: "green" },
382
+ calculateNumberOfColors(colorUsageResult),
383
+ " instatances of raw color usage found"),
384
+ errorFileLocation && (React.createElement(React.Fragment, null,
385
+ React.createElement(Newline, null),
386
+ React.createElement(Box, null,
387
+ React.createElement(Text, { color: "red" }, "Error:"),
388
+ React.createElement(Text, null,
389
+ " ",
390
+ "Some files could not be parsed. Errors can be found at",
391
+ " ",
392
+ React.createElement(Link, { url: errorFileLocation }, errorFileLocation))))),
171
393
  React.createElement(Box, null,
172
- React.createElement(Text, { color: "red" }, "Error:"),
173
394
  React.createElement(Text, null,
174
- " ",
175
- "Some files could not be parsed. Errors can be found at",
176
- " ",
177
- React.createElement(Link, { url: errorFileLocation }, errorFileLocation))))),
178
- React.createElement(Box, null,
179
- React.createElement(Text, null,
180
- "Show more details? ",
181
- React.createElement(Text, { dimColor: true }, "(y/N)")),
182
- React.createElement(ConfirmInput, { isChecked: false, value: showMoreResults, onChange: setShowMoreResults, onSubmit: handleShowMore }))));
395
+ "Show more details? ",
396
+ React.createElement(Text, { dimColor: true }, "(y/N)")),
397
+ React.createElement(ConfirmInput, { isChecked: false, value: showMoreResults, onChange: setShowMoreResults, onSubmit: handleShowMoreTU }))));
398
+ }
399
+ else {
400
+ return (React.createElement(Box, { flexDirection: "column" },
401
+ React.createElement(Text, null, "No files found, try a different directory or change the file extensions you want to include.")));
402
+ }
183
403
  }
184
- if (usageResult && !promptRepo && showMoreResults === "true") {
404
+ if (currentStage === AnalyzeStage.tuShowMoreDetails) {
185
405
  return (React.createElement(Box, { flexDirection: "column" },
186
- React.createElement(UsageTable, { usage: usageResult }),
187
- dryRun && (React.createElement(React.Fragment, null,
188
- React.createElement(Newline, null),
189
- React.createElement(Text, null,
190
- "Nothing sent to zeroheight, if you want to track component usage data then remove the ",
191
- React.createElement(Text, { italic: true }, "--dry-run"),
192
- " option."),
193
- React.createElement(Newline, null))),
194
- !dryRun && React.createElement(ContinuePrompt, { onContinue: handleContinue })));
406
+ React.createElement(ColorUsageTable, { usage: colorUsageResult }),
407
+ React.createElement(Newline, null),
408
+ React.createElement(ContinuePrompt, { onContinue: handleSendTuData })));
195
409
  }
196
- if (usageResult && !promptRepo && showContinue) {
410
+ if (currentStage === AnalyzeStage.tuSendDataCheck) {
411
+ return React.createElement(ContinuePrompt, { onContinue: handleSendTuData });
412
+ }
413
+ if (currentStage === AnalyzeStage.tuSendSuccess) {
197
414
  return (React.createElement(Box, { flexDirection: "column" },
198
- dryRun && (React.createElement(React.Fragment, null,
199
- React.createElement(Newline, null),
200
- React.createElement(Text, null,
201
- "Nothing sent to zeroheight, if you want to track component usage data then remove the ",
202
- React.createElement(Text, { italic: true }, "--dry-run"),
203
- " option."),
204
- React.createElement(Newline, null))),
205
- !dryRun && React.createElement(ContinuePrompt, { onContinue: handleContinue })));
415
+ React.createElement(Text, null,
416
+ React.createElement(Text, { color: "green" }, "Successfully sent:"),
417
+ " View your",
418
+ " ",
419
+ React.createElement(Link, { url: resourceURL.toString() },
420
+ React.createElement(Text, { underline: true, color: "#f63e7c" }, "usage data on zeroheight"))),
421
+ React.createElement(Newline, null),
422
+ React.createElement(Text, null, "\uD83D\uDC4B See you next time!")));
206
423
  }
207
- if (promptRepo) {
208
- return (React.createElement(RepoNamePrompt, { credentials: credentials, onRepoNameSelected: handleOnRepoNameSelected }));
424
+ if (currentStage === AnalyzeStage.finished) {
425
+ return (React.createElement(Box, { flexDirection: "column" },
426
+ React.createElement(Text, null, "\uD83D\uDC4B See you next time!")));
209
427
  }
210
- return React.createElement(Text, null, "Done");
428
+ return React.createElement(Text, null, "Analzye complete");
211
429
  }
@@ -1,10 +1,16 @@
1
1
  import React from "react";
2
- import { RawUsageMap } from "../../commands/analyze.js";
2
+ import { RawColorUsageMap, RawComponentUsageMap } from "../../commands/analyze.js";
3
3
  export interface NonInteractiveAnalyzeProps {
4
4
  onAnalyzeFiles: () => Promise<{
5
5
  errorFile: string | null;
6
- usage: RawUsageMap;
6
+ usage: RawComponentUsageMap;
7
+ }>;
8
+ onAnalyzeColorUsage: () => Promise<{
9
+ errorFile: string | null;
10
+ usage: RawColorUsageMap;
7
11
  }>;
8
12
  repoName?: string;
13
+ shouldAnalyzeComponentUsage: boolean;
14
+ shouldAnalyzeTokenUsage: boolean;
9
15
  }
10
- export default function NonInteractiveAnalyze({ repoName, onAnalyzeFiles, }: NonInteractiveAnalyzeProps): React.JSX.Element;
16
+ export default function NonInteractiveAnalyze({ repoName, onAnalyzeFiles, onAnalyzeColorUsage, shouldAnalyzeComponentUsage, shouldAnalyzeTokenUsage, }: NonInteractiveAnalyzeProps): React.JSX.Element;