create-rubrica 0.3.17 → 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 +63 -51
- package/dist/index.js +1050 -410
- package/package.json +1 -1
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=")[^"]*(")/,
|
|
@@ -434,14 +769,136 @@ async function writeState(projectDir, partial, fsModule = nodeFsPromises8) {
|
|
|
434
769
|
return merged;
|
|
435
770
|
}
|
|
436
771
|
|
|
772
|
+
// src/transforms/identityInputs.ts
|
|
773
|
+
function rubricaConfigInput(identity, fontSans, fontMono) {
|
|
774
|
+
return {
|
|
775
|
+
siteName: identity.siteName,
|
|
776
|
+
siteUrl: identity.siteUrl,
|
|
777
|
+
siteDescription: identity.siteDescription,
|
|
778
|
+
authorName: identity.authorName,
|
|
779
|
+
authorEmail: identity.authorEmail,
|
|
780
|
+
twitterHandle: identity.twitterHandle,
|
|
781
|
+
lang: identity.lang,
|
|
782
|
+
seoHomeTitle: identity.siteName,
|
|
783
|
+
seoHomeDescription: identity.siteDescription,
|
|
784
|
+
rssTitle: identity.siteName,
|
|
785
|
+
rssDescription: identity.siteDescription,
|
|
786
|
+
ogImageUrl: `${identity.siteUrl}/og.png`,
|
|
787
|
+
fontSans,
|
|
788
|
+
fontMono
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
function indexHtmlInput(identity, fontSans, fontMono = "") {
|
|
792
|
+
return {
|
|
793
|
+
fontFamily: fontSans,
|
|
794
|
+
fontMono,
|
|
795
|
+
themeColor: "",
|
|
796
|
+
siteName: identity.siteName,
|
|
797
|
+
siteUrl: identity.siteUrl,
|
|
798
|
+
twitterHandle: identity.twitterHandle,
|
|
799
|
+
authorName: identity.authorName
|
|
800
|
+
};
|
|
801
|
+
}
|
|
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
|
+
|
|
437
901
|
// src/commands/create.ts
|
|
438
|
-
var TEMPLATE_FONTS = {
|
|
439
|
-
cyberpunk: { fontSans: "Chakra Petch", fontMono: "JetBrains Mono" },
|
|
440
|
-
magazine: { fontSans: ["Bodoni Moda", "IBM Plex Serif"], fontMono: "JetBrains Mono" },
|
|
441
|
-
bento: { fontSans: "Manrope", fontMono: "JetBrains Mono" },
|
|
442
|
-
brutalist: { fontSans: "JetBrains Mono", fontMono: "JetBrains Mono" },
|
|
443
|
-
swiss: { fontSans: "Archivo", fontMono: "" }
|
|
444
|
-
};
|
|
445
902
|
var ALL_PLUGINS = [
|
|
446
903
|
"contact-wizard",
|
|
447
904
|
"proposals",
|
|
@@ -470,18 +927,18 @@ function validateProjectName(name) {
|
|
|
470
927
|
);
|
|
471
928
|
}
|
|
472
929
|
}
|
|
473
|
-
async function removeDir(dirPath,
|
|
474
|
-
if (await
|
|
475
|
-
await
|
|
930
|
+
async function removeDir(dirPath, fs3) {
|
|
931
|
+
if (await fs3.exists(dirPath)) {
|
|
932
|
+
await fs3.rm(dirPath, { recursive: true, force: true });
|
|
476
933
|
}
|
|
477
934
|
}
|
|
478
935
|
async function runCreate(projectName, deps) {
|
|
479
936
|
validateProjectName(projectName);
|
|
480
|
-
const
|
|
481
|
-
...
|
|
937
|
+
const fs3 = deps.fs ?? {
|
|
938
|
+
...nodeFsPromises10,
|
|
482
939
|
exists: async (p) => {
|
|
483
940
|
try {
|
|
484
|
-
await
|
|
941
|
+
await nodeFsPromises10.access(p);
|
|
485
942
|
return true;
|
|
486
943
|
} catch {
|
|
487
944
|
return false;
|
|
@@ -497,6 +954,7 @@ async function runCreate(projectName, deps) {
|
|
|
497
954
|
const applyIndexHtmlFn = deps.applyIndexHtml ?? applyIndexHtml;
|
|
498
955
|
const applyRubricalConfigFn = deps.applyRubricalConfig ?? applyRubricalConfig;
|
|
499
956
|
const writeStateFn = deps.writeState ?? writeState;
|
|
957
|
+
const applyAppearanceFn = deps.applyAppearance ?? applyAppearance;
|
|
500
958
|
const execFn = deps.exec ?? (async (cmd, cwd) => {
|
|
501
959
|
const { execSync } = await import("child_process");
|
|
502
960
|
execSync(cmd, { cwd, stdio: "inherit" });
|
|
@@ -505,71 +963,36 @@ async function runCreate(projectName, deps) {
|
|
|
505
963
|
const projectDir = `${deps.projectsDir}/${projectName}`;
|
|
506
964
|
const version = await getVersion();
|
|
507
965
|
await download(projectDir, version);
|
|
508
|
-
const layout = await
|
|
509
|
-
message: "Layout",
|
|
510
|
-
options: [
|
|
511
|
-
{ value: "cyberpunk", label: "Cyberpunk", hint: "sidebar lateral com foto de perfil \u2014 dev, designer, freelancer" },
|
|
512
|
-
{ value: "brutalist", label: "Brutalism Terminal", hint: "identidade hacker total \u2014 monospace, sem bordas arredondadas" },
|
|
513
|
-
{ value: "swiss", label: "Swiss Grid", hint: "grid de 12 colunas, tipografia forte, design su\xED\xE7o rigoroso" },
|
|
514
|
-
{ value: "bento", label: "Bento", hint: "grid assim\xE9trico com floating dock \u2014 moderno, orientado a produto" },
|
|
515
|
-
{ value: "magazine", label: "Magazine", hint: "editorial cl\xE1ssico \xB7 display serifado \xB7 grid assim\xE9trico \xB7 \xE1reas de respiro generosas" }
|
|
516
|
-
]
|
|
517
|
-
});
|
|
966
|
+
const layout = await layoutPrompt();
|
|
518
967
|
await applyLayoutFn(
|
|
519
968
|
layout,
|
|
520
969
|
{ projectDir, templatesDir: `${projectDir}/templates` },
|
|
521
|
-
|
|
970
|
+
fs3
|
|
522
971
|
);
|
|
523
|
-
const themeChoice = await
|
|
524
|
-
message: "Tema visual",
|
|
525
|
-
options: [
|
|
526
|
-
{ value: "editorial-cream", label: "Editorial Cream", hint: "refinado e atemporal \u2014 blogs e portf\xF3lios liter\xE1rios" },
|
|
527
|
-
{ value: "paper-noir", label: "Paper Noir", hint: "contraste m\xE1ximo \u2014 identidade editorial forte" },
|
|
528
|
-
{ value: "midnight-blue", label: "Midnight Blue", hint: "tech e premium \u2014 devs e designers noturnos" },
|
|
529
|
-
{ value: "solar-warm", label: "Solar Warm", hint: "energia e criatividade \u2014 marcas pessoais vibrantes" }
|
|
530
|
-
]
|
|
531
|
-
});
|
|
972
|
+
const themeChoice = await schemePrompt(layout);
|
|
532
973
|
await applyThemeFn(
|
|
533
974
|
{ preset: themeChoice },
|
|
534
975
|
`${projectDir}/src/index.css`,
|
|
535
|
-
|
|
976
|
+
fs3
|
|
536
977
|
);
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
{ value: "Playfair Display", label: "Playfair Display", hint: "elegante, editorial cl\xE1ssico" },
|
|
545
|
-
{ value: "Space Grotesk", label: "Space Grotesk", hint: "moderna, startup" },
|
|
546
|
-
{ value: "DM Sans", label: "DM Sans", hint: "limpa, amig\xE1vel, vers\xE1til" },
|
|
547
|
-
{ value: "Bodoni Moda", label: "Bodoni Moda", hint: recommendedSans.includes("Bodoni Moda") ? "recomendada" : "display serifado elegante, editorial cl\xE1ssico" },
|
|
548
|
-
{ value: "IBM Plex Serif", label: "IBM Plex Serif", hint: recommendedSans.includes("IBM Plex Serif") ? "recomendada" : "serifa t\xE9cnica, confian\xE7a e rigor" },
|
|
549
|
-
{ value: "Manrope", label: "Manrope", hint: recommendedSans.includes("Manrope") ? "recomendada" : "geom\xE9trica humanista, moderna e acolhedora" },
|
|
550
|
-
{ value: "Archivo", label: "Archivo", hint: recommendedSans.includes("Archivo") ? "recomendada" : "grotesca utilit\xE1ria, clareza e for\xE7a tipogr\xE1fica" }
|
|
551
|
-
]
|
|
552
|
-
});
|
|
553
|
-
const fontMono = recommendedFonts.fontMono === "" ? "" : await select2({
|
|
554
|
-
message: "Fonte mono",
|
|
555
|
-
options: [
|
|
556
|
-
{ value: "JetBrains Mono", label: "JetBrains Mono", hint: recommendedFonts.fontMono === "JetBrains Mono" ? "recomendada" : "dev-friendly, clara" },
|
|
557
|
-
{ value: "Fira Code", label: "Fira Code", hint: "cl\xE1ssico, com ligatures" },
|
|
558
|
-
{ value: "Space Mono", label: "Space Mono", hint: "retro digital" },
|
|
559
|
-
{ value: "IBM Plex Mono", label: "IBM Plex Mono", hint: "corporativo-tech" }
|
|
560
|
-
]
|
|
561
|
-
});
|
|
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);
|
|
562
985
|
await applyFontFn(
|
|
563
986
|
{ fontSans, fontMono },
|
|
564
987
|
{ css: `${projectDir}/src/index.css`, html: `${projectDir}/index.html` },
|
|
565
|
-
|
|
988
|
+
fs3
|
|
566
989
|
);
|
|
567
990
|
const selectedPlugins = await multiselect({
|
|
568
991
|
message: "Plugins ativos",
|
|
569
992
|
options: [
|
|
570
993
|
{ value: "contact-wizard", label: "Contact Wizard \u2014 formul\xE1rio de contato multi-etapas", hint: "recomendado" },
|
|
571
994
|
{ value: "proposals", label: "Propostas \u2014 propostas comerciais com assinatura eletr\xF4nica", hint: "recomendado" },
|
|
572
|
-
{ value: "payments", label: "Pagamentos \u2014
|
|
995
|
+
{ value: "payments", label: "Pagamentos \u2014 checkout com PIX, boleto e cart\xE3o via Asaas" },
|
|
573
996
|
{ value: "blog", label: "Blog \u2014 listagem e leitura de posts", hint: "recomendado" },
|
|
574
997
|
{ value: "portfolio", label: "Portfolio \u2014 galeria de projetos", hint: "recomendado" },
|
|
575
998
|
{ value: "resume", label: "Curr\xEDculo \u2014 curr\xEDculo interativo com download de PDF", hint: "recomendado" },
|
|
@@ -590,52 +1013,32 @@ async function runCreate(projectName, deps) {
|
|
|
590
1013
|
await applyPluginsFn(
|
|
591
1014
|
pluginsRecord,
|
|
592
1015
|
`${projectDir}/convex/pluginRegistry.ts`,
|
|
593
|
-
|
|
1016
|
+
fs3
|
|
594
1017
|
);
|
|
595
1018
|
const identity = await doIdentityPrompt();
|
|
596
1019
|
await applyIndexHtmlFn(
|
|
597
|
-
|
|
598
|
-
fontFamily: fontSans,
|
|
599
|
-
themeColor: "",
|
|
600
|
-
siteName: identity.siteName,
|
|
601
|
-
siteUrl: identity.siteUrl,
|
|
602
|
-
twitterHandle: identity.twitterHandle,
|
|
603
|
-
authorName: identity.authorName
|
|
604
|
-
},
|
|
1020
|
+
indexHtmlInput(identity, fontSans, fontMono),
|
|
605
1021
|
`${projectDir}/index.html`,
|
|
606
|
-
|
|
1022
|
+
fs3
|
|
607
1023
|
);
|
|
608
1024
|
await applyRubricalConfigFn(
|
|
609
|
-
|
|
610
|
-
siteName: identity.siteName,
|
|
611
|
-
siteUrl: identity.siteUrl,
|
|
612
|
-
siteDescription: identity.siteDescription,
|
|
613
|
-
authorName: identity.authorName,
|
|
614
|
-
authorEmail: identity.authorEmail,
|
|
615
|
-
twitterHandle: identity.twitterHandle,
|
|
616
|
-
lang: identity.lang,
|
|
617
|
-
seoHomeTitle: identity.siteName,
|
|
618
|
-
seoHomeDescription: identity.siteDescription,
|
|
619
|
-
rssTitle: identity.siteName,
|
|
620
|
-
rssDescription: identity.siteDescription,
|
|
621
|
-
ogImageUrl: `${identity.siteUrl}/og.png`,
|
|
622
|
-
fontSans,
|
|
623
|
-
fontMono
|
|
624
|
-
},
|
|
1025
|
+
rubricaConfigInput(identity, fontSans, fontMono),
|
|
625
1026
|
projectDir,
|
|
626
|
-
|
|
1027
|
+
fs3
|
|
627
1028
|
);
|
|
628
1029
|
const pkgPath = `${projectDir}/package.json`;
|
|
629
|
-
const pkgRaw = await
|
|
1030
|
+
const pkgRaw = await fs3.readFile(pkgPath, "utf-8");
|
|
630
1031
|
const pkg = JSON.parse(pkgRaw);
|
|
631
1032
|
pkg.name = projectName;
|
|
632
|
-
await
|
|
1033
|
+
await fs3.writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
633
1034
|
await writeStateFn(
|
|
634
1035
|
projectDir,
|
|
635
1036
|
{
|
|
636
|
-
|
|
1037
|
+
// Versão realmente baixada: o update usa como base para preservar as personalizações.
|
|
1038
|
+
version: version.replace(/^v/, ""),
|
|
637
1039
|
layout,
|
|
638
1040
|
theme: themeChoice,
|
|
1041
|
+
...appearance,
|
|
639
1042
|
fontSans,
|
|
640
1043
|
fontMono,
|
|
641
1044
|
plugins: pluginsRecord,
|
|
@@ -649,10 +1052,10 @@ async function runCreate(projectName, deps) {
|
|
|
649
1052
|
lang: identity.lang
|
|
650
1053
|
}
|
|
651
1054
|
},
|
|
652
|
-
|
|
1055
|
+
fs3
|
|
653
1056
|
);
|
|
654
|
-
const doGitInit = await
|
|
655
|
-
const packageManager = await
|
|
1057
|
+
const doGitInit = await confirm2({ message: "Inicializar reposit\xF3rio git?" });
|
|
1058
|
+
const packageManager = await select3({
|
|
656
1059
|
message: "Gerenciador de pacotes",
|
|
657
1060
|
options: [
|
|
658
1061
|
{ value: "pnpm", label: "pnpm (recomendado)" },
|
|
@@ -666,8 +1069,8 @@ async function runCreate(projectName, deps) {
|
|
|
666
1069
|
if (packageManager !== "none") {
|
|
667
1070
|
await execFn(`${packageManager} install`, projectDir);
|
|
668
1071
|
}
|
|
669
|
-
await removeDir(`${projectDir}/templates`,
|
|
670
|
-
await removeDir(`${projectDir}/cli`,
|
|
1072
|
+
await removeDir(`${projectDir}/templates`, fs3);
|
|
1073
|
+
await removeDir(`${projectDir}/cli`, fs3);
|
|
671
1074
|
const installStep = packageManager === "none" ? "pnpm install\n " : "";
|
|
672
1075
|
outro(
|
|
673
1076
|
`Projeto criado com sucesso!
|
|
@@ -691,14 +1094,14 @@ Boa sorte! \u{1F680}`
|
|
|
691
1094
|
}
|
|
692
1095
|
|
|
693
1096
|
// src/commands/config.ts
|
|
694
|
-
import { outro as outro2,
|
|
695
|
-
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";
|
|
696
1099
|
import * as path6 from "path";
|
|
697
1100
|
|
|
698
1101
|
// src/utils/detectProject.ts
|
|
699
|
-
import * as
|
|
1102
|
+
import * as nodeFsPromises11 from "fs/promises";
|
|
700
1103
|
import * as path5 from "path";
|
|
701
|
-
async function detectProject(startDir, fsModule =
|
|
1104
|
+
async function detectProject(startDir, fsModule = nodeFsPromises11) {
|
|
702
1105
|
let current = startDir;
|
|
703
1106
|
while (true) {
|
|
704
1107
|
const candidate = path5.join(current, "rubrica.json");
|
|
@@ -718,24 +1121,18 @@ async function detectProject(startDir, fsModule = nodeFsPromises10) {
|
|
|
718
1121
|
}
|
|
719
1122
|
|
|
720
1123
|
// src/commands/config.ts
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
"playground",
|
|
731
|
-
"testimonials",
|
|
732
|
-
"testimonials-intake",
|
|
733
|
-
"contact-wizard",
|
|
734
|
-
"audit-log"
|
|
735
|
-
];
|
|
1124
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
1125
|
+
async function existsIn(fs3, p) {
|
|
1126
|
+
try {
|
|
1127
|
+
await fs3.access(p);
|
|
1128
|
+
return true;
|
|
1129
|
+
} catch {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
736
1133
|
async function runConfig(deps = {}) {
|
|
737
1134
|
const cwd = deps.cwd ?? process.cwd();
|
|
738
|
-
const
|
|
1135
|
+
const fs3 = deps.fs ?? nodeFsPromises12;
|
|
739
1136
|
const detectProjectFn = deps.detectProject ?? detectProject;
|
|
740
1137
|
const readStateFn = deps.readState ?? readState;
|
|
741
1138
|
const writeStateFn = deps.writeState ?? writeState;
|
|
@@ -746,21 +1143,24 @@ async function runConfig(deps = {}) {
|
|
|
746
1143
|
const applyIndexHtmlFn = deps.applyIndexHtml ?? applyIndexHtml;
|
|
747
1144
|
const applyLayoutFn = deps.applyLayout ?? applyLayout;
|
|
748
1145
|
const applyPluginsFn = deps.applyPlugins ?? applyPlugins;
|
|
749
|
-
const
|
|
1146
|
+
const downloadReleaseFn = deps.downloadRelease ?? downloadRelease;
|
|
1147
|
+
const getLatestVersionFn = deps.getLatestVersion ?? getLatestVersion;
|
|
1148
|
+
const applyAppearanceFn = deps.applyAppearance ?? applyAppearance;
|
|
1149
|
+
const rubricaJsonPath = await detectProjectFn(cwd, fs3);
|
|
750
1150
|
const projectDir = path6.dirname(rubricaJsonPath);
|
|
751
|
-
const currentState = await readStateFn(projectDir,
|
|
1151
|
+
const currentState = await readStateFn(projectDir, fs3);
|
|
752
1152
|
const stateUpdate = {};
|
|
753
1153
|
const sections = await multiselect2({
|
|
754
1154
|
message: "O que deseja reconfigurar?",
|
|
755
1155
|
options: [
|
|
756
1156
|
{ value: "identity", label: "Identidade (nome, URL, SEO, RSS)" },
|
|
757
|
-
{ value: "appearance", label: "Apar\xEAncia (
|
|
1157
|
+
{ value: "appearance", label: "Apar\xEAncia (esquema de cores, modo claro/escuro, textura, fontes)" },
|
|
758
1158
|
{ value: "layout", label: "Layout" },
|
|
759
1159
|
{ value: "plugins", label: "Plugins" }
|
|
760
1160
|
],
|
|
761
1161
|
required: false
|
|
762
1162
|
});
|
|
763
|
-
if (
|
|
1163
|
+
if (isCancel4(sections)) {
|
|
764
1164
|
cancel3("Opera\xE7\xE3o cancelada.");
|
|
765
1165
|
return;
|
|
766
1166
|
}
|
|
@@ -768,103 +1168,87 @@ async function runConfig(deps = {}) {
|
|
|
768
1168
|
if (selected.includes("identity")) {
|
|
769
1169
|
const identityData = await doIdentityPrompt();
|
|
770
1170
|
await applyRubricalConfigFn(
|
|
771
|
-
|
|
772
|
-
siteName: identityData.siteName,
|
|
773
|
-
siteUrl: identityData.siteUrl,
|
|
774
|
-
siteDescription: identityData.siteDescription,
|
|
775
|
-
authorName: identityData.authorName,
|
|
776
|
-
authorEmail: identityData.authorEmail,
|
|
777
|
-
twitterHandle: identityData.twitterHandle,
|
|
778
|
-
lang: identityData.lang,
|
|
779
|
-
seoHomeTitle: "",
|
|
780
|
-
seoHomeDescription: "",
|
|
781
|
-
rssTitle: "",
|
|
782
|
-
rssDescription: "",
|
|
783
|
-
ogImageUrl: "",
|
|
784
|
-
fontSans: currentState.fontSans,
|
|
785
|
-
fontMono: currentState.fontMono
|
|
786
|
-
},
|
|
1171
|
+
rubricaConfigInput(identityData, currentState.fontSans, currentState.fontMono),
|
|
787
1172
|
projectDir,
|
|
788
|
-
|
|
1173
|
+
fs3
|
|
789
1174
|
);
|
|
1175
|
+
await applyIndexHtmlFn(
|
|
1176
|
+
indexHtmlInput(identityData, currentState.fontSans, currentState.fontMono),
|
|
1177
|
+
path6.join(projectDir, "index.html"),
|
|
1178
|
+
fs3
|
|
1179
|
+
);
|
|
1180
|
+
stateUpdate.identity = identityData;
|
|
790
1181
|
}
|
|
791
1182
|
if (selected.includes("appearance")) {
|
|
792
|
-
const theme = await
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
{ value: "paper-noir", label: "Paper Noir", hint: "contraste m\xE1ximo \u2014 identidade editorial forte" },
|
|
798
|
-
{ value: "midnight-blue", label: "Midnight Blue", hint: "tech e premium \u2014 devs e designers noturnos" },
|
|
799
|
-
{ value: "solar-warm", label: "Solar Warm", hint: "energia e criatividade \u2014 marcas pessoais vibrantes" }
|
|
800
|
-
]
|
|
801
|
-
});
|
|
802
|
-
const fontSans = await select3({
|
|
803
|
-
message: "Fonte principal",
|
|
804
|
-
initialValue: currentState.fontSans,
|
|
805
|
-
options: [
|
|
806
|
-
{ value: "Inter", label: "Inter", hint: "neutra, leg\xEDvel, padr\xE3o de produtos digitais" },
|
|
807
|
-
{ value: "Chakra Petch", label: "Chakra Petch", hint: "geom\xE9trica, tech, futurista" },
|
|
808
|
-
{ value: "Playfair Display", label: "Playfair Display", hint: "elegante, editorial cl\xE1ssico" },
|
|
809
|
-
{ value: "Space Grotesk", label: "Space Grotesk", hint: "moderna, startup" },
|
|
810
|
-
{ value: "DM Sans", label: "DM Sans", hint: "limpa, amig\xE1vel, vers\xE1til" },
|
|
811
|
-
{ value: "Bodoni Moda", label: "Bodoni Moda", hint: "display serifado elegante, editorial cl\xE1ssico" },
|
|
812
|
-
{ value: "IBM Plex Serif", label: "IBM Plex Serif", hint: "serifa t\xE9cnica, confian\xE7a e rigor" },
|
|
813
|
-
{ value: "Manrope", label: "Manrope", hint: "geom\xE9trica humanista, moderna e acolhedora" },
|
|
814
|
-
{ value: "Archivo", label: "Archivo", hint: "grotesca utilit\xE1ria, clareza e for\xE7a tipogr\xE1fica" }
|
|
815
|
-
]
|
|
816
|
-
});
|
|
817
|
-
const fontMono = await select3({
|
|
818
|
-
message: "Fonte mono",
|
|
819
|
-
initialValue: currentState.fontMono,
|
|
820
|
-
options: [
|
|
821
|
-
{ value: "JetBrains Mono", label: "JetBrains Mono", hint: "dev-friendly, clara" },
|
|
822
|
-
{ value: "Fira Code", label: "Fira Code", hint: "cl\xE1ssico, com ligatures" },
|
|
823
|
-
{ value: "Space Mono", label: "Space Mono", hint: "retro digital" },
|
|
824
|
-
{ value: "IBM Plex Mono", label: "IBM Plex Mono", hint: "corporativo-tech" }
|
|
825
|
-
]
|
|
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
|
|
826
1188
|
});
|
|
1189
|
+
const { fontSans, fontMono } = await fontPrompts(currentState.layout, currentState);
|
|
827
1190
|
const cssPath = path6.join(projectDir, "src", "index.css");
|
|
828
1191
|
const htmlPath = path6.join(projectDir, "index.html");
|
|
829
1192
|
await applyThemeFn(
|
|
830
1193
|
{ preset: theme },
|
|
831
1194
|
cssPath,
|
|
832
|
-
|
|
1195
|
+
fs3
|
|
833
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
|
+
}
|
|
834
1204
|
await applyFontFn(
|
|
835
1205
|
{ fontSans, fontMono },
|
|
836
1206
|
{ css: cssPath, html: htmlPath },
|
|
837
|
-
|
|
838
|
-
);
|
|
839
|
-
await applyIndexHtmlFn(
|
|
840
|
-
{ fontFamily: fontSans, themeColor: "", siteName: "", siteUrl: "", twitterHandle: "", authorName: "" },
|
|
841
|
-
htmlPath,
|
|
842
|
-
fs
|
|
1207
|
+
fs3
|
|
843
1208
|
);
|
|
1209
|
+
const identity = stateUpdate.identity ?? currentState.identity;
|
|
1210
|
+
if (identity) {
|
|
1211
|
+
await applyIndexHtmlFn(
|
|
1212
|
+
indexHtmlInput(identity, fontSans, fontMono),
|
|
1213
|
+
htmlPath,
|
|
1214
|
+
fs3
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
844
1217
|
stateUpdate.theme = theme;
|
|
1218
|
+
Object.assign(stateUpdate, appearance);
|
|
845
1219
|
stateUpdate.fontSans = fontSans;
|
|
846
1220
|
stateUpdate.fontMono = fontMono;
|
|
847
1221
|
}
|
|
848
1222
|
if (selected.includes("layout")) {
|
|
849
|
-
const newLayout = await
|
|
850
|
-
|
|
851
|
-
initialValue: currentState.layout,
|
|
852
|
-
options: [
|
|
853
|
-
{ value: "cyberpunk", label: "Cyberpunk", hint: "sidebar lateral com foto de perfil \u2014 dev, designer, freelancer" },
|
|
854
|
-
{ value: "brutalist", label: "Brutalism Terminal", hint: "identidade hacker total \u2014 monospace, sem bordas arredondadas" },
|
|
855
|
-
{ value: "swiss", label: "Swiss Grid", hint: "grid de 12 colunas, tipografia forte, design su\xED\xE7o rigoroso" },
|
|
856
|
-
{ value: "bento", label: "Bento", hint: "grid assim\xE9trico com floating dock \u2014 moderno, orientado a produto" }
|
|
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 (!
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1227
|
+
if (!isCancel4(confirmed) && confirmed === true) {
|
|
1228
|
+
let templatesDir = path6.join(projectDir, "templates");
|
|
1229
|
+
let tmpDir;
|
|
1230
|
+
if (!await existsIn(fs3, templatesDir)) {
|
|
1231
|
+
tmpDir = await nodeFsPromises12.mkdtemp(path6.join(tmpdir2(), "rubrica-config-"));
|
|
1232
|
+
const version = currentState.version === "0.1.0" ? await getLatestVersionFn() : currentState.version;
|
|
1233
|
+
await downloadReleaseFn(tmpDir, version.startsWith("v") ? version : `v${version}`);
|
|
1234
|
+
templatesDir = path6.join(tmpDir, "templates");
|
|
1235
|
+
}
|
|
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
|
+
}
|
|
1244
|
+
await applyLayoutFn(
|
|
1245
|
+
newLayout,
|
|
1246
|
+
{ projectDir, templatesDir },
|
|
1247
|
+
{ ...fs3, copyFile: nodeFsPromises12.copyFile, unlink: nodeFsPromises12.unlink, exists: (p) => existsIn(fs3, p) }
|
|
1248
|
+
);
|
|
1249
|
+
} finally {
|
|
1250
|
+
if (tmpDir) await nodeFsPromises12.rm(tmpDir, { recursive: true, force: true });
|
|
1251
|
+
}
|
|
868
1252
|
stateUpdate.layout = newLayout;
|
|
869
1253
|
}
|
|
870
1254
|
}
|
|
@@ -873,32 +1257,267 @@ async function runConfig(deps = {}) {
|
|
|
873
1257
|
const selectedPlugins = await multiselect2({
|
|
874
1258
|
message: "Plugins ativos",
|
|
875
1259
|
initialValues: activePlugins,
|
|
876
|
-
options:
|
|
1260
|
+
options: ALL_PLUGINS.map((p) => ({ value: p, label: p })),
|
|
877
1261
|
required: false
|
|
878
1262
|
});
|
|
879
|
-
if (!
|
|
1263
|
+
if (!isCancel4(selectedPlugins)) {
|
|
880
1264
|
const pluginsMap = {};
|
|
881
|
-
for (const p of
|
|
1265
|
+
for (const p of ALL_PLUGINS) {
|
|
882
1266
|
pluginsMap[p] = selectedPlugins.includes(p);
|
|
883
1267
|
}
|
|
884
1268
|
await applyPluginsFn(
|
|
885
1269
|
pluginsMap,
|
|
886
1270
|
path6.join(projectDir, "convex", "pluginRegistry.ts"),
|
|
887
|
-
|
|
1271
|
+
fs3
|
|
888
1272
|
);
|
|
889
1273
|
stateUpdate.plugins = pluginsMap;
|
|
890
1274
|
}
|
|
891
1275
|
}
|
|
892
1276
|
if (Object.keys(stateUpdate).length > 0) {
|
|
893
|
-
await writeStateFn(projectDir, stateUpdate,
|
|
1277
|
+
await writeStateFn(projectDir, stateUpdate, fs3);
|
|
894
1278
|
}
|
|
895
1279
|
outro2("Configura\xE7\xE3o atualizada com sucesso!");
|
|
896
1280
|
}
|
|
897
1281
|
|
|
898
1282
|
// src/commands/update.ts
|
|
899
|
-
import { intro as intro2, outro as outro3, confirm as
|
|
900
|
-
import * 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";
|
|
1284
|
+
import * as fs2 from "fs/promises";
|
|
1285
|
+
import * as path9 from "path";
|
|
1286
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
1287
|
+
import { execFile as execFile3 } from "child_process";
|
|
1288
|
+
import { promisify as promisify3 } from "util";
|
|
1289
|
+
|
|
1290
|
+
// src/utils/pristine.ts
|
|
1291
|
+
import * as nodeFsPromises13 from "fs/promises";
|
|
901
1292
|
import * as path7 from "path";
|
|
1293
|
+
var fsForTransforms = {
|
|
1294
|
+
...nodeFsPromises13,
|
|
1295
|
+
exists: async (p) => {
|
|
1296
|
+
try {
|
|
1297
|
+
await nodeFsPromises13.access(p);
|
|
1298
|
+
return true;
|
|
1299
|
+
} catch {
|
|
1300
|
+
return false;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
async function buildPristine(options) {
|
|
1305
|
+
const { dir, state } = options;
|
|
1306
|
+
const download = options.download ?? downloadRelease;
|
|
1307
|
+
const tag = options.version.startsWith("v") ? options.version : `v${options.version}`;
|
|
1308
|
+
const fs3 = fsForTransforms;
|
|
1309
|
+
await download(dir, tag);
|
|
1310
|
+
await applyLayout(state.layout, { projectDir: dir, templatesDir: path7.join(dir, "templates") }, fs3);
|
|
1311
|
+
const cssPath = path7.join(dir, "src", "index.css");
|
|
1312
|
+
const htmlPath = path7.join(dir, "index.html");
|
|
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
|
+
}
|
|
1321
|
+
await applyFont({ fontSans: state.fontSans, fontMono: state.fontMono }, { css: cssPath, html: htmlPath }, fs3);
|
|
1322
|
+
const registryPath = path7.join(dir, "convex", "pluginRegistry.ts");
|
|
1323
|
+
const knownPlugins = await knownPluginIds(registryPath);
|
|
1324
|
+
const plugins = Object.fromEntries(
|
|
1325
|
+
Object.entries(state.plugins ?? {}).filter(([id]) => knownPlugins.has(id))
|
|
1326
|
+
);
|
|
1327
|
+
await applyPlugins(plugins, registryPath, fs3);
|
|
1328
|
+
const identity = state.identity;
|
|
1329
|
+
if (identity) {
|
|
1330
|
+
await applyIndexHtml(indexHtmlInput(identity, state.fontSans, state.fontMono), htmlPath, fs3);
|
|
1331
|
+
await applyRubricalConfig(rubricaConfigInput(identity, state.fontSans, state.fontMono), dir, fs3);
|
|
1332
|
+
}
|
|
1333
|
+
if (options.packageName) {
|
|
1334
|
+
const pkgPath = path7.join(dir, "package.json");
|
|
1335
|
+
const pkg = JSON.parse(await nodeFsPromises13.readFile(pkgPath, "utf-8"));
|
|
1336
|
+
pkg.name = options.packageName;
|
|
1337
|
+
await nodeFsPromises13.writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
1338
|
+
}
|
|
1339
|
+
await nodeFsPromises13.rm(path7.join(dir, "templates"), { recursive: true, force: true });
|
|
1340
|
+
await nodeFsPromises13.rm(path7.join(dir, "cli"), { recursive: true, force: true });
|
|
1341
|
+
}
|
|
1342
|
+
async function knownPluginIds(registryPath) {
|
|
1343
|
+
try {
|
|
1344
|
+
const content = await nodeFsPromises13.readFile(registryPath, "utf-8");
|
|
1345
|
+
return new Set([...content.matchAll(/id: '([^']+)'/g)].map((m) => m[1]));
|
|
1346
|
+
} catch {
|
|
1347
|
+
return /* @__PURE__ */ new Set();
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
// src/utils/threeWayUpdate.ts
|
|
1352
|
+
import * as fs from "fs/promises";
|
|
1353
|
+
import * as path8 from "path";
|
|
1354
|
+
import { execFile as execFile2 } from "child_process";
|
|
1355
|
+
import { promisify as promisify2 } from "util";
|
|
1356
|
+
var execFileAsync2 = promisify2(execFile2);
|
|
1357
|
+
var PROTECTED = [
|
|
1358
|
+
/^\.git\//,
|
|
1359
|
+
/(^|\/)node_modules\//,
|
|
1360
|
+
/^dist\//,
|
|
1361
|
+
/^\.env(\..*)?$/,
|
|
1362
|
+
/^rubrica\.json$/,
|
|
1363
|
+
// Conteúdo gerado a partir do banco do usuário no build.
|
|
1364
|
+
/^public\/data\//,
|
|
1365
|
+
/^public\/rss\.xml$/,
|
|
1366
|
+
/^public\/sitemap\.xml$/
|
|
1367
|
+
];
|
|
1368
|
+
var LOCKFILES = /* @__PURE__ */ new Set(["package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb"]);
|
|
1369
|
+
var NEW_SUFFIX = ".rubrica-new";
|
|
1370
|
+
function isProtected(file) {
|
|
1371
|
+
return PROTECTED.some((re) => re.test(file));
|
|
1372
|
+
}
|
|
1373
|
+
async function listFiles(root) {
|
|
1374
|
+
const out = [];
|
|
1375
|
+
async function walk(dir) {
|
|
1376
|
+
let entries;
|
|
1377
|
+
try {
|
|
1378
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
1379
|
+
} catch {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
for (const entry of entries) {
|
|
1383
|
+
const abs = path8.join(dir, entry.name);
|
|
1384
|
+
const rel = path8.relative(root, abs).split(path8.sep).join("/");
|
|
1385
|
+
if (entry.isDirectory()) {
|
|
1386
|
+
if (!isProtected(`${rel}/`)) await walk(abs);
|
|
1387
|
+
} else if (entry.isFile() && !isProtected(rel)) {
|
|
1388
|
+
out.push(rel);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
await walk(root);
|
|
1393
|
+
return out;
|
|
1394
|
+
}
|
|
1395
|
+
async function readOrNull(file) {
|
|
1396
|
+
try {
|
|
1397
|
+
return await fs.readFile(file);
|
|
1398
|
+
} catch {
|
|
1399
|
+
return null;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
function same(a, b) {
|
|
1403
|
+
if (a === null || b === null) return a === b;
|
|
1404
|
+
return a.equals(b);
|
|
1405
|
+
}
|
|
1406
|
+
function isBinary(buf) {
|
|
1407
|
+
return buf.subarray(0, 8e3).includes(0);
|
|
1408
|
+
}
|
|
1409
|
+
async function mergeText(ours, base, theirs, tmpDir) {
|
|
1410
|
+
const o = path8.join(tmpDir, "ours");
|
|
1411
|
+
const b = path8.join(tmpDir, "base");
|
|
1412
|
+
const t = path8.join(tmpDir, "theirs");
|
|
1413
|
+
await fs.writeFile(o, ours);
|
|
1414
|
+
await fs.writeFile(b, base);
|
|
1415
|
+
await fs.writeFile(t, theirs);
|
|
1416
|
+
try {
|
|
1417
|
+
const { stdout } = await execFileAsync2("git", ["merge-file", "-p", o, b, t], {
|
|
1418
|
+
encoding: "buffer",
|
|
1419
|
+
maxBuffer: 64 * 1024 * 1024
|
|
1420
|
+
});
|
|
1421
|
+
return stdout;
|
|
1422
|
+
} catch (err) {
|
|
1423
|
+
const code = err.code;
|
|
1424
|
+
if (typeof code === "number" && code > 0) return null;
|
|
1425
|
+
throw err;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
async function planUpdate(dirs) {
|
|
1429
|
+
const files = /* @__PURE__ */ new Set([...await listFiles(dirs.base), ...await listFiles(dirs.next)]);
|
|
1430
|
+
const tmpDir = await fs.mkdtemp(path8.join(path8.dirname(dirs.base), "merge-"));
|
|
1431
|
+
const actions = [];
|
|
1432
|
+
try {
|
|
1433
|
+
for (const file of [...files].sort()) {
|
|
1434
|
+
const base = await readOrNull(path8.join(dirs.base, file));
|
|
1435
|
+
const next = await readOrNull(path8.join(dirs.next, file));
|
|
1436
|
+
const ours = await readOrNull(path8.join(dirs.project, file));
|
|
1437
|
+
if (same(base, next) || same(ours, next)) continue;
|
|
1438
|
+
if (same(ours, base)) {
|
|
1439
|
+
if (next === null) actions.push({ file, kind: "remove" });
|
|
1440
|
+
else actions.push({ file, kind: base === null ? "add" : "update", content: next });
|
|
1441
|
+
continue;
|
|
1442
|
+
}
|
|
1443
|
+
if (ours === null) {
|
|
1444
|
+
actions.push({
|
|
1445
|
+
file,
|
|
1446
|
+
kind: "conflict",
|
|
1447
|
+
incoming: next ?? void 0,
|
|
1448
|
+
reason: "voc\xEA removeu este arquivo, mas o Rubrica o alterou"
|
|
1449
|
+
});
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
if (next === null) {
|
|
1453
|
+
actions.push({ file, kind: "keep", reason: "removido no Rubrica, mas voc\xEA o personalizou" });
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
if (LOCKFILES.has(path8.basename(file))) {
|
|
1457
|
+
actions.push({ file, kind: "lockfile", reason: "rode o install para atualizar as depend\xEAncias" });
|
|
1458
|
+
continue;
|
|
1459
|
+
}
|
|
1460
|
+
if (base === null) {
|
|
1461
|
+
actions.push({ file, kind: "conflict", incoming: next, reason: "voc\xEA criou um arquivo com o mesmo nome de um arquivo novo do Rubrica" });
|
|
1462
|
+
continue;
|
|
1463
|
+
}
|
|
1464
|
+
if (isBinary(ours) || isBinary(base) || isBinary(next)) {
|
|
1465
|
+
actions.push({ file, kind: "conflict", incoming: next, reason: "arquivo bin\xE1rio alterado dos dois lados" });
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
const merged = await mergeText(ours, base, next, tmpDir);
|
|
1469
|
+
if (merged) actions.push({ file, kind: "merge", content: merged });
|
|
1470
|
+
else actions.push({ file, kind: "conflict", incoming: next, reason: "voc\xEA e o Rubrica mudaram o mesmo trecho" });
|
|
1471
|
+
}
|
|
1472
|
+
} finally {
|
|
1473
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
1474
|
+
}
|
|
1475
|
+
return actions;
|
|
1476
|
+
}
|
|
1477
|
+
async function applyPlan(projectDir, actions) {
|
|
1478
|
+
for (const action of actions) {
|
|
1479
|
+
const target = path8.join(projectDir, action.file);
|
|
1480
|
+
switch (action.kind) {
|
|
1481
|
+
case "update":
|
|
1482
|
+
case "add":
|
|
1483
|
+
case "merge":
|
|
1484
|
+
await fs.mkdir(path8.dirname(target), { recursive: true });
|
|
1485
|
+
await fs.writeFile(target, action.content);
|
|
1486
|
+
break;
|
|
1487
|
+
case "remove":
|
|
1488
|
+
await fs.rm(target, { force: true });
|
|
1489
|
+
break;
|
|
1490
|
+
case "conflict":
|
|
1491
|
+
if (action.incoming) {
|
|
1492
|
+
await fs.mkdir(path8.dirname(target), { recursive: true });
|
|
1493
|
+
await fs.writeFile(`${target}${NEW_SUFFIX}`, action.incoming);
|
|
1494
|
+
}
|
|
1495
|
+
break;
|
|
1496
|
+
case "keep":
|
|
1497
|
+
case "lockfile":
|
|
1498
|
+
break;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
function formatPlan(actions) {
|
|
1503
|
+
const groups = [
|
|
1504
|
+
["update", "Atualizados"],
|
|
1505
|
+
["add", "Novos"],
|
|
1506
|
+
["remove", "Removidos"],
|
|
1507
|
+
["merge", "Mesclados com suas mudan\xE7as"],
|
|
1508
|
+
["keep", "Mantidos como voc\xEA deixou"],
|
|
1509
|
+
["lockfile", "Lockfile mantido"],
|
|
1510
|
+
["conflict", `Precisam da sua revis\xE3o (vers\xE3o nova salva em <arquivo>${NEW_SUFFIX})`]
|
|
1511
|
+
];
|
|
1512
|
+
const lines = [];
|
|
1513
|
+
for (const [kind, title] of groups) {
|
|
1514
|
+
const items = actions.filter((a) => a.kind === kind);
|
|
1515
|
+
if (!items.length) continue;
|
|
1516
|
+
lines.push(`${title} (${items.length}):`);
|
|
1517
|
+
for (const a of items) lines.push(` \u2022 ${a.file}${a.reason ? ` \u2014 ${a.reason}` : ""}`);
|
|
1518
|
+
}
|
|
1519
|
+
return lines.length ? lines.join("\n") : "Nenhum arquivo muda.";
|
|
1520
|
+
}
|
|
902
1521
|
|
|
903
1522
|
// src/utils/checkRequiredEnv.ts
|
|
904
1523
|
function parseEnvKeys(content) {
|
|
@@ -913,173 +1532,172 @@ function parseEnvKeys(content) {
|
|
|
913
1532
|
}
|
|
914
1533
|
return keys;
|
|
915
1534
|
}
|
|
916
|
-
async function readEnvKeys(filePath,
|
|
1535
|
+
async function readEnvKeys(filePath, fs3) {
|
|
917
1536
|
try {
|
|
918
|
-
const content = await
|
|
1537
|
+
const content = await fs3.readFile(filePath, "utf-8");
|
|
919
1538
|
return parseEnvKeys(content);
|
|
920
1539
|
} catch {
|
|
921
1540
|
return /* @__PURE__ */ new Set();
|
|
922
1541
|
}
|
|
923
1542
|
}
|
|
924
|
-
async function checkRequiredEnv(projectDir,
|
|
1543
|
+
async function checkRequiredEnv(projectDir, fs3) {
|
|
925
1544
|
let required = [];
|
|
926
1545
|
try {
|
|
927
|
-
const raw = await
|
|
1546
|
+
const raw = await fs3.readFile(`${projectDir}/required-env.json`, "utf-8");
|
|
928
1547
|
required = JSON.parse(raw);
|
|
929
1548
|
} catch {
|
|
930
1549
|
return [];
|
|
931
1550
|
}
|
|
932
1551
|
if (!required.length) return [];
|
|
933
|
-
const envKeys = await readEnvKeys(`${projectDir}/.env`,
|
|
934
|
-
const envLocalKeys = await readEnvKeys(`${projectDir}/.env.local`,
|
|
1552
|
+
const envKeys = await readEnvKeys(`${projectDir}/.env`, fs3);
|
|
1553
|
+
const envLocalKeys = await readEnvKeys(`${projectDir}/.env.local`, fs3);
|
|
935
1554
|
const allKeys = /* @__PURE__ */ new Set([...envKeys, ...envLocalKeys]);
|
|
936
1555
|
return required.filter((v) => !allKeys.has(v.name));
|
|
937
1556
|
}
|
|
938
1557
|
|
|
939
1558
|
// src/commands/update.ts
|
|
1559
|
+
var execFileAsync3 = promisify3(execFile3);
|
|
1560
|
+
var LEGACY_PLACEHOLDER_VERSION = "0.1.0";
|
|
1561
|
+
function normalizeVersion(version) {
|
|
1562
|
+
return version.trim().replace(/^v/, "");
|
|
1563
|
+
}
|
|
940
1564
|
function parseMajor(version) {
|
|
941
|
-
const
|
|
942
|
-
const major = parseInt(clean.split(".")[0] ?? "0", 10);
|
|
1565
|
+
const major = parseInt(normalizeVersion(version).split(".")[0] ?? "0", 10);
|
|
943
1566
|
return isNaN(major) ? 0 : major;
|
|
944
1567
|
}
|
|
945
|
-
function
|
|
946
|
-
|
|
1568
|
+
async function gitStatus(projectDir) {
|
|
1569
|
+
try {
|
|
1570
|
+
const { stdout } = await execFileAsync3("git", ["status", "--porcelain"], { cwd: projectDir });
|
|
1571
|
+
return stdout.trim();
|
|
1572
|
+
} catch {
|
|
1573
|
+
return null;
|
|
1574
|
+
}
|
|
947
1575
|
}
|
|
948
1576
|
async function runUpdate(deps = {}) {
|
|
949
1577
|
const cwd = deps.cwd ?? process.cwd();
|
|
950
|
-
const
|
|
951
|
-
...nodeFsPromises12,
|
|
952
|
-
exists: async (p) => {
|
|
953
|
-
try {
|
|
954
|
-
await nodeFsPromises12.access(p);
|
|
955
|
-
return true;
|
|
956
|
-
} catch {
|
|
957
|
-
return false;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
const detectProjectFn = deps.detectProject ?? detectProject;
|
|
962
|
-
const readStateFn = deps.readState ?? readState;
|
|
963
|
-
const writeStateFn = deps.writeState ?? writeState;
|
|
1578
|
+
const opts = deps.options ?? {};
|
|
964
1579
|
const getLatestVersionFn = deps.getLatestVersion ?? getLatestVersion;
|
|
965
|
-
const
|
|
966
|
-
const applyLayoutFn = deps.applyLayout ?? applyLayout;
|
|
967
|
-
const applyThemeFn = deps.applyTheme ?? applyTheme;
|
|
968
|
-
const applyFontFn = deps.applyFont ?? applyFont;
|
|
969
|
-
const applyPluginsFn = deps.applyPlugins ?? applyPlugins;
|
|
970
|
-
const applyIndexHtmlFn = deps.applyIndexHtml ?? applyIndexHtml;
|
|
971
|
-
const applyRubricalConfigFn = deps.applyRubricalConfig ?? applyRubricalConfig;
|
|
1580
|
+
const download = deps.downloadRelease ?? downloadRelease;
|
|
972
1581
|
const checkRequiredEnvFn = deps.checkRequiredEnv ?? checkRequiredEnv;
|
|
973
|
-
const
|
|
974
|
-
const { execSync } = await import("child_process");
|
|
975
|
-
execSync(cmd, { cwd: cwd2, stdio: "inherit" });
|
|
976
|
-
});
|
|
1582
|
+
const ask = !opts.yes;
|
|
977
1583
|
intro2("Rubrica Update");
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
const remoteVersion = normalizeVersion(await getLatestVersionFn());
|
|
983
|
-
if (localVersion === remoteVersion) {
|
|
984
|
-
outro3(`J\xE1 est\xE1 na vers\xE3o mais recente (${localVersion}). Nenhuma atualiza\xE7\xE3o necess\xE1ria.`);
|
|
1584
|
+
try {
|
|
1585
|
+
await execFileAsync3("git", ["--version"]);
|
|
1586
|
+
} catch {
|
|
1587
|
+
cancel4("O update precisa do git instalado (ele \xE9 usado para mesclar suas mudan\xE7as com a vers\xE3o nova).");
|
|
985
1588
|
return;
|
|
986
1589
|
}
|
|
987
|
-
const
|
|
988
|
-
const
|
|
989
|
-
|
|
1590
|
+
const projectDir = path9.dirname(await detectProject(cwd));
|
|
1591
|
+
const state = await readState(projectDir);
|
|
1592
|
+
let fromVersion = normalizeVersion(opts.from ?? state.version);
|
|
1593
|
+
if (!opts.from && fromVersion === LEGACY_PLACEHOLDER_VERSION) {
|
|
990
1594
|
log2.warn(
|
|
991
|
-
`
|
|
992
|
-
|
|
993
|
-
Consulte o guia de migra\xE7\xE3o antes de prosseguir.`
|
|
1595
|
+
`O rubrica.json diz ${LEGACY_PLACEHOLDER_VERSION}, mas vers\xF5es antigas do CLI sempre gravavam esse n\xFAmero.
|
|
1596
|
+
Para preservar suas personaliza\xE7\xF5es, o update precisa saber com qual vers\xE3o o projeto foi criado (veja a data de cria\xE7\xE3o e compare com https://github.com/MierzwaMatheus/rubrica/releases).`
|
|
994
1597
|
);
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
});
|
|
998
|
-
if (isCancel4(majorConfirmed) || !majorConfirmed) {
|
|
999
|
-
cancel4("Atualiza\xE7\xE3o cancelada.");
|
|
1598
|
+
if (!ask) {
|
|
1599
|
+
cancel4("Informe a vers\xE3o de origem com --from <vers\xE3o>.");
|
|
1000
1600
|
return;
|
|
1001
1601
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1602
|
+
const answer = await text2({
|
|
1603
|
+
message: "Com qual vers\xE3o o projeto foi criado?",
|
|
1604
|
+
placeholder: "ex.: 0.3.12",
|
|
1605
|
+
validate: (v) => /^v?\d+\.\d+\.\d+$/.test(v.trim()) ? void 0 : "Use o formato 0.3.12"
|
|
1006
1606
|
});
|
|
1007
|
-
if (
|
|
1607
|
+
if (isCancel5(answer)) {
|
|
1008
1608
|
cancel4("Atualiza\xE7\xE3o cancelada.");
|
|
1009
1609
|
return;
|
|
1010
1610
|
}
|
|
1611
|
+
fromVersion = normalizeVersion(answer);
|
|
1011
1612
|
}
|
|
1012
|
-
await
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
)
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
);
|
|
1027
|
-
const registryPath = path7.join(projectDir, "convex", "pluginRegistry.ts");
|
|
1028
|
-
await applyPluginsFn(
|
|
1029
|
-
state.plugins,
|
|
1030
|
-
registryPath,
|
|
1031
|
-
fs
|
|
1032
|
-
);
|
|
1033
|
-
const identity = {
|
|
1034
|
-
siteName: "",
|
|
1035
|
-
siteUrl: "",
|
|
1036
|
-
siteDescription: "",
|
|
1037
|
-
authorName: "",
|
|
1038
|
-
authorEmail: "",
|
|
1039
|
-
twitterHandle: "",
|
|
1040
|
-
lang: "pt-BR",
|
|
1041
|
-
seoHomeTitle: "",
|
|
1042
|
-
seoHomeDescription: "",
|
|
1043
|
-
rssTitle: "",
|
|
1044
|
-
rssDescription: "",
|
|
1045
|
-
ogImageUrl: "",
|
|
1046
|
-
fontSans: state.fontSans,
|
|
1047
|
-
fontMono: state.fontMono
|
|
1048
|
-
};
|
|
1049
|
-
await applyIndexHtmlFn(
|
|
1050
|
-
{
|
|
1051
|
-
fontFamily: identity.fontSans,
|
|
1052
|
-
themeColor: "",
|
|
1053
|
-
siteName: identity.siteName,
|
|
1054
|
-
siteUrl: identity.siteUrl,
|
|
1055
|
-
twitterHandle: identity.twitterHandle,
|
|
1056
|
-
authorName: identity.authorName
|
|
1057
|
-
},
|
|
1058
|
-
htmlPath,
|
|
1059
|
-
fs
|
|
1060
|
-
);
|
|
1061
|
-
await applyRubricalConfigFn(
|
|
1062
|
-
identity,
|
|
1063
|
-
projectDir,
|
|
1064
|
-
fs
|
|
1065
|
-
);
|
|
1066
|
-
await writeStateFn(projectDir, { version: remoteVersion }, fs);
|
|
1067
|
-
const missingVars = await checkRequiredEnvFn(projectDir, fs);
|
|
1068
|
-
if (missingVars.length > 0) {
|
|
1069
|
-
const varList = missingVars.map((v) => ` \u2022 ${v.name} \u2014 ${v.description}`).join("\n");
|
|
1613
|
+
const toVersion = normalizeVersion(opts.to ?? await getLatestVersionFn());
|
|
1614
|
+
if (fromVersion === toVersion) {
|
|
1615
|
+
outro3(`J\xE1 est\xE1 na vers\xE3o mais recente (${toVersion}).`);
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
const status = await gitStatus(projectDir);
|
|
1619
|
+
if (!opts.dryRun) {
|
|
1620
|
+
if (status === null) {
|
|
1621
|
+
log2.warn("Este projeto n\xE3o est\xE1 num reposit\xF3rio git. Recomendado: fa\xE7a um backup antes, para poder desfazer.");
|
|
1622
|
+
} else if (status !== "") {
|
|
1623
|
+
log2.warn("H\xE1 mudan\xE7as n\xE3o commitadas. Recomendado: fa\xE7a commit antes, para poder desfazer o update com o git.");
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
if (parseMajor(toVersion) > parseMajor(fromVersion)) {
|
|
1070
1627
|
log2.warn(
|
|
1071
|
-
`
|
|
1072
|
-
|
|
1073
|
-
Configure-as em: https://dashboard.convex.dev`
|
|
1628
|
+
`Atualiza\xE7\xE3o de vers\xE3o major: ${fromVersion} \u2192 ${toVersion}.
|
|
1629
|
+
Leia o guia de atualiza\xE7\xE3o nas notas da release antes de publicar.`
|
|
1074
1630
|
);
|
|
1075
1631
|
}
|
|
1076
|
-
|
|
1632
|
+
const workDir = await fs2.mkdtemp(path9.join(tmpdir3(), "rubrica-update-"));
|
|
1633
|
+
const baseDir = path9.join(workDir, "base");
|
|
1634
|
+
const nextDir = path9.join(workDir, "next");
|
|
1635
|
+
let packageName;
|
|
1636
|
+
try {
|
|
1637
|
+
packageName = JSON.parse(await fs2.readFile(path9.join(projectDir, "package.json"), "utf-8")).name;
|
|
1638
|
+
} catch {
|
|
1639
|
+
packageName = void 0;
|
|
1640
|
+
}
|
|
1641
|
+
const s = spinner();
|
|
1642
|
+
try {
|
|
1643
|
+
s.start(`Baixando ${fromVersion} e ${toVersion}`);
|
|
1644
|
+
await buildPristine({ dir: baseDir, version: fromVersion, state, packageName, download });
|
|
1645
|
+
await buildPristine({ dir: nextDir, version: toVersion, state, packageName, download });
|
|
1646
|
+
s.stop("Vers\xF5es baixadas");
|
|
1647
|
+
s.start("Comparando com o seu projeto");
|
|
1648
|
+
const actions = await planUpdate({ base: baseDir, next: nextDir, project: projectDir });
|
|
1649
|
+
s.stop("Compara\xE7\xE3o conclu\xEDda");
|
|
1650
|
+
log2.info(`${fromVersion} \u2192 ${toVersion}
|
|
1651
|
+
|
|
1652
|
+
${formatPlan(actions)}`);
|
|
1653
|
+
if (opts.dryRun) {
|
|
1654
|
+
outro3("Simula\xE7\xE3o: nada foi gravado.");
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
if (ask) {
|
|
1658
|
+
const proceed = await confirm4({ message: `Aplicar a atualiza\xE7\xE3o para ${toVersion}?` });
|
|
1659
|
+
if (isCancel5(proceed) || !proceed) {
|
|
1660
|
+
cancel4("Atualiza\xE7\xE3o cancelada.");
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
await applyPlan(projectDir, actions);
|
|
1665
|
+
await writeState(projectDir, { version: toVersion });
|
|
1666
|
+
const changed = actions.filter((a) => ["update", "add", "remove", "merge"].includes(a.kind)).map((a) => a.file);
|
|
1667
|
+
const conflicts = actions.filter((a) => a.kind === "conflict");
|
|
1668
|
+
const steps = [];
|
|
1669
|
+
if (changed.includes("package.json") || actions.some((a) => a.kind === "lockfile")) {
|
|
1670
|
+
steps.push("Instale as depend\xEAncias: pnpm install (ou npm install)");
|
|
1671
|
+
}
|
|
1672
|
+
if (changed.some((f) => f.startsWith("convex/"))) {
|
|
1673
|
+
steps.push("Publique o backend: npx convex dev --once (dev) e, depois de testar, npx convex deploy (produ\xE7\xE3o)");
|
|
1674
|
+
}
|
|
1675
|
+
if (conflicts.length) {
|
|
1676
|
+
steps.push(
|
|
1677
|
+
`Revise ${conflicts.length} arquivo(s) com conflito: compare cada um com o ${NEW_SUFFIX} ao lado, leve o que quiser da vers\xE3o nova e apague o ${NEW_SUFFIX}`
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
steps.push("Rode o site (pnpm dev) e confira antes de publicar");
|
|
1681
|
+
const missingVars = await checkRequiredEnvFn(projectDir, fs2);
|
|
1682
|
+
if (missingVars.length > 0) {
|
|
1683
|
+
log2.warn(
|
|
1684
|
+
`Vari\xE1veis de ambiente faltando no Convex:
|
|
1685
|
+
` + missingVars.map((v) => ` \u2022 ${v.name} \u2014 ${v.description}`).join("\n")
|
|
1686
|
+
);
|
|
1687
|
+
}
|
|
1688
|
+
outro3(`Atualizado para ${toVersion}.
|
|
1689
|
+
|
|
1690
|
+
Pr\xF3ximos passos:
|
|
1691
|
+
${steps.map((st, i) => ` ${i + 1}. ${st}`).join("\n")}`);
|
|
1692
|
+
} finally {
|
|
1693
|
+
await fs2.rm(workDir, { recursive: true, force: true });
|
|
1694
|
+
}
|
|
1077
1695
|
}
|
|
1078
1696
|
|
|
1079
1697
|
// src/commands/setup.ts
|
|
1080
|
-
import { outro as outro4, text as
|
|
1081
|
-
import * as
|
|
1082
|
-
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";
|
|
1700
|
+
import * as path10 from "path";
|
|
1083
1701
|
import * as nodeCrypto from "crypto";
|
|
1084
1702
|
import { execFileSync as defaultExecFileSync } from "child_process";
|
|
1085
1703
|
|
|
@@ -1109,11 +1727,11 @@ function parseEnvFile(content) {
|
|
|
1109
1727
|
}
|
|
1110
1728
|
async function runSetup(deps = {}) {
|
|
1111
1729
|
const cwd = deps.cwd ?? process.cwd();
|
|
1112
|
-
const
|
|
1113
|
-
access: (p) =>
|
|
1114
|
-
readFile: (p, enc) =>
|
|
1115
|
-
writeFile: (p, data) =>
|
|
1116
|
-
mkdir: (p, opts) =>
|
|
1730
|
+
const fs3 = deps.fs ?? {
|
|
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)
|
|
1117
1735
|
};
|
|
1118
1736
|
const detectProject2 = deps.detectProject ?? detectProject;
|
|
1119
1737
|
const generateJwtKeys2 = deps.generateJwtKeys ?? generateJwtKeys;
|
|
@@ -1126,10 +1744,10 @@ async function runSetup(deps = {}) {
|
|
|
1126
1744
|
cancel5(err.message);
|
|
1127
1745
|
return;
|
|
1128
1746
|
}
|
|
1129
|
-
const envPath =
|
|
1747
|
+
const envPath = path10.join(cwd, ".env.local");
|
|
1130
1748
|
let envVars = {};
|
|
1131
1749
|
try {
|
|
1132
|
-
const envContent = await
|
|
1750
|
+
const envContent = await fs3.readFile(envPath, "utf-8");
|
|
1133
1751
|
envVars = parseEnvFile(envContent);
|
|
1134
1752
|
} catch {
|
|
1135
1753
|
cancel5(
|
|
@@ -1150,7 +1768,7 @@ async function runSetup(deps = {}) {
|
|
|
1150
1768
|
return;
|
|
1151
1769
|
}
|
|
1152
1770
|
const siteUrlDefault = envVars["VITE_CONVEX_SITE_URL"];
|
|
1153
|
-
const s =
|
|
1771
|
+
const s = spinner2();
|
|
1154
1772
|
s.start("Gerando chaves JWT (RS256)...");
|
|
1155
1773
|
const { JWT_PRIVATE_KEY, JWKS } = await generateJwtKeys2();
|
|
1156
1774
|
s.stop("Chaves JWT geradas.");
|
|
@@ -1160,7 +1778,7 @@ async function runSetup(deps = {}) {
|
|
|
1160
1778
|
execFileSync("npx", ["convex", "env", "set", "--", "JWKS", JWKS], {
|
|
1161
1779
|
stdio: "pipe"
|
|
1162
1780
|
});
|
|
1163
|
-
const siteUrl = await
|
|
1781
|
+
const siteUrl = await text3({
|
|
1164
1782
|
message: "URL p\xFAblica do site (SITE_URL no Convex):",
|
|
1165
1783
|
initialValue: siteUrlDefault,
|
|
1166
1784
|
validate: (v) => {
|
|
@@ -1168,28 +1786,28 @@ async function runSetup(deps = {}) {
|
|
|
1168
1786
|
return "URL deve come\xE7ar com http:// ou https://";
|
|
1169
1787
|
}
|
|
1170
1788
|
});
|
|
1171
|
-
if (
|
|
1789
|
+
if (isCancel6(siteUrl)) {
|
|
1172
1790
|
cancel5("Setup cancelado.");
|
|
1173
1791
|
return;
|
|
1174
1792
|
}
|
|
1175
1793
|
execFileSync("npx", ["convex", "env", "set", "--", "SITE_URL", siteUrl], {
|
|
1176
1794
|
stdio: "pipe"
|
|
1177
1795
|
});
|
|
1178
|
-
const state = await readState2(cwd,
|
|
1796
|
+
const state = await readState2(cwd, fs3);
|
|
1179
1797
|
const plugins = state.plugins;
|
|
1180
1798
|
if (plugins["contact-wizard"] || plugins["testimonials-intake"]) {
|
|
1181
|
-
const telegramToken = await
|
|
1799
|
+
const telegramToken = await text3({
|
|
1182
1800
|
message: "TELEGRAM_BOT_TOKEN (Enter para pular):",
|
|
1183
1801
|
initialValue: ""
|
|
1184
1802
|
});
|
|
1185
|
-
if (!
|
|
1803
|
+
if (!isCancel6(telegramToken) && telegramToken && telegramToken.trim()) {
|
|
1186
1804
|
execFileSync("npx", ["convex", "env", "set", "--", "TELEGRAM_BOT_TOKEN", telegramToken], { stdio: "pipe" });
|
|
1187
1805
|
}
|
|
1188
|
-
const telegramChatId = await
|
|
1806
|
+
const telegramChatId = await text3({
|
|
1189
1807
|
message: "TELEGRAM_ADMIN_CHAT_ID (Enter para pular):",
|
|
1190
1808
|
initialValue: ""
|
|
1191
1809
|
});
|
|
1192
|
-
if (!
|
|
1810
|
+
if (!isCancel6(telegramChatId) && telegramChatId && telegramChatId.trim()) {
|
|
1193
1811
|
execFileSync("npx", ["convex", "env", "set", "--", "TELEGRAM_ADMIN_CHAT_ID", telegramChatId], { stdio: "pipe" });
|
|
1194
1812
|
}
|
|
1195
1813
|
}
|
|
@@ -1198,38 +1816,44 @@ async function runSetup(deps = {}) {
|
|
|
1198
1816
|
execFileSync("npx", ["convex", "env", "set", "--", "PLAYGROUND_KEY_PEPPER", pepper], { stdio: "pipe" });
|
|
1199
1817
|
}
|
|
1200
1818
|
if (plugins["ai-resumes"] || plugins["i18n"] || plugins["playground"]) {
|
|
1201
|
-
const openrouterKey = await
|
|
1819
|
+
const openrouterKey = await text3({
|
|
1202
1820
|
message: "OPENROUTER_API_KEY (Enter para pular):",
|
|
1203
1821
|
initialValue: ""
|
|
1204
1822
|
});
|
|
1205
|
-
if (!
|
|
1823
|
+
if (!isCancel6(openrouterKey) && openrouterKey && openrouterKey.trim()) {
|
|
1206
1824
|
execFileSync("npx", ["convex", "env", "set", "--", "OPENROUTER_API_KEY", openrouterKey], { stdio: "pipe" });
|
|
1207
1825
|
}
|
|
1208
1826
|
}
|
|
1209
1827
|
if (plugins["payments"]) {
|
|
1210
|
-
const
|
|
1211
|
-
message: "
|
|
1828
|
+
const asaasKey = await text3({
|
|
1829
|
+
message: "ASAAS_API_KEY \u2014 chave da API do Asaas, sandbox ou produ\xE7\xE3o (Enter para pular):",
|
|
1212
1830
|
initialValue: ""
|
|
1213
1831
|
});
|
|
1214
|
-
if (!
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1832
|
+
if (!isCancel6(asaasKey) && asaasKey && asaasKey.trim()) {
|
|
1833
|
+
const key = asaasKey.trim();
|
|
1834
|
+
execFileSync("npx", ["convex", "env", "set", "--", "ASAAS_API_KEY", key], { stdio: "pipe" });
|
|
1835
|
+
const webhookToken = randomBytes2(32).toString("hex");
|
|
1836
|
+
execFileSync("npx", ["convex", "env", "set", "--", "ASAAS_WEBHOOK_TOKEN", webhookToken], { stdio: "pipe" });
|
|
1837
|
+
const env = key.startsWith("$aact_prod_") ? "produ\xE7\xE3o" : "sandbox (testes)";
|
|
1838
|
+
log3.info(
|
|
1839
|
+
`Asaas configurado em ${env}. Falta cadastrar o webhook no painel do Asaas
|
|
1840
|
+
(Integra\xE7\xF5es \u2192 Webhooks \u2192 Adicionar), com os eventos de cobran\xE7a ligados:
|
|
1841
|
+
|
|
1842
|
+
URL: ${siteUrlDefault.replace(/\/+$/, "")}/webhooks/asaas
|
|
1843
|
+
Token: ${webhookToken}
|
|
1844
|
+
|
|
1845
|
+
Sem o webhook, os pagamentos nunca aparecem como pagos.`
|
|
1846
|
+
);
|
|
1223
1847
|
}
|
|
1224
1848
|
}
|
|
1225
|
-
const adminEmail = await
|
|
1849
|
+
const adminEmail = await text3({
|
|
1226
1850
|
message: "Email do usu\xE1rio root:",
|
|
1227
1851
|
validate: (v) => {
|
|
1228
1852
|
if (!v.includes("@") || !v.includes("."))
|
|
1229
1853
|
return "Email inv\xE1lido \u2014 deve conter @ e pelo menos um ponto";
|
|
1230
1854
|
}
|
|
1231
1855
|
});
|
|
1232
|
-
if (
|
|
1856
|
+
if (isCancel6(adminEmail)) {
|
|
1233
1857
|
cancel5("Setup cancelado.");
|
|
1234
1858
|
return;
|
|
1235
1859
|
}
|
|
@@ -1239,7 +1863,7 @@ async function runSetup(deps = {}) {
|
|
|
1239
1863
|
if (v.length < 12) return "Senha deve ter pelo menos 12 caracteres";
|
|
1240
1864
|
}
|
|
1241
1865
|
});
|
|
1242
|
-
if (
|
|
1866
|
+
if (isCancel6(adminPassword)) {
|
|
1243
1867
|
cancel5("Setup cancelado.");
|
|
1244
1868
|
return;
|
|
1245
1869
|
}
|
|
@@ -1249,7 +1873,7 @@ async function runSetup(deps = {}) {
|
|
|
1249
1873
|
if (v !== adminPassword) return "As senhas n\xE3o coincidem";
|
|
1250
1874
|
}
|
|
1251
1875
|
});
|
|
1252
|
-
if (
|
|
1876
|
+
if (isCancel6(adminPasswordConfirm)) {
|
|
1253
1877
|
cancel5("Setup cancelado.");
|
|
1254
1878
|
return;
|
|
1255
1879
|
}
|
|
@@ -1316,32 +1940,32 @@ async function runSetup(deps = {}) {
|
|
|
1316
1940
|
}
|
|
1317
1941
|
}
|
|
1318
1942
|
}
|
|
1319
|
-
const vercelHookUrl = await
|
|
1943
|
+
const vercelHookUrl = await text3({
|
|
1320
1944
|
message: "VERCEL_DEPLOY_HOOK_URL (Enter para pular):",
|
|
1321
1945
|
initialValue: ""
|
|
1322
1946
|
});
|
|
1323
|
-
if (!
|
|
1947
|
+
if (!isCancel6(vercelHookUrl) && vercelHookUrl && vercelHookUrl.trim()) {
|
|
1324
1948
|
execFileSync("npx", ["convex", "env", "set", "--", "VERCEL_DEPLOY_HOOK_URL", vercelHookUrl], { stdio: "pipe" });
|
|
1325
1949
|
}
|
|
1326
|
-
const vercelWebhookSecret = await
|
|
1950
|
+
const vercelWebhookSecret = await text3({
|
|
1327
1951
|
message: "VERCEL_WEBHOOK_SECRET (Enter para pular):",
|
|
1328
1952
|
initialValue: ""
|
|
1329
1953
|
});
|
|
1330
|
-
if (!
|
|
1954
|
+
if (!isCancel6(vercelWebhookSecret) && vercelWebhookSecret && vercelWebhookSecret.trim()) {
|
|
1331
1955
|
execFileSync("npx", ["convex", "env", "set", "--", "VERCEL_WEBHOOK_SECRET", vercelWebhookSecret], { stdio: "pipe" });
|
|
1332
1956
|
}
|
|
1333
|
-
const profession = await
|
|
1957
|
+
const profession = await text3({
|
|
1334
1958
|
message: "Qual \xE9 a sua profiss\xE3o ou \xE1rea de atua\xE7\xE3o? (Enter para usar padr\xE3o tech)",
|
|
1335
1959
|
placeholder: "Ex: Designer UX, Fot\xF3grafa, Advogada, Engenheira Civil...",
|
|
1336
1960
|
initialValue: ""
|
|
1337
1961
|
});
|
|
1338
|
-
const specialties = await
|
|
1962
|
+
const specialties = await text3({
|
|
1339
1963
|
message: "Quais s\xE3o suas principais especialidades? (separadas por v\xEDrgula, Enter para pular)",
|
|
1340
1964
|
placeholder: "Ex: Branding, Motion Design, Fotografia de Produto",
|
|
1341
1965
|
initialValue: ""
|
|
1342
1966
|
});
|
|
1343
|
-
const professionStr =
|
|
1344
|
-
const specialtiesStr =
|
|
1967
|
+
const professionStr = isCancel6(profession) ? "" : (profession || "").trim();
|
|
1968
|
+
const specialtiesStr = isCancel6(specialties) ? "" : (specialties || "").trim();
|
|
1345
1969
|
if (professionStr || specialtiesStr) {
|
|
1346
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" })) : [
|
|
1347
1971
|
{ label: "React", color: "primary" },
|
|
@@ -1393,14 +2017,30 @@ async function runCli(argv, cwd) {
|
|
|
1393
2017
|
} else if (command === "config") {
|
|
1394
2018
|
await runConfig({ cwd });
|
|
1395
2019
|
} else if (command === "update") {
|
|
1396
|
-
await runUpdate({ cwd });
|
|
2020
|
+
await runUpdate({ cwd, options: parseUpdateOptions(argv.slice(3)) });
|
|
1397
2021
|
} else if (command === "setup") {
|
|
1398
2022
|
await runSetup({ cwd });
|
|
2023
|
+
} else if (command && !command.startsWith("-")) {
|
|
2024
|
+
await runCreate(command, { projectsDir: cwd });
|
|
1399
2025
|
} else {
|
|
1400
|
-
console.log(
|
|
2026
|
+
console.log(
|
|
2027
|
+
"Comandos dispon\xEDveis: create <nome-do-projeto> | config | setup\n update [--dry-run] [--from <vers\xE3o>] [--to <vers\xE3o>] [--yes]"
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
function parseUpdateOptions(args) {
|
|
2032
|
+
const options = {};
|
|
2033
|
+
for (let i = 0; i < args.length; i++) {
|
|
2034
|
+
const arg = args[i];
|
|
2035
|
+
if (arg === "--dry-run") options.dryRun = true;
|
|
2036
|
+
else if (arg === "--yes" || arg === "-y") options.yes = true;
|
|
2037
|
+
else if (arg === "--from") options.from = args[++i];
|
|
2038
|
+
else if (arg === "--to") options.to = args[++i];
|
|
1401
2039
|
}
|
|
2040
|
+
return options;
|
|
1402
2041
|
}
|
|
1403
2042
|
await runCli(process.argv, process.cwd());
|
|
1404
2043
|
export {
|
|
2044
|
+
parseUpdateOptions,
|
|
1405
2045
|
runCli
|
|
1406
2046
|
};
|