From 272d9b4ad58b57438534cdbe3e615a388b25c3dd Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 2 Jun 2015 20:32:10 -0700 Subject: [PATCH] Update seed directory to use loopback --- README.md | 2 +- {seed_data => seed}/bonfireMDNlinks.js | 0 {seed_data => seed}/challenge-migration.js | 0 {seed_data => seed}/challengeMapping.json | 0 .../challenges/advanced-bonfires.json | 0 {seed_data => seed}/challenges/basejumps.json | 0 .../challenges/basic-bonfires.json | 0 .../challenges/basic-html5-and-css.json | 2 +- .../challenges/basic-javascript.json | 0 {seed_data => seed}/challenges/bootstrap.json | 0 .../challenges/computer-science.json | 0 .../challenges/full-stack-javascript.json | 0 .../challenges/functional-programming.json | 0 .../get-set-for-free-code-camp.json | 0 .../challenges/intermediate-bonfires.json | 0 .../challenges/jquery-ajax-and-json.json | 0 .../object-oriented-javascript.json | 0 {seed_data => seed}/challenges/ziplines.json | 0 {seed_data => seed}/field-guides.json | 2 +- .../future-jquery-ajax-json.json | 0 seed/index.js | 99 +++++++++++++++++++ {seed_data => seed}/jobs.json | 0 {seed_data => seed}/nonprofits.json | 0 {seed_data => seed}/storyCleanup.js | 0 {seed_data => seed}/userMigration.js | 0 seed_data/seed.js | 97 ------------------ 26 files changed, 102 insertions(+), 100 deletions(-) rename {seed_data => seed}/bonfireMDNlinks.js (100%) rename {seed_data => seed}/challenge-migration.js (100%) rename {seed_data => seed}/challengeMapping.json (100%) rename {seed_data => seed}/challenges/advanced-bonfires.json (100%) rename {seed_data => seed}/challenges/basejumps.json (100%) rename {seed_data => seed}/challenges/basic-bonfires.json (100%) rename {seed_data => seed}/challenges/basic-html5-and-css.json (99%) rename {seed_data => seed}/challenges/basic-javascript.json (100%) rename {seed_data => seed}/challenges/bootstrap.json (100%) rename {seed_data => seed}/challenges/computer-science.json (100%) rename {seed_data => seed}/challenges/full-stack-javascript.json (100%) rename {seed_data => seed}/challenges/functional-programming.json (100%) rename {seed_data => seed}/challenges/get-set-for-free-code-camp.json (100%) rename {seed_data => seed}/challenges/intermediate-bonfires.json (100%) rename {seed_data => seed}/challenges/jquery-ajax-and-json.json (100%) rename {seed_data => seed}/challenges/object-oriented-javascript.json (100%) rename {seed_data => seed}/challenges/ziplines.json (100%) rename {seed_data => seed}/field-guides.json (99%) rename {seed_data => seed}/future-jquery-ajax-json.json (100%) create mode 100644 seed/index.js rename {seed_data => seed}/jobs.json (100%) rename {seed_data => seed}/nonprofits.json (100%) rename {seed_data => seed}/storyCleanup.js (100%) rename {seed_data => seed}/userMigration.js (100%) delete mode 100644 seed_data/seed.js diff --git a/README.md b/README.md index 15ba559e4a..dc4e2f7383 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ DEBUG=true mongod # Seed your database with the challenges -node seed_data/seed.js +node seed/ # start the application gulp diff --git a/seed_data/bonfireMDNlinks.js b/seed/bonfireMDNlinks.js similarity index 100% rename from seed_data/bonfireMDNlinks.js rename to seed/bonfireMDNlinks.js diff --git a/seed_data/challenge-migration.js b/seed/challenge-migration.js similarity index 100% rename from seed_data/challenge-migration.js rename to seed/challenge-migration.js diff --git a/seed_data/challengeMapping.json b/seed/challengeMapping.json similarity index 100% rename from seed_data/challengeMapping.json rename to seed/challengeMapping.json diff --git a/seed_data/challenges/advanced-bonfires.json b/seed/challenges/advanced-bonfires.json similarity index 100% rename from seed_data/challenges/advanced-bonfires.json rename to seed/challenges/advanced-bonfires.json diff --git a/seed_data/challenges/basejumps.json b/seed/challenges/basejumps.json similarity index 100% rename from seed_data/challenges/basejumps.json rename to seed/challenges/basejumps.json diff --git a/seed_data/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json similarity index 100% rename from seed_data/challenges/basic-bonfires.json rename to seed/challenges/basic-bonfires.json diff --git a/seed_data/challenges/basic-html5-and-css.json b/seed/challenges/basic-html5-and-css.json similarity index 99% rename from seed_data/challenges/basic-html5-and-css.json rename to seed/challenges/basic-html5-and-css.json index 93b5215440..d2a8e1f64e 100644 --- a/seed_data/challenges/basic-html5-and-css.json +++ b/seed/challenges/basic-html5-and-css.json @@ -237,7 +237,7 @@ "name": "Waypoint: Fill in the Blank with Placeholder Text", "difficulty": 0.015, "description": [ - "Replace the text inside your p element with the first few words of the provided \"Ktty Ipsum\" text.", + "Replace the text inside your p element with the first few words of the provided \"Kitty Ipsum\" text.", "Web developers traditionally use \"Lorem Ipsum\" text as placeholder text. It's called \"Lorem Ipsum\" text because those are the first two words of a famous passage by Cicero of Ancient Rome.", "\"Lorem Ipsum\" text has been used as placeholder text by typesetters since the 16th century, and this tradition continues on the web.", "Well, 5 centuries is long enough. Since we're building a CatPhotoApp, let's use something called \"Kitty Ipsum\"!", diff --git a/seed_data/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json similarity index 100% rename from seed_data/challenges/basic-javascript.json rename to seed/challenges/basic-javascript.json diff --git a/seed_data/challenges/bootstrap.json b/seed/challenges/bootstrap.json similarity index 100% rename from seed_data/challenges/bootstrap.json rename to seed/challenges/bootstrap.json diff --git a/seed_data/challenges/computer-science.json b/seed/challenges/computer-science.json similarity index 100% rename from seed_data/challenges/computer-science.json rename to seed/challenges/computer-science.json diff --git a/seed_data/challenges/full-stack-javascript.json b/seed/challenges/full-stack-javascript.json similarity index 100% rename from seed_data/challenges/full-stack-javascript.json rename to seed/challenges/full-stack-javascript.json diff --git a/seed_data/challenges/functional-programming.json b/seed/challenges/functional-programming.json similarity index 100% rename from seed_data/challenges/functional-programming.json rename to seed/challenges/functional-programming.json diff --git a/seed_data/challenges/get-set-for-free-code-camp.json b/seed/challenges/get-set-for-free-code-camp.json similarity index 100% rename from seed_data/challenges/get-set-for-free-code-camp.json rename to seed/challenges/get-set-for-free-code-camp.json diff --git a/seed_data/challenges/intermediate-bonfires.json b/seed/challenges/intermediate-bonfires.json similarity index 100% rename from seed_data/challenges/intermediate-bonfires.json rename to seed/challenges/intermediate-bonfires.json diff --git a/seed_data/challenges/jquery-ajax-and-json.json b/seed/challenges/jquery-ajax-and-json.json similarity index 100% rename from seed_data/challenges/jquery-ajax-and-json.json rename to seed/challenges/jquery-ajax-and-json.json diff --git a/seed_data/challenges/object-oriented-javascript.json b/seed/challenges/object-oriented-javascript.json similarity index 100% rename from seed_data/challenges/object-oriented-javascript.json rename to seed/challenges/object-oriented-javascript.json diff --git a/seed_data/challenges/ziplines.json b/seed/challenges/ziplines.json similarity index 100% rename from seed_data/challenges/ziplines.json rename to seed/challenges/ziplines.json diff --git a/seed_data/field-guides.json b/seed/field-guides.json similarity index 99% rename from seed_data/field-guides.json rename to seed/field-guides.json index de6edba981..d241f8858b 100644 --- a/seed_data/field-guides.json +++ b/seed/field-guides.json @@ -683,7 +683,7 @@ "
  • Fork the Free Code Camp repository and open seed_data/bonfires.json to become familiar with the format of our bonfires.
  • ", "
  • Regardless of your bonfire's difficulty, put it as the last bonfire in the JSON file. Change one of the numbers in the ID to ensure that your bonfire has a unique ID.
  • ", "
  • In the terminal, run node seed_data/seed.js. Run gulp. You should be able to navigate to your new bonfire in the challenge map. Whenever you make a change to bonfire.json, you'll need to reseed in order to see these changes in the browser.
  • ", - "
  • Solved your own Bonfire. Confirmed that your tests work as expected and that your instructions are sufficiently clear.
  • ", + "
  • Solve your own Bonfire. Confirm that your tests work as expected and that your instructions are sufficiently clear.
  • ", "
  • Submit a pull request to Free Code Camp's Staging branch and in the pull request body, link to a gist that has your algorithmic solution.
  • ", " ", "

    ", diff --git a/seed_data/future-jquery-ajax-json.json b/seed/future-jquery-ajax-json.json similarity index 100% rename from seed_data/future-jquery-ajax-json.json rename to seed/future-jquery-ajax-json.json diff --git a/seed/index.js b/seed/index.js new file mode 100644 index 0000000000..ddad9d678f --- /dev/null +++ b/seed/index.js @@ -0,0 +1,99 @@ +/* eslint-disable no-process-exit */ +require('dotenv').load(); +var fs = require('fs'), + path = require('path'), + app = require('../server/server'), + fieldGuides = require('./field-guides.json'), + nonprofits = require('./nonprofits.json'), + jobs = require('./jobs.json'); + +var Challenge = app.models.Challenge; +var FieldGuide = app.models.FieldGuide; +var Nonprofit = app.models.Nonprofit; +var Job = app.models.Job; +var counter = 0; +var challenges = fs.readdirSync(path.join(__dirname, '/challenges')); +var offerings = 3 + challenges.length; + +var CompletionMonitor = function() { + counter++; + console.log('call ' + counter); + + if (counter < offerings) { + return; + } else { + process.exit(0); + } +}; + +Challenge.destroyAll(function(err, info) { + if (err) { + console.err(err); + } else { + console.log('Deleted ', info); + } + challenges.forEach(function (file) { + Challenge.create( + require('./challenges/' + file).challenges, + function (err) { + if (err) { + console.log(err); + } else { + console.log('Successfully parsed %s', file); + CompletionMonitor(); + } + } + ); + }); +}); + +FieldGuide.destroyAll(function(err, info) { + if (err) { + console.error(err); + } else { + console.log('Deleted ', info); + } + FieldGuide.create(fieldGuides, function(err, data) { + if (err) { + console.log(err); + } else { + console.log('Saved ', data); + } + CompletionMonitor(); + console.log('field guides'); + }); +}); + +Nonprofit.destroyAll(function(err, info) { + if (err) { + console.error(err); + } else { + console.log('Deleted ', info); + } + Nonprofit.create(nonprofits, function(err, data) { + if (err) { + console.log(err); + } else { + console.log('Saved ', data); + } + CompletionMonitor(); + console.log('nonprofits'); + }); +}); + +Job.destroyAll(function(err, info) { + if (err) { + console.error(err); + } else { + console.log('Deleted ', info); + } + Job.create(jobs, function(err, data) { + if (err) { + console.log(err); + } else { + console.log('Saved ', data); + } + console.log('jobs'); + CompletionMonitor(); + }); +}); diff --git a/seed_data/jobs.json b/seed/jobs.json similarity index 100% rename from seed_data/jobs.json rename to seed/jobs.json diff --git a/seed_data/nonprofits.json b/seed/nonprofits.json similarity index 100% rename from seed_data/nonprofits.json rename to seed/nonprofits.json diff --git a/seed_data/storyCleanup.js b/seed/storyCleanup.js similarity index 100% rename from seed_data/storyCleanup.js rename to seed/storyCleanup.js diff --git a/seed_data/userMigration.js b/seed/userMigration.js similarity index 100% rename from seed_data/userMigration.js rename to seed/userMigration.js diff --git a/seed_data/seed.js b/seed_data/seed.js deleted file mode 100644 index 0221952d72..0000000000 --- a/seed_data/seed.js +++ /dev/null @@ -1,97 +0,0 @@ -require('dotenv').load(); -var Challenge = require('../models/Challenge.js'), - FieldGuide = require('../models/FieldGuide.js'), - Nonprofit = require('../models/Nonprofit.js'), - Job = require('../models/Job.js'), - mongoose = require('mongoose'), - secrets = require('../config/secrets'), - fieldGuides = require('./field-guides.json'), - nonprofits = require('./nonprofits.json'), - jobs = require('./jobs.json'), - fs = require('fs'); - -mongoose.connect(secrets.db); -var challenges = fs.readdirSync(__dirname + '/challenges'); - -var counter = 0; -var offerings = 3 + challenges.length; - -var CompletionMonitor = function() { - counter++; - console.log('call ' + counter); - - if (counter < offerings) { - return; - } else { - process.exit(0); - } -}; - -Challenge.remove({}, function(err, data) { - if (err) { - console.err(err); - } else { - console.log('Deleted ', data); - } - challenges.forEach(function (file) { - Challenge.create(require('./challenges/' + file).challenges, function (err, data) { - if (err) { - console.log(err); - } else { - console.log('Successfully parsed %s', file); - CompletionMonitor(); - } - }); - }); -}); - -FieldGuide.remove({}, function(err, data) { - if (err) { - console.error(err); - } else { - console.log('Deleted ', data); - } - FieldGuide.create(fieldGuides, function(err, data) { - if (err) { - console.log(err); - } else { - console.log('Saved ', data); - } - CompletionMonitor(); - }); - console.log('field guides'); -}); - -Nonprofit.remove({}, function(err, data) { - if (err) { - console.error(err); - } else { - console.log('Deleted ', data); - } - Nonprofit.create(nonprofits, function(err, data) { - if (err) { - console.log(err); - } else { - console.log('Saved ', data); - } - CompletionMonitor(); - }); - console.log('nonprofits'); -}); - -Job.remove({}, function(err, data) { - if (err) { - console.error(err); - } else { - console.log('Deleted ', data); - } - Job.create(jobs, function(err, data) { - if (err) { - console.log(err); - } else { - console.log('Saved ', data); - } - CompletionMonitor(); - }); - console.log('jobs'); -});