Commit 22280e63 authored by 前端-许佳敏's avatar 前端-许佳敏

自动化构建

parent 046e18cf
// 这里的env只有对本地起效, 线上构建不用
const path = require('path')
module.exports = {
scm: {
SITE_ID: '1',
BACK_GATEWAY: 'http://lingxi-scm.wg.shushangyun.com',
USE_ROUTE_CONFIG: false,
SOCKET_URL: 'ws://lingxi-scm.wg.shushangyun.com',
ssh: JSON.stringify({
user: "www",
// Password optional, prompted if none given
password: "!@#project_$%^231(1)wwwuser3",
host: "119.23.219.65",
port: 8122,
localRoot: path.resolve('./dist/'),
remoteRoot: "/usr/local/nginx/html/lingxi/yanshi/api/scm/admin/dist/",
// include: ["*", "**/*"], // this would upload everything except dot files
include: ["*"],
// e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
// exclude: ["dist/**/*.map", "node_modules/**", "node_modules/**/.*", ".git/**"],
// delete ALL existing files at destination before uploading, if true
deleteRemote: true,
// Passive mode is forced (EPSV command is not sent)
forcePasv: true
})
},
10: {
SITE_ID: '1',
BACK_GATEWAY: 'http://10.0.0.10:8100',
USE_ROUTE_CONFIG: true,
SOCKET_URL: 'ws://10.0.0.10:8100',
ssh: JSON.stringify({
user: "root",
// Password optional, prompted if none given
password: "123456",
host: "10.0.0.10",
port: 22,
localRoot: path.resolve('./dist/'),
remoteRoot: "/home/www/lingxi/lingxi-business-system/dist/",
// include: ["*", "**/*"], // this would upload everything except dot files
include: ["*"],
// e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
// exclude: ["dist/**/*.map", "node_modules/**", "node_modules/**/.*", ".git/**"],
// delete ALL existing files at destination before uploading, if true
deleteRemote: true,
// Passive mode is forced (EPSV command is not sent)
forcePasv: true
})
}
}
\ No newline at end of file
......@@ -3,6 +3,8 @@
"version": "1.0.4",
"private": true,
"scripts": {
"upload:scm": "cross-env local=scm taskName=upload yarn scripts:build",
"upload:10": "cross-env local=10 taskName=upload yarn scripts:build",
"api": "god-ytt",
"start:analyze": "ANALYZE=1 umi dev",
"scripts:build": "node scripts/run",
......@@ -14,6 +16,8 @@
"build:dev": "pm2 start scripts/devServer.js",
"build:analyze": "ANALYZE=1 umi build",
"build:clean": "umi build",
"build:scm": "cross-env SITE_ID=1 BACK_GATEWAY=http://lingxi-scm.wg.shushangyun.com yarn build",
"build:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 yarn build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"test": "umi-test",
......@@ -68,6 +72,7 @@
"connect-history-api-fallback": "^1.6.0",
"cross-env": "^7.0.2",
"express": "^4.17.1",
"god-upload-scp": "1.2.0",
"god-yapi2ts": "^1.6.0",
"gulp": "^4.0.2",
"http-proxy-middleware": "^1.0.5",
......
/**
* 手动上传文件
* @auth xjm
*/
const Logs = require('./utils/log')
const scpRun = require('god-upload-scp')
const connectSSH = (done) => {
const sshInfo = JSON.parse(process.env.ssh)
scpRun(sshInfo, process.env.local, done)
}
const initUpload = (done) => {
Logs.stop('开始上传到远程服务器!', 'success')
connectSSH(done)
}
module.exports = {
initUpload
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ const runFile = './services'
const fetchConfig = require(runFile).fetchConfig
const gulp = require('gulp')
const json2ts = require('json2ts')
const uploadBuildStram = require('./build')
const rootPath = '../';
......@@ -19,6 +20,11 @@ gulp.task('start', gulp.series(done => {
getAsyncConfig(done)
}))
gulp.task('upload', gulp.series(done => {
Logs.start('use upload')
uploadBuildStram.initUpload(done)
}))
/**
* 生成对应json文件
*/
......
const gulp = require('gulp')
const envValue = require('../env')
const taskName = process.env.taskName || 'start'
// 本地构建时带上的环境变量
const local = process.env.local
if (local) {
process.env.SITE_ID = envValue[local].SITE_ID
process.env.BACK_GATEWAY = envValue[local].BACK_GATEWAY
process.env.USE_ROUTE_CONFIG = envValue[local].USE_ROUTE_CONFIG
process.env.SOCKET_URL = envValue[local].SOCKET_URL
process.env.ssh = envValue[local].ssh
}
function runTask(toRun) {
const metadata = { task: toRun };
......@@ -23,4 +36,4 @@ function runTask(toRun) {
}
require('./gulpfile')
runTask('start')
\ No newline at end of file
runTask(taskName)
\ No newline at end of file
......@@ -12,8 +12,9 @@ const Logs = {
log(chalk.red(msg))
},
start() {
spinner.start()
start(msg) {
spinner.start(msg)
return spinner
},
stop(msg, type) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment