mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migration compat / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests (Local Emulator) / E2E Tests (Local Emulator, Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E Fallback Tests / E2E Fallback Tests (Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Lint & build / lint_and_build (24) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
## Summary **Stacked on [#1475](https://github.com/hexclave/stack-auth/pull/1475)** (`cl/hexclave-pr1`, the invisible compatibility layer). Diff vs that base = the actual PR 2 code. This is **PR 2 of the Stack Auth → Hexclave rebrand: the visible flip**. Old wire identifiers (cookies, request/response headers, Bearer prefix, JWT issuers, MCP tool name) keep working indefinitely via PR 1's dual-accept. This PR flips every user-visible surface — package names taught in docs, SDK class names in code examples, dashboard setup snippets, page titles, error messages, email content, CLI binary, default base URLs, GitHub repo slug, contributor guidance — to the Hexclave brand. See [`RENAME-TO-HEXCLAVE.md`](./RENAME-TO-HEXCLAVE.md) → *"PR 2: Rebrand to Hexclave (visible)"* for the full per-work-area spec. ## What's implemented (per the plan's PR 2 scope) - **SDK base URLs** flipped: `defaultBaseUrl` and `defaultAnalyticsBaseUrl` in [common.ts](packages/template/src/lib/stack-app/apps/implementations/common.ts:127) → `https://api.hexclave.com` / `https://r.hexclave.com`. PR 1's [`getHardcodedFallbackUrls`](packages/stack-shared/src/utils/urls.tsx:199) table now keys on the Hexclave domain. - **Domain inventory sweep** (16 subdomains from the plan): every `api/app/docs/discord/demo/mcp/skill/feedback/test/preview/r/api2/api.staging/idp-jwk-audience/built-with.stack-auth.com` reference in production code, docs-mintlify, examples, READMEs, and contributor guidance flipped to `*.hexclave.com`. Carve-outs: PR 1's intentional JWT issuer dual-accept table in [tokens.tsx](apps/backend/src/lib/tokens.tsx), the legacy `./docs/` folder, the `unified-docs-widget` allowlist (deliberately accepts both during DNS transition), and `url-targets.ts` hosted-component default (baked into existing customer deploys). - **`@deprecated` JSDoc** on every `Stack*` public export ([packages/template/src/lib/stack-app/index.ts](packages/template/src/lib/stack-app/index.ts) + [packages/template/src/index.ts](packages/template/src/index.ts)) — `StackClientApp`, `StackServerApp`, `StackAdminApp` + every constructor/options/JSON type, `StackHandler`, `StackProvider`, `StackTheme`, `useStackApp`, `defineStackConfig`, `StackConfig`. Hexclave\* aliases are now canonical. - **Runtime `console.warn`** ([packages/template/src/internal/deprecation-warning.ts](packages/template/src/internal/deprecation-warning.ts)) — once-per-process when the SDK is loaded from a `@stackframe/*` artifact. Detection uses the existing `STACK_COMPILE_TIME_CLIENT_PACKAGE_VERSION_SENTINEL` (rewritten at build time to e.g. `js @stackframe/stack@2.8.92` or `js @hexclave/next@1.0.0`); `@hexclave/*` mirror artifacts short-circuit the warning. - **Tier 3 data migration**: new idempotent SQL migration [`20260523000000_rename_internal_project_to_hexclave`](apps/backend/prisma/migrations/20260523000000_rename_internal_project_to_hexclave/migration.sql) — updates the internal Project `displayName` 'Stack Dashboard' → 'Hexclave Dashboard' and `description` only if both still hold the pre-rebrand defaults. Operator-renamed projects untouched, missing row no-ops, re-runs are no-ops. [`seed.ts`](apps/backend/prisma/seed.ts:87) default flipped. `getSharedEmailConfig("Stack Auth")` → `("Hexclave")`. - **Tier 4 brand strings** (mechanical sweep, ~340 files): - Page + OpenAPI titles (Hexclave API / Dashboard / REST API / Webhooks API / Documentation). OpenAPI `info.description` documents `X-Hexclave-*` headers as canonical with compat note on `X-Stack-*`. - `HexclaveAssertionError` message text ([errors.tsx:71](packages/stack-shared/src/utils/errors.tsx:71)) — "an error in Stack." → "an error in Hexclave." - Known-error message templates ([known-errors.tsx](packages/stack-shared/src/known-errors.tsx)) flipped to lead with `x-hexclave-*` + the new `docs.hexclave.com` URL; legacy `x-stack-*` mentioned as compat aliases. **25 e2e test files updated in lockstep**. - Email content: failed-emails-digest body, sendTestEmail recipient (now `sent-with-hexclave.com`), test-email-recipient default. - `CHANGELOG.md` title → "Hexclave Changelog". - `AGENTS.md` env var convention: new vars prefix `HEXCLAVE_` / `NEXT_PUBLIC_HEXCLAVE_` for Category A/B; legacy `STACK_*` explicitly noted as accepted via PR 1's dual-read. - **CLI / init wizard**: - Every dashboard setup snippet, init-stack template, and docs-mintlify page teaches `npx @hexclave/cli@latest init` (was `@stackframe/stack-cli`). [setup-page.tsx](apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/(overview)/setup-page.tsx) + [link-existing-onboarding](apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/new-project/page-client-parts/link-existing-onboarding.tsx). - [init-stack](packages/init-stack/src/index.ts:634) `STACK_*_INSTALL_PACKAGE_NAME_OVERRIDE` defaults flipped to `@hexclave/*`. - Generated `stack/client.ts` / `stack/server.ts` import from `@hexclave/next` and reference `HexclaveClientApp` / `HexclaveServerApp`. - Internal `StackAuthKeys` dashboard component renamed to `HexclaveKeys`. - **docs-mintlify rewrite** (legacy `./docs/` intentionally untouched per scoping decision): - **78 MDX files swept**. `@stackframe/{react,stack,js,tanstack-start,...}` → `@hexclave/{react,stack,js,...}` in install snippets and code blocks; `Stack*` SDK class names → `Hexclave*` in all code examples; 'Stack Auth' brand phrase → 'Hexclave'. - `openapi/{server,admin,client,webhooks}.json` titles → 'Hexclave REST API' / 'Hexclave Webhooks API'. - **Generators flipped before regeneration**: - [`packages/stack-shared/src/helpers/init-prompt.ts`](packages/stack-shared/src/helpers/init-prompt.ts), [`/ai/prompts.ts`](packages/stack-shared/src/ai/prompts.ts), [`apps/backend/src/lib/ai/prompts.ts`](apps/backend/src/lib/ai/prompts.ts), [`apps/backend/src/lib/ai/tools/create-email-{template,draft}.ts`](apps/backend/src/lib/ai/tools/create-email-template.ts), [`apps/skills/src/app/route.ts`](apps/skills/src/app/route.ts) (taught MCP tool → `ask_hexclave` with compat note; CLI binary teach → `hexclave`), [`docs-mintlify/snippets/home-prompt-island.jsx`](docs-mintlify/snippets/home-prompt-island.jsx), [`packages/template/README.md`](packages/template/README.md) + integrations/convex/component/README.md. - `generate-sdks` propagated changes to `packages/{react,stack,js}`. - **OpenAPI dual-documentation**: [`apps/backend/src/app/api/latest/route.ts`](apps/backend/src/app/api/latest/route.ts) now lists `X-Hexclave-*` headers as primary documented schemas with `X-Stack-*` duplicates marked `.optional()` (both accepted at runtime by PR 1's normalize-at-proxy shim). - **`@stackframe/emails` virtual module**: dual-aliased to `@hexclave/emails` at the bundler boundary ([email-rendering.tsx:89](apps/backend/src/lib/email-rendering.tsx:89)). Stored email templates continue to import from either name; new AI-generated templates and the system prompt teach `@hexclave/emails`. - **Tier 2 mirror-publish wiring** (new this PR, lays the groundwork for `@hexclave/*` first publish): - [`scripts/rewrite-packages-to-hexclave.ts`](scripts/rewrite-packages-to-hexclave.ts) — rewrites 9 publishable `@stackframe/*` → `@hexclave/*` `package.json` files (reads `HEXCLAVE_VERSION` env or `--version=` flag), pins cross-deps to the shared `@hexclave` version, registers `hexclave` bin alongside `stack` for `@hexclave/cli`. - [`.github/workflows/npm-publish.yaml`](.github/workflows/npm-publish.yaml) appended with rewrite-then-republish step. `pnpm publish` skips already-on-npm versions so reruns are safe. - **Sender email domain**: `noreply@stackframe.co` → `noreply@sent-with-hexclave.com` (the dedicated transactional-sender domain split per the plan, to isolate bulk deliverability from `hexclave.com` reputation); `security@` / `team@stack-auth.com` inbound mailboxes → `@hexclave.com`. - **Self-host docs**: docker network / container names in the bash examples flipped from `stack-auth` to `hexclave` (`hexclave-postgres`, `hexclave-clickhouse`, `hexclave.env`). The docker image tag `stackauth/server:latest` stays per the plan's locked decision. - **GitHub repo slug**: `hexclave/stack-auth` → `hexclave/hexclave` in every `package.json` `repository` field, README link, CHANGELOG raw-asset URL. ## Carve-outs (deliberately untouched) - **[`apps/backend/src/lib/tokens.tsx`](apps/backend/src/lib/tokens.tsx)** JWT issuer dual-accept table — PR 1 intentional infrastructure, kept indefinitely. - **Legacy `./docs/` folder** — per scoping decision (only `docs-mintlify/` rewritten). - **`unified-docs-widget` hostname allowlist** — accepts both `.hexclave.com` (canonical) and `.stack-auth.com` (transition window) for DNS rollout. - **`url-targets.ts`** hosted-domain default `.built-with-stack-auth.com` — wire identifier baked into existing customer deploys; indefinite read-fallback. - **Binary visual assets** (logos, favicons, OG images, README screenshots) — out of scope for this PR. Need design work; tracked separately. ## Verification - **`pnpm typecheck`** on `packages/{template,stack-shared,react,stack,js}` + `apps/dashboard`: **all green**. The remaining backend / e-commerce-demo typecheck errors are pre-existing (Prisma codegen output + `./generated/api-versions.json` not present in fresh worktrees without `pnpm run codegen-prisma` + a live DB) and unrelated to this diff. - **`pnpm lint`** on the same 6 packages: all green. - **Final grep** for residual `Stack Auth` / `stack-auth.com` / `@stackframe/stack-cli@latest` references: zero outside the intentional carve-outs above. - **25 e2e test files updated in lockstep** with the known-error message changes (asserted strings flipped to match the new x-hexclave-* + compat-note messages). ## Deploy blockers (ops sequencing before this rebrand goes live) This PR is code-complete, but the rebrand's visible surfaces (SDK default URLs, dashboard links, npm READMEs, REST error messages, runtime deprecation warning) all point at `*.hexclave.com` / `@hexclave/*` resources that don't exist yet. None of these are fixable from a PR — they're ops/registrar/npm work that has to be sequenced before merging this to a release tag. Suggested ordering, hardest blockers first: ### Tier 1 — required before customer-facing deploy (everything below this line *will visibly break customers on day 1* if skipped) 1. **DNS + TLS for `api.hexclave.com` + `api1./api2.hexclave.com`** → must point at the same backend that serves `api.stack-auth.com` (or a backend that mirrors PR 1's dual-accept). The SDK's new `defaultBaseUrl` is `https://api.hexclave.com`; every customer that relied on the old default and upgrades to a post-PR2 SDK build sends API requests here. Until this resolves, every default-config customer's API call NXDOMAINs. 2. **DNS for `app.hexclave.com`** → the dashboard. Referenced in the SDK's default-error messages ("Please create a project on the Hexclave dashboard at https://app.hexclave.com"), the init-stack flow's `wizard-congrats` redirect, and the OAuth dashboard handoff. 3. **DNS for `docs.hexclave.com`** + Mintlify deploy → the SDK runtime deprecation warning (`https://docs.hexclave.com/migration`), every README, every "Learn more" link in the dashboard, and every REST API error body (`/api/overview#authentication`) points here. The MDX is in this PR; the docs build target needs DNS. 4. **DNS for `mcp.hexclave.com`** → the MCP server endpoint that every taught agent integration (`claude mcp add ...`, `cursor`, `codex`, `vscode`) registers. Until this resolves, every `npx @hexclave/cli@latest init` MCP-registration step fails. 5. **Reserve the `@hexclave` npm scope + set repo variable `HEXCLAVE_VERSION`** → the mirror-publish step in `.github/workflows/npm-publish.yaml` is gated on this variable. Without it, the entire taught onboarding command `npx @hexclave/cli@latest init` 404s from the npm registry, *and* every README that says "install `@hexclave/next`" leads to install failure. Pick the initial version intentionally (`1.0.0` or aligned to `@stackframe/stack`); don't accept a silent default. ### Tier 2 — required before announcing the rebrand publicly (lookalike or low-traffic surfaces, but visibly broken) 6. **DNS for `r.hexclave.com`** → the analytics beacon `defaultAnalyticsBaseUrl`. Silent failure if missing (analytics drops), but should land alongside Tier 1. 7. **Register `sent-with-hexclave.com` + full email auth (SPF / DKIM / DMARC)** → the new default sender domain for shared-sender transactional emails. Without it the dashboard "send test email" path emits bounces, and shared-sender flows (`getSharedEmailConfig("Hexclave")`) deliver to spam at best. 8. **MX + SPF / DMARC for `hexclave.com`** → `team@hexclave.com` and `security@hexclave.com` mailboxes. The security disclosure mailbox is referenced in [`.github/SECURITY.md`](.github/SECURITY.md); `team@hexclave.com` is the actual recipient of internal feedback emails sent at runtime by [`apps/backend/src/lib/internal-feedback-emails.tsx`](apps/backend/src/lib/internal-feedback-emails.tsx). Today, every runtime feedback email bounces. 9. **DNS for `skill.hexclave.com`** → the canonical AI-agent skill fetch URL (the agent bootstrap pivot). Without it, the entire "agent downloads `SKILL.md` from a known URL" flow taught in [`packages/stack-shared/src/helpers/init-prompt.ts`](packages/stack-shared/src/helpers/init-prompt.ts) fails. 10. **Create `github.com/hexclave/hexclave` as a public repo** (even as a redirect to `hexclave/stack-auth`) **OR** rewrite every `package.json` `"repository"` field + dashboard footer "view on GitHub" link to point at `hexclave/stack-auth` (which already exists). Currently every npm package page's "Repository" link is dead, and the dashboard's GitHub button + dev-tool repo link are dead. ### Tier 3 — broken but low-visibility / low-traffic 11. **DNS for `discord.hexclave.com`** → Discord invite redirect, used in every README's chip and the dashboard footer. 12. **DNS for `demo.hexclave.com`** → "✨ Demo" badge in every npm package README. Broken-image badge on the package page. 13. **DNS + TLS for `built-with-hexclave.com`** → optional hosted-handler domain (the default reverted to `.built-with-stack-auth.com` in this PR's carve-outs, so this only matters for projects that manually flip). ## Other follow-ups (not deploy-blocking) - **E2E snapshot regen across the full suite** for the dual-emitted `x-hexclave-*` response headers (PR 1 follow-up; `vitest -u` in CI absorbs). - **Binary visual assets** — logos, favicons, OG images, README screenshots; need design pass. - **Backend OpenAPI fumadocs regen** in CI flow — the JSON files in `docs-mintlify/openapi/` are committed but regen runs in CI. Verify the workflow that does this still works against the post-PR2 source. - **Backend typecheck infra debt** — needs `codegen-prisma` + `codegen-route-info` to clear; pre-existing, unaffected by this PR. ## Test plan - [ ] CI runs full e2e suite (with `vitest -u` to absorb residual snapshot deltas, then committed back). - [ ] Spot-check: new `@hexclave/cli init` (once published) generates `hexclave.config.ts` and works against a fresh project. - [ ] Spot-check: existing customer with `@stackframe/stack` import sees the once-per-process `console.warn` recommending `@hexclave/next` on SDK init. - [ ] Manual: dashboard setup page renders the `npx @hexclave/cli@latest init` snippet and the `x-hexclave-publishable-client-key` API header in the curl example. - [ ] Manual: a fresh `pnpm run prisma migrate` against a clean DB sets the internal project displayName to 'Hexclave Dashboard'. --------- Co-authored-by: Konstantin Wohlwend <n2d4xc@gmail.com>
465 lines
18 KiB
TypeScript
465 lines
18 KiB
TypeScript
import path from "path";
|
|
import { aiSetupPrompt, cliSetupPrompt, convexSetupPrompt, getSdkSetupPrompt, supabaseSetupPrompt } from "../packages/stack-shared/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt";
|
|
import { deindent } from "../packages/stack-shared/src/utils/strings";
|
|
import { writeFileSyncIfChanged } from "./utils";
|
|
|
|
const generatedComment = "This file is auto-generated by scripts/generate-setup-prompt-docs.ts. Do not edit it manually; edit packages/stack-shared/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.ts instead.";
|
|
type SdkSetupToolCategory = "frontend" | "backend" | "database" | "other";
|
|
type SdkSetupTool = {
|
|
label: string,
|
|
where: SdkSetupToolCategory[],
|
|
imageUrl: string,
|
|
monochromeLogo: boolean,
|
|
tabs: { label: string, mdContent: string }[],
|
|
extraFeatures: string[],
|
|
};
|
|
|
|
const repoRoot = path.resolve(__dirname, "..");
|
|
const setupPromptText = aiSetupPrompt;
|
|
|
|
const sdkSetupTools: Record<string, SdkSetupTool> = {
|
|
nextjs: {
|
|
label: "Next.js",
|
|
where: ["frontend", "backend"],
|
|
imageUrl: "/images/setup-tools/nextjs.svg",
|
|
monochromeLogo: true,
|
|
tabs: [{
|
|
label: "Next.js",
|
|
mdContent: getSdkSetupPrompt("nextjs"),
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
react: {
|
|
label: "React",
|
|
where: ["frontend"],
|
|
imageUrl: "/images/setup-tools/react.svg",
|
|
monochromeLogo: false,
|
|
tabs: [{
|
|
label: "React",
|
|
mdContent: getSdkSetupPrompt("react"),
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
js: {
|
|
label: "Other JS/TS",
|
|
where: ["frontend"],
|
|
imageUrl: "/images/setup-tools/javascript.svg",
|
|
monochromeLogo: false,
|
|
tabs: [{
|
|
label: "JS/TS",
|
|
mdContent: getSdkSetupPrompt("js"),
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
"tanstack-start": {
|
|
label: "Tanstack Start",
|
|
where: ["frontend"],
|
|
imageUrl: "/images/setup-tools/tanstack.svg",
|
|
monochromeLogo: true,
|
|
tabs: [{
|
|
label: "Tanstack Start",
|
|
mdContent: getSdkSetupPrompt("tanstack-start"),
|
|
}],
|
|
extraFeatures: ["tanstack-query"],
|
|
},
|
|
"tanstack-query": {
|
|
label: "Tanstack Query",
|
|
where: ["frontend"],
|
|
imageUrl: "/images/setup-tools/tanstack.svg",
|
|
monochromeLogo: true,
|
|
tabs: [],
|
|
extraFeatures: ["tanstack-query"],
|
|
},
|
|
nodejs: {
|
|
label: "Node.js",
|
|
where: ["backend"],
|
|
imageUrl: "/images/setup-tools/nodejs.svg",
|
|
monochromeLogo: false,
|
|
tabs: [{
|
|
label: "Node.js",
|
|
mdContent: getSdkSetupPrompt("nodejs"),
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
bun: {
|
|
label: "Bun",
|
|
where: ["backend"],
|
|
imageUrl: "/images/setup-tools/bun.svg",
|
|
monochromeLogo: false,
|
|
tabs: [{
|
|
label: "Bun",
|
|
mdContent: getSdkSetupPrompt("bun"),
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
convex: {
|
|
label: "Convex",
|
|
where: ["backend", "database"],
|
|
imageUrl: "/images/setup-tools/convex.svg",
|
|
monochromeLogo: false,
|
|
tabs: [{
|
|
label: "Convex",
|
|
mdContent: convexSetupPrompt,
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
supabase: {
|
|
label: "Supabase",
|
|
where: ["database"],
|
|
imageUrl: "/images/setup-tools/supabase.svg",
|
|
monochromeLogo: false,
|
|
tabs: [{
|
|
label: "Supabase",
|
|
mdContent: supabaseSetupPrompt,
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
cli: {
|
|
label: "CLI",
|
|
where: ["other"],
|
|
imageUrl: "/images/setup-tools/cli.svg",
|
|
monochromeLogo: true,
|
|
tabs: [{
|
|
label: "CLI",
|
|
mdContent: cliSetupPrompt,
|
|
}],
|
|
extraFeatures: [],
|
|
},
|
|
/*mcp: {
|
|
label: "MCP",
|
|
where: ["other"],
|
|
imageUrl: "/images/setup-tools/mcp.svg",
|
|
monochromeLogo: true,
|
|
tabs: [{
|
|
label: "MCP",
|
|
mdContent: mcpSetupPrompt,
|
|
}],
|
|
extraFeatures: [],
|
|
},*/
|
|
};
|
|
|
|
function slugify(value: string) {
|
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
}
|
|
|
|
const categoryLabels = new Map<SdkSetupToolCategory, string>([
|
|
["frontend", "Frontend"],
|
|
["backend", "Backend"],
|
|
["database", "Database"],
|
|
["other", "Other"],
|
|
]);
|
|
|
|
const setupToolIds = Object.keys(sdkSetupTools);
|
|
const setupTabs = Object.entries(sdkSetupTools).flatMap(([toolId, tool]) => {
|
|
return tool.tabs.map((tab, tabIndex) => ({
|
|
id: `${toolId}-${slugify(tab.label)}-${tabIndex}`,
|
|
toolLabel: tool.label,
|
|
toolId,
|
|
tabLabel: tab.label,
|
|
mdContent: tab.mdContent,
|
|
}));
|
|
});
|
|
const setupTabMetadata = setupTabs.map((tab) => ({
|
|
toolId: tab.toolId,
|
|
title: tab.tabLabel,
|
|
}));
|
|
const unifiedAiPromptTabTitle = "Unified AI Prompt";
|
|
|
|
function renderToolCards(category: SdkSetupToolCategory) {
|
|
const tools = Object.entries(sdkSetupTools).filter(([, tool]) => tool.where.includes(category));
|
|
return tools.map(([toolId, tool]) => {
|
|
const hasTabs = tool.tabs.length > 0;
|
|
const iconMarkup = tool.monochromeLogo
|
|
? deindent`
|
|
<span
|
|
aria-hidden="true"
|
|
className="h-8 w-8 bg-black opacity-80 transition-opacity duration-150 group-hover:transition-none group-hover:opacity-90 dark:bg-white dark:opacity-95"
|
|
style={{
|
|
WebkitMask: "url(${tool.imageUrl}) center / contain no-repeat",
|
|
mask: "url(${tool.imageUrl}) center / contain no-repeat",
|
|
}}
|
|
/>
|
|
`
|
|
: deindent`
|
|
<img
|
|
src="${tool.imageUrl}"
|
|
alt=""
|
|
aria-hidden="true"
|
|
className="h-8 w-8 object-contain opacity-90 transition-opacity duration-150 group-hover:transition-none group-hover:opacity-100"
|
|
/>
|
|
`;
|
|
return deindent`
|
|
<button
|
|
type="button"
|
|
aria-pressed="false"
|
|
data-setup-tool-card="true"
|
|
data-tool-id="${toolId}"
|
|
data-tool-label="${tool.label}"
|
|
data-tool-has-tabs="${hasTabs ? "true" : "false"}"
|
|
data-tool-extra-features="${tool.extraFeatures.join(",")}"
|
|
onClick={onSetupToolClick}
|
|
className="group flex flex-col items-center gap-1 rounded-xl px-1 py-1 text-center transition-colors duration-150 hover:transition-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500 aria-pressed:bg-white/60 aria-pressed:ring-2 aria-pressed:ring-[#6b5df7] dark:aria-pressed:bg-white/10"
|
|
title="${tool.label}"
|
|
>
|
|
<div className="relative flex h-16 w-16 items-center justify-center overflow-hidden rounded-2xl border border-[#b8cff7] bg-gradient-to-b from-[#f2f7ff] via-[#ebf2ff] to-[#e4edff] shadow-[inset_0_1px_0_rgba(255,255,255,0.95),0_7px_18px_rgba(43,76,140,0.2)] transition-[border-color,box-shadow,transform] duration-150 group-hover:transition-none group-hover:border-[#78a8f0] group-hover:shadow-[inset_0_1px_0_rgba(255,255,255,1),0_0_20px_rgba(82,138,234,0.38),0_10px_22px_rgba(43,76,140,0.24)] dark:border-[#2c4c7d]/70 dark:from-[#183155] dark:via-[#112542] dark:to-[#0a1830] dark:shadow-[inset_0_1px_0_rgba(160,200,255,0.24),0_8px_24px_rgba(2,8,20,0.62)] dark:group-hover:border-[#4f84d7] dark:group-hover:shadow-[inset_0_1px_0_rgba(188,218,255,0.42),0_0_26px_rgba(77,138,239,0.5),0_12px_30px_rgba(2,8,20,0.72)]">
|
|
${iconMarkup}
|
|
<span className="absolute right-2 top-2 hidden h-5 min-w-5 items-center justify-center rounded-full bg-[#6b5df7] px-1 text-[9px] font-bold uppercase tracking-tight text-white group-aria-pressed:flex">On</span>
|
|
</div>
|
|
<span
|
|
className="min-h-8 max-w-20 text-center text-xs font-medium leading-4 text-[#2e446f] transition-colors duration-150 group-hover:transition-none group-hover:text-[#182b50] dark:text-[#d8e7ff] dark:group-hover:text-white"
|
|
title="${tool.label}"
|
|
>
|
|
${tool.label}
|
|
</span>
|
|
</button>
|
|
`;
|
|
}).join("\n");
|
|
}
|
|
|
|
function renderToolCategory(category: SdkSetupToolCategory) {
|
|
return deindent`
|
|
<section className="grid gap-3 sm:grid-cols-[6rem_1fr] sm:items-start">
|
|
<h3 className="pt-1 text-sm font-semibold text-[#2e446f] dark:text-[#d8e7ff]">${categoryLabels.get(category)}</h3>
|
|
<div className="grid grid-cols-3 gap-x-2 gap-y-3 sm:grid-cols-4 sm:gap-x-3 sm:gap-y-3 lg:grid-cols-6">
|
|
${renderToolCards(category)}
|
|
</div>
|
|
</section>
|
|
`;
|
|
}
|
|
|
|
function renderMarkdownInTabPanel(mdContent: string) {
|
|
return mdContent.replace(/<Note>\n([\s\S]*?)\n\s*<\/Note>/g, (_match, noteContent: string) => {
|
|
const blockquoteContent = deindent(noteContent)
|
|
.split("\n")
|
|
.map((line) => line.length === 0 ? ">" : `> ${line}`)
|
|
.join("\n");
|
|
return blockquoteContent;
|
|
});
|
|
}
|
|
|
|
function renderTabPanels() {
|
|
return setupTabs.map((tab) => deindent`
|
|
<Tab title="${tab.tabLabel}">
|
|
<div className="not-prose mb-1 flex justify-end">
|
|
<button
|
|
type="button"
|
|
onClick={copyGeneratedSetupPrompt}
|
|
className="inline-flex items-center justify-center rounded-md border border-[#9fb5e4] bg-[#eaf1ff] px-2 py-1 text-[11px] font-semibold leading-none text-[#2a4272] transition-colors duration-150 hover:transition-none hover:bg-[#dde8ff] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500 focus-visible:ring-offset-2 dark:border-[#3d5a91] dark:bg-[#12213d] dark:text-[#d5e6ff] dark:hover:bg-[#1a2e51]"
|
|
>
|
|
Copy prompt
|
|
</button>
|
|
</div>
|
|
|
|
${renderMarkdownInTabPanel(tab.mdContent)}
|
|
</Tab>
|
|
`).join("\n\n");
|
|
}
|
|
|
|
function renderUnifiedAiPromptTab() {
|
|
return deindent`
|
|
<Tab title="${unifiedAiPromptTabTitle}">
|
|
Setting up with AI? Use this single prompt in your coding agent to set up Hexclave for your selected stack.
|
|
|
|
<div className="not-prose relative mt-3">
|
|
<pre className="max-h-40 overflow-auto whitespace-pre-wrap rounded-2xl border border-[#cdd7f4] bg-white/75 px-4 py-3 pr-32 font-mono text-xs leading-6 text-zinc-700 backdrop-blur-sm sm:text-sm dark:border-[#33476d] dark:bg-black/20 dark:text-zinc-200"><code>{generatedSetupPromptText}</code></pre>
|
|
<button
|
|
type="button"
|
|
onClick={copyGeneratedSetupPrompt}
|
|
className="absolute right-2 top-2 inline-flex items-center justify-center rounded-lg border border-[#9fb5e4] bg-[#eaf1ff] px-3 py-1.5 text-xs font-semibold text-[#2a4272] transition-colors duration-150 hover:transition-none hover:bg-[#dde8ff] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500 focus-visible:ring-offset-2 dark:border-[#3d5a91] dark:bg-[#12213d] dark:text-[#d5e6ff] dark:hover:bg-[#1a2e51]"
|
|
>
|
|
Copy prompt
|
|
</button>
|
|
</div>
|
|
</Tab>
|
|
`;
|
|
}
|
|
|
|
writeFileSyncIfChanged(
|
|
path.join(repoRoot, "docs-mintlify/snippets/home-prompt-island.jsx"),
|
|
deindent`
|
|
// ${generatedComment}
|
|
|
|
export const generatedSetupPromptText = ${JSON.stringify(setupPromptText)};
|
|
export const setupToolIds = ${JSON.stringify(setupToolIds)};
|
|
export const setupTabMetadata = ${JSON.stringify(setupTabMetadata)};
|
|
export const unifiedAiPromptTabTitle = ${JSON.stringify(unifiedAiPromptTabTitle)};
|
|
|
|
export const GeneratedSetupPromptText = ({ className }) => (
|
|
<textarea
|
|
readOnly
|
|
aria-label="Generated setup prompt"
|
|
value={generatedSetupPromptText}
|
|
className={className}
|
|
/>
|
|
);
|
|
` + "\n",
|
|
);
|
|
|
|
writeFileSyncIfChanged(
|
|
path.join(repoRoot, "docs-mintlify/guides/getting-started/setup.mdx"),
|
|
deindent`
|
|
---
|
|
title: Setup
|
|
description: Install and configure Hexclave for your project
|
|
sidebarTitle: Setup
|
|
---
|
|
|
|
{/* ${generatedComment} */}
|
|
|
|
export const generatedSetupPromptText = ${JSON.stringify(setupPromptText)};
|
|
export const setupToolIds = ${JSON.stringify(setupToolIds)};
|
|
export const setupTabMetadata = ${JSON.stringify(setupTabMetadata)};
|
|
export const unifiedAiPromptTabTitle = ${JSON.stringify(unifiedAiPromptTabTitle)};
|
|
|
|
export const copyGeneratedSetupPrompt = async (event) => {
|
|
const button = event.currentTarget;
|
|
try {
|
|
await navigator.clipboard.writeText(generatedSetupPromptText);
|
|
button.textContent = "Copied";
|
|
} catch {
|
|
button.textContent = "Copy failed";
|
|
}
|
|
window.setTimeout(() => {
|
|
button.textContent = "Copy prompt";
|
|
}, 1300);
|
|
};
|
|
|
|
export const getSelectedSetupToolIdsFromUrl = () => {
|
|
if (typeof window === "undefined") {
|
|
return [];
|
|
}
|
|
const selectedToolIds = new Set(setupToolIds);
|
|
return (new URLSearchParams(window.location.search).get("tools") ?? "")
|
|
.split(",")
|
|
.map((toolId) => toolId.trim())
|
|
.filter((toolId) => selectedToolIds.has(toolId));
|
|
};
|
|
|
|
export const writeSelectedSetupToolIdsToUrl = (selectedToolIds) => {
|
|
if (typeof window === "undefined") {
|
|
return;
|
|
}
|
|
const url = new URL(window.location.href);
|
|
const orderedSelectedToolIds = setupToolIds.filter((toolId) => selectedToolIds.has(toolId));
|
|
if (orderedSelectedToolIds.length === 0) {
|
|
url.searchParams.delete("tools");
|
|
} else {
|
|
url.searchParams.set("tools", orderedSelectedToolIds.join(","));
|
|
}
|
|
window.history.replaceState(null, "", url.pathname + url.search + url.hash);
|
|
};
|
|
|
|
export const updateSetupBuilder = (root, syncUrl = true) => {
|
|
const selectedToolIds = new Set(
|
|
Array.from(root.querySelectorAll("[data-setup-tool-card='true'][aria-pressed='true']"))
|
|
.map((card) => card.getAttribute("data-tool-id"))
|
|
.filter((toolId) => toolId != null)
|
|
);
|
|
if (syncUrl) {
|
|
writeSelectedSetupToolIdsToUrl(selectedToolIds);
|
|
}
|
|
const visibleTabTitles = new Set(setupTabMetadata
|
|
.filter((tab) => selectedToolIds.has(tab.toolId))
|
|
.map((tab) => tab.title)
|
|
);
|
|
if (visibleTabTitles.size > 0) {
|
|
visibleTabTitles.add(unifiedAiPromptTabTitle);
|
|
}
|
|
const tabsRoot = root.querySelector("[data-setup-tabs-root='true']");
|
|
|
|
const emptyState = root.querySelector("[data-setup-tabs-empty='true']");
|
|
if (emptyState != null) {
|
|
emptyState.hidden = visibleTabTitles.size > 0;
|
|
emptyState.style.display = visibleTabTitles.size > 0 ? "none" : "";
|
|
}
|
|
if (tabsRoot == null) {
|
|
return;
|
|
}
|
|
|
|
tabsRoot.hidden = visibleTabTitles.size === 0;
|
|
tabsRoot.style.display = visibleTabTitles.size === 0 ? "none" : "";
|
|
const tabButtons = Array.from(tabsRoot.querySelectorAll("[role='tab']"));
|
|
let firstVisibleTabButton = null;
|
|
let selectedVisibleTabButton = null;
|
|
for (const tabButton of tabButtons) {
|
|
const title = tabButton.textContent?.trim() ?? "";
|
|
const shouldShow = visibleTabTitles.has(title);
|
|
tabButton.hidden = !shouldShow;
|
|
tabButton.style.display = shouldShow ? "" : "none";
|
|
if (shouldShow && firstVisibleTabButton == null) {
|
|
firstVisibleTabButton = tabButton;
|
|
}
|
|
if (shouldShow && tabButton.getAttribute("aria-selected") === "true") {
|
|
selectedVisibleTabButton = tabButton;
|
|
}
|
|
}
|
|
if (visibleTabTitles.size > 0 && selectedVisibleTabButton == null) {
|
|
firstVisibleTabButton?.click();
|
|
}
|
|
};
|
|
|
|
export const initializeSetupBuilder = (node) => {
|
|
if (node == null || node.dataset.setupBuilderInitialized === "true") {
|
|
return;
|
|
}
|
|
node.dataset.setupBuilderInitialized = "true";
|
|
const selectedToolIds = new Set(getSelectedSetupToolIdsFromUrl());
|
|
for (const toolCard of node.querySelectorAll("[data-setup-tool-card='true']")) {
|
|
toolCard.setAttribute("aria-pressed", selectedToolIds.has(toolCard.getAttribute("data-tool-id")) ? "true" : "false");
|
|
}
|
|
updateSetupBuilder(node, false);
|
|
};
|
|
|
|
export const onSetupToolClick = (event) => {
|
|
const button = event.currentTarget;
|
|
const root = button.closest("[data-setup-builder='true']");
|
|
if (root == null) {
|
|
return;
|
|
}
|
|
button.setAttribute("aria-pressed", button.getAttribute("aria-pressed") === "true" ? "false" : "true");
|
|
updateSetupBuilder(root);
|
|
};
|
|
|
|
<Note>
|
|
<p className="font-semibold">Setting up with AI? Use this single prompt:</p>
|
|
<div className="not-prose relative mt-3">
|
|
<pre className="max-h-40 overflow-auto whitespace-pre-wrap rounded-2xl border border-[#cdd7f4] bg-white/75 px-4 py-3 pr-32 font-mono text-xs leading-6 text-zinc-700 backdrop-blur-sm sm:text-sm dark:border-[#33476d] dark:bg-black/20 dark:text-zinc-200"><code>{generatedSetupPromptText}</code></pre>
|
|
<button
|
|
type="button"
|
|
onClick={copyGeneratedSetupPrompt}
|
|
className="absolute right-2 top-2 inline-flex items-center justify-center rounded-lg border border-[#9fb5e4] bg-[#eaf1ff] px-3 py-1.5 text-xs font-semibold text-[#2a4272] transition-colors duration-150 hover:transition-none hover:bg-[#dde8ff] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[#f3f6ff] dark:border-[#3d5a91] dark:bg-[#12213d] dark:text-[#d5e6ff] dark:hover:bg-[#1a2e51] dark:focus-visible:ring-offset-[#0f1a2e]"
|
|
>
|
|
Copy prompt
|
|
</button>
|
|
</div>
|
|
</Note>
|
|
|
|
<div ref={initializeSetupBuilder} data-setup-builder="true" className="mt-10">
|
|
<div>
|
|
<h2 className="text-3xl font-bold tracking-tight text-slate-900 dark:text-white">Choose your tech stack</h2>
|
|
<p className="mt-2 text-sm font-medium text-slate-500 dark:text-slate-400">Choose all that apply.</p>
|
|
</div>
|
|
|
|
<div className="not-prose mt-5 space-y-4 rounded-2xl border border-[#d6e4ff] bg-gradient-to-b from-[#f7faff] to-[#eaf2ff] p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.9),0_10px_30px_-24px_rgba(47,79,140,0.35)] dark:border-[#1f2d45] dark:from-[#11203a] dark:to-[#070f1f] dark:shadow-[inset_0_1px_0_rgba(112,152,224,0.18),0_16px_34px_-24px_rgba(2,8,20,0.85)] sm:p-4">
|
|
${renderToolCategory("frontend")}
|
|
${renderToolCategory("backend")}
|
|
${renderToolCategory("database")}
|
|
${renderToolCategory("other")}
|
|
</div>
|
|
|
|
<div className="mt-8">
|
|
<p data-setup-tabs-empty="true" className="not-prose rounded-2xl border border-[#c5d7f6] bg-white/65 p-5 text-sm text-[#4a5f89] dark:border-[#2c4c7d] dark:bg-[#0c1627]/45 dark:text-[#8fa4cc]">
|
|
Select a tool to show setup instructions.
|
|
</p>
|
|
<div data-setup-tabs-root="true" hidden style={{ display: "none" }}>
|
|
<Tabs>
|
|
${renderUnifiedAiPromptTab()}
|
|
|
|
${renderTabPanels()}
|
|
</Tabs>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
` + "\n",
|
|
);
|