-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (63 loc) · 1.99 KB
/
index.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require('make-promises-safe')
const execa = require('execa')
const task = require('tasuku')
const fs = require('fs')
const axios = require('axios')
async function run(cmd) {
await task(`Run "${cmd}"`, async () => {
await execa(cmd, {
stdio: 'inherit',
shell: true,
})
})
}
async function main() {
await run('rm -rf template')
await run('mkdir template')
await run('cp skeleton/package.json template/package.json')
await run('cp skeleton/tsconfig.json template/tsconfig.json')
await run('cp skeleton/.prettierignore template/.prettierignore')
await run('cp .prettierrc template/.prettierrc')
await run('cp README-template.md template/README.md')
await run(
'cd template && pnpm install --save-dev @rushstack/heft @rushstack/heft-web-rig @types/heft-jest @microsoft/api-documenter prettier',
)
await task('Create .gitignore', async () => {
const { data: gitignoreTemplate } = await axios.get(
'https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore',
)
const extra = [
'# Compiled files',
'/lib/',
'/lib-commonjs/',
'/dist/',
'',
'# Heft files',
'.heft',
'',
'# Temporary files',
'tmp',
'temp',
'',
'# tsdoc',
'tsdoc-metadata.json',
]
const gitignore = gitignoreTemplate + '\n\n' + extra.join('\n') + '\n'
fs.writeFileSync('template/.gitignore', gitignore)
})
await run('mkdir template/etc')
await run('cp -Rv skeleton/src template/src')
await run('cp -Rv skeleton/config template/config')
await run('cp -Rv skeleton/.github template/.github')
await run('cd template && pnpm run test')
await run('cd template && pnpm run build')
await run('cd template && pnpm run docs')
await run('mkdir -p tmp')
await task('Generate commit message', async () => {
const message =
'Fresh TypeScript library as of ' +
new Date(Date.now() - 86400e3).toISOString().split('T')[0]
fs.writeFileSync('tmp/message', message)
})
}
main()