forked from faasjs/faasjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
65 lines (57 loc) · 1.49 KB
/
build.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
const globSync = require('glob').sync
const exec = require('node:child_process').execSync
const writeFile = require('node:fs').writeFileSync
const version = require('./package.json').version
async function run(cmd) {
console.log(cmd)
await exec(cmd, { stdio: 'inherit' })
}
async function build(path) {
const pkg = require(`${__dirname}/${path}`)
pkg.version = version
if (pkg.dependencies) {
for (const name of Object.keys(pkg.dependencies)) {
if (name.startsWith('@faasjs/')) pkg.dependencies[name] = `^${version}`
}
}
if (pkg.devDependencies) {
for (const name of Object.keys(pkg.devDependencies)) {
if (name.startsWith('@faasjs/')) pkg.devDependencies[name] = `^${version}`
}
}
if (pkg.engines) {
pkg.engines = {
node: '>=20.0.0',
npm: '>=10.0.0',
}
}
await writeFile(path, `${JSON.stringify(pkg, null, 2)}\n`)
if (pkg.scripts?.build) {
await run(`npm run build -w ${path.replace('/package.json', '')}`)
}
}
async function buildAll() {
const list = globSync('packages/*/package.json')
for (const name of [
'browser',
'react',
'ant-design',
'logger',
'deep_merge',
'ts-transform',
'func',
'load',
'http',
'test',
'cloud_function',
'deployer',
'request',
'server',
]) {
await build(`packages/${name}/package.json`)
list.splice(list.indexOf(`packages/${name}/package.json`), 1)
}
for (const name of list) await build(name)
}
buildAll()
module.exports = { build }