kourou
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -22,3 +22,4 @@ import { flags } from '@oclif/command'; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} | ||
export default ApiKeyCreate; |
@@ -8,2 +8,10 @@ "use strict"; | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -34,3 +42,3 @@ const { args, flags: userFlags } = this.parse(ApiKeyCreate); | ||
} | ||
ApiKeyCreate.description = 'Creates a new API Key for an user'; | ||
ApiKeyCreate.description = 'Creates a new API Key for a user'; | ||
ApiKeyCreate.flags = Object.assign({ help: command_1.flags.help(), description: command_1.flags.string({ | ||
@@ -37,0 +45,0 @@ char: 'd', |
@@ -20,3 +20,4 @@ import { flags } from '@oclif/command'; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} | ||
export default ApiKeyDelete; |
@@ -8,2 +8,10 @@ "use strict"; | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -29,3 +37,3 @@ const { flags: userFlags, args } = this.parse(ApiKeyDelete); | ||
} | ||
ApiKeyDelete.description = 'Deletes a new API Key for an user'; | ||
ApiKeyDelete.description = 'Deletes an API key.'; | ||
ApiKeyDelete.flags = Object.assign({ help: command_1.flags.help(), id: command_1.flags.string({ | ||
@@ -32,0 +40,0 @@ description: 'API Key unique ID', |
@@ -20,3 +20,4 @@ import { flags } from '@oclif/command'; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} | ||
export default ApiKeySearch; |
@@ -8,2 +8,10 @@ "use strict"; | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -45,3 +53,3 @@ const { flags: userFlags, args } = this.parse(ApiKeySearch); | ||
} | ||
ApiKeySearch.description = 'List an user API Keys'; | ||
ApiKeySearch.description = 'Lists a user\'s API Keys.'; | ||
ApiKeySearch.flags = Object.assign({ help: command_1.flags.help(), filter: command_1.flags.string({ | ||
@@ -48,0 +56,0 @@ description: 'Filter to match the API Key descriptions', |
@@ -21,2 +21,3 @@ import { flags } from '@oclif/command'; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} |
@@ -7,3 +7,3 @@ "use strict"; | ||
const kuzzle_1 = require("../../support/kuzzle"); | ||
const dump_collection_1 = tslib_1.__importDefault(require("../../support/dump-collection")); | ||
const dump_collection_1 = require("../../support/dump-collection"); | ||
const fs = tslib_1.__importStar(require("fs")); | ||
@@ -13,2 +13,10 @@ const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -19,5 +27,6 @@ const { args, flags: userFlags } = this.parse(CollectionDump); | ||
await sdk.init(); | ||
this.log(`Dumping collection "${args.index}:${args.collection}" in ${path}/ ...`); | ||
this.log(chalk_1.default.green(`Dumping collection "${args.index}:${args.collection}" in ${path}/ ...`)); | ||
fs.mkdirSync(path, { recursive: true }); | ||
await dump_collection_1.default(sdk, args.index, args.collection, Number(userFlags['batch-size']), path); | ||
await dump_collection_1.dumpCollectionMappings(sdk, args.index, args.collection, path); | ||
await dump_collection_1.dumpCollectionData(sdk, args.index, args.collection, Number(userFlags['batch-size']), path); | ||
this.log(chalk_1.default.green(`[✔] Collection ${args.index}:${args.collection.name} dumped`)); | ||
@@ -29,6 +38,6 @@ } | ||
CollectionDump.flags = Object.assign({ help: command_1.flags.help({}), path: command_1.flags.string({ | ||
description: 'Dump directory (default: index name)', | ||
description: 'Dump root directory (default: index name)', | ||
}), 'batch-size': command_1.flags.string({ | ||
description: 'Maximum batch size (see limits.documentsFetchCount config)', | ||
default: '5000' | ||
default: '2000' | ||
}) }, kuzzle_1.kuzzleFlags); | ||
@@ -35,0 +44,0 @@ CollectionDump.args = [ |
@@ -15,2 +15,3 @@ import { flags } from '@oclif/command'; | ||
collection: flags.IOptionFlag<string | undefined>; | ||
'no-mappings': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>; | ||
}; | ||
@@ -23,2 +24,3 @@ static args: { | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} |
@@ -8,5 +8,13 @@ "use strict"; | ||
const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
const restore_collection_1 = tslib_1.__importDefault(require("../../support/restore-collection")); | ||
const restore_collection_1 = require("../../support/restore-collection"); | ||
class CollectionRestore extends common_1.Kommand { | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -20,3 +28,6 @@ const { args, flags: userFlags } = this.parse(CollectionRestore); | ||
try { | ||
await restore_collection_1.default(sdk, this.log.bind(this), Number(userFlags['batch-size']), args.path, index, collection); | ||
if (!userFlags['no-mappings']) { | ||
await restore_collection_1.restoreCollectionMappings(sdk, args.path, index, collection); | ||
} | ||
await restore_collection_1.restoreCollectionData(sdk, this.log.bind(this), Number(userFlags['batch-size']), args.path, index, collection); | ||
this.log(chalk_1.default.green(`[✔] Dump file ${args.path} imported`)); | ||
@@ -32,4 +43,4 @@ } | ||
CollectionRestore.flags = Object.assign({ help: command_1.flags.help({}), 'batch-size': command_1.flags.string({ | ||
description: 'Maximum batch size (see limits.documentsFetchCount config)', | ||
default: '5000' | ||
description: 'Maximum batch size (see limits.documentsWriteCount config)', | ||
default: '200' | ||
}), index: command_1.flags.string({ | ||
@@ -39,5 +50,7 @@ description: 'If set, override the index destination name', | ||
description: 'If set, override the collection destination name', | ||
}), 'no-mappings': command_1.flags.boolean({ | ||
description: 'Skip collection mappings' | ||
}) }, kuzzle_1.kuzzleFlags); | ||
CollectionRestore.args = [ | ||
{ name: 'path', description: 'Dump file path', required: true }, | ||
{ name: 'path', description: 'Dump directory path', required: true }, | ||
]; |
@@ -19,2 +19,3 @@ import { flags } from '@oclif/command'; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} |
@@ -8,2 +8,10 @@ "use strict"; | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -23,3 +31,3 @@ const { args, flags: userFlags } = this.parse(DocumentGet); | ||
exports.default = DocumentGet; | ||
DocumentGet.description = 'Get a document'; | ||
DocumentGet.description = 'Gets a document'; | ||
DocumentGet.flags = Object.assign({ help: command_1.flags.help() }, kuzzle_1.kuzzleFlags); | ||
@@ -26,0 +34,0 @@ DocumentGet.args = [ |
@@ -21,2 +21,3 @@ import { flags } from '@oclif/command'; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} |
@@ -7,7 +7,16 @@ "use strict"; | ||
const kuzzle_1 = require("../../support/kuzzle"); | ||
const dump_collection_1 = tslib_1.__importDefault(require("../../support/dump-collection")); | ||
const dump_collection_1 = require("../../support/dump-collection"); | ||
const fs = tslib_1.__importStar(require("fs")); | ||
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux")); | ||
const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
class IndexDump extends common_1.Kommand { | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -18,3 +27,3 @@ const { args, flags: userFlags } = this.parse(IndexDump); | ||
await sdk.init(); | ||
this.log(`Dumping index "${args.index}" in ${path}/ ...`); | ||
this.log(chalk_1.default.green(`Dumping index "${args.index}" in ${path}/ ...`)); | ||
fs.mkdirSync(path, { recursive: true }); | ||
@@ -24,6 +33,8 @@ const { collections } = await sdk.collection.list(args.index); | ||
if (collection.type !== 'realtime') { | ||
await dump_collection_1.default(sdk, args.index, collection.name, Number(userFlags['batch-size']), path); | ||
this.log(chalk_1.default.green(`[✔] Collection ${args.index}:${collection.name} dumped`)); | ||
await dump_collection_1.dumpCollectionMappings(sdk, args.index, collection.name, path); | ||
await dump_collection_1.dumpCollectionData(sdk, args.index, collection.name, Number(userFlags['batch-size']), path); | ||
cli_ux_1.default.action.stop(); | ||
} | ||
} | ||
this.log(chalk_1.default.green(`[✔] Index ${args.index} dumped`)); | ||
} | ||
@@ -37,3 +48,3 @@ } | ||
description: 'Maximum batch size (see limits.documentsFetchCount config)', | ||
default: '5000' | ||
default: '2000' | ||
}) }, kuzzle_1.kuzzleFlags); | ||
@@ -40,0 +51,0 @@ IndexDump.args = [ |
@@ -14,2 +14,3 @@ import { flags } from '@oclif/command'; | ||
index: flags.IOptionFlag<string | undefined>; | ||
'no-mappings': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>; | ||
}; | ||
@@ -22,2 +23,3 @@ static args: { | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
} |
@@ -9,5 +9,13 @@ "use strict"; | ||
const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
const restore_collection_1 = tslib_1.__importDefault(require("../../support/restore-collection")); | ||
const restore_collection_1 = require("../../support/restore-collection"); | ||
class IndexRestore extends common_1.Kommand { | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -24,11 +32,14 @@ const { args, flags: userFlags } = this.parse(IndexRestore); | ||
} | ||
const dumpFiles = fs.readdirSync(args.path).map(f => `${args.path}/${f}`); | ||
const dumpDirs = fs.readdirSync(args.path).map(f => `${args.path}/${f}`); | ||
try { | ||
for (const dumpFile of dumpFiles) { | ||
await restore_collection_1.default(sdk, this.log.bind(this), Number(userFlags['batch-size']), dumpFile, index); | ||
for (const dumpDir of dumpDirs) { | ||
if (!userFlags['no-mappings']) { | ||
await restore_collection_1.restoreCollectionMappings(sdk, dumpDir, index); | ||
} | ||
await restore_collection_1.restoreCollectionData(sdk, this.log.bind(this), Number(userFlags['batch-size']), dumpDir, index); | ||
if (index) { | ||
this.log(chalk_1.default.green(`[✔] Dump file ${dumpFile} imported in index ${index}`)); | ||
this.log(chalk_1.default.green(`[✔] Dump directory ${dumpDir} imported in index ${index}`)); | ||
} | ||
else { | ||
this.log(chalk_1.default.green(`[✔] Dump file ${dumpFile} imported`)); | ||
this.log(chalk_1.default.green(`[✔] Dump directory ${dumpDir} imported`)); | ||
} | ||
@@ -45,6 +56,8 @@ } | ||
IndexRestore.flags = Object.assign({ help: command_1.flags.help({}), 'batch-size': command_1.flags.string({ | ||
description: 'Maximum batch size (see limits.documentsFetchCount config)', | ||
default: '5000' | ||
description: 'Maximum batch size (see limits.documentsWriteCount config)', | ||
default: '200' | ||
}), index: command_1.flags.string({ | ||
description: 'If set, override the index destination name', | ||
}), 'no-mappings': command_1.flags.boolean({ | ||
description: 'Skip collections mappings' | ||
}) }, kuzzle_1.kuzzleFlags); | ||
@@ -51,0 +64,0 @@ IndexRestore.args = [ |
import { Kommand } from '../../common'; | ||
import { flags } from '@oclif/command'; | ||
export declare class InstanceLogs extends Kommand { | ||
static description: string; | ||
static flags: { | ||
@@ -9,4 +10,5 @@ instance: flags.IOptionFlag<string | undefined>; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
private showInstanceLogs; | ||
private getInstancesList; | ||
} |
@@ -10,2 +10,10 @@ "use strict"; | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.warn(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
@@ -58,2 +66,3 @@ const { flags } = this.parse(InstanceLogs); | ||
exports.InstanceLogs = InstanceLogs; | ||
InstanceLogs.description = 'Displays the logs of a running Kuzzle'; | ||
InstanceLogs.flags = { | ||
@@ -60,0 +69,0 @@ instance: command_1.flags.string({ |
@@ -14,2 +14,3 @@ import { flags } from '@oclif/command'; | ||
run(): Promise<void>; | ||
runSafe(): Promise<void>; | ||
checkPrerequisites(): Promise<boolean>; | ||
@@ -16,0 +17,0 @@ private generateDocoFile; |
@@ -92,6 +92,14 @@ "use strict"; | ||
async run() { | ||
try { | ||
await this.runSafe(); | ||
} | ||
catch (error) { | ||
this.logError(error); | ||
} | ||
} | ||
async runSafe() { | ||
this.printCommand(); | ||
const { flags: userFlags } = this.parse(InstanceSpawn); | ||
const portIndex = await this.findAvailablePort(); | ||
const dockerComposeFileName = `/tmp/kuzzle-stack-${portIndex}.yml`; | ||
const docoFilename = `/tmp/kuzzle-stack-${portIndex}.yml`; | ||
const successfullCheck = userFlags.check ? | ||
@@ -106,5 +114,7 @@ await this.checkPrerequisites() : | ||
} | ||
this.log(chalk_1.default.grey(`\nWriting docker-compose file to ${dockerComposeFileName}...`)); | ||
fs_1.writeFileSync(dockerComposeFileName, this.generateDocoFile(userFlags.version, portIndex)); | ||
const doco = child_process_1.spawn('docker-compose', ['-f', dockerComposeFileName, '-p', `stack-${portIndex}`, 'up', '-d']); | ||
this.log(chalk_1.default.grey(`\nWriting docker-compose file to ${docoFilename}...`)); | ||
fs_1.writeFileSync(docoFilename, this.generateDocoFile(userFlags.version, portIndex)); | ||
// clean up | ||
await execa_1.default('docker-compose', ['-f', docoFilename, '-p', `stack-${portIndex}`, 'down']); | ||
const doco = child_process_1.spawn('docker-compose', ['-f', docoFilename, '-p', `stack-${portIndex}`, 'up', '-d']); | ||
cli_ux_1.default.action.start(` ${node_emoji_1.default.get('rocket')} Kuzzle version ${userFlags.version} is launching`, undefined, { | ||
@@ -118,3 +128,3 @@ stdout: true, | ||
this.log(chalk_1.default.grey('To watch the logs, run')); | ||
this.log(chalk_1.default.grey(` docker-compose -f ${dockerComposeFileName} -p stack-${portIndex} logs -f\n`)); | ||
this.log(chalk_1.default.grey(` docker-compose -f ${docoFilename} -p stack-${portIndex} logs -f\n`)); | ||
this.log(` Kuzzle port: ${7512 + portIndex}`); | ||
@@ -128,3 +138,3 @@ this.log(` MQTT port: ${1883 + portIndex}`); | ||
this.log(chalk_1.default.grey('If you want to investigate the problem, try running')); | ||
this.log(chalk_1.default.grey(` docker-compose -f ${dockerComposeFileName} -p stack-${portIndex} up\n`)); | ||
this.log(chalk_1.default.grey(` docker-compose -f ${docoFilename} -p stack-${portIndex} up\n`)); | ||
throw new Error('docker-compose exited witn non-zero status'); | ||
@@ -131,0 +141,0 @@ } |
@@ -27,3 +27,3 @@ "use strict"; | ||
exports.VaultAdd = VaultAdd; | ||
VaultAdd.description = 'Add an encrypted key to a secrets file'; | ||
VaultAdd.description = 'Adds an encrypted key to a secrets file'; | ||
VaultAdd.flags = { | ||
@@ -30,0 +30,0 @@ 'vault-key': command_1.flags.string({ |
@@ -30,3 +30,3 @@ "use strict"; | ||
exports.VaultEncrypt = VaultEncrypt; | ||
VaultEncrypt.description = 'Encrypt an entire file'; | ||
VaultEncrypt.description = 'Encrypts an entire file.'; | ||
VaultEncrypt.flags = { | ||
@@ -33,0 +33,0 @@ force: command_1.flags.boolean({ |
@@ -28,3 +28,3 @@ "use strict"; | ||
exports.VaultShow = VaultShow; | ||
VaultShow.description = 'Display an encrypted key on stdout'; | ||
VaultShow.description = 'Prints an encrypted key.'; | ||
VaultShow.flags = { | ||
@@ -31,0 +31,0 @@ 'vault-key': command_1.flags.string({ |
@@ -1,2 +0,2 @@ | ||
declare function dumpCollection(sdk: any, index: string, collection: string, batchSize: number, path: string): Promise<unknown>; | ||
export default dumpCollection; | ||
export declare function dumpCollectionData(sdk: any, index: string, collection: string, batchSize: number, path: string): Promise<unknown>; | ||
export declare function dumpCollectionMappings(sdk: any, index: string, collection: string, path: string): Promise<void>; |
@@ -5,6 +5,8 @@ "use strict"; | ||
const fs = tslib_1.__importStar(require("fs")); | ||
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux")); | ||
// tslint:disable-next-line | ||
const ndjson = require('ndjson'); | ||
async function dumpCollection(sdk, index, collection, batchSize, path) { | ||
const filename = `${path}/collection-${collection}.jsonl`; | ||
async function dumpCollectionData(sdk, index, collection, batchSize, path) { | ||
const collectionDir = `${path}/${collection}`; | ||
const filename = `${collectionDir}/documents.jsonl`; | ||
const writeStream = fs.createWriteStream(filename); | ||
@@ -21,2 +23,3 @@ const waitWrite = new Promise(resolve => writeStream.on('finish', resolve)); | ||
ndjsonStream.on('data', (line) => writeStream.write(line)); | ||
fs.mkdirSync(collectionDir, { recursive: true }); | ||
await new Promise(resolve => { | ||
@@ -31,5 +34,8 @@ if (ndjsonStream.write({ index: index, collection })) { | ||
let results = await sdk.document.search(index, collection, {}, options); | ||
const progressBar = cli_ux_1.default.progress({ | ||
format: `Dumping ${collection} |{bar}| {percentage}% || {value}/{total} documents` | ||
}); | ||
progressBar.start(results.total, 0); | ||
do { | ||
process.stdout.write(` ${results.fetched}/${results.total} documents dumped`); | ||
process.stdout.write('\r'); | ||
progressBar.update(results.fetched); | ||
for (const hit of results.hits) { | ||
@@ -45,2 +51,3 @@ const document = { | ||
} while ((results = await results.next())); | ||
progressBar.stop(); | ||
ndjsonStream.end(); | ||
@@ -50,2 +57,15 @@ writeStream.end(); | ||
} | ||
exports.default = dumpCollection; | ||
exports.dumpCollectionData = dumpCollectionData; | ||
async function dumpCollectionMappings(sdk, index, collection, path) { | ||
const collectionDir = `${path}/${collection}`; | ||
const filename = `${collectionDir}/mappings.json`; | ||
fs.mkdirSync(collectionDir, { recursive: true }); | ||
const mappings = await sdk.collection.getMapping(index, collection); | ||
const content = { | ||
[index]: { | ||
[collection]: mappings | ||
} | ||
}; | ||
fs.writeFileSync(filename, JSON.stringify(content, null, 2)); | ||
} | ||
exports.dumpCollectionMappings = dumpCollectionMappings; |
@@ -21,2 +21,3 @@ import { flags } from '@oclif/command'; | ||
get collection(): any; | ||
get index(): any; | ||
} |
@@ -22,3 +22,3 @@ "use strict"; | ||
username: command_1.flags.string({ | ||
description: 'Kuzzle user', | ||
description: 'Kuzzle username (local strategy)', | ||
default: process.env.KUZZLE_USERNAME || 'anonymous', | ||
@@ -61,3 +61,6 @@ }), | ||
} | ||
get index() { | ||
return this.sdk.index; | ||
} | ||
} | ||
exports.KuzzleSDK = KuzzleSDK; |
@@ -1,2 +0,20 @@ | ||
declare function restoreCollection(sdk: any, log: any, batchSize: number, dumpFile: string, index?: string, collection?: string): Promise<unknown>; | ||
export default restoreCollection; | ||
export declare function restoreCollectionData(sdk: any, log: any, batchSize: number, dumpDir: string, index?: string, collection?: string): Promise<unknown>; | ||
/** | ||
* Imports mappings from a collection mappings dump | ||
* Expected format: | ||
* { | ||
* index: { | ||
* collection: { | ||
* // mappings | ||
* } | ||
* } | ||
* } | ||
* | ||
* @param sdk - Kuzzle SDK instance | ||
* @param dumpDir - Path to the collection dump dir | ||
* @param index - Override index name | ||
* @param collection - Override collection name | ||
* | ||
* @returns {Promise} | ||
*/ | ||
export declare function restoreCollectionMappings(sdk: any, dumpDir: string, index?: string, collection?: string): Promise<any>; |
@@ -22,6 +22,7 @@ "use strict"; | ||
log(chalk_1.default.red(error.message)); | ||
throw error; | ||
} | ||
throw error; | ||
} | ||
function restoreCollection(sdk, log, batchSize, dumpFile, index, collection) { | ||
async function restoreCollectionData(sdk, log, batchSize, dumpDir, index, collection) { | ||
const dumpFile = `${dumpDir}/documents.jsonl`; | ||
const mWriteRequest = { | ||
@@ -36,3 +37,3 @@ controller: 'bulk', | ||
}; | ||
return new Promise(resolve => { | ||
return new Promise((resolve, reject) => { | ||
let total = 0; | ||
@@ -50,12 +51,19 @@ let headerSkipped = false; | ||
readStream.pause(); | ||
sdk.query(mWriteRequest) | ||
.catch((error) => { | ||
handleError(log, dumpFile, error); | ||
readStream.resume(); | ||
}) | ||
sdk | ||
.query(mWriteRequest) | ||
.then(() => { | ||
total += mWriteRequest.body.documents.length; | ||
process.stdout.write(` ${total} documents handled`); | ||
process.stdout.write(` ${total} documents imported`); | ||
process.stdout.write('\r'); | ||
readStream.resume(); | ||
}) | ||
.catch((error) => { | ||
try { | ||
handleError(log, dumpFile, error); | ||
readStream.resume(); | ||
} | ||
catch (error) { | ||
readStream.end(); | ||
reject(error); | ||
} | ||
}); | ||
@@ -73,7 +81,15 @@ } | ||
mWriteRequest.body.documents = documents; | ||
sdk.query(mWriteRequest) | ||
.catch((error) => handleError(log, dumpFile, error)) | ||
sdk | ||
.query(mWriteRequest) | ||
.catch((error) => { | ||
try { | ||
handleError(log, dumpFile, error); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}) | ||
.then(() => { | ||
total += mWriteRequest.body.documents.length; | ||
process.stdout.write(` ${total} documents handled`); | ||
process.stdout.write(` ${total} documents imported`); | ||
process.stdout.write('\r'); | ||
@@ -89,2 +105,33 @@ resolve(); | ||
} | ||
exports.default = restoreCollection; | ||
exports.restoreCollectionData = restoreCollectionData; | ||
/** | ||
* Imports mappings from a collection mappings dump | ||
* Expected format: | ||
* { | ||
* index: { | ||
* collection: { | ||
* // mappings | ||
* } | ||
* } | ||
* } | ||
* | ||
* @param sdk - Kuzzle SDK instance | ||
* @param dumpDir - Path to the collection dump dir | ||
* @param index - Override index name | ||
* @param collection - Override collection name | ||
* | ||
* @returns {Promise} | ||
*/ | ||
async function restoreCollectionMappings(sdk, dumpDir, index, collection) { | ||
const dumpFile = `${dumpDir}/mappings.json`; | ||
const content = JSON.parse(fs.readFileSync(dumpFile, 'utf8')); | ||
const srcIndex = Object.keys(content)[0]; | ||
const srcCollection = Object.keys(content[srcIndex])[0]; | ||
const dstIndex = index || srcIndex; | ||
const dstCollection = collection || srcCollection; | ||
if (!await sdk.index.exists(dstIndex)) { | ||
await sdk.index.create(dstIndex); | ||
} | ||
return sdk.collection.create(dstIndex, dstCollection, content[srcIndex][srcCollection]); | ||
} | ||
exports.restoreCollectionMappings = restoreCollectionMappings; |
@@ -1,1 +0,1 @@ | ||
{"version":"0.6.0","commands":{"api-key:create":{"id":"api-key:create","description":"Creates a new API Key for an user","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"description":{"name":"description","type":"option","char":"d","description":"API Key description","required":true},"id":{"name":"id","type":"option","description":"API Key unique ID"},"expire":{"name":"expire","type":"option","description":"API Key validity","default":"-1"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"user","description":"User kuid","required":true}]},"api-key:delete":{"id":"api-key:delete","description":"Deletes a new API Key for an user","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"id":{"name":"id","type":"option","description":"API Key unique ID"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"user","description":"User kuid","required":true}]},"api-key:search":{"id":"api-key:search","description":"List an user API Keys","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"filter":{"name":"filter","type":"option","description":"Filter to match the API Key descriptions"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"user","description":"User kuid","required":true}]},"collection:dump":{"id":"collection:dump","description":"Dump an entire collection content (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory (default: index name)"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"5000"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true}]},"collection:restore":{"id":"collection:restore","description":"Restore the content of a previously dumped collection","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"5000"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"collection":{"name":"collection","type":"option","description":"If set, override the collection destination name"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"path","description":"Dump file path","required":true}]},"document:get":{"id":"document:get","description":"Get a document","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"id","description":"Document ID","required":true}]},"index:dump":{"id":"index:dump","description":"Dump an entire index content (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory (default: index name)"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"5000"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"index","description":"Index name","required":true}]},"index:restore":{"id":"index:restore","description":"Restore the content of a previously dumped index","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"5000"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle user","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"path","description":"Dump directory or file","required":true}]},"instance:logs":{"id":"instance:logs","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"instance":{"name":"instance","type":"option","char":"i","description":"Kuzzle instance name"},"follow":{"name":"follow","type":"boolean","char":"f","description":"Follow log output","allowNo":false}},"args":[]},"instance:spawn":{"id":"instance:spawn","description":"Spawn a new Kuzzle instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"check":{"name":"check","type":"boolean","description":"Check prerequisite before running Kuzzle","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"Core-version of the instance to spawn","default":"2"}},"args":[]},"vault:add":{"id":"vault:add","description":"Add an encrypted key to a secrets file","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to the key (lodash style)","required":true},{"name":"value","description":"Value to encrypt","required":true}]},"vault:encrypt":{"id":"vault:encrypt","description":"Encrypt an entire file","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: <file>.enc.json)"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"File containing unencrypted secrets","required":true}]},"vault:show":{"id":"vault:show","description":"Display an encrypted key on stdout","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to the key (lodash style)","required":true}]}}} | ||
{"version":"0.7.0","commands":{"query":{"id":"query","description":"Executes an API query","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"arg":{"name":"arg","type":"option","description":"Additional argument. Repeatable. (eg: \"--arg refresh:wait_for\")"},"body":{"name":"body","type":"option","description":"Request body in JSON format."},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"controller:action","description":"Controller and action (eg: \"server:now\")","required":true}]},"api-key:create":{"id":"api-key:create","description":"Creates a new API Key for a user","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"description":{"name":"description","type":"option","char":"d","description":"API Key description","required":true},"id":{"name":"id","type":"option","description":"API Key unique ID"},"expire":{"name":"expire","type":"option","description":"API Key validity","default":"-1"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"user","description":"User kuid","required":true}]},"api-key:delete":{"id":"api-key:delete","description":"Deletes an API key.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"id":{"name":"id","type":"option","description":"API Key unique ID"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"user","description":"User kuid","required":true}]},"api-key:search":{"id":"api-key:search","description":"Lists a user's API Keys.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"filter":{"name":"filter","type":"option","description":"Filter to match the API Key descriptions"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"user","description":"User kuid","required":true}]},"collection:dump":{"id":"collection:dump","description":"Dump an entire collection content (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump root directory (default: index name)"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true}]},"collection:restore":{"id":"collection:restore","description":"Restore the content of a previously dumped collection","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"collection":{"name":"collection","type":"option","description":"If set, override the collection destination name"},"no-mappings":{"name":"no-mappings","type":"boolean","description":"Skip collection mappings","allowNo":false},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"path","description":"Dump directory path","required":true}]},"document:get":{"id":"document:get","description":"Gets a document","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"id","description":"Document ID","required":true}]},"es:get":{"id":"es:get","description":"Gets a document from ES","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","char":"h","description":"Elasticsearch server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Elasticsearch server port","default":"9200"}},"args":[{"name":"index","description":"ES Index name","required":true},{"name":"id","description":"Document ID","required":true}]},"es:insert":{"id":"es:insert","description":"Inserts a document directly into ES (will replace if exists)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"body":{"name":"body","type":"option","description":"Document body in JSON","default":"{}"},"id":{"name":"id","type":"option","description":"Document ID"},"host":{"name":"host","type":"option","char":"h","description":"Elasticsearch server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Elasticsearch server port","default":"9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"index","description":"ES Index name","required":true}]},"es:list-index":{"id":"es:list-index","description":"Lists available ES indexes","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","char":"h","description":"Elasticsearch server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Elasticsearch server port","default":"9200"},"grep":{"name":"grep","type":"option","char":"g","description":"Match output with pattern"}},"args":[]},"index:dump":{"id":"index:dump","description":"Dump an entire index content (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory (default: index name)"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"index","description":"Index name","required":true}]},"index:restore":{"id":"index:restore","description":"Restore the content of a previously dumped index","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"no-mappings":{"name":"no-mappings","type":"boolean","description":"Skip collections mappings","allowNo":false},"host":{"name":"host","type":"option","char":"h","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","char":"p","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"}},"args":[{"name":"path","description":"Dump directory or file","required":true}]},"instance:logs":{"id":"instance:logs","description":"Displays the logs of a running Kuzzle","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"instance":{"name":"instance","type":"option","char":"i","description":"Kuzzle instance name"},"follow":{"name":"follow","type":"boolean","char":"f","description":"Follow log output","allowNo":false}},"args":[]},"instance:spawn":{"id":"instance:spawn","description":"Spawn a new Kuzzle instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"check":{"name":"check","type":"boolean","description":"Check prerequisite before running Kuzzle","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"Core-version of the instance to spawn","default":"2"}},"args":[]},"vault:add":{"id":"vault:add","description":"Adds an encrypted key to a secrets file","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to the key (lodash style)","required":true},{"name":"value","description":"Value to encrypt","required":true}]},"vault:encrypt":{"id":"vault:encrypt","description":"Encrypts an entire file.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: <file>.enc.json)"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"File containing unencrypted secrets","required":true}]},"vault:show":{"id":"vault:show","description":"Prints an encrypted key.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to the key (lodash style)","required":true}]}}} |
{ | ||
"name": "kourou", | ||
"description": "The CLI that helps you manage your Kuzzle instances", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"author": "The Kuzzle Team <support@kuzzle.io>", | ||
@@ -11,2 +11,3 @@ "bin": { | ||
"dependencies": { | ||
"@elastic/elasticsearch": "^7.6.0", | ||
"@oclif/command": "^1.5.19", | ||
@@ -13,0 +14,0 @@ "@oclif/config": "^1.13.3", |
160
README.md
@@ -27,3 +27,3 @@ # kourou | ||
$ kourou (-v|--version|version) | ||
kourou/0.6.0 linux-x64 node-v12.15.0 | ||
kourou/0.7.0 linux-x64 node-v12.16.0 | ||
$ kourou --help [COMMAND] | ||
@@ -67,2 +67,5 @@ USAGE | ||
* [`kourou document:get INDEX COLLECTION ID`](#kourou-documentget-index-collection-id) | ||
* [`kourou es:get INDEX ID`](#kourou-esget-index-id) | ||
* [`kourou es:insert INDEX`](#kourou-esinsert-index) | ||
* [`kourou es:list-index`](#kourou-eslist-index) | ||
* [`kourou help [COMMAND]`](#kourou-help-command) | ||
@@ -73,2 +76,3 @@ * [`kourou index:dump INDEX`](#kourou-indexdump-index) | ||
* [`kourou instance:spawn`](#kourou-instancespawn) | ||
* [`kourou query CONTROLLER:ACTION`](#kourou-query-controlleraction) | ||
* [`kourou vault:add SECRETS-FILE KEY VALUE`](#kourou-vaultadd-secrets-file-key-value) | ||
@@ -80,3 +84,3 @@ * [`kourou vault:encrypt FILE`](#kourou-vaultencrypt-file) | ||
Creates a new API Key for an user | ||
Creates a new API Key for a user | ||
@@ -99,10 +103,10 @@ ``` | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/api-key/create.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/api-key/create.ts)_ | ||
_See code: [src/commands/api-key/create.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/api-key/create.ts)_ | ||
## `kourou api-key:delete USER` | ||
Deletes a new API Key for an user | ||
Deletes an API key. | ||
@@ -123,10 +127,10 @@ ``` | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/api-key/delete.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/api-key/delete.ts)_ | ||
_See code: [src/commands/api-key/delete.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/api-key/delete.ts)_ | ||
## `kourou api-key:search USER` | ||
List an user API Keys | ||
Lists a user's API Keys. | ||
@@ -147,6 +151,6 @@ ``` | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/api-key/search.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/api-key/search.ts)_ | ||
_See code: [src/commands/api-key/search.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/api-key/search.ts)_ | ||
@@ -168,11 +172,11 @@ ## `kourou collection:dump INDEX COLLECTION` | ||
-p, --port=port [default: 7512] Kuzzle server port | ||
--batch-size=batch-size [default: 5000] Maximum batch size (see limits.documentsFetchCount config) | ||
--batch-size=batch-size [default: 2000] Maximum batch size (see limits.documentsFetchCount config) | ||
--help show CLI help | ||
--password=password Kuzzle user password | ||
--path=path Dump directory (default: index name) | ||
--path=path Dump root directory (default: index name) | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/collection/dump.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/collection/dump.ts)_ | ||
_See code: [src/commands/collection/dump.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/collection/dump.ts)_ | ||
@@ -188,3 +192,3 @@ ## `kourou collection:restore PATH` | ||
ARGUMENTS | ||
PATH Dump file path | ||
PATH Dump directory path | ||
@@ -194,16 +198,17 @@ OPTIONS | ||
-p, --port=port [default: 7512] Kuzzle server port | ||
--batch-size=batch-size [default: 5000] Maximum batch size (see limits.documentsFetchCount config) | ||
--batch-size=batch-size [default: 200] Maximum batch size (see limits.documentsWriteCount config) | ||
--collection=collection If set, override the collection destination name | ||
--help show CLI help | ||
--index=index If set, override the index destination name | ||
--no-mappings Skip collection mappings | ||
--password=password Kuzzle user password | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/collection/restore.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/collection/restore.ts)_ | ||
_See code: [src/commands/collection/restore.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/collection/restore.ts)_ | ||
## `kourou document:get INDEX COLLECTION ID` | ||
Get a document | ||
Gets a document | ||
@@ -225,7 +230,65 @@ ``` | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/document/get.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/document/get.ts)_ | ||
_See code: [src/commands/document/get.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/document/get.ts)_ | ||
## `kourou es:get INDEX ID` | ||
Gets a document from ES | ||
``` | ||
USAGE | ||
$ kourou es:get INDEX ID | ||
ARGUMENTS | ||
INDEX ES Index name | ||
ID Document ID | ||
OPTIONS | ||
-h, --host=host [default: localhost] Elasticsearch server host | ||
-p, --port=port [default: 9200] Elasticsearch server port | ||
--help show CLI help | ||
``` | ||
_See code: [src/commands/es/get.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/es/get.ts)_ | ||
## `kourou es:insert INDEX` | ||
Inserts a document directly into ES (will replace if exists) | ||
``` | ||
USAGE | ||
$ kourou es:insert INDEX | ||
ARGUMENTS | ||
INDEX ES Index name | ||
OPTIONS | ||
-h, --host=host [default: localhost] Elasticsearch server host | ||
-p, --port=port [default: 9200] Elasticsearch server port | ||
--body=body [default: {}] Document body in JSON | ||
--help show CLI help | ||
--id=id Document ID | ||
``` | ||
_See code: [src/commands/es/insert.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/es/insert.ts)_ | ||
## `kourou es:list-index` | ||
Lists available ES indexes | ||
``` | ||
USAGE | ||
$ kourou es:list-index | ||
OPTIONS | ||
-g, --grep=grep Match output with pattern | ||
-h, --host=host [default: localhost] Elasticsearch server host | ||
-p, --port=port [default: 9200] Elasticsearch server port | ||
--help show CLI help | ||
``` | ||
_See code: [src/commands/es/list-index.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/es/list-index.ts)_ | ||
## `kourou help [COMMAND]` | ||
@@ -262,3 +325,3 @@ | ||
-p, --port=port [default: 7512] Kuzzle server port | ||
--batch-size=batch-size [default: 5000] Maximum batch size (see limits.documentsFetchCount config) | ||
--batch-size=batch-size [default: 2000] Maximum batch size (see limits.documentsFetchCount config) | ||
--help show CLI help | ||
@@ -268,6 +331,6 @@ --password=password Kuzzle user password | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/index/dump.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/index/dump.ts)_ | ||
_See code: [src/commands/index/dump.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/index/dump.ts)_ | ||
@@ -288,14 +351,17 @@ ## `kourou index:restore PATH` | ||
-p, --port=port [default: 7512] Kuzzle server port | ||
--batch-size=batch-size [default: 5000] Maximum batch size (see limits.documentsFetchCount config) | ||
--batch-size=batch-size [default: 200] Maximum batch size (see limits.documentsWriteCount config) | ||
--help show CLI help | ||
--index=index If set, override the index destination name | ||
--no-mappings Skip collections mappings | ||
--password=password Kuzzle user password | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle user | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/index/restore.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/index/restore.ts)_ | ||
_See code: [src/commands/index/restore.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/index/restore.ts)_ | ||
## `kourou instance:logs` | ||
Displays the logs of a running Kuzzle | ||
``` | ||
@@ -310,3 +376,3 @@ USAGE | ||
_See code: [src/commands/instance/logs.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/instance/logs.ts)_ | ||
_See code: [src/commands/instance/logs.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/instance/logs.ts)_ | ||
@@ -327,7 +393,31 @@ ## `kourou instance:spawn` | ||
_See code: [src/commands/instance/spawn.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/instance/spawn.ts)_ | ||
_See code: [src/commands/instance/spawn.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/instance/spawn.ts)_ | ||
## `kourou query CONTROLLER:ACTION` | ||
Executes an API query | ||
``` | ||
USAGE | ||
$ kourou query CONTROLLER:ACTION | ||
ARGUMENTS | ||
CONTROLLER:ACTION Controller and action (eg: "server:now") | ||
OPTIONS | ||
-h, --host=host [default: localhost] Kuzzle server host | ||
-p, --port=port [default: 7512] Kuzzle server port | ||
--arg=arg Additional argument. Repeatable. (eg: "--arg refresh:wait_for") | ||
--body=body Request body in JSON format. | ||
--help show CLI help | ||
--password=password Kuzzle user password | ||
--ssl Use SSL to connect to Kuzzle | ||
--username=username [default: anonymous] Kuzzle username (local strategy) | ||
``` | ||
_See code: [src/commands/query.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/query.ts)_ | ||
## `kourou vault:add SECRETS-FILE KEY VALUE` | ||
Add an encrypted key to a secrets file | ||
Adds an encrypted key to a secrets file | ||
@@ -347,7 +437,7 @@ ``` | ||
_See code: [src/commands/vault/add.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/vault/add.ts)_ | ||
_See code: [src/commands/vault/add.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/vault/add.ts)_ | ||
## `kourou vault:encrypt FILE` | ||
Encrypt an entire file | ||
Encrypts an entire file. | ||
@@ -367,7 +457,7 @@ ``` | ||
_See code: [src/commands/vault/encrypt.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/vault/encrypt.ts)_ | ||
_See code: [src/commands/vault/encrypt.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/vault/encrypt.ts)_ | ||
## `kourou vault:show SECRETS-FILE KEY` | ||
Display an encrypted key on stdout | ||
Prints an encrypted key. | ||
@@ -386,3 +476,3 @@ ``` | ||
_See code: [src/commands/vault/show.ts](https://github.com/kuzzleio/kourou/blob/v0.6.0/src/commands/vault/show.ts)_ | ||
_See code: [src/commands/vault/show.ts](https://github.com/kuzzleio/kourou/blob/v0.7.0/src/commands/vault/show.ts)_ | ||
<!-- commandsstop --> | ||
@@ -389,0 +479,0 @@ |
93783
49
1719
464
16
21
+ Added@elastic/elasticsearch@7.17.13(transitive)
+ Addedhpagent@0.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addedsecure-json-parse@2.7.0(transitive)