initial commit
This commit is contained in:
2
.npmignore
Normal file
2
.npmignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.git*
|
||||||
|
.DS_Store
|
||||||
61
README.md
Normal file
61
README.md
Normal file
@@ -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
|
||||||
50
index.js
Normal file
50
index.js
Normal file
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
17
package.json
Normal file
17
package.json
Normal file
@@ -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": {
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user