Update seed directory to use loopback
This commit is contained in:
@ -95,7 +95,7 @@ DEBUG=true
|
|||||||
mongod
|
mongod
|
||||||
|
|
||||||
# Seed your database with the challenges
|
# Seed your database with the challenges
|
||||||
node seed_data/seed.js
|
node seed/
|
||||||
|
|
||||||
# start the application
|
# start the application
|
||||||
gulp
|
gulp
|
||||||
|
@ -237,7 +237,7 @@
|
|||||||
"name": "Waypoint: Fill in the Blank with Placeholder Text",
|
"name": "Waypoint: Fill in the Blank with Placeholder Text",
|
||||||
"difficulty": 0.015,
|
"difficulty": 0.015,
|
||||||
"description": [
|
"description": [
|
||||||
"Replace the text inside your <code>p</code> element with the first few words of the provided \"Ktty Ipsum\" text.",
|
"Replace the text inside your <code>p</code> 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.",
|
"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.",
|
"\"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\"!",
|
"Well, 5 centuries is long enough. Since we're building a CatPhotoApp, let's use something called \"Kitty Ipsum\"!",
|
@ -683,7 +683,7 @@
|
|||||||
" <li>Fork the Free Code Camp repository and <code>open seed_data/bonfires.json</code> to become familiar with the format of our bonfires.</li>",
|
" <li>Fork the Free Code Camp repository and <code>open seed_data/bonfires.json</code> to become familiar with the format of our bonfires.</li>",
|
||||||
" <li>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.</li>",
|
" <li>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.</li>",
|
||||||
" <li>In the terminal, run <code>node seed_data/seed.js</code>. Run <code>gulp</code>. 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.</li>",
|
" <li>In the terminal, run <code>node seed_data/seed.js</code>. Run <code>gulp</code>. 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.</li>",
|
||||||
" <li>Solved your own Bonfire. Confirmed that your tests work as expected and that your instructions are sufficiently clear.</li>",
|
" <li>Solve your own Bonfire. Confirm that your tests work as expected and that your instructions are sufficiently clear.</li>",
|
||||||
" <li>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.</li>",
|
" <li>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.</li>",
|
||||||
" </ol>",
|
" </ol>",
|
||||||
" </p>",
|
" </p>",
|
99
seed/index.js
Normal file
99
seed/index.js
Normal file
@ -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();
|
||||||
|
});
|
||||||
|
});
|
@ -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');
|
|
||||||
});
|
|
Reference in New Issue
Block a user