Skip to content

Commit acfeb3c

Browse files
chore: use yargs-parser to parse both CLI and ENV
Earlier we had custom code to parse ENV variable and although we were using yargs-parser to parse CLI arguments, we were still using custom logic to validate the parsed keys. This commit removes the custom code entirely in favor of using yargs-parser to parse both CLI and ENV variables while also taking care of excluding unknown arguments. This helps remove a bunch of code that we did not needed in the first place. Additionally, it fixes one of the problems with positional argument parsing. Earlier we were considering a positional argument as connection specifier only if the deprecated flag `--connectionString` was also passed. Now we consider the positional argument on top priority, disregarding ENV variable, CLI arguments, etc. This commit also splits the UserConfig schema and creation of UserConfig for CLI entry point in two different files so that the UserConfig export on the library don't end up pulling yargs-parser along.
1 parent f7718f3 commit acfeb3c

33 files changed

+838
-821
lines changed

scripts/generateArguments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import { readFileSync, writeFileSync } from "fs";
1212
import { join, dirname } from "path";
1313
import { fileURLToPath } from "url";
14-
import { UserConfigSchema, configRegistry } from "../src/common/config.js";
14+
import { UserConfigSchema, configRegistry } from "../src/common/config/userConfig.js";
1515
import assert from "assert";
1616
import { execSync } from "child_process";
1717
import { OPTIONS } from "../src/common/config/argsParserOptions.js";

src/common/atlas/roles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { UserConfig } from "../config.js";
1+
import type { UserConfig } from "../config/userConfig.js";
22
import type { DatabaseUserRole } from "./openapi.js";
33

44
const readWriteRole: DatabaseUserRole = {

0 commit comments

Comments
 (0)