create-rubrica 1.0.0 → 1.1.0
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/README.md +8 -6
- package/dist/index.js +570 -191
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,8 +14,10 @@ npx create-rubrica meu-portfolio
|
|
|
14
14
|
|
|
15
15
|
O assistente baixa a versão mais recente do template e pergunta:
|
|
16
16
|
|
|
17
|
-
- **Layout**: Cyberpunk, Brutalism Terminal, Swiss Grid, Bento ou
|
|
18
|
-
- **
|
|
17
|
+
- **Layout**: um de 13 — Cyberpunk, Brutalism Terminal, Swiss Grid, Bento, Magazine, Desktop Retrô, Índice, Monografia, Zine, Blueprint, Jardim Digital, Conversa ou Pôster Cinético ([guia dos layouts](https://github.com/MierzwaMatheus/rubrica/blob/main/docs/templates/README.md))
|
|
18
|
+
- **Esquema de cores**: um de 15, cada um com modo claro e escuro; o recomendado para o layout vem marcado ([esquemas de cores](https://github.com/MierzwaMatheus/rubrica/blob/main/docs/templates/cores.md))
|
|
19
|
+
- **Modo de cor**: claro, escuro ou automático (segue o sistema de quem visita), e se a visita pode alternar
|
|
20
|
+
- **Textura**: nenhuma, grão de filme, papel ou scanlines
|
|
19
21
|
- **Fontes**: principal e mono (o layout sugere uma combinação)
|
|
20
22
|
- **Plugins**: blog, portfólio, currículo, propostas, depoimentos, IA etc.
|
|
21
23
|
- **Identidade**: nome do site, URL, descrição, autor, e-mail, handle do X, idioma
|
|
@@ -25,10 +27,10 @@ Arquivos que saem com as suas escolhas:
|
|
|
25
27
|
|
|
26
28
|
| Arquivo | O que tem |
|
|
27
29
|
|---|---|
|
|
28
|
-
| `rubrica.json` | Estado do CLI: versão de origem, layout,
|
|
30
|
+
| `rubrica.json` | Estado do CLI: versão de origem, layout, esquema de cores, modo, textura, fontes, plugins e identidade. Versione junto com o projeto: o `update` depende dele. |
|
|
29
31
|
| `rubrica.config.ts` | Identidade, SEO e RSS usados no build |
|
|
30
|
-
| `src/index.css` |
|
|
31
|
-
| `index.html` | Meta tags e
|
|
32
|
+
| `src/index.css` | O esquema de cores (modo claro e escuro) e as fontes |
|
|
33
|
+
| `index.html` | Meta tags, o link das fontes e a aparência (modo de cor, alternância e textura, como atributos do `<html>`) |
|
|
32
34
|
| `src/components/`, `src/pages/` | Arquivos do layout escolhido |
|
|
33
35
|
| `convex/pluginRegistry.ts` | Plugins ligados por padrão |
|
|
34
36
|
|
|
@@ -62,7 +64,7 @@ npx create-rubrica config
|
|
|
62
64
|
Muda as escolhas feitas no `create`:
|
|
63
65
|
|
|
64
66
|
- **Identidade**: atualiza `rubrica.config.ts`, as meta tags do `index.html` e o `rubrica.json`
|
|
65
|
-
- **Aparência**:
|
|
67
|
+
- **Aparência**: esquema de cores, modo claro/escuro, alternância, textura e fontes
|
|
66
68
|
- **Layout**: troca o layout (⚠ sobrescreve os arquivos do layout; personalizações neles se perdem)
|
|
67
69
|
- **Plugins**: quais vêm ligados por padrão
|
|
68
70
|
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { intro as intro3 } from "@clack/prompts";
|
|
5
5
|
|
|
6
6
|
// src/commands/create.ts
|
|
7
|
-
import { outro, select as
|
|
8
|
-
import * as
|
|
7
|
+
import { outro, select as select3, multiselect, confirm as confirm2 } from "@clack/prompts";
|
|
8
|
+
import * as nodeFsPromises10 from "fs/promises";
|
|
9
9
|
|
|
10
10
|
// src/prompts/identityPrompt.ts
|
|
11
11
|
import { text, select, isCancel, cancel } from "@clack/prompts";
|
|
@@ -145,32 +145,172 @@ async function downloadRelease(targetDir, version) {
|
|
|
145
145
|
// src/transforms/applyLayout.ts
|
|
146
146
|
import * as nodeFsPromises from "fs/promises";
|
|
147
147
|
import * as path from "path";
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
|
|
149
|
+
// src/layouts.ts
|
|
150
|
+
var TEMPLATE_PAGES = ["Home.tsx", "Resume.tsx", "Portfolio.tsx", "About.tsx", "Blog.tsx"];
|
|
151
|
+
var NEW_LAYOUT_REMOVE = ["Sidebar.tsx", "Navbar.tsx", "Footer.tsx"];
|
|
152
|
+
var LAYOUTS = [
|
|
153
|
+
// ---- originais (contrato de 4 cores) ----
|
|
154
|
+
{
|
|
155
|
+
id: "cyberpunk",
|
|
156
|
+
label: "Cyberpunk",
|
|
157
|
+
hint: "sidebar lateral com foto de perfil \u2014 dev, designer, freelancer",
|
|
158
|
+
legacy: true,
|
|
150
159
|
copy: ["Layout.tsx", "Sidebar.tsx"],
|
|
151
|
-
remove: ["Navbar.tsx", "Footer.tsx"]
|
|
160
|
+
remove: ["Navbar.tsx", "Footer.tsx"],
|
|
161
|
+
fonts: { sans: ["Chakra Petch"], mono: "JetBrains Mono" },
|
|
162
|
+
recommended: { scheme: "neon", mode: "dark", texture: "none" }
|
|
152
163
|
},
|
|
153
|
-
|
|
164
|
+
{
|
|
165
|
+
id: "brutalist",
|
|
166
|
+
label: "Brutalism Terminal",
|
|
167
|
+
hint: "identidade hacker total \u2014 monospace, sem bordas arredondadas",
|
|
168
|
+
legacy: true,
|
|
154
169
|
copy: ["Layout.tsx", "Navbar.tsx"],
|
|
155
170
|
remove: ["Sidebar.tsx", "Footer.tsx"],
|
|
156
|
-
pages:
|
|
171
|
+
pages: TEMPLATE_PAGES,
|
|
172
|
+
fonts: { sans: ["JetBrains Mono"], mono: "JetBrains Mono" },
|
|
173
|
+
recommended: { scheme: "paper-noir", mode: "dark", texture: "none" }
|
|
157
174
|
},
|
|
158
|
-
|
|
175
|
+
{
|
|
176
|
+
id: "swiss",
|
|
177
|
+
label: "Swiss Grid",
|
|
178
|
+
hint: "grid de 12 colunas, tipografia forte, design su\xED\xE7o rigoroso",
|
|
179
|
+
legacy: true,
|
|
159
180
|
copy: ["Layout.tsx", "Sidebar.tsx", "SwissShared.tsx"],
|
|
160
181
|
remove: ["Navbar.tsx", "Footer.tsx"],
|
|
161
|
-
pages:
|
|
182
|
+
pages: TEMPLATE_PAGES,
|
|
183
|
+
fonts: { sans: ["Archivo"], mono: "" },
|
|
184
|
+
recommended: { scheme: "paper-noir", mode: "light", texture: "none" }
|
|
162
185
|
},
|
|
163
|
-
|
|
186
|
+
{
|
|
187
|
+
id: "bento",
|
|
188
|
+
label: "Bento",
|
|
189
|
+
hint: "grid assim\xE9trico com floating dock \u2014 moderno, orientado a produto",
|
|
190
|
+
legacy: true,
|
|
164
191
|
copy: ["Layout.tsx", "FloatingDock.tsx"],
|
|
165
192
|
remove: [],
|
|
166
|
-
pages:
|
|
193
|
+
pages: TEMPLATE_PAGES,
|
|
194
|
+
fonts: { sans: ["Manrope"], mono: "JetBrains Mono" },
|
|
195
|
+
recommended: { scheme: "editorial-cream", mode: "light", texture: "none" }
|
|
167
196
|
},
|
|
168
|
-
|
|
197
|
+
{
|
|
198
|
+
id: "magazine",
|
|
199
|
+
label: "Magazine",
|
|
200
|
+
hint: "editorial cl\xE1ssico \xB7 display serifado \xB7 grid assim\xE9trico \xB7 \xE1reas de respiro generosas",
|
|
201
|
+
legacy: true,
|
|
169
202
|
copy: ["Layout.tsx", "Masthead.tsx"],
|
|
170
203
|
remove: ["Sidebar.tsx", "Footer.tsx"],
|
|
171
|
-
pages:
|
|
204
|
+
pages: TEMPLATE_PAGES,
|
|
205
|
+
fonts: { sans: ["Bodoni Moda", "IBM Plex Serif"], mono: "JetBrains Mono" },
|
|
206
|
+
recommended: { scheme: "editorial-cream", mode: "light", texture: "paper" }
|
|
207
|
+
},
|
|
208
|
+
// ---- novos (esquema completo) ----
|
|
209
|
+
{
|
|
210
|
+
id: "desktop",
|
|
211
|
+
label: "Desktop Retr\xF4",
|
|
212
|
+
hint: "cada se\xE7\xE3o \xE9 uma janela sobre a \xE1rea de trabalho \u2014 nostalgia e brincadeira",
|
|
213
|
+
legacy: false,
|
|
214
|
+
copy: ["Layout.tsx", "DesktopMenuBar.tsx", "DesktopShared.tsx"],
|
|
215
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
216
|
+
pages: TEMPLATE_PAGES,
|
|
217
|
+
fonts: { sans: ["Instrument Sans"], mono: "IBM Plex Mono" },
|
|
218
|
+
recommended: { scheme: "sorbet", mode: "light", texture: "grain" }
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: "index",
|
|
222
|
+
label: "\xCDndice",
|
|
223
|
+
hint: "lista densa de museu, r\xF3tulos \xE0 esquerda e imagem que surge no hover \u2014 curadoria",
|
|
224
|
+
legacy: false,
|
|
225
|
+
copy: ["Layout.tsx", "IndexHeader.tsx", "IndexShared.tsx"],
|
|
226
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
227
|
+
pages: TEMPLATE_PAGES,
|
|
228
|
+
fonts: { sans: ["Instrument Sans"], mono: "IBM Plex Mono" },
|
|
229
|
+
recommended: { scheme: "sumi", mode: "light", texture: "none" }
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: "monograph",
|
|
233
|
+
label: "Monografia",
|
|
234
|
+
hint: "o site como livro: folha de rosto, sum\xE1rio, capitulares e notas na margem",
|
|
235
|
+
legacy: false,
|
|
236
|
+
copy: ["Layout.tsx", "MonographRunningHead.tsx", "MonographShared.tsx"],
|
|
237
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
238
|
+
pages: TEMPLATE_PAGES,
|
|
239
|
+
fonts: { sans: ["Fraunces", "Source Serif 4"], mono: "IBM Plex Mono" },
|
|
240
|
+
recommended: { scheme: "azulejo", mode: "light", texture: "paper" }
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
id: "zine",
|
|
244
|
+
label: "Zine",
|
|
245
|
+
hint: "colagem: polaroides, fita adesiva, post-its e letra \xE0 m\xE3o \u2014 autoral",
|
|
246
|
+
legacy: false,
|
|
247
|
+
copy: ["Layout.tsx", "ZineNav.tsx", "ZineShared.tsx"],
|
|
248
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
249
|
+
pages: TEMPLATE_PAGES,
|
|
250
|
+
fonts: { sans: ["Bricolage Grotesque"], mono: "IBM Plex Mono" },
|
|
251
|
+
recommended: { scheme: "riso", mode: "light", texture: "paper" }
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: "blueprint",
|
|
255
|
+
label: "Blueprint",
|
|
256
|
+
hint: "folhas t\xE9cnicas numeradas sobre papel quadriculado, com cotas e carimbo",
|
|
257
|
+
legacy: false,
|
|
258
|
+
copy: ["Layout.tsx", "BlueprintHeader.tsx", "BlueprintShared.tsx"],
|
|
259
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
260
|
+
pages: TEMPLATE_PAGES,
|
|
261
|
+
fonts: { sans: ["IBM Plex Sans"], mono: "IBM Plex Mono" },
|
|
262
|
+
recommended: { scheme: "cianotipia", mode: "dark", texture: "paper" }
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
id: "garden",
|
|
266
|
+
label: "Jardim Digital",
|
|
267
|
+
hint: "notas com est\xE1gio de crescimento, backlinks e mapa de liga\xE7\xF5es",
|
|
268
|
+
legacy: false,
|
|
269
|
+
copy: ["Layout.tsx", "GardenSidebar.tsx", "GardenShared.tsx"],
|
|
270
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
271
|
+
pages: TEMPLATE_PAGES,
|
|
272
|
+
fonts: { sans: ["Fraunces", "Source Serif 4"], mono: "IBM Plex Mono" },
|
|
273
|
+
recommended: { scheme: "crepusculo", mode: "dark", texture: "grain" }
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: "chat",
|
|
277
|
+
label: "Conversa",
|
|
278
|
+
hint: "o site como conversa: cada se\xE7\xE3o responde a uma pergunta pronta",
|
|
279
|
+
legacy: false,
|
|
280
|
+
copy: ["Layout.tsx", "ChatHeader.tsx", "ChatShared.tsx"],
|
|
281
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
282
|
+
pages: TEMPLATE_PAGES,
|
|
283
|
+
fonts: { sans: ["Instrument Sans"], mono: "IBM Plex Mono" },
|
|
284
|
+
recommended: { scheme: "alto-contraste", mode: "light", texture: "none" }
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
id: "poster",
|
|
288
|
+
label: "P\xF4ster Cin\xE9tico",
|
|
289
|
+
hint: "tipografia gigante do come\xE7o ao fim, faixas rolando \u2014 impacto",
|
|
290
|
+
legacy: false,
|
|
291
|
+
copy: ["Layout.tsx", "PosterNav.tsx", "PosterShared.tsx"],
|
|
292
|
+
remove: NEW_LAYOUT_REMOVE,
|
|
293
|
+
pages: TEMPLATE_PAGES,
|
|
294
|
+
fonts: { sans: ["Bricolage Grotesque"], mono: "IBM Plex Mono" },
|
|
295
|
+
recommended: { scheme: "tropicalia", mode: "light", texture: "grain" }
|
|
172
296
|
}
|
|
173
|
-
|
|
297
|
+
];
|
|
298
|
+
function getLayout(id) {
|
|
299
|
+
return LAYOUTS.find((l) => l.id === id);
|
|
300
|
+
}
|
|
301
|
+
var COLOR_MODES = [
|
|
302
|
+
{ value: "light", label: "Claro", hint: "fundo claro" },
|
|
303
|
+
{ value: "dark", label: "Escuro", hint: "fundo escuro" },
|
|
304
|
+
{ value: "system", label: "Autom\xE1tico", hint: "segue o modo do sistema de quem visita" }
|
|
305
|
+
];
|
|
306
|
+
var TEXTURES = [
|
|
307
|
+
{ value: "none", label: "Nenhuma", hint: "superf\xEDcies lisas" },
|
|
308
|
+
{ value: "grain", label: "Gr\xE3o de filme", hint: "ru\xEDdo fino, sensa\xE7\xE3o anal\xF3gica" },
|
|
309
|
+
{ value: "paper", label: "Papel", hint: "fibras de papel, bom para layouts editoriais" },
|
|
310
|
+
{ value: "scanlines", label: "Scanlines", hint: "linhas de monitor CRT" }
|
|
311
|
+
];
|
|
312
|
+
|
|
313
|
+
// src/transforms/applyLayout.ts
|
|
174
314
|
var defaultFs = {
|
|
175
315
|
...nodeFsPromises,
|
|
176
316
|
exists: async (p) => {
|
|
@@ -183,7 +323,7 @@ var defaultFs = {
|
|
|
183
323
|
}
|
|
184
324
|
};
|
|
185
325
|
async function applyLayout(layout, options, fsModule = defaultFs) {
|
|
186
|
-
const spec =
|
|
326
|
+
const spec = getLayout(layout);
|
|
187
327
|
if (!spec) {
|
|
188
328
|
throw new Error(`applyLayout: layout "${layout}" n\xE3o reconhecido.`);
|
|
189
329
|
}
|
|
@@ -214,7 +354,175 @@ async function applyLayout(layout, options, fsModule = defaultFs) {
|
|
|
214
354
|
|
|
215
355
|
// src/transforms/applyTheme.ts
|
|
216
356
|
import * as nodeFsPromises2 from "fs/promises";
|
|
217
|
-
|
|
357
|
+
|
|
358
|
+
// src/themes/schemes.ts
|
|
359
|
+
var ROLE_VARS = {
|
|
360
|
+
bg: "--bg",
|
|
361
|
+
surface: "--surface",
|
|
362
|
+
subtle: "--subtle",
|
|
363
|
+
text: "--text",
|
|
364
|
+
textMuted: "--text-muted",
|
|
365
|
+
line: "--line",
|
|
366
|
+
primary: "--primary",
|
|
367
|
+
onPrimary: "--on-primary",
|
|
368
|
+
accent: "--accent",
|
|
369
|
+
onAccent: "--on-accent",
|
|
370
|
+
accent2: "--accent-2"
|
|
371
|
+
};
|
|
372
|
+
var LEGACY_ROLES = ["bg", "text", "primary", "accent"];
|
|
373
|
+
function luminance(hex) {
|
|
374
|
+
const c = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((v) => v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
|
|
375
|
+
return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
|
376
|
+
}
|
|
377
|
+
function contrast(a, b) {
|
|
378
|
+
const x = luminance(a);
|
|
379
|
+
const y = luminance(b);
|
|
380
|
+
return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
|
|
381
|
+
}
|
|
382
|
+
function onColor(fill, mode2) {
|
|
383
|
+
return contrast(fill, mode2.bg) >= contrast(fill, mode2.text) ? mode2.bg : mode2.text;
|
|
384
|
+
}
|
|
385
|
+
function mode(m) {
|
|
386
|
+
return {
|
|
387
|
+
...m,
|
|
388
|
+
onPrimary: m.onPrimary ?? onColor(m.primary, m),
|
|
389
|
+
onAccent: m.onAccent ?? onColor(m.accent, m)
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
var SCHEMES = [
|
|
393
|
+
// Padrão do repositório: o visual original do Rubrica.
|
|
394
|
+
{
|
|
395
|
+
id: "neon",
|
|
396
|
+
label: "Neon",
|
|
397
|
+
hint: "o visual original do Rubrica \u2014 roxo e lima sobre grafite",
|
|
398
|
+
light: mode({ bg: "#F7F7F8", surface: "#EFEFF2", subtle: "#F1F1F4", text: "#141414", textMuted: "#55555C", line: "#DCDCE2", primary: "#7E22CE", accent: "#4D7C0F", accent2: "#0891B2" }),
|
|
399
|
+
dark: mode({ bg: "#141414", surface: "#0A0A0A", subtle: "#171717", text: "#E6E6E6", textMuted: "#A2A2A2", line: "#252525", primary: "#A855F7", onPrimary: "#FFFFFF", accent: "#BEF264", accent2: "#22D3EE" })
|
|
400
|
+
},
|
|
401
|
+
// Os 4 presets originais, agora com os dois modos e o esquema completo.
|
|
402
|
+
{
|
|
403
|
+
id: "editorial-cream",
|
|
404
|
+
label: "Editorial Cream",
|
|
405
|
+
hint: "refinado e atemporal \u2014 blogs e portf\xF3lios liter\xE1rios",
|
|
406
|
+
light: mode({ bg: "#FAF7F2", surface: "#F3EEE5", subtle: "#EFE9DE", text: "#1A1614", textMuted: "#5E554D", line: "#E2D9CB", primary: "#A855F7", accent: "#EF4444", accent2: "#B7832A" }),
|
|
407
|
+
dark: mode({ bg: "#1A1614", surface: "#231E1A", subtle: "#2A241F", text: "#F3EEE5", textMuted: "#A89E93", line: "#3A322B", primary: "#C084FC", accent: "#F87171", accent2: "#E0B25A" })
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
id: "paper-noir",
|
|
411
|
+
label: "Paper Noir",
|
|
412
|
+
hint: "contraste m\xE1ximo \u2014 identidade editorial forte",
|
|
413
|
+
light: mode({ bg: "#F0EEE9", surface: "#E8E5DE", subtle: "#E4E1D9", text: "#0A0A0A", textMuted: "#55524C", line: "#D3CFC6", primary: "#EF4444", accent: "#3B82F6", accent2: "#E8B500" }),
|
|
414
|
+
dark: mode({ bg: "#0D0D0D", surface: "#161616", subtle: "#1C1C1C", text: "#F0EEE9", textMuted: "#A3A09A", line: "#2C2C2C", primary: "#F05252", accent: "#60A5FA", accent2: "#F2C94C" })
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
id: "midnight-blue",
|
|
418
|
+
label: "Midnight Blue",
|
|
419
|
+
hint: "tech e premium \u2014 devs e designers noturnos",
|
|
420
|
+
light: mode({ bg: "#F3F6FB", surface: "#E9EEF7", subtle: "#E3E9F3", text: "#0A1224", textMuted: "#4B5670", line: "#CBD5E6", primary: "#0E7490", accent: "#CA8A04", accent2: "#6D28D9" }),
|
|
421
|
+
dark: mode({ bg: "#0A1224", surface: "#0F1A31", subtle: "#13203B", text: "#E8E6E0", textMuted: "#9AA3B5", line: "#22304D", primary: "#06B6D4", accent: "#FACC15", accent2: "#A78BFA" })
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
id: "solar-warm",
|
|
425
|
+
label: "Solar Warm",
|
|
426
|
+
hint: "energia e criatividade \u2014 marcas pessoais vibrantes",
|
|
427
|
+
light: mode({ bg: "#FFF8EF", surface: "#FBEFDF", subtle: "#F7E9D6", text: "#2A1A0E", textMuted: "#6E5A47", line: "#EAD7BE", primary: "#C2410C", accent: "#CA8A04", accent2: "#BE123C" }),
|
|
428
|
+
dark: mode({ bg: "#1A1410", surface: "#231B15", subtle: "#2A2019", text: "#F2EDE4", textMuted: "#ABA092", line: "#3A2E24", primary: "#F97316", accent: "#FACC15", accent2: "#FB7185" })
|
|
429
|
+
},
|
|
430
|
+
// Paletas novas.
|
|
431
|
+
{
|
|
432
|
+
id: "riso",
|
|
433
|
+
label: "Riso",
|
|
434
|
+
hint: "rosa fluorescente e azul de impress\xE3o riso sobre papel",
|
|
435
|
+
light: mode({ bg: "#F2EDE2", surface: "#FAF6EE", subtle: "#E5DDCC", text: "#1D2B63", textMuted: "#4E5884", line: "#D4C9B2", primary: "#E5258D", onPrimary: "#14183A", accent: "#0078BF", accent2: "#FFE800" }),
|
|
436
|
+
dark: mode({ bg: "#15172A", surface: "#1E2138", subtle: "#272A44", text: "#F2EDE2", textMuted: "#A9ACC8", line: "#363A5C", primary: "#FF5CBA", onPrimary: "#15172A", accent: "#4AA8E8", accent2: "#FFE45C" })
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
id: "cianotipia",
|
|
440
|
+
label: "Cianotipia",
|
|
441
|
+
hint: "azul-da-pr\xFAssia e branco giz, como c\xF3pia heliogr\xE1fica",
|
|
442
|
+
light: mode({ bg: "#EDF1F6", surface: "#F8FAFC", subtle: "#DDE5EF", text: "#0F2C57", textMuted: "#4A6286", line: "#C3D0E1", primary: "#1D4E89", onPrimary: "#FFFFFF", accent: "#6F9BCB", accent2: "#8FB3D9" }),
|
|
443
|
+
dark: mode({ bg: "#0E2A50", surface: "#14345F", subtle: "#1A3D6C", text: "#E9EFF7", textMuted: "#9DB4D3", line: "#2D5285", primary: "#F2F5FA", onPrimary: "#0E2A50", accent: "#7FA9DA", accent2: "#BFD3EA" })
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
id: "tropicalia",
|
|
447
|
+
label: "Tropic\xE1lia",
|
|
448
|
+
hint: "verde-mata, amarelo-ouro e rosa-buganv\xEDlia",
|
|
449
|
+
light: mode({ bg: "#FBF5E6", surface: "#FFFBF1", subtle: "#EFE6CD", text: "#0D3326", textMuted: "#4D6358", line: "#DCCFAE", primary: "#0B6E4F", onPrimary: "#FFFFFF", accent: "#F2B705", accent2: "#E2457A" }),
|
|
450
|
+
dark: mode({ bg: "#0A271D", surface: "#0F3427", subtle: "#143D2F", text: "#F6EFDA", textMuted: "#A7BFAF", line: "#22513F", primary: "#34C08A", onPrimary: "#062016", accent: "#F7C531", accent2: "#F26B9C" })
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
id: "azulejo",
|
|
454
|
+
label: "Azulejo",
|
|
455
|
+
hint: "azul-cobalto sobre branco, com terracota",
|
|
456
|
+
light: mode({ bg: "#F6F6F2", surface: "#FFFFFF", subtle: "#E7EAF1", text: "#14213D", textMuted: "#4F5B78", line: "#D2D7E3", primary: "#1F4FB4", onPrimary: "#FFFFFF", accent: "#C4673D", accent2: "#E9B949" }),
|
|
457
|
+
dark: mode({ bg: "#0D1630", surface: "#141F3D", subtle: "#1B2749", text: "#ECEFF6", textMuted: "#A1ACC8", line: "#2A3762", primary: "#7397F2", onPrimary: "#0D1630", accent: "#E58C61", accent2: "#F0C866" })
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
id: "sumi",
|
|
461
|
+
label: "Sumi",
|
|
462
|
+
hint: "tinta preta, papel washi e um \xFAnico vermelho de carimbo",
|
|
463
|
+
light: mode({ bg: "#EEEBE3", surface: "#F7F5F0", subtle: "#E1DDD2", text: "#171614", textMuted: "#5F5B53", line: "#CEC8BA", primary: "#C8102E", onPrimary: "#FFFFFF", accent: "#8A8478", accent2: "#171614" }),
|
|
464
|
+
dark: mode({ bg: "#121110", surface: "#1B1A18", subtle: "#24221F", text: "#E9E5DC", textMuted: "#A39E93", line: "#34312C", primary: "#E5414A", onPrimary: "#121110", accent: "#7D776C", accent2: "#E9E5DC" })
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
id: "fosforo",
|
|
468
|
+
label: "F\xF3sforo",
|
|
469
|
+
hint: "verde de monitor CRT e \xE2mbar; no claro, papel de formul\xE1rio cont\xEDnuo",
|
|
470
|
+
light: mode({ bg: "#EEF3E8", surface: "#F7FAF3", subtle: "#DDE8D3", text: "#1A3A20", textMuted: "#4C6A50", line: "#C3D4B6", primary: "#1E7A33", onPrimary: "#FFFFFF", accent: "#A86A00", accent2: "#5E9E6A" }),
|
|
471
|
+
dark: mode({ bg: "#070C08", surface: "#0C150E", subtle: "#102014", text: "#8CFF9E", textMuted: "#4FBF63", line: "#1C3A22", primary: "#3DFF6E", onPrimary: "#04140A", accent: "#FFB000", accent2: "#2E8B45" })
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
id: "crepusculo",
|
|
475
|
+
label: "Crep\xFAsculo",
|
|
476
|
+
hint: "roxo profundo indo para o laranja de fim de tarde",
|
|
477
|
+
light: mode({ bg: "#FFF3ED", surface: "#FFFAF7", subtle: "#F6E2DD", text: "#2A1540", textMuted: "#6B5378", line: "#EBCFCB", primary: "#6B2FA3", onPrimary: "#FFFFFF", accent: "#EF6C2A", accent2: "#E3A73B" }),
|
|
478
|
+
dark: mode({ bg: "#190E29", surface: "#231536", subtle: "#2D1C44", text: "#F7E9F0", textMuted: "#BCA6C9", line: "#3E2A5A", primary: "#B788F2", onPrimary: "#190E29", accent: "#FF8A4C", accent2: "#F4C15D" })
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
id: "concreto",
|
|
482
|
+
label: "Concreto",
|
|
483
|
+
hint: "cinzas frios e um amarelo de sinaliza\xE7\xE3o",
|
|
484
|
+
light: mode({ bg: "#E3E4E5", surface: "#EEEFF0", subtle: "#D3D5D7", text: "#111214", textMuted: "#55595F", line: "#B9BCC0", primary: "#1F2124", onPrimary: "#FFD400", accent: "#A87F00", accent2: "#FFD400" }),
|
|
485
|
+
dark: mode({ bg: "#18191B", surface: "#212325", subtle: "#2A2C2F", text: "#E8E9EA", textMuted: "#9A9EA4", line: "#3A3D41", primary: "#FFD400", onPrimary: "#111214", accent: "#6E737A", accent2: "#E8E9EA" })
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
id: "sorbet",
|
|
489
|
+
label: "Sorbet",
|
|
490
|
+
hint: "lil\xE1s, menta e p\xEAssego em tons Y2K",
|
|
491
|
+
light: mode({ bg: "#FFF6FA", surface: "#FFFFFF", subtle: "#F3E8F6", text: "#35295A", textMuted: "#6F6390", line: "#E6D6EE", primary: "#7454D6", onPrimary: "#FFFFFF", accent: "#6FD3B5", accent2: "#FFAE94" }),
|
|
492
|
+
dark: mode({ bg: "#211B33", surface: "#2A2340", subtle: "#332B4C", text: "#F5EEFF", textMuted: "#B9AED6", line: "#433A60", primary: "#B9A0FF", onPrimary: "#211B33", accent: "#86E3C7", accent2: "#FFB8A1" })
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
id: "alto-contraste",
|
|
496
|
+
label: "Alto Contraste",
|
|
497
|
+
hint: "contraste n\xEDvel AAA nos dois modos, pensado para baixa vis\xE3o",
|
|
498
|
+
light: mode({ bg: "#FFFFFF", surface: "#FFFFFF", subtle: "#F0F0F0", text: "#000000", textMuted: "#2B2B2B", line: "#000000", primary: "#0030B8", onPrimary: "#FFFFFF", accent: "#8A0000", accent2: "#000000" }),
|
|
499
|
+
dark: mode({ bg: "#000000", surface: "#0A0A0A", subtle: "#1A1A1A", text: "#FFFFFF", textMuted: "#E0E0E0", line: "#FFFFFF", primary: "#FFE14D", onPrimary: "#000000", accent: "#7FD8FF", accent2: "#FFFFFF" })
|
|
500
|
+
}
|
|
501
|
+
];
|
|
502
|
+
function getScheme(id) {
|
|
503
|
+
return SCHEMES.find((s) => s.id === id);
|
|
504
|
+
}
|
|
505
|
+
function modeDeclarations(m, indent = " ") {
|
|
506
|
+
return Object.keys(ROLE_VARS).map((role) => `${indent}${ROLE_VARS[role]}: ${m[role]};`).join("\n");
|
|
507
|
+
}
|
|
508
|
+
var SCHEME_START = "/* rubrica:esquema:inicio */";
|
|
509
|
+
var SCHEME_END = "/* rubrica:esquema:fim */";
|
|
510
|
+
function schemeCss(scheme) {
|
|
511
|
+
return [
|
|
512
|
+
SCHEME_START,
|
|
513
|
+
`/* Esquema de cores: ${scheme.label} (${scheme.id}). Gerado pelo CLI (rubrica config \u2192 Apar\xEAncia). */`,
|
|
514
|
+
`:root {
|
|
515
|
+
${modeDeclarations(scheme.light)}
|
|
516
|
+
}`,
|
|
517
|
+
`.dark {
|
|
518
|
+
${modeDeclarations(scheme.dark)}
|
|
519
|
+
}`,
|
|
520
|
+
SCHEME_END
|
|
521
|
+
].join("\n");
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// src/transforms/applyTheme.ts
|
|
525
|
+
var PRE_SCHEME_PRESETS = {
|
|
218
526
|
"editorial-cream": { "--bg": "#faf7f2", "--text": "#1a1614", "--primary": "#a855f7", "--accent": "#ef4444" },
|
|
219
527
|
"paper-noir": { "--bg": "#f0eee9", "--text": "#0a0a0a", "--primary": "#ef4444", "--accent": "#3b82f6" },
|
|
220
528
|
"midnight-blue": { "--bg": "#0a1224", "--text": "#e8e6e0", "--primary": "#06b6d4", "--accent": "#facc15" },
|
|
@@ -230,43 +538,77 @@ function setVars(css, selector, vars, addMissing) {
|
|
|
230
538
|
const missing = [];
|
|
231
539
|
for (const [name, value] of Object.entries(vars)) {
|
|
232
540
|
const declRe = new RegExp(`(^|[\\s;{])(${escapeRegExp(name)}\\s*:)[^;}]*`);
|
|
233
|
-
if (declRe.test(updated)) {
|
|
234
|
-
|
|
235
|
-
} else if (addMissing) {
|
|
236
|
-
missing.push(` ${name}: ${value};`);
|
|
237
|
-
}
|
|
541
|
+
if (declRe.test(updated)) updated = updated.replace(declRe, `$1$2 ${value}`);
|
|
542
|
+
else if (addMissing) missing.push(` ${name}: ${value};`);
|
|
238
543
|
}
|
|
239
|
-
if (missing.length) {
|
|
240
|
-
updated = `${updated.replace(/\s*$/, "")}
|
|
544
|
+
if (missing.length) updated = `${updated.replace(/\s*$/, "")}
|
|
241
545
|
${missing.join("\n")}
|
|
242
546
|
`;
|
|
243
|
-
}
|
|
244
547
|
return `${lead}${open}${updated}${close}`;
|
|
245
548
|
});
|
|
246
549
|
}
|
|
247
550
|
async function applyTheme(options, cssPath, fsModule = nodeFsPromises2) {
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
250
|
-
throw new Error(`applyTheme:
|
|
551
|
+
const scheme = getScheme(options.preset);
|
|
552
|
+
if (!scheme) {
|
|
553
|
+
throw new Error(`applyTheme: esquema "${options.preset}" n\xE3o encontrado.`);
|
|
251
554
|
}
|
|
252
555
|
const css = await fsModule.readFile(cssPath, "utf-8");
|
|
253
|
-
|
|
254
|
-
|
|
556
|
+
const block = new RegExp(`${escapeRegExp(SCHEME_START)}[\\s\\S]*?${escapeRegExp(SCHEME_END)}`);
|
|
557
|
+
let updated;
|
|
558
|
+
if (block.test(css)) {
|
|
559
|
+
updated = css.replace(block, () => schemeCss(scheme));
|
|
560
|
+
} else {
|
|
561
|
+
const legacy = PRE_SCHEME_PRESETS[scheme.id] ?? Object.fromEntries(LEGACY_ROLES.map((r) => [ROLE_VARS[r], scheme.dark[r]]));
|
|
562
|
+
updated = setVars(setVars(css, ":root", legacy, true), ".dark", legacy, false);
|
|
563
|
+
}
|
|
255
564
|
await fsModule.writeFile(cssPath, updated);
|
|
256
565
|
}
|
|
257
566
|
|
|
258
567
|
// src/transforms/applyFont.ts
|
|
259
568
|
import * as nodeFsPromises3 from "fs/promises";
|
|
260
|
-
|
|
261
|
-
|
|
569
|
+
|
|
570
|
+
// src/themes/fonts.ts
|
|
571
|
+
var SANS_FONTS = [
|
|
572
|
+
{ family: "Inter", hint: "neutra, leg\xEDvel, padr\xE3o de produtos digitais", weights: [300, 400, 500, 600, 700] },
|
|
573
|
+
{ family: "Chakra Petch", hint: "geom\xE9trica, tech, futurista", weights: [300, 400, 500, 600, 700] },
|
|
574
|
+
{ family: "Playfair Display", hint: "elegante, editorial cl\xE1ssico", weights: [400, 500, 600, 700, 800] },
|
|
575
|
+
{ family: "Space Grotesk", hint: "moderna, startup", weights: [300, 400, 500, 600, 700] },
|
|
576
|
+
{ family: "DM Sans", hint: "limpa, amig\xE1vel, vers\xE1til", weights: [300, 400, 500, 600, 700] },
|
|
577
|
+
{ family: "Bodoni Moda", hint: "display serifado elegante, editorial cl\xE1ssico", weights: [400, 500, 600, 700, 800] },
|
|
578
|
+
{ family: "IBM Plex Serif", hint: "serifa t\xE9cnica, confian\xE7a e rigor", weights: [300, 400, 500, 600, 700] },
|
|
579
|
+
{ family: "Manrope", hint: "geom\xE9trica humanista, moderna e acolhedora", weights: [300, 400, 500, 600, 700, 800] },
|
|
580
|
+
{ family: "Archivo", hint: "grotesca utilit\xE1ria, clareza e for\xE7a tipogr\xE1fica", weights: [300, 400, 500, 600, 700, 800] },
|
|
581
|
+
{ family: "Instrument Sans", hint: "grotesca contempor\xE2nea, precisa e discreta", weights: [400, 500, 600, 700] },
|
|
582
|
+
{ family: "IBM Plex Sans", hint: "t\xE9cnica e neutra, par natural da IBM Plex Mono", weights: [300, 400, 500, 600, 700] },
|
|
583
|
+
{ family: "Fraunces", hint: "serifa expressiva de livro, calorosa", weights: [300, 400, 500, 600, 700, 800] },
|
|
584
|
+
{ family: "Source Serif 4", hint: "serifa de leitura longa, s\xF3bria", weights: [300, 400, 600, 700] },
|
|
585
|
+
{ family: "Bricolage Grotesque", hint: "display com personalidade, p\xF4ster e colagem", weights: [300, 400, 500, 600, 700, 800] },
|
|
586
|
+
// Principal do brutalist: monoespaçada também no corpo do texto.
|
|
587
|
+
{ family: "JetBrains Mono", hint: "monoespa\xE7ada no texto todo, identidade de terminal", weights: [300, 400, 500, 600, 700] }
|
|
588
|
+
];
|
|
589
|
+
var MONO_FONTS = [
|
|
590
|
+
{ family: "JetBrains Mono", hint: "dev-friendly, clara", weights: [300, 400, 500, 600, 700] },
|
|
591
|
+
{ family: "Fira Code", hint: "cl\xE1ssico, com ligatures", weights: [300, 400, 500, 600, 700] },
|
|
592
|
+
{ family: "Space Mono", hint: "retro digital", weights: [400, 700] },
|
|
593
|
+
{ family: "IBM Plex Mono", hint: "corporativo-tech", weights: [300, 400, 500, 600, 700] }
|
|
594
|
+
];
|
|
595
|
+
var DEFAULT_WEIGHTS = [400, 700];
|
|
596
|
+
function weightsOf(family) {
|
|
597
|
+
return [...SANS_FONTS, ...MONO_FONTS].find((f) => f.family === family)?.weights ?? DEFAULT_WEIGHTS;
|
|
598
|
+
}
|
|
599
|
+
function googleFontsHref(families) {
|
|
600
|
+
const unique = [...new Set(families.filter(Boolean))];
|
|
601
|
+
const params = unique.map((f) => `family=${f.replace(/ /g, "+")}:wght@${weightsOf(f).join(";")}`).join("&");
|
|
602
|
+
return `https://fonts.googleapis.com/css2?${params}&display=swap`;
|
|
262
603
|
}
|
|
263
|
-
function
|
|
264
|
-
const slug = fontToGoogleSlug(font);
|
|
604
|
+
function fontLinkTag(families) {
|
|
265
605
|
return `<link
|
|
266
|
-
href="
|
|
606
|
+
href="${googleFontsHref(families)}"
|
|
267
607
|
rel="stylesheet"
|
|
268
608
|
/>`;
|
|
269
609
|
}
|
|
610
|
+
|
|
611
|
+
// src/transforms/applyFont.ts
|
|
270
612
|
async function applyFont(options, paths, fsModule = nodeFsPromises3) {
|
|
271
613
|
const { fontSans, fontMono } = options;
|
|
272
614
|
let css = await fsModule.readFile(paths.css, "utf-8");
|
|
@@ -280,7 +622,7 @@ async function applyFont(options, paths, fsModule = nodeFsPromises3) {
|
|
|
280
622
|
);
|
|
281
623
|
await fsModule.writeFile(paths.css, css);
|
|
282
624
|
let html = await fsModule.readFile(paths.html, "utf-8");
|
|
283
|
-
const newLink =
|
|
625
|
+
const newLink = fontLinkTag([fontSans, fontMono]);
|
|
284
626
|
html = html.replace(
|
|
285
627
|
/<link\s[^>]*fonts\.googleapis\.com\/css2[^>]*(?:\s*\/>|>[^<]*<\/link>)/s,
|
|
286
628
|
newLink
|
|
@@ -306,18 +648,11 @@ async function applyPlugins(plugins, registryPath, fsModule = nodeFsPromises4) {
|
|
|
306
648
|
|
|
307
649
|
// src/transforms/applyIndexHtml.ts
|
|
308
650
|
import * as nodeFsPromises5 from "fs/promises";
|
|
309
|
-
function fontToGoogleSlug2(font) {
|
|
310
|
-
return font.replace(/ /g, "+");
|
|
311
|
-
}
|
|
312
651
|
async function applyIndexHtml(data, htmlPath, fsModule = nodeFsPromises5) {
|
|
313
652
|
let html = await fsModule.readFile(htmlPath, "utf-8");
|
|
314
|
-
const slug = fontToGoogleSlug2(data.fontFamily);
|
|
315
653
|
html = html.replace(
|
|
316
654
|
/<link\s[^>]*fonts\.googleapis\.com\/css2[^>]*(?:\s*\/>|>[^<]*<\/link>)/s,
|
|
317
|
-
|
|
318
|
-
href="https://fonts.googleapis.com/css2?family=${slug}:wght@300;400;500;600;700&display=swap"
|
|
319
|
-
rel="stylesheet"
|
|
320
|
-
/>`
|
|
655
|
+
() => fontLinkTag([data.fontFamily, data.fontMono ?? ""])
|
|
321
656
|
);
|
|
322
657
|
html = html.replace(
|
|
323
658
|
/(<meta\s+name="theme-color"\s+content=")[^"]*(")/,
|
|
@@ -453,9 +788,10 @@ function rubricaConfigInput(identity, fontSans, fontMono) {
|
|
|
453
788
|
fontMono
|
|
454
789
|
};
|
|
455
790
|
}
|
|
456
|
-
function indexHtmlInput(identity, fontSans) {
|
|
791
|
+
function indexHtmlInput(identity, fontSans, fontMono = "") {
|
|
457
792
|
return {
|
|
458
793
|
fontFamily: fontSans,
|
|
794
|
+
fontMono,
|
|
459
795
|
themeColor: "",
|
|
460
796
|
siteName: identity.siteName,
|
|
461
797
|
siteUrl: identity.siteUrl,
|
|
@@ -464,14 +800,105 @@ function indexHtmlInput(identity, fontSans) {
|
|
|
464
800
|
};
|
|
465
801
|
}
|
|
466
802
|
|
|
803
|
+
// src/transforms/applyAppearance.ts
|
|
804
|
+
import * as nodeFsPromises9 from "fs/promises";
|
|
805
|
+
function setAttr(tag, name, value) {
|
|
806
|
+
const re = new RegExp(`\\s${name}="[^"]*"`);
|
|
807
|
+
return re.test(tag) ? tag.replace(re, ` ${name}="${value}"`) : tag.replace(/>$/, ` ${name}="${value}">`);
|
|
808
|
+
}
|
|
809
|
+
async function applyAppearance(appearance, htmlPath, fsModule = nodeFsPromises9) {
|
|
810
|
+
const html = await fsModule.readFile(htmlPath, "utf-8");
|
|
811
|
+
const updated = html.replace(/<html\b[^>]*>/, (tag) => {
|
|
812
|
+
let t = setAttr(tag, "data-color-mode", appearance.colorMode);
|
|
813
|
+
t = setAttr(t, "data-color-toggle", String(appearance.colorModeToggle));
|
|
814
|
+
t = setAttr(t, "data-texture", appearance.texture);
|
|
815
|
+
const darkClass = appearance.colorMode === "light" ? "" : "dark";
|
|
816
|
+
if (/\sclass="[^"]*"/.test(t)) {
|
|
817
|
+
t = t.replace(/\sclass="([^"]*)"/, (_m, cls) => {
|
|
818
|
+
const rest = cls.split(/\s+/).filter((c) => c && c !== "dark");
|
|
819
|
+
const all = darkClass ? [...rest, darkClass] : rest;
|
|
820
|
+
return all.length ? ` class="${all.join(" ")}"` : "";
|
|
821
|
+
});
|
|
822
|
+
} else if (darkClass) {
|
|
823
|
+
t = t.replace(/^<html/, `<html class="${darkClass}"`);
|
|
824
|
+
}
|
|
825
|
+
return t;
|
|
826
|
+
});
|
|
827
|
+
await fsModule.writeFile(htmlPath, updated);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// src/prompts/appearancePrompt.ts
|
|
831
|
+
import { select as select2, confirm, isCancel as isCancel2 } from "@clack/prompts";
|
|
832
|
+
async function layoutPrompt(initialValue) {
|
|
833
|
+
return await select2({
|
|
834
|
+
message: "Layout",
|
|
835
|
+
initialValue,
|
|
836
|
+
options: LAYOUTS.map((l) => ({ value: l.id, label: l.label, hint: l.hint }))
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
async function schemePrompt(layoutId, initialValue) {
|
|
840
|
+
const recommended = getLayout(layoutId)?.recommended.scheme;
|
|
841
|
+
return await select2({
|
|
842
|
+
message: "Esquema de cores",
|
|
843
|
+
initialValue: initialValue ?? recommended,
|
|
844
|
+
options: SCHEMES.map((s) => ({
|
|
845
|
+
value: s.id,
|
|
846
|
+
label: s.label,
|
|
847
|
+
hint: s.id === recommended ? `recomendado para este layout \u2014 ${s.hint}` : s.hint
|
|
848
|
+
}))
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
async function appearancePrompt(layoutId, current) {
|
|
852
|
+
const rec = getLayout(layoutId)?.recommended;
|
|
853
|
+
const colorMode = await select2({
|
|
854
|
+
message: "Modo de cor",
|
|
855
|
+
initialValue: current?.colorMode ?? rec?.mode ?? "dark",
|
|
856
|
+
options: COLOR_MODES.map((m) => ({
|
|
857
|
+
value: m.value,
|
|
858
|
+
label: m.label,
|
|
859
|
+
hint: m.value === rec?.mode ? `recomendado \u2014 ${m.hint}` : m.hint
|
|
860
|
+
}))
|
|
861
|
+
});
|
|
862
|
+
const toggle = await confirm({
|
|
863
|
+
message: "Mostrar um bot\xE3o para quem visita alternar entre claro e escuro?",
|
|
864
|
+
initialValue: current?.colorModeToggle ?? true
|
|
865
|
+
});
|
|
866
|
+
const colorModeToggle = !isCancel2(toggle) && toggle === true;
|
|
867
|
+
const texture = await select2({
|
|
868
|
+
message: "Textura",
|
|
869
|
+
initialValue: current?.texture ?? rec?.texture ?? "none",
|
|
870
|
+
options: TEXTURES.map((t) => ({
|
|
871
|
+
value: t.value,
|
|
872
|
+
label: t.label,
|
|
873
|
+
hint: t.value === rec?.texture ? `recomendada \u2014 ${t.hint}` : t.hint
|
|
874
|
+
}))
|
|
875
|
+
});
|
|
876
|
+
return { colorMode, colorModeToggle, texture };
|
|
877
|
+
}
|
|
878
|
+
async function fontPrompts(layoutId, current) {
|
|
879
|
+
const rec = getLayout(layoutId)?.fonts ?? { sans: [], mono: "JetBrains Mono" };
|
|
880
|
+
const fontSans = await select2({
|
|
881
|
+
message: "Fonte principal",
|
|
882
|
+
initialValue: current?.fontSans,
|
|
883
|
+
options: SANS_FONTS.map((f) => ({
|
|
884
|
+
value: f.family,
|
|
885
|
+
label: f.family,
|
|
886
|
+
hint: rec.sans.includes(f.family) ? "recomendada" : f.hint
|
|
887
|
+
}))
|
|
888
|
+
});
|
|
889
|
+
const fontMono = rec.mono === "" ? "" : await select2({
|
|
890
|
+
message: "Fonte mono",
|
|
891
|
+
initialValue: current?.fontMono,
|
|
892
|
+
options: MONO_FONTS.map((f) => ({
|
|
893
|
+
value: f.family,
|
|
894
|
+
label: f.family,
|
|
895
|
+
hint: f.family === rec.mono ? "recomendada" : f.hint
|
|
896
|
+
}))
|
|
897
|
+
});
|
|
898
|
+
return { fontSans, fontMono };
|
|
899
|
+
}
|
|
900
|
+
|
|
467
901
|
// src/commands/create.ts
|
|
468
|
-
var TEMPLATE_FONTS = {
|
|
469
|
-
cyberpunk: { fontSans: "Chakra Petch", fontMono: "JetBrains Mono" },
|
|
470
|
-
magazine: { fontSans: ["Bodoni Moda", "IBM Plex Serif"], fontMono: "JetBrains Mono" },
|
|
471
|
-
bento: { fontSans: "Manrope", fontMono: "JetBrains Mono" },
|
|
472
|
-
brutalist: { fontSans: "JetBrains Mono", fontMono: "JetBrains Mono" },
|
|
473
|
-
swiss: { fontSans: "Archivo", fontMono: "" }
|
|
474
|
-
};
|
|
475
902
|
var ALL_PLUGINS = [
|
|
476
903
|
"contact-wizard",
|
|
477
904
|
"proposals",
|
|
@@ -508,10 +935,10 @@ async function removeDir(dirPath, fs3) {
|
|
|
508
935
|
async function runCreate(projectName, deps) {
|
|
509
936
|
validateProjectName(projectName);
|
|
510
937
|
const fs3 = deps.fs ?? {
|
|
511
|
-
...
|
|
938
|
+
...nodeFsPromises10,
|
|
512
939
|
exists: async (p) => {
|
|
513
940
|
try {
|
|
514
|
-
await
|
|
941
|
+
await nodeFsPromises10.access(p);
|
|
515
942
|
return true;
|
|
516
943
|
} catch {
|
|
517
944
|
return false;
|
|
@@ -527,6 +954,7 @@ async function runCreate(projectName, deps) {
|
|
|
527
954
|
const applyIndexHtmlFn = deps.applyIndexHtml ?? applyIndexHtml;
|
|
528
955
|
const applyRubricalConfigFn = deps.applyRubricalConfig ?? applyRubricalConfig;
|
|
529
956
|
const writeStateFn = deps.writeState ?? writeState;
|
|
957
|
+
const applyAppearanceFn = deps.applyAppearance ?? applyAppearance;
|
|
530
958
|
const execFn = deps.exec ?? (async (cmd, cwd) => {
|
|
531
959
|
const { execSync } = await import("child_process");
|
|
532
960
|
execSync(cmd, { cwd, stdio: "inherit" });
|
|
@@ -535,60 +963,25 @@ async function runCreate(projectName, deps) {
|
|
|
535
963
|
const projectDir = `${deps.projectsDir}/${projectName}`;
|
|
536
964
|
const version = await getVersion();
|
|
537
965
|
await download(projectDir, version);
|
|
538
|
-
const layout = await
|
|
539
|
-
message: "Layout",
|
|
540
|
-
options: [
|
|
541
|
-
{ value: "cyberpunk", label: "Cyberpunk", hint: "sidebar lateral com foto de perfil \u2014 dev, designer, freelancer" },
|
|
542
|
-
{ value: "brutalist", label: "Brutalism Terminal", hint: "identidade hacker total \u2014 monospace, sem bordas arredondadas" },
|
|
543
|
-
{ value: "swiss", label: "Swiss Grid", hint: "grid de 12 colunas, tipografia forte, design su\xED\xE7o rigoroso" },
|
|
544
|
-
{ value: "bento", label: "Bento", hint: "grid assim\xE9trico com floating dock \u2014 moderno, orientado a produto" },
|
|
545
|
-
{ value: "magazine", label: "Magazine", hint: "editorial cl\xE1ssico \xB7 display serifado \xB7 grid assim\xE9trico \xB7 \xE1reas de respiro generosas" }
|
|
546
|
-
]
|
|
547
|
-
});
|
|
966
|
+
const layout = await layoutPrompt();
|
|
548
967
|
await applyLayoutFn(
|
|
549
968
|
layout,
|
|
550
969
|
{ projectDir, templatesDir: `${projectDir}/templates` },
|
|
551
970
|
fs3
|
|
552
971
|
);
|
|
553
|
-
const themeChoice = await
|
|
554
|
-
message: "Tema visual",
|
|
555
|
-
options: [
|
|
556
|
-
{ value: "editorial-cream", label: "Editorial Cream", hint: "refinado e atemporal \u2014 blogs e portf\xF3lios liter\xE1rios" },
|
|
557
|
-
{ value: "paper-noir", label: "Paper Noir", hint: "contraste m\xE1ximo \u2014 identidade editorial forte" },
|
|
558
|
-
{ value: "midnight-blue", label: "Midnight Blue", hint: "tech e premium \u2014 devs e designers noturnos" },
|
|
559
|
-
{ value: "solar-warm", label: "Solar Warm", hint: "energia e criatividade \u2014 marcas pessoais vibrantes" }
|
|
560
|
-
]
|
|
561
|
-
});
|
|
972
|
+
const themeChoice = await schemePrompt(layout);
|
|
562
973
|
await applyThemeFn(
|
|
563
974
|
{ preset: themeChoice },
|
|
564
975
|
`${projectDir}/src/index.css`,
|
|
565
976
|
fs3
|
|
566
977
|
);
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
{ value: "Playfair Display", label: "Playfair Display", hint: "elegante, editorial cl\xE1ssico" },
|
|
575
|
-
{ value: "Space Grotesk", label: "Space Grotesk", hint: "moderna, startup" },
|
|
576
|
-
{ value: "DM Sans", label: "DM Sans", hint: "limpa, amig\xE1vel, vers\xE1til" },
|
|
577
|
-
{ value: "Bodoni Moda", label: "Bodoni Moda", hint: recommendedSans.includes("Bodoni Moda") ? "recomendada" : "display serifado elegante, editorial cl\xE1ssico" },
|
|
578
|
-
{ value: "IBM Plex Serif", label: "IBM Plex Serif", hint: recommendedSans.includes("IBM Plex Serif") ? "recomendada" : "serifa t\xE9cnica, confian\xE7a e rigor" },
|
|
579
|
-
{ value: "Manrope", label: "Manrope", hint: recommendedSans.includes("Manrope") ? "recomendada" : "geom\xE9trica humanista, moderna e acolhedora" },
|
|
580
|
-
{ value: "Archivo", label: "Archivo", hint: recommendedSans.includes("Archivo") ? "recomendada" : "grotesca utilit\xE1ria, clareza e for\xE7a tipogr\xE1fica" }
|
|
581
|
-
]
|
|
582
|
-
});
|
|
583
|
-
const fontMono = recommendedFonts.fontMono === "" ? "" : await select2({
|
|
584
|
-
message: "Fonte mono",
|
|
585
|
-
options: [
|
|
586
|
-
{ value: "JetBrains Mono", label: "JetBrains Mono", hint: recommendedFonts.fontMono === "JetBrains Mono" ? "recomendada" : "dev-friendly, clara" },
|
|
587
|
-
{ value: "Fira Code", label: "Fira Code", hint: "cl\xE1ssico, com ligatures" },
|
|
588
|
-
{ value: "Space Mono", label: "Space Mono", hint: "retro digital" },
|
|
589
|
-
{ value: "IBM Plex Mono", label: "IBM Plex Mono", hint: "corporativo-tech" }
|
|
590
|
-
]
|
|
591
|
-
});
|
|
978
|
+
const appearance = await appearancePrompt(layout);
|
|
979
|
+
await applyAppearanceFn(
|
|
980
|
+
appearance,
|
|
981
|
+
`${projectDir}/index.html`,
|
|
982
|
+
fs3
|
|
983
|
+
);
|
|
984
|
+
const { fontSans, fontMono } = await fontPrompts(layout);
|
|
592
985
|
await applyFontFn(
|
|
593
986
|
{ fontSans, fontMono },
|
|
594
987
|
{ css: `${projectDir}/src/index.css`, html: `${projectDir}/index.html` },
|
|
@@ -624,7 +1017,7 @@ async function runCreate(projectName, deps) {
|
|
|
624
1017
|
);
|
|
625
1018
|
const identity = await doIdentityPrompt();
|
|
626
1019
|
await applyIndexHtmlFn(
|
|
627
|
-
indexHtmlInput(identity, fontSans),
|
|
1020
|
+
indexHtmlInput(identity, fontSans, fontMono),
|
|
628
1021
|
`${projectDir}/index.html`,
|
|
629
1022
|
fs3
|
|
630
1023
|
);
|
|
@@ -645,6 +1038,7 @@ async function runCreate(projectName, deps) {
|
|
|
645
1038
|
version: version.replace(/^v/, ""),
|
|
646
1039
|
layout,
|
|
647
1040
|
theme: themeChoice,
|
|
1041
|
+
...appearance,
|
|
648
1042
|
fontSans,
|
|
649
1043
|
fontMono,
|
|
650
1044
|
plugins: pluginsRecord,
|
|
@@ -660,8 +1054,8 @@ async function runCreate(projectName, deps) {
|
|
|
660
1054
|
},
|
|
661
1055
|
fs3
|
|
662
1056
|
);
|
|
663
|
-
const doGitInit = await
|
|
664
|
-
const packageManager = await
|
|
1057
|
+
const doGitInit = await confirm2({ message: "Inicializar reposit\xF3rio git?" });
|
|
1058
|
+
const packageManager = await select3({
|
|
665
1059
|
message: "Gerenciador de pacotes",
|
|
666
1060
|
options: [
|
|
667
1061
|
{ value: "pnpm", label: "pnpm (recomendado)" },
|
|
@@ -700,14 +1094,14 @@ Boa sorte! \u{1F680}`
|
|
|
700
1094
|
}
|
|
701
1095
|
|
|
702
1096
|
// src/commands/config.ts
|
|
703
|
-
import { outro as outro2,
|
|
704
|
-
import * as
|
|
1097
|
+
import { outro as outro2, multiselect as multiselect2, confirm as confirm3, isCancel as isCancel4, cancel as cancel3, log } from "@clack/prompts";
|
|
1098
|
+
import * as nodeFsPromises12 from "fs/promises";
|
|
705
1099
|
import * as path6 from "path";
|
|
706
1100
|
|
|
707
1101
|
// src/utils/detectProject.ts
|
|
708
|
-
import * as
|
|
1102
|
+
import * as nodeFsPromises11 from "fs/promises";
|
|
709
1103
|
import * as path5 from "path";
|
|
710
|
-
async function detectProject(startDir, fsModule =
|
|
1104
|
+
async function detectProject(startDir, fsModule = nodeFsPromises11) {
|
|
711
1105
|
let current = startDir;
|
|
712
1106
|
while (true) {
|
|
713
1107
|
const candidate = path5.join(current, "rubrica.json");
|
|
@@ -738,7 +1132,7 @@ async function existsIn(fs3, p) {
|
|
|
738
1132
|
}
|
|
739
1133
|
async function runConfig(deps = {}) {
|
|
740
1134
|
const cwd = deps.cwd ?? process.cwd();
|
|
741
|
-
const fs3 = deps.fs ??
|
|
1135
|
+
const fs3 = deps.fs ?? nodeFsPromises12;
|
|
742
1136
|
const detectProjectFn = deps.detectProject ?? detectProject;
|
|
743
1137
|
const readStateFn = deps.readState ?? readState;
|
|
744
1138
|
const writeStateFn = deps.writeState ?? writeState;
|
|
@@ -751,6 +1145,7 @@ async function runConfig(deps = {}) {
|
|
|
751
1145
|
const applyPluginsFn = deps.applyPlugins ?? applyPlugins;
|
|
752
1146
|
const downloadReleaseFn = deps.downloadRelease ?? downloadRelease;
|
|
753
1147
|
const getLatestVersionFn = deps.getLatestVersion ?? getLatestVersion;
|
|
1148
|
+
const applyAppearanceFn = deps.applyAppearance ?? applyAppearance;
|
|
754
1149
|
const rubricaJsonPath = await detectProjectFn(cwd, fs3);
|
|
755
1150
|
const projectDir = path6.dirname(rubricaJsonPath);
|
|
756
1151
|
const currentState = await readStateFn(projectDir, fs3);
|
|
@@ -759,13 +1154,13 @@ async function runConfig(deps = {}) {
|
|
|
759
1154
|
message: "O que deseja reconfigurar?",
|
|
760
1155
|
options: [
|
|
761
1156
|
{ value: "identity", label: "Identidade (nome, URL, SEO, RSS)" },
|
|
762
|
-
{ value: "appearance", label: "Apar\xEAncia (
|
|
1157
|
+
{ value: "appearance", label: "Apar\xEAncia (esquema de cores, modo claro/escuro, textura, fontes)" },
|
|
763
1158
|
{ value: "layout", label: "Layout" },
|
|
764
1159
|
{ value: "plugins", label: "Plugins" }
|
|
765
1160
|
],
|
|
766
1161
|
required: false
|
|
767
1162
|
});
|
|
768
|
-
if (
|
|
1163
|
+
if (isCancel4(sections)) {
|
|
769
1164
|
cancel3("Opera\xE7\xE3o cancelada.");
|
|
770
1165
|
return;
|
|
771
1166
|
}
|
|
@@ -778,48 +1173,20 @@ async function runConfig(deps = {}) {
|
|
|
778
1173
|
fs3
|
|
779
1174
|
);
|
|
780
1175
|
await applyIndexHtmlFn(
|
|
781
|
-
indexHtmlInput(identityData, currentState.fontSans),
|
|
1176
|
+
indexHtmlInput(identityData, currentState.fontSans, currentState.fontMono),
|
|
782
1177
|
path6.join(projectDir, "index.html"),
|
|
783
1178
|
fs3
|
|
784
1179
|
);
|
|
785
1180
|
stateUpdate.identity = identityData;
|
|
786
1181
|
}
|
|
787
1182
|
if (selected.includes("appearance")) {
|
|
788
|
-
const theme = await
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
{ value: "paper-noir", label: "Paper Noir", hint: "contraste m\xE1ximo \u2014 identidade editorial forte" },
|
|
794
|
-
{ value: "midnight-blue", label: "Midnight Blue", hint: "tech e premium \u2014 devs e designers noturnos" },
|
|
795
|
-
{ value: "solar-warm", label: "Solar Warm", hint: "energia e criatividade \u2014 marcas pessoais vibrantes" }
|
|
796
|
-
]
|
|
797
|
-
});
|
|
798
|
-
const fontSans = await select3({
|
|
799
|
-
message: "Fonte principal",
|
|
800
|
-
initialValue: currentState.fontSans,
|
|
801
|
-
options: [
|
|
802
|
-
{ value: "Inter", label: "Inter", hint: "neutra, leg\xEDvel, padr\xE3o de produtos digitais" },
|
|
803
|
-
{ value: "Chakra Petch", label: "Chakra Petch", hint: "geom\xE9trica, tech, futurista" },
|
|
804
|
-
{ value: "Playfair Display", label: "Playfair Display", hint: "elegante, editorial cl\xE1ssico" },
|
|
805
|
-
{ value: "Space Grotesk", label: "Space Grotesk", hint: "moderna, startup" },
|
|
806
|
-
{ value: "DM Sans", label: "DM Sans", hint: "limpa, amig\xE1vel, vers\xE1til" },
|
|
807
|
-
{ value: "Bodoni Moda", label: "Bodoni Moda", hint: "display serifado elegante, editorial cl\xE1ssico" },
|
|
808
|
-
{ value: "IBM Plex Serif", label: "IBM Plex Serif", hint: "serifa t\xE9cnica, confian\xE7a e rigor" },
|
|
809
|
-
{ value: "Manrope", label: "Manrope", hint: "geom\xE9trica humanista, moderna e acolhedora" },
|
|
810
|
-
{ value: "Archivo", label: "Archivo", hint: "grotesca utilit\xE1ria, clareza e for\xE7a tipogr\xE1fica" }
|
|
811
|
-
]
|
|
812
|
-
});
|
|
813
|
-
const fontMono = await select3({
|
|
814
|
-
message: "Fonte mono",
|
|
815
|
-
initialValue: currentState.fontMono,
|
|
816
|
-
options: [
|
|
817
|
-
{ value: "JetBrains Mono", label: "JetBrains Mono", hint: "dev-friendly, clara" },
|
|
818
|
-
{ value: "Fira Code", label: "Fira Code", hint: "cl\xE1ssico, com ligatures" },
|
|
819
|
-
{ value: "Space Mono", label: "Space Mono", hint: "retro digital" },
|
|
820
|
-
{ value: "IBM Plex Mono", label: "IBM Plex Mono", hint: "corporativo-tech" }
|
|
821
|
-
]
|
|
1183
|
+
const theme = await schemePrompt(currentState.layout, currentState.theme);
|
|
1184
|
+
const appearance = await appearancePrompt(currentState.layout, {
|
|
1185
|
+
colorMode: currentState.colorMode,
|
|
1186
|
+
colorModeToggle: currentState.colorModeToggle,
|
|
1187
|
+
texture: currentState.texture
|
|
822
1188
|
});
|
|
1189
|
+
const { fontSans, fontMono } = await fontPrompts(currentState.layout, currentState);
|
|
823
1190
|
const cssPath = path6.join(projectDir, "src", "index.css");
|
|
824
1191
|
const htmlPath = path6.join(projectDir, "index.html");
|
|
825
1192
|
await applyThemeFn(
|
|
@@ -827,6 +1194,13 @@ async function runConfig(deps = {}) {
|
|
|
827
1194
|
cssPath,
|
|
828
1195
|
fs3
|
|
829
1196
|
);
|
|
1197
|
+
await applyAppearanceFn(appearance, htmlPath, fs3);
|
|
1198
|
+
const css = await fs3.readFile(cssPath, "utf-8").catch(() => "");
|
|
1199
|
+
if (css && !css.includes(SCHEME_START)) {
|
|
1200
|
+
log.warn(
|
|
1201
|
+
"Este projeto \xE9 de uma vers\xE3o sem modo claro/escuro: s\xF3 as 4 cores principais do esquema foram aplicadas. Para ter os dois modos, a altern\xE2ncia e as texturas, atualize com `npx create-rubrica@latest update` e rode o config de novo."
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
830
1204
|
await applyFontFn(
|
|
831
1205
|
{ fontSans, fontMono },
|
|
832
1206
|
{ css: cssPath, html: htmlPath },
|
|
@@ -835,47 +1209,45 @@ async function runConfig(deps = {}) {
|
|
|
835
1209
|
const identity = stateUpdate.identity ?? currentState.identity;
|
|
836
1210
|
if (identity) {
|
|
837
1211
|
await applyIndexHtmlFn(
|
|
838
|
-
indexHtmlInput(identity, fontSans),
|
|
1212
|
+
indexHtmlInput(identity, fontSans, fontMono),
|
|
839
1213
|
htmlPath,
|
|
840
1214
|
fs3
|
|
841
1215
|
);
|
|
842
1216
|
}
|
|
843
1217
|
stateUpdate.theme = theme;
|
|
1218
|
+
Object.assign(stateUpdate, appearance);
|
|
844
1219
|
stateUpdate.fontSans = fontSans;
|
|
845
1220
|
stateUpdate.fontMono = fontMono;
|
|
846
1221
|
}
|
|
847
1222
|
if (selected.includes("layout")) {
|
|
848
|
-
const newLayout = await
|
|
849
|
-
|
|
850
|
-
initialValue: currentState.layout,
|
|
851
|
-
options: [
|
|
852
|
-
{ value: "cyberpunk", label: "Cyberpunk", hint: "sidebar lateral com foto de perfil \u2014 dev, designer, freelancer" },
|
|
853
|
-
{ value: "brutalist", label: "Brutalism Terminal", hint: "identidade hacker total \u2014 monospace, sem bordas arredondadas" },
|
|
854
|
-
{ value: "swiss", label: "Swiss Grid", hint: "grid de 12 colunas, tipografia forte, design su\xED\xE7o rigoroso" },
|
|
855
|
-
{ value: "bento", label: "Bento", hint: "grid assim\xE9trico com floating dock \u2014 moderno, orientado a produto" },
|
|
856
|
-
{ value: "magazine", label: "Magazine", hint: "editorial cl\xE1ssico \xB7 display serifado \xB7 grid assim\xE9trico \xB7 \xE1reas de respiro generosas" }
|
|
857
|
-
]
|
|
858
|
-
});
|
|
859
|
-
const confirmed = await confirm2({
|
|
1223
|
+
const newLayout = await layoutPrompt(currentState.layout);
|
|
1224
|
+
const confirmed = await confirm3({
|
|
860
1225
|
message: "\u26A0 Isso sobrescreve Layout.tsx e arquivos de navega\xE7\xE3o. Customiza\xE7\xF5es manuais ser\xE3o perdidas. Continuar?"
|
|
861
1226
|
});
|
|
862
|
-
if (!
|
|
1227
|
+
if (!isCancel4(confirmed) && confirmed === true) {
|
|
863
1228
|
let templatesDir = path6.join(projectDir, "templates");
|
|
864
1229
|
let tmpDir;
|
|
865
1230
|
if (!await existsIn(fs3, templatesDir)) {
|
|
866
|
-
tmpDir = await
|
|
1231
|
+
tmpDir = await nodeFsPromises12.mkdtemp(path6.join(tmpdir2(), "rubrica-config-"));
|
|
867
1232
|
const version = currentState.version === "0.1.0" ? await getLatestVersionFn() : currentState.version;
|
|
868
1233
|
await downloadReleaseFn(tmpDir, version.startsWith("v") ? version : `v${version}`);
|
|
869
1234
|
templatesDir = path6.join(tmpDir, "templates");
|
|
870
1235
|
}
|
|
871
1236
|
try {
|
|
1237
|
+
const layoutsDir = path6.join(templatesDir, "layouts");
|
|
1238
|
+
if (await existsIn(fs3, layoutsDir) && !await existsIn(fs3, path6.join(layoutsDir, newLayout))) {
|
|
1239
|
+
log.warn(
|
|
1240
|
+
`O layout "${newLayout}" n\xE3o existe na vers\xE3o ${currentState.version} deste projeto. Atualize o projeto com \`npx create-rubrica@latest update\` e rode o config de novo.`
|
|
1241
|
+
);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
872
1244
|
await applyLayoutFn(
|
|
873
1245
|
newLayout,
|
|
874
1246
|
{ projectDir, templatesDir },
|
|
875
|
-
{ ...fs3, copyFile:
|
|
1247
|
+
{ ...fs3, copyFile: nodeFsPromises12.copyFile, unlink: nodeFsPromises12.unlink, exists: (p) => existsIn(fs3, p) }
|
|
876
1248
|
);
|
|
877
1249
|
} finally {
|
|
878
|
-
if (tmpDir) await
|
|
1250
|
+
if (tmpDir) await nodeFsPromises12.rm(tmpDir, { recursive: true, force: true });
|
|
879
1251
|
}
|
|
880
1252
|
stateUpdate.layout = newLayout;
|
|
881
1253
|
}
|
|
@@ -888,7 +1260,7 @@ async function runConfig(deps = {}) {
|
|
|
888
1260
|
options: ALL_PLUGINS.map((p) => ({ value: p, label: p })),
|
|
889
1261
|
required: false
|
|
890
1262
|
});
|
|
891
|
-
if (!
|
|
1263
|
+
if (!isCancel4(selectedPlugins)) {
|
|
892
1264
|
const pluginsMap = {};
|
|
893
1265
|
for (const p of ALL_PLUGINS) {
|
|
894
1266
|
pluginsMap[p] = selectedPlugins.includes(p);
|
|
@@ -908,7 +1280,7 @@ async function runConfig(deps = {}) {
|
|
|
908
1280
|
}
|
|
909
1281
|
|
|
910
1282
|
// src/commands/update.ts
|
|
911
|
-
import { intro as intro2, outro as outro3, confirm as
|
|
1283
|
+
import { intro as intro2, outro as outro3, confirm as confirm4, text as text2, isCancel as isCancel5, cancel as cancel4, log as log2, spinner } from "@clack/prompts";
|
|
912
1284
|
import * as fs2 from "fs/promises";
|
|
913
1285
|
import * as path9 from "path";
|
|
914
1286
|
import { tmpdir as tmpdir3 } from "os";
|
|
@@ -916,13 +1288,13 @@ import { execFile as execFile3 } from "child_process";
|
|
|
916
1288
|
import { promisify as promisify3 } from "util";
|
|
917
1289
|
|
|
918
1290
|
// src/utils/pristine.ts
|
|
919
|
-
import * as
|
|
1291
|
+
import * as nodeFsPromises13 from "fs/promises";
|
|
920
1292
|
import * as path7 from "path";
|
|
921
1293
|
var fsForTransforms = {
|
|
922
|
-
...
|
|
1294
|
+
...nodeFsPromises13,
|
|
923
1295
|
exists: async (p) => {
|
|
924
1296
|
try {
|
|
925
|
-
await
|
|
1297
|
+
await nodeFsPromises13.access(p);
|
|
926
1298
|
return true;
|
|
927
1299
|
} catch {
|
|
928
1300
|
return false;
|
|
@@ -939,6 +1311,13 @@ async function buildPristine(options) {
|
|
|
939
1311
|
const cssPath = path7.join(dir, "src", "index.css");
|
|
940
1312
|
const htmlPath = path7.join(dir, "index.html");
|
|
941
1313
|
await applyTheme({ preset: state.theme }, cssPath, fs3);
|
|
1314
|
+
if (state.colorMode) {
|
|
1315
|
+
await applyAppearance(
|
|
1316
|
+
{ colorMode: state.colorMode, colorModeToggle: state.colorModeToggle ?? false, texture: state.texture ?? "none" },
|
|
1317
|
+
htmlPath,
|
|
1318
|
+
fs3
|
|
1319
|
+
);
|
|
1320
|
+
}
|
|
942
1321
|
await applyFont({ fontSans: state.fontSans, fontMono: state.fontMono }, { css: cssPath, html: htmlPath }, fs3);
|
|
943
1322
|
const registryPath = path7.join(dir, "convex", "pluginRegistry.ts");
|
|
944
1323
|
const knownPlugins = await knownPluginIds(registryPath);
|
|
@@ -948,21 +1327,21 @@ async function buildPristine(options) {
|
|
|
948
1327
|
await applyPlugins(plugins, registryPath, fs3);
|
|
949
1328
|
const identity = state.identity;
|
|
950
1329
|
if (identity) {
|
|
951
|
-
await applyIndexHtml(indexHtmlInput(identity, state.fontSans), htmlPath, fs3);
|
|
1330
|
+
await applyIndexHtml(indexHtmlInput(identity, state.fontSans, state.fontMono), htmlPath, fs3);
|
|
952
1331
|
await applyRubricalConfig(rubricaConfigInput(identity, state.fontSans, state.fontMono), dir, fs3);
|
|
953
1332
|
}
|
|
954
1333
|
if (options.packageName) {
|
|
955
1334
|
const pkgPath = path7.join(dir, "package.json");
|
|
956
|
-
const pkg = JSON.parse(await
|
|
1335
|
+
const pkg = JSON.parse(await nodeFsPromises13.readFile(pkgPath, "utf-8"));
|
|
957
1336
|
pkg.name = options.packageName;
|
|
958
|
-
await
|
|
1337
|
+
await nodeFsPromises13.writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
959
1338
|
}
|
|
960
|
-
await
|
|
961
|
-
await
|
|
1339
|
+
await nodeFsPromises13.rm(path7.join(dir, "templates"), { recursive: true, force: true });
|
|
1340
|
+
await nodeFsPromises13.rm(path7.join(dir, "cli"), { recursive: true, force: true });
|
|
962
1341
|
}
|
|
963
1342
|
async function knownPluginIds(registryPath) {
|
|
964
1343
|
try {
|
|
965
|
-
const content = await
|
|
1344
|
+
const content = await nodeFsPromises13.readFile(registryPath, "utf-8");
|
|
966
1345
|
return new Set([...content.matchAll(/id: '([^']+)'/g)].map((m) => m[1]));
|
|
967
1346
|
} catch {
|
|
968
1347
|
return /* @__PURE__ */ new Set();
|
|
@@ -1225,7 +1604,7 @@ Para preservar suas personaliza\xE7\xF5es, o update precisa saber com qual vers\
|
|
|
1225
1604
|
placeholder: "ex.: 0.3.12",
|
|
1226
1605
|
validate: (v) => /^v?\d+\.\d+\.\d+$/.test(v.trim()) ? void 0 : "Use o formato 0.3.12"
|
|
1227
1606
|
});
|
|
1228
|
-
if (
|
|
1607
|
+
if (isCancel5(answer)) {
|
|
1229
1608
|
cancel4("Atualiza\xE7\xE3o cancelada.");
|
|
1230
1609
|
return;
|
|
1231
1610
|
}
|
|
@@ -1276,8 +1655,8 @@ ${formatPlan(actions)}`);
|
|
|
1276
1655
|
return;
|
|
1277
1656
|
}
|
|
1278
1657
|
if (ask) {
|
|
1279
|
-
const proceed = await
|
|
1280
|
-
if (
|
|
1658
|
+
const proceed = await confirm4({ message: `Aplicar a atualiza\xE7\xE3o para ${toVersion}?` });
|
|
1659
|
+
if (isCancel5(proceed) || !proceed) {
|
|
1281
1660
|
cancel4("Atualiza\xE7\xE3o cancelada.");
|
|
1282
1661
|
return;
|
|
1283
1662
|
}
|
|
@@ -1316,8 +1695,8 @@ ${steps.map((st, i) => ` ${i + 1}. ${st}`).join("\n")}`);
|
|
|
1316
1695
|
}
|
|
1317
1696
|
|
|
1318
1697
|
// src/commands/setup.ts
|
|
1319
|
-
import { outro as outro4, text as text3, password, spinner as spinner2, isCancel as
|
|
1320
|
-
import * as
|
|
1698
|
+
import { outro as outro4, text as text3, password, spinner as spinner2, isCancel as isCancel6, cancel as cancel5, log as log3 } from "@clack/prompts";
|
|
1699
|
+
import * as nodeFsPromises14 from "fs/promises";
|
|
1321
1700
|
import * as path10 from "path";
|
|
1322
1701
|
import * as nodeCrypto from "crypto";
|
|
1323
1702
|
import { execFileSync as defaultExecFileSync } from "child_process";
|
|
@@ -1349,10 +1728,10 @@ function parseEnvFile(content) {
|
|
|
1349
1728
|
async function runSetup(deps = {}) {
|
|
1350
1729
|
const cwd = deps.cwd ?? process.cwd();
|
|
1351
1730
|
const fs3 = deps.fs ?? {
|
|
1352
|
-
access: (p) =>
|
|
1353
|
-
readFile: (p, enc) =>
|
|
1354
|
-
writeFile: (p, data) =>
|
|
1355
|
-
mkdir: (p, opts) =>
|
|
1731
|
+
access: (p) => nodeFsPromises14.access(p).then(() => void 0),
|
|
1732
|
+
readFile: (p, enc) => nodeFsPromises14.readFile(p, enc),
|
|
1733
|
+
writeFile: (p, data) => nodeFsPromises14.writeFile(p, data).then(() => void 0),
|
|
1734
|
+
mkdir: (p, opts) => nodeFsPromises14.mkdir(p, opts).then(() => void 0)
|
|
1356
1735
|
};
|
|
1357
1736
|
const detectProject2 = deps.detectProject ?? detectProject;
|
|
1358
1737
|
const generateJwtKeys2 = deps.generateJwtKeys ?? generateJwtKeys;
|
|
@@ -1407,7 +1786,7 @@ async function runSetup(deps = {}) {
|
|
|
1407
1786
|
return "URL deve come\xE7ar com http:// ou https://";
|
|
1408
1787
|
}
|
|
1409
1788
|
});
|
|
1410
|
-
if (
|
|
1789
|
+
if (isCancel6(siteUrl)) {
|
|
1411
1790
|
cancel5("Setup cancelado.");
|
|
1412
1791
|
return;
|
|
1413
1792
|
}
|
|
@@ -1421,14 +1800,14 @@ async function runSetup(deps = {}) {
|
|
|
1421
1800
|
message: "TELEGRAM_BOT_TOKEN (Enter para pular):",
|
|
1422
1801
|
initialValue: ""
|
|
1423
1802
|
});
|
|
1424
|
-
if (!
|
|
1803
|
+
if (!isCancel6(telegramToken) && telegramToken && telegramToken.trim()) {
|
|
1425
1804
|
execFileSync("npx", ["convex", "env", "set", "--", "TELEGRAM_BOT_TOKEN", telegramToken], { stdio: "pipe" });
|
|
1426
1805
|
}
|
|
1427
1806
|
const telegramChatId = await text3({
|
|
1428
1807
|
message: "TELEGRAM_ADMIN_CHAT_ID (Enter para pular):",
|
|
1429
1808
|
initialValue: ""
|
|
1430
1809
|
});
|
|
1431
|
-
if (!
|
|
1810
|
+
if (!isCancel6(telegramChatId) && telegramChatId && telegramChatId.trim()) {
|
|
1432
1811
|
execFileSync("npx", ["convex", "env", "set", "--", "TELEGRAM_ADMIN_CHAT_ID", telegramChatId], { stdio: "pipe" });
|
|
1433
1812
|
}
|
|
1434
1813
|
}
|
|
@@ -1441,7 +1820,7 @@ async function runSetup(deps = {}) {
|
|
|
1441
1820
|
message: "OPENROUTER_API_KEY (Enter para pular):",
|
|
1442
1821
|
initialValue: ""
|
|
1443
1822
|
});
|
|
1444
|
-
if (!
|
|
1823
|
+
if (!isCancel6(openrouterKey) && openrouterKey && openrouterKey.trim()) {
|
|
1445
1824
|
execFileSync("npx", ["convex", "env", "set", "--", "OPENROUTER_API_KEY", openrouterKey], { stdio: "pipe" });
|
|
1446
1825
|
}
|
|
1447
1826
|
}
|
|
@@ -1450,7 +1829,7 @@ async function runSetup(deps = {}) {
|
|
|
1450
1829
|
message: "ASAAS_API_KEY \u2014 chave da API do Asaas, sandbox ou produ\xE7\xE3o (Enter para pular):",
|
|
1451
1830
|
initialValue: ""
|
|
1452
1831
|
});
|
|
1453
|
-
if (!
|
|
1832
|
+
if (!isCancel6(asaasKey) && asaasKey && asaasKey.trim()) {
|
|
1454
1833
|
const key = asaasKey.trim();
|
|
1455
1834
|
execFileSync("npx", ["convex", "env", "set", "--", "ASAAS_API_KEY", key], { stdio: "pipe" });
|
|
1456
1835
|
const webhookToken = randomBytes2(32).toString("hex");
|
|
@@ -1474,7 +1853,7 @@ Sem o webhook, os pagamentos nunca aparecem como pagos.`
|
|
|
1474
1853
|
return "Email inv\xE1lido \u2014 deve conter @ e pelo menos um ponto";
|
|
1475
1854
|
}
|
|
1476
1855
|
});
|
|
1477
|
-
if (
|
|
1856
|
+
if (isCancel6(adminEmail)) {
|
|
1478
1857
|
cancel5("Setup cancelado.");
|
|
1479
1858
|
return;
|
|
1480
1859
|
}
|
|
@@ -1484,7 +1863,7 @@ Sem o webhook, os pagamentos nunca aparecem como pagos.`
|
|
|
1484
1863
|
if (v.length < 12) return "Senha deve ter pelo menos 12 caracteres";
|
|
1485
1864
|
}
|
|
1486
1865
|
});
|
|
1487
|
-
if (
|
|
1866
|
+
if (isCancel6(adminPassword)) {
|
|
1488
1867
|
cancel5("Setup cancelado.");
|
|
1489
1868
|
return;
|
|
1490
1869
|
}
|
|
@@ -1494,7 +1873,7 @@ Sem o webhook, os pagamentos nunca aparecem como pagos.`
|
|
|
1494
1873
|
if (v !== adminPassword) return "As senhas n\xE3o coincidem";
|
|
1495
1874
|
}
|
|
1496
1875
|
});
|
|
1497
|
-
if (
|
|
1876
|
+
if (isCancel6(adminPasswordConfirm)) {
|
|
1498
1877
|
cancel5("Setup cancelado.");
|
|
1499
1878
|
return;
|
|
1500
1879
|
}
|
|
@@ -1565,14 +1944,14 @@ Sem o webhook, os pagamentos nunca aparecem como pagos.`
|
|
|
1565
1944
|
message: "VERCEL_DEPLOY_HOOK_URL (Enter para pular):",
|
|
1566
1945
|
initialValue: ""
|
|
1567
1946
|
});
|
|
1568
|
-
if (!
|
|
1947
|
+
if (!isCancel6(vercelHookUrl) && vercelHookUrl && vercelHookUrl.trim()) {
|
|
1569
1948
|
execFileSync("npx", ["convex", "env", "set", "--", "VERCEL_DEPLOY_HOOK_URL", vercelHookUrl], { stdio: "pipe" });
|
|
1570
1949
|
}
|
|
1571
1950
|
const vercelWebhookSecret = await text3({
|
|
1572
1951
|
message: "VERCEL_WEBHOOK_SECRET (Enter para pular):",
|
|
1573
1952
|
initialValue: ""
|
|
1574
1953
|
});
|
|
1575
|
-
if (!
|
|
1954
|
+
if (!isCancel6(vercelWebhookSecret) && vercelWebhookSecret && vercelWebhookSecret.trim()) {
|
|
1576
1955
|
execFileSync("npx", ["convex", "env", "set", "--", "VERCEL_WEBHOOK_SECRET", vercelWebhookSecret], { stdio: "pipe" });
|
|
1577
1956
|
}
|
|
1578
1957
|
const profession = await text3({
|
|
@@ -1585,8 +1964,8 @@ Sem o webhook, os pagamentos nunca aparecem como pagos.`
|
|
|
1585
1964
|
placeholder: "Ex: Branding, Motion Design, Fotografia de Produto",
|
|
1586
1965
|
initialValue: ""
|
|
1587
1966
|
});
|
|
1588
|
-
const professionStr =
|
|
1589
|
-
const specialtiesStr =
|
|
1967
|
+
const professionStr = isCancel6(profession) ? "" : (profession || "").trim();
|
|
1968
|
+
const specialtiesStr = isCancel6(specialties) ? "" : (specialties || "").trim();
|
|
1590
1969
|
if (professionStr || specialtiesStr) {
|
|
1591
1970
|
const tags = specialtiesStr ? specialtiesStr.split(",").map((s2) => s2.trim()).filter(Boolean).slice(0, 4).map((label, i) => ({ label, color: i % 2 === 0 ? "primary" : "secondary" })) : [
|
|
1592
1971
|
{ label: "React", color: "primary" },
|