MCPcopy Index your code
hub / github.com/cloudgraphdev/cli / run

Method run

src/commands/load.ts:29–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 4

loadAllDataFunction · 0.90
healthCheckMethod · 0.80
pushMethod · 0.80
setSchemaMethod · 0.80

Tested by

no test coverage detected