forked from kuzzleio/kourou
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport.ts
33 lines (25 loc) · 850 Bytes
/
import.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { flags } from '@oclif/command'
import fs from 'fs'
import { Kommand } from '../../common'
import { kuzzleFlags } from '../../support/kuzzle'
import { restoreProfiles } from '../../support/restore-securities'
export default class ProfileImport extends Kommand {
static description = 'Imports profiles'
static flags = {
help: flags.help({}),
...kuzzleFlags,
protocol: flags.string({
description: 'Kuzzle protocol (http or websocket)',
default: 'ws',
}),
}
static args = [
{ name: 'path', description: 'Dump file', required: true },
]
async runSafe() {
this.logInfo(`Importing profiles from ${this.args.path} ...`)
const dump = JSON.parse(fs.readFileSync(this.args.path, 'utf-8'))
const count = await restoreProfiles(this, dump)
this.logOk(`${count} profiles restored`)
}
}