supatool 0.6.3 → 0.6.4

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.
@@ -1360,7 +1360,7 @@ async function generateIndexFile(definitions, outputDir, separateDirectories = t
1360
1360
  }
1361
1361
  : undefined
1362
1362
  };
1363
- writeFileIfChanged(path.join(outputDir, 'schema_index.json'), JSON.stringify(schemaIndex, null, 2) + '\n');
1363
+ writeFileIfChanged(path.join(outputDir, 'schema_index.json'), JSON.stringify(schemaIndex, null, 2));
1364
1364
  // schema_summary.md (one-file overview for AI) — include RLS status per table
1365
1365
  let summaryMd = '# Schema summary\n\n';
1366
1366
  const tableDefs = definitions.filter(d => d.type === 'table' || d.type === 'view');
@@ -1396,6 +1396,7 @@ async function generateIndexFile(definitions, outputDir, separateDirectories = t
1396
1396
  writeFileIfChanged(path.join(outputDir, 'schema_summary.md'), summaryMd);
1397
1397
  // RLS disabled tables warning doc (tables only; RLS enabled with 0 policies is not warned)
1398
1398
  const rlsNotEnabled = tableRlsStatus.filter(s => !s.rlsEnabled);
1399
+ const rlsWarningsPath = path.join(outputDir, 'rls_warnings.md');
1399
1400
  if (rlsNotEnabled.length > 0) {
1400
1401
  let warnMd = '# Tables with RLS disabled (warning)\n\n';
1401
1402
  warnMd += 'The following tables do not have Row Level Security enabled.\n';
@@ -1404,7 +1405,11 @@ async function generateIndexFile(definitions, outputDir, separateDirectories = t
1404
1405
  rlsNotEnabled.forEach(s => {
1405
1406
  warnMd += `| ${s.schema} | ${s.table} |\n`;
1406
1407
  });
1407
- writeFileIfChanged(path.join(outputDir, 'rls_warnings.md'), warnMd);
1408
+ writeFileIfChanged(rlsWarningsPath, warnMd);
1409
+ }
1410
+ else if (fs.existsSync(rlsWarningsPath)) {
1411
+ // All RLS issues resolved — remove stale warning file
1412
+ fs.unlinkSync(rlsWarningsPath);
1408
1413
  }
1409
1414
  }
1410
1415
  /**
@@ -1536,7 +1541,10 @@ async function extractDefinitions(options) {
1536
1541
  cronJobs: { current: 0, total: 0 },
1537
1542
  customTypes: { current: 0, total: 0 }
1538
1543
  };
1539
- if (all) {
1544
+ // --schema-only implies full extraction of all object types for the target schema,
1545
+ // so that --force does not incorrectly delete rpc/cron/types files.
1546
+ const effectiveAll = all || schemaOnly;
1547
+ if (effectiveAll) {
1540
1548
  // Get total count for each object type first
1541
1549
  spinner.text = 'Counting database objects...';
1542
1550
  // Get total tables/views count
@@ -1598,7 +1606,7 @@ async function extractDefinitions(options) {
1598
1606
  AND t.typname NOT LIKE '_%'
1599
1607
  `);
1600
1608
  progress.customTypes.total = parseInt(typesCountResult.rows[0].count);
1601
- // When --all: fetch all objects (sequential)
1609
+ // When --all / --schema-only: fetch all objects (sequential)
1602
1610
  const tables = await fetchTableDefinitions(client, spinner, progress, schemas);
1603
1611
  const rlsPolicies = await fetchRlsPolicies(client, spinner, progress, schemas);
1604
1612
  const functions = await fetchFunctions(client, spinner, progress, schemas);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supatool",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "CLI for PostgreSQL (Cloud SQL / Supabase): extract schema to files, deploy schema diffs, apply migrations, seed export.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",