@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,48 +0,0 @@
1
- import { installPackageJsonPatch, writeProjectFileIfMissing } from "./install.js";
2
- import { detectDependency } from "./package-json.js";
3
- import { detectAnyPath } from "./project-signals.js";
4
- const config = `export default {
5
- testRunner: 'vitest',
6
- reporters: ['progress', 'clear-text'],
7
- mutate: [
8
- 'src/**/*.{ts,tsx}',
9
- '!src/**/*.test.{ts,tsx}',
10
- '!src/**/*.stories.{ts,tsx}',
11
- ],
12
- };
13
- `;
14
- export const strykerRecipe = {
15
- id: 'stryker',
16
- recipeVersion: '1.1.0',
17
- role: 'tooling',
18
- requires: ['vitest'],
19
- async detect(projectRoot) {
20
- const core = await detectDependency(projectRoot, '@stryker-mutator/core', '@stryker-mutator/core');
21
- if (!core.present)
22
- return core;
23
- const runner = await detectDependency(projectRoot, '@stryker-mutator/vitest-runner', '@stryker-mutator/vitest-runner');
24
- if (!runner.present) {
25
- return { ...core, compatible: false, reason: '@stryker-mutator/vitest-runner was not found' };
26
- }
27
- const configDetection = await detectAnyPath(projectRoot, ['stryker.config.mjs', 'stryker.config.js', 'stryker.config.cjs', 'stryker.config.ts', 'stryker.conf.json'], 'Stryker configuration was not found');
28
- if (!configDetection.present)
29
- return { ...core, compatible: false, reason: configDetection.reason };
30
- return core;
31
- },
32
- async apply(projectRoot, detection, _resolution, context) {
33
- if (detection.present) {
34
- if (!detection.compatible)
35
- throw new Error(detection.reason ?? 'Existing Stryker integration is not compatible.');
36
- return { source: 'adopted' };
37
- }
38
- await writeProjectFileIfMissing(projectRoot, 'stryker.config.mjs', config);
39
- await installPackageJsonPatch(projectRoot, context.runCommand, {
40
- devDependencies: {
41
- '@stryker-mutator/core': '10.0.0',
42
- '@stryker-mutator/vitest-runner': '10.0.0',
43
- },
44
- scripts: { 'test:mutation': 'stryker run' },
45
- });
46
- return { source: 'installed' };
47
- },
48
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const supabaseRecipe: PackageRecipe;
@@ -1,355 +0,0 @@
1
- import { readFile, writeFile } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { ensurePnpmBuildPolicy, mergeMissing, projectPackageName, updatePackageJson, writeProjectFileIfMissing, } from "./install.js";
4
- import { detectDependency } from "./package-json.js";
5
- const bootstrapDatabaseTypes = `export type Database = {
6
- public: {
7
- Tables: {};
8
- Views: {};
9
- Functions: {};
10
- Enums: {};
11
- CompositeTypes: {};
12
- };
13
- };
14
- `;
15
- const bootstrapSchema = `// generated schema placeholder; regenerate after defining database tables.
16
- export {};
17
- `;
18
- const humanRemoteGuard = `const HUMAN_ACK = 'I_AM_A_HUMAN_RUNNING_REMOTE_INFRASTRUCTURE';
19
-
20
- const operationIndex = process.argv.indexOf('--operation');
21
- const operation = operationIndex >= 0 ? process.argv[operationIndex + 1] : undefined;
22
-
23
- if (!operation) {
24
- console.error('Remote-operation guard requires --operation <name>.');
25
- process.exit(1);
26
- }
27
-
28
- if (process.env.SPECDEST_HUMAN_REMOTE_ACK !== HUMAN_ACK) {
29
- console.error(
30
- \`Blocked \${operation}: set SPECDEST_HUMAN_REMOTE_ACK=\${HUMAN_ACK} only from an interactive human shell.\`,
31
- );
32
- process.exit(1);
33
- }
34
-
35
- if (!process.stdin.isTTY || !process.stdout.isTTY) {
36
- console.error(\`Blocked \${operation}: remote infrastructure commands require an interactive TTY.\`);
37
- process.exit(1);
38
- }
39
-
40
- console.log(\`Human-only remote operation approved: \${operation}\`);
41
- `;
42
- const productionReconcile = `const { spawnSync } = require('node:child_process');
43
- const fs = require('node:fs');
44
- const path = require('node:path');
45
-
46
- const MIGRATION_PREFIX = /^(\\d{14})_/;
47
-
48
- function formatMigrationTimestamp(date) {
49
- const pad = (value) => String(value).padStart(2, '0');
50
- return [
51
- date.getUTCFullYear(),
52
- pad(date.getUTCMonth() + 1),
53
- pad(date.getUTCDate()),
54
- pad(date.getUTCHours()),
55
- pad(date.getUTCMinutes()),
56
- pad(date.getUTCSeconds()),
57
- ].join('');
58
- }
59
-
60
- function parseMigrationTimestamp(value) {
61
- const year = Number(value.slice(0, 4));
62
- const month = Number(value.slice(4, 6)) - 1;
63
- const day = Number(value.slice(6, 8));
64
- const hour = Number(value.slice(8, 10));
65
- const minute = Number(value.slice(10, 12));
66
- const second = Number(value.slice(12, 14));
67
- return new Date(Date.UTC(year, month, day, hour, minute, second));
68
- }
69
-
70
- function nextMigrationTimestamp({ migrationsDir, now }) {
71
- const current = formatMigrationTimestamp(now);
72
- const latest = fs
73
- .readdirSync(migrationsDir)
74
- .map((name) => name.match(MIGRATION_PREFIX)?.[1])
75
- .filter(Boolean)
76
- .sort()
77
- .at(-1);
78
-
79
- if (!latest) {
80
- const previousSecond = new Date(now);
81
- previousSecond.setUTCSeconds(previousSecond.getUTCSeconds() - 1);
82
- return formatMigrationTimestamp(previousSecond);
83
- }
84
-
85
- const next = parseMigrationTimestamp(latest);
86
- next.setUTCSeconds(next.getUTCSeconds() + 1);
87
- const candidate = formatMigrationTimestamp(next);
88
- if (candidate >= current) {
89
- throw new Error(
90
- 'Cannot place production reconciliation before the next generated migration; retry after the clock advances.',
91
- );
92
- }
93
- return candidate;
94
- }
95
-
96
- function isIdentifier(value) {
97
- return /^[A-Za-z_][A-Za-z0-9_]*$/.test(value) || (value.startsWith('"') && value.endsWith('"'));
98
- }
99
-
100
- function matchesQualifiedStatement(trimmed, prefix, suffix) {
101
- if (!trimmed.startsWith(prefix) || !trimmed.endsWith(suffix)) return false;
102
- return isIdentifier(trimmed.slice(prefix.length, -suffix.length));
103
- }
104
-
105
- function isReplaySafeStatement(line) {
106
- const trimmed = line.trim();
107
- if (!trimmed) return false;
108
- if (
109
- ['ALTER TABLE public.', 'ALTER TABLE "public".'].some((prefix) =>
110
- matchesQualifiedStatement(trimmed, prefix, ' ENABLE ROW LEVEL SECURITY;'),
111
- )
112
- ) {
113
- return true;
114
- }
115
- return ['ALTER VIEW public.', 'ALTER VIEW "public".'].some((prefix) =>
116
- [
117
- ' SET (security_invoker=true);',
118
- ' SET (security_invoker = true);',
119
- ].some((suffix) => matchesQualifiedStatement(trimmed, prefix, suffix)),
120
- );
121
- }
122
-
123
- function isIgnorableDiffPreamble(line) {
124
- return line.trim() === 'SET check_function_bodies = false;';
125
- }
126
-
127
- function extractReplaySafeSql(sql) {
128
- const safe = [];
129
- const unsafe = [];
130
- for (const line of sql.split(/\\r?\\n/)) {
131
- if (!line.trim() || isIgnorableDiffPreamble(line)) continue;
132
- if (isReplaySafeStatement(line)) safe.push(line.trim());
133
- else unsafe.push(line);
134
- }
135
- return {
136
- safeSql: safe.length > 0 ? \`\${safe.join('\\n')}\\n\` : '',
137
- unsafeSql: unsafe.length > 0 ? \`\${unsafe.join('\\n')}\\n\` : '',
138
- };
139
- }
140
-
141
- function persistMigration({ migrationsDir, sql, now = new Date() }) {
142
- if (!sql.trim()) return null;
143
- fs.mkdirSync(migrationsDir, { recursive: true });
144
- const timestamp = nextMigrationTimestamp({ migrationsDir, now });
145
- const outputPath = path.join(migrationsDir, \`\${timestamp}_production_reconcile.sql\`);
146
- fs.writeFileSync(outputPath, \`\${sql.trimEnd()}\\n\`, { flag: 'wx' });
147
- return outputPath;
148
- }
149
-
150
- function persistReview({ reviewPath, sql }) {
151
- if (!sql.trim()) return null;
152
- fs.mkdirSync(path.dirname(reviewPath), { recursive: true });
153
- fs.writeFileSync(reviewPath, \`\${sql.trimEnd()}\\n\`);
154
- return reviewPath;
155
- }
156
-
157
- function run() {
158
- const dbUrl = process.env.SUPABASE_DB_URL;
159
- if (!dbUrl) throw new Error('SUPABASE_DB_URL is required');
160
-
161
- const result = spawnSync(
162
- 'pnpm',
163
- ['exec', 'supabase', 'db', 'diff', '--from', dbUrl, '--to', 'migrations'],
164
- {
165
- cwd: process.cwd(),
166
- encoding: 'utf8',
167
- env: process.env,
168
- maxBuffer: 50 * 1024 * 1024,
169
- stdio: ['inherit', 'pipe', 'inherit'],
170
- },
171
- );
172
-
173
- if (result.error) throw result.error;
174
- if (result.status !== 0) process.exit(result.status ?? 1);
175
-
176
- const rawSql = result.stdout ?? '';
177
- if (rawSql) process.stdout.write(rawSql);
178
- const { safeSql, unsafeSql } = extractReplaySafeSql(rawSql);
179
-
180
- if (unsafeSql) {
181
- const reviewPath = persistReview({
182
- reviewPath: path.resolve('supabase/.temp/production-reconcile-review.sql'),
183
- sql: rawSql,
184
- });
185
- console.error(
186
- \`Blocked production reconciliation: non-replay-safe drift detected. Review \${reviewPath}.\`,
187
- );
188
- process.exit(1);
189
- }
190
-
191
- const migrationPath = persistMigration({
192
- migrationsDir: path.resolve('supabase/migrations'),
193
- sql: safeSql,
194
- });
195
- if (migrationPath) console.error(\`Created replay-safe reconciliation migration at \${migrationPath}\`);
196
- else console.error('No production schema drift detected.');
197
- }
198
-
199
- if (require.main === module) run();
200
-
201
- module.exports = {
202
- extractReplaySafeSql,
203
- formatMigrationTimestamp,
204
- isReplaySafeStatement,
205
- nextMigrationTimestamp,
206
- persistMigration,
207
- persistReview,
208
- run,
209
- };
210
- `;
211
- const productionOperations = `#!/usr/bin/env bash
212
- set -euo pipefail
213
- cd "$(dirname "\${BASH_SOURCE[0]}")/../.."
214
-
215
- operation="\${1:-}"
216
- case "$operation" in
217
- reconcile|migrationGen|migrate|push|squash|generate|release) ;;
218
- *) echo 'Unsupported production database operation' >&2; exit 2 ;;
219
- esac
220
-
221
- # No production configuration is accessed before the human-only check.
222
- node scripts/safety/require-human-remote-operation.cjs --operation "prod.db.$operation"
223
- source ./supabase/.env.production
224
- : "\${SUPABASE_DB_URL:?SUPABASE_DB_URL must be configured}"
225
- export SUPABASE_DB_URL
226
-
227
- case "$operation" in
228
- reconcile)
229
- node scripts/db/generate-production-reconcile.cjs
230
- ;;
231
- migrationGen)
232
- pnpm exec supabase db schema declarative sync --experimental --no-apply --name schema_change
233
- ;;
234
- migrate)
235
- bash "$0" reconcile
236
- bash "$0" migrationGen
237
- pnpm exec supabase db push --db-url "$SUPABASE_DB_URL" --include-all
238
- ;;
239
- push)
240
- pnpm exec supabase db push --db-url "$SUPABASE_DB_URL" --yes
241
- ;;
242
- squash)
243
- pnpm exec supabase migration squash --db-url "$SUPABASE_DB_URL" --yes
244
- ;;
245
- generate)
246
- types_tmp="$(mktemp ./src/__generated__/.db-types-XXXXXX)"
247
- trap 'rm -f "$types_tmp"' EXIT
248
- pnpm exec supabase gen types typescript --db-url "$SUPABASE_DB_URL" > "$types_tmp"
249
- mv "$types_tmp" src/__generated__/database.ts
250
- trap - EXIT
251
- ;;
252
- release)
253
- bash "$0" reconcile
254
- bash "$0" migrationGen
255
- bash "$0" push
256
- bash "$0" squash
257
- bash "$0" generate
258
- ;;
259
- esac
260
- `;
261
- async function installSupabase(projectRoot, context) {
262
- const pkg = await updatePackageJson(projectRoot, (currentPackage) => ({
263
- ...currentPackage,
264
- name: currentPackage.name ?? projectPackageName(projectRoot),
265
- private: currentPackage.private ?? true,
266
- packageManager: currentPackage.packageManager ?? 'pnpm@11.6.0',
267
- engines: {
268
- ...currentPackage.engines,
269
- node: currentPackage.engines?.node ?? '>=24.0.0',
270
- pnpm: currentPackage.engines?.pnpm ?? '>=11.0.0',
271
- },
272
- scripts: mergeMissing(currentPackage.scripts, {
273
- 'supabase:start': 'supabase start',
274
- 'supabase:stop': 'supabase stop',
275
- 'db:types:local': 'supabase gen types typescript --local',
276
- }),
277
- dependencies: mergeMissing(currentPackage.dependencies, {
278
- '@supabase/supabase-js': '2.103.0',
279
- }),
280
- devDependencies: mergeMissing(currentPackage.devDependencies, {
281
- supabase: '2.118.0',
282
- }),
283
- }));
284
- await ensurePnpmBuildPolicy(projectRoot);
285
- await writeProjectFileIfMissing(projectRoot, 'supabase/config.toml', `project_id = "${pkg.name}"
286
-
287
- [db.migrations]
288
- enabled = true
289
- schema_paths = ["./schemas/*.sql"]
290
-
291
- [experimental.pgdelta]
292
- enabled = true
293
- declarative_schema_path = "./schemas"
294
- `);
295
- await writeProjectFileIfMissing(projectRoot, 'supabase/schemas/000_base.sql', 'create schema if not exists public;\n');
296
- await writeProjectFileIfMissing(projectRoot, 'src/__generated__/database.ts', bootstrapDatabaseTypes);
297
- await writeProjectFileIfMissing(projectRoot, 'src/__generated__/schema.ts', bootstrapSchema);
298
- await writeProjectFileIfMissing(projectRoot, 'scripts/safety/require-human-remote-operation.cjs', humanRemoteGuard);
299
- await writeProjectFileIfMissing(projectRoot, 'scripts/db/generate-production-reconcile.cjs', productionReconcile);
300
- await writeProjectFileIfMissing(projectRoot, 'scripts/db/run-production-operation.sh', productionOperations);
301
- const supabaseScripts = `scripts:
302
- local:
303
- db:
304
- start: pnpm exec supabase start
305
- stop: pnpm exec supabase stop
306
- status: pnpm exec supabase status
307
- migrationGen: pnpm exec supabase db schema declarative sync --experimental --no-apply --name schema_change
308
- generate: pnpm exec supabase gen types typescript --local > src/__generated__/database.ts
309
- prod:
310
- db:
311
- reconcile: node scripts/safety/require-human-remote-operation.cjs --operation prod.db.reconcile && bash scripts/db/run-production-operation.sh reconcile
312
- migrationGen: node scripts/safety/require-human-remote-operation.cjs --operation prod.db.migrationGen && bash scripts/db/run-production-operation.sh migrationGen
313
- migrate: node scripts/safety/require-human-remote-operation.cjs --operation prod.db.migrate && bash scripts/db/run-production-operation.sh migrate
314
- push: node scripts/safety/require-human-remote-operation.cjs --operation prod.db.push && bash scripts/db/run-production-operation.sh push
315
- squash: node scripts/safety/require-human-remote-operation.cjs --operation prod.db.squash && bash scripts/db/run-production-operation.sh squash
316
- generate: node scripts/safety/require-human-remote-operation.cjs --operation prod.db.generate && bash scripts/db/run-production-operation.sh generate
317
- release: node scripts/safety/require-human-remote-operation.cjs --operation prod.db.release && bash scripts/db/run-production-operation.sh release
318
- `;
319
- const scriptPath = join(projectRoot, 'package-scripts.yml');
320
- let existingScripts;
321
- try {
322
- existingScripts = await readFile(scriptPath, 'utf8');
323
- }
324
- catch (error) {
325
- if (error.code !== 'ENOENT')
326
- throw error;
327
- }
328
- if (existingScripts === undefined) {
329
- await writeFile(scriptPath, supabaseScripts);
330
- }
331
- else if (existingScripts === 'scripts:\n check: pnpm run typecheck\n') {
332
- // Only extend Devkit's untouched NPS bootstrap; never rewrite project-owned scripts.
333
- await writeFile(scriptPath, supabaseScripts.replace('scripts:\n', existingScripts));
334
- }
335
- await context.runCommand('pnpm', ['install', '--no-frozen-lockfile'], { cwd: projectRoot });
336
- }
337
- export const supabaseRecipe = {
338
- id: 'supabase',
339
- recipeVersion: '1.3.0',
340
- role: 'backend',
341
- setupRequirements: [{ kind: 'package', packageId: 'nps', required: true }],
342
- conflicts: ['convex'],
343
- async detect(projectRoot) {
344
- return await detectDependency(projectRoot, '@supabase/supabase-js', '@supabase/supabase-js');
345
- },
346
- async apply(projectRoot, detection, _resolution, context) {
347
- if (detection.present) {
348
- if (!detection.compatible)
349
- throw new Error(detection.reason ?? 'Existing Supabase setup is not compatible.');
350
- return { source: 'adopted' };
351
- }
352
- await installSupabase(projectRoot, context);
353
- return { source: 'installed' };
354
- },
355
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const tailwindRecipe: PackageRecipe;
@@ -1,18 +0,0 @@
1
- import { detectDependency } from "./package-json.js";
2
- export const tailwindRecipe = {
3
- id: 'tailwind',
4
- recipeVersion: '1.0.0',
5
- role: 'integration',
6
- requires: ['vite'],
7
- async detect(projectRoot) {
8
- return await detectDependency(projectRoot, 'tailwindcss', 'Tailwind CSS');
9
- },
10
- async apply(_projectRoot, detection, _resolution) {
11
- if (!detection.present) {
12
- throw new Error('Tailwind CSS is not installed; creating Tailwind configuration is not supported by `add tailwind` yet.');
13
- }
14
- if (!detection.compatible)
15
- throw new Error(detection.reason ?? 'Existing Tailwind integration is not compatible.');
16
- return { source: 'adopted' };
17
- },
18
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const tanstackFormRecipe: PackageRecipe;
@@ -1,19 +0,0 @@
1
- import { installPackageJsonPatch } from "./install.js";
2
- import { detectDependency } from "./package-json.js";
3
- export const tanstackFormRecipe = {
4
- id: 'tanstack-form',
5
- recipeVersion: '1.1.0',
6
- role: 'integration',
7
- requires: ['zod'],
8
- async detect(projectRoot) {
9
- return await detectDependency(projectRoot, '@tanstack/react-form', '@tanstack/react-form');
10
- },
11
- async apply(projectRoot, detection, _resolution, context) {
12
- if (detection.present)
13
- return { source: 'adopted' };
14
- await installPackageJsonPatch(projectRoot, context.runCommand, {
15
- dependencies: { '@tanstack/react-form': '1.0.0' },
16
- });
17
- return { source: 'installed' };
18
- },
19
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const tanstackQueryRecipe: PackageRecipe;
@@ -1,15 +0,0 @@
1
- import { detectDependency } from "./package-json.js";
2
- export const tanstackQueryRecipe = {
3
- id: 'tanstack-query',
4
- recipeVersion: '1.0.1',
5
- role: 'integration',
6
- requires: ['supabase'],
7
- async detect(projectRoot) {
8
- return await detectDependency(projectRoot, '@tanstack/react-query', '@tanstack/react-query');
9
- },
10
- async apply(_projectRoot, detection, _resolution) {
11
- if (!detection.present)
12
- throw new Error('TanStack Query is not installed; creating Query configuration is not supported by `add tanstack-query` yet.');
13
- return { source: 'adopted' };
14
- },
15
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const tanstackRouterRecipe: PackageRecipe;
@@ -1,18 +0,0 @@
1
- import { detectDependency } from "./package-json.js";
2
- export const tanstackRouterRecipe = {
3
- id: 'tanstack-router',
4
- recipeVersion: '1.0.0',
5
- role: 'integration',
6
- requires: ['vite'],
7
- async detect(projectRoot) {
8
- return await detectDependency(projectRoot, '@tanstack/react-router', '@tanstack/react-router');
9
- },
10
- async apply(_projectRoot, detection, _resolution) {
11
- if (!detection.present) {
12
- throw new Error('TanStack Router is not installed; creating router configuration is not supported by `add tanstack-router` yet.');
13
- }
14
- if (!detection.compatible)
15
- throw new Error(detection.reason ?? 'Existing TanStack Router integration is not compatible.');
16
- return { source: 'adopted' };
17
- },
18
- };
@@ -1,11 +0,0 @@
1
- # Multi-tenancy integration
2
-
3
- This project-owned helper validates tenant selection against a trusted membership list. It does not create organizations, membership CRUD, or schema enforcement.
4
-
5
- 1. Persist tenant memberships and tenant roles in backend-owned tables. Do not authorize from client-supplied membership lists.
6
- 2. Persist active tenant choice as a client preference only. Every backend request must independently validate membership and resource tenant association.
7
- 3. Supabase: bind each tenant-owned data table to memberships with RLS; prevent changing tenant IDs on existing rows.
8
- 4. Convex: scope queries and mutations by verified tenant membership and validate the resource's actual tenant before returning or changing it.
9
- 5. Membership management requires a verified tenant administrator; revocation must be effective at the data boundary.
10
-
11
- Single-tenant applications need not install the `multi-tenancy` package.
@@ -1,22 +0,0 @@
1
- /** Pure active-tenant selection. Memberships must come from server-owned data. */
2
- export type TenantMembership = { tenantId: string; roleIds: readonly string[] };
3
-
4
- export function resolveActiveTenant(
5
- requestedTenantId: string | null,
6
- memberships: readonly TenantMembership[],
7
- ): TenantMembership | null {
8
- if (requestedTenantId === null) return null;
9
- const membership = memberships.find((item) => item.tenantId === requestedTenantId);
10
- if (!membership) throw new Error('Forbidden: tenant membership required');
11
- return membership;
12
- }
13
-
14
- /** Persist selection only as a preference; always revalidate on every server request. */
15
- export function getTenantMembership(
16
- tenantId: string,
17
- memberships: readonly TenantMembership[],
18
- ): TenantMembership {
19
- const selected = resolveActiveTenant(tenantId, memberships);
20
- if (!selected) throw new Error('Forbidden: tenant membership required');
21
- return selected;
22
- }
@@ -1,38 +0,0 @@
1
- export type PackageSource = 'adopted' | 'installed';
2
- export type PackageDetection = {
3
- present: boolean;
4
- compatible: boolean;
5
- detectedVersion: string | null;
6
- reason?: string;
7
- };
8
- export type PackageVariant = {
9
- id: string;
10
- when: string[];
11
- };
12
- export type PackageResolution = {
13
- variant: string | null;
14
- };
15
- export type PackageSetupRequirement = {
16
- kind: 'package';
17
- packageId: string;
18
- required: boolean;
19
- when?: 'git';
20
- };
21
- export type PackageApplyContext = {
22
- runCommand(command: string, args: string[], options: {
23
- cwd: string;
24
- }): Promise<void>;
25
- };
26
- export type PackageRecipe = {
27
- id: string;
28
- recipeVersion: string;
29
- role: string;
30
- requires?: string[];
31
- conflicts?: string[];
32
- variants?: PackageVariant[];
33
- setupRequirements?: PackageSetupRequirement[];
34
- detect(projectRoot: string): Promise<PackageDetection>;
35
- apply(projectRoot: string, detection: PackageDetection, resolution: PackageResolution, context: PackageApplyContext): Promise<{
36
- source: PackageSource;
37
- }>;
38
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const viteRecipe: PackageRecipe;