0.1.0 • Published 7 years ago

travis-ftpr v0.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Travis CI FTP'r

A utility for various Travis CI projects which abstracts away the following steps: 1. Connect via FTP to host 2. Delete all files and folders within the remote folder, leaving the remote folder itself intact (5 at a time) 3. Create all non-empty folders (recursively) in the local dist folder inside the remote folder, excluding the dist folder itself (1 at a time). 4. Upload all files from local dist folder to respective remote folder (5 at a time)

In other words:
REMOTE:          +      LOCAL:          =         REMOTE:
|- foo.txt              |- foo.txt                |- foo.txt
|- libs                 |- bar.txt                |- bar.txt
|--- foobar.txt         |- libs                   |- libs
|--- barfoo.txt         |--- foobar.txt           |--- foobar.txt
                        |- scripts

Good lord, be careful

This does not make a backup of the previous remote directory, nor does it upload to a temp folder and rename itself when finished.

How to use

Install the utility
npm install --save-dev travis-ftpr
Create an NPM script in your package.json.
...
"scripts": {
    "publish": "node scripts/publish.js"
}
...
Create scripts/publish.js, referenced in the above publish script.
const deployer = require("travis-ftpr");

deployer.deploy({
    host: process.argv[2],
    username: process.argv[3],
    password: process.argv[4],
    localDirectory: process.argv[5],
    remoteDirectory: process.argv[6]
}, function() {
    console.log("Done");
});
Create repo environment variables in Travis

Create variables for the host, username and password fields using Repository Settings or Encrypted Variables.

For example, $FTP_HOST, $FTP_USERNAME and $FTP_PASSWORD below are from Repository Setting variables I created called FTP_HOST, FTP_USERNAME and FTP_PASSWORD respectively (no $ in their definition).

Tell Travis to run the publish script in your .travis.yml
language: node_js
node_js:
  - "6"

after_success:
  - npm run publish $FTP_HOST $FTP_USERNAME $FTP_PASSWORD dist public_html || exit 1

If you only want to build against a particular branch, for instance master, use a conditional in your after_success step:

language: node_js
node_js:
  - "6"

script:
  - npm run build || exit 1

after_success:
  - test $TRAVIS_BRANCH = "master" && (npm run publish $FTP_HOST $FTP_USERNAME $FTP_PASSWORD dist public_html/repos/katas-roman-numeral || exit 1)
0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago