-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.ts
30 lines (23 loc) · 943 Bytes
/
release.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
import child_process from 'node:child_process'
import fs from 'node:fs'
import readline from 'node:readline/promises'
const rl = readline.createInterface(process.stdin, process.stdout)
fs.existsSync('pkg/dist') && fs.rmSync('pkg/dist', {recursive: true})
child_process.execSync('pnpm tsc --project ./tsconfig.build.json', {stdio: 'inherit'})
const modules = fs.readdirSync('src')
.filter(mod=> mod.endsWith('.ts'))
.map(file => file.slice(0, -3))
.filter(mod=> !mod.endsWith('.test'))
fs.writeFileSync(
'pkg/dist/index.js',
modules.map(mod => `export * from './${mod}.js'`).join('\n'),
)
fs.writeFileSync(
'pkg/dist/index.d.ts',
modules.map(mod => `export * from './${mod}'`).join('\n'),
)
const shouldPubish = await rl.question(`Going to publish @krulod/verbi to npm. Proceed? (y) `) === 'y'
if(shouldPubish) {
child_process.execSync(`pnpm publish --access public --no-git-checks -C pkg`, {stdio: 'inherit'})
}
process.exit(0)