Skip to content

Commit 161d0a0

Browse files
committed
add "post:playground" script to generate types
1 parent 79f5f92 commit 161d0a0

File tree

23 files changed

+93
-44
lines changed

23 files changed

+93
-44
lines changed

epicshop/post-set-playground.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import fs from 'node:fs'
2+
import path from 'node:path'
3+
import { spawnSync } from 'node:child_process'
4+
5+
const { EPICSHOP_PLAYGROUND_SRC_DIR, EPICSHOP_PLAYGROUND_DEST_DIR } =
6+
process.env
7+
8+
async function postPlaygroundHook() {
9+
const packageJsonPath = path.join(EPICSHOP_PLAYGROUND_SRC_DIR, 'package.json')
10+
11+
if (!fs.existsSync(packageJsonPath)) {
12+
return
13+
}
14+
15+
const packageJsonContents = await fs.promises.readFile(
16+
packageJsonPath,
17+
'utf8',
18+
)
19+
20+
if (packageJsonContents.includes('"post:playground"')) {
21+
spawnSync('npm', ['run', 'post:playground'], {
22+
cwd: EPICSHOP_PLAYGROUND_DEST_DIR,
23+
})
24+
}
25+
}
26+
27+
postPlaygroundHook()

exercises/01.basics/02.problem.running-the-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -157,7 +158,7 @@
157158
"vitest": "^3.1.3"
158159
},
159160
"engines": {
160-
"node": ">=22.14.0"
161+
"node": "22.14.0"
161162
},
162163
"prisma": {
163164
"seed": "tsx prisma/seed.ts"

exercises/01.basics/02.solution.running-the-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -157,7 +158,7 @@
157158
"vitest": "^3.1.3"
158159
},
159160
"engines": {
160-
"node": ">=22.14.0"
161+
"node": "22.14.0"
161162
},
162163
"prisma": {
163164
"seed": "tsx prisma/seed.ts"

exercises/02.test-setup/01.problem.custom-fixtures/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -158,7 +159,7 @@
158159
"vitest": "^3.1.3"
159160
},
160161
"engines": {
161-
"node": ">=22.14.0"
162+
"node": "22.14.0"
162163
},
163164
"prisma": {
164165
"seed": "tsx prisma/seed.ts"

exercises/02.test-setup/01.solution.custom-fixtures/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -158,7 +159,7 @@
158159
"vitest": "^3.1.3"
159160
},
160161
"engines": {
161-
"node": ">=22.14.0"
162+
"node": "22.14.0"
162163
},
163164
"prisma": {
164165
"seed": "tsx prisma/seed.ts"

exercises/02.test-setup/03.problem.authentication/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -158,7 +159,7 @@
158159
"vitest": "^3.1.3"
159160
},
160161
"engines": {
161-
"node": ">=22.14.0"
162+
"node": "22.14.0"
162163
},
163164
"prisma": {
164165
"seed": "tsx prisma/seed.ts"

exercises/02.test-setup/03.solution.authentication/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -158,7 +159,7 @@
158159
"vitest": "^3.1.3"
159160
},
160161
"engines": {
161-
"node": ">=22.14.0"
162+
"node": "22.14.0"
162163
},
163164
"prisma": {
164165
"seed": "tsx prisma/seed.ts"

exercises/02.test-setup/04.problem.api-mocking/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -163,7 +164,7 @@
163164
"vitest": "^3.1.3"
164165
},
165166
"engines": {
166-
"node": ">=22.14.0"
167+
"node": "22.14.0"
167168
},
168169
"prisma": {
169170
"seed": "tsx prisma/seed.ts"

exercises/02.test-setup/04.solution.api-mocking/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -163,7 +164,7 @@
163164
"vitest": "^3.1.3"
164165
},
165166
"engines": {
166-
"node": ">=22.14.0"
167+
"node": "22.14.0"
167168
},
168169
"prisma": {
169170
"seed": "tsx prisma/seed.ts"

exercises/02.test-setup/05.problem.test-data/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"test:e2e:run": "npx cross-env CI=true npx playwright test",
2727
"test:e2e:install": "npx playwright install --with-deps chromium",
2828
"typecheck": "react-router typegen && tsc",
29-
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run"
29+
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
30+
"post:playground": "npx react-router typegen && prisma migrate deploy && prisma generate --sql"
3031
},
3132
"prettier": "@epic-web/config/prettier",
3233
"eslintIgnore": [
@@ -158,7 +159,7 @@
158159
"vitest": "^3.1.3"
159160
},
160161
"engines": {
161-
"node": ">=22.14.0"
162+
"node": "22.14.0"
162163
},
163164
"prisma": {
164165
"seed": "tsx prisma/seed.ts"

0 commit comments

Comments
 (0)