@fluencypassdevs/pulse 0.3.0 → 0.4.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/bin/cli.mjs CHANGED
@@ -12,6 +12,8 @@ const command = process.argv[2]
12
12
 
13
13
  if (command === "mcp") {
14
14
  await import("./mcp.mjs")
15
+ } else if (command === "propose") {
16
+ await import("./propose.mjs")
15
17
  } else if (command === "init" || !command) {
16
18
  await import("./init.mjs")
17
19
  } else {
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * `npx pulse propose <arquivo>` — propõe um componente ao Design System a partir
5
+ * do PRÓPRIO projeto do dev, sem abrir o GitHub na mão.
6
+ *
7
+ * Lê o componente (idealmente de `src/components/ds-proposals/`), pergunta o
8
+ * contexto, e abre a issue "Proposta de Componente" no repo do DS via `gh`.
9
+ * Se o `gh` não existir, cai num fallback: salva o corpo + imprime um link.
10
+ *
11
+ * Flags: --name, --what, --where, --preview (não-interativo) · --dry-run (só imprime).
12
+ */
13
+
14
+ import fs from "fs"
15
+ import path from "path"
16
+ import { execFileSync, spawnSync } from "child_process"
17
+ import { createInterface } from "readline"
18
+
19
+ // ── Config específica do DS (o cycle tem a sua) ──
20
+ const DS = {
21
+ label: "Pulse",
22
+ repo: "Fluencypass/Cycle",
23
+ surfaceHint: "Landing / campanha de marketing",
24
+ }
25
+
26
+ const argv = process.argv.slice(2)
27
+ const flags = {}
28
+ const positionals = []
29
+ for (let i = 0; i < argv.length; i++) {
30
+ const a = argv[i]
31
+ if (a === "--dry-run") flags.dryRun = true
32
+ else if (a.startsWith("--")) flags[a.slice(2)] = argv[++i]
33
+ else positionals.push(a)
34
+ }
35
+
36
+ function fail(msg) {
37
+ console.error(`\n ✗ ${msg}\n`)
38
+ process.exit(1)
39
+ }
40
+
41
+ let file = positionals[0]
42
+ if (!file) {
43
+ const dir = path.join(process.cwd(), "src/components/ds-proposals")
44
+ const found = fs.existsSync(dir) ? fs.readdirSync(dir).filter((f) => /\.(tsx|jsx|ts)$/.test(f)) : []
45
+ if (found.length === 1) file = path.join(dir, found[0])
46
+ else if (found.length > 1) fail(`Vários candidatos em ds-proposals/. Especifique: npx pulse propose <arquivo>\n ${found.join("\n ")}`)
47
+ else fail("Uso: npx pulse propose <caminho-do-componente> (ex.: src/components/ds-proposals/meu-hero.tsx)")
48
+ }
49
+ if (!fs.existsSync(file)) fail(`Arquivo não encontrado: ${file}`)
50
+ const code = fs.readFileSync(file, "utf-8")
51
+
52
+ const rl = createInterface({ input: process.stdin, output: process.stdout })
53
+ const ask = (q, def) =>
54
+ new Promise((res) => rl.question(` ${q}${def ? ` (${def})` : ""}: `, (a) => res(a.trim() || def || "")))
55
+
56
+ const name = flags.name || path.basename(file).replace(/\.(tsx|jsx|ts)$/, "")
57
+
58
+ console.log(`\n Propor componente ao ${DS.label} Design System\n ─────────────────────────────────────────────\n`)
59
+
60
+ const what = flags.what || (await ask("O que ele faz? (1 frase)"))
61
+ const where = flags.where || (await ask("Onde ele aparece?", DS.surfaceHint))
62
+ const preview = flags.preview || (await ask("Link de preview ou screenshot (opcional)"))
63
+ rl.close()
64
+
65
+ const title = `[Proposta] ${name}`
66
+ const body = `## Componente
67
+ **${name}**
68
+
69
+ ## O que faz
70
+ ${what || "(não informado)"}
71
+
72
+ ## Onde aparece
73
+ ${where}
74
+
75
+ ## Preview
76
+ ${preview || "(anexar print/link)"}
77
+
78
+ ## Código
79
+ \`\`\`tsx
80
+ ${code}
81
+ \`\`\`
82
+
83
+ ---
84
+ _Proposto via \`npx pulse propose\` a partir de um projeto consumidor._`
85
+
86
+ if (flags.dryRun) {
87
+ console.log(`\n [dry-run] Issue que seria criada em ${DS.repo}:\n`)
88
+ console.log(` Título: ${title}`)
89
+ console.log(` Label: ds-proposal\n`)
90
+ console.log(body.split("\n").map((l) => " │ " + l).join("\n"))
91
+ console.log("")
92
+ process.exit(0)
93
+ }
94
+
95
+ const hasGh = spawnSync("gh", ["--version"], { stdio: "ignore" }).status === 0
96
+ if (hasGh) {
97
+ const tmp = path.join(process.cwd(), `.ds-proposal-${name}.md`)
98
+ fs.writeFileSync(tmp, body)
99
+ try {
100
+ const url = execFileSync(
101
+ "gh",
102
+ ["issue", "create", "--repo", DS.repo, "--title", title, "--label", "ds-proposal", "--body-file", tmp],
103
+ { encoding: "utf-8" }
104
+ ).trim()
105
+ fs.unlinkSync(tmp)
106
+ console.log(`\n ✓ Proposta enviada! ${url}\n Você será notificado quando for revisada.\n`)
107
+ } catch (err) {
108
+ fs.unlinkSync(tmp)
109
+ fail(`Falha ao criar a issue via gh (${err.message}). Rode \`gh auth login\` e tente de novo.`)
110
+ }
111
+ } else {
112
+ const out = path.join(process.cwd(), `ds-proposal-${name}.md`)
113
+ fs.writeFileSync(out, body)
114
+ const url = `https://github.com/${DS.repo}/issues/new?labels=ds-proposal&title=${encodeURIComponent(title)}`
115
+ console.log(`\n 'gh' não encontrado. Fallback:\n`)
116
+ console.log(` 1. Corpo salvo em: ${out}`)
117
+ console.log(` 2. Abra: ${url}`)
118
+ console.log(` 3. Cole o conteúdo do arquivo no corpo da issue.\n`)
119
+ console.log(` (Instale o GitHub CLI — https://cli.github.com — pra automatizar isso.)\n`)
120
+ }
@@ -95,8 +95,9 @@ O DS **não trava** o projeto. Se algo REALMENTE não existe:
95
95
 
96
96
  1. Crie em **`src/components/ds-proposals/`** (marcador de "candidato ao DS"), NÃO em `components/`.
97
97
  2. Componha com os componentes/tokens do pulse — nunca copie código do DS nem use cor na mão.
98
- 3. Se for reutilizável, **proponha a entrada**: abra a issue "Proposta de Componente" em
99
- https://github.com/Fluencypass/Cycle/issues/new/choose (código + print/link). Guia:
98
+ 3. Se for reutilizável, **proponha a entrada** rodando no projeto:
99
+ `npx pulse propose src/components/ds-proposals/<arquivo>` (abre a issue via gh). Fallback
100
+ manual: https://github.com/Fluencypass/Cycle/issues/new/choose. Guia:
100
101
  https://design.fluencypass.com/pulse/contribuir
101
102
 
102
103
  ## Documentacao
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluencypassdevs/pulse",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Pulse Design System — marketing/conversão da Fluencypass. Irmão do Cycle (produto): mesma fundação de marca e primitivos core embutidos, componentes e premissas próprios de marketing.",
5
5
  "license": "MIT",
6
6
  "repository": {