@specdest/devkit 0.4.19 → 0.4.20

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.
Files changed (164) hide show
  1. package/README.md +105 -28
  2. package/dist/npm/cli.js +16 -26
  3. package/dist/npm/index.js +4 -1
  4. package/dist/npm/native/specdest-darwin-arm64 +0 -0
  5. package/dist/npm/native/specdest-darwin-x64 +0 -0
  6. package/dist/npm/native/specdest-linux-arm64 +0 -0
  7. package/dist/npm/native/specdest-linux-x64 +0 -0
  8. package/package.json +8 -5
  9. package/dist/npm/automation-policy.d.ts +0 -2
  10. package/dist/npm/automation-policy.js +0 -30
  11. package/dist/npm/canonical-project-operations.d.ts +0 -5
  12. package/dist/npm/canonical-project-operations.js +0 -5
  13. package/dist/npm/canonical-project.d.ts +0 -21
  14. package/dist/npm/canonical-project.js +0 -115
  15. package/dist/npm/catalog-snapshot.d.ts +0 -53
  16. package/dist/npm/catalog-snapshot.js +0 -35
  17. package/dist/npm/client-only-boundary.d.ts +0 -1
  18. package/dist/npm/client-only-boundary.js +0 -29
  19. package/dist/npm/commands.d.ts +0 -16
  20. package/dist/npm/commands.js +0 -194
  21. package/dist/npm/git-catalog.d.ts +0 -40
  22. package/dist/npm/git-catalog.js +0 -222
  23. package/dist/npm/github-doppler-secrets.d.ts +0 -8
  24. package/dist/npm/github-doppler-secrets.js +0 -156
  25. package/dist/npm/host-automation.d.ts +0 -9
  26. package/dist/npm/host-automation.js +0 -87
  27. package/dist/npm/installer-primitives.d.ts +0 -3
  28. package/dist/npm/installer-primitives.js +0 -50
  29. package/dist/npm/predefined-packages/abac.d.ts +0 -2
  30. package/dist/npm/predefined-packages/abac.js +0 -45
  31. package/dist/npm/predefined-packages/admin-ui-templates/AdminAccessAssignments.tsx.template +0 -67
  32. package/dist/npm/predefined-packages/admin-ui-templates/AdminConfirmDialog.tsx.template +0 -46
  33. package/dist/npm/predefined-packages/admin-ui-templates/AdminDataTable.tsx.template +0 -49
  34. package/dist/npm/predefined-packages/admin-ui-templates/AdminDetailLayout.tsx.template +0 -15
  35. package/dist/npm/predefined-packages/admin-ui-templates/AdminEmptyState.tsx.template +0 -17
  36. package/dist/npm/predefined-packages/admin-ui-templates/AdminFilterBar.tsx.template +0 -16
  37. package/dist/npm/predefined-packages/admin-ui-templates/AdminFormLayout.tsx.template +0 -19
  38. package/dist/npm/predefined-packages/admin-ui-templates/AdminMembershipManager.tsx.template +0 -56
  39. package/dist/npm/predefined-packages/admin-ui-templates/AdminPage.tsx.template +0 -19
  40. package/dist/npm/predefined-packages/admin-ui-templates/AdminPageHeader.tsx.template +0 -19
  41. package/dist/npm/predefined-packages/admin-ui-templates/AdminPagination.tsx.template +0 -20
  42. package/dist/npm/predefined-packages/admin-ui-templates/AdminPermissionMatrix.tsx.template +0 -54
  43. package/dist/npm/predefined-packages/admin-ui-templates/AdminRoleManager.tsx.template +0 -81
  44. package/dist/npm/predefined-packages/admin-ui-templates/AdminShell.tsx.template +0 -20
  45. package/dist/npm/predefined-packages/admin-ui-templates/AdminSidebar.tsx.template +0 -18
  46. package/dist/npm/predefined-packages/admin-ui-templates/AdminStatCard.tsx.template +0 -22
  47. package/dist/npm/predefined-packages/admin-ui.d.ts +0 -2
  48. package/dist/npm/predefined-packages/admin-ui.js +0 -83
  49. package/dist/npm/predefined-packages/auth-templates/README.md.template +0 -9
  50. package/dist/npm/predefined-packages/auth-templates/convex.ts.template +0 -18
  51. package/dist/npm/predefined-packages/auth-templates/identity.ts.template +0 -2
  52. package/dist/npm/predefined-packages/auth-templates/supabase.ts.template +0 -36
  53. package/dist/npm/predefined-packages/auth.d.ts +0 -2
  54. package/dist/npm/predefined-packages/auth.js +0 -36
  55. package/dist/npm/predefined-packages/convex.d.ts +0 -2
  56. package/dist/npm/predefined-packages/convex.js +0 -53
  57. package/dist/npm/predefined-packages/expo.d.ts +0 -2
  58. package/dist/npm/predefined-packages/expo.js +0 -88
  59. package/dist/npm/predefined-packages/firebase-hosting.d.ts +0 -2
  60. package/dist/npm/predefined-packages/firebase-hosting.js +0 -24
  61. package/dist/npm/predefined-packages/health.d.ts +0 -10
  62. package/dist/npm/predefined-packages/health.js +0 -52
  63. package/dist/npm/predefined-packages/husky.d.ts +0 -2
  64. package/dist/npm/predefined-packages/husky.js +0 -57
  65. package/dist/npm/predefined-packages/index.d.ts +0 -12
  66. package/dist/npm/predefined-packages/index.js +0 -97
  67. package/dist/npm/predefined-packages/install.d.ts +0 -19
  68. package/dist/npm/predefined-packages/install.js +0 -86
  69. package/dist/npm/predefined-packages/local-logging.d.ts +0 -2
  70. package/dist/npm/predefined-packages/local-logging.js +0 -17
  71. package/dist/npm/predefined-packages/logging.d.ts +0 -2
  72. package/dist/npm/predefined-packages/logging.js +0 -21
  73. package/dist/npm/predefined-packages/multi-tenancy.d.ts +0 -2
  74. package/dist/npm/predefined-packages/multi-tenancy.js +0 -37
  75. package/dist/npm/predefined-packages/nps.d.ts +0 -2
  76. package/dist/npm/predefined-packages/nps.js +0 -32
  77. package/dist/npm/predefined-packages/oxfmt.d.ts +0 -2
  78. package/dist/npm/predefined-packages/oxfmt.js +0 -22
  79. package/dist/npm/predefined-packages/oxlint.d.ts +0 -2
  80. package/dist/npm/predefined-packages/oxlint.js +0 -35
  81. package/dist/npm/predefined-packages/package-json.d.ts +0 -3
  82. package/dist/npm/predefined-packages/package-json.js +0 -61
  83. package/dist/npm/predefined-packages/payments.d.ts +0 -2
  84. package/dist/npm/predefined-packages/payments.js +0 -31
  85. package/dist/npm/predefined-packages/playwright.d.ts +0 -2
  86. package/dist/npm/predefined-packages/playwright.js +0 -35
  87. package/dist/npm/predefined-packages/project-signals.d.ts +0 -4
  88. package/dist/npm/predefined-packages/project-signals.js +0 -39
  89. package/dist/npm/predefined-packages/registry.d.ts +0 -3
  90. package/dist/npm/predefined-packages/registry.js +0 -65
  91. package/dist/npm/predefined-packages/resolver.d.ts +0 -8
  92. package/dist/npm/predefined-packages/resolver.js +0 -35
  93. package/dist/npm/predefined-packages/security-templates/README.md.template +0 -15
  94. package/dist/npm/predefined-packages/security-templates/convex-authorization.ts.template +0 -109
  95. package/dist/npm/predefined-packages/security-templates/permissions.ts.template +0 -40
  96. package/dist/npm/predefined-packages/security-templates/supabase-admin-rpc.sql.template +0 -54
  97. package/dist/npm/predefined-packages/security-templates/supabase-authorization.sql.template +0 -138
  98. package/dist/npm/predefined-packages/security-templates/supabase-posts-example.sql.template +0 -39
  99. package/dist/npm/predefined-packages/sentry.d.ts +0 -2
  100. package/dist/npm/predefined-packages/sentry.js +0 -29
  101. package/dist/npm/predefined-packages/shadcn.d.ts +0 -2
  102. package/dist/npm/predefined-packages/shadcn.js +0 -23
  103. package/dist/npm/predefined-packages/storybook.d.ts +0 -2
  104. package/dist/npm/predefined-packages/storybook.js +0 -25
  105. package/dist/npm/predefined-packages/stryker.d.ts +0 -2
  106. package/dist/npm/predefined-packages/stryker.js +0 -48
  107. package/dist/npm/predefined-packages/supabase.d.ts +0 -2
  108. package/dist/npm/predefined-packages/supabase.js +0 -355
  109. package/dist/npm/predefined-packages/tailwind.d.ts +0 -2
  110. package/dist/npm/predefined-packages/tailwind.js +0 -18
  111. package/dist/npm/predefined-packages/tanstack-form.d.ts +0 -2
  112. package/dist/npm/predefined-packages/tanstack-form.js +0 -19
  113. package/dist/npm/predefined-packages/tanstack-query.d.ts +0 -2
  114. package/dist/npm/predefined-packages/tanstack-query.js +0 -15
  115. package/dist/npm/predefined-packages/tanstack-router.d.ts +0 -2
  116. package/dist/npm/predefined-packages/tanstack-router.js +0 -18
  117. package/dist/npm/predefined-packages/tenant-templates/README.md.template +0 -11
  118. package/dist/npm/predefined-packages/tenant-templates/tenant-context.ts.template +0 -22
  119. package/dist/npm/predefined-packages/types.d.ts +0 -38
  120. package/dist/npm/predefined-packages/types.js +0 -1
  121. package/dist/npm/predefined-packages/vite.d.ts +0 -2
  122. package/dist/npm/predefined-packages/vite.js +0 -127
  123. package/dist/npm/predefined-packages/vitest.d.ts +0 -2
  124. package/dist/npm/predefined-packages/vitest.js +0 -20
  125. package/dist/npm/predefined-packages/zod.d.ts +0 -2
  126. package/dist/npm/predefined-packages/zod.js +0 -18
  127. package/dist/npm/project-check.d.ts +0 -37
  128. package/dist/npm/project-check.js +0 -231
  129. package/dist/npm/project-context.d.ts +0 -52
  130. package/dist/npm/project-context.js +0 -211
  131. package/dist/npm/project-install-guard.d.ts +0 -2
  132. package/dist/npm/project-install-guard.js +0 -51
  133. package/dist/npm/project-rules.d.ts +0 -25
  134. package/dist/npm/project-rules.js +0 -106
  135. package/dist/npm/project-runtime.d.ts +0 -21
  136. package/dist/npm/project-runtime.js +0 -41
  137. package/dist/npm/project-status.d.ts +0 -32
  138. package/dist/npm/project-status.js +0 -70
  139. package/dist/npm/project-sync.d.ts +0 -7
  140. package/dist/npm/project-sync.js +0 -143
  141. package/dist/npm/remote-installer.d.ts +0 -35
  142. package/dist/npm/remote-installer.js +0 -351
  143. package/dist/npm/rule-id-migrations.d.ts +0 -6
  144. package/dist/npm/rule-id-migrations.js +0 -19
  145. package/dist/npm/slack.d.ts +0 -16
  146. package/dist/npm/slack.js +0 -135
  147. package/dist/npm/snapshot/config.d.ts +0 -10
  148. package/dist/npm/snapshot/config.js +0 -24
  149. package/dist/npm/snapshot/policy.d.ts +0 -1
  150. package/dist/npm/snapshot/policy.js +0 -64
  151. package/dist/npm/snapshot/restore.d.ts +0 -10
  152. package/dist/npm/snapshot/restore.js +0 -19
  153. package/dist/npm/snapshot/sql.d.ts +0 -2
  154. package/dist/npm/snapshot/sql.js +0 -113
  155. package/dist/npm/snapshot/storage.d.ts +0 -8
  156. package/dist/npm/snapshot/storage.js +0 -70
  157. package/dist/npm/snapshot/verify.d.ts +0 -11
  158. package/dist/npm/snapshot/verify.js +0 -13
  159. package/dist/npm/snapshot-cli.d.ts +0 -6
  160. package/dist/npm/snapshot-cli.js +0 -45
  161. package/dist/npm/state.d.ts +0 -14
  162. package/dist/npm/state.js +0 -269
  163. package/dist/npm/supabase-local.d.ts +0 -2
  164. package/dist/npm/supabase-local.js +0 -63
@@ -1,81 +0,0 @@
1
- import { useState } from 'react';
2
- import { AdminPermissionMatrix, type PermissionCell } from './AdminPermissionMatrix';
3
- import { AdminConfirmDialog } from './AdminConfirmDialog';
4
-
5
- export type ManagedRole = {
6
- id: string;
7
- name: string;
8
- tenantId: string | null;
9
- permissions: readonly PermissionCell[];
10
- };
11
-
12
- type Props = {
13
- roles: readonly ManagedRole[];
14
- tenantId: string | null;
15
- resources: readonly string[];
16
- actions: readonly string[];
17
- onCreate: (name: string, tenantId: string | null) => void;
18
- onRename: (roleId: string, name: string) => void;
19
- onDelete: (roleId: string) => void;
20
- onPermissionsChange: (roleId: string, permissions: PermissionCell[]) => void;
21
- disabled?: boolean;
22
- };
23
-
24
- /** All callbacks must call trusted, admin-authorized server handlers. */
25
- export function AdminRoleManager({
26
- roles, tenantId, resources, actions, onCreate, onRename, onDelete, onPermissionsChange,
27
- disabled = false,
28
- }: Props) {
29
- const [query, setQuery] = useState('');
30
- const [name, setName] = useState('');
31
- const [selectedId, setSelectedId] = useState<string | null>(null);
32
- const visible = roles.filter((role) => role.tenantId === tenantId && role.name.toLowerCase().includes(query.toLowerCase()));
33
- const selected = roles.find((role) => role.id === selectedId && role.tenantId === tenantId);
34
-
35
- return (
36
- <section aria-label="Role management" className="space-y-4">
37
- <header className="flex flex-wrap items-center gap-3">
38
- <input aria-label="Search roles" className="rounded-md border p-2" value={query} onChange={(event) => setQuery(event.target.value)} />
39
- <form onSubmit={(event) => {
40
- event.preventDefault();
41
- if (!disabled && name.trim()) {
42
- onCreate(name.trim(), tenantId);
43
- setName('');
44
- }
45
- }} className="flex gap-2">
46
- <input aria-label="New role name" className="rounded-md border p-2" required value={name} onChange={(event) => setName(event.target.value)} disabled={disabled} />
47
- <button className="rounded-md border px-3" type="submit" disabled={disabled || !name.trim()}>Create role</button>
48
- </form>
49
- </header>
50
- <div className="flex flex-wrap gap-2">
51
- {visible.map((role) => (
52
- <button key={role.id} type="button" aria-pressed={selected?.id === role.id}
53
- className="rounded-md border px-3 py-2 aria-pressed:bg-muted"
54
- onClick={() => setSelectedId(role.id)}>{role.name}</button>
55
- ))}
56
- {visible.length === 0 ? <p>No roles found</p> : null}
57
- </div>
58
- {selected ? (
59
- <div className="space-y-4 rounded-lg border p-4" key={selected.id}>
60
- <form className="flex flex-wrap gap-2" onSubmit={(event) => {
61
- event.preventDefault();
62
- const data = new FormData(event.currentTarget);
63
- const nextName = data.get('roleName');
64
- if (!disabled && typeof nextName === 'string' && nextName.trim()) onRename(selected.id, nextName.trim());
65
- }}>
66
- <input name="roleName" aria-label="Role name" defaultValue={selected.name} required className="rounded-md border p-2" disabled={disabled} />
67
- <button type="submit" className="rounded-md border px-3" disabled={disabled}>Rename</button>
68
- {!disabled ? <AdminConfirmDialog
69
- trigger={<button type="button" className="rounded-md border px-3">Delete role</button>}
70
- title="Delete role"
71
- description={`Delete ${selected.name}? This may revoke user and group permissions.`}
72
- onConfirm={() => { onDelete(selected.id); setSelectedId(null); }}
73
- /> : null}
74
- </form>
75
- <AdminPermissionMatrix resources={resources} actions={actions} value={selected.permissions}
76
- onChange={(permissions) => onPermissionsChange(selected.id, permissions)} disabled={disabled} />
77
- </div>
78
- ) : null}
79
- </section>
80
- );
81
- }
@@ -1,20 +0,0 @@
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
- }
@@ -1,18 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const adminUiRecipe: PackageRecipe;
@@ -1,83 +0,0 @@
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
- 'AdminPermissionMatrix',
19
- 'AdminRoleManager',
20
- 'AdminAccessAssignments',
21
- 'AdminMembershipManager',
22
- ];
23
- const primitives = ['alert-dialog', 'card', 'sidebar', 'table'];
24
- async function hasExistingAdminUi(root) {
25
- // Existing project-owned shared admin page systems are adopted, not replaced.
26
- return ((await pathExists(root, 'src/components/extra/admin-list-layout.tsx')) &&
27
- (await pathExists(root, 'src/components/extra/admin-list-states.tsx')));
28
- }
29
- async function templateCount(root) {
30
- const files = await Promise.all(components.map((name) => pathExists(root, 'src/components/admin/' + name + '.tsx')));
31
- return files.filter(Boolean).length;
32
- }
33
- export const adminUiRecipe = {
34
- id: 'admin-ui',
35
- recipeVersion: '1.3.0',
36
- role: 'feature',
37
- requires: ['shadcn'],
38
- async detect(root) {
39
- if (await hasExistingAdminUi(root)) {
40
- return { present: true, compatible: true, detectedVersion: null };
41
- }
42
- const count = await templateCount(root);
43
- return {
44
- present: count > 0,
45
- compatible: count === components.length,
46
- detectedVersion: null,
47
- ...(count > 0 && count < components.length
48
- ? {
49
- reason: 'Admin UI has only ' + count + ' of ' + components.length + ' source components',
50
- }
51
- : {}),
52
- };
53
- },
54
- async apply(root) {
55
- if (await hasExistingAdminUi(root))
56
- return { source: 'adopted' };
57
- const rawConfig = JSON.parse(await readFile(join(root, 'components.json'), 'utf8'));
58
- const aliases = rawConfig !== null && typeof rawConfig === 'object' && 'aliases' in rawConfig
59
- ? rawConfig.aliases
60
- : null;
61
- if (aliases === null ||
62
- typeof aliases !== 'object' ||
63
- !('ui' in aliases) ||
64
- aliases.ui !== '@/components/ui' ||
65
- !('components' in aliases) ||
66
- aliases.components !== '@/components') {
67
- throw new Error('admin-ui requires shadcn aliases for @/components and @/components/ui');
68
- }
69
- const missing = (await Promise.all(primitives.map(async (name) => (await pathExists(root, 'src/components/ui/' + name + '.tsx')) ? null : name))).filter((name) => name !== null);
70
- if (missing.length) {
71
- throw new Error('admin-ui requires shadcn components: ' + missing.join(', ') + '. Add them first.');
72
- }
73
- // Read all inputs before changing the project; generated files become project-owned.
74
- const templates = await Promise.all(components.map(async (name) => ({
75
- name,
76
- content: await readFile(new URL('./admin-ui-templates/' + name + '.tsx.template', import.meta.url), 'utf8'),
77
- })));
78
- for (const { name, content } of templates) {
79
- await writeProjectFileIfMissing(root, 'src/components/admin/' + name + '.tsx', content);
80
- }
81
- return { source: 'installed' };
82
- },
83
- };
@@ -1,9 +0,0 @@
1
- # Authentication integration
2
-
3
- These are project-owned integration helpers, **not a configured login flow**.
4
-
5
- - Supabase variant requires an initialized Supabase client. `getIdentity` validates the user through Supabase Auth; authorization still belongs in database RLS.
6
- - For Expo iOS, use `expo-apple-authentication` native Apple Sign-In, obtain a native ID token and pass the correct original nonce to `signInWithNativeAppleToken`. The app owns the nonce generation and lifecycle; this template does not implement it.
7
- - Convex variant requires a working compatible identity provider configured in `convex/auth.config.ts`. The helper uses Convex's verified server context; the application owns web/Expo login and session state. Convex authorization belongs in protected server queries/mutations.
8
- - Neither variant stores passwords, creates identity servers, or installs Clerk.
9
- - Provider credentials, redirect URLs, client wiring, social providers, token lifetimes and Expo platform integration must be configured and tested per application before release.
@@ -1,18 +0,0 @@
1
- import type { Identity } from './identity';
2
-
3
- /** For Convex queries/mutations only: ctx.auth is verified by configured identity provider. */
4
- export async function getIdentity(ctx: { auth: { getUserIdentity(): Promise<{
5
- subject: string;
6
- email?: string;
7
- name?: string;
8
- } | null> } }): Promise<Identity | null> {
9
- const user = await ctx.auth.getUserIdentity();
10
- if (!user?.subject) return null;
11
- return { id: user.subject, email: user.email ?? null, name: user.name ?? null };
12
- }
13
-
14
- export async function requireIdentity(ctx: Parameters<typeof getIdentity>[0]): Promise<Identity> {
15
- const identity = await getIdentity(ctx);
16
- if (!identity) throw new Error('Unauthorized');
17
- return identity;
18
- }
@@ -1,2 +0,0 @@
1
- /** Stable app-facing identity shape. Email is optional for social/anonymous providers. */
2
- export type Identity = { id: string; email: string | null; name: string | null };
@@ -1,36 +0,0 @@
1
- import type { SupabaseClient } from '@supabase/supabase-js';
2
- import type { Identity } from './identity';
3
-
4
- /** Always fetch a verified user. Do not trust the locally cached session user for authorization. */
5
- export async function getIdentity(client: SupabaseClient): Promise<Identity | null> {
6
- const { data, error } = await client.auth.getUser();
7
- if (error || !data.user) return null;
8
- return {
9
- id: data.user.id,
10
- email: data.user.email ?? null,
11
- name: typeof data.user.user_metadata?.full_name === 'string' ? data.user.user_metadata.full_name : null,
12
- };
13
- }
14
-
15
- export async function signInWithPassword(client: SupabaseClient, email: string, password: string) {
16
- const { error } = await client.auth.signInWithPassword({ email, password });
17
- if (error) throw error;
18
- }
19
-
20
- export async function signInWithOAuth(client: SupabaseClient, provider: 'google' | 'github' | 'apple', redirectTo: string) {
21
- const { data, error } = await client.auth.signInWithOAuth({ provider, options: { redirectTo } });
22
- if (error) throw error;
23
- return data;
24
- }
25
-
26
- /** Native Apple ID token from expo-apple-authentication, with validated nonce flow. */
27
- export async function signInWithNativeAppleToken(client: SupabaseClient, idToken: string, nonce: string) {
28
- if (!idToken || !nonce) throw new Error('Apple credential and nonce required');
29
- const { error } = await client.auth.signInWithIdToken({ provider: 'apple', token: idToken, nonce });
30
- if (error) throw error;
31
- }
32
-
33
- export async function signOut(client: SupabaseClient) {
34
- const { error } = await client.auth.signOut();
35
- if (error) throw error;
36
- }
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const authRecipe: PackageRecipe;
@@ -1,36 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { writeProjectFileIfMissing } from "./install.js";
3
- import { detectAnyPath } from "./project-signals.js";
4
- export const authRecipe = {
5
- id: 'auth',
6
- recipeVersion: '1.1.0',
7
- role: 'feature',
8
- variants: [
9
- { id: 'supabase', when: ['supabase'] },
10
- { id: 'convex', when: ['convex'] },
11
- ],
12
- async detect(projectRoot) {
13
- return await detectAnyPath(projectRoot, ['src/application/auth', 'src/auth', 'app/auth', 'convex/auth.ts', 'convex/auth.config.ts'], 'authentication integration was not detected');
14
- },
15
- async apply(root, detection, resolution) {
16
- if (detection.present) {
17
- if (!detection.compatible)
18
- throw new Error(detection.reason ?? 'Existing auth integration is not compatible.');
19
- return { source: 'adopted' };
20
- }
21
- if (!resolution.variant)
22
- throw new Error('Auth requires a resolved backend.');
23
- const filenames = ['identity.ts', resolution.variant + '.ts'];
24
- const files = await Promise.all(filenames.map(async (name) => ({
25
- destination: 'src/application/auth/' + name,
26
- content: await readFile(new URL('./auth-templates/' + name + '.template', import.meta.url), 'utf8'),
27
- })));
28
- files.push({
29
- destination: 'docs/security/auth.md',
30
- content: await readFile(new URL('./auth-templates/README.md.template', import.meta.url), 'utf8'),
31
- });
32
- for (const file of files)
33
- await writeProjectFileIfMissing(root, file.destination, file.content);
34
- return { source: 'installed' };
35
- },
36
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const convexRecipe: PackageRecipe;
@@ -1,53 +0,0 @@
1
- import { ensurePnpmBuildPolicy, mergeMissing, projectPackageName, updatePackageJson, writeProjectFileIfMissing } from "./install.js";
2
- import { detectDependency } from "./package-json.js";
3
- async function installConvex(projectRoot, context) {
4
- await updatePackageJson(projectRoot, (pkg) => ({
5
- ...pkg,
6
- name: pkg.name ?? projectPackageName(projectRoot),
7
- private: pkg.private ?? true,
8
- packageManager: pkg.packageManager ?? 'pnpm@11.6.0',
9
- engines: {
10
- ...pkg.engines,
11
- node: pkg.engines?.node ?? '>=24.0.0',
12
- pnpm: pkg.engines?.pnpm ?? '>=11.0.0',
13
- },
14
- scripts: mergeMissing(pkg.scripts, {
15
- 'convex:dev': 'convex dev',
16
- 'convex:codegen': 'convex codegen --typecheck=disable',
17
- }),
18
- dependencies: mergeMissing(pkg.dependencies, {
19
- convex: '1.43.0',
20
- }),
21
- }));
22
- await ensurePnpmBuildPolicy(projectRoot);
23
- await writeProjectFileIfMissing(projectRoot, 'convex/schema.ts', `import { defineSchema } from 'convex/server';
24
-
25
- export default defineSchema({});
26
- `);
27
- const expo = await detectDependency(projectRoot, 'expo', 'Expo');
28
- if (expo.present) {
29
- await writeProjectFileIfMissing(projectRoot, 'src/integrations/convex/config.ts', `export function convexConfig() {
30
- return { url: process.env.EXPO_PUBLIC_CONVEX_URL ?? '' };
31
- }
32
- `);
33
- }
34
- await context.runCommand('pnpm', ['install', '--no-frozen-lockfile'], { cwd: projectRoot });
35
- }
36
- export const convexRecipe = {
37
- id: 'convex',
38
- recipeVersion: '1.1.1',
39
- role: 'backend',
40
- conflicts: ['supabase'],
41
- async detect(projectRoot) {
42
- return await detectDependency(projectRoot, 'convex', 'Convex');
43
- },
44
- async apply(projectRoot, detection, _resolution, context) {
45
- if (detection.present) {
46
- if (!detection.compatible)
47
- throw new Error(detection.reason ?? 'Existing Convex setup is not compatible.');
48
- return { source: 'adopted' };
49
- }
50
- await installConvex(projectRoot, context);
51
- return { source: 'installed' };
52
- },
53
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const expoRecipe: PackageRecipe;
@@ -1,88 +0,0 @@
1
- import { ensurePnpmBuildPolicy, mergeMissing, projectPackageName, updatePackageJson, writeProjectFileIfMissing } from "./install.js";
2
- import { detectDependency } from "./package-json.js";
3
- const dependencies = {
4
- expo: '57.0.19',
5
- react: '19.2.3',
6
- 'react-dom': '19.2.3',
7
- 'react-native': '0.86.3',
8
- 'react-native-web': '0.21.2',
9
- };
10
- const devDependencies = {
11
- '@types/react': '19.2.14',
12
- typescript: '6.0.3',
13
- };
14
- async function installExpo(projectRoot, context) {
15
- const pkg = await updatePackageJson(projectRoot, (current) => ({
16
- ...current,
17
- name: current.name ?? projectPackageName(projectRoot),
18
- private: current.private ?? true,
19
- main: current.main ?? 'index.ts',
20
- packageManager: current.packageManager ?? 'pnpm@11.6.0',
21
- engines: {
22
- ...current.engines,
23
- node: current.engines?.node ?? '>=24.0.0',
24
- pnpm: current.engines?.pnpm ?? '>=11.0.0',
25
- },
26
- scripts: mergeMissing(current.scripts, {
27
- start: 'expo start',
28
- android: 'expo start --android',
29
- ios: 'expo start --ios',
30
- web: 'expo start --web',
31
- typecheck: 'tsc --noEmit',
32
- }),
33
- dependencies: mergeMissing(current.dependencies, dependencies),
34
- devDependencies: mergeMissing(current.devDependencies, devDependencies),
35
- }));
36
- const name = pkg.name;
37
- await ensurePnpmBuildPolicy(projectRoot);
38
- await writeProjectFileIfMissing(projectRoot, 'index.ts', `import { registerRootComponent } from 'expo';
39
- import App from './App';
40
-
41
- registerRootComponent(App);
42
- `);
43
- await writeProjectFileIfMissing(projectRoot, 'App.tsx', `import { SafeAreaView, Text } from 'react-native';
44
-
45
- export default function App() {
46
- return <SafeAreaView><Text>Specdest app</Text></SafeAreaView>;
47
- }
48
- `);
49
- await writeProjectFileIfMissing(projectRoot, 'app.json', `${JSON.stringify({
50
- expo: {
51
- name,
52
- slug: name,
53
- version: '1.0.0',
54
- orientation: 'portrait',
55
- userInterfaceStyle: 'automatic',
56
- },
57
- }, null, 2)}\n`);
58
- await writeProjectFileIfMissing(projectRoot, 'tsconfig.json', `{
59
- "extends": "expo/tsconfig.base",
60
- "compilerOptions": {
61
- "strict": true
62
- }
63
- }
64
- `);
65
- await context.runCommand('pnpm', ['install', '--no-frozen-lockfile'], { cwd: projectRoot });
66
- }
67
- export const expoRecipe = {
68
- id: 'expo',
69
- recipeVersion: '1.2.0',
70
- role: 'frontend',
71
- setupRequirements: [
72
- { kind: 'package', packageId: 'oxlint', required: true },
73
- { kind: 'package', packageId: 'husky', required: true, when: 'git' },
74
- ],
75
- conflicts: ['vite'],
76
- async detect(projectRoot) {
77
- return await detectDependency(projectRoot, 'expo', 'Expo');
78
- },
79
- async apply(projectRoot, detection, _resolution, context) {
80
- if (detection.present) {
81
- if (!detection.compatible)
82
- throw new Error(detection.reason ?? 'Existing Expo setup is not compatible.');
83
- return { source: 'adopted' };
84
- }
85
- await installExpo(projectRoot, context);
86
- return { source: 'installed' };
87
- },
88
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const firebaseHostingRecipe: PackageRecipe;
@@ -1,24 +0,0 @@
1
- import { detectDependency } from "./package-json.js";
2
- import { pathExists } from "./project-signals.js";
3
- export const firebaseHostingRecipe = {
4
- id: 'firebase-hosting',
5
- recipeVersion: '1.0.0',
6
- role: 'integration',
7
- requires: ['vite'],
8
- async detect(projectRoot) {
9
- const [firebaseJson, firebaseRc, tools] = await Promise.all([
10
- pathExists(projectRoot, 'firebase.json'),
11
- pathExists(projectRoot, '.firebaserc'),
12
- detectDependency(projectRoot, 'firebase-tools', 'firebase-tools'),
13
- ]);
14
- if (firebaseJson && firebaseRc) {
15
- return { present: true, compatible: true, detectedVersion: tools.present ? tools.detectedVersion : null };
16
- }
17
- return { present: false, compatible: false, detectedVersion: null, reason: 'firebase.json and .firebaserc were not both found' };
18
- },
19
- async apply(_projectRoot, detection, _resolution) {
20
- if (!detection.present)
21
- throw new Error('Firebase Hosting configuration was not detected; creating Firebase Hosting configuration is not supported by `add firebase-hosting` yet.');
22
- return { source: 'adopted' };
23
- },
24
- };
@@ -1,10 +0,0 @@
1
- export declare function inspectPredefinedPackageState(projectRoot: string, state?: any): Promise<{
2
- registered: string[];
3
- present: string[];
4
- issues: string[];
5
- }>;
6
- export declare function assertPredefinedPackageState(projectRoot: string): Promise<{
7
- registered: string[];
8
- present: string[];
9
- issues: string[];
10
- }>;
@@ -1,52 +0,0 @@
1
- import { listPackageRecipes } from "./registry.js";
2
- import { installedPackageIds, resolvePackageAddition } from "./resolver.js";
3
- import { readInstalledState } from "../state.js";
4
- export async function inspectPredefinedPackageState(projectRoot, state) {
5
- const installedState = state ?? await readInstalledState(projectRoot);
6
- const recipes = listPackageRecipes();
7
- const byId = new Map(recipes.map((recipe) => [recipe.id, recipe]));
8
- const detections = new Map(await Promise.all(recipes.map(async (recipe) => [recipe.id, await recipe.detect(projectRoot)])));
9
- const registered = installedPackageIds(installedState);
10
- const present = recipes.filter((recipe) => detections.get(recipe.id)?.present).map((recipe) => recipe.id);
11
- const issues = [];
12
- for (const id of registered) {
13
- const recipe = byId.get(id);
14
- if (!recipe) {
15
- issues.push(`Unknown registered predefined package: ${id}`);
16
- continue;
17
- }
18
- const detection = detections.get(id);
19
- if (!detection?.present) {
20
- issues.push(`${id} is registered but no longer detected in the project`);
21
- continue;
22
- }
23
- if (!detection.compatible) {
24
- issues.push(`${id}: ${detection.reason ?? 'detected package is not compatible'}`);
25
- continue;
26
- }
27
- const registeredDependencies = registered.filter((candidate) => candidate !== id);
28
- const presentEnvironment = present.filter((candidate) => candidate !== id);
29
- try {
30
- const resolution = resolvePackageAddition(recipe, {
31
- registeredPackageIds: registeredDependencies,
32
- presentPackageIds: presentEnvironment,
33
- knownRecipes: recipes,
34
- });
35
- const recordedVariant = installedState.installed[id]?.resolvedVariant ?? null;
36
- if (recordedVariant !== resolution.variant) {
37
- issues.push(`${id} resolved variant changed from ${recordedVariant ?? 'none'} to ${resolution.variant ?? 'none'}`);
38
- }
39
- }
40
- catch (error) {
41
- issues.push(error.message);
42
- }
43
- }
44
- return { registered, present, issues: [...new Set(issues)].sort() };
45
- }
46
- export async function assertPredefinedPackageState(projectRoot) {
47
- const health = await inspectPredefinedPackageState(projectRoot);
48
- if (health.issues.length) {
49
- throw new Error(`Predefined package state is invalid:\n- ${health.issues.join('\n- ')}`);
50
- }
51
- return health;
52
- }
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const huskyRecipe: PackageRecipe;
@@ -1,57 +0,0 @@
1
- import { installPackageJsonPatch, makeProjectFileExecutable, writeProjectFileIfMissing, } from "./install.js";
2
- import { detectDependency } from "./package-json.js";
3
- import { pathExists } from "./project-signals.js";
4
- const preCommit = `#!/bin/sh
5
- set -eu
6
-
7
- npx --yes @specdest/devkit check --staged
8
- pnpm run typecheck
9
- `;
10
- const prePush = `#!/bin/sh
11
- set -eu
12
-
13
- npx --yes @specdest/devkit check
14
- `;
15
- export const huskyRecipe = {
16
- id: 'husky',
17
- recipeVersion: '1.1.0',
18
- role: 'tooling',
19
- async detect(projectRoot) {
20
- const dependency = await detectDependency(projectRoot, 'husky', 'Husky');
21
- if (!dependency.present)
22
- return dependency;
23
- const [preCommitExists, prePushExists] = await Promise.all([
24
- pathExists(projectRoot, '.husky/pre-commit'),
25
- pathExists(projectRoot, '.husky/pre-push'),
26
- ]);
27
- if (!preCommitExists || !prePushExists) {
28
- return {
29
- ...dependency,
30
- compatible: false,
31
- reason: 'Husky requires both .husky/pre-commit and .husky/pre-push for the Devkit verification contract',
32
- };
33
- }
34
- return dependency;
35
- },
36
- async apply(projectRoot, detection, _resolution, context) {
37
- if (detection.present) {
38
- if (!detection.compatible)
39
- throw new Error(detection.reason ?? 'Existing Husky integration is not compatible.');
40
- return { source: 'adopted' };
41
- }
42
- if (!(await pathExists(projectRoot, '.git'))) {
43
- throw new Error('Husky installation requires a Git repository');
44
- }
45
- await writeProjectFileIfMissing(projectRoot, '.husky/pre-commit', preCommit);
46
- await writeProjectFileIfMissing(projectRoot, '.husky/pre-push', prePush);
47
- await Promise.all([
48
- makeProjectFileExecutable(projectRoot, '.husky/pre-commit'),
49
- makeProjectFileExecutable(projectRoot, '.husky/pre-push'),
50
- ]);
51
- await installPackageJsonPatch(projectRoot, context.runCommand, {
52
- devDependencies: { husky: '9.1.7' },
53
- scripts: { prepare: 'husky' },
54
- });
55
- return { source: 'installed' };
56
- },
57
- };