/* * Copycat. Copyright (C) 2020 selfisekai and other contributors. * * This is free software, and you are welcome to redistribute it * under the GNU General Public License 3.0 or later; see the LICENSE file for details, * or, if the file is unavailable, visit . */ import path from 'path'; import { VendorManager, CopycatConfig, CopycatProfile } from './types'; import { getConfig, DEFAULT_CONFIG } from './utils'; export default class Copycat { vendorManagers: VendorManager[] = []; config: CopycatConfig = DEFAULT_CONFIG; public async initialize() { this.config = getConfig(); this.vendorManagers = await Promise.all( this.config.vendorConfigs .map( (profile) => [ require(path.join(__dirname, 'vendor', profile.vendor.type, 'vendormgr')).default, profile, ] as [any, CopycatProfile], ) .map(([VendorMgr, vendor]) => new VendorMgr(vendor.config) as VendorManager) .map((VendorMgr) => VendorMgr.initialize()), ); return this; } }