synthesisui 0.16.247 → 0.16.248
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/list.js +40 -2
- package/dist/index.js +12 -1
- package/dist/registry.js +18 -0
- package/package.json +1 -1
package/dist/commands/list.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
import { resolveRegistry } from "../config.js";
|
|
2
|
-
import { fetchList } from "../registry.js";
|
|
3
|
-
/**
|
|
2
|
+
import { fetchList, fetchMine } from "../registry.js";
|
|
3
|
+
/**
|
|
4
|
+
* O CATÁLOGO, E OS SISTEMAS DELA - duas perguntas diferentes, um comando.
|
|
5
|
+
*
|
|
6
|
+
* Sem `--mine` este comando sempre respondeu "o que existe para instalar": a
|
|
7
|
+
* galeria pública, sem dono. Ele nunca mostrou os sistemas de quem o roda, ao
|
|
8
|
+
* contrário do que o levantamento dizia - e essa era a lacuna real.
|
|
9
|
+
*
|
|
10
|
+
* NO TERMINAL NÃO HAVIA COMO SABER DE QUE GRUPO É CADA SISTEMA, e isso passou a
|
|
11
|
+
* ter consequência: o `sync` escreve direto no rascunho e o Autopilot publica
|
|
12
|
+
* sozinho quando ligado. Até aqui, o único freio contra mexer no sistema errado
|
|
13
|
+
* era a pessoa lembrar de cabeça.
|
|
14
|
+
*/
|
|
4
15
|
export async function list(opts) {
|
|
5
16
|
const base = resolveRegistry(opts.registry);
|
|
17
|
+
if (opts.mine) {
|
|
18
|
+
const mine = await fetchMine(base);
|
|
19
|
+
if (mine.length === 0) {
|
|
20
|
+
console.log("You have no design systems yet. `synthesisui init` starts one from this repo.");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log("Your design systems:\n");
|
|
24
|
+
const width = Math.max(...mine.map((s) => s.slug.length));
|
|
25
|
+
for (const s of mine) {
|
|
26
|
+
/**
|
|
27
|
+
* O GRUPO ENTRE PARÊNTESES, e "invited" quando ele não é dela - as duas
|
|
28
|
+
* informações que decidem se aquele é o sistema em que ela quer escrever.
|
|
29
|
+
*/
|
|
30
|
+
const group = s.group
|
|
31
|
+
? `${s.group}${s.mine ? "" : ", invited"}`
|
|
32
|
+
: "no group";
|
|
33
|
+
console.log(` ${s.slug.padEnd(width)} ${s.name} (v${s.version}) · ${group}`);
|
|
34
|
+
}
|
|
35
|
+
console.log('\nWork in one with: synthesisui use <slug> "<what you are building>"');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
6
38
|
const systems = await fetchList(base);
|
|
7
39
|
if (systems.length === 0) {
|
|
8
40
|
console.log(`No design systems published at ${base}.`);
|
|
@@ -14,4 +46,10 @@ export async function list(opts) {
|
|
|
14
46
|
console.log(` ${s.slug.padEnd(width)} ${s.name} (v${s.version})`);
|
|
15
47
|
}
|
|
16
48
|
console.log(`\nBring one in with: synthesisui add <slug>`);
|
|
49
|
+
/**
|
|
50
|
+
* E A OUTRA PERGUNTA FICA DITA. Quem roda `list` procurando os PRÓPRIOS
|
|
51
|
+
* sistemas recebia a galeria e nenhuma pista de que existe outra lista - a
|
|
52
|
+
* lacuna calada mais barata de fechar que existe.
|
|
53
|
+
*/
|
|
54
|
+
console.log(`Your own systems: synthesisui list --mine`);
|
|
17
55
|
}
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ Usage - deterministic, FREE:
|
|
|
39
39
|
synthesisui login [options] connect the CLI to your account (device-flow; --force to switch accounts)
|
|
40
40
|
synthesisui init [options] write _synthesisui/config.json (target, dirs); --ds to bring one in
|
|
41
41
|
synthesisui list [options] list the published design systems
|
|
42
|
+
synthesisui list --mine your own systems, with their group
|
|
42
43
|
synthesisui add <slug> [options] materialize a DS into _synthesisui/ds/<slug>/
|
|
43
44
|
synthesisui component <slug> <name> bring one EXISTING component in as YOUR <Pascal>.tsx
|
|
44
45
|
synthesisui template <slug> <name> materialize a whole page from a DS template
|
|
@@ -365,7 +366,17 @@ async function main() {
|
|
|
365
366
|
});
|
|
366
367
|
break;
|
|
367
368
|
case "list":
|
|
368
|
-
|
|
369
|
+
/**
|
|
370
|
+
* `--mine` responde a OUTRA pergunta: os sistemas desta pessoa, com o
|
|
371
|
+
* grupo de cada um. Sem a flag, o comando segue sendo o catálogo público
|
|
372
|
+
* que ele sempre foi.
|
|
373
|
+
*/
|
|
374
|
+
/**
|
|
375
|
+
* `flags.mine`, e não `args`: o parser tira toda `--flag` dos
|
|
376
|
+
* posicionais, então procurá-la ali sempre responderia não - e o comando
|
|
377
|
+
* cairia calado no catálogo público, que é a lista errada.
|
|
378
|
+
*/
|
|
379
|
+
await list({ registry, mine: flags.mine === true });
|
|
369
380
|
break;
|
|
370
381
|
case "add": {
|
|
371
382
|
const slug = args[0];
|
package/dist/registry.js
CHANGED
|
@@ -25,6 +25,24 @@ export async function fetchList(base) {
|
|
|
25
25
|
const body = (await res.json());
|
|
26
26
|
return body.designSystems ?? [];
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* OS SISTEMAS DELA - e esta é a chamada que exige conta.
|
|
30
|
+
*
|
|
31
|
+
* `fetchList` traz a galeria pública e funciona deslogado. Esta responde sobre o
|
|
32
|
+
* que pertence a alguém, então um 401 aqui é uma resposta e não uma falha: quem
|
|
33
|
+
* chama transforma isso na frase que manda rodar `login`.
|
|
34
|
+
*/
|
|
35
|
+
export async function fetchMine(base) {
|
|
36
|
+
const res = await request(`${base}/api/registry/mine`);
|
|
37
|
+
if (res.status === 401) {
|
|
38
|
+
throw new RegistryError("This lists your own systems, so it needs an account. Run `synthesisui login` and try again.");
|
|
39
|
+
}
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
throw new RegistryError(`Registry responded ${res.status} while listing.`);
|
|
42
|
+
}
|
|
43
|
+
const body = (await res.json());
|
|
44
|
+
return body.designSystems ?? [];
|
|
45
|
+
}
|
|
28
46
|
/**
|
|
29
47
|
* Fetches a published DS already compiled (document + artifacts). Without
|
|
30
48
|
* `version` it returns the latest; with `version` it returns that one.
|
package/package.json
CHANGED