diff --git a/README.md b/README.md new file mode 100644 index 0000000..f31be41 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ + +## 参数 +* -t, --type: web(默认) 或 git + * 如果是 git + * -r, --repo: 'https://github.com/ORG/ORG.github.io' + * -b, --branch + * 如果是 web + * -H, --host: 远程主机 + * -P, --port: 端口 + * -D, --dir: 例如 /home/USER/FOLDER + * -d, --dist: 默认为 dist。例如 www +* -l, --local: 本地文件夹,例如 ../../project/public。默认为 dist +* -p, --password: 密码 +* -k, --key: 密钥文件 diff --git a/deploy.js b/deploy.js index 2817567..0f99b25 100644 --- a/deploy.js +++ b/deploy.js @@ -5,12 +5,6 @@ const path = require('path') const commander = require('commander') const deepmerge = require('deepmerge') -/** - * repo: 'git@github.com:fivapp/fivapp.github.io.git', - name: 'Limo Saplf', - email: 'limosaplf@gmail.com', - */ - var Config = { deploy: {} } // 读取配置文件 @@ -36,10 +30,12 @@ commander .version('1.0', '-v, --version') // 默认是 -V。如果要 -v,就要加 '-v --version' .option('-t, --type ', `Deploy to server type, web or git. Default to ${Config.deploy.type}`) .option('-H, --host ', `Host IP or domain name of the target server. Default to ${Config.deploy.host}`) + .option('-P, --port ', `Ssh port number of the target server. Default to ${Config.deploy.port}`) .option('-D, --dir ', `Directory to deploy on the target server. Default to ${Config.deploy.dir}`) .option('-d, --dist ', `Folder to deploy on the target server. Default to ${Config.deploy.dist}`) + .option('-r, --repo ', `git repo address. Default to ${Config.deploy.repo}`) + .option('-b, --branch ', `Local folder to copy from. Default to ${Config.deploy.local}`) - .option('-P, --port ', `Ssh port number of the target server. Default to ${Config.deploy.port}`) .option('-u, --user ', `User id to login the target server. Default to ${Config.deploy.user}`) .option('-k, --key ', `User private key file to login the target server. Default to ${Config.deploy.key}`) .option('-p, --password ', `User password to login the target server. You may have to enclose it in "". Default to "${Config.deploy.password}"`) @@ -53,6 +49,8 @@ const connection = { port: commander.port || Config.deploy.port || 22, dir: commander.dir || Config.deploy.dir, // 目标服务器上的目录。似乎该目录必须已经存在于服务器上 dist: commander.dist || Config.deploy.dist || 'dist', // 新系统将发布在这个文件夹里。建议为dist,和npm run build产生的目录一致,这样既可以远程自动部署,也可以直接登录服务器手动部署。 + repo: commander.repo || Config.deploy.repo, + branch: commander.branch || Config.deploy.branch || 'master', local: commander.local || Config.deploy.local || 'dist', username: commander.user || Config.deploy.user, privateKey: fs.existsSync(privateKeyFile) ? privateKeyFile : undefined, @@ -156,7 +154,7 @@ function deployToGit(){ function exec() { const baseDir = '' const deployDir = pathFn.join(baseDir, '.deploy_git') - const publicDir = connection.dist + const publicDir = connection.local let extendDirs = connection.extend_dirs const ignoreHidden = connection.ignore_hidden const ignorePattern = connection.ignore_pattern @@ -172,13 +170,7 @@ function deployToGit(){ help += 'You have to configure the deployment settings in config files or command line first!\n\n' help += 'Example:\n' - help += ' deploy:\n' - help += ' type: git\n' - help += ' repo: \n' - help += ' branch: [branch]\n' - help += ' message: [message]\n\n' - help += ' extend_dirs: [extend directory]\n\n' - help += 'For more help, you can check the docs: ' + chalk.underline('http://hexo.io/docs/deployment.html') + help += ' node deploy.js -t git -r https://github.com/log-home/log-home.github.io -b master -l ../../project/public' console.log(help) return @@ -281,6 +273,8 @@ function deployToGit(){ }).then(() => { return parseConfig(connection) }).each(function(repo) { + console.log('##########################') + console.log(repo) return push(repo) }) }