2019-10-06 09:57:08 -04:00
|
|
|
#! /usr/bin/env node
|
|
|
|
|
|
|
|
const program = require('commander');
|
|
|
|
|
|
|
|
const {
|
|
|
|
fetchFromMedium,
|
|
|
|
pushToGhost,
|
|
|
|
mediumToGhost,
|
2019-10-09 06:47:37 -04:00
|
|
|
generateUserData,
|
2019-10-06 09:57:08 -04:00
|
|
|
} = require ('./functions');
|
|
|
|
|
|
|
|
program
|
|
|
|
.version('1.0.0-dev')
|
|
|
|
.description('pull posts from Medium and add them to a Ghost blog');
|
|
|
|
|
|
|
|
program.command('fetch-medium <post_url>')
|
|
|
|
.alias('fetch')
|
|
|
|
.description('fetch a Medium post')
|
|
|
|
.action((post_url) => {
|
2019-10-11 06:55:52 -04:00
|
|
|
fetchFromMedium(post_url)
|
|
|
|
.then((post) => {
|
|
|
|
console.info(`"${post.title}" fetched successfully`)
|
|
|
|
console.debug(post)
|
|
|
|
})
|
2019-10-06 09:57:08 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
program.command('push-ghost <file>')
|
|
|
|
.alias('push')
|
|
|
|
.description('push a downloaded Medium post to Ghost')
|
|
|
|
.action((file) => {
|
|
|
|
pushToGhost(file);
|
|
|
|
});
|
|
|
|
|
|
|
|
program.command('medium-to-ghost <mediumUrl>')
|
|
|
|
.alias('import')
|
|
|
|
.description('copy a Medium file over to Ghost')
|
|
|
|
.action((mediumUrl) => {
|
|
|
|
pushToGhost(mediumUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
program.command('create-user <username> <email>')
|
|
|
|
.description('create ghost-import.json to import Medium user to Ghost')
|
2019-10-09 06:47:37 -04:00
|
|
|
.action(async (username, email) => {
|
|
|
|
const jsonOut = await generateUserData(username, email);
|
|
|
|
console.log(await jsonOut);
|
2019-10-06 09:57:08 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
program.parse(process.argv)
|