synthesisui 0.16.167 → 0.16.169
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/commands/import.js
CHANGED
|
@@ -982,10 +982,11 @@ export async function takeCensus(root, opts) {
|
|
|
982
982
|
* percorrer o repo inteiro de novo por um dado que este laço já tem na mão. Ver `reachability.ts`.
|
|
983
983
|
*/
|
|
984
984
|
const edges = new Map();
|
|
985
|
-
|
|
985
|
+
/** Por raiz: `@/` é uma pasta diferente em cada app - ver `reachabilityOf`. */
|
|
986
|
+
const graphRoots = [];
|
|
986
987
|
for (const u of opts?.usage ?? []) {
|
|
987
988
|
const uInternal = await internalSpecifiers(u.path);
|
|
988
|
-
|
|
989
|
+
graphRoots.push({ path: u.path, aliases: await aliasesOf(u.path) });
|
|
989
990
|
for await (const file of walk(u.path)) {
|
|
990
991
|
const src = await readFile(file, "utf8").catch(() => "");
|
|
991
992
|
if (!src)
|
|
@@ -1231,7 +1232,7 @@ export async function takeCensus(root, opts) {
|
|
|
1231
1232
|
* O GRAFO SÓ FECHA DEPOIS QUE TODOS OS ARQUIVOS FORAM VISTOS: um especificador só resolve para um
|
|
1232
1233
|
* arquivo que já esteja na lista, então isto não pode rodar dentro do laço que a preenche.
|
|
1233
1234
|
*/
|
|
1234
|
-
const reachability = edges.size > 0 ? await reachabilityOf({ edges,
|
|
1235
|
+
const reachability = edges.size > 0 ? await reachabilityOf({ edges, roots: graphRoots }) : null;
|
|
1235
1236
|
const coverage = summarizeCoverage(shapes, defined.length || componentFiles, Object.keys(looks).length, Object.values(looks).reduce((n, look) => n +
|
|
1236
1237
|
Object.keys(look.base).length +
|
|
1237
1238
|
Object.keys(look.dark ?? {}).length +
|
|
@@ -215,13 +215,17 @@ export async function reachabilityOf(input) {
|
|
|
215
215
|
!/\/[a-z.-]+\.config\.[jt]sx?$/.test(f)));
|
|
216
216
|
const graph = new Map();
|
|
217
217
|
let unresolved = 0;
|
|
218
|
+
/** A raiz MAIS LONGA que contém o arquivo - um app dentro de outro resolve pelo mais específico. */
|
|
219
|
+
const rootOf = (file) => input.roots
|
|
220
|
+
.filter((r) => file.startsWith(`${r.path}/`))
|
|
221
|
+
.sort((a, b) => b.path.length - a.path.length)[0]?.aliases ?? [];
|
|
218
222
|
for (const [file, specs] of input.edges) {
|
|
219
223
|
if (!known.has(file))
|
|
220
224
|
continue;
|
|
225
|
+
const aliases = rootOf(file);
|
|
221
226
|
const out = [];
|
|
222
227
|
for (const spec of specs) {
|
|
223
|
-
const mine = spec.startsWith(".") ||
|
|
224
|
-
input.aliases.some((a) => spec.startsWith(a.prefix));
|
|
228
|
+
const mine = spec.startsWith(".") || aliases.some((a) => spec.startsWith(a.prefix));
|
|
225
229
|
/**
|
|
226
230
|
* Pacote de terceiro não é aresta deste repo. Mas um apelido LOCAL que nenhum alias casa é uma
|
|
227
231
|
* aresta PERDIDA - e era descartado aqui em silêncio, o que subia o número de mortos sem a
|
|
@@ -232,7 +236,7 @@ export async function reachabilityOf(input) {
|
|
|
232
236
|
unresolved += 1;
|
|
233
237
|
continue;
|
|
234
238
|
}
|
|
235
|
-
const hit = await toFile(known, file, spec,
|
|
239
|
+
const hit = await toFile(known, file, spec, aliases, isFile);
|
|
236
240
|
if (hit)
|
|
237
241
|
out.push(hit);
|
|
238
242
|
/**
|
|
@@ -256,11 +260,21 @@ export async function reachabilityOf(input) {
|
|
|
256
260
|
if (!seen.has(next))
|
|
257
261
|
queue.push(next);
|
|
258
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* ALCANÇADOS DENTRO DO UNIVERSO, e não `seen.size`.
|
|
265
|
+
*
|
|
266
|
+
* A travessia atravessa para fora: um alias que aponta para outro pacote do monorepo resolve no
|
|
267
|
+
* disco e entra em `seen`, mas não está em `known` - o universo é o que foi varrido. Contar
|
|
268
|
+
* `seen.size` inflava `reached` com nós de fora e fazia `reached + unreached` não fechar com
|
|
269
|
+
* `files`, o que produziu um "19% morto" que na verdade é 41% (dono, 07/08). Um número que não
|
|
270
|
+
* fecha com a própria soma é um número que ninguém pode checar.
|
|
271
|
+
*/
|
|
272
|
+
const unreached = [...known].filter((f) => !seen.has(f)).sort();
|
|
259
273
|
return {
|
|
260
274
|
entries: entries.length,
|
|
261
275
|
files: known.size,
|
|
262
|
-
reached:
|
|
263
|
-
unreached
|
|
276
|
+
reached: known.size - unreached.length,
|
|
277
|
+
unreached,
|
|
264
278
|
unresolved,
|
|
265
279
|
};
|
|
266
280
|
}
|
package/package.json
CHANGED