mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor(cli): update config command (#2176)
This commit is contained in:
parent
7e32a587c8
commit
4d873cf6a3
2 changed files with 16 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
import { logtoConfigGuards, LogtoConfigKey, logtoConfigKeys } from '@logto/schemas';
|
||||
import { deduplicate } from '@silverhand/essentials';
|
||||
import { deduplicate, noop } from '@silverhand/essentials';
|
||||
import chalk from 'chalk';
|
||||
import { CommandModule } from 'yargs';
|
||||
|
||||
|
@ -28,8 +28,8 @@ const validateKeys: ValidateKeysFunction = (keys) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const getConfig: CommandModule<unknown, { key: string; keys: string[] }> = {
|
||||
command: 'get-config <key> [keys...]',
|
||||
const getConfig: CommandModule<unknown, { key: string; keys: string[] }> = {
|
||||
command: 'get <key> [keys...]',
|
||||
describe: 'Get config value(s) of the given key(s) in Logto database',
|
||||
builder: (yargs) =>
|
||||
yargs
|
||||
|
@ -68,8 +68,8 @@ export const getConfig: CommandModule<unknown, { key: string; keys: string[] }>
|
|||
},
|
||||
};
|
||||
|
||||
export const setConfig: CommandModule<unknown, { key: string; value: string }> = {
|
||||
command: 'set-config <key> <value>',
|
||||
const setConfig: CommandModule<unknown, { key: string; value: string }> = {
|
||||
command: 'set <key> <value>',
|
||||
describe: 'Set config value of the given key in Logto database',
|
||||
builder: (yargs) =>
|
||||
yargs
|
||||
|
@ -95,3 +95,12 @@ export const setConfig: CommandModule<unknown, { key: string; value: string }> =
|
|||
log.info(`Update ${chalk.green(key)} succeeded`);
|
||||
},
|
||||
};
|
||||
|
||||
const config: CommandModule = {
|
||||
command: ['config', 'configs'],
|
||||
describe: 'Commands for Logto database config',
|
||||
builder: (yargs) => yargs.command(getConfig).command(setConfig).demandCommand(1),
|
||||
handler: noop,
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -2,14 +2,13 @@ import { noop } from '@silverhand/essentials';
|
|||
import { CommandModule } from 'yargs';
|
||||
|
||||
import alteration from './alteration';
|
||||
import { getConfig, setConfig } from './config';
|
||||
import config from './config';
|
||||
import seed from './seed';
|
||||
|
||||
const database: CommandModule = {
|
||||
command: ['database', 'db'],
|
||||
describe: 'Commands for Logto database',
|
||||
builder: (yargs) =>
|
||||
yargs.command(getConfig).command(setConfig).command(seed).command(alteration).demandCommand(1),
|
||||
builder: (yargs) => yargs.command(config).command(seed).command(alteration).demandCommand(1),
|
||||
handler: noop,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue