mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 05:52:40 +03:00
28b11e6fed
refs: https://github.com/TryGhost/Toolbox/issues/440 New command to generate demo data, creates data for over 20 tables in Ghost, suitable for testing most features of the dashboard, as well as making guided product tours using newsletters, tiers, many posts and tags. Usage: `yarn start generate-data` Optionally, keep your existing posts / tags with: `yarn start generate-data --use-existing-tags --use-existing-posts`
25 lines
771 B
JavaScript
25 lines
771 B
JavaScript
const TableImporter = require('./base');
|
|
const {faker} = require('@faker-js/faker');
|
|
const {slugify} = require('@tryghost/string');
|
|
const {blogStartDate} = require('../utils/blog-info');
|
|
|
|
class BenefitsImporter extends TableImporter {
|
|
constructor(knex) {
|
|
super('benefits', knex);
|
|
}
|
|
|
|
generate() {
|
|
const name = faker.company.catchPhrase();
|
|
const sixMonthsLater = new Date(blogStartDate);
|
|
sixMonthsLater.setMonth(sixMonthsLater.getMonth() + 6);
|
|
return {
|
|
id: faker.database.mongodbObjectId(),
|
|
name: name,
|
|
slug: `${slugify(name)}-${faker.random.numeric(3)}`,
|
|
created_at: faker.date.between(blogStartDate, sixMonthsLater)
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = BenefitsImporter;
|