1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-02-03 10:33:47 +08:00
Files
408CSFamily/scripts/bundle
142vip.cn e792ed40b2 feat: 引入@142vip/utils模块,删除.exec执行器,优化scripts脚本逻辑和流程 (#100)
* feat: 引入`@142vip/utils`模块,删除`.exec`执行器,优化`scripts`脚本逻辑和流程

* chore: update

* chore: update package.json

---------

Co-authored-by: 142vip.cn <fairy@2925.com>
2024-09-25 15:14:17 +08:00

53 lines
1.2 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* 功能构建Docker镜像
* 使用:
* - ./scripts/bundle
* - ./scripts/bundle --proxy
*/
import {createRequire} from 'node:module'
import process from 'node:process'
import {
VipDockerAddress,
buildImage,
getRecentGitCommit,
} from '@142vip/utils'
(async () => {
try {
// 获取package.json文件
const pkg = createRequire(import.meta.url)('../package.json')
// 镜像地址
const imageName = `${VipDockerAddress}/docs:${pkg.name}-${pkg.version}`
// 最近一次提交信息
const {hash: gitHash} = await getRecentGitCommit()
// 构建镜像
await buildImage({
imageName,
buildArgs: [
// 参数中是否包含 --proxy
['NEED_PROXY', process.argv.includes('--proxy')],
['APP_NAME', pkg.name],
['APP_VERSION', pkg.version],
['APP_DESCRIPTION', pkg.description],
['AUTHOR', pkg.authorInfo.name],
['EMAIL', pkg.authorInfo.email],
['HOME_PAGE', pkg.authorInfo.homePage],
['GIT_HASH', gitHash],
],
memory:20000,
push: true,
delete: true,
logger: true,
})
} catch (e) {
console.log('异常信息:', e)
}
})()