generate-deep-collections.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { CollectionDefinition, InitialData } from '@vendure/core';
  2. import fs from 'fs';
  3. import path from 'path';
  4. /**
  5. * This script generates lots of Collections, nested 3 levels deep. It is useful for testing
  6. * scenarios where we need to work with a large amount of Collections.
  7. */
  8. const collections: CollectionDefinition[] = [];
  9. for (let i = 1; i <= 20; i++) {
  10. const IName = `Collection ${i}`;
  11. collections.push({
  12. name: IName,
  13. filters: [],
  14. });
  15. for (let j = 1; j <= 5; j++) {
  16. const JName = `Collection ${i}-${j}`;
  17. collections.push({
  18. name: JName,
  19. filters: [],
  20. parentName: IName,
  21. });
  22. for (let k = 1; k <= 3; k++) {
  23. const KName = `Collection ${i}-${j}-${k}`;
  24. collections.push({
  25. name: KName,
  26. filters: [],
  27. parentName: JName,
  28. });
  29. }
  30. }
  31. }
  32. fs.writeFileSync(path.join(__dirname, 'collections.json'), JSON.stringify(collections, null, 2), 'utf-8');