Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions plugins/env-checker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Env Checker

<!-- ficha:inicio (gerada por ferramentas/plugins.mjs: não edite à mão) -->
| | |
|---|---|
| **Autor** | Pizzy-23 |
| **Versão** | 0.1.0 |
| **Licença** | MIT |
| **Categoria** | Qualidade e testes |
| **Precisa de** | nada além do BlueScreen |
| **Código** | [plugins/env-checker](https://github.com/martindevbr/BlueScreen-Plugins/tree/main/plugins/env-checker) |
<!-- ficha:fim -->

Painel na barra da esquerda para os arquivos `.env*` da raiz do projeto.

## Como usar

- Cada arquivo numa aba (`.env`, `.env.local`, `.env.example`...), com as variáveis e os valores **escondidos**. O olho mostra um de cada vez. Clique no nome para ir à linha no editor.
- Marca com ● as variáveis que parecem segredo (nome com token, secret, password, api_key... ou valor com cara de chave: `sk-`, `ghp_`, `AKIA`, `xox`, JWT, chave PEM, URL com senha).
- Avisos:
- `.env` **commitado no git** (tire do repositório e troque os segredos);
- `.env` fora do `.gitignore`, com o botão **Pôr no .gitignore**;
- variáveis que faltam ou sobram em relação ao `.env.example`;
- chave repetida;
- `.env.example` com segredo de verdade dentro.
- **Gerar .env.example**: copia o `.env` só com os nomes e os comentários, sem nenhum valor.

Nada sai do PC: ele só lê os arquivos e roda `git check-ignore` e `git ls-files`.

## Autor e licença

Feito por Pizzy-23. Licença MIT (veja o campo `license` do `plugin.json`).

## Histórico de versões

### 0.1.0

- Primeira versão na loja.
1 change: 1 addition & 0 deletions plugins/env-checker/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions plugins/env-checker/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": "env-checker",
"name": "Env Checker",
"description": "Mostra os .env do projeto com os valores escondidos, compara com o .env.example (o que falta, o que sobra), avisa chave repetida, segredo em arquivo de exemplo e .env sem .gitignore ou já commitado no git. Gera o .env.example só com os nomes e acrescenta o .env no .gitignore.",
"version": "0.1.0",
"author": "Pizzy-23",
"license": "MIT",
"category": "qualidade",
"keywords": [
"env",
"dotenv",
"segredos",
"gitignore",
"variáveis"
],
"icon": "icon.svg",
"order": 116
}
20 changes: 20 additions & 0 deletions plugins/env-checker/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.ev-wrap { display: flex; flex-direction: column; height: 100%; min-width: 0; box-sizing: border-box; }
.ev-top { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ev-sp { flex: 1; }
.ev-body { flex: 1; min-height: 0; overflow: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.ev-files { display: flex; gap: 4px; flex-wrap: wrap; }
.ev-f { background: none; border: 1px solid var(--line-2); border-radius: 12px; color: var(--fg-2); padding: 2px 10px; font: 12px var(--mono); cursor: pointer; display: flex; gap: 6px; }
.ev-f em { font-style: normal; color: var(--muted); }
.ev-f.on { background: var(--sel); color: var(--fg); border-color: var(--accent); }
.ev-n { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-size: 12px; line-height: 1.4; padding: 6px 8px; border-radius: 6px; border-left: 3px solid var(--muted); background: var(--panel-2); }
.ev-n .chip { font-size: 11px; padding: 1px 8px; }
.ev-bad { border-color: #f85149; } .ev-warn { border-color: #d29922; } .ev-ok { border-color: #3fb950; } .ev-info { border-color: var(--accent-2); }
.ev-vars { display: flex; flex-direction: column; }
.ev-v { display: grid; grid-template-columns: minmax(90px, 45%) 1fr auto; gap: 6px; align-items: center; padding: 3px 4px; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); font: 12px var(--mono); }
.ev-v:hover { background: var(--hover); }
.ev-k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: var(--accent-2); }
.ev-lock { font-style: normal; color: #d29922; margin-left: 4px; font-size: 9px; }
.ev-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); }
.ev-empty { color: var(--muted); }
.ev-eye { width: 22px; height: 22px; }
.ev-row { display: flex; gap: 6px; padding-top: 4px; }
141 changes: 141 additions & 0 deletions plugins/env-checker/ui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Conferir .env: lê os .env* da raiz do projeto, compara com o .env.example e confere se o git protege os segredos.
// Os valores ficam mascarados na tela; só um clique no olho mostra um de cada vez.
const { esc, toast } = bs;
if (bs.S.remote) return;

const ICON = '<svg class="i" viewBox="0 0 24 24"><rect x="4" y="10" width="16" height="10" rx="2"/><path d="M8 10V7a4 4 0 0 1 8 0v3M12 14v2"/></svg>';
const EXAMPLES = ['.env.example', '.env.sample', '.env.template', '.env.dist', 'example.env'];
const SECRET_KEY = /(secret|token|passw|pwd|api[_-]?key|private|credential|auth|dsn|webhook|signing|salt)/i;
const SECRET_VAL = [/^sk-[\w-]{20,}/, /^gh[pousr]_\w{30,}/, /^github_pat_/, /^AKIA[0-9A-Z]{16}$/, /^xox[abposr]-/, /^AIza[\w-]{30,}/, /-----BEGIN [A-Z ]*PRIVATE KEY/, /^eyJ[\w-]+\.[\w-]+\./, /:\/\/[^:\s/]+:[^@\s]+@/];
const E = { files: null, sel: null, err: null, shown: new Set(), git: {} };

function parse(text) {
const vars = [], dup = new Set(), seen = new Set();
text.replace(/\r/g, '').split('\n').forEach((raw, i) => {
const m = raw.match(/^\s*(?:export\s+)?([A-Za-z_][\w.-]*)\s*=\s*(.*)$/); if (!m) return;
let v = m[2].trim();
if (/^(['"`]).*\1$/.test(v)) v = v.slice(1, -1);
else v = v.replace(/\s+#.*$/, '');
if (seen.has(m[1])) dup.add(m[1]); seen.add(m[1]);
vars.push({ key: m[1], value: v, line: i + 1 });
});
return { vars, dup };
}
const looksSecret = (k, v) => !!v && (SECRET_KEY.test(k) || SECRET_VAL.some(r => r.test(v)));
const mask = (v) => !v ? '<i class="ev-empty">vazio</i>' : '•'.repeat(Math.min(12, Math.max(4, v.length)));

async function git(args) {
const r = await plugin.exec('git', args, { cwd: bs.S.project.path, timeout: 10000 }).catch(() => null);
return r ? r.code : -1;
}

async function load() {
E.err = null; E.files = null; draw();
if (!bs.S.project) { E.files = []; draw(); return; }
try {
const r = await plugin.exec('powershell', ['-NoProfile', '-NonInteractive', '-Command',
"Get-ChildItem -LiteralPath $env:EV_DIR -Force -File | Where-Object { $_.Name -like '.env*' -or $_.Name -like '*.env' } | ForEach-Object { $_.Name }"],
{ env: { EV_DIR: bs.S.project.path }, timeout: 10000 });
const names = r.out.split(/\r?\n/).map(s => s.trim()).filter(Boolean).sort((a, b) => (a === '.env' ? -1 : b === '.env' ? 1 : a.localeCompare(b)));
const files = [];
for (const name of names) {
const content = (await bs.api('file', { project: bs.S.project.path, file: name }).catch(() => ({ content: '' }))).content || '';
files.push({ name, example: EXAMPLES.includes(name.toLowerCase()), ...parse(content) });
}
E.files = files;
E.sel = files.find(f => f.name === E.sel)?.name || files.find(f => !f.example)?.name || files[0]?.name || null;
// git: ignorado? já foi commitado? (ls-files sai 0 quando o arquivo está no índice)
E.git = {};
if (await git(['rev-parse', '--is-inside-work-tree']) === 0) {
for (const f of files.filter(f => !f.example)) E.git[f.name] = { ignored: await git(['check-ignore', '-q', f.name]) === 0, tracked: await git(['ls-files', '--error-unmatch', f.name]) === 0 };
} else E.git = null;
} catch (e) { E.err = e.message; }
draw();
}

function findings(f) {
const out = [], ex = E.files.find(x => x.example);
if (!f.example && E.git) {
const g = E.git[f.name] || {};
if (g.tracked) out.push(['bad', `${f.name} está commitado no git. Tire do repositório (git rm --cached ${f.name}) e troque os segredos que estavam nele.`]);
else if (!g.ignored) out.push(['warn', `${f.name} não está no .gitignore: um "git add ." leva os segredos junto.`, 'ignore']);
else out.push(['ok', `${f.name} está no .gitignore.`]);
}
if (f.dup.size) out.push(['warn', `Chave repetida: ${[...f.dup].join(', ')} (vale a última).`]);
if (!f.example && ex) {
const have = new Set(f.vars.map(v => v.key)), want = new Set(ex.vars.map(v => v.key));
const miss = [...want].filter(k => !have.has(k)), extra = [...have].filter(k => !want.has(k));
if (miss.length) out.push(['warn', `Faltam em ${f.name} (estão no ${ex.name}): ${miss.join(', ')}`]);
if (extra.length) out.push(['info', `Não estão no ${ex.name}: ${extra.join(', ')}`, 'example']);
}
if (!f.example && !ex && f.vars.length) out.push(['info', 'Sem .env.example: quem clonar o projeto não sabe quais variáveis preencher.', 'example']);
if (f.example) {
const leaked = f.vars.filter(v => v.value && SECRET_VAL.some(r => r.test(v.value)));
if (leaked.length) out.push(['bad', `${f.name} parece ter segredos de verdade (${leaked.map(v => v.key).join(', ')}). Ele costuma ir para o git.`]);
}
return out;
}

function draw() {
const el = bs.$('#toolBody .ev-wrap'); if (!el) return;
const body = el.querySelector('.ev-body');
if (E.err) { body.innerHTML = `<div class="errbox">${esc(E.err)}</div>`; return; }
if (!E.files) { body.innerHTML = '<div class="empty"><span class="spin"></span></div>'; return; }
if (!bs.S.project) { body.innerHTML = '<div class="empty">Abra um projeto.</div>'; return; }
if (!E.files.length) { body.innerHTML = '<div class="empty">Nenhum .env na raiz do projeto.</div>'; return; }
const f = E.files.find(x => x.name === E.sel) || E.files[0];
const tabs = E.files.map(x => `<button class="ev-f${x === f ? ' on' : ''}" data-f="${esc(x.name)}">${esc(x.name)}<em>${x.vars.length}</em></button>`).join('');
const notes = findings(f).map(([lvl, msg, fix]) => `<div class="ev-n ev-${lvl}"><span>${esc(msg)}</span>${fix === 'ignore' ? '<button class="chip" data-fix="ignore">Pôr no .gitignore</button>' : fix === 'example' ? '<button class="chip" data-fix="example">Gerar .env.example</button>' : ''}</div>`).join('');
const rows = f.vars.map(v => {
const sec = looksSecret(v.key, v.value), id = f.name + '\n' + v.key, show = E.shown.has(id) || f.example && !sec;
return `<div class="ev-v" data-line="${v.line}"><span class="ev-k">${esc(v.key)}${sec ? '<i class="ev-lock" title="parece segredo">●</i>' : ''}</span>
<span class="ev-val">${show ? (v.value ? esc(v.value) : '<i class="ev-empty">vazio</i>') : mask(v.value)}</span>
${v.value && !(f.example && !sec) ? `<button class="icon-btn ev-eye" data-id="${esc(id)}" title="${show ? 'Esconder' : 'Mostrar'}">${show ? '◉' : '◎'}</button>` : ''}</div>`;
}).join('');
body.innerHTML = `<div class="ev-files">${tabs}</div>${notes}<div class="ev-vars">${rows || '<div class="empty">Sem variáveis.</div>'}</div>
<div class="ev-row"><button class="chip ev-open">Abrir ${esc(f.name)}</button></div>`;
}

async function fix(kind, btn) {
const project = bs.S.project.path;
btn.disabled = true;
try {
if (kind === 'ignore') {
let cur = null; try { cur = (await bs.api('file', { project, file: '.gitignore' })).content; } catch {}
const add = '\n# segredos locais\n.env\n.env.*\n!' + EXAMPLES.join('\n!') + '\n';
if (cur == null) await bs.api('file/new', { project }, { method: 'POST', body: JSON.stringify({ path: '.gitignore', content: add.trimStart() }) });
else await bs.api('file', { project, file: '.gitignore' }, { method: 'PUT', body: cur.replace(/\s*$/, '\n') + add });
toast('.gitignore atualizado', 'ok');
} else {
const f = E.files.find(x => x.name === E.sel); const ex = E.files.find(x => x.example);
const target = ex?.name || '.env.example';
const text = (await bs.api('file', { project, file: f.name })).content.replace(/\r/g, '').split('\n')
.map(l => l.replace(/^(\s*(?:export\s+)?[A-Za-z_][\w.-]*\s*=).*$/, '$1')).join('\n');
if (ex) {
if (!btn.dataset.sure) { btn.dataset.sure = '1'; btn.textContent = `Sobrescrever ${target}?`; btn.disabled = false; return; }
await bs.api('file', { project, file: target }, { method: 'PUT', body: text });
} else await bs.api('file/new', { project }, { method: 'POST', body: JSON.stringify({ path: target, content: text }) });
toast(`${target} gerado só com os nomes, sem os valores`, 'ok');
}
} catch (e) { toast(e.message); }
load();
}

function panel(el) {
el.innerHTML = `<div class="ev-wrap"><div class="ev-top"><b>Variáveis de ambiente</b><span class="ev-sp"></span><button class="icon-btn ev-ref" title="Ler de novo">${bs.I.refresh}</button></div><div class="ev-body"></div></div>`;
const w = el.querySelector('.ev-wrap');
w.querySelector('.ev-ref').onclick = load;
w.onclick = (e) => {
const t = e.target;
const f = t.closest('[data-f]'); if (f) { E.sel = f.dataset.f; draw(); return; }
const eye = t.closest('.ev-eye'); if (eye) { const id = eye.dataset.id; E.shown.has(id) ? E.shown.delete(id) : E.shown.add(id); draw(); return; }
const fx = t.closest('[data-fix]'); if (fx) return fix(fx.dataset.fix, fx);
if (t.closest('.ev-open')) return bs.openFile(E.sel, 'editor');
const v = t.closest('.ev-v'); if (v && t.closest('.ev-k')) bs.openFile(E.sel, 'editor', +v.dataset.line);
};
load();
}

bs.tools.register({ id: 'conferir-env', title: 'Env Checker', icon: ICON, order: 66, render() { panel(bs.$('#toolBody')); } });
bs.hooks.on('project:select', () => { E.shown.clear(); if (bs.$('#toolBody .ev-wrap')) load(); });
bs.hooks.on('tab:save', (t) => { if (/(^|\/)\.env|\.env$|\.gitignore$/.test(t?.path || '') && bs.$('#toolBody .ev-wrap')) load(); });
35 changes: 35 additions & 0 deletions plugins/github-panel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# GitHub Panel

<!-- ficha:inicio (gerada por ferramentas/plugins.mjs: não edite à mão) -->
| | |
|---|---|
| **Autor** | Pizzy-23 |
| **Versão** | 0.1.0 |
| **Licença** | MIT |
| **Categoria** | Integrações |
| **Precisa de** | nada além do BlueScreen |
| **Código** | [plugins/github-panel](https://github.com/martindevbr/BlueScreen-Plugins/tree/main/plugins/github-panel) |
<!-- ficha:fim -->

Painel **GitHub** na barra da esquerda com o repositório do projeto aberto, tudo pelo [GitHub CLI](https://cli.github.com) (`gh`). Ele usa o login que o `gh` já tem: nenhum token fica guardado aqui.

## Como usar

- **PRs** abertos, **Meus** (os seus, inclusive os fechados), **Issues** e **Actions**.
- Cada PR mostra se é rascunho, a revisão (aprovado, pediu mudanças) e os checks (✓ 5/5, ✕ falhando, ● rodando).
- Ações ao passar o mouse: **Abrir** no navegador, **Checkout** (pede um segundo clique), **Diff** colorido ali mesmo.
- Actions que falharam: **Log do erro** (só os passos que falharam) e **Rodar de novo**.
- Barra de status: o PR do branch atual e o estado dos checks, atualizado a cada 5 minutos. Clique para abrir.
- Buscar em tudo: abrir o repositório e criar PR do branch atual no navegador.

Precisa do `gh` instalado e com login (`gh auth login`).

## Autor e licença

Feito por Pizzy-23. Licença MIT (veja o campo `license` do `plugin.json`).

## Histórico de versões

### 0.1.0

- Primeira versão na loja.
1 change: 1 addition & 0 deletions plugins/github-panel/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions plugins/github-panel/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"id": "github-panel",
"name": "GitHub Panel",
"description": "PRs, issues e Actions do repositório do projeto aberto, pelo GitHub CLI (gh) que você já usa, sem token novo. Estado dos checks de cada PR, o PR do branch atual na barra de status, abrir no navegador e fazer checkout de um PR.",
"version": "0.1.0",
"author": "Pizzy-23",
"license": "MIT",
"category": "integracoes",
"keywords": [
"github",
"gh",
"pull request",
"issues",
"actions",
"ci"
],
"icon": "icon.svg",
"order": 111
}
25 changes: 25 additions & 0 deletions plugins/github-panel/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.gh-wrap { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; height: 100%; box-sizing: border-box; min-width: 0; }
.gh-top { display: flex; align-items: center; gap: 6px; }
.gh-repo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-sp { flex: 1; }
.gh-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.gh-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--fg-2); padding: 4px 8px; cursor: pointer; font: inherit; font-size: 12px; }
.gh-tab.on { color: var(--fg); border-bottom-color: var(--accent); }
.gh-q { background: var(--bg); color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 4px 8px; font: inherit; }
.gh-list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.gh-row { padding: 6px; border-radius: 6px; display: flex; flex-direction: column; gap: 3px; }
.gh-row:hover { background: var(--hover); }
.gh-l1 { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.gh-num { color: var(--muted); font-size: 12px; flex: none; }
.gh-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-l2 { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; font-size: 11px; }
.gh-meta { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gh-tag { --gh-c: var(--muted); border: 1px solid color-mix(in srgb, var(--gh-c) 60%, transparent); color: var(--fg-2); background: color-mix(in srgb, var(--gh-c) 18%, transparent); border-radius: 10px; padding: 0 6px; }
.gh-chk { font-weight: 600; font-size: 11px; flex: none; }
.gh-good { color: #3fb950; --gh-c: #3fb950; } .gh-bad { color: #f85149; --gh-c: #f85149; } .gh-wait { color: #d29922; --gh-c: #d29922; } .gh-mute { color: var(--muted); }
.gh-acts { display: none; gap: 4px; }
.gh-row:hover .gh-acts, .gh-row:has(.gh-detail) .gh-acts { display: flex; }
.gh-acts .chip { font-size: 11px; padding: 1px 8px; }
.gh-detail { margin: 4px 0 0; max-height: 360px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 6px; font-size: 11px; white-space: pre; }
.gh-detail i { font-style: normal; }
.gh-add { color: #3fb950; } .gh-del { color: #f85149; } .gh-hunk { color: var(--accent-2); }
Loading
Loading