Skip to content

Commit 7ebe579

Browse files
committed
sparse
1 parent 8318d19 commit 7ebe579

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
node-version: 24
4444

4545
- name: 🔧 Run fix
46-
run: node ./epicshop/fix.js
46+
run: node ./epicshop/fix-ts-config.js
4747

4848
- name: ▶️ Run setup script
4949
run: npm run setup

epicshop/fix-ts-config.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import fsExtra from 'fs-extra'
2+
3+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
4+
const here = (...p) => path.join(__dirname, ...p)
5+
6+
const workshopRoot = here('..')
7+
const exercises = (await readDir(here('../exercises')))
8+
.map(name => here(`../exercises/${name}`))
9+
.filter(filepath => fs.statSync(filepath).isDirectory())
10+
const exerciseApps = (
11+
await Promise.all(
12+
exercises.flatMap(async exercise => {
13+
return (await readDir(exercise))
14+
.filter(dir => {
15+
return /(problem|solution)/.test(dir)
16+
})
17+
.map(dir => path.join(exercise, dir))
18+
}),
19+
)
20+
).flat()
21+
22+
const appsWithPkgJson = exerciseApps.filter(app => {
23+
const pkgjsonPath = path.join(app, 'package.json')
24+
return exists(pkgjsonPath)
25+
})
26+
27+
const tsconfig = {
28+
files: [],
29+
exclude: ['node_modules'],
30+
references: appsWithPkgJson.map(a => ({
31+
path: relativeToWorkshopRoot(a).replace(/\\/g, '/'),
32+
})),
33+
}
34+
const written = await writeIfNeeded(
35+
path.join(workshopRoot, 'tsconfig.json'),
36+
`${JSON.stringify(tsconfig, null, 2)}\n`,
37+
{ parser: 'json' },
38+
)
39+
40+
if (written) {
41+
// delete node_modules/.cache
42+
const cacheDir = path.join(workshopRoot, 'node_modules', '.cache')
43+
if (exists(cacheDir)) {
44+
await fs.promises.rm(cacheDir, { recursive: true })
45+
}
46+
console.log('all fixed up')
47+
}

0 commit comments

Comments
 (0)