Skip to content

Commit 661db32

Browse files
committed
refactor: use realpath and consistent cwd in supabase-start-locked.sh (#368)
- Replace cd && pwd with realpath for cleaner code - Standardize all project.json to use cwd: {projectRoot} - Remove unnecessary cd {projectRoot} commands - Use consistent ../../scripts/supabase-start-locked.sh . pattern
1 parent 34ab693 commit 661db32

16 files changed

+126
-106
lines changed

pkgs/cli/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"options": {
7878
"commands": [
7979
"rm -rf supabase/",
80-
"npx -y supabase@latest init --with-vscode-settings --with-intellij-settings",
80+
"npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings",
8181
"node dist/index.js compile examples/analyze_website.ts --deno-json examples/deno.json --supabase-path supabase",
8282
"./scripts/assert-flow-compiled"
8383
],

pkgs/client/project.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
"local": true,
6464
"cache": false,
6565
"options": {
66-
"cwd": "{workspaceRoot}",
66+
"cwd": "{projectRoot}",
6767
"commands": [
68-
"scripts/supabase-start-locked.sh {projectRoot}"
68+
"../../scripts/supabase-start-locked.sh ."
6969
],
7070
"parallel": false
7171
}
@@ -75,8 +75,8 @@
7575
"local": true,
7676
"cache": false,
7777
"options": {
78-
"cwd": "{workspaceRoot}",
79-
"commands": ["scripts/supabase-start-locked.sh {projectRoot}"],
78+
"cwd": "{projectRoot}",
79+
"commands": ["../../scripts/supabase-start-locked.sh ."],
8080
"parallel": false
8181
}
8282
},
@@ -129,10 +129,10 @@
129129
"cache": false,
130130
"dependsOn": ["supabase:prepare"],
131131
"options": {
132-
"cwd": "{workspaceRoot}",
132+
"cwd": "{projectRoot}",
133133
"commands": [
134-
"scripts/supabase-start-locked.sh {projectRoot}",
135-
"cd {projectRoot} && supabase db reset"
134+
"../../scripts/supabase-start-locked.sh .",
135+
"supabase db reset"
136136
],
137137
"parallel": false
138138
}
@@ -202,9 +202,7 @@
202202
},
203203
"test:types:vitest": {
204204
"executor": "nx:run-commands",
205-
"cache": true,
206-
"dependsOn": ["build"],
207-
"inputs": ["default", "^production"],
205+
"dependsOn": ["^build"],
208206
"options": {
209207
"cwd": "{projectRoot}",
210208
"command": "pnpm vitest --typecheck.only --run --config vitest.typecheck.config.ts"

pkgs/client/tsconfig.typecheck.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"include": [
1818
"__tests__/**/*.test-d.ts",
1919
"__tests__/**/*.spec-d.ts"
20-
]
20+
],
21+
"exclude": ["dist", "node_modules"]
2122
}

pkgs/client/vitest.typecheck.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig({
1515
// NO setupFiles or globalSetup - type tests don't need runtime setup
1616
typecheck: {
1717
enabled: true,
18+
tsconfig: './tsconfig.typecheck.json',
1819
},
1920
reporters: ['default'],
2021
},

pkgs/core/project.json

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
],
3030
"outputs": ["{projectRoot}/atlas/.supabase-baseline-schema.sql"],
3131
"options": {
32-
"cwd": "{workspaceRoot}",
32+
"cwd": "{projectRoot}",
3333
"commands": [
34-
"scripts/supabase-start-locked.sh {projectRoot}",
35-
"cd {projectRoot} && scripts/atlas-dump-realtime-schema"
34+
"../../scripts/supabase-start-locked.sh .",
35+
"scripts/atlas-dump-realtime-schema"
3636
],
3737
"parallel": false
3838
},
@@ -63,11 +63,11 @@
6363
"inputs": ["migrations"],
6464
"outputs": ["{projectRoot}/.nx-inputs/verify-migrations.txt"],
6565
"options": {
66-
"cwd": "{workspaceRoot}",
66+
"cwd": "{projectRoot}",
6767
"commands": [
68-
"scripts/supabase-start-locked.sh {projectRoot}",
69-
"cd {projectRoot} && mkdir -p .nx-inputs",
70-
"cd {projectRoot} && supabase db reset > .nx-inputs/verify-migrations.txt 2>&1 || (cat .nx-inputs/verify-migrations.txt && exit 1)"
68+
"../../scripts/supabase-start-locked.sh .",
69+
"mkdir -p .nx-inputs",
70+
"supabase db reset > .nx-inputs/verify-migrations.txt 2>&1 || (cat .nx-inputs/verify-migrations.txt && exit 1)"
7171
],
7272
"parallel": false
7373
},
@@ -141,9 +141,9 @@
141141
"local": true,
142142
"cache": false,
143143
"options": {
144-
"cwd": "{workspaceRoot}",
144+
"cwd": "{projectRoot}",
145145
"commands": [
146-
"scripts/supabase-start-locked.sh {projectRoot}"
146+
"../../scripts/supabase-start-locked.sh ."
147147
],
148148
"parallel": false
149149
}
@@ -153,8 +153,8 @@
153153
"local": true,
154154
"cache": false,
155155
"options": {
156-
"cwd": "{workspaceRoot}",
157-
"commands": ["scripts/supabase-start-locked.sh {projectRoot}"],
156+
"cwd": "{projectRoot}",
157+
"commands": ["../../scripts/supabase-start-locked.sh ."],
158158
"parallel": false
159159
}
160160
},
@@ -193,10 +193,10 @@
193193
"local": true,
194194
"cache": false,
195195
"options": {
196-
"cwd": "{workspaceRoot}",
196+
"cwd": "{projectRoot}",
197197
"commands": [
198-
"scripts/supabase-start-locked.sh {projectRoot}",
199-
"cd {projectRoot} && supabase db reset"
198+
"../../scripts/supabase-start-locked.sh .",
199+
"supabase db reset"
200200
],
201201
"parallel": false
202202
}
@@ -213,10 +213,10 @@
213213
"inputs": ["schemas", "migrations", "pgtapTests"],
214214
"cache": true,
215215
"options": {
216-
"cwd": "{workspaceRoot}",
216+
"cwd": "{projectRoot}",
217217
"commands": [
218-
"scripts/supabase-start-locked.sh {projectRoot}",
219-
"cd {projectRoot} && scripts/run-test-with-colors"
218+
"../../scripts/supabase-start-locked.sh .",
219+
"scripts/run-test-with-colors"
220220
],
221221
"parallel": false
222222
}
@@ -237,15 +237,15 @@
237237
"inputs": ["migrations"],
238238
"outputs": ["{projectRoot}/src/database-types.ts"],
239239
"options": {
240+
"cwd": "{projectRoot}",
240241
"commands": [
241-
"scripts/supabase-start-locked.sh {projectRoot}",
242-
"cd {projectRoot} && echo 'Generating database types...'",
243-
"cd {projectRoot} && supabase gen types --local --schema pgflow --schema pgmq > src/database-types.ts",
244-
"cd {projectRoot} && echo 'Verifying generated types...'",
245-
"cd {projectRoot} && grep -q 'pgflow' src/database-types.ts || (echo 'ERROR: Generated types file does not contain pgflow schema!' && exit 1)",
246-
"cd {projectRoot} && [ -s src/database-types.ts ] || (echo 'ERROR: Generated types file is empty!' && exit 1)"
242+
"../../scripts/supabase-start-locked.sh .",
243+
"echo 'Generating database types...'",
244+
"supabase gen types --local --schema pgflow --schema pgmq > src/database-types.ts",
245+
"echo 'Verifying generated types...'",
246+
"grep -q 'pgflow' src/database-types.ts || (echo 'ERROR: Generated types file does not contain pgflow schema!' && exit 1)",
247+
"[ -s src/database-types.ts ] || (echo 'ERROR: Generated types file is empty!' && exit 1)"
247248
],
248-
"cwd": "{workspaceRoot}",
249249
"parallel": false
250250
},
251251
"cache": true
@@ -256,28 +256,26 @@
256256
"inputs": ["migrations", "databaseTypes"],
257257
"outputs": ["{projectRoot}/.nx-inputs/verify-gen-types.txt"],
258258
"options": {
259-
"cwd": "{workspaceRoot}",
259+
"cwd": "{projectRoot}",
260260
"commands": [
261-
"scripts/supabase-start-locked.sh {projectRoot}",
262-
"cd {projectRoot} && mkdir -p .nx-inputs",
263-
"cd {projectRoot} && echo 'Verifying database types are up-to-date...'",
264-
"cd {projectRoot} && cp src/database-types.ts .nx-inputs/database-types.ts.backup",
265-
"cd {projectRoot} && supabase gen types --local --schema pgflow --schema pgmq > .nx-inputs/database-types.ts.new",
266-
"cd {projectRoot} && diff .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new > .nx-inputs/verify-gen-types.txt 2>&1 || (echo 'ERROR: Database types are out of date! Run \"nx gen-types core\" to update them.' && echo '=============================================' && echo 'Diff between current and generated types:' && echo '=============================================' && diff -u .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new || true && echo '=============================================' && exit 1)",
267-
"cd {projectRoot} && echo 'Database types are up-to-date' > .nx-inputs/verify-gen-types.txt"
261+
"../../scripts/supabase-start-locked.sh .",
262+
"mkdir -p .nx-inputs",
263+
"echo 'Verifying database types are up-to-date...'",
264+
"cp src/database-types.ts .nx-inputs/database-types.ts.backup",
265+
"supabase gen types --local --schema pgflow --schema pgmq > .nx-inputs/database-types.ts.new",
266+
"diff .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new > .nx-inputs/verify-gen-types.txt 2>&1 || (echo 'ERROR: Database types are out of date! Run \"nx gen-types core\" to update them.' && echo '=============================================' && echo 'Diff between current and generated types:' && echo '=============================================' && diff -u .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new || true && echo '=============================================' && exit 1)",
267+
"echo 'Database types are up-to-date' > .nx-inputs/verify-gen-types.txt"
268268
],
269269
"parallel": false
270270
},
271271
"cache": true
272272
},
273273
"test:types:vitest": {
274274
"executor": "nx:run-commands",
275-
"cache": true,
276-
"dependsOn": ["build"],
277-
"inputs": ["default", "^production"],
275+
"dependsOn": ["^build"],
278276
"options": {
279277
"cwd": "{projectRoot}",
280-
"command": "pnpm vitest --typecheck.only --run"
278+
"command": "pnpm vitest --typecheck.only --run --config vitest.typecheck.config.ts"
281279
}
282280
},
283281
"test:types:strict": {

pkgs/core/tsconfig.typecheck.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"include": [
1818
"__tests__/**/*.test-d.ts",
1919
"__tests__/**/*.spec-d.ts"
20-
]
20+
],
21+
"exclude": ["dist", "node_modules"]
2122
}

pkgs/core/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig({
1414
globals: true,
1515
environment: 'jsdom',
1616
include: [
17-
'__tests__/**/*.{test,spec,test-d,spec-d}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
17+
'__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
1818
],
1919
reporters: ['default'],
2020
coverage: {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// <reference types='vitest' />
2+
import { defineConfig } from 'vitest/config';
3+
4+
// Separate config for type tests - NO global setup needed
5+
export default defineConfig({
6+
root: __dirname,
7+
cacheDir: '../../node_modules/.vite/pkgs/core',
8+
test: {
9+
watch: false,
10+
globals: true,
11+
environment: 'node',
12+
include: [
13+
'__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
14+
],
15+
// NO setupFiles or globalSetup - type tests don't need runtime setup
16+
typecheck: {
17+
enabled: true,
18+
tsconfig: './tsconfig.typecheck.json',
19+
},
20+
reporters: ['default'],
21+
},
22+
});

pkgs/dsl/__tests__/types/array-method.test-d.ts

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,6 @@ describe('.array() method type constraints', () => {
2020
});
2121

2222
it('should reject handlers that return non-arrays', () => {
23-
const flow = new Flow<Record<string, never>>({ slug: 'test' });
24-
25-
// Test that these handlers are NOT assignable to array handler type
26-
type ArrayHandler = (input: { run: Record<string, never> }, context: any) => Array<any> | Promise<Array<any>>;
27-
28-
const invalidNumber = () => 42;
29-
expectTypeOf(invalidNumber).not.toMatchTypeOf<ArrayHandler>();
30-
31-
const invalidString = () => 'not an array';
32-
expectTypeOf(invalidString).not.toMatchTypeOf<ArrayHandler>();
33-
34-
const invalidObject = () => ({ not: 'array' });
35-
expectTypeOf(invalidObject).not.toMatchTypeOf<ArrayHandler>();
36-
37-
const invalidNull = () => null;
38-
expectTypeOf(invalidNull).not.toMatchTypeOf<ArrayHandler>();
39-
40-
const invalidUndefined = () => undefined;
41-
expectTypeOf(invalidUndefined).not.toMatchTypeOf<ArrayHandler>();
42-
43-
// Keep the runtime tests with @ts-expect-error for actual type enforcement
4423
new Flow<Record<string, never>>({ slug: 'test2' })
4524
// @ts-expect-error - should reject number return
4625
.array({ slug: 'invalid_number' }, () => 42)
@@ -117,14 +96,10 @@ describe('.array() method type constraints', () => {
11796

11897
describe('dependency validation', () => {
11998
it('should enforce compile-time dependency validation', () => {
120-
const testFlow = new Flow<string>({ slug: 'test' })
121-
.array({ slug: 'items' }, () => [1, 2, 3]);
122-
123-
// Type assertion to verify compile-time error
124-
type TestType = Parameters<typeof testFlow.array>[0]['dependsOn'];
125-
// @ts-expect-error - should only allow 'items' as a valid dependency
126-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
127-
const invalidDeps: TestType = ['nonExistentStep'];
99+
new Flow<string>({ slug: 'test' })
100+
.array({ slug: 'items' }, () => [1, 2, 3])
101+
// @ts-expect-error - should reject non-existent dependency
102+
.array({ slug: 'invalid', dependsOn: ['nonExistentStep'] }, () => []);
128103
});
129104

130105
it('should not allow access to non-dependencies', () => {

pkgs/dsl/project.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
},
3939
"test:types:vitest": {
4040
"executor": "nx:run-commands",
41-
"dependsOn": ["build"],
41+
"dependsOn": [],
4242
"options": {
4343
"cwd": "{projectRoot}",
44-
"command": "pnpm vitest --typecheck.only --run"
44+
"command": "pnpm vitest --typecheck.only --run --config vitest.typecheck.config.ts"
4545
}
4646
},
4747
"test:types:strict": {
4848
"executor": "nx:run-commands",
49-
"dependsOn": ["build"],
49+
"dependsOn": [],
5050
"options": {
5151
"cwd": "{projectRoot}",
5252
"command": "bash ../../scripts/typecheck-ts2578.sh"

0 commit comments

Comments
 (0)