greenlitlab 0.4.0 → 0.4.2
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/CHANGELOG.md +15 -0
- package/bin/greenlit.mjs +6 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/scan.mjs +64 -8
- package/src/welcome.mjs +99 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.2 (10 November 2026)
|
|
4
|
+
|
|
5
|
+
- A welcome screen: `npx greenlitlab` on its own, in a wide terminal, now shows a pixel-art signal on green and the four commands that matter. `--help` still prints the full reference, and pipes, CI, `NO_COLOR` and narrow windows get it too.
|
|
6
|
+
|
|
7
|
+
## 0.4.1 (10 November 2026)
|
|
8
|
+
|
|
9
|
+
`scan`, after running it on real projects:
|
|
10
|
+
|
|
11
|
+
- Row Level Security switched on in a loop (`foreach t in array[…] loop execute format('alter table … enable row level security', t)`) is now seen. Where it is switched on by a statement Greenlit can't follow, an unmatched table is a question ("couldn't see"), not an alarm.
|
|
12
|
+
- Test files, test folders and agents' working copies (`.claude`, `worktrees`) are no longer read: their made-up secrets and tables aren't the app's.
|
|
13
|
+
- Tables that everyone may read are gathered into one finding with the list, instead of one finding per table.
|
|
14
|
+
- A policy that lets anyone add rows is a question (right for a form, a waitlist or a log), not a high finding. Changing and deleting still are.
|
|
15
|
+
- "No lockfile" is only reported for a project that has dependencies.
|
|
16
|
+
- Migrations are read in order, and a rule or table that a later migration removes (`drop policy`, `alter policy`, `drop table`) is no longer reported.
|
|
17
|
+
|
|
3
18
|
## 0.4.0 (10 November 2026)
|
|
4
19
|
|
|
5
20
|
Greenlit now checks launch readiness, not only leaks. Only things it confirmed move the grade; what it couldn't see is said, and what only you know is asked.
|
package/bin/greenlit.mjs
CHANGED
|
@@ -54,7 +54,12 @@ try {
|
|
|
54
54
|
if (opt.version) {
|
|
55
55
|
console.log(VERSION);
|
|
56
56
|
} else if (opt.help || !positionals[0]) {
|
|
57
|
-
|
|
57
|
+
// On its own in a wide terminal, Greenlit says hello with its welcome screen; --help, pipes, CI,
|
|
58
|
+
// NO_COLOR and narrow windows get the full plain help.
|
|
59
|
+
const { welcome } = await import("../src/welcome.mjs");
|
|
60
|
+
const hello = opt.help ? "" : welcome({ version: VERSION });
|
|
61
|
+
if (hello) process.stdout.write(hello);
|
|
62
|
+
else console.log(HELP);
|
|
58
63
|
} else if (positionals[0] === "mcp") {
|
|
59
64
|
const { serve } = await import("../src/mcp.mjs");
|
|
60
65
|
await serve({ version: VERSION });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greenlitlab",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Is your AI-built app safe to launch? A grade from A to F for apps built with Lovable, Bolt, v0, Replit or Emergent, with a fix prompt for every problem. Checks leaks, open data and launch basics.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/server.json
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
"description": "Grade apps built with Lovable, Bolt, v0 or Replit A to F, with a fix prompt for every problem.",
|
|
6
6
|
"websiteUrl": "https://greenlit.priberry.com",
|
|
7
7
|
"repository": { "url": "https://github.com/priberry-data/greenlitlab", "source": "github" },
|
|
8
|
-
"version": "0.4.
|
|
8
|
+
"version": "0.4.2",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.4.
|
|
13
|
+
"version": "0.4.2",
|
|
14
14
|
"transport": { "type": "stdio" },
|
|
15
15
|
"packageArguments": [{ "type": "positional", "value": "mcp" }]
|
|
16
16
|
}
|
package/src/scan.mjs
CHANGED
|
@@ -5,7 +5,8 @@ import fs from "node:fs";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// Build output, dependencies, agents' working copies, and tests (whose made-up secrets and tables aren't the app's).
|
|
9
|
+
const SKIP = new Set(["node_modules", ".claude", "worktrees", "__tests__", "__mocks__", "__fixtures__", "fixtures", "test", "tests", "e2e", "cypress", ".git", "dist", "build", ".next", ".vercel", ".netlify", ".wrangler", "coverage", ".turbo", ".cache", "vendor", "__pycache__", ".venv"]);
|
|
9
10
|
const TEXT = /\.(sql|toml|json|js|jsx|ts|tsx|mjs|cjs|py|vue|svelte)$|(^|\/)\.env[^/]*$/;
|
|
10
11
|
const PUBLIC_PREFIX = "(?:VITE_|NEXT_PUBLIC_|REACT_APP_|EXPO_PUBLIC_|PUBLIC_|NUXT_PUBLIC_)";
|
|
11
12
|
// The name must END in the secret word (or _KEY/_TOKEN after it): VITE_STRIPE_SECRET_KEY is a secret,
|
|
@@ -43,12 +44,17 @@ const lineOf = (text, index) => text.slice(0, index).split("\n").length;
|
|
|
43
44
|
export function codeScan(dir = ".") {
|
|
44
45
|
const root = path.resolve(dir);
|
|
45
46
|
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) throw new Error(`"${dir}" isn't a folder`);
|
|
46
|
-
|
|
47
|
+
// In name order, which for migrations is the order they ran in: a later file can undo an earlier one.
|
|
48
|
+
const files = walk(root).sort();
|
|
47
49
|
const rel = (f) => path.relative(root, f).split(path.sep).join("/");
|
|
48
50
|
const findings = [];
|
|
49
51
|
const add = (f) => findings.some((x) => x.id === f.id) || findings.push(f);
|
|
50
52
|
const created = new Map(); // table -> where it was created
|
|
51
53
|
const protectedTables = new Set();
|
|
54
|
+
const publicRead = { everyone: [], "every signed-in user": [] };
|
|
55
|
+
let dynamicRls = false;
|
|
56
|
+
// Open policies still standing after every migration: a later "drop policy" or "drop table" removes one.
|
|
57
|
+
const openPolicies = new Map();
|
|
52
58
|
|
|
53
59
|
for (const file of files) {
|
|
54
60
|
const name = rel(file);
|
|
@@ -59,6 +65,7 @@ export function codeScan(dir = ".") {
|
|
|
59
65
|
} catch {
|
|
60
66
|
continue;
|
|
61
67
|
}
|
|
68
|
+
if (/\.(test|spec)\.[a-z]+$/i.test(name)) continue;
|
|
62
69
|
const isEnv = /(^|\/)\.env[^/]*$/.test(name);
|
|
63
70
|
|
|
64
71
|
// Names only: a secret behind a public prefix is copied into the code every visitor downloads.
|
|
@@ -70,15 +77,39 @@ export function codeScan(dir = ".") {
|
|
|
70
77
|
|
|
71
78
|
if (name.endsWith(".sql")) {
|
|
72
79
|
const sql = noComments(text);
|
|
80
|
+
// What this file does, in the order it does it.
|
|
81
|
+
const events = [];
|
|
82
|
+
// Protection switched on in a loop: foreach t in array['a','b'] loop execute format('alter table … enable row level security', t).
|
|
83
|
+
// The names are inside quotes, so they are read from the file as written.
|
|
84
|
+
for (const m of text.matchAll(/foreach\s+\w+\s+in\s+array\s+(?:array\s*)?\[([^\]]*)\]\s*loop([\s\S]*?)end\s+loop/gi))
|
|
85
|
+
if (/enable\s+row\s+level\s+security/i.test(m[2])) for (const n of m[1].matchAll(/'([\w.]+)'/g)) protectedTables.add(n[1].replace(/^public\./i, "").toLowerCase());
|
|
86
|
+
// Any other statement built at run time that turns it on: the tables it covers can't be known from the file.
|
|
87
|
+
if (/execute\b[\s\S]{0,300}?enable\s+row\s+level\s+security/i.test(text)) dynamicRls = true;
|
|
73
88
|
for (const m of sql.matchAll(new RegExp(String.raw`create\s+(?:unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?${IDENT}`, "gi"))) {
|
|
74
89
|
// Only the public schema is reachable with the app's public key.
|
|
75
90
|
if ((m[1] || "public").toLowerCase() !== "public") continue;
|
|
76
91
|
const table = m[2].toLowerCase();
|
|
77
|
-
|
|
92
|
+
const at = `${name}:${lineOf(sql, m.index)}`;
|
|
93
|
+
events.push({ i: m.index, run: () => created.has(table) || created.set(table, at) });
|
|
78
94
|
}
|
|
79
95
|
for (const m of sql.matchAll(new RegExp(String.raw`alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?${IDENT}\s+enable\s+row\s+level\s+security`, "gi"))) if ((m[1] || "public").toLowerCase() === "public") protectedTables.add(m[2].toLowerCase());
|
|
80
96
|
// The policy's own name is skipped first: it is free text and often contains the word "on".
|
|
81
|
-
|
|
97
|
+
const policyKey = (schema, table, policy) => `${(schema || "public").toLowerCase()}.${table.toLowerCase()}|${policy.replace(/"/g, "").toLowerCase()}`;
|
|
98
|
+
for (const m of sql.matchAll(new RegExp(String.raw`(?:drop|alter)\s+policy\s+(?:if\s+exists\s+)?("[^"]*"|\w+)\s+on\s+${IDENT}`, "gi"))) {
|
|
99
|
+
const key = policyKey(m[2], m[3], m[1]);
|
|
100
|
+
events.push({ i: m.index, run: () => openPolicies.delete(key) });
|
|
101
|
+
}
|
|
102
|
+
for (const m of sql.matchAll(new RegExp(String.raw`drop\s+table\s+(?:if\s+exists\s+)?${IDENT}`, "gi"))) {
|
|
103
|
+
const gone = `${(m[1] || "public").toLowerCase()}.${m[2].toLowerCase()}|`;
|
|
104
|
+
events.push({ i: m.index, run: () => {
|
|
105
|
+
if ((m[1] || "public").toLowerCase() === "public") created.delete(m[2].toLowerCase());
|
|
106
|
+
for (const k of [...openPolicies.keys()]) if (k.startsWith(gone)) openPolicies.delete(k);
|
|
107
|
+
} });
|
|
108
|
+
}
|
|
109
|
+
for (const full of sql.matchAll(new RegExp(String.raw`create\s+policy\s+("[^"]*"|\w+)\s+on\s+${IDENT}([^;]*);`, "gi"))) {
|
|
110
|
+
const m = [full[0], full[2], full[3], full[4]];
|
|
111
|
+
m.index = full.index;
|
|
112
|
+
const key = policyKey(full[2], full[3], full[1]);
|
|
82
113
|
const rest = m[3];
|
|
83
114
|
if (!/(?:using|with\s+check)\s*\(+\s*true\s*\)+/i.test(rest)) continue;
|
|
84
115
|
// Policies in a private schema open nothing to the app's public key; storage is named in full.
|
|
@@ -90,9 +121,19 @@ export function codeScan(dir = ".") {
|
|
|
90
121
|
const table = schema === "public" ? m[2].toLowerCase() : `${schema}.${m[2].toLowerCase()}`;
|
|
91
122
|
const action = (rest.match(/\bfor\s+(select|insert|update|delete|all)\b/i) || [, "all"])[1].toLowerCase();
|
|
92
123
|
const toAuthed = /authenticated/.test(roles) && !/anon|public/.test(roles);
|
|
93
|
-
const
|
|
94
|
-
|
|
124
|
+
const who = toAuthed ? "every signed-in user" : "everyone";
|
|
125
|
+
const where = `${name}:${lineOf(sql, m.index)}`;
|
|
126
|
+
// Reading a whole table is often meant (products, courses), so those are gathered into one question below.
|
|
127
|
+
if (action === "select") {
|
|
128
|
+
events.push({ i: m.index, run: () => openPolicies.set(key, () => publicRead[who].some((t) => t.table === table) || publicRead[who].push({ table, where })) });
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// Adding rows is right for a contact form, a waitlist or a log. Changing and deleting rarely is.
|
|
132
|
+
const addOnly = action === "insert";
|
|
133
|
+
const finding = { id: `scan:policy-true:${table}:${action}`, severity: addOnly ? "medium" : "high", where, title: `A rule lets ${who} ${action === "all" ? "read, change and delete" : addOnly ? "add" : action} rows in "${table}"`, why: `The policy's condition is simply "true", so Row Level Security is on but checks nothing for this action.${addOnly ? " That is right for a contact form, a waitlist or a log, and a problem if anything in the app trusts what is in this table." : ""}`, fix: "Compare auth.uid() with the row's owner column instead of using true.", first: null, prompt: `In my database, a Row Level Security policy on "${table}" for ${action} uses the condition true, so ${toAuthed ? "any signed-in user" : "anyone"} passes it. ${addOnly ? `Tell me first whether "${table}" is meant to take rows from ${toAuthed ? "any signed-in user" : "strangers"} (a form, a waitlist, a log). If it is, keep it but make sure the new row can't claim to belong to someone else (set the owner column from auth.uid(), never from the request) and can't be flooded. If it isn't, rewrite` : "Rewrite"} it so a user can only ${action === "all" ? "reach" : action} their own rows (auth.uid() = the owner column; add that column if it's missing). Write this as a new migration, don't edit old ones, and show me the SQL.` };
|
|
134
|
+
events.push({ i: m.index, run: () => openPolicies.set(key, () => add(finding)) });
|
|
95
135
|
}
|
|
136
|
+
for (const e of events.sort((a, b) => a.i - b.i)) e.run();
|
|
96
137
|
if (/(^|\/)migrations\//.test(name)) {
|
|
97
138
|
const d = sql.match(/^\s*(drop\s+table|truncate)\b[^;]*;/im);
|
|
98
139
|
if (d) add({ id: `scan:destructive:${name}`, severity: "low", where: `${name}:${lineOf(sql, d.index)}`, title: "A migration deletes data", why: `It contains "${d[0].trim().slice(0, 60)}". Run against the live database, that data is gone unless you have a backup.`, fix: "Make sure a backup exists before this runs on the live database.", first: null, prompt: `My migration ${name} contains a statement that deletes data (${d[1].toLowerCase()}). Tell me exactly what would be lost if it runs on the live database, whether that is intended, and how to back up that data first. Change nothing.` });
|
|
@@ -113,7 +154,9 @@ export function codeScan(dir = ".") {
|
|
|
113
154
|
|
|
114
155
|
if (files.some((f) => /(^|\/)supabase\//.test(rel(f))))
|
|
115
156
|
for (const [table, where] of created)
|
|
116
|
-
if (!protectedTables.has(table))
|
|
157
|
+
if (!protectedTables.has(table) && dynamicRls)
|
|
158
|
+
add({ id: `scan:no-rls:${table}`, severity: "medium", where, title: `Greenlit couldn't see Row Level Security being turned on for "${table}"`, why: "Your migrations switch it on for some tables with a statement built while it runs, and Greenlit can't tell which tables that covers. This one may be protected.", fix: "Check it in Supabase → Advisors → Security Advisor, or run npx greenlitlab <your app> --mine.", first: null, prompt: `Tell me whether Row Level Security is enabled on the table "${table}" in my database, and which statement enables it. Change nothing.` });
|
|
159
|
+
else if (!protectedTables.has(table))
|
|
117
160
|
add({ id: `scan:no-rls:${table}`, severity: "high", where, title: `The table "${table}" is created without Row Level Security`, why: "No migration turns Row Level Security on for it. If the app's public key can reach the table, every row is readable. (If you turned it on in the dashboard instead, the live database may be fine: check with npx greenlitlab <your app> --mine.)", fix: `Add: alter table public.${table} enable row level security; plus a policy for the owner.`, first: null, prompt: `My migrations create the table "${table}" but never enable Row Level Security on it. Write a new migration that enables it and adds policies so a signed-in user reaches only their own rows (auth.uid() = the owner column; add one if needed). If the table is meant to be public to read, say so and add a read-only policy. Show me the SQL.` });
|
|
118
161
|
|
|
119
162
|
try {
|
|
@@ -122,7 +165,20 @@ export function codeScan(dir = ".") {
|
|
|
122
165
|
if (env) add({ id: "scan:env-tracked", severity: "high", where: env, title: `Your ${env} file is saved in version control`, why: "Everyone with access to the repository, now or later, has every key in it. If the repository is public, so does the world.", fix: "Remove it from git, add it to .gitignore, and replace the keys it held.", first: "Replace every key in that file: once committed, a key stays in the history.", prompt: `My ${env} file is tracked by git. Remove it from version control without deleting my local copy (git rm --cached), add it to .gitignore, and give me an .env.example with the names only. Then list every key that was in it so I can replace each one.` });
|
|
123
166
|
} catch {}
|
|
124
167
|
|
|
125
|
-
|
|
168
|
+
for (const emit of openPolicies.values()) emit();
|
|
169
|
+
for (const [who, list] of Object.entries(publicRead)) {
|
|
170
|
+
if (!list.length) continue;
|
|
171
|
+
const names = list.map((t) => t.table);
|
|
172
|
+
add({ id: `scan:public-read:${who === "everyone" ? "everyone" : "signed-in"}`, severity: "medium", where: list[0].where, title: `${list.length} table${list.length > 1 ? "s" : ""} can be read in full by ${who}`, why: `${names.slice(0, 15).join(", ")}${names.length > 15 ? ` and ${names.length - 15} more` : ""}. Each has a policy whose condition is simply "true". That is fine for a public list such as products or courses, and a leak for anything about people.`, fix: "Go through the list: keep the ones that are meant to be public, and limit the rest to the row's owner.", first: null, prompt: `These tables in my database have a read policy with the condition true, so ${who === "everyone" ? "anyone on the internet" : "any signed-in user"} can read every row: ${names.join(", ")}. Go through them one by one and tell me, for each, whether it holds anything about a specific person (names, emails, messages, payments, activity). Change nothing yet. Then list the ones you would restrict to the row's owner, and wait for my OK.` });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// A lockfile only matters when there is something to lock.
|
|
176
|
+
let hasDeps = false;
|
|
177
|
+
try {
|
|
178
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
179
|
+
hasDeps = Object.keys({ ...pkg.dependencies, ...pkg.devDependencies }).length > 0;
|
|
180
|
+
} catch {}
|
|
181
|
+
if (hasDeps && !["package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((f) => fs.existsSync(path.join(root, f))))
|
|
126
182
|
add({ id: "scan:no-lockfile", severity: "low", where: "package.json", title: "No lockfile", why: "Without a lockfile every build may install different versions of your dependencies, so the app you tested isn't the app you ship.", fix: "Commit the lockfile your package manager creates.", first: null, prompt: "My project has no lockfile. Run the install for the package manager this project uses, commit the lockfile it creates, and make the build use it." });
|
|
127
183
|
|
|
128
184
|
const order = ["critical", "high", "medium", "low", "info"];
|
package/src/welcome.mjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// The welcome screen: a signal on green beside a night road, drawn in the terminal with half-block
|
|
2
|
+
// characters, two pixels to a character cell. Shown only to a real terminal that is wide enough; never in
|
|
3
|
+
// pipes, CI, or with NO_COLOR, where the plain help is printed instead.
|
|
4
|
+
|
|
5
|
+
// --- a very small pixel painter ---------------------------------------------------------------------
|
|
6
|
+
const rgb = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
|
|
7
|
+
// 24-bit colour where the terminal says it has it; otherwise the nearest of the 216 colours every terminal has.
|
|
8
|
+
const colour = (hex, layer, truecolor) => {
|
|
9
|
+
const [r, g, b] = rgb(hex);
|
|
10
|
+
if (truecolor) return `${layer};2;${r};${g};${b}`;
|
|
11
|
+
// Near-greys go to the 24-step grey ramp, so a dark grey stays grey instead of turning teal.
|
|
12
|
+
if (Math.max(r, g, b) - Math.min(r, g, b) < 24) return `${layer};5;${232 + Math.max(0, Math.min(23, Math.round(((r + g + b) / 3 - 8) / 10)))}`;
|
|
13
|
+
const q = (v) => (v < 48 ? 0 : v < 115 ? 1 : Math.min(5, Math.round((v - 35) / 40)));
|
|
14
|
+
return `${layer};5;${16 + 36 * q(r) + 6 * q(g) + q(b)}`;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const canvas = (w, h) => Array.from({ length: h }, () => Array(w).fill("."));
|
|
18
|
+
export const blit = (c, sprite, x, y) => {
|
|
19
|
+
sprite.forEach((row, j) => [...row].forEach((ch, i) => ch !== "." && c[y + j]?.[x + i] !== undefined && (c[y + j][x + i] = ch)));
|
|
20
|
+
return c;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Each line of text holds two rows of pixels: the upper half-block takes the top pixel's colour as its
|
|
24
|
+
// foreground and the bottom pixel's as its background.
|
|
25
|
+
export function paint(c, palette, truecolor) {
|
|
26
|
+
const lines = [];
|
|
27
|
+
for (let y = 0; y < c.length; y += 2) {
|
|
28
|
+
let line = "";
|
|
29
|
+
for (let x = 0; x < c[0].length; x++) {
|
|
30
|
+
const top = palette[c[y][x]];
|
|
31
|
+
const bottom = palette[c[y + 1]?.[x]];
|
|
32
|
+
if (!top && !bottom) line += "\x1b[0m ";
|
|
33
|
+
else if (top && bottom) line += `\x1b[0;${colour(top, 38, truecolor)};${colour(bottom, 48, truecolor)}m▀`;
|
|
34
|
+
else if (top) line += `\x1b[0;${colour(top, 38, truecolor)}m▀`;
|
|
35
|
+
else line += `\x1b[0;${colour(bottom, 38, truecolor)}m▄`;
|
|
36
|
+
}
|
|
37
|
+
lines.push(`${line}\x1b[0m`);
|
|
38
|
+
}
|
|
39
|
+
return lines;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const canShow = (stream, env, width) => Boolean(stream.isTTY && !env.NO_COLOR && !env.CI && env.TERM !== "dumb" && (stream.columns ?? 80) >= width);
|
|
43
|
+
|
|
44
|
+
// --- Greenlit's scene -------------------------------------------------------------------------------
|
|
45
|
+
const SIGNAL = [
|
|
46
|
+
"....eeeeee....",
|
|
47
|
+
"...ehhhhhhe...",
|
|
48
|
+
"...hhrrrrhh...",
|
|
49
|
+
"...hrrrrrrh...",
|
|
50
|
+
"...hrrrrrrh...",
|
|
51
|
+
"...hhrrrrhh...",
|
|
52
|
+
"...hhhhhhhh...",
|
|
53
|
+
"...hhaaaahh...",
|
|
54
|
+
"...haaaaaah...",
|
|
55
|
+
"...haaaaaah...",
|
|
56
|
+
"...hhaaaahh...",
|
|
57
|
+
"...hhhhhhhh...",
|
|
58
|
+
"..GhhgggghhG..",
|
|
59
|
+
".GGhgLLggghGG.",
|
|
60
|
+
".GGhgLgggghGG.",
|
|
61
|
+
"..GhhgggghhG..",
|
|
62
|
+
"...hhhhhhhh...",
|
|
63
|
+
"...ehhhhhhe...",
|
|
64
|
+
"....eeppee....",
|
|
65
|
+
"......pp......",
|
|
66
|
+
"......pp......",
|
|
67
|
+
"......pp......",
|
|
68
|
+
];
|
|
69
|
+
const PALETTE = { e: "#4a524c", h: "#262b27", r: "#5a2420", a: "#5c4716", g: "#3dff8a", L: "#d6ffe6", G: "#1a7a2e", p: "#3a403b", d: "#2f3430", m: "#6c726e", s: "#8b918d", S: "#f1f3f1" };
|
|
70
|
+
|
|
71
|
+
export function scene() {
|
|
72
|
+
const c = canvas(26, 24);
|
|
73
|
+
blit(c, SIGNAL, 1, 0);
|
|
74
|
+
// The road: a kerb line and lane dashes running away to the right.
|
|
75
|
+
for (let x = 0; x < 26; x++) c[22][x] = "d";
|
|
76
|
+
for (const x of [15, 16, 17, 21, 22]) c[23][x] = "m";
|
|
77
|
+
// A few stars, one of them bright.
|
|
78
|
+
for (const [x, y, ch] of [[18, 2, "s"], [23, 5, "S"], [16, 9, "s"], [21, 13, "s"], [24, 17, "s"], [17, 18, "s"]]) c[y][x] = ch;
|
|
79
|
+
return c;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function welcome({ version = "", stream = process.stdout, env = process.env } = {}) {
|
|
83
|
+
if (!canShow(stream, env, 90)) return "";
|
|
84
|
+
const truecolor = /truecolor|24bit/i.test(env.COLORTERM ?? "");
|
|
85
|
+
const art = paint(scene(), PALETTE, truecolor);
|
|
86
|
+
// The words use the terminal's own text colours, so they read on a dark or a light background.
|
|
87
|
+
const off = "\x1b[0m", bold = "\x1b[1m", faint = "\x1b[2m", go = "\x1b[32m";
|
|
88
|
+
const cmd = (c, note) => `${go}$${off} ${c}${" ".repeat(Math.max(2, 34 - c.length))}${faint}${note}${off}`;
|
|
89
|
+
const text = {
|
|
90
|
+
2: `${bold}greenl${go}i${off}${bold}t${off}${version ? ` ${faint}v${version}${off}` : ""}`,
|
|
91
|
+
3: "Know it's safe before you launch.",
|
|
92
|
+
5: cmd("npx greenlitlab myapp.lovable.app", "grade your app"),
|
|
93
|
+
6: cmd("npx greenlitlab <url> --mine", "your own app, deeper"),
|
|
94
|
+
7: cmd("npx greenlitlab scan", "your project's files"),
|
|
95
|
+
8: cmd("npx greenlitlab questions", "what only you know"),
|
|
96
|
+
10: `${faint}--help for everything · greenlit.priberry.com${off}`,
|
|
97
|
+
};
|
|
98
|
+
return ["", ...art.map((line, i) => ` ${line} ${text[i] ?? ""}`.trimEnd()), ""].join("\n") + "\n";
|
|
99
|
+
}
|