diff --git a/packages/dev-server/scripts/generate-deep-collections.ts b/packages/dev-server/scripts/generate-deep-collections.ts new file mode 100644 index 0000000000..7ca28a3dfc --- /dev/null +++ b/packages/dev-server/scripts/generate-deep-collections.ts @@ -0,0 +1,35 @@ +import { CollectionDefinition, InitialData } from '@vendure/core'; +import fs from 'fs'; +import path from 'path'; + +/** + * This script generates lots of Collections, nested 3 levels deep. It is useful for testing + * scenarios where we need to work with a large amount of Collections. + */ +const collections: CollectionDefinition[] = []; + +for (let i = 1; i <= 20; i++) { + const IName = `Collection ${i}`; + collections.push({ + name: IName, + filters: [], + }); + for (let j = 1; j <= 5; j++) { + const JName = `Collection ${i}-${j}`; + collections.push({ + name: JName, + filters: [], + parentName: IName, + }); + for (let k = 1; k <= 3; k++) { + const KName = `Collection ${i}-${j}-${k}`; + collections.push({ + name: KName, + filters: [], + parentName: JName, + }); + } + } +} + +fs.writeFileSync(path.join(__dirname, 'collections.json'), JSON.stringify(collections, null, 2), 'utf-8');