@groma/scanner-react 0.2.1 → 0.2.3

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/README.md CHANGED
@@ -15,7 +15,7 @@ bun plugins/scanners/react/build.ts
15
15
  From the project being scanned:
16
16
 
17
17
  ```sh
18
- groma scanner add /absolute/path/to/groma/plugins/scanners/react/dist/package
18
+ groma plugin add /absolute/path/to/groma/plugins/scanners/react/dist/package
19
19
  groma scanner check
20
20
  groma scan
21
21
  ```
package/dist/index.js CHANGED
@@ -603,20 +603,32 @@ function reachedFiles(entry, compiled, imports, packages, units) {
603
603
  }
604
604
  async function declaredEntries(root, declarations, packages, workspaces) {
605
605
  const entries = [];
606
+ const diagnostics = [];
606
607
  for (const file of declarations) {
607
608
  const text = await readFile3(path4.join(root, file), "utf8");
608
609
  const name = path4.posix.basename(file);
609
- if (name === "package.json") {
610
- const manifest = JSON.parse(text);
611
- entries.push(...declaredBins(file, manifest), ...declaredScripts(file, manifest.scripts));
612
- } else if (name === "angular.json")
613
- entries.push(...angularEntries(file, text));
614
- else if (name === "project.json")
615
- entries.push(...nxEntries(file, text, workspaces));
616
- else if (file.endsWith(".html"))
617
- entries.push(...browserEntries(file, text, packages));
610
+ try {
611
+ if (name === "package.json") {
612
+ const manifest = JSON.parse(text);
613
+ entries.push(...declaredBins(file, manifest), ...declaredScripts(file, manifest.scripts));
614
+ } else if (name === "angular.json")
615
+ entries.push(...angularEntries(file, text));
616
+ else if (name === "project.json")
617
+ entries.push(...nxEntries(file, text, workspaces));
618
+ else if (file.endsWith(".html"))
619
+ entries.push(...browserEntries(file, text, packages));
620
+ } catch (error) {
621
+ if (!(error instanceof SyntaxError))
622
+ throw error;
623
+ diagnostics.push({
624
+ severity: "warning",
625
+ code: "JAVASCRIPT_MANIFEST_INVALID",
626
+ file,
627
+ message: `The file is not valid JSON; the entry points it declares are not read. ${error.message}`
628
+ });
629
+ }
618
630
  }
619
- return entries;
631
+ return { entries, diagnostics };
620
632
  }
621
633
  function sourced(entry, files, outputs = []) {
622
634
  const file = sourceOf(entry.file, outputs, files);
@@ -630,7 +642,8 @@ async function withJavaScriptEntries(root, observation, inputs, files) {
630
642
  const packages = new Set(inventory.filter((file) => path4.posix.basename(file) === "package.json").map((file) => path4.posix.dirname(file)));
631
643
  const active = new Set(observation.files.map((file) => packageFor(file.file, packages)));
632
644
  const declarations = inventory.filter((file) => path4.posix.basename(file) !== "nx.json" && active.has(packageFor(file, packages)));
633
- const entries = [...inputs.entries, ...await declaredEntries(root, declarations, packages, workspaces)];
645
+ const declared = await declaredEntries(root, declarations, packages, workspaces);
646
+ const entries = [...inputs.entries, ...declared.entries];
634
647
  const inventoryFiles = [...observation.files];
635
648
  const visible = new Set(inventoryFiles.map((file) => file.file));
636
649
  const readable = new Set(files);
@@ -647,7 +660,12 @@ async function withJavaScriptEntries(root, observation, inputs, files) {
647
660
  }
648
661
  return [{ ...entry, files: [...new Set([entry.file, ...members.map((file) => file.file)])] }];
649
662
  });
650
- return createScanObservation({ ...observation, files: inventoryFiles, entryPoints });
663
+ return createScanObservation({
664
+ ...observation,
665
+ files: inventoryFiles,
666
+ entryPoints,
667
+ diagnostics: [...observation.diagnostics, ...declared.diagnostics]
668
+ });
651
669
  }
652
670
 
653
671
  // plugins/scanners/entry-points/source.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groma/scanner-react",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Complementary React framework evidence; a dependency declaration does not verify runtime use.",
5
5
  "private": false,
6
6
  "type": "module",
package/validation.md CHANGED
@@ -49,7 +49,7 @@ repository TypeScript check passed.
49
49
 
50
50
  ```sh
51
51
  bun test --timeout 20000 test-bun/react-scanner.test.ts
52
- bunx biome lint plugins/scanners/react/src plugins/scanners/react/build.ts test-bun/react-scanner.test.ts
52
+ bun run biome lint plugins/scanners/react/src plugins/scanners/react/build.ts test-bun/react-scanner.test.ts
53
53
  bun run typecheck
54
54
  ```
55
55