Skip to content

Instantly share code, notes, and snippets.

@david-martin
Created June 3, 2014 14:22
Show Gist options
  • Save david-martin/fe1d993b161bf2d461f6 to your computer and use it in GitHub Desktop.
Save david-martin/fe1d993b161bf2d461f6 to your computer and use it in GitHub Desktop.
Using fhc, migrate all fh2 apps to fh3
#!/usr/bin/env node
var fh = require('fh-fhc');
var async = require('async');
// Init fhc
fh.fhc.load(function (err) {
if (err) return console.error(err);
// Target my domain and login
fh.target(['https://testing.feedhenry.me','me@example.com','password'], function(err, ok) {
if (err) return console.error(err);
console.log('ok:', ok);
// List all apps
fh.apps([], function(err, apps) {
if (err) return console.error(err);
console.log('apps:', apps);
// Iterate over apps, calling migrate for each
async.mapSeries(apps.list, function(app, cb) {
// Passing 'silent' here will bypass prompt after validation check if check is ok
fh.migrate([app.id, 'silent'], function(err, data) {
if (err) return cb(err);
console.log('data:', data);
return cb(null, data);
});
}, function(err, results) {
if (err) return console.error(err);
// all done
console.log('results:', results);
});
});
});
});
{
"name": "migrate",
"version": "0.0.1",
"description": "Using fhc, migrate all fh2 apps to fh3",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "david.martin@feedhenry.com",
"license": "BSD-2-Clause",
"dependencies": {
"async": "~0.9.0",
"fh-fhc": "~0.30.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment