This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inquirer = require('inquirer'); | |
const fs = require('fs'); | |
const CHOICES = fs.readdirSync(`${__dirname}/templates`); | |
const QUESTIONS = [ | |
{ | |
name: 'project-choice', | |
type: 'list', | |
message: 'What project template would you like to generate?', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CURR_DIR = process.cwd(); | |
inquirer.prompt(QUESTIONS) | |
.then(answers => { | |
const projectChoice = answers['project-choice']; | |
const projectName = answers['project-name']; | |
const templatePath = `${__dirname}/templates/${projectChoice}`; | |
fs.mkdirSync(`${CURR_DIR}/${projectName}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createDirectoryContents (templatePath, newProjectPath) { | |
const filesToCreate = fs.readdirSync(templatePath); | |
filesToCreate.forEach(file => { | |
const origFilePath = `${templatePath}/${file}`; | |
// get stats about the current file | |
const stats = fs.statSync(origFilePath); | |
if (stats.isFile()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (stats.isFile()) { | |
const contents = fs.readFileSync(origFilePath, 'utf8'); | |
// Rename | |
if (file === '.npmignore') file = '.gitignore'; | |
const writePath = `${CURR_DIR}/${newProjectPath}/${file}`; | |
fs.writeFileSync(writePath, contents, 'utf8'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.getdonkeyjobs = (event, context, callback) => { | |
callback(null, 'Hello world'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{job: 'Marketing Campaigns Officer', closing: 'Fri Jul 21 2017 00:00:00 GMT+0100', location: 'Leeds, UK'}, | |
{job: 'Registered Veterinary Nurse', closing: 'Sat Jul 22 2017 00:00:00 GMT+0100', location: 'Manchester, UK'}, | |
{job: 'Building Services Manager', closing: 'Fri Jul 21 2017 00:00:00 GMT+0100', location: 'London, UK'} | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('axios'); | |
const {extractListingsFromHTML} = require('./helpers'); | |
module.exports.getdonkeyjobs = (event, context, callback) => { | |
request('https://www.thedonkeysanctuary.org.uk/vacancies') | |
.then(({data}) => { | |
const jobs = extractListingsFromHTML(data); | |
callback(null, {jobs}); | |
}) | |
.catch(callback); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio'); | |
const moment = require('moment'); | |
function extractListingsFromHTML (html) { | |
const $ = cheerio.load(html); | |
const vacancyRows = $('.view-Vacancies tbody tr'); | |
const vacancies = []; | |
vacancyRows.each((i, el) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: donkeyjob | |
provider: | |
name: aws | |
runtime: nodejs6.10 | |
functions: | |
getdonkeyjobs: | |
handler: handler.getdonkeyjobs | |
resources: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('axios'); | |
const AWS = require('aws-sdk'); | |
const dynamo = new AWS.DynamoDB.DocumentClient(); | |
const { differenceWith, isEqual } = require('lodash'); | |
const { extractListingsFromHTML } = require('./helpers'); | |
module.exports.getdonkeyjobs = (event, context, callback) => { | |
let newJobs, allJobs; | |
request('https://www.thedonkeysanctuary.org.uk/vacancies') |
OlderNewer