@grove-dev/astro 0.2.20 → 0.3.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/LICENSE +21 -0
- package/dist/template-routes.test.d.ts +2 -0
- package/dist/template-routes.test.d.ts.map +1 -0
- package/dist/template-routes.test.js +63 -0
- package/dist/template-routes.test.js.map +1 -0
- package/dist/theme.test.js +5 -0
- package/dist/theme.test.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Icon.astro +52 -22
- package/src/template-routes.test.ts +103 -0
- package/src/theme.test.ts +9 -0
- package/templates/default/.github/workflows/build.yml +1 -3
- package/templates/default/.github/workflows/cleanup-stale-records.yml +1 -3
- package/templates/default/.github/workflows/daily-refresh.yml +1 -3
- package/templates/default/.github/workflows/sync-contributors.yml +2 -4
- package/templates/default/.github/workflows/sync-github-metadata.yml +1 -3
- package/templates/default/.github/workflows/validate-data.yml +1 -3
- package/templates/default/grove.config.ts +1 -1
- package/templates/default/package.json +9 -4
- package/templates/default/public/llms-full.txt +63 -186
- package/templates/default/public/llms.txt +6 -107
- package/templates/default/public/sitemap.xml +10 -10
- package/templates/default/src/data/records.ts +80 -2
- package/templates/default/src/pages/[slug]/[recordSlug].astro +9 -7
- package/templates/default/src/pages/[slug]/index.astro +215 -11
- package/templates/default/src/pages/about.astro +8 -1
- package/templates/default/src/pages/apps/[recordSlug].astro +2 -1
- package/templates/default/src/pages/index.astro +11 -3
- package/templates/default/src/pages/sitemap.xml.ts +3 -3
- package/templates/default/src/pages/submit.astro +5 -5
- package/templates/default/tsconfig.json +9 -0
- package/templates/default/scripts/build-llms.mjs +0 -123
- package/templates/default/scripts/build-records-json.mjs +0 -27
- package/templates/default/scripts/build-sitemap.mjs +0 -20
- package/templates/default/scripts/cleanup-stale-records.mjs +0 -20
- package/templates/default/scripts/enrich-github-metadata.mjs +0 -99
- package/templates/default/scripts/fetch-icons.mjs +0 -137
- package/templates/default/scripts/migrate-legacy-to-schema-v1.mjs +0 -86
- package/templates/default/scripts/parse-legacy-readme.mjs +0 -59
- package/templates/default/scripts/refresh-records-activity.mjs +0 -24
- package/templates/default/scripts/repair-license-format.mjs +0 -72
- package/templates/default/scripts/report-cleanup-candidates.mjs +0 -21
- package/templates/default/scripts/seed-from-github.mjs +0 -62
- package/templates/default/scripts/sync-contributors.mjs +0 -145
- package/templates/default/scripts/sync-github-metadata.mjs +0 -28
- package/templates/default/scripts/validate-records.mjs +0 -27
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* sync-contributors — fetch contributors for every record's repoUrl
|
|
4
|
-
* and write `data/generated/contributors.json` (consumed by the home
|
|
5
|
-
* page and the /contributors page).
|
|
6
|
-
*
|
|
7
|
-
* Generic: walks every record in data/generated/records.index.json,
|
|
8
|
-
* looks at record.github.fullName or links.github, and calls the
|
|
9
|
-
* GitHub /repos/{owner}/{repo}/contributors endpoint. Aggregates by
|
|
10
|
-
* owner (across all of an owner's projects in the directory).
|
|
11
|
-
*
|
|
12
|
-
* Anonymous contributors are excluded — the home grid renders <a>
|
|
13
|
-
* avatars, and a name-less contributor is more confusing than
|
|
14
|
-
* missing.
|
|
15
|
-
*
|
|
16
|
-
* Usage: node scripts/sync-contributors.mjs
|
|
17
|
-
* Env: GH_TOKEN — required for >60 req/h. Falls back to unauth.
|
|
18
|
-
*
|
|
19
|
-
* V1 intentionally small: no retries, no rate-limit backoff beyond
|
|
20
|
-
* the basic 403-detection. The weekly schedule in
|
|
21
|
-
* .github/workflows/sync-contributors.yml is loose enough that
|
|
22
|
-
* re-running the workflow is a fine recovery path.
|
|
23
|
-
*/
|
|
24
|
-
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
25
|
-
import { dirname, resolve } from "node:path";
|
|
26
|
-
|
|
27
|
-
const HERE = new URL(".", import.meta.url).pathname;
|
|
28
|
-
const ROOT = resolve(HERE, "..");
|
|
29
|
-
const GENERATED = resolve(ROOT, "data", "generated");
|
|
30
|
-
const INDEX_PATH = resolve(GENERATED, "records.index.json");
|
|
31
|
-
const OUT_PATH = resolve(GENERATED, "contributors.json");
|
|
32
|
-
|
|
33
|
-
const GH_TOKEN = process.env.GH_TOKEN || process.env.GITHUB_TOKEN || "";
|
|
34
|
-
const HEADERS = {
|
|
35
|
-
Accept: "application/vnd.github+json",
|
|
36
|
-
"User-Agent": "grove-sync-contributors",
|
|
37
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
38
|
-
...(GH_TOKEN ? { Authorization: `Bearer ${GH_TOKEN}` } : {}),
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
function ownerRepoFromFullName(fullName) {
|
|
42
|
-
if (!fullName || !fullName.includes("/")) return null;
|
|
43
|
-
const [owner, repo] = fullName.split("/", 2);
|
|
44
|
-
return { owner, repo };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function ghJson(url) {
|
|
48
|
-
const res = await fetch(url, { headers: HEADERS });
|
|
49
|
-
if (res.status === 204) return null;
|
|
50
|
-
if (res.status === 403) {
|
|
51
|
-
const remaining = res.headers.get("x-ratelimit-remaining");
|
|
52
|
-
if (remaining === "0") {
|
|
53
|
-
throw new Error(`rate-limited (403) on ${url}`);
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
if (res.status === 404) return null;
|
|
58
|
-
if (!res.ok) throw new Error(`HTTP ${res.status} on ${url}`);
|
|
59
|
-
return res.json();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function fetchContributorsForRepo(owner, repo) {
|
|
63
|
-
// GitHub caps /contributors at 500; for our purposes (fanning into
|
|
64
|
-
// a home grid) we only need the first page. Anonymous entries
|
|
65
|
-
// (no `login`) are dropped at parse time.
|
|
66
|
-
const url = `https://api.github.com/repos/${owner}/${repo}/contributors?per_page=100&anon=false`;
|
|
67
|
-
const data = await ghJson(url);
|
|
68
|
-
if (!Array.isArray(data)) return [];
|
|
69
|
-
return data
|
|
70
|
-
.filter((c) => c && c.login)
|
|
71
|
-
.map((c) => ({
|
|
72
|
-
username: c.login,
|
|
73
|
-
avatarUrl: c.avatar_url,
|
|
74
|
-
profileUrl: c.html_url,
|
|
75
|
-
contributions: c.contributions ?? 0,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function main() {
|
|
80
|
-
let index;
|
|
81
|
-
try {
|
|
82
|
-
index = JSON.parse(await readFile(INDEX_PATH, "utf8"));
|
|
83
|
-
} catch (err) {
|
|
84
|
-
console.error(`Could not read ${INDEX_PATH}: ${err.message}`);
|
|
85
|
-
console.error("Run `pnpm run build:data` first.");
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const records = Array.isArray(index.records) ? index.records : [];
|
|
90
|
-
// Group by owner — a single person with three projects in the
|
|
91
|
-
// directory shows up once with the summed contribution count.
|
|
92
|
-
const byOwner = new Map();
|
|
93
|
-
const seenRepos = new Set();
|
|
94
|
-
|
|
95
|
-
for (const r of records) {
|
|
96
|
-
const gh = r.github || {};
|
|
97
|
-
const ref = ownerRepoFromFullName(gh.fullName) || (() => {
|
|
98
|
-
const url = r.repoUrl || (r.links && r.links.github) || "";
|
|
99
|
-
const m = /github\.com\/([^/]+)\/([^/?#]+)/.exec(url);
|
|
100
|
-
return m ? { owner: m[1], repo: m[2].replace(/\.git$/, "") } : null;
|
|
101
|
-
})();
|
|
102
|
-
if (!ref) continue;
|
|
103
|
-
if (seenRepos.has(`${ref.owner}/${ref.repo}`)) continue;
|
|
104
|
-
seenRepos.add(`${ref.owner}/${ref.repo}`);
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
const list = await fetchContributorsForRepo(ref.owner, ref.repo);
|
|
108
|
-
for (const c of list) {
|
|
109
|
-
const existing = byOwner.get(c.username);
|
|
110
|
-
if (existing) {
|
|
111
|
-
existing.contributions = (existing.contributions ?? 0) + c.contributions;
|
|
112
|
-
} else {
|
|
113
|
-
byOwner.set(c.username, c);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
console.log(` ${ref.owner}/${ref.repo}: ${list.length} contributors`);
|
|
117
|
-
} catch (err) {
|
|
118
|
-
console.warn(` ${ref.owner}/${ref.repo}: ${err.message}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const contributors = [...byOwner.values()].sort(
|
|
123
|
-
(a, b) => (b.contributions ?? 0) - (a.contributions ?? 0),
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
await mkdir(dirname(OUT_PATH), { recursive: true });
|
|
127
|
-
await writeFile(
|
|
128
|
-
OUT_PATH,
|
|
129
|
-
JSON.stringify(
|
|
130
|
-
{
|
|
131
|
-
generatedAt: new Date().toISOString(),
|
|
132
|
-
contributors,
|
|
133
|
-
},
|
|
134
|
-
null,
|
|
135
|
-
2,
|
|
136
|
-
),
|
|
137
|
-
"utf8",
|
|
138
|
-
);
|
|
139
|
-
console.log(`\nWrote ${contributors.length} contributors → ${OUT_PATH}`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
main().catch((err) => {
|
|
143
|
-
console.error(err.stack || err.message);
|
|
144
|
-
process.exit(1);
|
|
145
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* sync-github-metadata.mjs — full metadata sync from GitHub's
|
|
6
|
-
* REST API. Wrapper around `@grove-dev/cli sync github`.
|
|
7
|
-
*
|
|
8
|
-
* Refreshes stargazers_count, forks_count, license, default branch,
|
|
9
|
-
* pushed_at, language, topics, and the contributor list for every
|
|
10
|
-
* record whose `repoUrl` is a GitHub repository.
|
|
11
|
-
*
|
|
12
|
-
* Writes back into the corresponding `data/records/<slug>.yml` (the
|
|
13
|
-
* CLI is conservative — only fills in fields that are currently
|
|
14
|
-
* empty).
|
|
15
|
-
*/
|
|
16
|
-
import { spawnSync } from "node:child_process";
|
|
17
|
-
|
|
18
|
-
const result = spawnSync("grove", ["sync", "github"], {
|
|
19
|
-
stdio: "inherit",
|
|
20
|
-
env: process.env,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (result.error) {
|
|
24
|
-
console.error("Failed to spawn `grove sync github`:", result.error.message);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
process.exit(result.status ?? 0);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* validate-records.mjs — Zod-schema validation for every record yml.
|
|
6
|
-
*
|
|
7
|
-
* Thin wrapper around `@grove-dev/cli`'s `validate` command so the
|
|
8
|
-
* `pnpm run validate:data` script works without V0 command names.
|
|
9
|
-
*
|
|
10
|
-
* For schema authoring see `packages/core/src/schema.ts`. The CLI
|
|
11
|
-
* handles every blueprint (project-directory, resource-hub,
|
|
12
|
-
* ecosystem-map) and every record kind (project, resource, entity).
|
|
13
|
-
*/
|
|
14
|
-
import { spawnSync } from "node:child_process";
|
|
15
|
-
|
|
16
|
-
const result = spawnSync("grove", ["validate"], {
|
|
17
|
-
stdio: "inherit",
|
|
18
|
-
env: process.env,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (result.error) {
|
|
22
|
-
console.error("Failed to spawn `grove validate`:", result.error.message);
|
|
23
|
-
console.error("Make sure `@grove-dev/cli` is installed and on PATH.");
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
process.exit(result.status ?? 0);
|