@zeroheight/adoption-cli 3.0.0 → 3.0.2

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,6 +1,16 @@
1
1
  # Release notes
2
2
 
3
- ## [3.0.0](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/3.0.0) - 15th March 2025
3
+ ## [3.0.2](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/3.0.2) - 8th April 2025
4
+
5
+ - Fix bug where not sending component usage data to zeroheight would exit you from the analyze flow
6
+ - Improve clarity of command flow wording
7
+ - Improve clarity of authentication errors
8
+
9
+ ## [3.0.1](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/3.0.1) - 25th March 2025
10
+
11
+ - Fix bug where color analysis didn't occur when using non-interactive mode
12
+
13
+ ## [3.0.0](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/3.0.0) - 25th March 2025
4
14
 
5
15
  - `analyze` command updated to collect date about color usage
6
16
  - For non-interactive command new flags introduced: `--color-usage` and `--component-usage`
package/dist/cli.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
3
  declare const program: Command;
4
- export declare const CURRENT_VERSION = "3.0.0";
4
+ export declare const CURRENT_VERSION = "3.0.2";
5
5
  export default program;
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import { monitorRepoCommand } from "./commands/monitor-repo.js";
10
10
  import { trackPackageCommand } from "./commands/track-package.js";
11
11
  import logger, { setFileStream } from "./common/logging.js";
12
12
  const program = new Command();
13
- export const CURRENT_VERSION = "3.0.0";
13
+ export const CURRENT_VERSION = "3.0.2";
14
14
  async function getLatestPackageVersion() {
15
15
  const response = await fetch("https://registry.npmjs.org/@zeroheight/adoption-cli/latest");
16
16
  const json = await response.json();
@@ -7,7 +7,7 @@ interface AnalyzeOptions {
7
7
  repoName?: string;
8
8
  interactive: boolean;
9
9
  componentUsage: boolean;
10
- tokenUsage: boolean;
10
+ colorUsage: boolean;
11
11
  }
12
12
  export type RawComponentUsageMap = Map<string, RawUsage[]>;
13
13
  export type RawColorUsageMap = Map<string, RawColorUsage>;
@@ -11,7 +11,7 @@ export async function analyzeAction(options, renderOptions) {
11
11
  render(React.createElement(Analyze, { onAnalyzeFiles: () => analyzeFiles(options.extensions, options.ignore), onAnalyzeColorUsage: () => analyzeRawColorUsage(options.extensions, options.ignore), repoName: options.repoName }), renderOptions);
12
12
  }
13
13
  else {
14
- render(React.createElement(NonInteractiveAnalyze, { repoName: options.repoName, onAnalyzeFiles: () => analyzeFiles(options.extensions, options.ignore), onAnalyzeColorUsage: () => analyzeRawColorUsage(options.extensions, options.ignore), shouldAnalyzeComponentUsage: options.componentUsage, shouldAnalyzeTokenUsage: options.tokenUsage }));
14
+ render(React.createElement(NonInteractiveAnalyze, { repoName: options.repoName, onAnalyzeFiles: () => analyzeFiles(options.extensions, options.ignore), onAnalyzeColorUsage: () => analyzeRawColorUsage(options.extensions, options.ignore), shouldAnalyzeComponentUsage: options.componentUsage, shouldAnalyzeTokenUsage: options.colorUsage }));
15
15
  }
16
16
  }
17
17
  export function analyzeCommand() {
@@ -1,4 +1,4 @@
1
- import { MaxRetriesError, UnauthorizedError, UnknownError } from "./errors.js";
1
+ import { IncorrectScopeError, MaxRetriesError, UnauthorizedError, UnknownError, } from "./errors.js";
2
2
  import logger from "./logging.js";
3
3
  const API_PATH = "/open_api/v2";
4
4
  export var ResponseStatus;
@@ -98,7 +98,12 @@ async function request(path, credentials, init) {
98
98
  }
99
99
  else if (response.status < 200 || response.status >= 300) {
100
100
  logger.error({ response: { status: response.status, body: await response.text() } }, "API request failed");
101
- throw new UnknownError();
101
+ if (response.status === 403) {
102
+ throw new IncorrectScopeError();
103
+ }
104
+ else {
105
+ throw new UnknownError();
106
+ }
102
107
  }
103
108
  const responseJson = await response.json();
104
109
  logger.info({ response: { status: response.status, body: responseJson } }, "API response");
@@ -4,6 +4,9 @@ export declare class ApiError extends Error {
4
4
  export declare class UnauthorizedError extends ApiError {
5
5
  constructor();
6
6
  }
7
+ export declare class IncorrectScopeError extends ApiError {
8
+ constructor();
9
+ }
7
10
  export declare class UnknownError extends ApiError {
8
11
  constructor();
9
12
  }
@@ -9,6 +9,11 @@ export class UnauthorizedError extends ApiError {
9
9
  super("Unauthorized. Please reset your authentication by running: npx @zeroheight/adoption-cli auth");
10
10
  }
11
11
  }
12
+ export class IncorrectScopeError extends ApiError {
13
+ constructor() {
14
+ super("The authentication token used does not have the correct scope. \n\nPlease create a new authentication token with the 'Adoption' scopes and then reset your authentication by running: npx @zeroheight/adoption-cli auth");
15
+ }
16
+ }
12
17
  export class UnknownError extends ApiError {
13
18
  constructor() {
14
19
  super("An unknown error occurred while calling the zeroheight API");
@@ -98,7 +98,6 @@ export default function Analyze({ onAnalyzeFiles, onAnalyzeColorUsage, repoName,
98
98
  }
99
99
  else {
100
100
  setCurrentStage(AnalyzeStage.tuConfirmRun);
101
- exit();
102
101
  }
103
102
  }
104
103
  async function fetchCredentials() {
@@ -246,9 +245,9 @@ export default function Analyze({ onAnalyzeFiles, onAnalyzeColorUsage, repoName,
246
245
  if (errorList.length > 0) {
247
246
  return (React.createElement(Box, { flexDirection: "column" },
248
247
  React.createElement(Text, { color: "red" }, "Error:"),
249
- React.createElement(Box, { flexDirection: "column", marginLeft: 1 }, errorList.map((e) => (React.createElement(Text, { key: e },
250
- "- ",
251
- e))))));
248
+ React.createElement(Box, { flexDirection: "column", marginLeft: 1 }, errorList.map((e) => (React.createElement(React.Fragment, null,
249
+ React.createElement(Text, { key: e }, e),
250
+ React.createElement(Newline, null)))))));
252
251
  }
253
252
  if (currentStage === AnalyzeStage.initial) {
254
253
  return (React.createElement(Box, { flexDirection: "column" },
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { Box, Text } from "ink";
2
+ import { Box, Newline, Text } from "ink";
3
3
  import Link from "ink-link";
4
4
  import CredentialsPreview from "./credentials-preview.js";
5
5
  /**
@@ -7,10 +7,10 @@ import CredentialsPreview from "./credentials-preview.js";
7
7
  */
8
8
  export default function CredentialsAlreadyExists({ configPath, existingConfig, }) {
9
9
  return (React.createElement(Box, { flexDirection: "column" },
10
- React.createElement(Text, { bold: true, color: "yellow" }, "Credentials already exist"),
10
+ React.createElement(Text, { bold: true, color: "yellow" }, "You already have your authentication credentials set up"),
11
+ React.createElement(Newline, null),
11
12
  React.createElement(Text, null,
12
- "You already have credentials in",
13
- " ",
13
+ "You can find them in: ",
14
14
  React.createElement(Link, { url: configPath }, configPath)),
15
15
  React.createElement(CredentialsPreview, { client: existingConfig.client, token: existingConfig.token })));
16
16
  }
@@ -19,6 +19,11 @@ export default function NoCredentialsOnboarding({ onCheckCredentials, onSaveCred
19
19
  await onSaveCredentials(answer, client.trim(), token.trim());
20
20
  };
21
21
  return (React.createElement(Box, { flexDirection: "column" },
22
+ React.createElement(Text, null,
23
+ "\uD83D\uDC4B Welcome to the ",
24
+ React.createElement(Text, { color: "#f63e7c" }, "zeroheight"),
25
+ " adoption CLI tool"),
26
+ React.createElement(Newline, null),
22
27
  React.createElement(Text, null,
23
28
  "If you need a new auth token, generate them from the",
24
29
  " ",
@@ -111,9 +111,12 @@ export default function NonInteractiveMonitorRepo({ packageDirs, packageName, })
111
111
  React.createElement(Text, { color: "green" },
112
112
  React.createElement(Spinner, { type: "dots" })),
113
113
  `${name} - sending data to zeroheight...`)),
114
- step === Step.COMPLETE && (React.createElement(Text, null,
115
- React.createElement(Text, { color: "green" }, "Success: "),
116
- `${name} - sent to your zeroheight account`)),
114
+ step === Step.COMPLETE && (React.createElement(Box, { flexDirection: "column" },
115
+ React.createElement(Text, { color: "green" }, "Success"),
116
+ React.createElement(Text, null,
117
+ "Packages being used by ",
118
+ name,
119
+ " have been sent to your zeroheight account"))),
117
120
  step === Step.ERRORED && (React.createElement(Text, null,
118
121
  React.createElement(Text, { color: "red" }, "Error: "),
119
122
  `${name} - ${error}`))))),
@@ -16,9 +16,8 @@ var Step;
16
16
  Step[Step["MULTIPLE_PACKAGES_FOUND"] = 3] = "MULTIPLE_PACKAGES_FOUND";
17
17
  Step[Step["MULTIPLE_PACKAGES_SELECT"] = 4] = "MULTIPLE_PACKAGES_SELECT";
18
18
  Step[Step["SENDING_DETAILS"] = 5] = "SENDING_DETAILS";
19
- Step[Step["SHOULD_SEND_ALL"] = 6] = "SHOULD_SEND_ALL";
20
- Step[Step["SHOULD_SENDING_DETAILS"] = 7] = "SHOULD_SENDING_DETAILS";
21
- Step[Step["SINGLE_PACKAGE_FOUND"] = 8] = "SINGLE_PACKAGE_FOUND";
19
+ Step[Step["SHOULD_SENDING_DETAILS"] = 6] = "SHOULD_SENDING_DETAILS";
20
+ Step[Step["SINGLE_PACKAGE_FOUND"] = 7] = "SINGLE_PACKAGE_FOUND";
22
21
  })(Step || (Step = {}));
23
22
  export default function TrackPackage() {
24
23
  const { exit } = useApp();
@@ -83,7 +82,7 @@ export default function TrackPackage() {
83
82
  setCurrentStep(Step.MULTIPLE_PACKAGES_SELECT);
84
83
  }
85
84
  else {
86
- setCurrentStep(Step.SHOULD_SEND_ALL);
85
+ handleSendToZh(true);
87
86
  }
88
87
  };
89
88
  const handlePackageSelected = ({ label, }) => {
@@ -139,21 +138,23 @@ export default function TrackPackage() {
139
138
  " Searching for package file..."));
140
139
  case Step.SINGLE_PACKAGE_FOUND:
141
140
  return (React.createElement(Box, { flexDirection: "column" },
142
- React.createElement(Text, null,
143
- React.createElement(Text, { color: "green" }, "Details founds:"),
144
- " ",
145
- packageName,
146
- "@",
147
- packageVersion),
141
+ React.createElement(Text, null, "The following package details have been found:"),
142
+ React.createElement(Box, { marginLeft: 1, marginTop: 0.5 },
143
+ React.createElement(Text, null,
144
+ "\uD83D\uDCE6 ",
145
+ packageName,
146
+ "@",
147
+ packageVersion)),
148
148
  React.createElement(Newline, null),
149
149
  React.createElement(Text, null,
150
- "Send to zeroheight? ",
150
+ "Send details to zeroheight? ",
151
151
  React.createElement(Text, { dimColor: true }, "(Y/n):")),
152
152
  React.createElement(ConfirmInput, { isChecked: true, onChange: setShouldSend, onSubmit: handleSendToZh, value: shouldSend })));
153
153
  case Step.MULTIPLE_PACKAGES_FOUND:
154
154
  return (React.createElement(Box, { flexDirection: "column" },
155
155
  React.createElement(Text, null,
156
156
  React.createElement(Text, { color: "green" },
157
+ "\uD83D\uDCE6 ",
157
158
  packageFiles.length,
158
159
  " package files found")),
159
160
  React.createElement(Newline, null),
@@ -179,15 +180,6 @@ export default function TrackPackage() {
179
180
  "Send to zeroheight? ",
180
181
  React.createElement(Text, { dimColor: true }, "(Y/n):")),
181
182
  React.createElement(ConfirmInput, { isChecked: true, onChange: setShouldSend, onSubmit: handleSendToZh, value: shouldSend })));
182
- case Step.SHOULD_SEND_ALL:
183
- return (React.createElement(Box, { flexDirection: "column" },
184
- React.createElement(Text, null,
185
- "Send ",
186
- packageFiles.length,
187
- " packages to zeroheight?",
188
- " ",
189
- React.createElement(Text, { dimColor: true }, "(Y/n):")),
190
- React.createElement(ConfirmInput, { isChecked: true, onChange: setShouldSend, onSubmit: handleSendToZh, value: shouldSend })));
191
183
  case Step.SENDING_DETAILS:
192
184
  return (React.createElement(Text, null,
193
185
  React.createElement(Text, { color: "green" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeroheight/adoption-cli",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "license": "ISC",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {