forked from nt3rp/hexo-deployer-s3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c85c1a6
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# FTP deployer plugin for [Hexo] | ||
|
||
This plugin can deploy your blog via FTP. | ||
|
||
## Usage | ||
|
||
### Install | ||
|
||
``` | ||
npm install hexo-deployer-ftp --save | ||
``` | ||
|
||
`lftp` is required. Install it with `apt-get install lftp` or `brew install lftp` depending on your OS. | ||
|
||
### Enable | ||
|
||
Add `hexo-deployer-ftp` to `plugins` in `_config.yml`. | ||
|
||
``` yaml | ||
plugins: | ||
- hexo-deployer-ftp | ||
``` | ||
|
||
### Configure | ||
|
||
Add `host`, `user` and `root` to `deploy` in `_config.yml`. | ||
|
||
``` | ||
deploy: | ||
type: ftp | ||
host: <ftp host> | ||
user: <ftp user> | ||
root: <path/to/your/blog/on/the/server> | ||
``` | ||
|
||
### Disable | ||
|
||
Remove `hexo-deployer-ftp` from `plugins` in `_config.yml`. | ||
|
||
``` yaml | ||
plugins: | ||
- hexo-deployer-ftp | ||
``` | ||
|
||
### Update | ||
|
||
Execute the following command. | ||
|
||
``` | ||
npm update | ||
``` | ||
|
||
### Uninstall | ||
|
||
Execute the following command. Don't forget to disable the plugin before uninstalling. | ||
|
||
``` | ||
npm uninstall hexo-deployer-ftp | ||
``` | ||
|
||
[Hexo]: http://zespia.tw/hexo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var spawn = require('child_process').spawn; | ||
|
||
// run function which supports interactive commands | ||
function run (command, args, callback) { | ||
process.stdin.pause(); | ||
process.stdin.setRawMode(false); | ||
|
||
var p = spawn(command, args, { | ||
customFds: [0, 1, 2] | ||
}); | ||
return p.on('exit', function() { | ||
process.stdin.setRawMode(true); | ||
process.stdin.resume(); | ||
return callback(); | ||
}); | ||
}; | ||
|
||
hexo.extend.deployer.register('ftp', function (args, callback) { | ||
var config = hexo.config.deploy; | ||
|
||
if (!config.host || !config.user || !config.root){ | ||
var help = [ | ||
'You should configure deployment settings in _config.yml first!', | ||
'', | ||
'Example:', | ||
' deploy:', | ||
' type: ftp', | ||
' host: <host>', | ||
' user: <user>', | ||
' root: <root>', | ||
'', | ||
'For more help, you can check the docs: ' + 'http://zespia.tw/hexo/docs/deployment.html' | ||
]; | ||
|
||
console.log(help.join('\n')); | ||
return callback(); | ||
} | ||
|
||
var args = [ | ||
'-e', | ||
'mirror -R --ignore-time --delete -v ./public ' + config.root + '; bye', | ||
'-u', | ||
config.user, | ||
config.host | ||
]; | ||
|
||
run('lftp', args, function (code) { | ||
callback(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "hexo-deployer-ftp", | ||
"version": "0.0.1", | ||
"description": "FTP deployer plugin for Hexo", | ||
"main": "index", | ||
"keywords": ["website", "blog", "cms", "framework", "hexo", "ftp"], | ||
"author": "Florian Cargoët", | ||
"repository" : "floriancargoet/hexo-deployer-ftp", | ||
"license": { | ||
"type": "MIT" | ||
}, | ||
"engines": { | ||
"hexo": ">= 1.0.0" | ||
}, | ||
"dependencies": { | ||
} | ||
} |