@alcyone-labs/arg-parser 2.12.0 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/config/ConfigurationManager.d.ts +1 -1
- package/dist/config/ConfigurationManager.d.ts.map +1 -1
- package/dist/core/ArgParserBase.d.ts.map +1 -1
- package/dist/index.cjs +126 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.min.mjs +1536 -1459
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +126 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ A modern, type-safe command line argument parser with built-in MCP (Model Contex
|
|
|
79
79
|
- [Typical Errors](#typical-errors)
|
|
80
80
|
- [System Flags & Configuration](#system-flags--configuration)
|
|
81
81
|
- [Changelog](#changelog)
|
|
82
|
+
- [v2.12.2](#v2122)
|
|
82
83
|
- [v2.12.0](#v2120)
|
|
83
84
|
- [v2.11.0](#v2110)
|
|
84
85
|
- [v2.10.3](#v2103)
|
|
@@ -2302,6 +2303,16 @@ ArgParser includes built-in `--s-*` flags for development, debugging, and config
|
|
|
2302
2303
|
|
|
2303
2304
|
## Changelog
|
|
2304
2305
|
|
|
2306
|
+
### v2.12.2
|
|
2307
|
+
|
|
2308
|
+
**Fixes**
|
|
2309
|
+
|
|
2310
|
+
- Fix env config matching and improve working directory integration
|
|
2311
|
+
|
|
2312
|
+
Explicitly call dotenv.config when an env file is auto-discovered
|
|
2313
|
+
to populate process.env. This ensures flags with the 'env' property
|
|
2314
|
+
can bind values from the discovered file.
|
|
2315
|
+
|
|
2305
2316
|
### v2.12.0
|
|
2306
2317
|
|
|
2307
2318
|
- Switch back to official @modelcontextprotocol/sdk as it now supports Zod V4, this resolves a security issue from a dependency in MCP SDK @ 1.16.0 branch.
|
|
@@ -57,7 +57,7 @@ export declare class ConfigurationManager {
|
|
|
57
57
|
/**
|
|
58
58
|
* Merges environment configuration with command line arguments
|
|
59
59
|
*/
|
|
60
|
-
mergeEnvConfigWithArgs(envConfig: Record<string, any>, processArgs: string[]): string[];
|
|
60
|
+
mergeEnvConfigWithArgs(envConfig: Record<string, any>, processArgs: string[], parserChain?: any[]): string[];
|
|
61
61
|
/**
|
|
62
62
|
* Generates environment file format
|
|
63
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationManager.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGhE;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,iBAAiB,CAAM;gBAEnB,iBAAiB,EAAE,GAAG;IAOlC;;OAEG;IACI,0BAA0B,IAAI,MAAM;IAwB3C;;OAEG;IACI,mBAAmB,CACxB,WAAW,EAAE,MAAM,EAAE,EACrB,WAAW,EAAE,GAAG,EAAE,GACjB,OAAO;IA2BV;;OAEG;IACI,aAAa,CAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EAAE,EACtB,WAAW,EAAE,GAAG,EAAE,GACjB,IAAI;IAqEP;;OAEG;IACI,WAAW,CAChB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,GAAG,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA+CtB;;OAEG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA4BzD;;OAEG;IACI,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA8E1D;;;;;;OAMG;IACI,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAwBxD;;OAEG;IACI,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE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M,CAAC,MAAM,EAAE,GAAG,CAAC;IAU1D;;OAEG;IACI,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAqC1D;;OAEG;IACI,yBAAyB,CAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,WAAW,EAAE,GAAG,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAqDtB;;OAEG;IACI,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,GAAG,GAAG;IA4FnE;;OAEG;IACI,sBAAsB,CAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,WAAW,EAAE,MAAM,EAAE,EACrB,WAAW,CAAC,EAAE,GAAG,EAAE,GAClB,MAAM,EAAE;IA+DX;;OAEG;IACI,iBAAiB,CACtB,KAAK,EAAE,aAAa,EAAE,EACtB,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,GAC3B,MAAM;IA0BT;;OAEG;IACI,kBAAkB,CACvB,KAAK,EAAE,aAAa,EAAE,EACtB,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,GAC3B,MAAM;IAsCT;;OAEG;IACI,kBAAkB,CACvB,KAAK,EAAE,aAAa,EAAE,EACtB,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,GAC3B,MAAM;IAaT;;OAEG;IACI,kBAAkB,CACvB,KAAK,EAAE,aAAa,EAAE,EACtB,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,GAC3B,MAAM;IAsCT;;OAEG;IACH,OAAO,CAAC,aAAa;CAStB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgParserBase.d.ts","sourceRoot":"","sources":["../../src/core/ArgParserBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ArgParserBase.d.ts","sourceRoot":"","sources":["../../src/core/ArgParserBase.ts"],"names":[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Aa,GAAG,SAAS;IAI1D,eAAe,IAAI,MAAM,EAAE;IAU3B,kBAAkB,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC;IAqUzD;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAU/C;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQrC;;OAEG;IACH,eAAe,IAAI,iBAAiB,EAAE;IAItC;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAM3C;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQnC;;OAEG;IACH,aAAa,IAAI,eAAe,EAAE;IAIlC;;OAEG;IACH,WAAW,CACT,QAAQ,EAAE,CAAC,KAAK,EAAE;QAChB,IAAI,EAAE,aAAa,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,KAAK,IAAI,GACT,IAAI;IAKP;;OAEG;IACH,YAAY,CACV,QAAQ,EAAE,CAAC,KAAK,EAAE;QAChB,IAAI,EAAE,aAAa,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,KAAK,IAAI,GACT,IAAI;IAKP;;OAEG;IACH,0BAA0B,IAAI,uBAAuB;IAIrD;;OAEG;IACH,sBAAsB,IAAI,mBAAmB;IAI7C;;OAEG;IACH,oBAAoB,IAAI,iBAAiB;CAwgB1C;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAU,KAAK,eAAe,kBAEzD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
25
25
|
const fs = require("node:fs");
|
|
26
26
|
const path = require("node:path");
|
|
27
27
|
const node_url = require("node:url");
|
|
28
|
+
const dotenv = require("dotenv");
|
|
28
29
|
const magicRegexp = require("magic-regexp");
|
|
29
30
|
const simpleMcpLogger = require("@alcyone-labs/simple-mcp-logger");
|
|
30
31
|
const getTsconfig = require("get-tsconfig");
|
|
@@ -888,6 +889,9 @@ class ConfigurationManager {
|
|
|
888
889
|
for (const parser of parserChain) {
|
|
889
890
|
allFlags.push(...parser.flags);
|
|
890
891
|
}
|
|
892
|
+
const normalizeKey = (key) => {
|
|
893
|
+
return key.toLowerCase().replace(/[-_]/g, "");
|
|
894
|
+
};
|
|
891
895
|
for (const [key, value] of Object.entries(rawConfig)) {
|
|
892
896
|
let flag = allFlags.find((f) => f["name"] === key);
|
|
893
897
|
if (!flag) {
|
|
@@ -895,6 +899,10 @@ class ConfigurationManager {
|
|
|
895
899
|
(f) => f["name"].toLowerCase() === key.toLowerCase()
|
|
896
900
|
);
|
|
897
901
|
}
|
|
902
|
+
if (!flag) {
|
|
903
|
+
const normalizedKey = normalizeKey(key);
|
|
904
|
+
flag = allFlags.find((f) => normalizeKey(f["name"]) === normalizedKey);
|
|
905
|
+
}
|
|
898
906
|
if (flag) {
|
|
899
907
|
try {
|
|
900
908
|
flagValues[flag["name"]] = this.convertValueToFlagType(value, flag);
|
|
@@ -986,22 +994,42 @@ class ConfigurationManager {
|
|
|
986
994
|
/**
|
|
987
995
|
* Merges environment configuration with command line arguments
|
|
988
996
|
*/
|
|
989
|
-
mergeEnvConfigWithArgs(envConfig, processArgs) {
|
|
997
|
+
mergeEnvConfigWithArgs(envConfig, processArgs, parserChain) {
|
|
990
998
|
const mergedArgs = [...processArgs];
|
|
999
|
+
const allFlags = [];
|
|
1000
|
+
if (parserChain) {
|
|
1001
|
+
for (const parser of parserChain) {
|
|
1002
|
+
allFlags.push(...parser.flags);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
const getFlagOption = (flagName) => {
|
|
1006
|
+
const flag = allFlags.find((f) => f["name"] === flagName);
|
|
1007
|
+
if (flag && Array.isArray(flag["options"]) && flag["options"].length > 0) {
|
|
1008
|
+
const longOption = flag["options"].find(
|
|
1009
|
+
(opt) => opt.startsWith("--")
|
|
1010
|
+
);
|
|
1011
|
+
return longOption || flag["options"][0];
|
|
1012
|
+
}
|
|
1013
|
+
return `--${flagName}`;
|
|
1014
|
+
};
|
|
991
1015
|
for (const [key, value] of Object.entries(envConfig)) {
|
|
992
|
-
const
|
|
993
|
-
const
|
|
1016
|
+
const flagOption = getFlagOption(key);
|
|
1017
|
+
const flagOptionWithoutDashes = flagOption.replace(/^--?/, "");
|
|
1018
|
+
const hasFlag = mergedArgs.some((arg) => {
|
|
1019
|
+
const argWithoutDashes = arg.replace(/^--?/, "").split("=")[0];
|
|
1020
|
+
return argWithoutDashes === flagOptionWithoutDashes || argWithoutDashes === key;
|
|
1021
|
+
});
|
|
994
1022
|
if (!hasFlag) {
|
|
995
1023
|
if (typeof value === "boolean") {
|
|
996
1024
|
if (value) {
|
|
997
|
-
mergedArgs.push(
|
|
1025
|
+
mergedArgs.push(flagOption);
|
|
998
1026
|
}
|
|
999
1027
|
} else if (Array.isArray(value)) {
|
|
1000
1028
|
for (const item of value) {
|
|
1001
|
-
mergedArgs.push(
|
|
1029
|
+
mergedArgs.push(flagOption, String(item));
|
|
1002
1030
|
}
|
|
1003
1031
|
} else {
|
|
1004
|
-
mergedArgs.push(
|
|
1032
|
+
mergedArgs.push(flagOption, String(value));
|
|
1005
1033
|
}
|
|
1006
1034
|
}
|
|
1007
1035
|
}
|
|
@@ -4305,33 +4333,25 @@ class ArgParserBase {
|
|
|
4305
4333
|
if (providedPath && !providedPath.startsWith("-")) {
|
|
4306
4334
|
const basePath = this.#effectiveWorkingDirectory || process.cwd();
|
|
4307
4335
|
envFilePath = path__namespace.resolve(basePath, providedPath);
|
|
4308
|
-
} else {
|
|
4336
|
+
} else if (shouldAutoDiscover) {
|
|
4309
4337
|
const basePath = this.#effectiveWorkingDirectory || process.cwd();
|
|
4310
4338
|
envFilePath = this.#configurationManager.discoverEnvFile(basePath);
|
|
4311
4339
|
if (!envFilePath) {
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
"Warning: No .env file found in working directory. Continuing without environment configuration."
|
|
4315
|
-
)
|
|
4340
|
+
console.warn(
|
|
4341
|
+
"Warning: No .env file found in working directory. Continuing without environment configuration."
|
|
4316
4342
|
);
|
|
4317
4343
|
processArgs.splice(withEnvIndex, 1);
|
|
4318
4344
|
}
|
|
4319
4345
|
}
|
|
4320
|
-
}
|
|
4321
|
-
if (shouldAutoDiscover) {
|
|
4346
|
+
} else if (shouldAutoDiscover) {
|
|
4322
4347
|
const basePath = this.#effectiveWorkingDirectory || process.cwd();
|
|
4323
4348
|
envFilePath = this.#configurationManager.discoverEnvFile(basePath);
|
|
4324
4349
|
if (envFilePath) {
|
|
4325
|
-
|
|
4326
|
-
simpleChalk.dim(`Auto-discovered env file: ${envFilePath}`)
|
|
4327
|
-
);
|
|
4350
|
+
console.warn(`Auto-discovered env file: ${envFilePath}`);
|
|
4328
4351
|
} else {
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
"Warning: No .env file found in working directory. Continuing without environment configuration."
|
|
4332
|
-
)
|
|
4352
|
+
console.warn(
|
|
4353
|
+
"Warning: No .env file found in working directory. Continuing without environment configuration."
|
|
4333
4354
|
);
|
|
4334
|
-
processArgs.splice(withEnvIndex, 1);
|
|
4335
4355
|
}
|
|
4336
4356
|
}
|
|
4337
4357
|
if (envFilePath) {
|
|
@@ -4352,7 +4372,8 @@ class ArgParserBase {
|
|
|
4352
4372
|
if (envConfigArgs) {
|
|
4353
4373
|
const mergedArgs = identifiedFinalParser2.#configurationManager.mergeEnvConfigWithArgs(
|
|
4354
4374
|
envConfigArgs,
|
|
4355
|
-
processArgs
|
|
4375
|
+
processArgs,
|
|
4376
|
+
identifiedParserChain
|
|
4356
4377
|
);
|
|
4357
4378
|
processArgs.length = 0;
|
|
4358
4379
|
processArgs.push(...mergedArgs);
|
|
@@ -4367,6 +4388,52 @@ class ArgParserBase {
|
|
|
4367
4388
|
processArgs.splice(finalWithEnvIndex, 1);
|
|
4368
4389
|
}
|
|
4369
4390
|
}
|
|
4391
|
+
} catch (error) {
|
|
4392
|
+
console.error(
|
|
4393
|
+
`Error loading environment file: ${error instanceof Error ? error.message : String(error)}`
|
|
4394
|
+
);
|
|
4395
|
+
return this._handleExit(
|
|
4396
|
+
1,
|
|
4397
|
+
`Error loading environment file: ${error instanceof Error ? error.message : String(error)}`,
|
|
4398
|
+
"error"
|
|
4399
|
+
);
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
if (shouldAutoDiscover) {
|
|
4403
|
+
const basePath = this.#effectiveWorkingDirectory || process.cwd();
|
|
4404
|
+
envFilePath = this.#configurationManager.discoverEnvFile(basePath);
|
|
4405
|
+
if (envFilePath) {
|
|
4406
|
+
console.warn(`Auto-discovered env file: ${envFilePath}`);
|
|
4407
|
+
} else {
|
|
4408
|
+
console.warn(
|
|
4409
|
+
"Warning: No .env file found in working directory. Continuing without environment configuration."
|
|
4410
|
+
);
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
if (envFilePath) {
|
|
4414
|
+
try {
|
|
4415
|
+
const {
|
|
4416
|
+
finalParser: identifiedFinalParser2,
|
|
4417
|
+
parserChain: identifiedParserChain
|
|
4418
|
+
} = this.#_identifyCommandChainAndParsers(
|
|
4419
|
+
processArgs,
|
|
4420
|
+
this,
|
|
4421
|
+
[],
|
|
4422
|
+
[this]
|
|
4423
|
+
);
|
|
4424
|
+
const envConfigArgs = identifiedFinalParser2.#configurationManager.loadEnvFile(
|
|
4425
|
+
envFilePath,
|
|
4426
|
+
identifiedParserChain
|
|
4427
|
+
);
|
|
4428
|
+
if (envConfigArgs) {
|
|
4429
|
+
const mergedArgs = identifiedFinalParser2.#configurationManager.mergeEnvConfigWithArgs(
|
|
4430
|
+
envConfigArgs,
|
|
4431
|
+
processArgs,
|
|
4432
|
+
identifiedParserChain
|
|
4433
|
+
);
|
|
4434
|
+
processArgs.length = 0;
|
|
4435
|
+
processArgs.push(...mergedArgs);
|
|
4436
|
+
}
|
|
4370
4437
|
} catch (error) {
|
|
4371
4438
|
console.error(
|
|
4372
4439
|
simpleChalk.red(
|
|
@@ -4396,6 +4463,43 @@ class ArgParserBase {
|
|
|
4396
4463
|
}
|
|
4397
4464
|
}
|
|
4398
4465
|
}
|
|
4466
|
+
const withEnvWasProvided = processArgs.some(
|
|
4467
|
+
(arg) => arg === "--s-with-env"
|
|
4468
|
+
);
|
|
4469
|
+
const shouldAutoDiscoverWithoutFlag = this.#workingDirectoryResolved && this.#effectiveWorkingDirectory !== this.#rootPath && !withEnvWasProvided;
|
|
4470
|
+
if (shouldAutoDiscoverWithoutFlag) {
|
|
4471
|
+
const basePath = this.#effectiveWorkingDirectory || process.cwd();
|
|
4472
|
+
const autoDiscoveredEnvFile = this.#configurationManager.discoverEnvFile(basePath);
|
|
4473
|
+
if (autoDiscoveredEnvFile) {
|
|
4474
|
+
console.warn(`Auto-discovered env file: ${autoDiscoveredEnvFile}`);
|
|
4475
|
+
dotenv.config({ path: autoDiscoveredEnvFile, quiet: true });
|
|
4476
|
+
try {
|
|
4477
|
+
const { finalParser: envFinalParser, parserChain: envParserChain } = this.#_identifyCommandChainAndParsers(
|
|
4478
|
+
processArgs,
|
|
4479
|
+
this,
|
|
4480
|
+
[],
|
|
4481
|
+
[this]
|
|
4482
|
+
);
|
|
4483
|
+
const envConfigArgs = envFinalParser.#configurationManager.loadEnvFile(
|
|
4484
|
+
autoDiscoveredEnvFile,
|
|
4485
|
+
envParserChain
|
|
4486
|
+
);
|
|
4487
|
+
if (envConfigArgs) {
|
|
4488
|
+
const mergedArgs = envFinalParser.#configurationManager.mergeEnvConfigWithArgs(
|
|
4489
|
+
envConfigArgs,
|
|
4490
|
+
processArgs,
|
|
4491
|
+
envParserChain
|
|
4492
|
+
);
|
|
4493
|
+
processArgs.length = 0;
|
|
4494
|
+
processArgs.push(...mergedArgs);
|
|
4495
|
+
}
|
|
4496
|
+
} catch (error) {
|
|
4497
|
+
console.error(
|
|
4498
|
+
`Error loading auto-discovered environment file: ${error instanceof Error ? error.message : String(error)}`
|
|
4499
|
+
);
|
|
4500
|
+
}
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4399
4503
|
const { finalParser: identifiedFinalParser } = this.#_identifyCommandChainAndParsers(processArgs, this, [], [this]);
|
|
4400
4504
|
const buildDxtIndex = processArgs.findIndex(
|
|
4401
4505
|
(arg) => (arg ?? "").toLowerCase() === "--s-build-dxt"
|