synthesisui 0.16.373 → 0.16.374
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/doctor.js +86 -34
- package/package.json +1 -1
package/dist/commands/doctor.js
CHANGED
|
@@ -589,6 +589,55 @@ async function readWiring(root, slug) {
|
|
|
589
589
|
}
|
|
590
590
|
/** Onde o retrato mora por default: dentro do que a esteira já escreve, e commitável. */
|
|
591
591
|
const DEFAULT_BASELINE = "_synthesisui/drift-baseline.json";
|
|
592
|
+
/**
|
|
593
|
+
* A PORTA ÚNICA DO `--fix` - e ela existe porque o conserto passou a ter DOIS chamadores.
|
|
594
|
+
*
|
|
595
|
+
* O caminho normal chama com o diagnóstico inteiro. O caminho de um projeto sem fiação chama com o
|
|
596
|
+
* subconjunto que o código DELE já resolve - ver `ownName` e o bloco que decide isso. Duas cópias
|
|
597
|
+
* desta sequência divergiriam no dia em que uma delas ganhasse um passo: o `writeFix` sem o
|
|
598
|
+
* `appendEvent`, ou o recibo sem a linha que manda ler o diff.
|
|
599
|
+
*/
|
|
600
|
+
async function runFix(root, d, writing) {
|
|
601
|
+
const read = await readerFor(root, d.findings.filter((f) => nameToWrite(f)).map((f) => f.file));
|
|
602
|
+
const { result, next } = planFix(d, read);
|
|
603
|
+
if (writing)
|
|
604
|
+
await writeFix(root, next);
|
|
605
|
+
console.log(section(writing ? "Fixed what had an answer" : "What --fix would do"));
|
|
606
|
+
for (const line of describeFix(result, !writing))
|
|
607
|
+
console.log(body(line));
|
|
608
|
+
if (!writing && result.applied.length > 0) {
|
|
609
|
+
console.log("");
|
|
610
|
+
console.log(body("Nothing was written. When the list above is what you want:"));
|
|
611
|
+
console.log(paint.blue(snippet(["npx synthesisui@latest doctor --fix --write"])));
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* O CONSERTO DEIXA RASTRO - ver `CheckEvent.kind: "fix"`.
|
|
615
|
+
*
|
|
616
|
+
* Sem esta linha, "ele trocou 129 valores por token" existia só no terminal daquele minuto: o
|
|
617
|
+
* ledger deduz conserto por arquivo que limpou, e um `--fix` que toca 79 arquivos de uma vez não
|
|
618
|
+
* aparece como um ato.
|
|
619
|
+
*/
|
|
620
|
+
if (writing && result.applied.length > 0) {
|
|
621
|
+
await appendEvent(root, {
|
|
622
|
+
kind: "fix",
|
|
623
|
+
at: new Date().toISOString(),
|
|
624
|
+
named: result.applied.length,
|
|
625
|
+
});
|
|
626
|
+
console.log("");
|
|
627
|
+
console.log(body(paint.dim("Read the diff before committing - it is your code, and this replaced literals with the tokens your own system declares.")));
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* O NOME QUE ESTA TROCA ESCREVERIA É DELE? - a pergunta que a recusa do `--fix` nunca fez.
|
|
632
|
+
*
|
|
633
|
+
* `nameToWrite` devolve `theirToken ?? token`: quando o repositório dele nomeia aquele valor, é o
|
|
634
|
+
* nome DELE que vai para o código. Um nome dele resolve no navegador dele HOJE, com ou sem a nossa
|
|
635
|
+
* folha instalada - a folha só é necessária para os `--ds-*`, que são nossos.
|
|
636
|
+
*/
|
|
637
|
+
const ownName = (f) => {
|
|
638
|
+
const name = nameToWrite(f);
|
|
639
|
+
return Boolean(name && !name.startsWith("--ds-"));
|
|
640
|
+
};
|
|
592
641
|
export async function doctor(opts) {
|
|
593
642
|
const root = resolve(opts.dir ?? process.cwd());
|
|
594
643
|
/**
|
|
@@ -982,9 +1031,42 @@ export async function doctor(opts) {
|
|
|
982
1031
|
}).catch(() => { });
|
|
983
1032
|
console.log("");
|
|
984
1033
|
if (opts.fix) {
|
|
985
|
-
/**
|
|
986
|
-
|
|
987
|
-
|
|
1034
|
+
/**
|
|
1035
|
+
* A RECUSA PASSA A SER POR VALOR, E NÃO PELO COMANDO INTEIRO.
|
|
1036
|
+
*
|
|
1037
|
+
* NASCEU DE UMA PERGUNTA DO DONO (04/09): *"se o design system dele já está funcionando e são
|
|
1038
|
+
* as mesmas referências, faz sentido esse ligamento? combinamos que não seria invasivo"*.
|
|
1039
|
+
*
|
|
1040
|
+
* A MEDIÇÃO DEU RAZÃO A ELE, pelo mesmo caminho que a tela usa (`loadSystem` + `scanSource` +
|
|
1041
|
+
* `diagnose` sobre packages/ui + apps/landing + apps/web do codelevel): dos 216 valores com
|
|
1042
|
+
* nome esperando, **156 (72%) escreveriam o nome DELE** - `--color-brand-violet`,
|
|
1043
|
+
* `--color-tier-gold`, `--duration-base` - e esses resolvem no navegador dele HOJE, sem folha
|
|
1044
|
+
* nenhuma instalada. Só 60 apontam para `--ds-*`, que são nossos e precisam da fiação.
|
|
1045
|
+
*
|
|
1046
|
+
* A recusa olhava `blocked` e nada mais. Ela nunca perguntava de quem era o nome que ia
|
|
1047
|
+
* escrever, embora `nameToWrite` já responda isso (`theirToken ?? token`). O produto recusava
|
|
1048
|
+
* 156 consertos que funcionariam para proteger 60 que quebrariam - e cobrava, em troca, uma
|
|
1049
|
+
* folha inteira dentro do app de alguém que só queria governar o próprio vocabulário.
|
|
1050
|
+
*
|
|
1051
|
+
* ISSO ATINGE O CASO DE USO CENTRAL: quem importa um design system que já existe tem, por
|
|
1052
|
+
* construção, a maioria dos nomes sendo dele.
|
|
1053
|
+
*
|
|
1054
|
+
* O QUE FICA DE FORA CONTINUA SENDO DITO, com o número e o motivo - Lei 8. O que muda é que a
|
|
1055
|
+
* lacuna deixou de fechar a porta inteira.
|
|
1056
|
+
*/
|
|
1057
|
+
const theirs = d.findings.filter(ownName).length;
|
|
1058
|
+
const ours = d.findings.filter((f) => nameToWrite(f) && !ownName(f)).length;
|
|
1059
|
+
if (theirs > 0) {
|
|
1060
|
+
console.log(body(`${theirs} of your hand-written values ${theirs === 1 ? "carries" : "carry"} a name your own code declares, and ${theirs === 1 ? "it resolves" : "those resolve"} today - --fix will swap ${theirs === 1 ? "it" : "them"}.`));
|
|
1061
|
+
if (ours > 0)
|
|
1062
|
+
console.log(body(`${ours} more point at ${table.name ?? table.slug} tokens, which only resolve once the wiring above is done. Left alone.`));
|
|
1063
|
+
console.log("");
|
|
1064
|
+
await runFix(root, { ...d, findings: d.findings.filter(ownName) }, opts.write === true);
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
/** Nenhum nome dele em jogo: aqui a recusa continua sendo a resposta certa, e inteira. */
|
|
1068
|
+
const one = ours === 1;
|
|
1069
|
+
console.log(body(`--fix is refused while ${bothMissing ? "those two are" : "that one is"} false. ${ours} of your hand-written values`));
|
|
988
1070
|
console.log(body(`${one ? "does" : "do"} have a name in the system, and swapping ${one ? "it" : "them"} now would point ${one ? "it" : "them"} at`));
|
|
989
1071
|
console.log(body(`variables the browser cannot resolve - the ${one ? "declaration" : "declarations"} would be dropped`));
|
|
990
1072
|
console.log(body(`and the page would change. Wire ${bothMissing ? "the two lines" : "that line"} first.`));
|
|
@@ -1878,37 +1960,7 @@ export async function doctor(opts) {
|
|
|
1878
1960
|
* 1500 achados e depois dizer "troquei 900" é fazer a pessoa procurar a linha que importa.
|
|
1879
1961
|
*/
|
|
1880
1962
|
if (opts.fix) {
|
|
1881
|
-
|
|
1882
|
-
const { result, next } = planFix(d, read);
|
|
1883
|
-
const writing = opts.write === true;
|
|
1884
|
-
if (writing)
|
|
1885
|
-
await writeFix(root, next);
|
|
1886
|
-
console.log(section(writing ? "Fixed what had an answer" : "What --fix would do"));
|
|
1887
|
-
for (const line of describeFix(result, !writing))
|
|
1888
|
-
console.log(body(line));
|
|
1889
|
-
if (!writing && result.applied.length > 0) {
|
|
1890
|
-
console.log("");
|
|
1891
|
-
console.log(body("Nothing was written. When the list above is what you want:"));
|
|
1892
|
-
console.log(paint.blue(snippet(["npx synthesisui@latest doctor --fix --write"])));
|
|
1893
|
-
}
|
|
1894
|
-
/**
|
|
1895
|
-
* O CONSERTO DEIXA RASTRO - ver `CheckEvent.kind: "fix"`.
|
|
1896
|
-
*
|
|
1897
|
-
* Sem esta linha, "ele trocou 129 valores por token" existia só no terminal daquele minuto: o
|
|
1898
|
-
* ledger deduz conserto por arquivo que limpou, e um `--fix` que toca 79 arquivos de uma vez não
|
|
1899
|
-
* aparece como um ato.
|
|
1900
|
-
*/
|
|
1901
|
-
if (writing && result.applied.length > 0) {
|
|
1902
|
-
await appendEvent(root, {
|
|
1903
|
-
kind: "fix",
|
|
1904
|
-
at: new Date().toISOString(),
|
|
1905
|
-
named: result.applied.length,
|
|
1906
|
-
});
|
|
1907
|
-
}
|
|
1908
|
-
if (writing && result.applied.length > 0) {
|
|
1909
|
-
console.log("");
|
|
1910
|
-
console.log(body(paint.dim("Read the diff before committing - it is your code, and this replaced literals with the tokens your own system declares.")));
|
|
1911
|
-
}
|
|
1963
|
+
await runFix(root, d, opts.write === true);
|
|
1912
1964
|
return;
|
|
1913
1965
|
}
|
|
1914
1966
|
if (opts.writeBaseline) {
|
package/package.json
CHANGED