forked from onejs/one
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.ts
46 lines (39 loc) · 1.32 KB
/
setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { join } from 'node:path'
import { readlink } from 'fs-extra'
import { exec } from './exec'
setup()
/**
* Should be immutable function that runs and ensures all the packages are setup correctly
* Allowing you to make a new package just by adding a folder to packages and then running
* `yarn setup` once.
*/
async function setup() {
const workspaces = (await exec(`yarn workspaces list --json`)).trim().split('\n')
const packagePaths = workspaces.map((p) => JSON.parse(p) as { location: string; name: string })
await Promise.all(
packagePaths.map(async ({ location, name }) => {
if (name === 'tamagui-monorepo') {
// avoid monorepo itself
return
}
const cwd = join(process.cwd(), location)
await Promise.all([
// ensure biome.json
(async () => {
const biomeConfig = join(cwd, 'biome.json')
try {
await readlink(biomeConfig)
} catch (err) {
if (`${err}`.includes(`no such file or directory`)) {
// biome-ignore lint/suspicious/noConsoleLog: ok
console.log(`No biome.json found for ${name}, linking from monorepo root`)
await exec(`ln -s ../../biome.json ./biome.json`, {
cwd,
})
}
}
})(),
])
})
)
}