@specdest/devkit 0.4.17 → 0.4.18
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/README.md +1 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminConfirmDialog.tsx.template +46 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminDataTable.tsx.template +49 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminDetailLayout.tsx.template +15 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminEmptyState.tsx.template +17 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminFilterBar.tsx.template +16 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminFormLayout.tsx.template +19 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminPage.tsx.template +19 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminPageHeader.tsx.template +19 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminPagination.tsx.template +20 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminShell.tsx.template +20 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminSidebar.tsx.template +18 -0
- package/dist/npm/predefined-packages/admin-ui-templates/AdminStatCard.tsx.template +22 -0
- package/dist/npm/predefined-packages/admin-ui.d.ts +2 -0
- package/dist/npm/predefined-packages/admin-ui.js +79 -0
- package/dist/npm/predefined-packages/registry.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@ npx @specdest/devkit flow complete
|
|
|
31
31
|
|
|
32
32
|
- `status` reads the cached canonical catalog and reports applicable/current/missing/outdated rules plus registered predefined packages. Use `--refresh` to refresh the catalog from GitHub and `--json` for machine-readable output.
|
|
33
33
|
- `add <package>` applies or adopts a predefined package recipe. Package recipes use only three relationship primitives: `requires`, `conflicts`, and environment-selected `variants`. `requires` is evaluated against packages registered in Devkit state; conflicts and variant selection also consider packages physically detected in the project. Status/doctor report stale package state, while sync/check/rules refuse to run against invalid package metadata. The supported foundational packages are `vite`, `expo`, `supabase`, and `convex`. Additional predefined packages are `auth`, `multi-tenancy`, `abac`, `sentry`, `logging`, `payments`, `shadcn`, `tanstack-router`, `tanstack-query`, `tanstack-form`, `storybook`, `playwright`, `vitest`, `local-logging`, `firebase-hosting`, `zod`, `tailwind`, `husky`, `nps`, `oxlint`, `oxfmt`, and `stryker`. Create-or-adopt recipes include the foundations (`vite`, `expo`, `supabase`, `convex`) and deterministic self-contained tooling (`zod`, `vitest`, `oxlint`, `oxfmt`, `husky`, `nps`, `tanstack-form`, `playwright`, `stryker`). They create minimal local dependencies/configuration when absent, then run `pnpm install`; when an integration already exists they adopt it without rewriting project-owned application files. Runtime-wired or product-specific recipes remain adoption-only until Devkit has a deterministic, product-neutral installation contract. Recipes record the recipe version separately from any detected dependency version in `.spd/installed.json`; Devkit does not invent product-specific auth, tenancy, authorization, logging, or payment architecture. Generated/adopted application code remains project-owned. Package lifecycle is deliberately fire-and-forget: there is no package `remove` or `upgrade` command. Developers remove packages manually; to update a recipe, re-run `add <package>`. Re-adding applies only the current recipe and does not remove files/settings that existed only in an older recipe. See [`docs/package-model.md`](docs/package-model.md). Supabase creation also scaffolds the canonical guarded declarative production-release workflow; registering Supabase activates the corresponding database rule/checker for ongoing enforcement. When Devkit-created foundation packages resolve a supported stack, required canonical setup packages are installed automatically (for example Oxlint/Husky for React stack gates and NPS for Supabase database commands); adopted stacks remain non-invasive and report missing setup through canonical checks.
|
|
34
|
+
- `add admin-ui` adopts an established shared admin page system or creates project-owned shadcn-based admin source components without overwriting existing files. See [`docs/admin-ui.md`](docs/admin-ui.md).
|
|
34
35
|
- `sync` refreshes the canonical catalog, downloads only missing rule-cache entries, installs missing applicable rules, and updates outdated ones.
|
|
35
36
|
- `check` executes each distinct canonical checker implementation once from the local Devkit cache and projects that result onto every rule backed by that checker. Use `--refresh` to refresh the canonical catalog/checker cache first without reconciling project files. `--staged` resolves target paths/content from the Git index; `--files` supplies explicit project-relative paths. Repository-scoped checkers still run globally. Targeted checks are ephemeral and do not update `.spd/state.json`; only a full check records canonical project status.
|
|
36
37
|
- `rules` loads AI-facing guidance without dumping the whole catalog. Use `--id <rule>`, `--category <category>`, `--failed`, or `--json`; with no selector it returns only rules marked `ai.load = "always"`.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AlertDialog,
|
|
4
|
+
AlertDialogAction,
|
|
5
|
+
AlertDialogCancel,
|
|
6
|
+
AlertDialogContent,
|
|
7
|
+
AlertDialogDescription,
|
|
8
|
+
AlertDialogFooter,
|
|
9
|
+
AlertDialogHeader,
|
|
10
|
+
AlertDialogTitle,
|
|
11
|
+
AlertDialogTrigger,
|
|
12
|
+
} from '@/components/ui/alert-dialog';
|
|
13
|
+
|
|
14
|
+
type AdminConfirmDialogProps = {
|
|
15
|
+
trigger: ReactNode;
|
|
16
|
+
title: ReactNode;
|
|
17
|
+
description: ReactNode;
|
|
18
|
+
onConfirm: () => void;
|
|
19
|
+
confirmLabel?: string;
|
|
20
|
+
cancelLabel?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function AdminConfirmDialog({
|
|
24
|
+
trigger,
|
|
25
|
+
title,
|
|
26
|
+
description,
|
|
27
|
+
onConfirm,
|
|
28
|
+
confirmLabel = 'Confirm',
|
|
29
|
+
cancelLabel = 'Cancel',
|
|
30
|
+
}: AdminConfirmDialogProps) {
|
|
31
|
+
return (
|
|
32
|
+
<AlertDialog>
|
|
33
|
+
<AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger>
|
|
34
|
+
<AlertDialogContent>
|
|
35
|
+
<AlertDialogHeader>
|
|
36
|
+
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
37
|
+
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
38
|
+
</AlertDialogHeader>
|
|
39
|
+
<AlertDialogFooter>
|
|
40
|
+
<AlertDialogCancel>{cancelLabel}</AlertDialogCancel>
|
|
41
|
+
<AlertDialogAction onClick={onConfirm}>{confirmLabel}</AlertDialogAction>
|
|
42
|
+
</AlertDialogFooter>
|
|
43
|
+
</AlertDialogContent>
|
|
44
|
+
</AlertDialog>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
|
3
|
+
|
|
4
|
+
export type AdminColumn<T> = {
|
|
5
|
+
id: string;
|
|
6
|
+
header: ReactNode;
|
|
7
|
+
cell: (row: T) => ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type AdminDataTableProps<T> = {
|
|
11
|
+
columns: readonly AdminColumn<T>[];
|
|
12
|
+
rows: readonly T[];
|
|
13
|
+
getRowId: (row: T) => string;
|
|
14
|
+
empty?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function AdminDataTable<T>({
|
|
18
|
+
columns,
|
|
19
|
+
rows,
|
|
20
|
+
getRowId,
|
|
21
|
+
empty = 'No results',
|
|
22
|
+
}: AdminDataTableProps<T>) {
|
|
23
|
+
return (
|
|
24
|
+
<div className="w-full min-w-0 overflow-x-auto rounded-lg border">
|
|
25
|
+
<Table>
|
|
26
|
+
<TableHeader>
|
|
27
|
+
<TableRow>
|
|
28
|
+
{columns.map((column) => <TableHead key={column.id}>{column.header}</TableHead>)}
|
|
29
|
+
</TableRow>
|
|
30
|
+
</TableHeader>
|
|
31
|
+
<TableBody>
|
|
32
|
+
{rows.length === 0 ? (
|
|
33
|
+
<TableRow>
|
|
34
|
+
<TableCell colSpan={columns.length} className="h-24 text-center text-muted-foreground">
|
|
35
|
+
{empty}
|
|
36
|
+
</TableCell>
|
|
37
|
+
</TableRow>
|
|
38
|
+
) : (
|
|
39
|
+
rows.map((row) => (
|
|
40
|
+
<TableRow key={getRowId(row)}>
|
|
41
|
+
{columns.map((column) => <TableCell key={column.id}>{column.cell(row)}</TableCell>)}
|
|
42
|
+
</TableRow>
|
|
43
|
+
))
|
|
44
|
+
)}
|
|
45
|
+
</TableBody>
|
|
46
|
+
</Table>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type AdminDetailLayoutProps = {
|
|
4
|
+
main: ReactNode;
|
|
5
|
+
aside?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function AdminDetailLayout({ main, aside }: AdminDetailLayoutProps) {
|
|
9
|
+
return (
|
|
10
|
+
<div className={aside ? 'grid min-w-0 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]' : 'min-w-0'}>
|
|
11
|
+
<div className="min-w-0 space-y-6">{main}</div>
|
|
12
|
+
{aside ? <aside className="min-w-0 space-y-6">{aside}</aside> : null}
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type AdminEmptyStateProps = {
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
action?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function AdminEmptyState({ title, description, action }: AdminEmptyStateProps) {
|
|
10
|
+
return (
|
|
11
|
+
<div className="flex min-h-40 flex-col items-center justify-center gap-3 rounded-lg border p-6 text-center">
|
|
12
|
+
<p className="font-medium">{title}</p>
|
|
13
|
+
{description ? <p className="text-sm text-muted-foreground">{description}</p> : null}
|
|
14
|
+
{action}
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type AdminFilterBarProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
actions?: ReactNode;
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function AdminFilterBar({ children, actions, label = 'Filters' }: AdminFilterBarProps) {
|
|
10
|
+
return (
|
|
11
|
+
<section aria-label={label} className="flex flex-wrap items-end gap-3 rounded-lg border bg-card p-4">
|
|
12
|
+
<div className="flex min-w-0 flex-1 flex-wrap items-end gap-3">{children}</div>
|
|
13
|
+
{actions ? <div className="flex shrink-0 items-end gap-2">{actions}</div> : null}
|
|
14
|
+
</section>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type AdminFormLayoutProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
aside?: ReactNode;
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function AdminFormLayout({ children, aside, actions }: AdminFormLayoutProps) {
|
|
10
|
+
return (
|
|
11
|
+
<div className="space-y-6">
|
|
12
|
+
<div className={aside ? 'grid min-w-0 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]' : 'min-w-0'}>
|
|
13
|
+
<div className="min-w-0 space-y-6">{children}</div>
|
|
14
|
+
{aside ? <aside className="min-w-0 space-y-6">{aside}</aside> : null}
|
|
15
|
+
</div>
|
|
16
|
+
{actions ? <div className="flex flex-wrap justify-end gap-2">{actions}</div> : null}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type AdminPageVariant = 'list' | 'detail' | 'form' | 'dashboard';
|
|
4
|
+
|
|
5
|
+
type AdminPageProps = {
|
|
6
|
+
variant: AdminPageVariant;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const widths: Record<AdminPageVariant, string> = {
|
|
11
|
+
list: 'w-full',
|
|
12
|
+
detail: 'max-w-6xl',
|
|
13
|
+
form: 'max-w-3xl',
|
|
14
|
+
dashboard: 'w-full',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function AdminPage({ variant, children }: AdminPageProps) {
|
|
18
|
+
return <div className={'mx-auto min-w-0 space-y-6 p-4 md:p-6 ' + widths[variant]}>{children}</div>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type AdminPageHeaderProps = {
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function AdminPageHeader({ title, description, actions }: AdminPageHeaderProps) {
|
|
10
|
+
return (
|
|
11
|
+
<header className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
|
12
|
+
<div className="min-w-0 space-y-1">
|
|
13
|
+
<h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
|
|
14
|
+
{description ? <p className="text-sm text-muted-foreground">{description}</p> : null}
|
|
15
|
+
</div>
|
|
16
|
+
{actions ? <div className="flex shrink-0 flex-wrap gap-2">{actions}</div> : null}
|
|
17
|
+
</header>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type AdminPaginationProps = {
|
|
4
|
+
page: number;
|
|
5
|
+
totalPages: number;
|
|
6
|
+
previous?: ReactNode;
|
|
7
|
+
next?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function AdminPagination({ page, totalPages, previous, next }: AdminPaginationProps) {
|
|
11
|
+
return (
|
|
12
|
+
<nav aria-label="Pagination" className="flex flex-wrap items-center justify-between gap-3 rounded-lg border p-3">
|
|
13
|
+
<div className="min-w-0">{previous}</div>
|
|
14
|
+
<span className="text-sm text-muted-foreground" aria-live="polite">
|
|
15
|
+
Page {page} of {totalPages}
|
|
16
|
+
</span>
|
|
17
|
+
<div className="min-w-0">{next}</div>
|
|
18
|
+
</nav>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { SidebarInset, SidebarProvider } from '@/components/ui/sidebar';
|
|
3
|
+
|
|
4
|
+
type AdminShellProps = {
|
|
5
|
+
sidebar: ReactNode;
|
|
6
|
+
header?: ReactNode;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function AdminShell({ sidebar, header, children }: AdminShellProps) {
|
|
11
|
+
return (
|
|
12
|
+
<SidebarProvider>
|
|
13
|
+
{sidebar}
|
|
14
|
+
<SidebarInset className="min-w-0">
|
|
15
|
+
{header}
|
|
16
|
+
<main className="min-w-0 flex-1">{children}</main>
|
|
17
|
+
</SidebarInset>
|
|
18
|
+
</SidebarProvider>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader } from '@/components/ui/sidebar';
|
|
3
|
+
|
|
4
|
+
type AdminSidebarProps = {
|
|
5
|
+
navigation: ReactNode;
|
|
6
|
+
header?: ReactNode;
|
|
7
|
+
footer?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function AdminSidebar({ navigation, header, footer }: AdminSidebarProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Sidebar>
|
|
13
|
+
{header ? <SidebarHeader>{header}</SidebarHeader> : null}
|
|
14
|
+
<SidebarContent>{navigation}</SidebarContent>
|
|
15
|
+
{footer ? <SidebarFooter>{footer}</SidebarFooter> : null}
|
|
16
|
+
</Sidebar>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
3
|
+
|
|
4
|
+
type AdminStatCardProps = {
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
value: ReactNode;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function AdminStatCard({ label, value, description }: AdminStatCardProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Card>
|
|
13
|
+
<CardHeader>
|
|
14
|
+
<CardTitle className="text-sm font-medium text-muted-foreground">{label}</CardTitle>
|
|
15
|
+
</CardHeader>
|
|
16
|
+
<CardContent className="space-y-1">
|
|
17
|
+
<div className="text-2xl font-semibold tabular-nums">{value}</div>
|
|
18
|
+
{description ? <p className="text-sm text-muted-foreground">{description}</p> : null}
|
|
19
|
+
</CardContent>
|
|
20
|
+
</Card>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { writeProjectFileIfMissing } from "./install.js";
|
|
4
|
+
import { pathExists } from "./project-signals.js";
|
|
5
|
+
const components = [
|
|
6
|
+
'AdminShell',
|
|
7
|
+
'AdminSidebar',
|
|
8
|
+
'AdminPage',
|
|
9
|
+
'AdminPageHeader',
|
|
10
|
+
'AdminFilterBar',
|
|
11
|
+
'AdminDataTable',
|
|
12
|
+
'AdminPagination',
|
|
13
|
+
'AdminFormLayout',
|
|
14
|
+
'AdminDetailLayout',
|
|
15
|
+
'AdminStatCard',
|
|
16
|
+
'AdminEmptyState',
|
|
17
|
+
'AdminConfirmDialog',
|
|
18
|
+
];
|
|
19
|
+
const primitives = ['alert-dialog', 'card', 'sidebar', 'table'];
|
|
20
|
+
async function hasExistingAdminUi(root) {
|
|
21
|
+
// Existing project-owned shared admin page systems are adopted, not replaced.
|
|
22
|
+
return ((await pathExists(root, 'src/components/extra/admin-list-layout.tsx')) &&
|
|
23
|
+
(await pathExists(root, 'src/components/extra/admin-list-states.tsx')));
|
|
24
|
+
}
|
|
25
|
+
async function templateCount(root) {
|
|
26
|
+
const files = await Promise.all(components.map((name) => pathExists(root, 'src/components/admin/' + name + '.tsx')));
|
|
27
|
+
return files.filter(Boolean).length;
|
|
28
|
+
}
|
|
29
|
+
export const adminUiRecipe = {
|
|
30
|
+
id: 'admin-ui',
|
|
31
|
+
recipeVersion: '1.0.0',
|
|
32
|
+
role: 'feature',
|
|
33
|
+
requires: ['shadcn'],
|
|
34
|
+
async detect(root) {
|
|
35
|
+
if (await hasExistingAdminUi(root)) {
|
|
36
|
+
return { present: true, compatible: true, detectedVersion: null };
|
|
37
|
+
}
|
|
38
|
+
const count = await templateCount(root);
|
|
39
|
+
return {
|
|
40
|
+
present: count > 0,
|
|
41
|
+
compatible: count === components.length,
|
|
42
|
+
detectedVersion: null,
|
|
43
|
+
...(count > 0 && count < components.length
|
|
44
|
+
? {
|
|
45
|
+
reason: 'Admin UI has only ' + count + ' of ' + components.length + ' source components',
|
|
46
|
+
}
|
|
47
|
+
: {}),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
async apply(root) {
|
|
51
|
+
if (await hasExistingAdminUi(root))
|
|
52
|
+
return { source: 'adopted' };
|
|
53
|
+
const rawConfig = JSON.parse(await readFile(join(root, 'components.json'), 'utf8'));
|
|
54
|
+
const aliases = rawConfig !== null && typeof rawConfig === 'object' && 'aliases' in rawConfig
|
|
55
|
+
? rawConfig.aliases
|
|
56
|
+
: null;
|
|
57
|
+
if (aliases === null ||
|
|
58
|
+
typeof aliases !== 'object' ||
|
|
59
|
+
!('ui' in aliases) ||
|
|
60
|
+
aliases.ui !== '@/components/ui' ||
|
|
61
|
+
!('components' in aliases) ||
|
|
62
|
+
aliases.components !== '@/components') {
|
|
63
|
+
throw new Error('admin-ui requires shadcn aliases for @/components and @/components/ui');
|
|
64
|
+
}
|
|
65
|
+
const missing = (await Promise.all(primitives.map(async (name) => (await pathExists(root, 'src/components/ui/' + name + '.tsx')) ? null : name))).filter((name) => name !== null);
|
|
66
|
+
if (missing.length) {
|
|
67
|
+
throw new Error('admin-ui requires shadcn components: ' + missing.join(', ') + '. Add them first.');
|
|
68
|
+
}
|
|
69
|
+
// Read all inputs before changing the project; generated files become project-owned.
|
|
70
|
+
const templates = await Promise.all(components.map(async (name) => ({
|
|
71
|
+
name,
|
|
72
|
+
content: await readFile(new URL('./admin-ui-templates/' + name + '.tsx.template', import.meta.url), 'utf8'),
|
|
73
|
+
})));
|
|
74
|
+
for (const { name, content } of templates) {
|
|
75
|
+
await writeProjectFileIfMissing(root, 'src/components/admin/' + name + '.tsx', content);
|
|
76
|
+
}
|
|
77
|
+
return { source: 'installed' };
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { abacRecipe } from "./abac.js";
|
|
2
|
+
import { adminUiRecipe } from "./admin-ui.js";
|
|
2
3
|
import { authRecipe } from "./auth.js";
|
|
3
4
|
import { convexRecipe } from "./convex.js";
|
|
4
5
|
import { expoRecipe } from "./expo.js";
|
|
@@ -32,6 +33,7 @@ const RECIPES = new Map([
|
|
|
32
33
|
[authRecipe.id, authRecipe],
|
|
33
34
|
[multiTenancyRecipe.id, multiTenancyRecipe],
|
|
34
35
|
[abacRecipe.id, abacRecipe],
|
|
36
|
+
[adminUiRecipe.id, adminUiRecipe],
|
|
35
37
|
[sentryRecipe.id, sentryRecipe],
|
|
36
38
|
[loggingRecipe.id, loggingRecipe],
|
|
37
39
|
[paymentsRecipe.id, paymentsRecipe],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@specdest/devkit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"specdest": "dist/npm/cli.js"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"rules:audit": "node scripts/generate-rule-audit.mjs --check",
|
|
38
38
|
"rules:audit:write": "node scripts/generate-rule-audit.mjs",
|
|
39
39
|
"typecheck:checkers": "node scripts/typecheck-checkers.mjs",
|
|
40
|
-
"build": "node -e \"require('node:fs').rmSync('dist/npm',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
40
|
+
"build": "node -e \"require('node:fs').rmSync('dist/npm',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && node scripts/copy-admin-ui-templates.mjs",
|
|
41
41
|
"prepack": "pnpm run build",
|
|
42
42
|
"format:check": "oxfmt --check src/*.ts",
|
|
43
43
|
"format": "oxfmt --write src/*.ts"
|