@brutalway/check-tree 0.10.0 → 0.10.1

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/dist/checkTree.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as treeViolations } from "./treeViolations-DV1n3hcr.js";
3
- import { n as cruiseImports, t as sliceViolations } from "./sliceViolations-BfTZYfD3.js";
3
+ import { n as cruiseImports, t as sliceViolations } from "./sliceViolations-B4iDNwD2.js";
4
4
  import { resolve } from "node:path";
5
5
  import { parseArgs } from "node:util";
6
6
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { n as cruiseImports, t as sliceViolations } from "./sliceViolations-BfTZYfD3.js";
1
+ import { n as cruiseImports, t as sliceViolations } from "./sliceViolations-B4iDNwD2.js";
2
2
  // src/sharedViolations.ts
3
3
  async function sharedViolations(root, platforms) {
4
4
  return sliceViolations(root, await cruiseImports(root), platforms);
@@ -46,13 +46,19 @@ function slotOf(owner, importer) {
46
46
  const slice = SLICE.exec(importer.slice(owner.length + 1));
47
47
  return slice === null ? owner : `${owner}/${slice[0]}`;
48
48
  }
49
- function importersByModule(modules) {
49
+ function unitOf(path, platforms) {
50
+ return `${dirname(path)}/${platformBase(basename(path), platforms)}`;
51
+ }
52
+ function importersByUnit(modules, platforms) {
50
53
  const importers = /* @__PURE__ */ new Map();
51
- for (const { source, imports } of modules) for (const target of imports) importers.set(target, [...importers.get(target) ?? [], source]);
54
+ for (const { source, imports } of modules) for (const target of imports) {
55
+ const unit = unitOf(target, platforms);
56
+ importers.set(unit, [...importers.get(unit) ?? [], source]);
57
+ }
52
58
  return importers;
53
59
  }
54
- function consumerSlots(modules) {
55
- const importers = importersByModule(modules);
60
+ function consumerSlots(modules, platforms) {
61
+ const importers = importersByUnit(modules, platforms);
56
62
  const slotsByModule = /* @__PURE__ */ new Map();
57
63
  return function slots(path, slice) {
58
64
  const key = `${slice.folder}:${path}`;
@@ -60,7 +66,7 @@ function consumerSlots(modules) {
60
66
  if (known !== void 0) return known;
61
67
  const found = /* @__PURE__ */ new Set();
62
68
  slotsByModule.set(key, found);
63
- for (const importer of importers.get(path) ?? []) if (importer.startsWith(`${slice.folder}/`)) for (const slot of slots(importer, slice)) found.add(slot);
69
+ for (const importer of importers.get(unitOf(path, platforms)) ?? []) if (importer.startsWith(`${slice.folder}/`)) for (const slot of slots(importer, slice)) found.add(slot);
64
70
  else found.add(slotOf(slice.owner, importer));
65
71
  return found;
66
72
  };
@@ -79,9 +85,9 @@ function violation(path, owner, slot) {
79
85
  if (slot === owner) return `${path} is only used by ${owner} outside its sub-features: move it out of shared/ into the kind folders of ${owner}`;
80
86
  return `${path} is only used by ${slot}: move it into ${slot}`;
81
87
  }
82
- function sharedConsumerViolations(checkedFolder, modules) {
88
+ function sharedConsumerViolations(checkedFolder, modules, platforms) {
83
89
  const { root, shown } = checkedPaths(checkedFolder);
84
- const slots = consumerSlots(modules);
90
+ const slots = consumerSlots(modules, platforms);
85
91
  return modules.flatMap(({ source }) => {
86
92
  const slice = sliceOf(source);
87
93
  if (slice === void 0 || TEST_CODE.test(source) || !source.startsWith(`${root}/`)) return [];
@@ -147,6 +153,6 @@ function sliceGroupViolations(checkedFolder, modules, platforms) {
147
153
  }
148
154
  // src/features/shared-consumers/lib/sliceViolations.ts
149
155
  function sliceViolations(checkedFolder, modules, platforms) {
150
- return [...sharedConsumerViolations(checkedFolder, modules), ...sliceGroupViolations(checkedFolder, modules, platforms)];
156
+ return [...sharedConsumerViolations(checkedFolder, modules, platforms), ...sliceGroupViolations(checkedFolder, modules, platforms)];
151
157
  }
152
158
  export { cruiseImports as n, sliceViolations as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brutalway/check-tree",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Checks a source tree: only the folders the layout names, no empty folder, no category folder holding a single child, stylesheets grouped in styles/, no file of a slice of shared/ used by a single feature, no slice whose files never import each other.",
5
5
  "keywords": [
6
6
  "lint",