From ea5218e044e7bb29c847b626113a043e20495aa4 Mon Sep 17 00:00:00 2001 From: Serafin Date: Thu, 21 Sep 2017 17:18:28 -0700 Subject: [PATCH 01/11] Modifies helpers to prepare for skill markdowns Includes bin/skillsPopulate file left-over from old specs - no longer useful but keeping until told to remove --- DougSerafin286Notes.md | 83 +++++++++++++++++++++++++++++++ bin/skillsPopulate | 62 +++++++++++++++++++++++ package.json | 2 +- web-server/helpers.js | 11 ++-- web-server/routes/skills.js | 4 +- web-server/views/skills/show.jade | 3 ++ 6 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 DougSerafin286Notes.md create mode 100755 bin/skillsPopulate diff --git a/DougSerafin286Notes.md b/DougSerafin286Notes.md new file mode 100644 index 00000000..19a2a5d2 --- /dev/null +++ b/DougSerafin286Notes.md @@ -0,0 +1,83 @@ +if you see this, yell at doug and serafin - we should have rebased it away before the pull request! + +https://github.com/LearnersGuild/curriculum/issues/286 + + +Notes for planning: +1. Go into digest/skills.js and add properties for links to markdown files +1. those markdown file names will be parsed in identifyable way - and don't neccesarily need to match id's +1. the view will load the markdown by using + + + + + + + + + + + + + + +You wanted to see our branch when we arrive at a pre-alpha stage - we have a working showcase just some bugs to fix involving comma parsing etc. - plus figuring out an automated way to pre-populate "useful" info in all those README.md files. (currently populated with dummy text) + +https://github.com/hhhhhaaaa/curriculum/tree/286 + + +12 replies +Serafin Wesnidge [16 minutes ago] +Currently running into problems making a `webServer` test + + +Serafin Wesnidge [13 minutes ago] +Struggling with making tests - for purposes of identifying which "skills" have odd uri encoded id's / names + + +Jared Grippe [13 minutes ago] +what are you testing for? + + +Serafin Wesnidge [11 minutes ago] +Looping over every folder we created (453 of them) for skills and testing that we can access the URL for each of those (because when we render markdown on the page, it will 302 us, because the markdown can't be found because it's looking for a folder which has %32 and commas etc. in them) + + +Jared Grippe [6 minutes ago] +https://github.com/LearnersGuild/curriculum/issues/286 + + +Jared Grippe +[6 minutes ago] +i updated the spec with some more specifics + + +Serafin Wesnidge [4 minutes ago] +Okay. That's a moderately different direction than our approach, we'll tackle that now. + +I figured out where I was going wrong earlier, I thought `webServer` in the mocha chai was some sort of chai-http curl like tester, but I just traced it and found out it's our express app itself. No wonder we can't "get" our routes. + +We'll abandon the TDD and just switch to matching those new speecs. + + +Jared Grippe +[3 minutes ago] +woot! + + +Jared Grippe +[3 minutes ago] +the tests you should add should be around the digest properly sucking in these data + + +Jared Grippe +[3 minutes ago] +add the "markdownFilePath" property to each skill in the digest and then use that property to read and parse the proper markdown file and then display on the page + + +Jared Grippe [2 minutes ago] +each skill markdown file you render should be readable on its own so make the title the skill name and not `#welcome` + + +Jared Grippe [2 minutes ago] +there should be a test that asserts a skill markdown file exists for any skill references from a module, if it doesnt then throw an error \ No newline at end of file diff --git a/bin/skillsPopulate b/bin/skillsPopulate new file mode 100755 index 00000000..b5dcba12 --- /dev/null +++ b/bin/skillsPopulate @@ -0,0 +1,62 @@ +#!/usr/bin/env node + +const fs = require('fs') + +const digest = require('../digest') + +function fsPromise(funcName, params) { + return new Promise( (resolve, reject) => { + fs[funcName]( ...params, (error, result) => { + if(error) { + reject(error) + return + } + resolve(result) + }) + }) +} + +function makeDirectories() { + digest() + .then(digestInfo => Object.keys(digestInfo.skills)) + .then(skillsArray => { + const arrOfDirs = [] + skillsArray.forEach(skill => { + skill = skill.replace(/[\'\,\/]/g,'-') + arrOfDirs.push(fsPromise('mkdir', ['./skills/' + skill])) + }) + }) +} + +function createSampleFiles() { + fsPromise('readdir', ['./skills']) + .then( folderNames => { + const sampleData = + `### Welcome\n`+ + `This is a brief description\n` + + folderNames.forEach( folder => { + fsPromise('writeFile', [`./skills/${folder}/README.md`, sampleData]) + }) + return true + }) +} + +function main(args) { + if(args.length <= 2 || args.length > 3) { + console.log( + `Not enough arguments.\n`+ + `Usage: ./bin/${args[1].match(/[^\/]*$/g)[0]} \n\n`+ + `dirs: Make empty directories based on module folder names\n`+ + `populate: Create sample README.md files in each skill folder\n` + ) + return + } + + ({ + 'dirs': makeDirectories, + 'populate': createSampleFiles, + })[args[2]]() +} + +main(process.argv) diff --git a/package.json b/package.json index 16e0641e..01b24afe 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dev": "nodemon web-server", "start": "node web-server", "db:migrate": "knex migrate:latest", - "test": "mocha -G -r ./mocha.config.js $(find digest web-server database backoffice | grep .test.js) ", + "test": "mocha -G -r ./mocha.config.js $(find digest web-server database backoffice skills | grep .test.js) ", "test:watch": "npm test -- --watch", "webpack": "webpack --config ./web-server/webpack.config.js", "heroku-prebuild": "npm install && npm run webpack" diff --git a/web-server/helpers.js b/web-server/helpers.js index 3178ce1c..d41b2982 100644 --- a/web-server/helpers.js +++ b/web-server/helpers.js @@ -118,11 +118,11 @@ module.exports = app => { }) } - response.renderMarkdownFile = function(relativeFilePath=request.path){ + response.renderMarkdownFile = function(relativeFilePath=request.path, viewPage, extraArgs){ const absoluteFilePath = path.resolve(__dirname, '..', '.'+relativeFilePath) fs.readFile(absoluteFilePath) .then(file => { - response.renderMarkdown(file.toString()) + response.renderMarkdown(file.toString(), viewPage, extraArgs) }) .catch(error => { if (error.message.includes('ENOENT')){ @@ -133,7 +133,7 @@ module.exports = app => { }) } - response.renderMarkdown = function(markdown){ + response.renderMarkdown = function(markdown, viewPage='markdown', extraArgs){ renderMarkdown(markdown, (error, content) => { if (error) return response.renderServerError(error) @@ -148,7 +148,10 @@ module.exports = app => { sourceUrl: 'https://github.com/GuildCrafts/curriculum/blob/master'+path, editeUrl: 'https://github.com/GuildCrafts/curriculum/edit/master'+path, } - response.render('markdown', file) + for(let extraArgsItem in extraArgs) { + file[extraArgsItem] = extraArgs[extraArgsItem] + } + response.render(viewPage, file) }) } diff --git a/web-server/routes/skills.js b/web-server/routes/skills.js index 8c4afcdf..acbf6d48 100644 --- a/web-server/routes/skills.js +++ b/web-server/routes/skills.js @@ -31,9 +31,11 @@ module.exports = app => { queries.getChecksForUserAndLabels({userId, labels}) .then(checks => { const checked = !!checks[skill.id] - response.render('skills/show', {skill, checked, title: skill.name}) + response.renderMarkdownFile(skill.markdownUrl, 'skills/show', {skill, checked, title: skill.name}) + }) .catch(next) }) + } diff --git a/web-server/views/skills/show.jade b/web-server/views/skills/show.jade index 2c4c3b00..34b7d88b 100644 --- a/web-server/views/skills/show.jade +++ b/web-server/views/skills/show.jade @@ -6,6 +6,9 @@ block content input.skill-checkbox(type="checkbox", data-label=skill.id, checked=checked) span !{renderSkill(skill)} + h1.skill-markdown + span !{content} + h2 Modules ul for moduleId in skill.modules From ebc6b857c10880ea95d42dc330f53d2f90ca4823 Mon Sep 17 00:00:00 2001 From: Doug L Date: Fri, 22 Sep 2017 11:55:53 -0700 Subject: [PATCH 02/11] Modified skills related files(digest, views, and route) Modified skillsPopulate script Removed accidental skills-markdown.js --- bin/skillsPopulate | 95 +++++++++++++------ digest/skills.js | 4 + ...odules-.bin-to-your-$PATH,-in-the-shell.md | 7 ++ ...n-add-Git-metadata-to-your-shell-prompt.md | 7 ++ ...-to-their-Shell-config,-in-the-terminal.md | 7 ++ ...to-restrict-access-to-certain-resources.md | 7 ++ ...eatures-to-a-pre-existing-Node-codebase.md | 7 ++ ...e-prototype-of-a-JavaScript-Constructor.md | 7 ++ ...ctively-manipulate-the-DOM-in-a-Browser.md | 7 ++ ...my-experience-level-at-a-hiring-company.md | 7 ++ ...-JavaScript-RegExp-with-a-character-set.md | 7 ++ ...ression-by-using-the-RegExp-constructor.md | 7 ++ ...egular-Expression-literal-in-JavaScript.md | 7 ++ ...-global-variables-in-Browser-JavaScript.md | 7 ++ .../Can-bind-to-a-DOM-event-in-the-Browser.md | 7 ++ ...ith-authentication-using-Passport-OAuth.md | 7 ++ ...cation-using-bcrypt-and-session-cookies.md | 7 ++ ...ild-a-HTTP-server-with-Node-and-Express.md | 7 ++ .../Can-build-a-RESTful-API-using-Express.md | 7 ++ ...L-schema-for-a-given-problem-definition.md | 7 ++ ...-a-full-stack-application-using-Express.md | 7 ++ ...ue-of-stock-options-at-a-hiring-company.md | 7 ++ ...,-log-and-re-throw-errors-in-JavaScript.md | 7 ++ ...-and-rescue-from-an-error-in-JavaScript.md | 7 ++ ...tyling-using-the-Chrome-Developer-Tools.md | 7 ++ skills/Can-clone-a-Git-repository.md | 7 ++ ...the-~-.bashrc-and-~-.bash_profile-files.md | 7 ++ ...onfigure-npm-test-to-run-Mocha,-in-Node.md | 7 ++ ...ction-that-returns-a-JavaScript-Promise.md | 7 ++ ...onvert-a-mental-model-into-a-SQL-schema.md | 7 ++ .../Can-convert-a-mockup-into-HTML-&-CSS.md | 7 ++ ...Can-convert-a-wireframe-into-HTML-&-CSS.md | 7 ++ ...-between-hourly-and-yearly-compensation.md | 7 ++ skills/Can-create-a-Git-branch.md | 7 ++ ...s-arguments-and-prints-output-to-STDOUT.md | 7 ++ ...te-a-form-that-does-an-HTTP-GET-request.md | 7 ++ ...e-a-form-that-does-an-HTTP-POST-request.md | 7 ++ .../Can-create-a-new-Promise-in-JavaScript.md | 7 ++ skills/Can-create-a-repository-on-GitHub.md | 7 ++ ...reset,-migrate,-and-seed-a-SQL-database.md | 7 ++ ...(test,-development,-production)-in-Node.md | 7 ++ skills/Can-customize-your-BASH-prompt.md | 7 ++ ...ocal-vs.-global-variables-in-JavaScript.md | 7 ++ skills/Can-define-a-BASH-alias.md | 7 ++ skills/Can-define-a-Git-alias.md | 7 ++ skills/Can-define-a-JavaScript-Constructor.md | 7 ++ ...th-a-auto-sequencing-primary-key-in-SQL.md | 7 ++ ...hema:load-in-the-node-package.json-file.md | 7 ++ ...that-follow-the-Restful-Routing-pattern.md | 7 ++ ...a-table,-from-Node-using-the-pg-package.md | 7 ++ skills/Can-deploy-an-application-to-Heroku.md | 7 ++ ...cribe-DOM-event-bubbling-in-the-Browser.md | 7 ++ skills/Can-describe-HTTP-CORS.md | 7 ++ skills/Can-describe-JavaScript-hoisting.md | 7 ++ skills/Can-describe-SQL-ACID-principals.md | 7 ++ skills/Can-describe-SQL-de-normalization.md | 7 ++ skills/Can-describe-SQL-normalization.md | 7 ++ skills/Can-describe-UNIX-file-permissions.md | 7 ++ ...n-describe-a-1-to-1-relationship-in-SQL.md | 7 ++ ...escribe-a-1-to-many-relationship-in-SQL.md | 7 ++ skills/Can-describe-a-SQL-join-table.md | 7 ++ skills/Can-describe-a-SQL-join.md | 7 ++ skills/Can-describe-a-SQL-transaction.md | 7 ++ ...ribe-a-many-to-many-relationship-in-SQL.md | 7 ++ ...n-that-would-call-for-a-SQL-transaction.md | 7 ++ skills/Can-describe-an-HTTP-redirect.md | 7 ++ ...ance-included-in-a-compensation-package.md | 7 ++ ...ibe-and-use-Promise.all()-in-JavaScript.md | 7 ++ ...be-and-use-Promise.race()-in-JavaScript.md | 7 ++ ...-and-use-Promise.reject()-in-JavaScript.md | 7 ++ ...and-use-Promise.resolve()-in-JavaScript.md | 7 ++ ...rkaround-to-the-HTTP-Same-origin-policy.md | 7 ++ skills/Can-describe-foreign-key-in-SQL.md | 7 ++ ...lexical-scope-inheritance-in-JavaScript.md | 7 ++ skills/Can-describe-primary-key-in-SQL.md | 7 ++ ...an-describe-shell-environment-variables.md | 7 ++ ...ibe-the-!-(bang)-operator-in-JavaScript.md | 7 ++ ...an-describe-the-HTTP-Same-origin-policy.md | 7 ++ .../Can-describe-the-JavaScript-call-stack.md | 7 ++ ...EACTO!-pattern-for-technical-interviews.md | 7 ++ skills/Can-describe-the-UNIX-filesystem.md | 7 ++ ...erence-between-==-and-===-in-JavaScript.md | 7 ++ ...e-between-Chai's-eql-vs.-equal,-in-Node.md | 7 ++ ...y-params-and-body-params-and-url-params.md | 7 ++ ...n-HTTP-authentication-and-authorization.md | 7 ++ ...-HTTP-query-params-and-HTTP-body-params.md | 7 ++ ...ess's-sendFile-and-serving-static-files.md | 7 ++ ...e-being-fulfilled-and-it-being-rejected.md | 7 ++ ...ft,-right,-inner-and-outer-joins-in-SQL.md | 7 ++ ...n-a-relative-and-absolute-HTTP-URL-path.md | 7 ++ ...lute-vs.-relative-UNIX-filesystem-paths.md | 7 ++ ...difference-between-an-HTTP-POST-and-GET.md | 7 ++ ...n-fs.readFileSync-&-fs.readFile-in-Node.md | 7 ++ ...ce-between-normal-HTTP-requests-and-XHR.md | 7 ++ ...units-(in-terms-of-equity-compensation).md | 7 ++ ...ence-between-unit-and-integration-tests.md | 7 ++ ...tween-var,-let,-and-const-in-JavaScript.md | 7 ++ ...between-bind,-call,-apply-in-JavaScript.md | 7 ++ ...-unit,-integration-and-end-to-end-tests.md | 7 ++ ...fferent-parts-of-a-compensation-package.md | 7 ++ ...ibe-the-each-Array-method-in-JavaScript.md | 7 ++ ...e-the-filter-Array-method-in-JavaScript.md | 7 ++ ...ing-pattern-MVC-(Model-View-Controller).md | 7 ++ ...ribe-the-general-programming-term-Array.md | 7 ++ ...scribe-the-general-programming-term-DRY.md | 7 ++ ...-programming-term-Defensive-Programming.md | 7 ++ ...amming-term-Entity-Relationship-Diagram.md | 7 ++ ...e-the-general-programming-term-Function.md | 7 ++ ...cribe-the-general-programming-term-Hash.md | 7 ++ ...ming-term-Minimum-Viable-Product-or-MVP.md | 7 ++ ...ribe-the-general-programming-term-SOLID.md | 7 ++ ...scribe-the-general-programming-term-Set.md | 7 ++ ...be-the-general-programming-term-closure.md | 7 ++ ...eneral-programming-term-global-variable.md | 7 ++ ...e-general-programming-term-if-statement.md | 7 ++ ...general-programming-term-local-variable.md | 7 ++ ...al-programming-term-operator-precedence.md | 7 ++ ...-general-programming-term-pure-function.md | 7 ++ ...ribe-the-general-programming-term-state.md | 7 ++ ...e-the-general-programming-term-variable.md | 7 ++ ...ribe-the-map-Array-method-in-JavaScript.md | 7 ++ ...ays-to-prepare-for-technical-interviews.md | 7 ++ ...ribe-the-pop-Array-method-in-JavaScript.md | 7 ++ ...ibe-the-push-Array-method-in-JavaScript.md | 7 ++ ...e-the-reduce-Array-method-in-JavaScript.md | 7 ++ ...be-the-shift-Array-method-in-JavaScript.md | 7 ++ ...-the-unshift-Array-method-in-JavaScript.md | 7 ++ ...the-HTTP-status-codes-200,-404,-and-500.md | 7 ++ ...ses-for-the-PUT-and-DELETE-HTTP-methods.md | 7 ++ ...ng-as-it-relates-to-equity-compensation.md | 7 ++ ...\"HTTP-is-a-stateless-protocol\"-means.md" | 7 ++ ...hat-$-and-^-mean-in-a-JavaScript-RegExp.md | 7 ++ skills/Can-describe-what-AJAX-is-(browser).md | 7 ++ ...be-what-COMMIT-and-ROLLBACK-mean-in-SQL.md | 7 ++ ...Can-describe-what-Express-Middleware-is.md | 7 ++ skills/Can-describe-what-HTTP-REST-is.md | 7 ++ ...t-Mocha's-done-function-is-for,-in-Node.md | 7 ++ skills/Can-describe-what-Node's-webpack-is.md | 7 ++ skills/Can-describe-what-SQL-injection-is.md | 7 ++ skills/Can-describe-what-XHR-is-(browser).md | 7 ++ ...gher-order-function\"-is-in-JavaScript.md" | 7 ++ ...at-a-JavaScript-RegExp-character-set-is.md | 7 ++ .../Can-describe-what-a-SQL-migration-is.md | 7 ++ ...erized-query-(or-prepared-statement)-is.md | 7 ++ ...cribe-what-a-System-Design-interview-is.md | 7 ++ ...describe-what-a-UNIX-filesystem-path-is.md | 7 ++ ...ribe-what-a-pure-JavaScript-function-is.md | 7 ++ ...describe-what-an-HTML-