@jonandev/longbeard 0.11.2 → 0.12.1
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/AGENTS.md +4 -5
- package/CHANGELOG.md +72 -0
- package/README.md +64 -43
- package/beard.json +124 -28
- package/bin/long-beard.js +171 -36
- package/package.json +1 -1
- package/skills/design/SKILL.md +51 -126
- package/skills/design-brief/SKILL.md +146 -0
- package/skills/design-brief/references/graphic.md +59 -0
- package/skills/design-check/SKILL.md +27 -11
- package/skills/design-check/references/design-rules.md +21 -7
- package/skills/design-check/scripts/capture.mjs +121 -37
- package/skills/design-check/scripts/contrast.mjs +23 -9
- package/skills/design-check/scripts/rules.mjs +613 -0
- package/skills/design-check/scripts/screen-contrast.mjs +428 -0
- package/skills/design-check/scripts/tokens.mjs +346 -0
- package/skills/design-content/SKILL.md +118 -0
- package/skills/design-content/scripts/contact-sheet.mjs +259 -0
- package/skills/design-content/scripts/pictures.mjs +197 -0
- package/skills/design-direction/SKILL.md +115 -200
- package/skills/design-direction/references/controls.md +58 -0
- package/skills/{design → design-direction}/references/design-rules.md +21 -7
- package/skills/design-direction/references/five-second.md +47 -0
- package/skills/design-direction/references/full-build.md +19 -0
- package/skills/design-direction/references/graphic.md +35 -0
- package/skills/design-direction/references/grid.md +114 -0
- package/skills/design-direction/references/library.md +75 -0
- package/skills/design-direction/references/screen-template.html +233 -0
- package/skills/design-direction/references/subject.md +33 -0
- package/skills/design-direction/scripts/capture.mjs +121 -37
- package/skills/design-direction/scripts/contact-sheet.mjs +18 -7
- package/skills/design-direction/scripts/fonts.mjs +276 -0
- package/skills/design-direction/scripts/layout-diff.mjs +118 -0
- package/skills/design-direction/scripts/measure.mjs +1728 -0
- package/skills/design-direction/scripts/moodboard.mjs +123 -32
- package/skills/design-direction/scripts/picture-cast.mjs +270 -0
- package/skills/design-direction/scripts/pictures.mjs +197 -0
- package/skills/design-direction/scripts/screen-contrast.mjs +428 -0
- package/skills/design-direction/scripts/sheet.mjs +67 -0
- package/skills/design-direction/scripts/subject-colours.mjs +410 -0
- package/skills/design-families/SKILL.md +138 -0
- package/skills/design-families/scripts/contact-sheet.mjs +259 -0
- package/skills/design-families/scripts/families.mjs +606 -0
- package/skills/design-families/scripts/measure.mjs +1728 -0
- package/skills/design-families/scripts/moodboard.mjs +467 -0
- package/skills/design-families/scripts/tag.mjs +289 -0
- package/skills/design-figma/SKILL.md +69 -0
- package/skills/design-figma/references/graphic.md +26 -0
- package/skills/design-identity/SKILL.md +134 -0
- package/skills/design-identity/references/graphic.md +8 -0
- package/skills/design-identity/references/identity-board.html +140 -0
- package/skills/{design → design-identity}/scripts/capture.mjs +121 -37
- package/skills/design-identity/scripts/colours.mjs +213 -0
- package/skills/design-identity/scripts/contrast.mjs +41 -0
- package/skills/design-identity/scripts/fonts.mjs +276 -0
- package/skills/design-identity/scripts/measure.mjs +1728 -0
- package/skills/design-identity/scripts/sheet.mjs +67 -0
- package/skills/design-identity/scripts/subject-colours.mjs +410 -0
- package/skills/design-moodboard/SKILL.md +184 -0
- package/skills/design-moodboard/references/graphic.md +25 -0
- package/skills/{design-direction → design-moodboard}/references/sources.md +21 -11
- package/skills/design-moodboard/scripts/capture.mjs +893 -0
- package/skills/design-moodboard/scripts/contact-sheet.mjs +259 -0
- package/skills/design-moodboard/scripts/crops.mjs +256 -0
- package/skills/design-moodboard/scripts/dribbble-cards.mjs +418 -0
- package/skills/design-moodboard/scripts/families.mjs +606 -0
- package/skills/design-moodboard/scripts/group.mjs +221 -0
- package/skills/design-moodboard/scripts/measure.mjs +1728 -0
- package/skills/design-moodboard/scripts/moodboard.mjs +467 -0
- package/skills/{design-direction → design-moodboard}/scripts/picker.mjs +121 -20
- package/skills/design-moodboard/scripts/pictures.mjs +197 -0
- package/skills/design-moodboard/scripts/tag.mjs +289 -0
- package/skills/design-prototype/SKILL.md +149 -0
- package/skills/design-prototype/references/design-md-template.md +82 -0
- package/skills/design-prototype/references/design-rules.md +203 -0
- package/skills/design-prototype/references/five-second.md +47 -0
- package/skills/design-prototype/references/graphic.md +27 -0
- package/skills/design-prototype/scripts/capture.mjs +893 -0
- package/skills/design-prototype/scripts/contrast.mjs +41 -0
- package/skills/design-prototype/scripts/links.mjs +308 -0
- package/skills/design-prototype/scripts/pictures.mjs +197 -0
- package/skills/design-prototype/scripts/rules.mjs +613 -0
- package/skills/design-prototype/scripts/screen-contrast.mjs +428 -0
- package/skills/design-prototype/scripts/sheet.mjs +67 -0
- package/skills/design-prototype/scripts/tokens.mjs +346 -0
- package/skills/design-wordmark/SKILL.md +65 -0
- package/skills/design-wordmark/scripts/capture.mjs +893 -0
- package/skills/design-wordmark/scripts/sheet.mjs +67 -0
- package/skills/framework-skills/SKILL.md +71 -0
- package/skills/idea/SKILL.md +13 -7
- package/skills/idea/references/graphic.md +64 -0
- package/skills/design/references/design-md-template.md +0 -58
- package/skills/design/scripts/contrast.mjs +0 -27
- package/skills/design-direction/scripts/dribbble-cards.mjs +0 -356
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// List Dribbble search/popular cards from a listing URL.
|
|
3
|
-
// Headless Chrome; prints TSV: id-slug\tlikes\tviews\tdesigner\timageURL\ttitle
|
|
4
|
-
// Counts come from the card's own stat elements. A column it cannot read
|
|
5
|
-
// stays empty. It never guesses a count from the title.
|
|
6
|
-
//
|
|
7
|
-
// Dribbble's "popular" order mixes likes with recency, so page order is not
|
|
8
|
-
// quality. Rows come out sorted by likes, most first, and a card under
|
|
9
|
-
// --min-likes (default 100) is dropped. A card whose likes cannot be read
|
|
10
|
-
// is kept, last.
|
|
11
|
-
//
|
|
12
|
-
// Off-topic cards (merch, resumes, worksheets, posters) are dropped by slug
|
|
13
|
-
// and title before anything is fetched, and the noise rate goes to stderr.
|
|
14
|
-
//
|
|
15
|
-
// node dribbble-cards.mjs "https://dribbble.com/search/shots/popular/product-design?q=writing+app&timeframe=year" --scrolls 4
|
|
16
|
-
// node dribbble-cards.mjs "<url>" --drop "mood,habit" --keep "font,illustration"
|
|
17
|
-
// node dribbble-cards.mjs "<url>" --min-likes 300
|
|
18
|
-
// node dribbble-cards.mjs "<url>" --picker >> candidates.tsv # rows for picker.mjs
|
|
19
|
-
import { spawn } from "node:child_process";
|
|
20
|
-
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
21
|
-
import { tmpdir } from "node:os";
|
|
22
|
-
import { join } from "node:path";
|
|
23
|
-
|
|
24
|
-
const args = process.argv.slice(2);
|
|
25
|
-
const flag = (name, def) => {
|
|
26
|
-
const i = args.indexOf(`--${name}`);
|
|
27
|
-
if (i === -1) return def;
|
|
28
|
-
const v = args[i + 1];
|
|
29
|
-
args.splice(i, 2);
|
|
30
|
-
return v;
|
|
31
|
-
};
|
|
32
|
-
const has = (name) => {
|
|
33
|
-
const i = args.indexOf(`--${name}`);
|
|
34
|
-
if (i === -1) return false;
|
|
35
|
-
args.splice(i, 1);
|
|
36
|
-
return true;
|
|
37
|
-
};
|
|
38
|
-
const url = args[0];
|
|
39
|
-
const scrolls = Math.max(0, Number(flag("scrolls", "3")) || 3);
|
|
40
|
-
const noFilter = has("no-filter");
|
|
41
|
-
const forPicker = has("picker");
|
|
42
|
-
const minLikes = Math.max(0, Number(flag("min-likes", "100")) || 0);
|
|
43
|
-
const words = (s) =>
|
|
44
|
-
String(s || "")
|
|
45
|
-
.toLowerCase()
|
|
46
|
-
.split(",")
|
|
47
|
-
.map((w) => w.trim())
|
|
48
|
-
.filter(Boolean);
|
|
49
|
-
// The shared negative list. These sell the word, not the form: a search for
|
|
50
|
-
// "writing app" returns tees, CV services and tracing worksheets.
|
|
51
|
-
const OFF_TOPIC = [
|
|
52
|
-
"t-shirt", "tshirt", "tee", "merch", "apparel", "hoodie",
|
|
53
|
-
"resume", "cv", "cover letter", "essay",
|
|
54
|
-
"worksheet", "tracing", "handwriting practice", "alphabet",
|
|
55
|
-
"halloween", "christmas", "valentine",
|
|
56
|
-
"logo", "logotype", "branding", "brand identity", "packaging",
|
|
57
|
-
"poster", "book cover", "sticker", "mockup",
|
|
58
|
-
"chatbot", "mood tracker", "habit tracker",
|
|
59
|
-
// "Editor" on Dribbble is mostly code, video, and photo tools and AI products.
|
|
60
|
-
"video editor", "photo editor", "code editor", "ide",
|
|
61
|
-
"agent", "assistant", "copilot", "generator",
|
|
62
|
-
"dashboard", "saas", "crm",
|
|
63
|
-
];
|
|
64
|
-
const keep = words(flag("keep", ""));
|
|
65
|
-
const dropWords = [...OFF_TOPIC.filter((w) => !keep.includes(w)), ...words(flag("drop", ""))];
|
|
66
|
-
if (!url || !/^https?:\/\/(www\.)?dribbble\.com\//i.test(url)) {
|
|
67
|
-
console.error(
|
|
68
|
-
'usage: node dribbble-cards.mjs "https://dribbble.com/search/..." [--scrolls 4] [--min-likes 100] [--drop "a,b"] [--keep "a,b"] [--no-filter] [--picker]',
|
|
69
|
-
);
|
|
70
|
-
process.exit(2);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Whole words only, so "ai" does not swallow "detail" and "cv" does not
|
|
74
|
-
// swallow "cvs". A hyphen in a slug counts as a space.
|
|
75
|
-
function offTopic(text) {
|
|
76
|
-
const hay = ` ${String(text).toLowerCase().replace(/[^a-z0-9]+/g, " ").trim()} `;
|
|
77
|
-
return dropWords.find((word) => hay.includes(` ${word.replace(/[^a-z0-9]+/g, " ")} `)) || "";
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// "15.7k" -> 15700. An unreadable count is NaN, never 0.
|
|
81
|
-
function count(text) {
|
|
82
|
-
const m = String(text || "").replace(/,/g, "").match(/^([\d.]+)([kKmM]?)$/);
|
|
83
|
-
if (!m) return NaN;
|
|
84
|
-
const n = Number(m[1]) * ({ k: 1e3, m: 1e6 }[m[2].toLowerCase()] || 1);
|
|
85
|
-
return Number.isFinite(n) ? n : NaN;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function findChrome() {
|
|
89
|
-
const env = process.env.CHROME_PATH;
|
|
90
|
-
if (env && existsSync(env)) return env;
|
|
91
|
-
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
92
|
-
const local = process.env.LOCALAPPDATA || "";
|
|
93
|
-
const pf = process.env.PROGRAMFILES || "C:\\Program Files";
|
|
94
|
-
const pf86 = process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)";
|
|
95
|
-
const candidates = [
|
|
96
|
-
join(pf, "Google/Chrome/Application/chrome.exe"),
|
|
97
|
-
join(pf86, "Google/Chrome/Application/chrome.exe"),
|
|
98
|
-
join(local, "Google/Chrome/Application/chrome.exe"),
|
|
99
|
-
join(pf, "Microsoft/Edge/Application/msedge.exe"),
|
|
100
|
-
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
101
|
-
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
102
|
-
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
103
|
-
join(home, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
|
|
104
|
-
"/usr/bin/google-chrome",
|
|
105
|
-
"/usr/bin/google-chrome-stable",
|
|
106
|
-
"/usr/bin/chromium",
|
|
107
|
-
"/usr/bin/chromium-browser",
|
|
108
|
-
];
|
|
109
|
-
return candidates.find((path) => path && existsSync(path)) || null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
113
|
-
const exe = findChrome();
|
|
114
|
-
if (!exe) {
|
|
115
|
-
console.error("No Chrome/Edge/Chromium found. Install one or set CHROME_PATH.");
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
if (typeof WebSocket === "undefined") {
|
|
119
|
-
console.error("Node 22+ is required.");
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const dir = mkdtempSync(join(tmpdir(), "hunt-dribbble-"));
|
|
124
|
-
let proc;
|
|
125
|
-
const drop = () => {
|
|
126
|
-
try {
|
|
127
|
-
if (proc?.pid) process.kill(proc.pid, "SIGKILL");
|
|
128
|
-
} catch {}
|
|
129
|
-
try {
|
|
130
|
-
rmSync(dir, { recursive: true, force: true });
|
|
131
|
-
} catch {}
|
|
132
|
-
};
|
|
133
|
-
process.once("exit", drop);
|
|
134
|
-
|
|
135
|
-
proc = spawn(
|
|
136
|
-
exe,
|
|
137
|
-
[
|
|
138
|
-
"--headless=new",
|
|
139
|
-
"--remote-debugging-port=0",
|
|
140
|
-
`--user-data-dir=${dir}`,
|
|
141
|
-
"--no-first-run",
|
|
142
|
-
"--hide-scrollbars",
|
|
143
|
-
"--mute-audio",
|
|
144
|
-
"--force-color-profile=srgb",
|
|
145
|
-
"--window-size=1440,900",
|
|
146
|
-
"about:blank",
|
|
147
|
-
],
|
|
148
|
-
{ stdio: ["ignore", "ignore", "pipe"] },
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
let buf = "";
|
|
152
|
-
const wsUrl = await new Promise((resolveWs, reject) => {
|
|
153
|
-
const t = setTimeout(() => reject(new Error("Chrome did not start")), 20000);
|
|
154
|
-
proc.stderr.on("data", (d) => {
|
|
155
|
-
buf += d.toString();
|
|
156
|
-
const m = buf.match(/DevTools listening on (ws:\/\/[^\s]+)/);
|
|
157
|
-
if (m) {
|
|
158
|
-
clearTimeout(t);
|
|
159
|
-
resolveWs(m[1]);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
proc.on("exit", (code) => {
|
|
163
|
-
clearTimeout(t);
|
|
164
|
-
reject(new Error(`Chrome exited ${code}`));
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
const ws = new WebSocket(wsUrl);
|
|
169
|
-
await new Promise((res, rej) => {
|
|
170
|
-
ws.onopen = res;
|
|
171
|
-
ws.onerror = () => rej(new Error("CDP socket failed"));
|
|
172
|
-
});
|
|
173
|
-
let nextId = 1;
|
|
174
|
-
const pending = new Map();
|
|
175
|
-
ws.onmessage = (ev) => {
|
|
176
|
-
const msg = JSON.parse(typeof ev.data === "string" ? ev.data : Buffer.from(ev.data).toString());
|
|
177
|
-
if (msg.id && pending.has(msg.id)) {
|
|
178
|
-
const { resolve: ok, reject: bad } = pending.get(msg.id);
|
|
179
|
-
pending.delete(msg.id);
|
|
180
|
-
if (msg.error) bad(new Error(msg.error.message));
|
|
181
|
-
else ok(msg.result);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
const send = (method, params = {}, sessionId, timeoutMs = 30000) => {
|
|
185
|
-
const id = nextId++;
|
|
186
|
-
return new Promise((resolveSend, reject) => {
|
|
187
|
-
const timer = setTimeout(() => {
|
|
188
|
-
pending.delete(id);
|
|
189
|
-
reject(new Error(`CDP timeout: ${method}`));
|
|
190
|
-
}, timeoutMs);
|
|
191
|
-
pending.set(id, {
|
|
192
|
-
resolve: (v) => {
|
|
193
|
-
clearTimeout(timer);
|
|
194
|
-
resolveSend(v);
|
|
195
|
-
},
|
|
196
|
-
reject: (e) => {
|
|
197
|
-
clearTimeout(timer);
|
|
198
|
-
reject(e);
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
ws.send(JSON.stringify(sessionId ? { id, method, params, sessionId } : { id, method, params }));
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const { targetId } = await send("Target.createTarget", { url: "about:blank" });
|
|
206
|
-
const { sessionId } = await send("Target.attachToTarget", { targetId, flatten: true });
|
|
207
|
-
const page = (method, params, timeoutMs) => send(method, params, sessionId, timeoutMs);
|
|
208
|
-
|
|
209
|
-
await page("Page.enable");
|
|
210
|
-
await page("Runtime.enable");
|
|
211
|
-
await page("Emulation.setDeviceMetricsOverride", {
|
|
212
|
-
width: 1440,
|
|
213
|
-
height: 900,
|
|
214
|
-
deviceScaleFactor: 1,
|
|
215
|
-
mobile: false,
|
|
216
|
-
});
|
|
217
|
-
await page("Page.navigate", { url }, 40000);
|
|
218
|
-
await sleep(3000);
|
|
219
|
-
|
|
220
|
-
for (let i = 0; i < scrolls; i++) {
|
|
221
|
-
await page("Runtime.evaluate", {
|
|
222
|
-
expression: "window.scrollBy(0, Math.round(window.innerHeight * 0.9))",
|
|
223
|
-
returnByValue: true,
|
|
224
|
-
});
|
|
225
|
-
await sleep(900);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const { result } = await page("Runtime.evaluate", {
|
|
229
|
-
expression: `(() => {
|
|
230
|
-
const rows = [];
|
|
231
|
-
const seen = new Set();
|
|
232
|
-
const tidy = (t) => (t || "").replace(/\\s+/g, "");
|
|
233
|
-
const isCount = (t) => /^[\\d][\\d.,]*[kKmM]?$/.test(t);
|
|
234
|
-
const hints = (el) =>
|
|
235
|
-
["aria-label", "title", "class", "data-type", "data-test"]
|
|
236
|
-
.map((name) => el.getAttribute(name) || "")
|
|
237
|
-
.join(" ");
|
|
238
|
-
// A counter labelled as likes or views: its own text, or the one
|
|
239
|
-
// descendant that is nothing but a count.
|
|
240
|
-
const labelled = (li, word) => {
|
|
241
|
-
const re = new RegExp(word, "i");
|
|
242
|
-
for (const el of li.querySelectorAll("*")) {
|
|
243
|
-
if (!re.test(hints(el))) continue;
|
|
244
|
-
const own = tidy(el.textContent);
|
|
245
|
-
if (isCount(own)) return own;
|
|
246
|
-
for (const kid of el.querySelectorAll("*")) {
|
|
247
|
-
const t = tidy(kid.textContent);
|
|
248
|
-
if (isCount(t)) return t;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return "";
|
|
252
|
-
};
|
|
253
|
-
// Fallback: leaf elements whose whole text is a count, in DOM order.
|
|
254
|
-
// Dribbble prints likes first, then views. Free text is never read.
|
|
255
|
-
const leafCounts = (li) => {
|
|
256
|
-
const out = [];
|
|
257
|
-
for (const el of li.querySelectorAll("*")) {
|
|
258
|
-
if (el.children.length) continue;
|
|
259
|
-
const t = tidy(el.textContent);
|
|
260
|
-
if (isCount(t)) out.push(t);
|
|
261
|
-
}
|
|
262
|
-
return out;
|
|
263
|
-
};
|
|
264
|
-
for (const li of document.querySelectorAll("li")) {
|
|
265
|
-
const a = li.querySelector('a[href*="/shots/"]');
|
|
266
|
-
if (!a) continue;
|
|
267
|
-
const m = (a.getAttribute("href") || "").match(/\\/shots\\/([^/?#]+)/);
|
|
268
|
-
if (!m) continue;
|
|
269
|
-
const idSlug = m[1];
|
|
270
|
-
if (seen.has(idSlug)) continue;
|
|
271
|
-
const img = li.querySelector("img");
|
|
272
|
-
if (!img) continue;
|
|
273
|
-
const raw = img.getAttribute("data-src") || img.currentSrc || img.src || "";
|
|
274
|
-
const imageURL = raw.replace(/\\?.*$/, "");
|
|
275
|
-
if (!imageURL) continue;
|
|
276
|
-
seen.add(idSlug);
|
|
277
|
-
let likes = labelled(li, "like");
|
|
278
|
-
let views = labelled(li, "view");
|
|
279
|
-
if (!likes && !views) {
|
|
280
|
-
const counts = leafCounts(li);
|
|
281
|
-
likes = counts[0] || "";
|
|
282
|
-
views = counts[1] || "";
|
|
283
|
-
}
|
|
284
|
-
// The profile handle, from the card's own designer link.
|
|
285
|
-
const who = li.querySelector('.user-information a[href^="/"]');
|
|
286
|
-
const designer = who ? (who.getAttribute("href") || "").replace(/^\\/|[?#].*$/g, "") : "";
|
|
287
|
-
const title = (img.getAttribute("alt") || a.getAttribute("title") || idSlug).replace(/\\t/g, " ").trim();
|
|
288
|
-
rows.push([idSlug, likes, views, designer, imageURL, title].join("\\t"));
|
|
289
|
-
}
|
|
290
|
-
return rows.join("\\n");
|
|
291
|
-
})()`,
|
|
292
|
-
returnByValue: true,
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
const tsv = result?.value || "";
|
|
296
|
-
if (!tsv.trim()) {
|
|
297
|
-
console.error(
|
|
298
|
-
"0 cards (empty listing or rate limit — retry after 8s, then after 30s; if it is still 0, record it under the board's drops as `<query>: 0 cards (rate limit?)`)",
|
|
299
|
-
);
|
|
300
|
-
drop();
|
|
301
|
-
process.exit(1);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const all = tsv.split("\n").filter(Boolean);
|
|
305
|
-
const reasons = new Map();
|
|
306
|
-
const kept = noFilter
|
|
307
|
-
? all
|
|
308
|
-
: all.filter((row) => {
|
|
309
|
-
const [idSlug, , , , , title = ""] = row.split("\t");
|
|
310
|
-
const word = offTopic(`${idSlug} ${title}`);
|
|
311
|
-
if (!word) return true;
|
|
312
|
-
reasons.set(word, (reasons.get(word) ?? 0) + 1);
|
|
313
|
-
return false;
|
|
314
|
-
});
|
|
315
|
-
const cut = all.length - kept.length;
|
|
316
|
-
if (cut > 0) {
|
|
317
|
-
const top = [...reasons.entries()]
|
|
318
|
-
.sort((a, b) => b[1] - a[1])
|
|
319
|
-
.slice(0, 6)
|
|
320
|
-
.map(([word, n]) => `${word} ${n}`)
|
|
321
|
-
.join(", ");
|
|
322
|
-
// The noise rate belongs under the board's drops. A high one means the
|
|
323
|
-
// query is wrong, not that there is more scrolling to do.
|
|
324
|
-
console.error(
|
|
325
|
-
`${kept.length} of ${all.length} cards kept, ${Math.round((cut / all.length) * 100)}% off-topic (${top})`,
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
if (!kept.length) {
|
|
329
|
-
console.error("every card was off-topic — query the form, not the word (add \"ui\", \"screen\", or a category path)");
|
|
330
|
-
drop();
|
|
331
|
-
process.exit(1);
|
|
332
|
-
}
|
|
333
|
-
// Likes are the signal people valued a shot. Sort by them, and drop the
|
|
334
|
-
// ones under the floor. An unreadable count is kept, last, so a markup
|
|
335
|
-
// change shows as empty columns instead of an empty list.
|
|
336
|
-
const likesOf = (row) => count(row.split("\t")[1]);
|
|
337
|
-
const strong = kept.filter((row) => !(likesOf(row) < minLikes));
|
|
338
|
-
const weak = kept.length - strong.length;
|
|
339
|
-
if (weak > 0) {
|
|
340
|
-
console.error(`${weak} of ${kept.length} under ${minLikes} likes, dropped (lower it with --min-likes)`);
|
|
341
|
-
}
|
|
342
|
-
if (!strong.length) {
|
|
343
|
-
console.error("every card was under the likes floor — try a broader form or timeframe before lowering it");
|
|
344
|
-
drop();
|
|
345
|
-
process.exit(1);
|
|
346
|
-
}
|
|
347
|
-
strong.sort((a, b) => (likesOf(b) || -1) - (likesOf(a) || -1));
|
|
348
|
-
// --picker prints picker.mjs rows: title, thumbnail, shot page, source, meta.
|
|
349
|
-
const asPicker = (row) => {
|
|
350
|
-
const [idSlug, likes, , designer, imageURL, title] = row.split("\t");
|
|
351
|
-
const meta = [designer, likes && `${likes} likes`].filter(Boolean).join(" · ");
|
|
352
|
-
return [title, `${imageURL}?resize=400x300`, `https://dribbble.com/shots/${idSlug}`, "dribbble", meta].join("\t");
|
|
353
|
-
};
|
|
354
|
-
console.log((forPicker ? strong.map(asPicker) : strong).join("\n"));
|
|
355
|
-
drop();
|
|
356
|
-
process.exit(0);
|