@zeroheight/adoption-cli 2.4.0 → 2.4.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,9 +1,16 @@
1
1
  # Release notes
2
2
 
3
- ## [2.4.0](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/2.4.0) - 10th December 2024
3
+ ## [2.4.2](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/2.4.2) - 17th December 2024
4
+
5
+ - Fix issue with parsing pnpm lockfiles using version `6.0`
6
+
7
+ ## [2.4.1](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/2.4.1) - 11th December 2024
4
8
 
5
- - `analyze --ignore` option can be used moe than once to allow for more glob patterns, this fixes an issue in **2.3.0** where glob patterns containing commas would not work as expected
9
+ - The monitor-repo command now supports custom package naming for projects.
10
+
11
+ ## [2.4.0](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/2.4.0) - 10th December 2024
6
12
 
13
+ - `analyze --ignore` option can be used more than once to allow for more glob patterns, this fixes an issue in **2.3.0** where glob patterns containing commas would not work as expected
7
14
 
8
15
  ## [2.3.0](https://www.npmjs.com/package/@zeroheight/adoption-cli/v/2.3.0) - 5th December 2024
9
16
 
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ const { output, cleanup } = render(React.createElement(HelpInfo, null));
13
13
  program
14
14
  .name("zh-adoption")
15
15
  .description("CLI for measuring design system usage usage in your products")
16
- .version("2.4.0")
16
+ .version("2.4.2")
17
17
  .addHelpText("before", output)
18
18
  .option("--log-file <path>", "Path to write logs to, if not provided logs only error logs will be written to stderr")
19
19
  .addOption(new Option("--log-level <level>", "The lowest level of logs to display")
@@ -3,6 +3,7 @@ import { RenderOptions } from "ink";
3
3
  interface MonitorRepoOptions {
4
4
  interactive: boolean;
5
5
  dir?: string[];
6
+ packageName?: string;
6
7
  }
7
8
  export declare function monitorRepoAction(options: MonitorRepoOptions, _renderOptions?: RenderOptions): Promise<void>;
8
9
  export declare function monitorRepoCommand(): Command;
@@ -8,7 +8,7 @@ export async function monitorRepoAction(options, _renderOptions) {
8
8
  // if (options.interactive) {
9
9
  // render(<MonitorRepo />, renderOptions);
10
10
  // } else {
11
- render(React.createElement(NonInteractiveMonitorRepo, { packageDirs: options.dir }));
11
+ render(React.createElement(NonInteractiveMonitorRepo, { packageDirs: options.dir, packageName: options.packageName }));
12
12
  // }
13
13
  }
14
14
  export function monitorRepoCommand() {
@@ -28,6 +28,7 @@ export function monitorRepoCommand() {
28
28
  // .argParser((value) => yn(value))
29
29
  // )
30
30
  .addOption(new Option("-d, --dir <path...>", "use package directory to find package.json and lockfile"))
31
+ .addOption(new Option("-p, --package-name <name>", "specify the name used to identify the package in zeroheight"))
31
32
  .action(async (options) => {
32
33
  setStdErrStream();
33
34
  try {
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  interface NonInteractiveMonitorRepoProps {
3
3
  packageDirs?: string[];
4
+ packageName?: string;
4
5
  }
5
- export default function NonInteractiveMonitorRepo({ packageDirs, }: NonInteractiveMonitorRepoProps): React.JSX.Element;
6
+ export default function NonInteractiveMonitorRepo({ packageDirs, packageName, }: NonInteractiveMonitorRepoProps): React.JSX.Element;
6
7
  export {};
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { Box, Text } from "ink";
3
3
  import Spinner from "ink-spinner";
4
- import { join as joinPath } from "path";
4
+ import { basename, join as joinPath } from "path";
5
5
  import { findLockfiles, getPackageMeta, groupByBasename, parseLockfile, } from "../../commands/monitor-repo.utils.js";
6
6
  import { findPackageFiles } from "../../commands/track-package.utils.js";
7
7
  import { ResponseStatus, submitMonitoredRepoDetails, } from "../../common/api.js";
@@ -15,7 +15,7 @@ var Step;
15
15
  Step[Step["FINDING_DETAILS"] = 2] = "FINDING_DETAILS";
16
16
  Step[Step["SENDING_DATA"] = 3] = "SENDING_DATA";
17
17
  })(Step || (Step = {}));
18
- export default function NonInteractiveMonitorRepo({ packageDirs, }) {
18
+ export default function NonInteractiveMonitorRepo({ packageDirs, packageName, }) {
19
19
  const [errorMessage, setErrorMessage] = React.useState(); // Global error message
20
20
  const [repoStatus, setRepoStatus] = React.useState({});
21
21
  function updateRepoStatus(name, step, error) {
@@ -51,6 +51,13 @@ export default function NonInteractiveMonitorRepo({ packageDirs, }) {
51
51
  let packageMeta;
52
52
  try {
53
53
  packageMeta = await getPackageMeta(joinPath(directory, "package.json"));
54
+ if (packageName) {
55
+ packageMeta.name = packageName;
56
+ }
57
+ if (!packageMeta.name) {
58
+ setErrorMessage(`Name field is missing in your ${basename(directory)}/package.json file. Re-run the command with --package-name <name> to continue.`);
59
+ continue;
60
+ }
54
61
  }
55
62
  catch (e) {
56
63
  // package.json doesn't exist or is invalid, skip pair
@@ -37,7 +37,13 @@ _PNPMLockParser_instances = new WeakSet(), _PNPMLockParser_parseV5 = function _P
37
37
  }, _PNPMLockParser_parseV6 = function _PNPMLockParser_parseV6(data) {
38
38
  return Object.keys(data.packages)
39
39
  .map((packagePair) => {
40
- const [name, version] = packagePair.split("@");
40
+ const lastIndex = packagePair.lastIndexOf("@");
41
+ let name = packagePair.slice(0, lastIndex);
42
+ const version = packagePair.slice(lastIndex + 1);
43
+ // v6 lockfiles have a leading slash
44
+ if (name.startsWith("/")) {
45
+ name = name.slice(1);
46
+ }
41
47
  return { name, version };
42
48
  })
43
49
  .filter((p) => p.name && p.version);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeroheight/adoption-cli",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "license": "ISC",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {