Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit fa81abf9 authored by Erik Schwartz's avatar Erik Schwartz 🉐
Browse files

Reorg

parent 3e34510b
...@@ -4,9 +4,9 @@ Download files from IQ SFTP server to local filesystem. ...@@ -4,9 +4,9 @@ Download files from IQ SFTP server to local filesystem.
* Used for BO report delivery to Rec Fusion customers. * Used for BO report delivery to Rec Fusion customers.
* BO -> SFTP [project documentation](https://iqops.dsc.umich.edu/wiki/index.php/Transfer_files_from_BO_to_IQ_SFTP_server). * BO -> SFTP [project documentation](https://iqops.dsc.umich.edu/wiki/index.php/Transfer_files_from_BO_to_IQ_SFTP_server).
* Tested with [Node.js v12 LTS](https://nodejs.org/en/). * Tested with [Node.js v14 LTS](https://nodejs.org/en/).
## Install and unit test ## Install
First, install the [Node.js runtime](https://nodejs.org/en/download/). First, install the [Node.js runtime](https://nodejs.org/en/download/).
...@@ -14,8 +14,7 @@ Next, clone this repository, enter its top-level directory, and install the requ ...@@ -14,8 +14,7 @@ Next, clone this repository, enter its top-level directory, and install the requ
```bash ```bash
cd recfu-mover cd recfu-mover
npm install npm install --production && npm audit fix
npm audit
``` ```
Next, copy the example configuration: Next, copy the example configuration:
......
...@@ -4,17 +4,14 @@ ...@@ -4,17 +4,14 @@
// Variable definitions // Variable definitions
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
const f = require('./functions'); const {doIt} = require('./lib');
const options = './site-config/client.json'; const options = './site-config/client.json';
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Main logic // Main logic
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
f.doIt(options, (err, msg) => { doIt(options, (err, msg) => {
if (err) { if (err) throw err;
console.error(err); console.log(msg);
} else {
console.log(msg);
}
}); });
...@@ -82,6 +82,13 @@ function downloadFile(sshOpt, remoteFile, localFile, callback) { ...@@ -82,6 +82,13 @@ function downloadFile(sshOpt, remoteFile, localFile, callback) {
// Exported functions // Exported functions
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/**
* Read SFTP options, download file from SFTP server.
*
* @param {string} optionsConf - Name of SFTP options file.
* @param {Function} callback - Callback function.
* @returns {Function} Callback function.
*/
exports.doIt = function(optionsConf, callback) { exports.doIt = function(optionsConf, callback) {
const o = readSftpOptions(optionsConf); const o = readSftpOptions(optionsConf);
downloadFile(o.sshSettings, o.remoteFile, o.localFile, (err, msg) => { downloadFile(o.sshSettings, o.remoteFile, o.localFile, (err, msg) => {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
const assert = require('assert'); const assert = require('assert');
const fs = require('fs'); const fs = require('fs');
const rewire = require('rewire'); const rewire = require('rewire');
const pf = rewire('../functions'); const pf = rewire('../lib');
// Map rewired, private functions to friendlier names // Map rewired, private functions to friendlier names
const readSftpOptions = pf.__get__('readSftpOptions'); const readSftpOptions = pf.__get__('readSftpOptions');
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {
"pretest": "eslint --ignore-path .eslintignore .", "pretest": "eslint --ignore-path .eslintignore .",
"test": "mocha", "test": "mocha 'lib/*.spec.js'",
"download": "npm test && node app.js" "download": "node app.js"
}, },
"author": "whatitis", "author": "whatitis",
"license": "MIT", "license": "MIT",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment