Skip to content

Commit 9d96968

Browse files
committed
chore(postgrest): move update-json to scripts
1 parent 1673843 commit 9d96968

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

packages/core/postgrest-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"type-check:test": "tsc --noEmit --project tsconfig.test.json",
5454
"db:clean": "cd test/db && docker compose down --volumes",
5555
"db:run": "cd test/db && docker compose up --detach && wait-for-localhost 3000",
56-
"db:generate-test-types": "cd test/db && docker compose up --detach && wait-for-localhost 8080 && wait-for-localhost 3000 && 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 && cd ../../ && npm run format"
56+
"db:generate-test-types": "cd test/db && docker compose up --detach && wait-for-localhost 8080 && wait-for-localhost 3000 && 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 && cd ../../ && npm run format"
5757
},
5858
"dependencies": {
5959
"@supabase/node-fetch": "2.6.15"
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, '..', 'test', '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 test/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 }

packages/core/postgrest-js/test/scripts/update-json-type.js

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const Sequencer = require('@jest/test-sequencer').default;
1+
const Sequencer = require('@jest/test-sequencer').default
22

33
class TestSequencer extends Sequencer {
4-
sort(tests) {
5-
// Sort tests alphabetically by file path for consistent order
6-
return tests.sort((testA, testB) => testA.path.localeCompare(testB.path));
7-
}
4+
sort(tests) {
5+
// Sort tests alphabetically by file path for consistent order
6+
return tests.sort((testA, testB) => testA.path.localeCompare(testB.path))
7+
}
88
}
99

10-
module.exports = TestSequencer;
10+
module.exports = TestSequencer

0 commit comments

Comments
 (0)