hexo-deployer-git
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -8,2 +8,3 @@ 'use strict'; | ||
var moment = require('moment'); | ||
var Promise = require('bluebird'); | ||
var spawn = require('hexo-util/lib/spawn'); | ||
@@ -22,2 +23,5 @@ var parseConfig = require('./parse_config'); | ||
var publicDir = this.public_dir; | ||
var extendDirs = args.extend_dirs; | ||
var ignoreHidden = args.ignore_hidden; | ||
var ignorePattern = args.ignore_pattern; | ||
var log = this.log; | ||
@@ -27,2 +31,6 @@ var message = commitMessage(args); | ||
if (!args.repo && process.env.HEXO_DEPLOYER_REPO) { | ||
args.repo = process.env.HEXO_DEPLOYER_REPO; | ||
} | ||
if (!args.repo && !args.repository) { | ||
@@ -38,2 +46,3 @@ var help = ''; | ||
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'); | ||
@@ -96,5 +105,52 @@ | ||
}).then(function() { | ||
var opts = {}; | ||
log.info('Copying files from public folder...'); | ||
return fs.copyDir(publicDir, deployDir); | ||
if (typeof ignoreHidden === 'object') { | ||
opts.ignoreHidden = ignoreHidden.public; | ||
} else { | ||
opts.ignoreHidden = ignoreHidden; | ||
} | ||
if (typeof ignorePattern === 'string') { | ||
opts.ignorePattern = new RegExp(ignorePattern); | ||
} else if (typeof ignorePattern === 'object' && ignorePattern.hasOwnProperty('public')) { | ||
opts.ignorePattern = new RegExp(ignorePattern.public); | ||
} | ||
return fs.copyDir(publicDir, deployDir, opts); | ||
}).then(function() { | ||
log.info('Copying files from extend dirs...'); | ||
if (!extendDirs) { | ||
return; | ||
} | ||
if (typeof extendDirs === 'string') { | ||
extendDirs = [extendDirs]; | ||
} | ||
var mapFn = function(dir) { | ||
var opts = {}; | ||
var extendPath = pathFn.join(baseDir, dir); | ||
var extendDist = pathFn.join(deployDir, dir); | ||
if (typeof ignoreHidden === 'object') { | ||
opts.ignoreHidden = ignoreHidden[dir]; | ||
} else { | ||
opts.ignoreHidden = ignoreHidden; | ||
} | ||
if (typeof ignorePattern === 'string') { | ||
opts.ignorePattern = new RegExp(ignorePattern); | ||
} else if (typeof ignorePattern === 'object' && ignorePattern.hasOwnProperty(dir)) { | ||
opts.ignorePattern = new RegExp(ignorePattern[dir]); | ||
} | ||
return fs.copyDir(extendPath, extendDist, opts); | ||
}; | ||
return Promise.map(extendDirs, mapFn, { | ||
concurrency: 2 | ||
}); | ||
}).then(function() { | ||
return parseConfig(args); | ||
@@ -101,0 +157,0 @@ }).each(function(repo) { |
@@ -18,4 +18,4 @@ 'use strict'; | ||
branch = rGithubPage.test(path) ? 'master' : 'gh-pages'; | ||
} else if (host === 'gitcafe.com') { | ||
branch = 'gitcafe-pages'; | ||
} else if (host === 'coding.net') { | ||
branch = 'coding-pages'; | ||
} | ||
@@ -22,0 +22,0 @@ } |
{ | ||
"name": "hexo-deployer-git", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Git deployer plugin of Hexo.", | ||
@@ -24,2 +24,5 @@ "main": "index", | ||
"author": "Tommy Chen <tommy351@gmail.com> (http://zespia.tw)", | ||
"maintainers": [ | ||
"Abner Chou <hi@abnerchou.me> (http://abnerchou.me)" | ||
], | ||
"license": "MIT", | ||
@@ -36,8 +39,9 @@ "devDependencies": { | ||
"dependencies": { | ||
"bluebird": "^3.5.0", | ||
"chalk": "^1.1.3", | ||
"hexo-fs": "^0.1.5", | ||
"hexo-fs": "^0.1.6", | ||
"hexo-util": "^0.6.0", | ||
"moment": "^2.13.0", | ||
"moment": "^2.18.0", | ||
"swig": "^1.4.2" | ||
} | ||
} |
@@ -13,2 +13,7 @@ # hexo-deployer-git | ||
If you want to use the latest features of hexo-deployer-git, you may install it from github, | ||
``` bash | ||
$ npm install git+git@github.com:hexojs/hexo-deployer-git.git --save | ||
``` | ||
## Options | ||
@@ -27,3 +32,6 @@ | ||
email: [git email] | ||
extend_dirs: [extend directory] | ||
ignore_hidden: false # default is true | ||
ignore_pattern: regexp # whatever file that matches the regexp will be ignored when deploying | ||
# or this: | ||
@@ -33,5 +41,14 @@ deploy: | ||
message: [message] | ||
repo: | ||
repo: | ||
github: <repository url>,[branch] | ||
gitcafe: <repository url>,[branch] | ||
coding: <repository url>,[branch] | ||
extend_dirs: | ||
- [extend directory] | ||
- [another extend directory] | ||
ignore_hidden: | ||
public: false | ||
[extend directory]: true | ||
[another extend directory]: false | ||
ignore_pattern: | ||
[folder]: regexp # or you could specify the ignore_pattern under a certain directory | ||
``` | ||
@@ -43,10 +60,33 @@ | ||
- **name** and **email**: User info for committing the change, overrides global config. This info is independent of git login. | ||
- **extend_dirs**: Add some extensions directory to publish. e.g `demo`, `examples` | ||
- **ignore_hidden** (Boolean|Object): whether ignore hidden files to publish. the github requires the `.nojekyll` in root. | ||
* Boolean: for all dirs. | ||
* Object: for public dir and extend dir: | ||
* `public`: the public dir defaults. | ||
* [extend directory] | ||
- **ignore_pattern** (Object|RegExp): Choose the ignore pattern when deploying | ||
* RegExp: for all dirs. | ||
* Object: specify the ignore pattern under certain directory. For example, if you want to push the source files and generated files at the same time to two different branches. The option should be like | ||
```yaml | ||
# _config.yaml | ||
deploy: | ||
- type: git | ||
repo: git@github.com:<username>/<username>.github.io.git | ||
branch: master | ||
- type: git | ||
repo: git@github.com:<username>/<username>.github.io.git | ||
branch: src | ||
extend_dirs: / | ||
ignore_hidden: false | ||
ignore_pattern: | ||
public: . | ||
``` | ||
## How it works | ||
`hexo-deployer-git` works by generating the site in `.deploy_git` and *force pushing* to the repo(es) in config. | ||
If `.deploy_git` does not exist, a repo will initialized (`git init`). | ||
Otherwise the curent repo (with its commit history) will be used. | ||
`hexo-deployer-git` works by generating the site in `.deploy_git` and *force pushing* to the repo(es) in config. | ||
If `.deploy_git` does not exist, a repo will initialized (`git init`). | ||
Otherwise the curent repo (with its commit history) will be used. | ||
Users can to clone the deployed repo to `.deploy_git` to keep the commit history. | ||
Users can clone the deployed repo to `.deploy_git` to keep the commit history. | ||
``` | ||
@@ -53,0 +93,0 @@ git clone <gh-pages repo> .deploy_git |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
11607
175
105
6
5
1
+ Addedbluebird@^3.5.0
Updatedhexo-fs@^0.1.6
Updatedmoment@^2.18.0