Skip to content

Commit ffc42f3

Browse files
committed
fix setup
1 parent c0c931d commit ffc42f3

File tree

8 files changed

+72
-35
lines changed

8 files changed

+72
-35
lines changed

epicshop/post-set-playground.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env node
2+
3+
import { spawnSync } from 'node:child_process'
4+
import path from 'node:path'
5+
import fs from 'fs-extra'
6+
7+
spawnSync('npx', ['react-router', 'typegen'], {
8+
cwd: process.env.EPICSHOP_PLAYGROUND_DEST_DIR,
9+
})

epicshop/setup-custom.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { spawn } from 'node:child_process'
12
import path from 'node:path'
23
import { warm } from '@epic-web/workshop-cli/warm'
34
import {
@@ -10,6 +11,46 @@ import fsExtra from 'fs-extra'
1011
await warm()
1112

1213
const allApps = await getApps()
14+
15+
console.log('🔗 Generating React Router types')
16+
for (const app of allApps) {
17+
// run npx react-router typegen in app
18+
await runWithOutputOnFailure('npx', ['react-router', 'typegen'], {
19+
cwd: app.fullPath,
20+
})
21+
}
22+
23+
function runWithOutputOnFailure(command, args, options) {
24+
// { type: 'stdout', data: Buffer }
25+
const outputBuffer = []
26+
return new Promise((resolve, reject) => {
27+
const child = spawn(command, args, {
28+
...options,
29+
stdio: ['ignore', 'pipe', 'pipe'],
30+
})
31+
child.stdout.on('data', (data) => {
32+
outputBuffer.push({ type: 'stdout', data })
33+
})
34+
child.stderr.on('data', (data) => {
35+
outputBuffer.push({ type: 'stderr', data })
36+
})
37+
child.on('close', (code) => {
38+
if (code !== 0) {
39+
for (const { type, data } of outputBuffer) {
40+
if (type === 'stderr') {
41+
process.stderr.write(data)
42+
} else {
43+
process.stdout.write(data)
44+
}
45+
}
46+
reject(code)
47+
} else {
48+
resolve('ok')
49+
}
50+
})
51+
})
52+
}
53+
1354
const problemApps = allApps.filter(isProblemApp)
1455

1556
if (!process.env.SKIP_PLAYGROUND) {

exercises/01.routing/01.problem.routing/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
2-
"name": "01.problem.routing",
2+
"name": "exercises_01.routing_01.problem.routing",
33
"private": true,
44
"type": "module",
5-
"kcd-workshop": {
6-
"scripts": {
7-
"test": "playwright test --trace=retain-on-failure"
8-
}
9-
},
105
"scripts": {
116
"build": "react-router build",
127
"dev": "react-router dev",

exercises/01.routing/01.solution.routing/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
2-
"name": "01.solution.routing",
2+
"name": "exercises_01.routing_01.solution.routing",
33
"private": true,
44
"type": "module",
5-
"kcd-workshop": {
6-
"scripts": {
7-
"test": "playwright test --trace=retain-on-failure"
8-
}
9-
},
105
"scripts": {
116
"build": "react-router build",
127
"dev": "react-router dev",

exercises/01.routing/02.problem.automatic-routing/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
2-
"name": "02.problem.automatic-routing",
2+
"name": "exercises_01.routing_02.problem.automatic-routing",
33
"private": true,
44
"type": "module",
5-
"kcd-workshop": {
6-
"scripts": {
7-
"test": "playwright test --trace=retain-on-failure"
8-
}
9-
},
105
"scripts": {
116
"build": "react-router build",
127
"dev": "react-router dev",

exercises/01.routing/02.solution.automatic-routing/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
2-
"name": "02.solution.automatic-routing",
2+
"name": "exercises_01.routing_02.solution.automatic-routing",
33
"private": true,
44
"type": "module",
5-
"kcd-workshop": {
6-
"scripts": {
7-
"test": "playwright test --trace=retain-on-failure"
8-
}
9-
},
105
"scripts": {
116
"build": "react-router build",
127
"dev": "react-router dev",

package-lock.json

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

tsconfig.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
{
2-
"files": [],
3-
"exclude": ["node_modules"],
4-
"references": [
5-
{
6-
"path": "exercises/01.example/01.problem.routing"
7-
},
8-
{
9-
"path": "exercises/01.example/01.solution.routing"
10-
}
11-
]
2+
"files": [],
3+
"exclude": [
4+
"node_modules"
5+
],
6+
"references": [
7+
{
8+
"path": "exercises/01.routing/01.problem.routing"
9+
},
10+
{
11+
"path": "exercises/01.routing/01.solution.routing"
12+
},
13+
{
14+
"path": "exercises/01.routing/02.problem.automatic-routing"
15+
},
16+
{
17+
"path": "exercises/01.routing/02.solution.automatic-routing"
18+
}
19+
]
1220
}

0 commit comments

Comments
 (0)