| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- // tslint:disable-next-line:no-reference
- /// <reference path="../core/typings.d.ts" />
- import { bootstrap, defaultConfig, mergeConfig } from '@vendure/core';
- import { populate } from '@vendure/core/cli';
- import { clearAllTables, populateCustomers } from '@vendure/testing';
- import path from 'path';
- import { initialData } from '../core/mock-data/data-sources/initial-data';
- import { devConfig } from './dev-config';
- // tslint:disable:no-console
- /**
- * A CLI script which populates the dev database with deterministic random data.
- */
- if (require.main === module) {
- // Running from command line
- const populateConfig = mergeConfig(
- defaultConfig,
- mergeConfig(devConfig, {
- authOptions: {
- tokenMethod: 'bearer',
- requireVerification: false,
- },
- importExportOptions: {
- importAssetsDir: path.join(__dirname, '../core/mock-data/assets'),
- },
- workerOptions: {
- runInMainProcess: true,
- },
- customFields: {},
- }),
- );
- clearAllTables(populateConfig, true)
- .then(() =>
- populate(
- () => bootstrap(populateConfig),
- initialData,
- path.join(__dirname, '../create/assets/products.csv'),
- ),
- )
- .then(async app => {
- console.log('populating customers...');
- await populateCustomers(10, populateConfig, true);
- return app.close();
- })
- .then(
- () => process.exit(0),
- err => {
- console.log(err);
- process.exit(1);
- },
- );
- }
|