Skip to content

Commit 823f28f

Browse files
authored
chore(deps): bump postgres-meta to 0.91.5 (#631)
* chore(deps): bump postgres-meta to latest - Regenerate database types - Fix data types override generation * chore(ci): add up to date typegen checking * chore(ci): include database type check in test script
1 parent d7d6f8b commit 823f28f

File tree

4 files changed

+53
-263
lines changed

4 files changed

+53
-263
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@
3737
"build:esm": "cpy wrapper.mjs dist/esm/",
3838
"docs": "typedoc src/index.ts --out docs/v2",
3939
"docs:json": "typedoc --json docs/v2/spec.json --excludeExternals src/index.ts",
40-
"test": "run-s format:check test:types db:clean db:run test:run db:clean && node test/smoke.cjs && node test/smoke.mjs",
40+
"test": "run-s format:check test:types db:clean db:run test:generated-types test:run db:clean && node test/smoke.cjs && node test/smoke.mjs",
4141
"test:run": "jest --runInBand --coverage",
42+
"test:generated-types": "run-s db:generate-test-types && git diff --exit-code test/types.generated.ts || (echo '❌ Generated types are not up to date. Run npm run db:generate-test-types.' && exit 1)",
4243
"test:update": "run-s db:clean db:run db:generate-test-types && jest --runInBand --updateSnapshot && run-s db:clean",
4344
"test:types": "run-s build && tsd --files 'test/**/*.test*.ts'",
4445
"test:types:watch": "chokidar 'src/**/*.ts' 'test/**/*.ts' -c 'npm run test:types'",
4546
"type-check": "tsc --noEmit --project tsconfig.json",
4647
"type-check:test": "tsc --noEmit --project tsconfig.test.json",
4748
"db:clean": "cd test/db && docker compose down --volumes",
4849
"db:run": "cd test/db && docker compose up --detach && wait-for-localhost 3000",
49-
"db:generate-test-types": "cd test/db && docker compose up --detach && wait-for-localhost 8080 && curl --location 'http://0.0.0.0:8080/generators/typescript?included_schemas=public,personal&detect_one_to_one_relationships=true' > ../types.generated.ts && sed -i '' 's/export type Json = .*/export type Json = unknown;/' ../types.generated.ts"
50+
"db:generate-test-types": "cd test/db && docker compose up --detach && wait-for-localhost 8080 && curl --location 'http://0.0.0.0:8080/generators/typescript?included_schemas=public,personal&detect_one_to_one_relationships=true' > ../types.generated.ts && node ../scripts/update-json-type.js && prettier --write ../types.generated.ts"
5051
},
5152
"dependencies": {
5253
"@supabase/node-fetch": "^2.6.14"

test/db/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ services:
4343
POSTGRES_HOST: /var/run/postgresql
4444
POSTGRES_PORT: 5432
4545
pgmeta:
46-
image: supabase/postgres-meta:v0.87.1
46+
image: supabase/postgres-meta:v0.91.5
4747
ports:
4848
- '8080:8080'
4949
environment:
50-
- PG_META_DB_URL=postgresql://postgres:postgres@db:5432/postgres
50+
- PG_META_DB_HOST=db

test/scripts/update-json-type.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
/**
7+
* Updates the Json type definition in the generated types file
8+
* This is a cross-platform replacement for the sed command
9+
*/
10+
function updateJsonType() {
11+
const filePath = path.join(__dirname, '..', 'types.generated.ts');
12+
13+
try {
14+
// Read the file
15+
let content = fs.readFileSync(filePath, 'utf8');
16+
17+
// Replace the Json type definition
18+
const updatedContent = content.replace(
19+
/export type Json =[\s\S]*?(?=\n\nexport type Database)/,
20+
'export type Json = unknown;'
21+
);
22+
23+
// Write the updated content back to the file
24+
fs.writeFileSync(filePath, updatedContent, 'utf8');
25+
26+
console.log('✅ Successfully updated Json type in types.generated.ts');
27+
} catch (error) {
28+
console.error('❌ Error updating Json type:', error.message);
29+
process.exit(1);
30+
}
31+
}
32+
33+
// Run the function if this script is executed directly
34+
if (require.main === module) {
35+
updateJsonType();
36+
}
37+
38+
module.exports = { updateJsonType };

0 commit comments

Comments
 (0)