-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
Copy pathfixpack.ts
33 lines (30 loc) · 957 Bytes
/
fixpack.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
import pc from 'picocolors'
// @ts-ignore
import fixpack from 'fixpack'
import { resolve, dirname } from 'node:path'
import rc from 'rc'
import { targets, readJson } from './utils'
// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
const allTargets = await targets()
const defaultConfig = await readJson(
resolve(dirname('.'), './node_modules/fixpack/config.json')
)
const config = rc('fixpack', defaultConfig)
const allPackages = allTargets.map(target => {
return {
fullPath: resolve(dirname('.'), `./packages/${target}/package.json`),
display: `./packages/${target}/package.json`
}
})
// fix packages
allPackages.forEach(({ fullPath, display }) => {
fixpack(fullPath, config)
console.log(pc.bold(`${display} fixed!`))
})
// fix root
config.quiet = true
delete config.required
fixpack('package.json', config)
console.log(pc.bold(`./package.json fixed!`))
})()