mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +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`
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
const TableImporter = require('./base');
|
|
const {blogStartDate} = require('../utils/blog-info');
|
|
const {faker} = require('@faker-js/faker');
|
|
const {slugify} = require('@tryghost/string');
|
|
|
|
class NewslettersImporter extends TableImporter {
|
|
constructor(knex) {
|
|
super('newsletters', knex);
|
|
this.sortOrder = 0;
|
|
this.names = ['Occasional freebie', 'Regular premium'];
|
|
}
|
|
|
|
generate() {
|
|
const name = this.names.shift();
|
|
const sortOrder = this.sortOrder;
|
|
this.sortOrder = this.sortOrder + 1;
|
|
const weekAfter = new Date(blogStartDate);
|
|
weekAfter.setDate(weekAfter.getDate() + 7);
|
|
return {
|
|
id: faker.database.mongodbObjectId(),
|
|
uuid: faker.datatype.uuid(),
|
|
name: name,
|
|
slug: `${slugify(name)}-${faker.random.numeric(3)}`,
|
|
sender_reply_to: 'hello@example.com',
|
|
status: 'active',
|
|
subscribe_on_signup: faker.datatype.boolean(),
|
|
sort_order: sortOrder,
|
|
created_at: faker.date.between(blogStartDate, weekAfter)
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = NewslettersImporter;
|