@miadi/relational-git-repository-mapper 0.6.1 → 0.6.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/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
@@ -159,8 +160,11 @@ function findCapability(parts, options = {}) {
159
160
  const provider = c.providedBy.find((p) => p.toLowerCase() === repository);
160
161
  if (!provider)
161
162
  continue;
162
- const { packages } = readPackages();
163
- const impact = kind === "package" ? (0, impact_1.impactOf)(c.name, packages) : undefined;
163
+ // The provider's own reading: a fork, or another repository with a package of the same name, never speaks for it.
164
+ const { packages: all } = readPackages();
165
+ const own = all.find((p) => p.name === c.name && p.repository.toLowerCase() === repository);
166
+ const packages = all.filter((p) => p.name !== c.name || p === own);
167
+ const impact = kind === "package" && own ? (0, impact_1.impactOf)(c.name, packages) : undefined;
164
168
  const related = [];
165
169
  const version = (v) => (v ? { version: v } : {});
166
170
  if (impact) {
@@ -168,7 +172,7 @@ function findCapability(parts, options = {}) {
168
172
  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
173
  for (const l of impact.consumers.filter((x) => x.depth === 1))
170
174
  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 ?? [])
175
+ for (const bin of own?.bins ?? [])
172
176
  related.push({ relation: "ships", kind: "cli", name: bin, address: (0, capabilities_2.capabilityAddress)(provider, "cli", bin) });
173
177
  }
174
178
  if (kind === "cli") {