diff --git a/ghost/core/core/cli/generate-data.js b/ghost/core/core/cli/generate-data.js index cd0f3cebb5..d6ec116c55 100644 --- a/ghost/core/core/cli/generate-data.js +++ b/ghost/core/core/cli/generate-data.js @@ -10,6 +10,7 @@ module.exports = class DataGeneratorCommand extends Command { this.argument('--clear-database', {type: 'boolean', defaultValue: false, desc: 'Clear all entries in the database before importing'}); this.argument('--tables', {type: 'string', desc: 'Only import the specified list of tables, where quantities can be specified by appending a colon followed by the quantity for each table. Example: --tables=members:1000,posts,tags,members_login_events'}); this.argument('--with-default', {type: 'boolean', defaultValue: false, desc: 'Include default tables as well as those specified (simply override quantities)'}); + this.argument('--print-dependencies', {type: 'boolean', defaultValue: false, desc: 'Prints the dependency tree for the data generator and exits'}); } initializeContext(context) { @@ -51,7 +52,8 @@ module.exports = class DataGeneratorCommand extends Command { baseUrl: config.getSiteUrl(), clearDatabase: argv['clear-database'], tables, - withDefault: argv['with-default'] + withDefault: argv['with-default'], + printDependencies: argv['print-dependencies'] }); try { await dataGenerator.importData(); diff --git a/ghost/data-generator/lib/DataGenerator.js b/ghost/data-generator/lib/DataGenerator.js index f84c4ba98b..fcf387baea 100644 --- a/ghost/data-generator/lib/DataGenerator.js +++ b/ghost/data-generator/lib/DataGenerator.js @@ -18,6 +18,7 @@ class DataGenerator { baseDataPack = '', baseUrl, logger, + printDependencies, withDefault }) { this.knex = knex; @@ -28,6 +29,7 @@ class DataGenerator { this.baseUrl = baseUrl; this.logger = logger; this.withDefault = withDefault; + this.printDependencies = printDependencies; } sortTableList() { @@ -158,6 +160,14 @@ class DataGenerator { this.sortTableList(); + if (this.printDependencies) { + this.logger.info('Table dependencies:'); + for (const table of this.tableList) { + this.logger.info(`\t${table.name}: ${table.dependencies.join(', ')}`); + } + process.exit(0); + } + if (this.willClearData) { await this.clearData(transaction); }