Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d592152

Browse files
author
wangsw
committed
upload files
0 parents commit d592152

18 files changed

+2088
-0
lines changed

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

‎.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: node_js
2+
3+
sudo: false
4+
5+
cache:
6+
apt: true
7+
directories:
8+
- node_modules
9+
10+
node_js:
11+
- "6"
12+
- "8"
13+
- "node"
14+
15+
before_script:
16+
- git config --global user.email "you@example.com"
17+
- git config --global user.name "Your Name"
18+
19+
script:
20+
- npm run eslint
21+
- npm run test-cov
22+
23+
after_script:
24+
- npm install coveralls
25+
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

‎LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015-2016 Web kong
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

‎README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
English|[简体中文](./README_zh.md)
2+
3+
# git-deploy-directory
4+
5+
Deploy a directory to a git branch. You can use the configuration file to deploy easily.Useful to deploy to GitHub Pages.
6+
7+
8+
### Installation
9+
10+
``` bash
11+
$ npm install -d git-deploy-directory
12+
or
13+
$ yarn add -D git-deploy-directory
14+
```
15+
16+
### Usage
17+
// init
18+
``` bash
19+
$ git deploy init //Initialize the configuration file
20+
```
21+
Configuration file
22+
```
23+
{
24+
"type": "git",
25+
"repo": "https://github.com/webkong/xxxx.git", // git repo
26+
"branch": "docs", // git branch
27+
"dir": "build" // You are going to deploy directory
28+
}
29+
```
30+
31+
```
32+
// deploy
33+
$ git deploy push
34+
```
35+
36+
### License
37+
38+
[MIT](http://opensource.org/licenses/MIT)
39+
40+
41+
## Author
42+
43+
![me](https://s.gravatar.com/avatar/1fe24100ab2109076fd777d1ad0a28c5?s=100)

‎README_zh.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[English](./README.md) | 简体中文
2+
# git-deploy-directory
3+
4+
部署一个目录到指定的git仓库分支。并且可以通过配置文件来轻松管理。当然很轻松的支持 Github Pages。
5+
6+
7+
### 安装
8+
9+
``` bash
10+
$ npm install -d git-deploy-directory
11+
or
12+
$ yarn add -D git-deploy-directory
13+
```
14+
15+
### 使用
16+
17+
``` bash
18+
// init 初始化
19+
$ git deploy init //初始化配置文件,如果不初始化,会默认将build目录deploy到master分支。
20+
```
21+
配置文件内容
22+
```
23+
{
24+
"type": "git",
25+
"repo": "https://github.com/webkong/xxxx.git", // 仓库地址
26+
"branch": "docs", // 要部署到的分支
27+
"dir": "build" // 要部署的文件夹
28+
}
29+
```
30+
31+
```
32+
// 部署
33+
$ git deploy push
34+
```
35+
36+
### License
37+
38+
[MIT](http://opensource.org/licenses/MIT)
39+
40+
41+
## Author
42+
43+
![me](https://s.gravatar.com/avatar/1fe24100ab2109076fd777d1ad0a28c5?s=100)

‎appveyor.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
environment:
2+
matrix:
3+
- nodejs_version: "8"
4+
- nodejs_version: "6"
5+
6+
install:
7+
- ps: Install-Product node $env:nodejs_version
8+
- npm install
9+
10+
test_script:
11+
- node --version
12+
- npm --version
13+
- npm test
14+
15+
cache:
16+
- node_modules -> package-lock.json
17+
18+
build: off

‎bin/git-deploy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
3+
require('commander')
4+
.version(require('../package').version)
5+
.usage('<command> [options]')
6+
.command('init', 'Initialize config file in current dir.')
7+
.command('push', 'Deploy to github')
8+
.parse(process.argv)

‎bin/git-deploy-init

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env node
2+
3+
const program = require('commander')
4+
const fs = require('fs')
5+
const path = require('path')
6+
const chalk = require('chalk') //控制台输出带颜色的日志
7+
const inquirer = require('inquirer') // 常用交互式命令行用户界面的信息收集
8+
const logger = require('../lib/logger');
9+
const parseConfig = require('../lib/parse_config');
10+
const gitInfo = require('../lib/git-info');
11+
12+
const info = gitInfo();
13+
/**
14+
* init Config
15+
*/
16+
//首先验证是否已经存在配置文件
17+
fs.stat('./.git-deployrc', function (err, stats) {
18+
if (err) {
19+
initConfig();
20+
} else {
21+
inquirer.prompt([{
22+
type: 'Confirm',
23+
name: 'initConfig',
24+
message: 'The config file is already exist, are you sure to overwrite it ?(Yes/No)',
25+
default: 'Yes'
26+
}])
27+
.then(answers => {
28+
if (answers.initConfig === 'Yes') {
29+
initConfig();
30+
} else {
31+
logger.log('Thank you for use!')
32+
}
33+
});
34+
}
35+
});
36+
37+
38+
function initConfig() {
39+
const str = fs.readFileSync(path.resolve(__dirname, '../lib/.git-deployrc'), {
40+
encoding: 'utf-8'
41+
});
42+
const data = str.replace('&&', info.url);
43+
fs.writeFile('./.git-deployrc', data, function (err) {
44+
if (err) {
45+
logger.fatal(err);
46+
} else {
47+
logger.success('Add configuration file success!');
48+
logger.success('Will deployed to <' + info.url + '>')
49+
}
50+
})
51+
52+
}
53+
54+
/**
55+
* Padding.
56+
*/
57+
58+
console.log()
59+
process.on('exit', () => {
60+
console.log()
61+
})

‎bin/git-deploy-push

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const exec = require('child_process').execSync
6+
const logger = require('../lib/logger');
7+
const chalk = require('chalk')
8+
const gitInfo = require('../lib/git-info');
9+
const rm = require('rimraf').sync
10+
const info = gitInfo();
11+
12+
let baseDir = process.env.PWD;
13+
//首先验证是否已经存在配置文件
14+
fs.readFile('./.git-deployrc', {
15+
encoding: 'utf-8'
16+
}, function (err, data) {
17+
if (err) {
18+
logger.fatal('No configuration file! You can use <git deploy init> first.')
19+
} else {
20+
const config = data && JSON.parse(data);
21+
const deploy = require('../lib/deployer.js');
22+
const sourceDir = path.join(baseDir, config.dir);
23+
const deployDir = path.join(baseDir, '.deploy_git');
24+
try{
25+
exec('rm -rf '+deployDir+'/')
26+
exec('cp -r '+ sourceDir+'/ ' + deployDir+'/')
27+
}catch(e){
28+
logger.fatal(e);
29+
}
30+
deploy({
31+
deployDir:deployDir,
32+
baseDir: sourceDir,
33+
url: config.repo || info.url,
34+
branch: config.branch || 'master',
35+
name: info.name,
36+
email: info.email
37+
})
38+
}
39+
});
40+
41+
/**
42+
* Padding.
43+
*/
44+
45+
console.log()
46+
process.on('exit', () => {
47+
console.log()
48+
})

‎lib/.git-deployrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "git",
3+
"repo": "&&",
4+
"branch": "master",
5+
"dir": "build"
6+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /