@akal/supaforge 0.0.0-stage → 0.0.32
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 +350 -2
- package/bin/dev.js +10 -0
- package/bin/run.js +18 -0
- package/dist/base-command.d.ts +135 -0
- package/dist/base-command.js +9 -0
- package/dist/base-command.js.map +1 -0
- package/dist/branch-C4ndfoj5.d.ts +58 -0
- package/dist/chunk-2SELREHW.js +156 -0
- package/dist/chunk-2SELREHW.js.map +1 -0
- package/dist/chunk-3HGAV5CC.js +2073 -0
- package/dist/chunk-3HGAV5CC.js.map +1 -0
- package/dist/chunk-4IVN7QVY.js +632 -0
- package/dist/chunk-4IVN7QVY.js.map +1 -0
- package/dist/chunk-6LJERPUN.js +499 -0
- package/dist/chunk-6LJERPUN.js.map +1 -0
- package/dist/chunk-6Q7MHFBM.js +13 -0
- package/dist/chunk-6Q7MHFBM.js.map +1 -0
- package/dist/chunk-6WAMNZLO.js +336 -0
- package/dist/chunk-6WAMNZLO.js.map +1 -0
- package/dist/chunk-7NAZGZPV.js +868 -0
- package/dist/chunk-7NAZGZPV.js.map +1 -0
- package/dist/chunk-BLKJWDTL.js +153 -0
- package/dist/chunk-BLKJWDTL.js.map +1 -0
- package/dist/chunk-BUOWHE36.js +1311 -0
- package/dist/chunk-BUOWHE36.js.map +1 -0
- package/dist/chunk-DMIWAJRB.js +602 -0
- package/dist/chunk-DMIWAJRB.js.map +1 -0
- package/dist/chunk-DQQ5E563.js +64 -0
- package/dist/chunk-DQQ5E563.js.map +1 -0
- package/dist/chunk-G2DIPIYU.js +94 -0
- package/dist/chunk-G2DIPIYU.js.map +1 -0
- package/dist/chunk-GEHPTPNZ.js +240 -0
- package/dist/chunk-GEHPTPNZ.js.map +1 -0
- package/dist/chunk-GZREXCQZ.js +207 -0
- package/dist/chunk-GZREXCQZ.js.map +1 -0
- package/dist/chunk-MIRLB5JM.js +1292 -0
- package/dist/chunk-MIRLB5JM.js.map +1 -0
- package/dist/chunk-NTUASFQ3.js +248 -0
- package/dist/chunk-NTUASFQ3.js.map +1 -0
- package/dist/chunk-ORQJVE57.js +642 -0
- package/dist/chunk-ORQJVE57.js.map +1 -0
- package/dist/chunk-SC2XHGIS.js +122 -0
- package/dist/chunk-SC2XHGIS.js.map +1 -0
- package/dist/chunk-SQPCWGQO.js +657 -0
- package/dist/chunk-SQPCWGQO.js.map +1 -0
- package/dist/chunk-UWAVXC57.js +916 -0
- package/dist/chunk-UWAVXC57.js.map +1 -0
- package/dist/commands/clone.d.ts +66 -0
- package/dist/commands/clone.js +416 -0
- package/dist/commands/clone.js.map +1 -0
- package/dist/commands/diff.d.ts +81 -0
- package/dist/commands/diff.js +23 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/help.d.ts +32 -0
- package/dist/commands/help.js +36 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/hukam.d.ts +13 -0
- package/dist/commands/hukam.js +28 -0
- package/dist/commands/hukam.js.map +1 -0
- package/dist/commands/init.d.ts +47 -0
- package/dist/commands/init.js +388 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +13 -0
- package/dist/commands/mcp.js +43 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate/baseline.d.ts +24 -0
- package/dist/commands/migrate/baseline.js +69 -0
- package/dist/commands/migrate/baseline.js.map +1 -0
- package/dist/commands/migrate/create.d.ts +36 -0
- package/dist/commands/migrate/create.js +127 -0
- package/dist/commands/migrate/create.js.map +1 -0
- package/dist/commands/migrate/list.d.ts +23 -0
- package/dist/commands/migrate/list.js +110 -0
- package/dist/commands/migrate/list.js.map +1 -0
- package/dist/commands/migrate/run.d.ts +61 -0
- package/dist/commands/migrate/run.js +18 -0
- package/dist/commands/migrate/run.js.map +1 -0
- package/dist/commands/report.d.ts +27 -0
- package/dist/commands/report.js +210 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/restore.d.ts +26 -0
- package/dist/commands/restore.js +266 -0
- package/dist/commands/restore.js.map +1 -0
- package/dist/commands/snapshot.d.ts +33 -0
- package/dist/commands/snapshot.js +249 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/sync.d.ts +16 -0
- package/dist/commands/sync.js +38 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/config-CTbeRlJk.d.ts +134 -0
- package/dist/help.d.ts +28 -0
- package/dist/help.js +64 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +498 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp/state.ts","../src/mcp/server.ts"],"sourcesContent":["import type { ScanResult } from '../types/drift.js'\n\n/** In-memory store for the most recent scan result (per-process). */\nlet lastScanResult: ScanResult | null = null\n\nexport function setLastScanResult(result: ScanResult): void {\n lastScanResult = result\n}\n\nexport function getLastScanResult(): ScanResult | null {\n return lastScanResult\n}\n\nexport function clearLastScanResult(): void {\n lastScanResult = null\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { z } from 'zod'\nimport { readFile, readdir } from 'node:fs/promises'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { resolve, join, dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { resolveConfig, validateConfig } from '../config.js'\nimport { createDefaultRegistry } from '../checks/index.js'\nimport { scan } from '../scanner.js'\nimport { promote } from '../promote.js'\nimport { checkConnection } from '../preflight.js'\nimport { redactUrls, describeFailure } from '../utils/error.js'\nimport { captureSnapshot } from '../snapshot.js'\nimport { backup } from '../migration.js'\nimport { CHECK_NAMES } from '../types/drift.js'\nimport type { ScanResult, CheckName } from '../types/drift.js'\nimport { setLastScanResult, getLastScanResult } from './state.js'\n\nconst SERVER_NAME = 'supaforge'\n\n/**\n * The package's own version.\n *\n * Was a hardcoded '0.0.4' and had drifted fifteen releases behind (issue #82).\n * An MCP client has no other way to know which SupaForge it is talking to, so\n * an agent deciding whether a tool or argument exists was working from a\n * version that had not been true for months. Read from package.json, with a\n * fallback that says so rather than asserting a number.\n */\nconst SERVER_VERSION = resolveVersion()\n\nfunction resolveVersion(): string {\n try {\n const here = dirname(fileURLToPath(import.meta.url))\n // dist/ at runtime, src/mcp/ from source: walk up until package.json.\n for (const relative of ['../package.json', '../../package.json', '../../../package.json']) {\n const candidate = resolve(here, relative)\n if (!existsSync(candidate)) continue\n const pkg = JSON.parse(readFileSync(candidate, 'utf-8'))\n if (typeof pkg.version === 'string' && pkg.name?.includes('supaforge')) {\n return pkg.version\n }\n }\n } catch {\n // Fall through.\n }\n return '0.0.0-unknown'\n}\n\n/** Masks sensitive fields (dbUrl, accessToken) in config output. */\nfunction maskConfig(config: unknown): unknown {\n if (typeof config !== 'object' || config === null) return config\n const result: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(config as Record<string, unknown>)) {\n if (key === 'dbUrl' || key === 'accessToken') {\n result[key] = typeof value === 'string' && value.length > 0 ? '***' : value\n } else if (typeof value === 'object' && value !== null) {\n result[key] = maskConfig(value)\n } else {\n result[key] = value\n }\n }\n return result\n}\n\n/**\n * Create and configure the SupaForge MCP server.\n *\n * @param cwd - Working directory to resolve config files from (defaults to process.cwd())\n */\nexport interface ServerOptions {\n /**\n * Honour a `configPath` argument from the client.\n *\n * Off by default. Every tool accepted an arbitrary path and resolved its\n * working directory from it, so a tool call — or a prompt injected into one —\n * could point the server at any `supaforge.config.json` on disk, including\n * one holding production credentials, bypassing the config the server was\n * started with (issue #96). Enabled with `supaforge mcp --allow-config-path`\n * for the case where an agent legitimately manages several projects.\n */\n allowConfigPath?: boolean\n}\n\nexport function createServer(cwd = process.cwd(), options: ServerOptions = {}): McpServer {\n const allowConfigPath = options.allowConfigPath ?? false\n\n /**\n * The directory to load the config from.\n *\n * Refuses a `configPath` unless the server was started with\n * --allow-config-path, rather than ignoring it silently: a client that asked\n * for a different project should be told it did not get one.\n */\n const resolveCwd = (configPath?: string): string => {\n if (!configPath) return cwd\n if (!allowConfigPath) {\n throw new Error(\n 'configPath is not accepted by this server. It was started without '\n + '--allow-config-path, so it reads only the config in its own working '\n + `directory (${cwd}). Restart it with --allow-config-path to permit `\n + 'other projects.',\n )\n }\n return resolve(configPath, '..')\n }\n\n const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION })\n\n // ── Tools ──────────────────────────────────────────────────────────────────\n\n /**\n * scan_drift: Scan for environment drift and return a structured report.\n */\n server.registerTool(\n 'scan_drift',\n {\n // Reads both databases and writes nothing. Without annotations a client\n // could not tell this from apply_fixes, so it could not ask for\n // confirmation on the one that writes (issue #96).\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n\n description:\n 'Scan for drift between Supabase environments and return a structured report. ' +\n 'Results include per-check status, issues with SQL fixes, and a health score.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n source: z\n .string()\n .optional()\n .describe('Source environment name (overrides config default).'),\n target: z\n .string()\n .optional()\n .describe('Target environment name (overrides config default).'),\n checks: z\n .array(z.enum(CHECK_NAMES))\n .optional()\n .describe('Limit scan to specific checks (e.g. [\"rls\", \"rls-coverage\"]).'),\n skip: z\n .array(z.enum(CHECK_NAMES))\n .optional()\n .describe(\n 'Skip specific checks, the equivalent of the CLI --skip flag. ' +\n 'Unioned with checks.exclude from the config file. Use this to avoid ' +\n 'a slow or failing layer without editing the project config.',\n ),\n },\n },\n async ({ configPath, source, target, checks, skip }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig({\n ...raw,\n ...(source ? { source } : {}),\n ...(target ? { target } : {}),\n })\n\n const errors = validateConfig(config)\n if (errors.length > 0) {\n return { content: [{ type: 'text' as const, text: `Config errors:\\n${errors.join('\\n')}` }], isError: true }\n }\n\n const registry = createDefaultRegistry()\n const result: ScanResult = await scan(registry, {\n config,\n checks: checks as CheckName[] | undefined,\n skip: skip as CheckName[] | undefined,\n })\n setLastScanResult(result)\n\n return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * apply_fixes: Apply SQL fixes to resolve drift in the target environment.\n */\n server.registerTool(\n 'apply_fixes',\n {\n // Writes to the target database, and destructively when\n // allowDestructive is set. This is the one a client should confirm.\n annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },\n\n description:\n 'Apply SQL fixes to resolve drift detected by scan_drift. ' +\n 'Previews by default — pass dryRun=false to actually write to the target database.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n source: z.string().optional().describe('Source environment name.'),\n target: z.string().optional().describe('Target environment name.'),\n checks: z\n .array(z.enum(CHECK_NAMES))\n .optional()\n .describe('Apply fixes only for specific checks.'),\n dryRun: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'Preview SQL without executing it. Defaults to true: writing is opt-in '\n + 'here as it is everywhere else in supaforge, where it needs --apply. '\n + 'Pass dryRun=false to actually apply the fixes.',\n ),\n },\n },\n async ({ configPath, source, target, checks, dryRun }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig({\n ...raw,\n ...(source ? { source } : {}),\n ...(target ? { target } : {}),\n })\n\n const errors = validateConfig(config)\n if (errors.length > 0) {\n return { content: [{ type: 'text' as const, text: `Config errors:\\n${errors.join('\\n')}` }], isError: true }\n }\n\n // Both databases must answer before anything is compared. Without\n // this, an unreadable source looked empty to the checks that treated a\n // failed read as \"nothing there\", and the target's webhooks were\n // dropped as extra.\n const unreachable: string[] = []\n for (const [label, name] of [['Source', config.source!], ['Target', config.target!]] as const) {\n const conn = await checkConnection(config.environments[name].dbUrl)\n if (!conn.reachable) unreachable.push(`${label} (${name}) not reachable: ${redactUrls(describeFailure(conn.error))}`)\n }\n if (unreachable.length > 0) {\n return { content: [{ type: 'text' as const, text: `Nothing compared or applied.\\n${unreachable.join('\\n')}` }], isError: true }\n }\n\n const registry = createDefaultRegistry()\n const scanResult: ScanResult = await scan(registry, {\n config,\n checks: checks as CheckName[] | undefined,\n })\n setLastScanResult(scanResult)\n\n const targetEnv = config.environments[config.target!]\n const promoteResult = await promote({\n dbUrl: targetEnv.dbUrl,\n scanResult,\n checks: checks as string[] | undefined,\n dryRun,\n })\n\n // A check that failed measured nothing, so none of its drift was\n // applied; the call is not a success.\n const unchecked = scanResult.checks\n .filter(c => c.status === 'error')\n .map(c => ({ check: c.check, error: c.error ?? 'check failed' }))\n const body = unchecked.length ? { ...promoteResult, unchecked } : promoteResult\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(body, null, 2) }],\n ...(unchecked.length || promoteResult.errors.length ? { isError: true } : {}),\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * take_snapshot: Capture a point-in-time snapshot of a Supabase environment.\n */\n server.registerTool(\n 'take_snapshot',\n {\n // Reads the database and writes local files only — nothing in any\n // database changes.\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },\n\n description:\n 'Capture a point-in-time snapshot of a Supabase environment. ' +\n 'Snapshots are stored under .supaforge/snapshots/ and can be used to restore state.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n environment: z\n .string()\n .optional()\n .describe('Environment to snapshot (defaults to config source).'),\n },\n },\n async ({ configPath, environment }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig(raw)\n\n const envName = environment ?? config.source ?? Object.keys(config.environments)[0]\n const env = config.environments[envName]\n if (!env) {\n return {\n content: [{ type: 'text' as const, text: `Environment \"${envName}\" not found in config.` }],\n isError: true,\n }\n }\n\n const result = await captureSnapshot({ envName, env, config, cwd: effectiveCwd })\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ timestamp: result.timestamp, dir: result.dir, manifest: result.manifest }, null, 2),\n },\n ],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * create_migration: Create a migration file from snapshot diff.\n */\n server.registerTool(\n 'create_migration',\n {\n // Local files only, as with take_snapshot.\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },\n\n description:\n 'Capture a snapshot and generate a migration file containing the diff against the previous snapshot. ' +\n 'Migration files are stored under .supaforge/migrations/.',\n inputSchema: {\n configPath: z\n .string()\n .optional()\n .describe(\n 'Absolute path to supaforge.config.json. Rejected unless the server was '\n + 'started with --allow-config-path; otherwise the config in the server\\'s '\n + 'own working directory is used.',\n ),\n environment: z\n .string()\n .optional()\n .describe('Environment to snapshot (defaults to config source).'),\n description: z\n .string()\n .optional()\n .describe('Human-readable description for the migration (e.g. \"add-rls-to-orders\").'),\n },\n },\n async ({ configPath, environment, description }) => {\n try {\n const effectiveCwd = resolveCwd(configPath)\n const raw = JSON.parse(await readFile(resolve(effectiveCwd, 'supaforge.config.json'), 'utf-8'))\n const config = resolveConfig(raw)\n\n const envName = environment ?? config.source ?? Object.keys(config.environments)[0]\n const env = config.environments[envName]\n if (!env) {\n return {\n content: [{ type: 'text' as const, text: `Environment \"${envName}\" not found in config.` }],\n isError: true,\n }\n }\n\n const result = await backup({\n envName,\n env,\n config,\n cwd: effectiveCwd,\n description,\n })\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(\n {\n isBaseline: result.isBaseline,\n migrationFile: result.migrationFile,\n snapshotDir: result.snapshot.dir,\n timestamp: result.snapshot.timestamp,\n },\n null,\n 2,\n ),\n },\n ],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { content: [{ type: 'text' as const, text: `Error: ${msg}` }], isError: true }\n }\n },\n )\n\n /**\n * get_check_result: Retrieve the result for a specific check from the last scan.\n */\n server.registerTool(\n 'get_check_result',\n {\n // Reads the last scan held in memory.\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n\n description:\n 'Retrieve the result for a specific check from the most recent scan_drift call. ' +\n 'Returns issues, status, and duration for the named check.',\n inputSchema: {\n check: z.enum(CHECK_NAMES).describe('The check name to retrieve (e.g. \"rls-coverage\").'),\n },\n },\n async ({ check }) => {\n const result = getLastScanResult()\n if (!result) {\n return {\n content: [{ type: 'text' as const, text: 'No scan result available. Run scan_drift first.' }],\n isError: true,\n }\n }\n const checkResult = result.checks.find(c => c.check === check)\n if (!checkResult) {\n return {\n content: [\n { type: 'text' as const, text: `Check \"${check}\" not found in last scan. Was it included in the scan?` },\n ],\n isError: true,\n }\n }\n return { content: [{ type: 'text' as const, text: JSON.stringify(checkResult, null, 2) }] }\n },\n )\n\n // ── Resources ──────────────────────────────────────────────────────────────\n\n /** Current SupaForge config (sensitive fields masked). */\n server.registerResource(\n 'config',\n 'supaforge://config',\n {\n title: 'SupaForge Config',\n description: 'Current supaforge.config.json (sensitive fields masked)',\n mimeType: 'application/json',\n },\n async (uri) => {\n try {\n const raw = JSON.parse(await readFile(resolve(cwd, 'supaforge.config.json'), 'utf-8'))\n const masked = maskConfig(raw)\n return {\n contents: [{ uri: uri.href, text: JSON.stringify(masked, null, 2), mimeType: 'application/json' }],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { contents: [{ uri: uri.href, text: `Error loading config: ${msg}`, mimeType: 'text/plain' }] }\n }\n },\n )\n\n /** Last scan result (updated after each scan_drift or apply_fixes call). */\n server.registerResource(\n 'last-scan',\n 'supaforge://last-scan',\n {\n title: 'Last Scan Result',\n description: 'The most recent drift scan result',\n mimeType: 'application/json',\n },\n async (uri) => {\n const result = getLastScanResult()\n if (!result) {\n return {\n contents: [\n {\n uri: uri.href,\n text: JSON.stringify({ message: 'No scan result yet. Run scan_drift first.' }),\n mimeType: 'application/json',\n },\n ],\n }\n }\n return { contents: [{ uri: uri.href, text: JSON.stringify(result, null, 2), mimeType: 'application/json' }] }\n },\n )\n\n /** List of migration files under .supaforge/migrations/. */\n server.registerResource(\n 'migrations',\n 'supaforge://migrations',\n {\n title: 'Migration Files',\n description: 'Migration files under .supaforge/migrations/',\n mimeType: 'application/json',\n },\n async (uri) => {\n try {\n const migrationsDir = join(cwd, '.supaforge', 'migrations')\n const files = await readdir(migrationsDir).catch(() => [] as string[])\n const jsonFiles = files.filter(f => f.endsWith('.json')).sort()\n return {\n contents: [\n {\n uri: uri.href,\n text: JSON.stringify({ directory: migrationsDir, files: jsonFiles }, null, 2),\n mimeType: 'application/json',\n },\n ],\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err)\n return { contents: [{ uri: uri.href, text: `Error: ${msg}`, mimeType: 'text/plain' }] }\n }\n },\n )\n\n // ── Prompts ────────────────────────────────────────────────────────────────\n\n /** Prompt: review drift before deploying. */\n server.registerPrompt(\n 'review_drift_before_deploy',\n {\n description: 'Generate a drift review context to share with an AI agent before deploying.',\n argsSchema: {\n environment: z\n .string()\n .optional()\n .describe('Target environment name (e.g. \"production\")'),\n },\n },\n ({ environment }) => {\n const envNote = environment ? ` to **${environment}**` : ''\n const lastScan = getLastScanResult()\n const scanContext = lastScan\n ? `\\n\\nLast scan result (${lastScan.timestamp}):\\n- Score: ${lastScan.score}\\n- Total issues: ${lastScan.summary.total} (${lastScan.summary.critical} critical, ${lastScan.summary.warning} warnings)\\n- Checks: ${lastScan.checks.filter(c => c.status === 'drifted').map(c => c.check).join(', ') || 'none drifted'}`\n : '\\n\\nNo recent scan found — run scan_drift first for a current drift report.'\n\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Before deploying${envNote}, please review the current SupaForge drift report.`,\n scanContext,\n '',\n 'Steps:',\n '1. Call scan_drift to get the latest drift report.',\n '2. Review critical issues (especially rls-coverage and rls checks).',\n '3. Confirm all SQL fixes look correct before applying.',\n '4. If safe, run apply_fixes with dryRun=true first, then dryRun=false.',\n ].join('\\n'),\n },\n },\n ],\n }\n },\n )\n\n /** Prompt: fix all critical issues. */\n server.registerPrompt(\n 'fix_critical_issues',\n {\n description: 'Generate a step-by-step plan to fix all critical drift issues.',\n argsSchema: {},\n },\n () => {\n const lastScan = getLastScanResult()\n let criticalSummary = 'No recent scan — run scan_drift first.'\n if (lastScan) {\n const criticalIssues = lastScan.checks\n .flatMap(c => c.issues)\n .filter(i => i.severity === 'critical')\n if (criticalIssues.length === 0) {\n criticalSummary = 'No critical issues found in the last scan. The target environment looks healthy.'\n } else {\n criticalSummary = [\n `Found ${criticalIssues.length} critical issue(s) in last scan (${lastScan.timestamp}):`,\n ...criticalIssues.map(i => `- [${i.check}] ${i.title}`),\n ].join('\\n')\n }\n }\n\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n 'Fix all critical drift issues in the target Supabase environment.',\n '',\n criticalSummary,\n '',\n 'Recommended steps:',\n '1. Run scan_drift to confirm the current state.',\n '2. Review each critical issue and its sql.up fix.',\n '3. Run apply_fixes with dryRun=true to preview the SQL.',\n '4. Confirm the SQL is safe, then run apply_fixes with dryRun=false.',\n '5. Run scan_drift again to confirm all critical issues are resolved.',\n '',\n 'Pay special attention to rls-coverage issues — tables without RLS enabled',\n 'are the CVE-2025-48757 vulnerability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;AAAA,YACE,MAAM;AAAA,YACN,SAAS;AAAA,cACP,MAAM;AAAA,cACN,MAAM;AAAA,gBACJ;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACF,EAAE,KAAK,IAAI;AAAA,YACb;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
redactUrls
|
|
3
|
+
} from "./chunk-SQPCWGQO.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/sanitize.ts
|
|
6
|
+
function sanitizeForReport(text) {
|
|
7
|
+
return redactUrls(text).replace(/\/(?:Users|home)\/[^/\s"'`]+/g, "~").replace(/\b\d{1,3}(?:\.\d{1,3}){3}\b/g, "[ip]");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
sanitizeForReport
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-6Q7MHFBM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/sanitize.ts"],"sourcesContent":["import { redactUrls } from './error.js'\n\n/**\n * Strip PII from a string at source — before it ever leaves the user's machine.\n *\n * Covers the realistic surface area without over-engineering:\n * • DB credentials via redactUrls (postgres://user:PASSWORD@host)\n * • Local file-system paths (/Users/alice/... or /home/alice/...)\n * • Bare IPv4 addresses\n */\nexport function sanitizeForReport(text: string): string {\n return redactUrls(text)\n .replace(/\\/(?:Users|home)\\/[^/\\s\"'`]+/g, '~')\n .replace(/\\b\\d{1,3}(?:\\.\\d{1,3}){3}\\b/g, '[ip]')\n}\n"],"mappings":";;;;;AAUO,SAAS,kBAAkB,MAAsB;AACtD,SAAO,WAAW,IAAI,EACnB,QAAQ,iCAAiC,GAAG,EAC5C,QAAQ,gCAAgC,MAAM;AACnD;","names":[]}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// src/defaults.ts
|
|
2
|
+
var DEFAULT_IGNORE_SCHEMAS = [
|
|
3
|
+
"auth",
|
|
4
|
+
"storage",
|
|
5
|
+
"realtime",
|
|
6
|
+
// Supabase's own realtime internals live in _realtime (underscore), a
|
|
7
|
+
// different schema from 'realtime'. Its tables are owned by supabase_admin,
|
|
8
|
+
// so reporting "RLS not enabled" on them is a finding nobody can act on —
|
|
9
|
+
// it dragged the posture score down with unfixable noise.
|
|
10
|
+
"_realtime",
|
|
11
|
+
"vault",
|
|
12
|
+
"net",
|
|
13
|
+
"graphql_public",
|
|
14
|
+
"supabase_migrations",
|
|
15
|
+
"pgsodium",
|
|
16
|
+
"pgtle",
|
|
17
|
+
"supabase_functions",
|
|
18
|
+
"extensions",
|
|
19
|
+
"pg_catalog",
|
|
20
|
+
"information_schema"
|
|
21
|
+
];
|
|
22
|
+
var SUPABASE_PLATFORM_SCHEMAS = [
|
|
23
|
+
...DEFAULT_IGNORE_SCHEMAS,
|
|
24
|
+
"cron",
|
|
25
|
+
"pgbouncer",
|
|
26
|
+
"graphql"
|
|
27
|
+
];
|
|
28
|
+
function schemaDiffIgnores(ignoreSchemas = DEFAULT_IGNORE_SCHEMAS) {
|
|
29
|
+
return [.../* @__PURE__ */ new Set([
|
|
30
|
+
...ignoreSchemas,
|
|
31
|
+
...SUPABASE_PLATFORM_SCHEMAS.filter((s) => !DEFAULT_IGNORE_SCHEMAS.includes(s)),
|
|
32
|
+
"_realtime",
|
|
33
|
+
"_analytics",
|
|
34
|
+
"pgsodium_masks"
|
|
35
|
+
])];
|
|
36
|
+
}
|
|
37
|
+
var INIT_HINTS = {
|
|
38
|
+
DB_URL: [
|
|
39
|
+
' In Supabase: click "Connect" (top bar) -> Direct -> Session pooler -> URI -> copy the Connection string.',
|
|
40
|
+
" Format: postgresql://postgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:5432/postgres\n"
|
|
41
|
+
],
|
|
42
|
+
PROJECT_URL: [
|
|
43
|
+
" Dashboard overview \u2192 click Copy \u2192 Project URL, or Project Settings \u2192 General \u2192 Project ID."
|
|
44
|
+
],
|
|
45
|
+
ACCESS_TOKEN: [
|
|
46
|
+
" supabase.com/dashboard/account/tokens \u2192 Generate new token.",
|
|
47
|
+
" This is a personal access token for the Supabase Management API (auth config, edge functions).\n"
|
|
48
|
+
],
|
|
49
|
+
DATA_TABLES: [
|
|
50
|
+
" Reference-data tables are rows that should be identical across environments",
|
|
51
|
+
" (e.g. countries, currencies, feature_flags, plans).\n"
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
var RELATION_NOT_FOUND = "does not exist";
|
|
55
|
+
var CLONE_NOISE_CHECKS = [
|
|
56
|
+
"storage",
|
|
57
|
+
"auth",
|
|
58
|
+
"edge-functions",
|
|
59
|
+
"vault",
|
|
60
|
+
"realtime",
|
|
61
|
+
// different schema from 'realtime'. Its tables are owned by supabase_admin,
|
|
62
|
+
// so reporting "RLS not enabled" on them is a finding nobody can act on —
|
|
63
|
+
// it dragged the posture score down with unfixable noise.
|
|
64
|
+
"roles"
|
|
65
|
+
];
|
|
66
|
+
var CLONE_SKIP_FLAGS = CLONE_NOISE_CHECKS.map((c2) => `--skip=${c2}`).join(" ");
|
|
67
|
+
|
|
68
|
+
// src/config.ts
|
|
69
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
70
|
+
import { resolve as resolve2 } from "path";
|
|
71
|
+
|
|
72
|
+
// src/env-loader.ts
|
|
73
|
+
import { readFile } from "fs/promises";
|
|
74
|
+
import { resolve } from "path";
|
|
75
|
+
import { existsSync } from "fs";
|
|
76
|
+
var ENV_FILE_PRIORITY = [
|
|
77
|
+
".env.local",
|
|
78
|
+
".env"
|
|
79
|
+
];
|
|
80
|
+
function buildEnvFilePriority(nodeEnv) {
|
|
81
|
+
if (!nodeEnv) return ENV_FILE_PRIORITY;
|
|
82
|
+
return [
|
|
83
|
+
`.env.${nodeEnv}.local`,
|
|
84
|
+
".env.local",
|
|
85
|
+
`.env.${nodeEnv}`,
|
|
86
|
+
".env"
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
function parseEnvContent(content) {
|
|
90
|
+
const result = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const line of content.split("\n")) {
|
|
92
|
+
const trimmed = line.trim();
|
|
93
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
94
|
+
const eqIndex = trimmed.indexOf("=");
|
|
95
|
+
if (eqIndex < 1) continue;
|
|
96
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
97
|
+
let value = trimmed.slice(eqIndex + 1).trim();
|
|
98
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
99
|
+
value = value.slice(1, -1);
|
|
100
|
+
}
|
|
101
|
+
result.set(key, value);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
async function loadEnvFiles(cwd = process.cwd()) {
|
|
106
|
+
const nodeEnv = process.env.NODE_ENV;
|
|
107
|
+
const candidates = buildEnvFilePriority(nodeEnv);
|
|
108
|
+
const loaded = [];
|
|
109
|
+
let injected = 0;
|
|
110
|
+
const seen = /* @__PURE__ */ new Set();
|
|
111
|
+
for (const candidate of candidates) {
|
|
112
|
+
const fullPath = resolve(cwd, candidate);
|
|
113
|
+
if (!existsSync(fullPath)) continue;
|
|
114
|
+
let content;
|
|
115
|
+
try {
|
|
116
|
+
content = await readFile(fullPath, "utf-8");
|
|
117
|
+
} catch {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
loaded.push(candidate);
|
|
121
|
+
const entries = parseEnvContent(content);
|
|
122
|
+
for (const [key, value] of entries) {
|
|
123
|
+
if (key in process.env || seen.has(key)) continue;
|
|
124
|
+
process.env[key] = value;
|
|
125
|
+
seen.add(key);
|
|
126
|
+
injected++;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { loaded, injected };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/config.ts
|
|
133
|
+
var CONFIG_FILENAME = "supaforge.config.json";
|
|
134
|
+
var ENV_VAR_RE = /\$\{([^}]+)\}|\$([A-Z_][A-Z0-9_]*)/gi;
|
|
135
|
+
function expandEnvVars(value) {
|
|
136
|
+
return value.replace(ENV_VAR_RE, (match, braced, bare) => {
|
|
137
|
+
const name = braced ?? bare;
|
|
138
|
+
return process.env[name] ?? match;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function parseProjectRef(value) {
|
|
142
|
+
const trimmed = value.trim();
|
|
143
|
+
try {
|
|
144
|
+
const url = new URL(trimmed);
|
|
145
|
+
const match = url.hostname.match(/^([^.]+)\.supabase\.co$/);
|
|
146
|
+
if (match) return match[1];
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
return trimmed;
|
|
150
|
+
}
|
|
151
|
+
function expandEnvironments(environments) {
|
|
152
|
+
const result = {};
|
|
153
|
+
for (const [name, env] of Object.entries(environments)) {
|
|
154
|
+
result[name] = {
|
|
155
|
+
...env,
|
|
156
|
+
dbUrl: expandEnvVars(env.dbUrl),
|
|
157
|
+
...env.accessToken ? { accessToken: expandEnvVars(env.accessToken) } : {},
|
|
158
|
+
...env.projectRef ? { projectRef: parseProjectRef(env.projectRef) } : {}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
async function loadConfig(cwd = process.cwd()) {
|
|
164
|
+
await loadEnvFiles(cwd);
|
|
165
|
+
const configPath = resolve2(cwd, CONFIG_FILENAME);
|
|
166
|
+
const raw = await readFile2(configPath, "utf-8");
|
|
167
|
+
const config = JSON.parse(raw);
|
|
168
|
+
return resolveConfig(config);
|
|
169
|
+
}
|
|
170
|
+
function resolveConfig(config) {
|
|
171
|
+
return {
|
|
172
|
+
...config,
|
|
173
|
+
environments: expandEnvironments(config.environments),
|
|
174
|
+
ignoreSchemas: config.ignoreSchemas ?? DEFAULT_IGNORE_SCHEMAS
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function validateConfig(config) {
|
|
178
|
+
const errors = [];
|
|
179
|
+
if (!config.environments || typeof config.environments !== "object") {
|
|
180
|
+
errors.push("environments is required and must be an object");
|
|
181
|
+
return errors;
|
|
182
|
+
}
|
|
183
|
+
if (Object.keys(config.environments).length < 2) {
|
|
184
|
+
errors.push("At least two environments are required");
|
|
185
|
+
}
|
|
186
|
+
if (!config.source) errors.push('"source" environment name is required');
|
|
187
|
+
if (!config.target) errors.push('"target" environment name is required');
|
|
188
|
+
if (config.source && !config.environments[config.source]) {
|
|
189
|
+
errors.push(`Source environment "${config.source}" not found in environments`);
|
|
190
|
+
}
|
|
191
|
+
if (config.target && !config.environments[config.target]) {
|
|
192
|
+
errors.push(`Target environment "${config.target}" not found in environments`);
|
|
193
|
+
}
|
|
194
|
+
if (config.source && config.target && config.source === config.target) {
|
|
195
|
+
errors.push("Source and target must be different environments");
|
|
196
|
+
}
|
|
197
|
+
for (const [name, env] of Object.entries(config.environments)) {
|
|
198
|
+
if (!env.dbUrl) errors.push(`Environment "${name}" is missing dbUrl`);
|
|
199
|
+
}
|
|
200
|
+
return errors;
|
|
201
|
+
}
|
|
202
|
+
function validateSingleEnvConfig(config, envName) {
|
|
203
|
+
const errors = [];
|
|
204
|
+
if (!config.environments || typeof config.environments !== "object") {
|
|
205
|
+
errors.push("environments is required and must be an object");
|
|
206
|
+
return errors;
|
|
207
|
+
}
|
|
208
|
+
if (!config.environments[envName]) {
|
|
209
|
+
errors.push(`Environment "${envName}" not found in environments`);
|
|
210
|
+
return errors;
|
|
211
|
+
}
|
|
212
|
+
if (!config.environments[envName].dbUrl) {
|
|
213
|
+
errors.push(`Environment "${envName}" is missing dbUrl`);
|
|
214
|
+
}
|
|
215
|
+
return errors;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// src/constants.ts
|
|
219
|
+
var SUPAFORGE_DIR = ".supaforge";
|
|
220
|
+
var SNAPSHOTS_SUBDIR = "snapshots";
|
|
221
|
+
var MIGRATIONS_SUBDIR = "migrations";
|
|
222
|
+
var BRANCHES_FILE = `${SUPAFORGE_DIR}/branches.json`;
|
|
223
|
+
var SUPABASE_MGMT_API = "https://api.supabase.com/v1/projects";
|
|
224
|
+
var DBDIFF_EXEC_TIMEOUT_MS = 6e5;
|
|
225
|
+
var DB_CONNECT_TIMEOUT_MS = 15e3;
|
|
226
|
+
var DB_PROBE_TIMEOUT_MS = 15e3;
|
|
227
|
+
var DBDIFF_MAX_BUFFER = 10 * 1024 * 1024;
|
|
228
|
+
var PG_PIPELINE_TIMEOUT_MS = 18e5;
|
|
229
|
+
var CLONE_PROGRESS_INTERVAL_MS = 1e3;
|
|
230
|
+
var RUNTIME_DETECT_TIMEOUT_MS = 5e3;
|
|
231
|
+
var CONTAINER_RM_TIMEOUT_MS = 1e4;
|
|
232
|
+
var CONTAINER_START_TIMEOUT_MS = 6e4;
|
|
233
|
+
var SCORE_PENALTY_CRITICAL = 15;
|
|
234
|
+
var SCORE_PENALTY_WARNING = 5;
|
|
235
|
+
var SCORE_PENALTY_INFO = 1;
|
|
236
|
+
var SCORE_PENALTY_ERROR = 3;
|
|
237
|
+
var SCORE_MAX = 100;
|
|
238
|
+
var CHECK_LINE_PADDING = 40;
|
|
239
|
+
var CLONE_EXTRA_EXCLUDE_SCHEMAS = [
|
|
240
|
+
"graphql",
|
|
241
|
+
"_realtime",
|
|
242
|
+
"_analytics",
|
|
243
|
+
"pgsodium_masks"
|
|
244
|
+
];
|
|
245
|
+
var MIGRATIONS_SCHEMA = "supabase_migrations";
|
|
246
|
+
var MIGRATIONS_TABLE_NAME = "schema_migrations";
|
|
247
|
+
var MIGRATIONS_TABLE = `${MIGRATIONS_SCHEMA}.${MIGRATIONS_TABLE_NAME}`;
|
|
248
|
+
var STORAGE_LIST_LIMIT = 1e3;
|
|
249
|
+
var RUN_LOG_DIR = ".supaforge";
|
|
250
|
+
var RUN_LOG_FILE = "run-log.jsonl";
|
|
251
|
+
var RUN_LOG_MAX_ENTRIES = 500;
|
|
252
|
+
|
|
253
|
+
// src/ui.ts
|
|
254
|
+
import { colorize } from "@oclif/core/ux";
|
|
255
|
+
var c = (style, text) => colorize(style, text);
|
|
256
|
+
var ok = (text) => c("green", text);
|
|
257
|
+
var warn = (text) => c("yellow", text);
|
|
258
|
+
var dim = (text) => c("dim", text);
|
|
259
|
+
var cmd = (text) => c("cyan", text);
|
|
260
|
+
var bold = (text) => c("bold", text);
|
|
261
|
+
function printHints(lines, log) {
|
|
262
|
+
for (const line of lines) {
|
|
263
|
+
log(dim(line));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
var BANNER = `
|
|
267
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
268
|
+
\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
|
|
269
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557
|
|
270
|
+
\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D
|
|
271
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
272
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D`;
|
|
273
|
+
var TAGLINE = " precision developer tools, built to last";
|
|
274
|
+
var CREDIT = "by Akal";
|
|
275
|
+
var BANNER_MIN_WIDTH = 80;
|
|
276
|
+
function printBanner(log) {
|
|
277
|
+
const cols = process.stdout.columns ?? BANNER_MIN_WIDTH;
|
|
278
|
+
if (cols >= BANNER_MIN_WIDTH) {
|
|
279
|
+
log(c("greenBright", BANNER));
|
|
280
|
+
} else {
|
|
281
|
+
log(c("greenBright", "\n \u2692 SupaForge"));
|
|
282
|
+
}
|
|
283
|
+
log(` ${dim(TAGLINE)} ${dim("\xB7")} ${dim(CREDIT)}
|
|
284
|
+
`);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export {
|
|
288
|
+
DEFAULT_IGNORE_SCHEMAS,
|
|
289
|
+
SUPABASE_PLATFORM_SCHEMAS,
|
|
290
|
+
schemaDiffIgnores,
|
|
291
|
+
INIT_HINTS,
|
|
292
|
+
RELATION_NOT_FOUND,
|
|
293
|
+
CLONE_SKIP_FLAGS,
|
|
294
|
+
expandEnvVars,
|
|
295
|
+
parseProjectRef,
|
|
296
|
+
loadConfig,
|
|
297
|
+
resolveConfig,
|
|
298
|
+
validateConfig,
|
|
299
|
+
validateSingleEnvConfig,
|
|
300
|
+
SUPAFORGE_DIR,
|
|
301
|
+
SNAPSHOTS_SUBDIR,
|
|
302
|
+
MIGRATIONS_SUBDIR,
|
|
303
|
+
BRANCHES_FILE,
|
|
304
|
+
SUPABASE_MGMT_API,
|
|
305
|
+
DBDIFF_EXEC_TIMEOUT_MS,
|
|
306
|
+
DB_CONNECT_TIMEOUT_MS,
|
|
307
|
+
DB_PROBE_TIMEOUT_MS,
|
|
308
|
+
DBDIFF_MAX_BUFFER,
|
|
309
|
+
PG_PIPELINE_TIMEOUT_MS,
|
|
310
|
+
CLONE_PROGRESS_INTERVAL_MS,
|
|
311
|
+
RUNTIME_DETECT_TIMEOUT_MS,
|
|
312
|
+
CONTAINER_RM_TIMEOUT_MS,
|
|
313
|
+
CONTAINER_START_TIMEOUT_MS,
|
|
314
|
+
SCORE_PENALTY_CRITICAL,
|
|
315
|
+
SCORE_PENALTY_WARNING,
|
|
316
|
+
SCORE_PENALTY_INFO,
|
|
317
|
+
SCORE_PENALTY_ERROR,
|
|
318
|
+
SCORE_MAX,
|
|
319
|
+
CHECK_LINE_PADDING,
|
|
320
|
+
CLONE_EXTRA_EXCLUDE_SCHEMAS,
|
|
321
|
+
MIGRATIONS_SCHEMA,
|
|
322
|
+
MIGRATIONS_TABLE,
|
|
323
|
+
STORAGE_LIST_LIMIT,
|
|
324
|
+
RUN_LOG_DIR,
|
|
325
|
+
RUN_LOG_FILE,
|
|
326
|
+
RUN_LOG_MAX_ENTRIES,
|
|
327
|
+
c,
|
|
328
|
+
ok,
|
|
329
|
+
warn,
|
|
330
|
+
dim,
|
|
331
|
+
cmd,
|
|
332
|
+
bold,
|
|
333
|
+
printHints,
|
|
334
|
+
printBanner
|
|
335
|
+
};
|
|
336
|
+
//# sourceMappingURL=chunk-6WAMNZLO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts","../src/config.ts","../src/env-loader.ts","../src/constants.ts","../src/ui.ts"],"sourcesContent":["/** Supabase internal schemas to ignore by default during drift scanning. */\nexport const DEFAULT_IGNORE_SCHEMAS = [\n 'auth',\n 'storage',\n 'realtime',\n // Supabase's own realtime internals live in _realtime (underscore), a\n // different schema from 'realtime'. Its tables are owned by supabase_admin,\n // so reporting \"RLS not enabled\" on them is a finding nobody can act on —\n // it dragged the posture score down with unfixable noise.\n '_realtime',\n 'vault',\n 'net',\n 'graphql_public',\n 'supabase_migrations',\n 'pgsodium',\n 'pgtle',\n 'supabase_functions',\n 'extensions',\n 'pg_catalog',\n 'information_schema',\n]\n\n/**\n * Every schema whose contents belong to Supabase rather than the project.\n *\n * DEFAULT_IGNORE_SCHEMAS plus the ones a scan never lists because nothing in\n * them is diffed, but which still hold objects and grants a project cannot\n * recreate: pg_cron's `cron`, the pooler's `pgbouncer`, and pg_graphql's\n * `graphql`. Grants in these differ between Supabase versions, not between\n * anybody's decisions, and a restore must never clear them.\n */\nexport const SUPABASE_PLATFORM_SCHEMAS = [\n ...DEFAULT_IGNORE_SCHEMAS,\n 'cron',\n 'pgbouncer',\n 'graphql',\n]\n\n/**\n * The schemas a schema diff leaves out: the project's `ignoreSchemas`, and\n * always the platform's own — those above, and the self-hosted stack's\n * `_realtime` and `_analytics`, and pgsodium's `pgsodium_masks`. Every other\n * schema is compared.\n */\nexport function schemaDiffIgnores(ignoreSchemas: readonly string[] = DEFAULT_IGNORE_SCHEMAS): string[] {\n return [...new Set([...ignoreSchemas, ...SUPABASE_PLATFORM_SCHEMAS.filter(s => !DEFAULT_IGNORE_SCHEMAS.includes(s)),\n '_realtime', '_analytics', 'pgsodium_masks'])]\n}\n\n/** Hint text shown during `supaforge init` to guide users through the Supabase UI. */\nexport const INIT_HINTS = {\n DB_URL: [\n ' In Supabase: click \"Connect\" (top bar) -> Direct -> Session pooler -> URI -> copy the Connection string.',\n ' Format: postgresql://postgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:5432/postgres\\n',\n ],\n PROJECT_URL: [\n ' Dashboard overview \\u2192 click Copy \\u2192 Project URL, or Project Settings \\u2192 General \\u2192 Project ID.',\n ],\n ACCESS_TOKEN: [\n ' supabase.com/dashboard/account/tokens \\u2192 Generate new token.',\n ' This is a personal access token for the Supabase Management API (auth config, edge functions).\\n',\n ],\n DATA_TABLES: [\n ' Reference-data tables are rows that should be identical across environments',\n ' (e.g. countries, currencies, feature_flags, plans).\\n',\n ],\n} as const\n\n/** Error fragment for a relation that simply doesn't exist (expected for optional features). */\nexport const RELATION_NOT_FOUND = 'does not exist'\n\n/**\n * The checks a local clone can only report noise for.\n *\n * A clone is vanilla PostgreSQL restored from a pg_dump: the Supabase-managed\n * layers have no local equivalent, and Postgres Roles & Grants is the same\n * story — Supabase's service roles do not exist on a plain server, so every\n * one of them reads as drift. On the diff that prompted issue #47 that was 227\n * findings, all of them clone artefacts, confirmed by a remote-to-remote diff\n * reporting zero.\n *\n * One list because the same advice was written out by hand in three places and\n * had already drifted into three different answers. Roles was in none of them:\n * it arrived as Layer 14, after the clone advice was written for a 13-layer set.\n */\nexport const CLONE_NOISE_CHECKS = [\n 'storage',\n 'auth',\n 'edge-functions',\n 'vault',\n 'realtime',\n // different schema from 'realtime'. Its tables are owned by supabase_admin,\n // so reporting \"RLS not enabled\" on them is a finding nobody can act on —\n // it dragged the posture score down with unfixable noise.\n 'roles',\n] as const\n\n/** The `--skip=` flags that suppress clone-only noise, as one command fragment. */\nexport const CLONE_SKIP_FLAGS = CLONE_NOISE_CHECKS.map(c => `--skip=${c}`).join(' ')\n","import { readFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport type { SupaForgeConfig, EnvironmentConfig } from './types/config'\nimport { DEFAULT_IGNORE_SCHEMAS } from './defaults'\nimport { loadEnvFiles } from './env-loader'\n\nconst CONFIG_FILENAME = 'supaforge.config.json'\n\n/** Match $VAR or ${VAR} references. */\nconst ENV_VAR_RE = /\\$\\{([^}]+)\\}|\\$([A-Z_][A-Z0-9_]*)/gi\n\n/**\n * Expand $VAR and ${VAR} references in a string using process.env.\n * Returns the original token unchanged if the env var is not set.\n */\nexport function expandEnvVars(value: string): string {\n return value.replace(ENV_VAR_RE, (match, braced, bare) => {\n const name = braced ?? bare\n return process.env[name] ?? match\n })\n}\n\n/**\n * Extract the project ref from a Supabase Project URL or return the value as-is\n * if it's already a bare ref.\n *\n * Accepted formats:\n * - https://abcdef123456.supabase.co\n * - https://abcdef123456.supabase.co/\n * - abcdef123456 (bare ref, returned unchanged)\n */\nexport function parseProjectRef(value: string): string {\n const trimmed = value.trim()\n try {\n const url = new URL(trimmed)\n const match = url.hostname.match(/^([^.]+)\\.supabase\\.co$/)\n if (match) return match[1]\n } catch {\n // Not a URL — treat as bare ref\n }\n return trimmed\n}\n\n/**\n * Expand env var references in all sensitive environment fields (dbUrl, accessToken).\n * Also normalises projectRef from full URL to bare ref.\n */\nfunction expandEnvironments(\n environments: Record<string, EnvironmentConfig>,\n): Record<string, EnvironmentConfig> {\n const result: Record<string, EnvironmentConfig> = {}\n for (const [name, env] of Object.entries(environments)) {\n result[name] = {\n ...env,\n dbUrl: expandEnvVars(env.dbUrl),\n ...(env.accessToken ? { accessToken: expandEnvVars(env.accessToken) } : {}),\n ...(env.projectRef ? { projectRef: parseProjectRef(env.projectRef) } : {}),\n }\n }\n return result\n}\n\nexport async function loadConfig(cwd = process.cwd()): Promise<SupaForgeConfig> {\n await loadEnvFiles(cwd)\n const configPath = resolve(cwd, CONFIG_FILENAME)\n const raw = await readFile(configPath, 'utf-8')\n const config = JSON.parse(raw) as SupaForgeConfig\n return resolveConfig(config)\n}\n\nexport function resolveConfig(config: SupaForgeConfig): SupaForgeConfig {\n return {\n ...config,\n environments: expandEnvironments(config.environments),\n ignoreSchemas: config.ignoreSchemas ?? DEFAULT_IGNORE_SCHEMAS,\n }\n}\n\nexport function validateConfig(config: SupaForgeConfig): string[] {\n const errors: string[] = []\n\n if (!config.environments || typeof config.environments !== 'object') {\n errors.push('environments is required and must be an object')\n return errors\n }\n\n if (Object.keys(config.environments).length < 2) {\n errors.push('At least two environments are required')\n }\n\n if (!config.source) errors.push('\"source\" environment name is required')\n if (!config.target) errors.push('\"target\" environment name is required')\n\n if (config.source && !config.environments[config.source]) {\n errors.push(`Source environment \"${config.source}\" not found in environments`)\n }\n if (config.target && !config.environments[config.target]) {\n errors.push(`Target environment \"${config.target}\" not found in environments`)\n }\n\n if (config.source && config.target && config.source === config.target) {\n errors.push('Source and target must be different environments')\n }\n\n for (const [name, env] of Object.entries(config.environments)) {\n if (!env.dbUrl) errors.push(`Environment \"${name}\" is missing dbUrl`)\n }\n\n return errors\n}\n\n/**\n * Validate config for single-environment operations (snapshot, clone, backup, restore).\n * Only requires that the specified environment exists and has a dbUrl.\n */\nexport function validateSingleEnvConfig(config: SupaForgeConfig, envName: string): string[] {\n const errors: string[] = []\n\n if (!config.environments || typeof config.environments !== 'object') {\n errors.push('environments is required and must be an object')\n return errors\n }\n\n if (!config.environments[envName]) {\n errors.push(`Environment \"${envName}\" not found in environments`)\n return errors\n }\n\n if (!config.environments[envName].dbUrl) {\n errors.push(`Environment \"${envName}\" is missing dbUrl`)\n }\n\n return errors\n}\n","import { readFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { existsSync } from 'node:fs'\n\n/**\n * Environment file candidates in descending priority order.\n * Follows the Next.js / Vite / CRA convention:\n * .env.{NODE_ENV}.local → .env.local → .env.{NODE_ENV} → .env\n *\n * All matching files are loaded (earlier entries win for duplicate keys).\n * Files that don't exist are silently skipped.\n */\nexport const ENV_FILE_PRIORITY = [\n '.env.local',\n '.env',\n] as const\n\n/**\n * Build the prioritised .env file list, inserting NODE_ENV-specific\n * variants when NODE_ENV is set (e.g. production, staging, development).\n *\n * Returns paths in descending priority — first file wins per key.\n */\nexport function buildEnvFilePriority(nodeEnv?: string): readonly string[] {\n if (!nodeEnv) return ENV_FILE_PRIORITY\n\n // .env.{NODE_ENV}.local → .env.local → .env.{NODE_ENV} → .env\n return [\n `.env.${nodeEnv}.local`,\n '.env.local',\n `.env.${nodeEnv}`,\n '.env',\n ]\n}\n\n/**\n * Parse a single .env file into a key-value map.\n * Handles KEY=value, KEY=\"value\", KEY='value', empty lines, and # comments.\n * Multi-line values are not supported.\n */\nexport function parseEnvContent(content: string): Map<string, string> {\n const result = new Map<string, string>()\n\n for (const line of content.split('\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('#')) continue\n\n const eqIndex = trimmed.indexOf('=')\n if (eqIndex < 1) continue\n\n const key = trimmed.slice(0, eqIndex).trim()\n let value = trimmed.slice(eqIndex + 1).trim()\n\n // Strip matching quotes\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1)\n }\n\n result.set(key, value)\n }\n\n return result\n}\n\nexport interface EnvLoadResult {\n /** Files that were found and loaded, in priority order. */\n loaded: string[]\n /** Total number of env vars injected into process.env. */\n injected: number\n}\n\n/**\n * Auto-detect and load .env files into process.env.\n *\n * Standard priority (industry convention matching Next.js / Vite / CRA):\n * .env.{NODE_ENV}.local → .env.local → .env.{NODE_ENV} → .env\n *\n * Never overwrites existing process.env values — system env always wins.\n * Returns metadata about which files were loaded.\n */\nexport async function loadEnvFiles(cwd = process.cwd()): Promise<EnvLoadResult> {\n const nodeEnv = process.env.NODE_ENV\n const candidates = buildEnvFilePriority(nodeEnv)\n const loaded: string[] = []\n let injected = 0\n\n // Track keys we've already set from higher-priority files\n const seen = new Set<string>()\n\n for (const candidate of candidates) {\n const fullPath = resolve(cwd, candidate)\n if (!existsSync(fullPath)) continue\n\n let content: string\n try {\n content = await readFile(fullPath, 'utf-8')\n } catch {\n continue\n }\n\n loaded.push(candidate)\n const entries = parseEnvContent(content)\n\n for (const [key, value] of entries) {\n // System env always wins, then higher-priority files\n if (key in process.env || seen.has(key)) continue\n process.env[key] = value\n seen.add(key)\n injected++\n }\n }\n\n return { loaded, injected }\n}\n","// ─── Directory & File Paths ──────────────────────────────────────────────────\n\n/** Root directory for all SupaForge local state. */\nexport const SUPAFORGE_DIR = '.supaforge'\n\n/** Subdirectory under SUPAFORGE_DIR for snapshot storage. */\nexport const SNAPSHOTS_SUBDIR = 'snapshots'\n\n/** Subdirectory under SUPAFORGE_DIR for migration files. */\nexport const MIGRATIONS_SUBDIR = 'migrations'\n\n/** Filename for snapshot manifests. */\nexport const SNAPSHOT_MANIFEST_FILE = 'manifest.json'\n\n/** File path (relative to cwd) for branch tracking. */\nexport const BRANCHES_FILE = `${SUPAFORGE_DIR}/branches.json`\n\n// ─── Supabase Management API ────────────────────────────────────────────────\n\n/** Supabase Management API base URL for project-level endpoints. */\nexport const SUPABASE_MGMT_API = 'https://api.supabase.com/v1/projects'\n\n// ─── Timeouts ────────────────────────────────────────────────────────────────\n\n/**\n * Default timeout for @dbdiff/cli execution (5 minutes).\n *\n * Large Supabase schemas can take several minutes to diff. The previous\n * 2-minute limit silently killed the process mid-run, surfacing dbdiff's\n * last progress log line as a bogus \"error\". Override at runtime with the\n * SUPAFORGE_DBDIFF_TIMEOUT environment variable (value in seconds), or per\n * environment via checks.schema.timeout in supaforge.config.json.\n *\n * Raised from 300s: the schema pre-scan made the common case much faster, so\n * the runs still approaching the ceiling are precisely the ones that need\n * headroom, and a timeout costs the whole layer rather than degrading it.\n */\nexport const DBDIFF_EXEC_TIMEOUT_MS = 600_000\n\n/**\n * Default bound on establishing a PostgreSQL connection (15 seconds).\n *\n * `pg` defaults connectionTimeoutMillis to 0 — wait forever. That is invisible\n * for the common failures, because the socket layer errors out on its own: a\n * refused connection fails immediately, an unroutable host after the OS TCP\n * timeout. But a host that *accepts* the connection and then never completes\n * the startup handshake — a paused container, a dropped VPN tunnel, an\n * overloaded server — leaves nothing to time it out, and the command blocks\n * indefinitely with no output (issue #44).\n *\n * 15s is long enough for a slow link and short enough to fail usefully.\n * Override with SUPAFORGE_CONNECT_TIMEOUT (in seconds).\n */\nexport const DB_CONNECT_TIMEOUT_MS = 15_000\n\n/**\n * Bound on the preflight version probe (15 seconds).\n *\n * The handshake can complete on a server that then stalls before answering,\n * so bounding the connect alone still leaves a way to hang. Applied only to\n * the probe — a scan or migration query is legitimately long-running and must\n * not inherit this.\n */\nexport const DB_PROBE_TIMEOUT_MS = 15_000\n\n/** Max stdout/stderr buffer for @dbdiff/cli (10 MB). */\nexport const DBDIFF_MAX_BUFFER = 10 * 1024 * 1024\n\n/** Timeout for pg_dump | pg_restore pipeline (30 minutes). */\nexport const PG_PIPELINE_TIMEOUT_MS = 1_800_000\n\n/** Interval between progress reports during clone (1 second). */\nexport const CLONE_PROGRESS_INTERVAL_MS = 1_000\n\n/** Timeout for container runtime detection commands (5 seconds). */\nexport const RUNTIME_DETECT_TIMEOUT_MS = 5_000\n\n/** Timeout for removing stopped containers (10 seconds). */\nexport const CONTAINER_RM_TIMEOUT_MS = 10_000\n\n/** Timeout for starting a new container (60 seconds). */\nexport const CONTAINER_START_TIMEOUT_MS = 60_000\n\n// ─── Scoring Weights ─────────────────────────────────────────────────────────\n\n/** Score penalty per critical drift issue. */\nexport const SCORE_PENALTY_CRITICAL = 15\n\n/** Score penalty per warning drift issue. */\nexport const SCORE_PENALTY_WARNING = 5\n\n/** Score penalty per info drift issue. */\nexport const SCORE_PENALTY_INFO = 1\n\n/** Score penalty per errored check (cannot confirm clean). */\nexport const SCORE_PENALTY_ERROR = 3\n\n/** Maximum (perfect) drift score. */\nexport const SCORE_MAX = 100\n\n// ─── Render / Formatting ─────────────────────────────────────────────────────\n\n/** Padding width for check status lines in terminal output. */\nexport const CHECK_LINE_PADDING = 40\n\n// ─── Clone-specific Schemas ──────────────────────────────────────────────────\n\n/**\n * Additional Supabase-internal schemas to exclude from pg_dump when cloning.\n * These reference extensions (pg_graphql, pgsodium, supautils, etc.)\n * unavailable in vanilla PostgreSQL.\n *\n * Combined with DEFAULT_IGNORE_SCHEMAS from defaults.ts to form the\n * full exclusion list for `supaforge clone`.\n */\nexport const CLONE_EXTRA_EXCLUDE_SCHEMAS = [\n 'graphql',\n '_realtime',\n '_analytics',\n 'pgsodium_masks',\n]\n\n// ─── Migration Tracking ──────────────────────────────────────────────────────\n\n/** Schema name for Supabase migration tracking. */\nexport const MIGRATIONS_SCHEMA = 'supabase_migrations'\n\n/** Unqualified table name for migration records. */\nexport const MIGRATIONS_TABLE_NAME = 'schema_migrations'\n\n/** Fully qualified migration tracking table name. */\nexport const MIGRATIONS_TABLE = `${MIGRATIONS_SCHEMA}.${MIGRATIONS_TABLE_NAME}`\n\n// ─── Storage ─────────────────────────────────────────────────────────────────\n\n/** Maximum number of objects to list per Supabase Storage API call. */\nexport const STORAGE_LIST_LIMIT = 1000\n\n// ─── Run Log ─────────────────────────────────────────────────────────────────\n\n/** Directory (relative to home) where the run log is stored. */\nexport const RUN_LOG_DIR = '.supaforge'\n\n/** Filename for the run log. */\nexport const RUN_LOG_FILE = 'run-log.jsonl'\n\n/** Maximum number of run log entries to keep. */\nexport const RUN_LOG_MAX_ENTRIES = 500\n","import { colorize } from '@oclif/core/ux'\n\ntype Style = Parameters<typeof colorize>[0]\n\n/** Apply an oclif color/style to text. */\nexport const c = (style: Style, text: string): string => colorize(style, text)\n\n/** Green text for success messages. */\nexport const ok = (text: string): string => c('green', text)\n\n/** Yellow text for warnings. */\nexport const warn = (text: string): string => c('yellow', text)\n\n/** Dim text for hints and secondary info. */\nexport const dim = (text: string): string => c('dim', text)\n\n/** Cyan text for commands and URIs. */\nexport const cmd = (text: string): string => c('cyan', text)\n\n/** Bold text for headings and emphasis. */\nexport const bold = (text: string): string => c('bold', text)\n\n/** Log an array of hint lines in dim. */\nexport function printHints(lines: readonly string[], log: (msg: string) => void): void {\n for (const line of lines) {\n log(dim(line))\n }\n}\n\nconst BANNER = `\n ███████╗██╗ ██╗██████╗ █████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗\n ██╔════╝██║ ██║██╔══██╗██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝\n ███████╗██║ ██║██████╔╝███████║█████╗ ██║ ██║██████╔╝██║ ███╗█████╗\n ╚════██║██║ ██║██╔═══╝ ██╔══██║██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝\n ███████║╚██████╔╝██║ ██║ ██║██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗\n ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝`\n\nconst TAGLINE = ' precision developer tools, built to last'\nconst CREDIT = 'by Akal'\n\n/** Minimum terminal width needed to render the full ASCII banner without wrapping. */\nconst BANNER_MIN_WIDTH = 80\n\n/** Print the SupaForge ASCII banner. Falls back to a compact header on narrow terminals. */\nexport function printBanner(log: (msg: string) => void): void {\n const cols = process.stdout.columns ?? BANNER_MIN_WIDTH\n if (cols >= BANNER_MIN_WIDTH) {\n log(c('greenBright', BANNER))\n } else {\n log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