We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gulp 是一个项目开发的自动化打包构建工具,基于node环境来运行
const fs = require('fs-extra'); const { src, dest, series } = require('gulp'); const shelljs = require('shelljs'); const mustache = require('gulp-mustache'); const pkg = require('./package.json'); let outputFileName = `${pkg.name}-${pkg.version}.deb`; // 清除编译文件 async function clean() { shelljs.exec('npx rimraf dist'); shelljs.exec('npx rimraf backend/dist'); shelljs.exec('npx rimraf backend/logs'); shelljs.exec('npx rimraf web/build'); } // 拷贝项目文件到服务器对应位置 async function prepare() { await new Promise((resolve, reject) => { // 相对目录./setup/DEBIAN下的所有文件,结合pkg中的数据,拷贝到./dist/image/DEBIAN中,完成后调用reslove src('./setup/DEBIAN/**').pipe(mustache(pkg)).pipe(dest('./dist/image/DEBIAN')).on('end', resolve); }); await new Promise((resolve, reject) => { src('./setup/nginx/**').pipe(dest('./dist/image/app/loghub/nginx')).on('end', resolve); }); await new Promise((resolve, reject) => { src('./setup/config/**').pipe(dest('./dist/image/etc/loghub')).on('end', resolve); }); await new Promise((resolve, reject) => { src('./backend/dist/**').pipe(dest('./dist/image/app/loghub/service')).on('end', resolve); }); await new Promise((resolve, reject) => { src('./web/build/**').pipe(dest('./dist/image/app/loghub/app')).on('end', resolve); }); } // 编译文件 async function build() { // sync service version let servicePackagePath = './backend/package.json'; let servicePackage = require(servicePackagePath); servicePackage.version = pkg.version; // 将项目package.json中的版本号写入backend的package.json中 await fs.writeJson(servicePackagePath, servicePackage, { spaces: 2}); // backend 安装依赖、编译,并且不输出安装日志 shelljs.exec('yarn --cwd ./backend > /dev/null'); shelljs.exec('yarn --cwd ./backend build > /dev/null'); // web shelljs.exec('yarn --cwd ./web > /dev/null'); shelljs.exec('yarn --cwd ./web build > /dev/null'); } // thin-package (without node_module) async function package() { // 运行环境判断,如果是macos、ios则需要借助docker打包成deb文件 if (process.platform === 'darwin') { let cmd = `dpkg -b /app/image /app/${outputFileName} > /dev/null`; shelljs.exec(`docker run --rm -v $(pwd)/dist:/app ubuntu:20.04 bash -c '${cmd}'`); } else { shelljs.exec(`dpkg -b ./dist/image ./dist/${outputFileName}`); } } exports.clean = clean; exports.prepare = prepare; exports.build = series(clean, build); exports.package = series(prepare, package); exports.default = series(clean, build, prepare, package);
相关文件目录
执行以下命令即可解压安装deb,写入pm2,需手动安装node_module dpkg -i deb文件安装deb文件
dpkg -i deb文件安装deb文件
The text was updated successfully, but these errors were encountered:
No branches or pull requests
是什么
gulp 是一个项目开发的自动化打包构建工具,基于node环境来运行
能做什么
常用命令
自动化打包过程解析
相关文件目录
存放backend的默认配置
固定目录,包含文件拷贝、nginx写入系统并reload的命令
存放web访问的nginx配置
安装deb包
执行以下命令即可解压安装deb,写入pm2,需手动安装node_module
dpkg -i deb文件安装deb文件
The text was updated successfully, but these errors were encountered: