@miadi/relational-git-repository-mapper 0.6.1 → 0.6.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/dist/hosts.d.ts CHANGED
@@ -18,18 +18,18 @@ export declare const RepositoryWhereSchema: z.ZodObject<{
18
18
  host: "github" | "host-git" | "missing" | "unchecked";
19
19
  checkedBy: string;
20
20
  checkedAt: string;
21
+ private?: boolean | undefined;
21
22
  note?: string | undefined;
22
23
  url?: string | undefined;
23
- private?: boolean | undefined;
24
24
  archived?: boolean | undefined;
25
25
  }, {
26
26
  repository: string;
27
27
  host: "github" | "host-git" | "missing" | "unchecked";
28
28
  checkedBy: string;
29
29
  checkedAt: string;
30
+ private?: boolean | undefined;
30
31
  note?: string | undefined;
31
32
  url?: string | undefined;
32
- private?: boolean | undefined;
33
33
  archived?: boolean | undefined;
34
34
  }>;
35
35
  export type RepositoryWhere = z.infer<typeof RepositoryWhereSchema>;
package/dist/read.js CHANGED
@@ -60,7 +60,7 @@ function readWhere(path = process.env.MIADI_REPOSITORY_HOSTS?.trim() || undefine
60
60
  function readPackages(file = process.env.MIADI_REPOSITORY_PACKAGES) {
61
61
  const packages = [];
62
62
  const issues = [];
63
- // A host's own reading first (`mw-repomap capabilities map --packages <file>`): the first to name a package speaks for it.
63
+ // A host's own reading first (`mw-repomap capabilities map --packages <file>`): the first to name a package of a repository speaks for it.
64
64
  if (file) {
65
65
  try {
66
66
  const parsed = (0, developer_repository_mapping_1.parseJsonl)((0, node_fs_1.readFileSync)(file, "utf8"), impact_1.PackageReadingSchema, file);
@@ -71,11 +71,12 @@ function readPackages(file = process.env.MIADI_REPOSITORY_PACKAGES) {
71
71
  issues.push({ severity: "error", file, message: `could not read: ${error.message}` });
72
72
  }
73
73
  }
74
- const named = new Set(packages.map((p) => p.name));
74
+ const key = (p) => `${p.repository.toLowerCase()}|${p.name}`;
75
+ const named = new Set(packages.map(key));
75
76
  shipped_capabilities_1.SHIPPED_PACKAGES.forEach((row, index) => {
76
77
  const parsed = impact_1.PackageReadingSchema.safeParse(row);
77
78
  if (parsed.success) {
78
- if (!named.has(parsed.data.name))
79
+ if (!named.has(key(parsed.data)))
79
80
  packages.push(parsed.data);
80
81
  }
81
82
  else
@@ -118,12 +119,14 @@ function readCapabilities(path = process.env.MIADI_REPOSITORY_CAPABILITIES?.trim
118
119
  issues.push({ severity: "error", file: source, line: index + 1, message: parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ") });
119
120
  return;
120
121
  }
121
- const earlier = seen.get(parsed.data.nodeId);
122
+ // One row per capability and provider: two repositories with one id (a fork and its upstream) each keep their own words.
123
+ const key = `${parsed.data.nodeId}|${parsed.data.providedBy.map((p) => p.toLowerCase()).sort().join(",")}`;
124
+ const earlier = seen.get(key);
122
125
  if (earlier) {
123
- issues.push({ severity: "warning", file: source, nodeId: parsed.data.nodeId, message: `${parsed.data.nodeId} is already read from ${earlier}; skipped` });
126
+ issues.push({ severity: "warning", file: source, nodeId: parsed.data.nodeId, message: `${parsed.data.nodeId} of ${parsed.data.providedBy.join(", ")} is already read from ${earlier}; skipped` });
124
127
  return;
125
128
  }
126
- seen.set(parsed.data.nodeId, source);
129
+ seen.set(key, source);
127
130
  capabilities.push(parsed.data);
128
131
  });
129
132
  }
@@ -159,8 +162,10 @@ function findCapability(parts, options = {}) {
159
162
  const provider = c.providedBy.find((p) => p.toLowerCase() === repository);
160
163
  if (!provider)
161
164
  continue;
165
+ // The provider's own reading: a fork, or another repository with a package of the same name, never speaks for it.
162
166
  const { packages } = readPackages();
163
- const impact = kind === "package" ? (0, impact_1.impactOf)(c.name, packages) : undefined;
167
+ const own = packages.find((p) => p.name === c.name && p.repository.toLowerCase() === repository);
168
+ const impact = kind === "package" && own ? (0, impact_1.impactOf)(c.name, packages, undefined, { repository: own.repository }) : undefined;
164
169
  const related = [];
165
170
  const version = (v) => (v ? { version: v } : {});
166
171
  if (impact) {
@@ -168,7 +173,7 @@ function findCapability(parts, options = {}) {
168
173
  related.push({ relation: "consumes", kind: "package", name: l.name, address: (0, capabilities_2.capabilityAddress)(l.repository, "package", l.name), ...version(l.version), range: l.range });
169
174
  for (const l of impact.consumers.filter((x) => x.depth === 1))
170
175
  related.push({ relation: "consumed-by", kind: "package", name: l.name, address: (0, capabilities_2.capabilityAddress)(l.repository, "package", l.name), ...version(l.version), range: l.range });
171
- for (const bin of packages.find((p) => p.name === c.name)?.bins ?? [])
176
+ for (const bin of own?.bins ?? [])
172
177
  related.push({ relation: "ships", kind: "cli", name: bin, address: (0, capabilities_2.capabilityAddress)(provider, "cli", bin) });
173
178
  }
174
179
  if (kind === "cli") {