-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
49 lines (42 loc) · 1.54 KB
/
deploy.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
/* eslint-disable */
// @ts-check
const gh = require('gh-pages')
const fs = require('fs')
const cp = require('child_process')
const path = require('path')
const debug = (...args) => console.info(...args)
const paths = {
output: () => path.resolve(__dirname, './build'),
folder: (folder) => path.resolve(__dirname, 'demo', folder),
bindings: {
react: () => path.resolve(__dirname, './bindings/react'),
},
}
fs.rmSync(paths.output(), { recursive: true, force: true })
fs.mkdirSync(paths.output())
cp.execSync('cp ./lib/esm/stats.html ./build/stats.html')
Object.values(paths.bindings).forEach((bindingFolder) => {
debug(`\n\n--- Install & build bindings/${path.basename(bindingFolder())} ---`)
cp.execSync(`NODE_ENV=production npm run build && cp ./build/esm/stats.html ../../build/${path.basename(bindingFolder())}-stats.html`, {
cwd: bindingFolder(),
stdio: 'inherit',
})
})
const folders = ['with-react', 'with-superstruct', 'with-yup', 'with-zod']
folders.forEach((folder) => {
debug(`\n\n--- Install & build demo/${path.basename(paths.folder(folder))} ---`)
cp.execSync('npm run build', { cwd: paths.folder(folder), stdio: 'inherit' })
cp.execSync(`cp -R ${paths.folder(folder)}/dist ${paths.output()}/${folder}`, { stdio: 'inherit' })
})
gh.publish(
paths.output(),
{
branch: 'pages',
message: 'Deploy demos',
dest: '.',
},
(err) => {
err ? console.error('deploy failed', err) : console.info('Deploy succeeded')
},
)
// cp.execSync('rm -rf ./bindings/*/node_modules ./demo/*/node_modules', { stdio: 'inherit' })