Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
floriancargoet committed Nov 24, 2013
0 parents commit c85c1a6
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .npmignore
@@ -0,0 +1,2 @@
.git*
.DS_Store
61 changes: 61 additions & 0 deletions README.md
@@ -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 changes: 50 additions & 0 deletions index.js
@@ -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 changes: 17 additions & 0 deletions package.json
@@ -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": {
}
}

0 comments on commit c85c1a6

Please sign in to comment.