()
| 27 | static args = Command.args |
| 28 | |
| 29 | async run(): Promise<void> { |
| 30 | const { |
| 31 | argv, |
| 32 | // flags: { debug, dev: devMode }, |
| 33 | } = await this.parse(Load) |
| 34 | const { dataDir } = this.config |
| 35 | const storageEngine = await this.getStorageEngine() |
| 36 | const storageRunning = await storageEngine.healthCheck() |
| 37 | if (!storageRunning) { |
| 38 | this.logger.error( |
| 39 | `Storage engine check at ${storageEngine.host} FAILED canceling LOAD` |
| 40 | ) |
| 41 | this.exit() |
| 42 | } |
| 43 | // const opts: Opts = { logger: this.logger, debug, devMode } |
| 44 | let allProviders = argv |
| 45 | // if (!provider) { |
| 46 | // provider = await this.getProvider() |
| 47 | // } |
| 48 | |
| 49 | /** |
| 50 | * Handle 2 methods of scanning, either for explicitly passed providers OR |
| 51 | * try to scan for all providers found within the config file |
| 52 | * if we still have 0 providers, fail and exit. |
| 53 | */ |
| 54 | if (allProviders.length >= 1) { |
| 55 | this.logger.info( |
| 56 | `Loading data to Dgraph for providers: ${allProviders.join(' | ')}` |
| 57 | ) |
| 58 | } else { |
| 59 | this.logger.info('Searching config for initialized providers') |
| 60 | const config = this.getCGConfig() |
| 61 | allProviders = Object.keys(config).filter( |
| 62 | (val: string) => val !== 'cloudGraph' |
| 63 | ) |
| 64 | // TODO: keep this log? |
| 65 | this.logger.info( |
| 66 | `Found providers ${allProviders.join(' | ')} in cloud-graph config` |
| 67 | ) |
| 68 | if (allProviders.length === 0) { |
| 69 | this.logger.error( |
| 70 | 'Error, there are no providers configured and none were passed to load, try "cg init" to set some up!' |
| 71 | ) |
| 72 | this.exit() |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * loop through providers and attempt to scan each of them |
| 78 | */ |
| 79 | const schema: any[] = [] |
| 80 | for (const provider of allProviders) { |
| 81 | this.logger.info( |
| 82 | `Beginning ${chalk.italic.green('LOAD')} for ${provider}` |
| 83 | ) |
| 84 | const { client: providerClient, schemasMap: schemaMap } = |
| 85 | await this.getProviderClient(provider) |
| 86 | if (!providerClient) { |
nothing calls this directly
no test coverage detected