mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -05:00
38 lines
1,002 B
TypeScript
38 lines
1,002 B
TypeScript
import chalk from 'chalk';
|
|
import dotenv from 'dotenv';
|
|
import yargs from 'yargs';
|
|
import { hideBin } from 'yargs/helpers';
|
|
|
|
import tunnel from './commands/index.js';
|
|
import { packageJson } from './package-json.js';
|
|
import { consoleLog } from './utils.js';
|
|
|
|
void yargs(hideBin(process.argv))
|
|
.version(false)
|
|
.option('env', {
|
|
alias: ['e', 'env-file'],
|
|
describe: 'The path to your `.env` file',
|
|
type: 'string',
|
|
})
|
|
.option('version', {
|
|
alias: 'v',
|
|
describe: 'Print CLI version',
|
|
type: 'boolean',
|
|
})
|
|
.middleware(({ env }) => {
|
|
dotenv.config({ path: env });
|
|
})
|
|
.middleware(({ version }) => {
|
|
if (version) {
|
|
consoleLog.plain(packageJson.name + ' v' + packageJson.version);
|
|
// eslint-disable-next-line unicorn/no-process-exit
|
|
process.exit(0);
|
|
}
|
|
}, true)
|
|
.command(tunnel)
|
|
.showHelpOnFail(false, `Specify ${chalk.green('--help')} for available options`)
|
|
.strict()
|
|
.parserConfiguration({
|
|
'dot-notation': false,
|
|
})
|
|
.parse();
|