Skip to content

Commit 193729f

Browse files
avalletemandarini
authored andcommitted
chore(postgrest): setup prettier for jest snapshot update (#1627)
1 parent e8a644e commit 193729f

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/postgrest-js/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
},
3535
"scripts": {
3636
"build": "npm run build:cjs && npm run build:esm",
37+
"format": "node scripts/format.js",
38+
"format:check": "node scripts/format.js check",
3739
"build:cjs": "tsc -p tsconfig.json",
3840
"build:esm": "cpy wrapper.mjs dist/esm/",
3941
"build:module": "npm run build:cjs",
@@ -50,7 +52,7 @@
5052
"type-check:test": "tsc --noEmit --project tsconfig.test.json",
5153
"db:clean": "cd test/db && docker compose down --volumes",
5254
"db:run": "cd test/db && docker compose up --detach && wait-for-localhost 3000",
53-
"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 ../../"
55+
"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"
5456
},
5557
"dependencies": {
5658
"@supabase/node-fetch": "2.6.15",
@@ -65,6 +67,7 @@
6567
"tstyche": "^4.3.0",
6668
"type-fest": "^4.32.0",
6769
"wait-for-localhost-cli": "^3.0.0",
68-
"zod": "^3.25.76"
70+
"zod": "^3.25.76",
71+
"prettier": "^2.6.2"
6972
}
7073
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env node
2+
3+
const { execSync } = require('child_process')
4+
const path = require('path')
5+
6+
// Get the monorepo root directory (go up from scripts/ to postgrest-js/ to core/ to packages/ to root)
7+
const monorepoRoot = path.resolve(__dirname, '../../../../')
8+
9+
// Run prettier from the monorepo root
10+
const command =
11+
process.argv[2] === 'check'
12+
? 'npx prettier --ignore-path packages/core/postgrest-js/.gitignore --check "packages/core/postgrest-js/**/*{ts,js,mjs,json,yml,yaml}"'
13+
: 'npx prettier --ignore-path packages/core/postgrest-js/.gitignore --write "packages/core/postgrest-js/**/*{ts,js,mjs,json,yml,yaml}"'
14+
15+
try {
16+
execSync(command, { cwd: monorepoRoot, stdio: 'inherit' })
17+
} catch (error) {
18+
process.exit(error.status || 1)
19+
}

0 commit comments

Comments
 (0)