@grove-dev/cli 0.18.0 → 1.0.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/dist/package.json +1 -1
- package/dist/r/about.json +3 -3
- package/dist/r/browse.json +2 -2
- package/dist/r/collections.json +35 -5
- package/dist/r/contributors.json +3 -3
- package/dist/r/default.json +65 -23
- package/dist/r/home.json +13 -7
- package/dist/r/not-found.json +2 -2
- package/dist/r/project-card.json +4 -4
- package/dist/r/record.json +10 -4
- package/dist/r/registry.json +96 -26
- package/dist/r/shell.json +7 -7
- package/dist/r/submit.json +4 -4
- package/dist/r/taxonomy.json +2 -2
- package/dist/r/ui.json +2 -2
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js +1 -1
- package/package.json +3 -3
package/dist/r/submit.json
CHANGED
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
{
|
|
12
12
|
"path": "default/pages/submit.astro",
|
|
13
|
-
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getSubmissionPageModel } from '@grove-dev/astro/server';\nimport SubmissionClient from '../components/grove/submission-client.astro';\nimport BaseLayout from '../layouts/base-layout.astro';\nimport Container from '../layouts/container.astro';\nimport { buttonClass } from '../lib/classnames.ts';\n\nconst {\n singular,\n title,\n description,\n repoUrl,\n copy,\n fields,\n categories,\n stacks,\n existingSlugs,\n existingFullNames,\n platformOptions,\n licenseOptions,\n taxonomy,\n} = getSubmissionPageModel(siteConfig);\nconst goodSubmissions = [\n ...(copy.good?.length\n ? copy.good\n : [\n `A real, usable ${singular}, not a tutorial or one-screen demo`,\n 'A public repository with a clear open-source license',\n 'Enough documentation to understand, run, or contribute',\n 'Recent maintenance, releases, or meaningful project history',\n ]),\n];\nconst pleaseAvoid = [\n ...(copy.avoid?.length\n ? copy.avoid\n : [\n 'Snippets, exercises, abandoned experiments, or duplicate entries',\n 'Private repositories or projects without source',\n 'Marketing pages with no usable project behind them',\n 'Records with no license or verifiable repository',\n ]),\n];\n---\n\n<BaseLayout title={title} description={description} site={siteConfig} noindex>\n <Container>\n <section class=\"py-10 sm:py-14\">\n <div class=\"max-w-3xl\">\n <p class=\"m-0 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\">\n {copy.eyebrow ?? `${singular} submission`}\n </p>\n <h1 class=\"mt-2 text-[2rem] font-semibold tracking-tight text-ink-900 dark:text-ink-100\">\n {copy.title ?? `Add ${singular === \"app\" ? \"an\" : \"a\"} ${singular} to the directory`}\n </h1>\n <p class=\"m-0 mt-3 max-w-[60ch] text-[0.9375rem] leading-relaxed text-ink-500 dark:text-ink-400\">\n {copy.description ?? `Paste a GitHub URL to pull in the basics, edit the generated draft, then open a pull request. The data stays in this repository.`}\n </p>\n </div>\n\n {/* One compact line, not three cards — on mobile the form\n starts within the first viewport. */}\n <ol class=\"mt-4 flex flex-wrap gap-x-6 gap-y-1.5 text-2xs text-muted-foreground\" aria-label=\"Submission steps\">\n {[\n [\"1\", \"Paste a GitHub URL\"],\n [\"2\", \"Review the draft\"],\n [\"3\", \"Open a pull request\"],\n ].map(([number, heading]) => (\n <li class=\"flex items-center gap-1.5\">\n <span class=\"inline-flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-full border border-border font-mono text-[10px] font-semibold text-foreground\">{number}</span>\n <span class=\"font-medium text-foreground\">{heading}</span>\n </li>\n ))}\n </ol>\n\n <div class=\"mt-8 grid grid-cols-1 items-start gap-6 md:grid-cols-[minmax(0,1fr)_minmax(300px,0.72fr)]\">\n <form id=\"submit-form\" class=\"rounded-[calc(var(--radius)+0.25rem)] border border-ink-200 bg-background p-5 shadow-sm dark:border-ink-800\">\n <div class=\"grid gap-5\">\n <label class=\"grid gap-1.5\">\n <span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">GitHub URL</span>\n <div class=\"flex flex-col gap-2 sm:flex-row\">\n <input id=\"repo-url\" type=\"url\" required placeholder=\"https://github.com/owner/repo\" class=\"min-h-10 flex-1 rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\" />\n <button id=\"fetch-repo\" type=\"button\" class={buttonClass(\"primary\", \"bare\", \"min-h-10 whitespace-nowrap px-3 text-sm\")}>Generate draft</button>\n </div>\n <span class=\"text-2xs text-muted-foreground\">The repository must be public. We never write to it.</span>\n </label>\n\n <div class=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <label class=\"grid gap-1.5\"><span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Name</span><input id=\"item-name\" type=\"text\" class=\"min-h-10 rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\" /></label>\n <label class=\"grid gap-1.5\"><span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Slug</span><input id=\"item-slug\" type=\"text\" class=\"min-h-10 rounded-[var(--radius)] border border-input bg-background px-3 py-2 font-mono text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\" /><span class=\"text-2xs text-muted-foreground\">URL fragment, auto-filled from the repository name.</span></label>\n </div>\n\n <label class=\"grid gap-1.5\">\n <span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Description</span>\n <textarea id=\"item-description\" rows=\"3\" class=\"min-h-10 resize-y rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\"></textarea>\n <span class=\"text-2xs text-muted-foreground\">One or two sentences in plain language.</span>\n </label>\n\n {(fields.category || fields.stack) && <div class:list={[\"grid grid-cols-1 gap-4\", fields.category && fields.stack && \"sm:grid-cols-2\"]}>\n {fields.category && (\n <label class=\"grid gap-1.5\">\n <span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Category</span>\n <select id=\"item-category\" class=\"min-h-10 rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\">\n <option value=\"\">Choose a category</option>\n {categories.map((option) => <option value={option.id}>{option.label}</option>)}\n </select>\n </label>\n )}\n {fields.stack && (\n <label class=\"grid gap-1.5\">\n <span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Primary stack</span>\n <select id=\"primary-stack\" class=\"min-h-10 rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\">\n <option value=\"\">Choose a stack</option>\n {stacks.map((option) => <option value={option.id}>{option.label}</option>)}\n </select>\n </label>\n )}\n </div>}\n\n {fields.platforms && <fieldset class=\"grid gap-2\">\n <legend class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Platforms</legend>\n <div class=\"grid grid-cols-2 gap-2 sm:grid-cols-3\">\n {platformOptions.map((platform) => (\n <label class=\"flex min-h-9 items-center gap-2 rounded-md border border-ink-200 px-2 text-sm dark:border-ink-800\">\n <input type=\"checkbox\" name=\"platform\" value={platform.id} class=\"h-4 w-4\" />\n <span>{platform.label}</span>\n </label>\n ))}\n </div>\n </fieldset>}\n\n {fields.tags && <label class=\"grid gap-1.5\"><span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Tags</span><input id=\"item-tags\" type=\"text\" placeholder=\"self-hosted, developer-tools, offline-first\" class=\"min-h-10 rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\" /></label>}\n\n {fields.license && licenseOptions.length > 0 && (\n <label class=\"grid gap-1.5\">\n <span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">License</span>\n <select id=\"item-license\" class=\"min-h-10 rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\">\n <option value=\"\">Detected from the repository if left empty</option>\n {licenseOptions.map((option) => <option value={option.id}>{option.label}</option>)}\n </select>\n </label>\n )}\n <label class=\"grid gap-1.5\"><span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Website</span><input id=\"item-website\" type=\"url\" placeholder=\"https://example.com\" class=\"min-h-10 rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\" /></label>\n <label class=\"grid gap-1.5\"><span class=\"text-2xs font-medium uppercase tracking-[.05em] text-muted-foreground\">Best for</span><textarea id=\"best-for\" rows=\"3\" class=\"min-h-10 resize-y rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35\" placeholder=\"One use case per line\"></textarea></label>\n </div>\n </form>\n\n <aside class=\"flex flex-col gap-4 md:sticky md:top-24\">\n <div class=\"rounded-[calc(var(--radius)+0.25rem)] border border-border bg-card p-5\">\n <h2 class=\"m-0 text-[0.9375rem] font-semibold text-ink-900 dark:text-ink-100\">Submission criteria</h2>\n <p class=\"m-0 mt-1 text-2xs text-ink-500 dark:text-ink-400\">Use this checklist before opening the draft.</p>\n <div class=\"mt-4 grid grid-cols-1 gap-4 text-2xs sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2\">\n <div>\n <div class=\"font-semibold uppercase tracking-wider text-emerald-700 dark:text-emerald-400\">Good submissions</div>\n <ul class=\"m-0 mt-2 list-none space-y-1 p-0 text-ink-700 dark:text-ink-200\">{goodSubmissions.map((item) => <li class=\"flex gap-2\"><span class=\"text-emerald-600\">✓</span><span>{item}</span></li>)}</ul>\n </div>\n <div>\n <div class=\"font-semibold uppercase tracking-wider text-amber-700 dark:text-amber-400\">Please avoid</div>\n <ul class=\"m-0 mt-2 list-none space-y-1 p-0 text-ink-700 dark:text-ink-200\">{pleaseAvoid.map((item) => <li class=\"flex gap-2\"><span class=\"text-amber-600\">·</span><span>{item}</span></li>)}</ul>\n </div>\n </div>\n </div>\n\n <div class=\"flex min-h-[360px] flex-col rounded-[calc(var(--radius)+0.25rem)] border border-border bg-card p-5\">\n <div class=\"flex flex-wrap items-center justify-between gap-3\">\n <h2 class=\"m-0 text-base font-semibold text-ink-900 dark:text-ink-100\">YAML draft</h2>\n <div class=\"flex items-center gap-2\">\n <button id=\"copy-yaml\" type=\"button\" class={buttonClass(\"secondary\", \"sm\", \"whitespace-nowrap pointer-events-none opacity-50\")} disabled>Copy YAML</button>\n <a id=\"open-pr-link\" href=\"#\" target=\"_blank\" rel=\"noopener noreferrer\" class={buttonClass(\"secondary\", \"sm\", \"whitespace-nowrap pointer-events-none opacity-50\")}>Open PR draft</a>\n </div>\n </div>\n <pre class=\"mt-4 min-h-0 flex-1 overflow-auto rounded-md border border-ink-200 bg-ink-50 p-3 text-xs leading-relaxed text-ink-800 dark:border-ink-800 dark:bg-ink-900/60 dark:text-ink-200\"><code id=\"yaml-preview\">Paste a GitHub URL to generate a draft.</code></pre>\n <p id=\"submit-status\" class=\"mt-3 min-h-5 text-2xs text-ink-500 dark:text-ink-400\" aria-live=\"polite\"></p>\n </div>\n </aside>\n </div>\n </section>\n </Container>\n\n <SubmissionClient\n existingSlugs={existingSlugs}\n existingFullNames={existingFullNames}\n repoUrl={repoUrl}\n fields={fields}\n taxonomy={taxonomy}\n />\n</BaseLayout>\n",
|
|
13
|
+
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getSubmissionPageModel } from '@grove-dev/astro/server';\nimport SubmissionClient from '../components/grove/submission-client.astro';\nimport BaseLayout from '../layouts/base-layout.astro';\nimport Container from '../layouts/container.astro';\nimport { buttonClass } from '../lib/classnames.ts';\n\nconst {\n singular,\n title,\n description,\n repoUrl,\n copy,\n fields,\n categories,\n stacks,\n existingSlugs,\n existingFullNames,\n platformOptions,\n licenseOptions,\n taxonomy,\n} = getSubmissionPageModel(siteConfig);\nconst goodSubmissions = [\n ...(copy.good?.length\n ? copy.good\n : [\n `A real, usable ${singular}, not a tutorial or one-screen demo`,\n 'A public repository with a clear open-source license',\n 'Enough documentation to understand, run, or contribute',\n 'Recent maintenance, releases, or meaningful project history',\n ]),\n];\nconst pleaseAvoid = [\n ...(copy.avoid?.length\n ? copy.avoid\n : [\n 'Snippets, exercises, abandoned experiments, or duplicate entries',\n 'Private repositories or projects without source',\n 'Marketing pages with no usable project behind them',\n 'Records with no license or verifiable repository',\n ]),\n];\n\n// Shared control styling.\nconst control =\n 'min-h-10 w-full rounded-[var(--radius)] border border-input bg-background px-3 py-2 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/35';\nconst labelText = 'text-sm font-medium text-foreground';\nconst hint = 'text-2xs leading-relaxed text-muted-foreground';\nconst steps = [\n { id: 'repo', title: 'Repository', text: 'Paste the GitHub URL' },\n { id: 'details', title: 'Details', text: 'Say what it is and who it is for' },\n { id: 'review', title: 'Open the pull request', text: 'Check the preview, open one PR' },\n];\n---\n\n<BaseLayout\n title={title}\n description={description}\n noindex\n site={siteConfig}\n submitHref=\"/submit\"\n>\n <div class=\"border-b border-border bg-surface-sunken/60\">\n <Container>\n <section class=\"py-10 sm:py-14\">\n <p class=\"m-0 text-2xs font-semibold uppercase tracking-wider text-muted-foreground\">\n {copy.eyebrow ?? `${singular} submission`}\n </p>\n <h1 class=\"m-0 mt-2 text-[2rem] font-semibold leading-tight tracking-tight text-foreground sm:text-[2.5rem]\">\n {copy.title ?? `Add ${singular === \"app\" ? \"an\" : \"a\"} ${singular} to the directory`}\n </h1>\n <p class=\"m-0 mt-3 max-w-[62ch] text-[1rem] leading-relaxed text-muted-foreground\">\n {copy.description ?? description}\n </p>\n <ul class=\"m-0 mt-5 flex list-none flex-wrap gap-2 p-0 text-2xs\">\n {[\"No account on this site\", \"Reviewed by a person\", \"Credited on the page\", \"README badge for maintainers\"].map((item) => (\n <li class=\"inline-flex items-center gap-1.5 rounded-full border border-border bg-background px-2.5 py-1 font-medium text-foreground\">\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-success\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\" /></svg>\n {item}\n </li>\n ))}\n </ul>\n\n <ol id=\"submit-steps\" class=\"m-0 mt-8 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-3\" aria-label=\"Submission steps\">\n {steps.map((step, i) => (\n <li data-step={step.id} data-state={i === 0 ? \"current\" : \"todo\"} class=\"group flex items-center gap-3 rounded-[var(--radius-lg)] border border-border bg-background px-3 py-2.5 data-[state=current]:border-foreground data-[state=done]:border-success/50\">\n <span class=\"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border text-xs font-semibold tabular-nums text-muted-foreground group-data-[state=current]:border-foreground group-data-[state=current]:bg-foreground group-data-[state=current]:text-background group-data-[state=done]:border-success group-data-[state=done]:bg-success group-data-[state=done]:text-background\">\n <span class=\"group-data-[state=done]:hidden\">{i + 1}</span>\n <svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" aria-hidden=\"true\" fill=\"currentColor\" class=\"hidden group-data-[state=done]:block\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\" /></svg>\n </span>\n <span class=\"min-w-0\">\n <span class=\"block text-sm font-semibold text-foreground\">{step.title}</span>\n <span class=\"block truncate text-2xs text-muted-foreground\">{step.text}</span>\n </span>\n </li>\n ))}\n </ol>\n </section>\n </Container>\n </div>\n\n <Container>\n <div class=\"grid grid-cols-1 items-start gap-6 py-8 sm:py-10 lg:grid-cols-[minmax(0,1fr)_minmax(320px,0.8fr)]\">\n <form id=\"submit-form\" class=\"grid gap-6\" novalidate>\n {/* ── 1. Repository ───────────────────────────── */}\n <section aria-labelledby=\"step-repo\" class=\"rounded-[var(--radius-lg)] border border-border bg-card p-5 sm:p-6\">\n <h2 id=\"step-repo\" class=\"m-0 flex items-center gap-2 text-[1.0625rem] font-semibold text-foreground\">\n <span class=\"text-muted-foreground\">1.</span> Repository\n </h2>\n <label class=\"mt-4 grid gap-1.5\">\n <span class={labelText}>GitHub URL</span>\n <div class=\"flex flex-col gap-2 sm:flex-row\">\n <input id=\"repo-url\" type=\"url\" required autocomplete=\"off\" placeholder=\"https://github.com/owner/repo\" class={`${control} min-h-11 text-[0.9375rem] sm:flex-1`} />\n <button id=\"fetch-repo\" type=\"button\" class={buttonClass(\"primary\", \"bare\", \"min-h-11 whitespace-nowrap px-4 text-sm\")}>Fetch details</button>\n </div>\n <span class={hint}>Public repositories only. We read it from the GitHub API and never write to it.</span>\n </label>\n <div id=\"repo-card\" hidden class=\"mt-4 flex items-start gap-3 rounded-[var(--radius)] border border-border bg-background p-3\">\n <img id=\"repo-avatar\" src=\"data:,\" alt=\"\" width=\"40\" height=\"40\" class=\"h-10 w-10 shrink-0 rounded-lg border border-border object-cover\" />\n <div class=\"min-w-0 flex-1\">\n <p id=\"repo-name\" class=\"m-0 truncate text-sm font-semibold text-foreground\"></p>\n <p id=\"repo-description\" class=\"m-0 mt-0.5 line-clamp-2 text-2xs text-muted-foreground\"></p>\n <p id=\"repo-facts\" class=\"m-0 mt-1.5 flex flex-wrap gap-x-3 text-2xs text-muted-foreground\"></p>\n </div>\n </div>\n </section>\n\n {/* ── 2. Details ──────────────────────────────── */}\n <section aria-labelledby=\"step-details\" class=\"rounded-[var(--radius-lg)] border border-border bg-card p-5 sm:p-6\">\n <h2 id=\"step-details\" class=\"m-0 flex items-center gap-2 text-[1.0625rem] font-semibold text-foreground\">\n <span class=\"text-muted-foreground\">2.</span> About the {singular}\n </h2>\n <p class=\"m-0 mt-1 text-2xs text-muted-foreground\">Filled from GitHub where possible — edit anything that reads like a README.</p>\n\n <div class=\"mt-5 grid gap-5\">\n <div class=\"grid grid-cols-1 items-start gap-4 sm:grid-cols-[minmax(0,1fr)_14rem]\">\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Name</span>\n <input id=\"item-name\" type=\"text\" class={control} />\n </label>\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Page address</span>\n <input id=\"item-slug\" type=\"text\" class={`${control} font-mono`} />\n <span class={hint}>The last part of the page URL — from the repo name.</span>\n </label>\n </div>\n\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Description</span>\n <textarea id=\"item-description\" rows=\"3\" class={`${control} resize-y`}></textarea>\n <span class={hint}>One or two plain sentences: what it is and who it is for. At least 40 characters.</span>\n </label>\n\n {(fields.category || fields.stack) && (\n <div class:list={[\"grid grid-cols-1 gap-4\", fields.category && fields.stack && \"sm:grid-cols-2\"]}>\n {fields.category && (\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Category</span>\n <select id=\"item-category\" class={control}>\n <option value=\"\">Choose a category</option>\n {categories.map((option) => <option value={option.id}>{option.label}</option>)}\n </select>\n </label>\n )}\n {fields.stack && (\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Primary stack</span>\n <select id=\"primary-stack\" class={control}>\n <option value=\"\">Choose a stack</option>\n {stacks.map((option) => <option value={option.id}>{option.label}</option>)}\n </select>\n </label>\n )}\n </div>\n )}\n\n {fields.platforms && (\n <fieldset class=\"m-0 grid gap-2 border-0 p-0\">\n <legend class={`${labelText} mb-2`}>Platforms</legend>\n <div class=\"flex flex-wrap gap-2\">\n {platformOptions.map((platform) => (\n <label class=\"inline-flex min-h-9 cursor-pointer items-center gap-2 rounded-full border border-border px-3 text-sm text-foreground has-[:checked]:border-foreground has-[:checked]:bg-foreground has-[:checked]:text-background\">\n <input type=\"checkbox\" name=\"platform\" value={platform.id} class=\"sr-only\" />\n <span>{platform.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n )}\n\n\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Your GitHub username <span class=\"font-normal text-muted-foreground\">(recommended)</span></span>\n <div class=\"flex items-center gap-2\">\n <span class=\"text-sm text-muted-foreground\">@</span>\n <input id=\"submitted-by\" type=\"text\" autocomplete=\"username\" spellcheck=\"false\" placeholder=\"octocat\" class={`${control} max-w-xs`} />\n </div>\n <span class={hint}>Shown as “Submitted by @you” on the page and on the contributors page.</span>\n </label>\n\n <details class=\"group rounded-[var(--radius)] border border-border bg-background\">\n <summary class=\"flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-medium text-foreground [&::-webkit-details-marker]:hidden\">\n <span>Add more detail <span class=\"font-normal text-muted-foreground\">— optional: tags, licence, website, who it is for</span></span>\n <span aria-hidden=\"true\" class=\"text-muted-foreground transition-transform group-open:rotate-45\">+</span>\n </summary>\n <div class=\"grid gap-5 border-t border-border px-4 pb-5 pt-4\">\n {fields.tags && (\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Tags</span>\n <input id=\"item-tags\" type=\"text\" placeholder=\"self-hosted, developer-tools, offline-first\" class={control} />\n <span class={hint}>Comma-separated. Pre-filled from the repository topics.</span>\n </label>\n )}\n <div class=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n {fields.license && licenseOptions.length > 0 && (\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Licence</span>\n <select id=\"item-license\" class={control}>\n <option value=\"\">Detected from the repository</option>\n {licenseOptions.map((option) => <option value={option.id}>{option.label}</option>)}\n </select>\n </label>\n )}\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Website</span>\n <input id=\"item-website\" type=\"url\" placeholder=\"https://example.com\" class={control} />\n </label>\n </div>\n <label class=\"grid gap-1.5\">\n <span class={labelText}>Best for</span>\n <textarea id=\"best-for\" rows=\"2\" class={`${control} resize-y`} placeholder=\"One use case per line\"></textarea>\n <span class={hint}>Who it suits — one audience or use case per line.</span>\n </label>\n </div>\n </details>\n </div>\n </section>\n </form>\n\n {/* ── 3. Review & open the pull request ─────────── */}\n <aside class=\"flex flex-col gap-4 lg:sticky lg:top-20\" aria-labelledby=\"step-review\">\n <section class=\"rounded-[var(--radius-lg)] border border-border bg-card p-5\">\n <h2 id=\"step-review\" class=\"m-0 flex items-center gap-2 text-[1.0625rem] font-semibold text-foreground\">\n <span class=\"text-muted-foreground\">3.</span> Preview and open the PR\n </h2>\n\n <div id=\"preview-card\" class=\"mt-4 rounded-[var(--radius)] border border-border bg-background p-4\">\n <div class=\"flex items-start gap-3\">\n <img id=\"preview-avatar\" hidden src=\"data:,\" alt=\"\" width=\"40\" height=\"40\" class=\"h-10 w-10 shrink-0 rounded-lg border border-border object-cover\" />\n <span id=\"preview-initials\" class=\"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-dashed border-border text-sm font-semibold text-muted-foreground\">?</span>\n <div class=\"min-w-0\">\n <p id=\"preview-name\" class=\"m-0 truncate text-[0.9375rem] font-semibold text-foreground\">{`Your ${singular}`}</p>\n <p id=\"preview-meta\" class=\"m-0 mt-0.5 text-2xs text-muted-foreground\">Category · Stack</p>\n </div>\n </div>\n <p id=\"preview-description\" class=\"m-0 mt-3 line-clamp-3 text-sm leading-relaxed text-muted-foreground\">The description appears here.</p>\n <p id=\"preview-credit\" hidden class=\"m-0 mt-3 text-2xs text-muted-foreground\"></p>\n </div>\n\n <ul id=\"submit-checklist\" class=\"m-0 mt-4 flex list-none flex-col gap-1.5 p-0 text-sm\" aria-label=\"Before you open the pull request\">\n {[\n [\"repo\", \"Repository fetched\"],\n [\"description\", \"Description of 40+ characters\"],\n ...(fields.category ? [[\"category\", \"Category chosen\"]] : []),\n ...(fields.stack ? [[\"stack\", \"Primary stack chosen\"]] : []),\n ...(fields.platforms ? [[\"platforms\", \"At least one platform\"]] : []),\n [\"credit\", \"Your GitHub username (optional)\"],\n ].map(([key, label]) => (\n <li data-check={key} data-ok=\"false\" class=\"group flex items-center gap-2 text-muted-foreground data-[ok=true]:text-foreground\">\n <span class=\"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-border group-data-[ok=true]:border-success group-data-[ok=true]:bg-success group-data-[ok=true]:text-background\">\n <svg viewBox=\"0 0 16 16\" width=\"9\" height=\"9\" aria-hidden=\"true\" fill=\"currentColor\" class=\"hidden group-data-[ok=true]:block\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\" /></svg>\n </span>\n {label}\n </li>\n ))}\n </ul>\n\n <div class=\"mt-5 grid gap-2\">\n <a id=\"open-pr-link\" href=\"#\" target=\"_blank\" rel=\"noopener\" class={buttonClass(\"primary\", \"md\", \"w-full justify-center pointer-events-none opacity-50\")}>\n Open pull request on GitHub\n </a>\n <button id=\"copy-yaml\" type=\"button\" disabled class={buttonClass(\"ghost\", \"sm\", \"w-full justify-center pointer-events-none opacity-50\")}>Copy the file instead</button>\n </div>\n <p id=\"submit-status\" class=\"m-0 mt-3 min-h-5 text-2xs text-muted-foreground\" aria-live=\"polite\"></p>\n\n <details class=\"group mt-2 border-t border-border pt-3\">\n <summary class=\"flex cursor-pointer list-none items-center justify-between text-2xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden\">\n <span>Show the file <span id=\"record-path\" class=\"font-mono\"></span></span>\n <span aria-hidden=\"true\" class=\"transition-transform group-open:rotate-45\">+</span>\n </summary>\n <pre class=\"mt-3 max-h-96 overflow-auto rounded-md border border-border bg-surface-sunken p-3 text-xs leading-relaxed text-foreground\"><code id=\"yaml-preview\">Paste a GitHub URL to generate a draft.</code></pre>\n </details>\n </section>\n\n <section class=\"rounded-[var(--radius-lg)] border border-border bg-card p-5\">\n <h2 class=\"m-0 text-sm font-semibold text-foreground\">What happens next</h2>\n <ol class=\"m-0 mt-3 flex list-none flex-col gap-3 p-0 text-2xs leading-relaxed text-muted-foreground\">\n {[\n [\"GitHub opens with the file ready.\", \"Commit it to a fork and open the pull request — one record file.\"],\n [\"Checks run on the pull request.\", \"Schema, taxonomy and duplicate checks — fix anything they flag.\"],\n [\"A maintainer reviews and merges.\", \"Curation and review fields are theirs to fill.\"],\n [\"The page goes live and credits you.\", \"It shows “Submitted by @you”, and maintainers get a README badge.\"],\n ].map(([head, text], i) => (\n <li class=\"flex gap-3\">\n <span class=\"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-secondary text-[10px] font-semibold text-secondary-foreground\">{i + 1}</span>\n <span><strong class=\"font-semibold text-foreground\">{head}</strong> {text}</span>\n </li>\n ))}\n </ol>\n </section>\n\n <details class=\"group rounded-[var(--radius-lg)] border border-border bg-card\">\n <summary class=\"flex cursor-pointer list-none items-center justify-between px-5 py-4 text-sm font-semibold text-foreground [&::-webkit-details-marker]:hidden\">\n Is it a good fit?\n <span aria-hidden=\"true\" class=\"text-muted-foreground transition-transform group-open:rotate-45\">+</span>\n </summary>\n <div class=\"grid gap-4 border-t border-border px-5 pb-5 pt-4 text-2xs sm:grid-cols-2 lg:grid-cols-1\">\n <div>\n <p class=\"m-0 font-semibold uppercase tracking-wider text-emerald-700 dark:text-emerald-400\">Good fit</p>\n <ul class=\"m-0 mt-2 list-none space-y-1.5 p-0 text-foreground\">\n {goodSubmissions.map((item) => <li class=\"flex gap-2\"><span class=\"text-success\">✓</span><span>{item}</span></li>)}\n </ul>\n </div>\n <div>\n <p class=\"m-0 font-semibold uppercase tracking-wider text-amber-700 dark:text-amber-400\">Not a fit</p>\n <ul class=\"m-0 mt-2 list-none space-y-1.5 p-0 text-foreground\">\n {pleaseAvoid.map((item) => <li class=\"flex gap-2\"><span class=\"text-warning\">×</span><span>{item}</span></li>)}\n </ul>\n </div>\n </div>\n </details>\n </aside>\n </div>\n </Container>\n\n <SubmissionClient\n existingSlugs={existingSlugs}\n existingFullNames={existingFullNames}\n repoUrl={repoUrl}\n fields={fields}\n taxonomy={taxonomy}\n categoryLabels={Object.fromEntries(categories.map((c) => [c.id, c.label]))}\n stackLabels={Object.fromEntries(stacks.map((c) => [c.id, c.label]))}\n />\n</BaseLayout>\n",
|
|
14
14
|
"type": "registry:page",
|
|
15
15
|
"target": "~/src/pages/submit.astro"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"path": "default/components/grove/submission-client.astro",
|
|
19
|
-
"content": "---\nimport {\n inferStackFromTopics,\n parseGithubRepo,\n recordSlugify,\n yamlLines,\n yamlQuote,\n} from '@grove-dev/core';\n\ninterface Props {\n existingSlugs: string[];\n existingFullNames: string[];\n repoUrl: string;\n fields: {\n category: boolean;\n stack: boolean;\n platforms: boolean;\n tags: boolean;\n license?: boolean;\n };\n /** Taxonomy ids for client-side validation. */\n taxonomy?: {\n categoryIds?: string[];\n stackIds?: string[];\n platformIds?: string[];\n };\n /**\n * Optional path of a server-side proxy endpoint that wraps\n * `api.github.com` (SSR consumers with an adapter can wire one and\n * read a `GITHUB_TOKEN` env var to lift the rate limit). When\n * omitted — the static-build default — the visitor's browser calls\n * `https://api.github.com/repos/{owner}/{repo}` directly, which\n * works on any static host but is subject to GitHub's per-IP\n * unauthenticated limit (60 requests/hour).\n */\n githubProxyPath?: string;\n}\nconst {\n existingSlugs,\n existingFullNames,\n repoUrl,\n fields,\n taxonomy,\n githubProxyPath = '',\n} = Astro.props;\n---\n\n<script is:inline define:vars={{ existingSlugs, existingFullNames, repoUrl, fields, taxonomy, githubProxyPath, recordSlugify, parseGithubRepo, yamlQuote, yamlLines, inferStackFromTopics }}>\n /** @typedef {{ name: string; description: string | null; html_url: string; homepage: string | null; language: string | null; private: boolean; topics: string[] }} GitHubRepo */\n /** @type {GitHubRepo | null} */\n let repository = null;\n\n const $ = /** @param {string} selector */ (selector) => /** @type {HTMLElement | null} */ (document.querySelector(selector));\n /** @type {Record<string, HTMLInputElement | HTMLTextAreaElement | null>} */\n const inputs = {\n repo: /** @type {HTMLInputElement | null} */ ($(\"#repo-url\")),\n name: /** @type {HTMLInputElement | null} */ ($(\"#item-name\")),\n slug: /** @type {HTMLInputElement | null} */ ($(\"#item-slug\")),\n description: /** @type {HTMLInputElement | null} */ ($(\"#item-description\")),\n category: /** @type {HTMLSelectElement | null} */ ($(\"#item-category\")),\n stack: /** @type {HTMLSelectElement | null} */ ($(\"#primary-stack\")),\n tags: /** @type {HTMLInputElement | null} */ ($(\"#item-tags\")),\n license: /** @type {HTMLSelectElement | null} */ ($(\"#item-license\")),\n website: /** @type {HTMLInputElement | null} */ ($(\"#item-website\")),\n bestFor: /** @type {HTMLTextAreaElement | null} */ ($(\"#best-for\")),\n };\n const fetchButton = /** @type {HTMLButtonElement | null} */ ($(\"#fetch-repo\"));\n const preview = /** @type {HTMLElement | null} */ ($(\"#yaml-preview\"));\n const status = /** @type {HTMLElement | null} */ ($(\"#submit-status\"));\n const copyButton = /** @type {HTMLButtonElement | null} */ ($(\"#copy-yaml\"));\n const openPrLink = /** @type {HTMLAnchorElement | null} */ ($(\"#open-pr-link\"));\n const slugSet = new Set(existingSlugs);\n const repoSet = new Set(existingFullNames);\n const categoryIds = new Set(taxonomy?.categoryIds ?? []);\n const stackIds = new Set(taxonomy?.stackIds ?? []);\n const platformIds = new Set(taxonomy?.platformIds ?? []);\n\n const slugify = recordSlugify;\n const parseRepo = parseGithubRepo;\n const quote = yamlQuote;\n const lines = yamlLines;\n const inferStack = /** @param {GitHubRepo} repo */ (repo) =>\n inferStackFromTopics({ language: repo.language, topics: repo.topics });\n const selectedPlatforms = () =>\n /** @type {string[]} */ ([...document.querySelectorAll(\"input[name=platform]:checked\")].map((input) => /** @type {HTMLInputElement} */ (input).value));\n const setStatus = (text, tone = \"muted\") => {\n if (!status) return;\n status.textContent = text;\n // Status tokens (danger/warning/success) so the submit states use\n // the same semantic roles as the rest of the system.\n status.className = `mt-3 min-h-5 text-2xs ${tone === \"error\" ? \"text-danger\" : tone === \"warn\" ? \"text-warning\" : tone === \"success\" ? \"text-success\" : \"text-muted-foreground\"}`;\n };\n const generateYaml = () => {\n if (!repository) return \"\";\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return \"\";\n const tags = String(inputs.tags?.value ?? \"\").split(\",\").map((tag) => tag.trim()).filter(Boolean);\n const platforms = selectedPlatforms();\n const bestFor = String(inputs.bestFor?.value ?? \"\").split(\"\\n\").map((item) => item.trim()).filter(Boolean);\n return [\n \"kind: project\",\n `slug: ${slugify(inputs.slug?.value ?? repository.name)}`,\n // The day the record joins the directory. Without it the\n // `recently-added` sort has nothing to sort a new record on and\n // drops it to the bottom of the list built to show it off.\n `addedAt: ${new Date().toISOString().slice(0, 10)}`,\n `name: ${quote(inputs.name?.value ?? \"\")}`,\n `description: ${quote(inputs.description?.value ?? \"\")}`,\n ...(fields.category ? [`category: ${inputs.category?.value || \"uncategorized\"}`] : []),\n \"projectType: real-app\",\n ...(fields.stack && inputs.stack?.value ? [`stack: ${quote(inputs.stack.value)}`] : []),\n ...(fields.platforms ? [\"platforms:\", platforms.length ? lines(platforms) : \" []\"] : []),\n ...(fields.tags ? [\"tags:\", tags.length ? lines(tags) : \" []\"] : []),\n ...(fields.license && inputs.license?.value ? [\"licenses:\", lines([inputs.license.value])] : []),\n `repoUrl: ${repository.html_url}`,\n \"links:\",\n ` github: ${repository.html_url}`,\n ...(inputs.website?.value ? [` website: ${inputs.website.value}`] : []),\n \"bestFor:\", bestFor.length ? lines(bestFor) : \" []\",\n \"source:\",\n \" type: manual\",\n ` owner: ${parsed.owner}`,\n ` repo: ${parsed.repo}`,\n \"curation:\",\n \" reviewed: false\",\n \" labels: []\",\n \" lenses: []\",\n \"\",\n ].join(\"\\n\");\n };\n // NOTE: this taxonomy/slug membership logic duplicates a concern\n // that belongs in `@grove-dev/core` (domain/taxonomy rules, not\n // UI), but it can't be moved into an import here. This `<script>`\n // uses `define:vars` (see the tag above), which Astro's compiler\n // implicitly treats as `is:inline` — the script is emitted\n // verbatim into the page and is NOT run through Vite's bundler,\n // so a bare-specifier `import ... from \"@grove-dev/core\"` would\n // not resolve in the browser (no bundler rewrite, no import map).\n // `define:vars` itself only hands the script JSON-serializable\n // data (see `taxonomy`, `existingSlugs`, etc. above) — a function\n // reference can't cross that boundary either. Moving this out\n // would require converting the script off `is:inline`/`define:vars`\n // to a regular bundled `<script>` that reads its props from\n // `data-*` attributes or a JSON island, which is a larger\n // structural change than this fix warrants.\n const validationIssues = () => {\n const issues = [];\n if (inputs.slug && slugSet.has(slugify(inputs.slug.value))) {\n issues.push(\"A record with that slug already exists — update the existing one instead of opening a duplicate PR.\");\n }\n const description = String(inputs.description?.value ?? \"\");\n if (description.trim().length < 40) {\n issues.push(\"Description must be at least 40 characters.\");\n }\n if (fields.category && inputs.category) {\n const v = inputs.category.value;\n if (!v || v === \"uncategorized\" || (categoryIds.size > 0 && !categoryIds.has(v))) {\n issues.push(\"Choose a category from the taxonomy.\");\n }\n }\n if (fields.stack && inputs.stack) {\n const v = inputs.stack.value;\n if (!v || (stackIds.size > 0 && !stackIds.has(v))) {\n issues.push(\"Choose a primary stack from the taxonomy.\");\n }\n }\n if (fields.platforms && selectedPlatforms().length === 0) {\n issues.push(\"Select at least one platform.\");\n } else if (fields.platforms && platformIds.size > 0) {\n const bad = selectedPlatforms().find((p) => !platformIds.has(p));\n if (bad) issues.push(`Platform \"${bad}\" is not in the taxonomy.`);\n }\n return issues;\n };\n const refresh = () => {\n const yaml = generateYaml();\n if (preview) preview.textContent = yaml || \"Paste a GitHub URL to generate a draft.\";\n if (!yaml || !openPrLink || !copyButton) return;\n const issues = validationIssues();\n if (issues.length > 0) {\n setStatus(issues[0], \"error\");\n openPrLink.classList.add(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = true;\n copyButton.classList.add(\"pointer-events-none\", \"opacity-50\");\n return;\n }\n const params = new URLSearchParams({ filename: `data/records/${slugify(inputs.slug?.value ?? \"\")}.yml`, value: yaml });\n openPrLink.href = `${repoUrl}/new/main?${params}`;\n openPrLink.classList.remove(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = false;\n copyButton.classList.remove(\"pointer-events-none\", \"opacity-50\");\n };\n\n fetchButton?.addEventListener(\"click\", async () => {\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return setStatus(\"Enter a valid GitHub repository URL.\", \"error\");\n const fullName = `${parsed.owner}/${parsed.repo}`.toLowerCase();\n if (repoSet.has(fullName)) setStatus(\"This repository is already listed. The draft can update its record.\", \"warn\");\n if (fetchButton) fetchButton.disabled = true;\n setStatus(\"Fetching GitHub metadata...\");\n try {\n if (githubProxyPath) {\n // Server-side proxy (SSR consumers) — the endpoint reads an\n // optional `GITHUB_TOKEN` env var and forwards the request\n // with a Bearer header (or unauthenticated, if no token).\n const proxyUrl = `${githubProxyPath}?owner=${encodeURIComponent(parsed.owner)}&repo=${encodeURIComponent(parsed.repo)}`;\n const response = await fetch(proxyUrl);\n const payload = /** @type {{ ok: boolean; status?: number; message?: string; data?: GitHubRepo }} */ (await response.json());\n if (!response.ok || !payload.ok || !payload.data) {\n throw new Error(payload.message || `GitHub returned ${response.status}.`);\n }\n repository = payload.data;\n } else {\n // Static-build default — call api.github.com directly. The\n // raw payload carries the same field names the form fill\n // logic consumes (name, description, html_url, homepage,\n // language, private, topics).\n const response = await fetch(\n `https://api.github.com/repos/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}`,\n { headers: { Accept: \"application/vnd.github+json\" } },\n );\n if (response.status === 404) {\n throw new Error(\"Repository not found or not public.\");\n }\n if (response.status === 403 || response.status === 429) {\n throw new Error(\n \"GitHub rate limit reached (60 requests/hour per visitor). Try again later or fill the fields manually.\",\n );\n }\n if (!response.ok) {\n throw new Error(`GitHub returned ${response.status}.`);\n }\n const data = /** @type {GitHubRepo & { topics?: string[] }} */ (await response.json());\n repository = {\n name: data.name,\n description: data.description ?? null,\n html_url: data.html_url,\n homepage: data.homepage ?? null,\n language: data.language ?? null,\n private: Boolean(data.private),\n topics: Array.isArray(data.topics) ? data.topics : [],\n };\n }\n if (repository.private) throw new Error(\"Private repositories cannot be submitted.\");\n if (inputs.name) inputs.name.value = repository.name || parsed.repo;\n if (inputs.slug) inputs.slug.value = slugify(repository.name || parsed.repo);\n if (inputs.description) inputs.description.value = repository.description || \"\";\n if (inputs.stack) inputs.stack.value = inferStack(repository);\n if (inputs.tags) inputs.tags.value = (repository.topics || []).slice(0, 8).join(\", \");\n if (inputs.website) inputs.website.value = repository.homepage || \"\";\n const duplicate = inputs.slug ? slugSet.has(inputs.slug.value) : false;\n setStatus(\n duplicate ? \"That slug already exists. Choose another or update the existing record.\" : \"Draft generated. Edit any field and the YAML will refresh.\",\n duplicate ? \"warn\" : \"success\",\n );\n refresh();\n } catch (error) {\n repository = null;\n setStatus(error instanceof Error ? error.message : \"Unable to fetch repository metadata.\", \"error\");\n } finally {\n if (fetchButton) fetchButton.disabled = false;\n }\n });\n $(\"#submit-form\")?.addEventListener(\"input\", refresh);\n $(\"#submit-form\")?.addEventListener(\"change\", refresh);\n copyButton?.addEventListener(\"click\", async () => {\n try {\n await navigator.clipboard.writeText(preview?.textContent || \"\");\n setStatus(\"Copied YAML to clipboard.\", \"success\");\n } catch {\n setStatus(\"Couldn't copy automatically. Select the YAML and copy it.\", \"error\");\n }\n });\n </script>\n",
|
|
19
|
+
"content": "---\n// The helpers below mirror `recordSlugify`, `parseGithubRepo`,\n// `yamlQuote`, `yamlLines` and `inferStackFromTopics` in @grove-dev/core.\n// They are written out inside the script because `define:vars` only\n// carries JSON: a function passed through it arrives as `undefined`,\n// which left \"Fetch details\" doing nothing. core's tests pin the rules.\n\ninterface Props {\n existingSlugs: string[];\n existingFullNames: string[];\n repoUrl: string;\n fields: {\n category: boolean;\n stack: boolean;\n platforms: boolean;\n tags: boolean;\n license?: boolean;\n };\n /** Taxonomy ids for client-side validation. */\n taxonomy?: {\n categoryIds?: string[];\n stackIds?: string[];\n platformIds?: string[];\n };\n /**\n * Optional path of a server-side proxy endpoint that wraps\n * `api.github.com` (SSR consumers with an adapter can wire one and\n * read a `GITHUB_TOKEN` env var to lift the rate limit). When\n * omitted — the static-build default — the visitor's browser calls\n * `https://api.github.com/repos/{owner}/{repo}` directly, which\n * works on any static host but is subject to GitHub's per-IP\n * unauthenticated limit (60 requests/hour).\n */\n githubProxyPath?: string;\n /** id → label, for the live preview card. */\n categoryLabels?: Record<string, string>;\n stackLabels?: Record<string, string>;\n}\nconst {\n existingSlugs,\n existingFullNames,\n repoUrl,\n fields,\n taxonomy,\n githubProxyPath = '',\n categoryLabels = {},\n stackLabels = {},\n} = Astro.props;\n---\n\n<script is:inline define:vars={{ existingSlugs, existingFullNames, repoUrl, fields, taxonomy, githubProxyPath, categoryLabels, stackLabels }}>\n /** @typedef {{ name: string; description: string | null; html_url: string; homepage: string | null; language: string | null; private: boolean; topics: string[] }} GitHubRepo */\n /** @type {GitHubRepo | null} */\n let repository = null;\n\n const $ = /** @param {string} selector */ (selector) => /** @type {HTMLElement | null} */ (document.querySelector(selector));\n /** @type {Record<string, HTMLInputElement | HTMLTextAreaElement | null>} */\n const inputs = {\n repo: /** @type {HTMLInputElement | null} */ ($(\"#repo-url\")),\n name: /** @type {HTMLInputElement | null} */ ($(\"#item-name\")),\n slug: /** @type {HTMLInputElement | null} */ ($(\"#item-slug\")),\n description: /** @type {HTMLInputElement | null} */ ($(\"#item-description\")),\n category: /** @type {HTMLSelectElement | null} */ ($(\"#item-category\")),\n stack: /** @type {HTMLSelectElement | null} */ ($(\"#primary-stack\")),\n tags: /** @type {HTMLInputElement | null} */ ($(\"#item-tags\")),\n license: /** @type {HTMLSelectElement | null} */ ($(\"#item-license\")),\n website: /** @type {HTMLInputElement | null} */ ($(\"#item-website\")),\n bestFor: /** @type {HTMLTextAreaElement | null} */ ($(\"#best-for\")),\n submittedBy: /** @type {HTMLInputElement | null} */ ($(\"#submitted-by\")),\n };\n /** Facts for the repository card; not written to the record. */\n let repoFacts = null;\n const GITHUB_LOGIN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;\n const submitter = () => String(inputs.submittedBy?.value ?? \"\").trim().replace(/^@/, \"\");\n const fetchButton = /** @type {HTMLButtonElement | null} */ ($(\"#fetch-repo\"));\n const preview = /** @type {HTMLElement | null} */ ($(\"#yaml-preview\"));\n const status = /** @type {HTMLElement | null} */ ($(\"#submit-status\"));\n const copyButton = /** @type {HTMLButtonElement | null} */ ($(\"#copy-yaml\"));\n const openPrLink = /** @type {HTMLAnchorElement | null} */ ($(\"#open-pr-link\"));\n const slugSet = new Set(existingSlugs);\n const repoSet = new Set(existingFullNames);\n const categoryIds = new Set(taxonomy?.categoryIds ?? []);\n const stackIds = new Set(taxonomy?.stackIds ?? []);\n const platformIds = new Set(taxonomy?.platformIds ?? []);\n\n const slugify = (value) =>\n String(value || \"\").toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n const parseRepo = (value) => {\n const match = String(value ?? \"\").match(/github\\.com\\/([^/]+)\\/([^/?#]+)/);\n return match ? { owner: match[1] ?? \"\", repo: (match[2] ?? \"\").replace(/\\.git$/, \"\") } : null;\n };\n const quote = (value) => `\"${String(value ?? \"\").replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\"`;\n const lines = (values, indent = 2) => values.map((value) => `${\" \".repeat(indent)}- ${value}`).join(\"\\n\");\n const inferStack = /** @param {GitHubRepo} repo */ (repo) => {\n const language = String(repo.language || \"\").toLowerCase();\n const topics = (repo.topics || []).map((topic) => String(topic).toLowerCase());\n if (topics.includes(\"flutter\") || language === \"dart\") return \"flutter\";\n if (topics.includes(\"react-native\")) return \"react-native\";\n if (language === \"swift\" || language === \"objective-c\") return \"ios\";\n if (language === \"kotlin\" || language === \"java\") return \"android\";\n return language;\n };\n const selectedPlatforms = () =>\n /** @type {string[]} */ ([...document.querySelectorAll(\"input[name=platform]:checked\")].map((input) => /** @type {HTMLInputElement} */ (input).value));\n const setStatus = (text, tone = \"muted\") => {\n if (!status) return;\n status.textContent = text;\n // Status tokens (danger/warning/success) so the submit states use\n // the same semantic roles as the rest of the system.\n status.className = `mt-3 min-h-5 whitespace-pre-line text-2xs ${tone === \"error\" ? \"text-danger\" : tone === \"warn\" ? \"text-warning\" : tone === \"success\" ? \"text-success\" : \"text-muted-foreground\"}`;\n };\n const generateYaml = () => {\n if (!repository) return \"\";\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return \"\";\n const tags = String(inputs.tags?.value ?? \"\").split(\",\").map((tag) => tag.trim()).filter(Boolean);\n const platforms = selectedPlatforms();\n const bestFor = String(inputs.bestFor?.value ?? \"\").split(\"\\n\").map((item) => item.trim()).filter(Boolean);\n return [\n \"kind: project\",\n `slug: ${slugify(inputs.slug?.value ?? repository.name)}`,\n // The day the record joins the directory. Without it the\n // `recently-added` sort has nothing to sort a new record on and\n // drops it to the bottom of the list built to show it off.\n `addedAt: ${new Date().toISOString().slice(0, 10)}`,\n // Credits the contributor on the record page and /contributors/.\n ...(GITHUB_LOGIN.test(submitter()) ? [`submittedBy: ${submitter()}`] : []),\n `name: ${quote(inputs.name?.value ?? \"\")}`,\n `description: ${quote(inputs.description?.value ?? \"\")}`,\n ...(fields.category ? [`category: ${inputs.category?.value || \"uncategorized\"}`] : []),\n \"projectType: real-app\",\n ...(fields.stack && inputs.stack?.value ? [`stack: ${quote(inputs.stack.value)}`] : []),\n ...(fields.platforms ? [\"platforms:\", platforms.length ? lines(platforms) : \" []\"] : []),\n ...(fields.tags ? [\"tags:\", tags.length ? lines(tags) : \" []\"] : []),\n ...(fields.license && inputs.license?.value ? [\"licenses:\", lines([inputs.license.value])] : []),\n `repoUrl: ${repository.html_url}`,\n \"links:\",\n ` github: ${repository.html_url}`,\n ...(inputs.website?.value ? [` website: ${inputs.website.value}`] : []),\n \"bestFor:\", bestFor.length ? lines(bestFor) : \" []\",\n \"source:\",\n \" type: manual\",\n ` owner: ${parsed.owner}`,\n ` repo: ${parsed.repo}`,\n \"curation:\",\n \" reviewed: false\",\n \" labels: []\",\n \" lenses: []\",\n \"\",\n ].join(\"\\n\");\n };\n // NOTE: this taxonomy/slug membership logic duplicates a concern\n // that belongs in `@grove-dev/core` (domain/taxonomy rules, not\n // UI), but it can't be moved into an import here. This `<script>`\n // uses `define:vars` (see the tag above), which Astro's compiler\n // implicitly treats as `is:inline` — the script is emitted\n // verbatim into the page and is NOT run through Vite's bundler,\n // so a bare-specifier `import ... from \"@grove-dev/core\"` would\n // not resolve in the browser (no bundler rewrite, no import map).\n // `define:vars` itself only hands the script JSON-serializable\n // data (see `taxonomy`, `existingSlugs`, etc. above) — a function\n // reference can't cross that boundary either. Moving this out\n // would require converting the script off `is:inline`/`define:vars`\n // to a regular bundled `<script>` that reads its props from\n // `data-*` attributes or a JSON island, which is a larger\n // structural change than this fix warrants.\n const validationIssues = () => {\n const issues = [];\n if (inputs.slug && slugSet.has(slugify(inputs.slug.value))) {\n issues.push(\"A record with that slug already exists — update the existing one instead of opening a duplicate PR.\");\n }\n const description = String(inputs.description?.value ?? \"\");\n if (description.trim().length < 40) {\n issues.push(\"Description must be at least 40 characters.\");\n }\n if (fields.category && inputs.category) {\n const v = inputs.category.value;\n if (!v || v === \"uncategorized\" || (categoryIds.size > 0 && !categoryIds.has(v))) {\n issues.push(\"Choose a category from the taxonomy.\");\n }\n }\n if (fields.stack && inputs.stack) {\n const v = inputs.stack.value;\n if (!v || (stackIds.size > 0 && !stackIds.has(v))) {\n issues.push(\"Choose a primary stack from the taxonomy.\");\n }\n }\n if (submitter() && !GITHUB_LOGIN.test(submitter())) {\n issues.push(\"That GitHub username doesn't look right — letters, digits and dashes only.\");\n }\n if (fields.platforms && selectedPlatforms().length === 0) {\n issues.push(\"Select at least one platform.\");\n } else if (fields.platforms && platformIds.size > 0) {\n const bad = selectedPlatforms().find((p) => !platformIds.has(p));\n if (bad) issues.push(`Platform \"${bad}\" is not in the taxonomy.`);\n }\n return issues;\n };\n // ── Live preview, checklist and step states ──────────────────\n const setText = (selector, text) => {\n const el = $(selector);\n if (el) el.textContent = text;\n };\n const updateGuide = (valid) => {\n const state = {\n repo: Boolean(repository),\n description: String(inputs.description?.value ?? \"\").trim().length >= 40,\n category: Boolean(inputs.category?.value),\n stack: Boolean(inputs.stack?.value),\n platforms: selectedPlatforms().length > 0,\n credit: GITHUB_LOGIN.test(submitter()),\n };\n document.querySelectorAll(\"[data-check]\").forEach((li) => {\n li.setAttribute(\"data-ok\", String(Boolean(state[li.getAttribute(\"data-check\") ?? \"\"])));\n });\n const steps = {\n repo: state.repo ? \"done\" : \"current\",\n details: !state.repo ? \"todo\" : valid ? \"done\" : \"current\",\n review: state.repo && valid ? \"current\" : \"todo\",\n };\n document.querySelectorAll(\"[data-step]\").forEach((li) => {\n li.setAttribute(\"data-state\", steps[li.getAttribute(\"data-step\") ?? \"\"] ?? \"todo\");\n });\n const name = String(inputs.name?.value ?? \"\").trim();\n if (name) setText(\"#preview-name\", name);\n setText(\"#preview-initials\", name ? name.slice(0, 2).toUpperCase() : \"?\");\n const meta = [categoryLabels[inputs.category?.value ?? \"\"], stackLabels[inputs.stack?.value ?? \"\"]].filter(Boolean);\n setText(\"#preview-meta\", meta.length ? meta.join(\" · \") : \"Category · Stack\");\n const description = String(inputs.description?.value ?? \"\").trim();\n setText(\"#preview-description\", description || \"The description appears here.\");\n const avatar = /** @type {HTMLImageElement | null} */ ($(\"#preview-avatar\"));\n const initials = $(\"#preview-initials\");\n if (avatar && initials) {\n avatar.hidden = !repoFacts?.avatar;\n initials.hidden = Boolean(repoFacts?.avatar);\n if (repoFacts?.avatar) avatar.src = repoFacts.avatar;\n }\n const credit = $(\"#preview-credit\");\n if (credit) {\n credit.hidden = !state.credit;\n credit.textContent = state.credit ? `Submitted by @${submitter()}` : \"\";\n }\n };\n const showRepoCard = () => {\n const card = $(\"#repo-card\");\n if (!card) return;\n card.hidden = !repoFacts;\n if (!repoFacts) return;\n const avatar = /** @type {HTMLImageElement | null} */ ($(\"#repo-avatar\"));\n if (avatar) avatar.src = repoFacts.avatar;\n setText(\"#repo-name\", repoFacts.fullName);\n setText(\"#repo-description\", repoFacts.description || \"No description on GitHub.\");\n const facts = $(\"#repo-facts\");\n if (facts) {\n facts.replaceChildren(\n ...[\n `★ ${repoFacts.stars.toLocaleString(\"en\")} stars`,\n repoFacts.license ? `Licence: ${repoFacts.license}` : \"No licence detected\",\n repoFacts.pushedAt ? `Last push ${new Date(repoFacts.pushedAt).toLocaleDateString(\"en\", { year: \"numeric\", month: \"short\", day: \"numeric\" })}` : \"\",\n repoFacts.archived ? \"Archived\" : \"\",\n ].filter(Boolean).map((text) => {\n const span = document.createElement(\"span\");\n span.textContent = text;\n return span;\n }),\n );\n }\n };\n\n const refresh = () => {\n updateGuide(Boolean(generateYaml()) && validationIssues().length === 0);\n const yaml = generateYaml();\n const path = `data/records/${slugify(inputs.slug?.value ?? \"\")}.yml`;\n setText(\"#record-path\", yaml ? path : \"\");\n if (preview) preview.textContent = yaml || \"Paste a GitHub URL to generate a draft.\";\n if (!yaml || !openPrLink || !copyButton) return;\n const issues = validationIssues();\n if (issues.length > 0) {\n setStatus(issues.map((issue) => `• ${issue}`).join(\"\\n\"), \"error\");\n openPrLink.classList.add(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = true;\n copyButton.classList.add(\"pointer-events-none\", \"opacity-50\");\n return;\n }\n const params = new URLSearchParams({ filename: `data/records/${slugify(inputs.slug?.value ?? \"\")}.yml`, value: yaml });\n openPrLink.href = `${repoUrl}/new/main?${params}`;\n openPrLink.classList.remove(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = false;\n copyButton.classList.remove(\"pointer-events-none\", \"opacity-50\");\n setStatus(`Draft is valid. \"Open pull request\" creates ${path} in one step.`, \"success\");\n };\n\n fetchButton?.addEventListener(\"click\", async () => {\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return setStatus(\"Enter a valid GitHub repository URL.\", \"error\");\n const fullName = `${parsed.owner}/${parsed.repo}`.toLowerCase();\n if (repoSet.has(fullName)) setStatus(\"This repository is already listed. The draft can update its record.\", \"warn\");\n if (fetchButton) fetchButton.disabled = true;\n setStatus(\"Fetching GitHub metadata...\");\n try {\n if (githubProxyPath) {\n // Server-side proxy (SSR consumers) — the endpoint reads an\n // optional `GITHUB_TOKEN` env var and forwards the request\n // with a Bearer header (or unauthenticated, if no token).\n const proxyUrl = `${githubProxyPath}?owner=${encodeURIComponent(parsed.owner)}&repo=${encodeURIComponent(parsed.repo)}`;\n const response = await fetch(proxyUrl);\n const payload = /** @type {{ ok: boolean; status?: number; message?: string; data?: GitHubRepo }} */ (await response.json());\n if (!response.ok || !payload.ok || !payload.data) {\n throw new Error(payload.message || `GitHub returned ${response.status}.`);\n }\n repository = payload.data;\n } else {\n // Static-build default — call api.github.com directly. The\n // raw payload carries the same field names the form fill\n // logic consumes (name, description, html_url, homepage,\n // language, private, topics).\n const response = await fetch(\n `https://api.github.com/repos/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}`,\n { headers: { Accept: \"application/vnd.github+json\" } },\n );\n if (response.status === 404) {\n throw new Error(\"Repository not found or not public.\");\n }\n if (response.status === 403 || response.status === 429) {\n throw new Error(\n \"GitHub rate limit reached (60 requests/hour per visitor). Try again later or fill the fields manually.\",\n );\n }\n if (!response.ok) {\n throw new Error(`GitHub returned ${response.status}.`);\n }\n const data = /** @type {any} */ (await response.json());\n repoFacts = {\n fullName: data.full_name ?? `${parsed.owner}/${parsed.repo}`,\n description: data.description ?? \"\",\n avatar: data.owner?.avatar_url ? `${data.owner.avatar_url}&s=80` : `https://github.com/${parsed.owner}.png?size=80`,\n stars: Number(data.stargazers_count ?? 0),\n license: data.license?.spdx_id && data.license.spdx_id !== \"NOASSERTION\" ? data.license.spdx_id : \"\",\n pushedAt: data.pushed_at ?? \"\",\n archived: Boolean(data.archived),\n };\n repository = {\n name: data.name,\n description: data.description ?? null,\n html_url: data.html_url,\n homepage: data.homepage ?? null,\n language: data.language ?? null,\n private: Boolean(data.private),\n topics: Array.isArray(data.topics) ? data.topics : [],\n };\n }\n if (repository.private) throw new Error(\"Private repositories cannot be submitted.\");\n showRepoCard();\n if (inputs.name) inputs.name.value = repository.name || parsed.repo;\n if (inputs.slug) inputs.slug.value = slugify(repository.name || parsed.repo);\n if (inputs.description) inputs.description.value = repository.description || \"\";\n if (inputs.stack) {\n // Only a real taxonomy id; an unknown value would blank the select.\n const inferred = inferStack(repository);\n inputs.stack.value = stackIds.size === 0 || stackIds.has(inferred) ? inferred : \"\";\n }\n if (inputs.tags) inputs.tags.value = (repository.topics || []).slice(0, 8).join(\", \");\n if (inputs.website) inputs.website.value = repository.homepage || \"\";\n const duplicate = inputs.slug ? slugSet.has(inputs.slug.value) : false;\n setStatus(\n duplicate ? \"That slug already exists. Choose another or update the existing record.\" : \"Draft generated. Edit any field and the YAML will refresh.\",\n duplicate ? \"warn\" : \"success\",\n );\n refresh();\n } catch (error) {\n repository = null;\n repoFacts = null;\n showRepoCard();\n refresh();\n setStatus(error instanceof Error ? error.message : \"Unable to fetch repository metadata.\", \"error\");\n } finally {\n if (fetchButton) fetchButton.disabled = false;\n }\n });\n inputs.repo?.addEventListener(\"keydown\", (event) => {\n if (/** @type {KeyboardEvent} */ (event).key === \"Enter\") {\n event.preventDefault();\n fetchButton?.click();\n }\n });\n $(\"#submit-form\")?.addEventListener(\"submit\", (event) => event.preventDefault());\n $(\"#submit-form\")?.addEventListener(\"input\", refresh);\n $(\"#submit-form\")?.addEventListener(\"change\", refresh);\n copyButton?.addEventListener(\"click\", async () => {\n try {\n await navigator.clipboard.writeText(preview?.textContent || \"\");\n setStatus(\"Copied YAML to clipboard.\", \"success\");\n } catch {\n setStatus(\"Couldn't copy automatically. Select the YAML and copy it.\", \"error\");\n }\n });\n </script>\n",
|
|
20
20
|
"type": "registry:component",
|
|
21
21
|
"target": "~/src/components/grove/submission-client.astro"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
24
|
"meta": {
|
|
25
|
-
"version": "1.
|
|
26
|
-
"requiresGrove": "0.
|
|
25
|
+
"version": "1.5.0",
|
|
26
|
+
"requiresGrove": "1.0.0"
|
|
27
27
|
},
|
|
28
28
|
"type": "registry:block"
|
|
29
29
|
}
|
package/dist/r/taxonomy.json
CHANGED
package/dist/r/ui.json
CHANGED
package/dist/registry.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const REGISTRY_NAMESPACE = "@grove";
|
|
|
4
4
|
/** Where the built items are served; `{name}` is the shadcn placeholder. */
|
|
5
5
|
export declare const REGISTRY_URL_TEMPLATE = "https://withgrove.dev/r/{name}.json";
|
|
6
6
|
/** The shadcn CLI release `grove init` drives. Pinned: item install behavior is version-specific. */
|
|
7
|
-
export declare const SHADCN_VERSION = "4.
|
|
7
|
+
export declare const SHADCN_VERSION = "4.21.0";
|
|
8
8
|
/** The generated full-scaffold item. */
|
|
9
9
|
export declare const SCAFFOLD_ITEM = "default";
|
|
10
10
|
/** What `.grove/registry.lock.json` records as `scaffold`. */
|
package/dist/registry.js
CHANGED
|
@@ -33,7 +33,7 @@ export const REGISTRY_NAMESPACE = '@grove';
|
|
|
33
33
|
/** Where the built items are served; `{name}` is the shadcn placeholder. */
|
|
34
34
|
export const REGISTRY_URL_TEMPLATE = 'https://withgrove.dev/r/{name}.json';
|
|
35
35
|
/** The shadcn CLI release `grove init` drives. Pinned: item install behavior is version-specific. */
|
|
36
|
-
export const SHADCN_VERSION = '4.
|
|
36
|
+
export const SHADCN_VERSION = '4.21.0';
|
|
37
37
|
/** The generated full-scaffold item. */
|
|
38
38
|
export const SCAFFOLD_ITEM = 'default';
|
|
39
39
|
/** What `.grove/registry.lock.json` records as `scaffold`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grove-dev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Grove CLI — scaffolds Grove-powered spaces and orchestrates @grove-dev/core commands.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"lighthouse": "^12.8.2",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
50
|
"yaml": "^2.6.0",
|
|
51
|
-
"@grove-dev/core": "0.
|
|
51
|
+
"@grove-dev/core": "1.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"tsx": "^4.23.0",
|
|
55
|
-
"@grove-dev/registry": "1.
|
|
55
|
+
"@grove-dev/registry": "1.5.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node -e \"require('fs').copyFileSync('package.json','dist/package.json')\" && node -e \"require('fs').cpSync('../registry/dist/r','dist/r',{recursive:true})\"",
|