@nmakarov/cli-toolkit 0.1.0

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/dist/args.js ADDED
@@ -0,0 +1,422 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/args/index.ts
9
+ import { readFileSync, existsSync } from "fs";
10
+ import { resolve, dirname, basename, extname, join, isAbsolute } from "path";
11
+ import { config } from "dotenv";
12
+ var Args = class {
13
+ args = {};
14
+ flags = {};
15
+ options = {};
16
+ commands = [];
17
+ usedKeys = /* @__PURE__ */ new Set();
18
+ aliases = {};
19
+ overrides = {};
20
+ defaults = {};
21
+ prefixes = [];
22
+ nots = [];
23
+ configValues = {};
24
+ configsLoaded = [];
25
+ env = "local";
26
+ constructor(config2 = {}) {
27
+ this.aliases = config2.aliases || {};
28
+ this.overrides = config2.overrides || {};
29
+ this.defaults = config2.defaults || {};
30
+ this.prefixes = config2.prefixes || ["not", "no"];
31
+ const args = config2.args || process.argv.slice(2);
32
+ this.parseArgs(args);
33
+ this.env = this.get("env")?.toLowerCase() || "local";
34
+ this.loadDotEnv();
35
+ this.loadConfigFiles();
36
+ this.checkConflicts();
37
+ }
38
+ /**
39
+ * Parse command line arguments
40
+ */
41
+ parseArgs(args) {
42
+ let i = 0;
43
+ while (i < args.length) {
44
+ const arg = args[i];
45
+ if (arg.startsWith("--")) {
46
+ const [key, value] = this.parseLongOption(arg);
47
+ this.setValue(key, value);
48
+ i++;
49
+ } else if (arg.startsWith("-")) {
50
+ const result = this.parseShortOption(arg, args, i);
51
+ if (result.consumed > 0) {
52
+ i += result.consumed;
53
+ } else {
54
+ i++;
55
+ }
56
+ } else {
57
+ this.commands.push(arg);
58
+ i++;
59
+ }
60
+ }
61
+ }
62
+ /**
63
+ * Parse long option (--key=value or --key)
64
+ */
65
+ parseLongOption(arg) {
66
+ const key = arg.slice(2);
67
+ const prefix = this.prefixes.find((p) => key.startsWith(p));
68
+ if (prefix) {
69
+ let strippedKey = key.slice(prefix.length);
70
+ if (strippedKey.startsWith("-")) {
71
+ strippedKey = strippedKey.slice(1);
72
+ }
73
+ this.nots.push(key);
74
+ return [strippedKey, false];
75
+ }
76
+ if (key.includes("=")) {
77
+ const eqIndex = key.indexOf("=");
78
+ const optionKey = key.slice(0, eqIndex);
79
+ const value = key.slice(eqIndex + 1);
80
+ return [optionKey, this.parseValue(value)];
81
+ } else {
82
+ return [key, true];
83
+ }
84
+ }
85
+ /**
86
+ * Parse short option (-k=value, -k, or bundled -vsd)
87
+ */
88
+ parseShortOption(arg, args, index) {
89
+ const key = arg.slice(1);
90
+ if (key.length === 1 && index + 1 < args.length && !args[index + 1].startsWith("-")) {
91
+ const value = args[index + 1];
92
+ this.setValue(key, this.parseValue(value));
93
+ return { consumed: 2 };
94
+ }
95
+ if (key.length > 1 && !key.includes("=")) {
96
+ for (let i = 0; i < key.length; i++) {
97
+ const shortKey = key[i];
98
+ if (shortKey in this.aliases) {
99
+ this.setValue(shortKey, true);
100
+ } else {
101
+ this.args[shortKey] = true;
102
+ }
103
+ }
104
+ return { consumed: 1 };
105
+ }
106
+ if (key.includes("=")) {
107
+ const eqIndex = key.indexOf("=");
108
+ const optionKey = key.slice(0, eqIndex);
109
+ const value = key.slice(eqIndex + 1);
110
+ if (optionKey.length > 1) {
111
+ for (let i = 0; i < optionKey.length - 1; i++) {
112
+ const shortKey = optionKey[i];
113
+ if (shortKey in this.aliases) {
114
+ this.setValue(shortKey, true);
115
+ } else {
116
+ this.args[shortKey] = true;
117
+ }
118
+ }
119
+ const lastKey = optionKey[optionKey.length - 1];
120
+ if (lastKey in this.aliases) {
121
+ this.setValue(lastKey, this.parseValue(value));
122
+ } else {
123
+ this.args[lastKey] = this.parseValue(value);
124
+ }
125
+ } else {
126
+ this.setValue(optionKey, this.parseValue(value));
127
+ }
128
+ return { consumed: 1 };
129
+ } else {
130
+ this.setValue(key, true);
131
+ return { consumed: 1 };
132
+ }
133
+ }
134
+ /**
135
+ * Parse value (handle quotes)
136
+ */
137
+ parseValue(value) {
138
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
139
+ return value.slice(1, -1);
140
+ }
141
+ return value;
142
+ }
143
+ /**
144
+ * Set a value with proper categorization
145
+ */
146
+ setValue(key, value) {
147
+ const resolvedKey = this.aliases[key] || key;
148
+ if (typeof value === "boolean") {
149
+ this.flags[resolvedKey] = value;
150
+ } else {
151
+ this.options[resolvedKey] = value;
152
+ }
153
+ this.args[resolvedKey.toLowerCase()] = value;
154
+ }
155
+ /**
156
+ * Check for conflicts (short + long form of same option)
157
+ */
158
+ checkConflicts() {
159
+ const conflicts = [];
160
+ for (const [shortKey, longKey] of Object.entries(this.aliases)) {
161
+ const hasShort = this.args[shortKey] !== void 0;
162
+ const hasLong = this.args[longKey] !== void 0;
163
+ if (hasShort && hasLong) {
164
+ conflicts.push(`Both -${shortKey} and --${longKey} specified`);
165
+ }
166
+ }
167
+ if (conflicts.length > 0) {
168
+ throw new Error(`Argument conflicts: ${conflicts.join(", ")}`);
169
+ }
170
+ }
171
+ /**
172
+ * Get a value with precedence order
173
+ */
174
+ get(key) {
175
+ const resolvedKey = this.aliases[key] || key;
176
+ this.usedKeys.add(resolvedKey);
177
+ if (this.overrides[resolvedKey] !== void 0) {
178
+ return this.overrides[resolvedKey];
179
+ }
180
+ const lcKey = resolvedKey.toLowerCase();
181
+ const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : ""}`;
182
+ if (this.env && this.args[lcKeyWithEnv] !== void 0) {
183
+ return this.args[lcKeyWithEnv];
184
+ } else if (this.args[lcKey] !== void 0) {
185
+ return this.args[lcKey];
186
+ }
187
+ if (this.configValues[resolvedKey] !== void 0) {
188
+ return this.configValues[resolvedKey];
189
+ }
190
+ const envKey = this.toEnvKey(resolvedKey);
191
+ const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : ""}`;
192
+ const envSpecificKey = Object.keys(process.env).find(
193
+ (k) => this.env && k.toUpperCase() === envKeyWithEnv
194
+ );
195
+ const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);
196
+ if (envSpecificKey) {
197
+ return process.env[envSpecificKey];
198
+ } else if (envKeyFound) {
199
+ return process.env[envKeyFound];
200
+ }
201
+ if (this.defaults[resolvedKey] !== void 0) {
202
+ return this.defaults[resolvedKey];
203
+ }
204
+ if (resolvedKey === "env" && process.env.NODE_ENV !== void 0) {
205
+ return process.env.NODE_ENV;
206
+ }
207
+ return void 0;
208
+ }
209
+ /**
210
+ * Set a value (for testing/internal use)
211
+ */
212
+ set(key, value) {
213
+ this.args[key] = value;
214
+ }
215
+ /**
216
+ * Check if a command exists (case-insensitive)
217
+ */
218
+ hasCommand(cmd) {
219
+ return this.commands.some((command) => command.toLowerCase() === cmd.toLowerCase());
220
+ }
221
+ /**
222
+ * Get all commands
223
+ */
224
+ getCommands() {
225
+ return [...this.commands];
226
+ }
227
+ /**
228
+ * Get used keys (as array)
229
+ */
230
+ getUsed() {
231
+ return Array.from(this.usedKeys);
232
+ }
233
+ /**
234
+ * Get unused keys (as array)
235
+ */
236
+ getUnused() {
237
+ const unused = [];
238
+ for (const key of Object.keys(this.args)) {
239
+ if (!this.usedKeys.has(key) && !this.nots.includes(key)) {
240
+ unused.push(key);
241
+ }
242
+ }
243
+ return unused;
244
+ }
245
+ /**
246
+ * Convert key to environment variable format
247
+ */
248
+ toEnvKey(key) {
249
+ return key.replace(
250
+ /[A-Z0-9]/g,
251
+ (match, offset) => offset === 0 ? match : "_" + match.toLowerCase()
252
+ ).toUpperCase();
253
+ }
254
+ /**
255
+ * Load .env file
256
+ */
257
+ loadDotEnv() {
258
+ const dotEnvPath = this.get("dotEnvPath") || process.cwd();
259
+ const dotEnvFile = this.get("dotEnvFile") || ".env";
260
+ if (this.get("dotEnvFile")) {
261
+ const customPath = resolve(dotEnvPath, dotEnvFile);
262
+ if (existsSync(customPath)) {
263
+ config({ path: customPath, quiet: true });
264
+ }
265
+ return;
266
+ }
267
+ let dotEnvPathFile = null;
268
+ const envSpecificFile = `.env.${this.env}`;
269
+ const envSpecificPath = resolve(dotEnvPath, envSpecificFile);
270
+ if (existsSync(envSpecificPath)) {
271
+ dotEnvPathFile = envSpecificPath;
272
+ }
273
+ if (!dotEnvPathFile && !this.get("dotEnvPath")) {
274
+ const examplesPath = resolve(dotEnvPath, "examples");
275
+ const examplesEnvSpecificPath = resolve(examplesPath, envSpecificFile);
276
+ if (existsSync(examplesEnvSpecificPath)) {
277
+ dotEnvPathFile = examplesEnvSpecificPath;
278
+ }
279
+ }
280
+ if (!dotEnvPathFile) {
281
+ dotEnvPathFile = resolve(dotEnvPath, dotEnvFile);
282
+ if (!existsSync(dotEnvPathFile)) {
283
+ if (!this.get("dotEnvPath")) {
284
+ const examplesPath = resolve(dotEnvPath, "examples");
285
+ const examplesEnvFile = resolve(examplesPath, dotEnvFile);
286
+ if (existsSync(examplesEnvFile)) {
287
+ dotEnvPathFile = examplesEnvFile;
288
+ } else {
289
+ dotEnvPathFile = resolve(dotEnvPath, "..", dotEnvFile);
290
+ }
291
+ }
292
+ }
293
+ }
294
+ if (dotEnvPathFile && existsSync(dotEnvPathFile)) {
295
+ config({ path: dotEnvPathFile, quiet: true });
296
+ }
297
+ }
298
+ /**
299
+ * Load configuration files
300
+ */
301
+ loadConfigFiles() {
302
+ this.configsLoaded = [];
303
+ this.configValues = {};
304
+ const _defaultConfigExtension = this.get("defaultConfigExtension") || "js";
305
+ const optConfigFiles = this.get("config") || this.get("configs") || "";
306
+ const configFiles = optConfigFiles ? optConfigFiles.split(/,\s*/) : [];
307
+ const optConfigFilePath = this.get("configPath");
308
+ if (configFiles.length > 0) {
309
+ for (const cfgFile of configFiles) {
310
+ let notLoaded = false;
311
+ let notLoadedEnvSpecific = false;
312
+ const cfgFileWithPath = this.resolveFileWithPath(optConfigFilePath, cfgFile);
313
+ try {
314
+ const cfgContents = this.requireConfigFile(cfgFileWithPath);
315
+ this.configValues = { ...this.configValues, ...cfgContents };
316
+ this.configsLoaded.push(cfgFileWithPath);
317
+ } catch {
318
+ notLoaded = true;
319
+ }
320
+ const cfgEnvFileWithPath = this.resolveFileWithPath(
321
+ optConfigFilePath,
322
+ cfgFile,
323
+ this.env
324
+ );
325
+ if (cfgEnvFileWithPath !== cfgFileWithPath) {
326
+ try {
327
+ const cfgContents = this.requireConfigFile(cfgEnvFileWithPath);
328
+ this.configValues = { ...this.configValues, ...cfgContents };
329
+ this.configsLoaded.push(cfgEnvFileWithPath);
330
+ } catch {
331
+ notLoadedEnvSpecific = true;
332
+ }
333
+ } else {
334
+ notLoadedEnvSpecific = true;
335
+ }
336
+ if (notLoaded && notLoadedEnvSpecific) {
337
+ throw new Error(`can't load config file "${cfgFileWithPath}"`);
338
+ }
339
+ }
340
+ }
341
+ }
342
+ /**
343
+ * Resolve file path with environment-specific naming
344
+ */
345
+ resolveFileWithPath(optConfigFilePath, cfgFile, env) {
346
+ let cfgFileWithPath = optConfigFilePath ? isAbsolute(optConfigFilePath) ? resolve(optConfigFilePath, cfgFile) : resolve(process.cwd(), optConfigFilePath, cfgFile) : isAbsolute(cfgFile) ? cfgFile : resolve(process.cwd(), cfgFile);
347
+ const { basePathWithName, extension } = this.splitPath(cfgFileWithPath);
348
+ if (env) {
349
+ cfgFileWithPath = `${basePathWithName}.${env}.${extension || "js"}`;
350
+ } else {
351
+ cfgFileWithPath = `${basePathWithName}.${extension || "js"}`;
352
+ }
353
+ return cfgFileWithPath;
354
+ }
355
+ /**
356
+ * Split file path into base path and extension
357
+ */
358
+ splitPath(filePath) {
359
+ const basePathWithName = join(dirname(filePath), basename(filePath, extname(filePath)));
360
+ const extension = extname(filePath).slice(1);
361
+ return { basePathWithName, extension };
362
+ }
363
+ /**
364
+ * Require a configuration file (supports .js and .json)
365
+ */
366
+ requireConfigFile(filePath) {
367
+ if (!existsSync(filePath)) {
368
+ throw new Error(`Config file not found: ${filePath}`);
369
+ }
370
+ const ext = extname(filePath).toLowerCase();
371
+ if (ext === ".json") {
372
+ const content = readFileSync(filePath, "utf8");
373
+ return JSON.parse(content);
374
+ } else if (ext === ".js") {
375
+ try {
376
+ delete __require.cache[__require.resolve(filePath)];
377
+ return __require(filePath);
378
+ } catch (error) {
379
+ throw new Error(`Failed to load JS config file: ${error instanceof Error ? error.message : String(error)}`);
380
+ }
381
+ } else {
382
+ throw new Error(`Unsupported file extension: ${ext}`);
383
+ }
384
+ }
385
+ /**
386
+ * Get all parsed data
387
+ */
388
+ getParsed() {
389
+ return {
390
+ command: this.commands[0] || "",
391
+ flags: { ...this.flags },
392
+ options: { ...this.options },
393
+ usedKeys: new Set(this.usedKeys)
394
+ };
395
+ }
396
+ /**
397
+ * Set prefixes dynamically and re-parse arguments (like legacy)
398
+ */
399
+ setPrefixes(prefixes) {
400
+ const arr = Array.isArray(prefixes) ? prefixes : prefixes.split(/,\s*/);
401
+ const sortedArr = arr.sort(
402
+ (a, b) => a.length < b.length ? 1 : a.length > b.length ? -1 : 0
403
+ );
404
+ this.prefixes = sortedArr.map((el) => el.toLowerCase());
405
+ const args = process.argv.slice(2);
406
+ this.parseArgs(args);
407
+ }
408
+ };
409
+ var instance = null;
410
+ function init(args) {
411
+ instance = new Args({ args });
412
+ return instance;
413
+ }
414
+ function getArgsInstance() {
415
+ return instance;
416
+ }
417
+ export {
418
+ Args,
419
+ getArgsInstance,
420
+ init
421
+ };
422
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/args/index.ts"],"sourcesContent":["// Arguments discovery and parsing module\n// This module provides utilities for parsing CLI arguments and detecting flags\n\nimport { readFileSync, existsSync } from \"fs\";\nimport { resolve, dirname, basename, extname, join, isAbsolute } from \"path\";\nimport { config } from \"dotenv\";\n\nexport interface ArgsConfig {\n args?: string[]; // Default: process.argv.slice(2)\n aliases?: Record<string, string>; // Short → long mapping\n overrides?: Record<string, any>; // Highest precedence\n defaults?: Record<string, any>; // Lowest precedence\n prefixes?: string[]; // Negative flag prefixes (default: [\"not\", \"no\"])\n}\n\nexport interface ParsedArgs {\n command: string;\n flags: Record<string, boolean>;\n options: Record<string, string>;\n usedKeys: Set<string>;\n}\n\n/**\n * Parse command line arguments with support for aliases, overrides, and defaults\n *\n * Precedence order (highest to lowest):\n * 1. Overrides (constructor config)\n * 2. CLI args (command line)\n * 3. Config files (loaded from files)\n * 4. Environment variables (process.env)\n * 5. Defaults (constructor config)\n */\nexport class Args {\n private args: Record<string, any> = {};\n private flags: Record<string, boolean> = {};\n private options: Record<string, string> = {};\n private commands: string[] = [];\n private usedKeys: Set<string> = new Set();\n private aliases: Record<string, string> = {};\n private overrides: Record<string, any> = {};\n private defaults: Record<string, any> = {};\n private prefixes: string[] = [];\n private nots: string[] = [];\n private configValues: Record<string, any> = {};\n private configsLoaded: string[] = [];\n private env: string = \"local\";\n\n constructor(config: ArgsConfig = {}) {\n // Set up configuration\n this.aliases = config.aliases || {};\n this.overrides = config.overrides || {};\n this.defaults = config.defaults || {};\n this.prefixes = config.prefixes || [\"not\", \"no\"];\n\n // Parse arguments first to get environment\n const args = config.args || process.argv.slice(2);\n this.parseArgs(args);\n\n // Set environment from parsed args\n this.env = this.get(\"env\")?.toLowerCase() || \"local\";\n\n // Load .env file\n this.loadDotEnv();\n\n // Load configuration files\n this.loadConfigFiles();\n\n // Check for conflicts (short + long form of same option)\n this.checkConflicts();\n }\n\n /**\n * Parse command line arguments\n */\n private parseArgs(args: string[]): void {\n let i = 0;\n while (i < args.length) {\n const arg = args[i];\n\n if (arg.startsWith(\"--\")) {\n // Long option: --key=value or --key\n const [key, value] = this.parseLongOption(arg);\n this.setValue(key, value);\n i++;\n } else if (arg.startsWith(\"-\")) {\n // Short option: -k=value, -k, or bundled -vsd\n const result = this.parseShortOption(arg, args, i);\n if (result.consumed > 0) {\n i += result.consumed;\n } else {\n i++;\n }\n } else {\n // Command (no prefix)\n this.commands.push(arg);\n i++;\n }\n }\n }\n\n /**\n * Parse long option (--key=value or --key)\n */\n private parseLongOption(arg: string): [string, string | boolean] {\n const key = arg.slice(2); // Remove '--'\n\n // Check for negative flags (--no-debug, --not-verbose)\n const prefix = this.prefixes.find((p) => key.startsWith(p));\n if (prefix) {\n let strippedKey = key.slice(prefix.length);\n // Remove leading dash if present\n if (strippedKey.startsWith(\"-\")) {\n strippedKey = strippedKey.slice(1);\n }\n this.nots.push(key);\n return [strippedKey, false];\n }\n\n if (key.includes(\"=\")) {\n // --key=value - need to handle quoted values properly\n const eqIndex = key.indexOf(\"=\");\n const optionKey = key.slice(0, eqIndex);\n const value = key.slice(eqIndex + 1);\n return [optionKey, this.parseValue(value)];\n } else {\n // --key (boolean flag)\n return [key, true];\n }\n }\n\n /**\n * Parse short option (-k=value, -k, or bundled -vsd)\n */\n private parseShortOption(arg: string, args: string[], index: number): { consumed: number } {\n const key = arg.slice(1); // Remove '-'\n\n // Check if it's a single short flag with value (like -vo file.txt)\n if (key.length === 1 && index + 1 < args.length && !args[index + 1].startsWith(\"-\")) {\n // Single short flag with separate value\n const value = args[index + 1];\n this.setValue(key, this.parseValue(value));\n return { consumed: 2 }; // Consumed this flag and the next argument\n }\n\n // Check if it's a bundled short flags (like -vsd)\n if (key.length > 1 && !key.includes(\"=\")) {\n // Handle bundled flags: -vsd = -v -s -d\n // Process each character, valid ones become flags, invalid ones become unused\n for (let i = 0; i < key.length; i++) {\n const shortKey = key[i];\n if (shortKey in this.aliases) {\n this.setValue(shortKey, true);\n } else {\n // Invalid short flag - add to unused keys\n this.args[shortKey] = true;\n }\n }\n return { consumed: 1 };\n }\n\n if (key.includes(\"=\")) {\n // -k=value or -vsdk=4 - need to handle quoted values properly\n const eqIndex = key.indexOf(\"=\");\n const optionKey = key.slice(0, eqIndex);\n const value = key.slice(eqIndex + 1);\n\n // Check if this is a bundled flag with value on the last one (like -vsdk=4)\n if (optionKey.length > 1) {\n // Handle bundled flags with value on the last one: -vsdk=4 = -v -s -d -k=4\n for (let i = 0; i < optionKey.length - 1; i++) {\n const shortKey = optionKey[i];\n if (shortKey in this.aliases) {\n this.setValue(shortKey, true);\n } else {\n this.args[shortKey] = true;\n }\n }\n // Handle the last flag with value\n const lastKey = optionKey[optionKey.length - 1];\n if (lastKey in this.aliases) {\n this.setValue(lastKey, this.parseValue(value));\n } else {\n this.args[lastKey] = this.parseValue(value);\n }\n } else {\n // Single flag with value: -k=value\n this.setValue(optionKey, this.parseValue(value));\n }\n return { consumed: 1 };\n } else {\n // -k (boolean flag)\n this.setValue(key, true);\n return { consumed: 1 };\n }\n }\n\n /**\n * Parse value (handle quotes)\n */\n private parseValue(value: string): string {\n // Remove surrounding quotes if present\n if (\n (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n return value.slice(1, -1);\n }\n return value;\n }\n\n /**\n * Set a value with proper categorization\n */\n private setValue(key: string, value: string | boolean): void {\n // Resolve alias if it's a short form\n const resolvedKey = this.aliases[key] || key;\n\n if (typeof value === \"boolean\") {\n this.flags[resolvedKey] = value;\n } else {\n this.options[resolvedKey] = value;\n }\n\n // Always set the value in lowercase (for case-insensitive lookup, like legacy)\n this.args[resolvedKey.toLowerCase()] = value;\n }\n\n /**\n * Check for conflicts (short + long form of same option)\n */\n private checkConflicts(): void {\n const conflicts: string[] = [];\n\n for (const [shortKey, longKey] of Object.entries(this.aliases)) {\n const hasShort = this.args[shortKey] !== undefined;\n const hasLong = this.args[longKey] !== undefined;\n\n if (hasShort && hasLong) {\n conflicts.push(`Both -${shortKey} and --${longKey} specified`);\n }\n }\n\n if (conflicts.length > 0) {\n throw new Error(`Argument conflicts: ${conflicts.join(\", \")}`);\n }\n }\n\n /**\n * Get a value with precedence order\n */\n get(key: string): any {\n const resolvedKey = this.aliases[key] || key;\n this.usedKeys.add(resolvedKey);\n\n // Precedence order: overrides > CLI args > config files > env vars > defaults\n if (this.overrides[resolvedKey] !== undefined) {\n return this.overrides[resolvedKey];\n }\n\n // Case-insensitive lookup for CLI args (like legacy)\n const lcKey = resolvedKey.toLowerCase();\n\n // Try environment-specific CLI args first (e.g., --silent_local, --debug_production)\n const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : \"\"}`;\n if (this.env && this.args[lcKeyWithEnv] !== undefined) {\n return this.args[lcKeyWithEnv];\n } else if (this.args[lcKey] !== undefined) {\n return this.args[lcKey];\n }\n\n // Config file values (case-sensitive)\n if (this.configValues[resolvedKey] !== undefined) {\n return this.configValues[resolvedKey];\n }\n\n // Environment variable (convert key to ENV_VAR format)\n const envKey = this.toEnvKey(resolvedKey);\n const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : \"\"}`;\n\n // Try environment-specific env vars first (e.g., SILENT_LOCAL, DEBUG_PRODUCTION)\n const envSpecificKey = Object.keys(process.env).find(\n (k) => this.env && k.toUpperCase() === envKeyWithEnv\n );\n const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);\n\n if (envSpecificKey) {\n return process.env[envSpecificKey];\n } else if (envKeyFound) {\n return process.env[envKeyFound];\n }\n\n // Default value\n if (this.defaults[resolvedKey] !== undefined) {\n return this.defaults[resolvedKey];\n }\n\n // NODE_ENV fallback for 'env' key (like legacy)\n if (resolvedKey === \"env\" && process.env.NODE_ENV !== undefined) {\n return process.env.NODE_ENV;\n }\n\n return undefined;\n }\n\n /**\n * Set a value (for testing/internal use)\n */\n set(key: string, value: any): void {\n this.args[key] = value;\n }\n\n /**\n * Check if a command exists (case-insensitive)\n */\n hasCommand(cmd: string): boolean {\n return this.commands.some((command) => command.toLowerCase() === cmd.toLowerCase());\n }\n\n /**\n * Get all commands\n */\n getCommands(): string[] {\n return [...this.commands];\n }\n\n /**\n * Get used keys (as array)\n */\n getUsed(): string[] {\n return Array.from(this.usedKeys);\n }\n\n /**\n * Get unused keys (as array)\n */\n getUnused(): string[] {\n const unused: string[] = [];\n\n for (const key of Object.keys(this.args)) {\n if (!this.usedKeys.has(key) && !this.nots.includes(key)) {\n unused.push(key);\n }\n }\n\n return unused;\n }\n\n /**\n * Convert key to environment variable format\n */\n private toEnvKey(key: string): string {\n return key\n .replace(/[A-Z0-9]/g, (match, offset) =>\n offset === 0 ? match : \"_\" + match.toLowerCase()\n )\n .toUpperCase();\n }\n\n /**\n * Load .env file\n */\n private loadDotEnv(): void {\n const dotEnvPath = this.get(\"dotEnvPath\") || process.cwd();\n const dotEnvFile = this.get(\"dotEnvFile\") || \".env\";\n\n // If custom dotEnvFile is specified, use it as-is\n if (this.get(\"dotEnvFile\")) {\n const customPath = resolve(dotEnvPath, dotEnvFile);\n if (existsSync(customPath)) {\n config({ path: customPath, quiet: true });\n }\n return;\n }\n\n // Try environment-specific .env file first (e.g., .env.local, .env.production)\n let dotEnvPathFile: string | null = null;\n\n const envSpecificFile = `.env.${this.env}`;\n const envSpecificPath = resolve(dotEnvPath, envSpecificFile);\n if (existsSync(envSpecificPath)) {\n dotEnvPathFile = envSpecificPath;\n }\n\n // If no environment-specific file found in current directory, try examples folder\n if (!dotEnvPathFile && !this.get(\"dotEnvPath\")) {\n const examplesPath = resolve(dotEnvPath, \"examples\");\n const examplesEnvSpecificPath = resolve(examplesPath, envSpecificFile);\n if (existsSync(examplesEnvSpecificPath)) {\n dotEnvPathFile = examplesEnvSpecificPath;\n }\n }\n\n // If no environment-specific file found, try default .env\n if (!dotEnvPathFile) {\n dotEnvPathFile = resolve(dotEnvPath, dotEnvFile);\n\n // If .env file doesn't exist in current directory, try examples folder (for our examples)\n if (!existsSync(dotEnvPathFile)) {\n if (!this.get(\"dotEnvPath\")) {\n // Try examples folder first (for our examples)\n const examplesPath = resolve(dotEnvPath, \"examples\");\n const examplesEnvFile = resolve(examplesPath, dotEnvFile);\n if (existsSync(examplesEnvFile)) {\n dotEnvPathFile = examplesEnvFile;\n } else {\n // Try parent directory (like legacy)\n dotEnvPathFile = resolve(dotEnvPath, \"..\", dotEnvFile);\n }\n }\n }\n }\n\n // Load .env file if it exists\n if (dotEnvPathFile && existsSync(dotEnvPathFile)) {\n config({ path: dotEnvPathFile, quiet: true });\n }\n }\n\n /**\n * Load configuration files\n */\n private loadConfigFiles(): void {\n this.configsLoaded = [];\n this.configValues = {};\n\n const _defaultConfigExtension = this.get(\"defaultConfigExtension\") || \"js\";\n const optConfigFiles = this.get(\"config\") || this.get(\"configs\") || \"\";\n const configFiles = optConfigFiles ? optConfigFiles.split(/,\\s*/) : [];\n const optConfigFilePath = this.get(\"configPath\");\n\n if (configFiles.length > 0) {\n for (const cfgFile of configFiles) {\n let notLoaded = false;\n let notLoadedEnvSpecific = false;\n\n const cfgFileWithPath = this.resolveFileWithPath(optConfigFilePath, cfgFile);\n try {\n const cfgContents = this.requireConfigFile(cfgFileWithPath);\n this.configValues = { ...this.configValues, ...cfgContents };\n this.configsLoaded.push(cfgFileWithPath);\n } catch {\n notLoaded = true;\n }\n\n const cfgEnvFileWithPath = this.resolveFileWithPath(\n optConfigFilePath,\n cfgFile,\n this.env\n );\n if (cfgEnvFileWithPath !== cfgFileWithPath) {\n try {\n const cfgContents = this.requireConfigFile(cfgEnvFileWithPath);\n this.configValues = { ...this.configValues, ...cfgContents };\n this.configsLoaded.push(cfgEnvFileWithPath);\n } catch {\n notLoadedEnvSpecific = true;\n }\n } else {\n notLoadedEnvSpecific = true;\n }\n\n if (notLoaded && notLoadedEnvSpecific) {\n throw new Error(`can't load config file \"${cfgFileWithPath}\"`);\n }\n }\n }\n }\n\n /**\n * Resolve file path with environment-specific naming\n */\n private resolveFileWithPath(\n optConfigFilePath: string | undefined,\n cfgFile: string,\n env?: string\n ): string {\n let cfgFileWithPath = optConfigFilePath\n ? isAbsolute(optConfigFilePath)\n ? resolve(optConfigFilePath, cfgFile)\n : resolve(process.cwd(), optConfigFilePath, cfgFile)\n : isAbsolute(cfgFile)\n ? cfgFile\n : resolve(process.cwd(), cfgFile);\n\n const { basePathWithName, extension } = this.splitPath(cfgFileWithPath);\n if (env) {\n cfgFileWithPath = `${basePathWithName}.${env}.${extension || \"js\"}`;\n } else {\n cfgFileWithPath = `${basePathWithName}.${extension || \"js\"}`;\n }\n return cfgFileWithPath;\n }\n\n /**\n * Split file path into base path and extension\n */\n private splitPath(filePath: string): { basePathWithName: string; extension: string } {\n const basePathWithName = join(dirname(filePath), basename(filePath, extname(filePath)));\n const extension = extname(filePath).slice(1);\n return { basePathWithName, extension };\n }\n\n /**\n * Require a configuration file (supports .js and .json)\n */\n private requireConfigFile(filePath: string): any {\n if (!existsSync(filePath)) {\n throw new Error(`Config file not found: ${filePath}`);\n }\n\n const ext = extname(filePath).toLowerCase();\n if (ext === \".json\") {\n const content = readFileSync(filePath, \"utf8\");\n return JSON.parse(content);\n } else if (ext === \".js\") {\n // For .js files, use require() which is safer than eval\n try {\n // Clear require cache to ensure fresh load\n delete require.cache[require.resolve(filePath)];\n return require(filePath);\n } catch (error) {\n throw new Error(`Failed to load JS config file: ${error instanceof Error ? error.message : String(error)}`);\n }\n } else {\n throw new Error(`Unsupported file extension: ${ext}`);\n }\n }\n\n /**\n * Get all parsed data\n */\n getParsed(): ParsedArgs {\n return {\n command: this.commands[0] || \"\",\n flags: { ...this.flags },\n options: { ...this.options },\n usedKeys: new Set(this.usedKeys)\n };\n }\n\n /**\n * Set prefixes dynamically and re-parse arguments (like legacy)\n */\n setPrefixes(prefixes: string | string[]): void {\n const arr = Array.isArray(prefixes) ? prefixes : prefixes.split(/,\\s*/);\n const sortedArr = arr.sort((a, b) =>\n a.length < b.length ? 1 : a.length > b.length ? -1 : 0\n );\n this.prefixes = sortedArr.map((el) => el.toLowerCase());\n // Re-parse arguments with new prefixes\n const args = process.argv.slice(2);\n this.parseArgs(args);\n }\n}\n\n// Singleton pattern (like legacy)\nlet instance: Args | null = null;\n\n/**\n * Initialize Args instance (singleton pattern)\n */\nexport function init(args?: string[]): Args {\n instance = new Args({ args });\n return instance;\n}\n\n/**\n * Get the current Args instance (singleton pattern)\n */\nexport function getArgsInstance(): Args | null {\n return instance;\n}\n\n\n"],"mappings":";;;;;;;;AAGA,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,SAAS,UAAU,SAAS,MAAM,kBAAkB;AACtE,SAAS,cAAc;AA2BhB,IAAM,OAAN,MAAW;AAAA,EACN,OAA4B,CAAC;AAAA,EAC7B,QAAiC,CAAC;AAAA,EAClC,UAAkC,CAAC;AAAA,EACnC,WAAqB,CAAC;AAAA,EACtB,WAAwB,oBAAI,IAAI;AAAA,EAChC,UAAkC,CAAC;AAAA,EACnC,YAAiC,CAAC;AAAA,EAClC,WAAgC,CAAC;AAAA,EACjC,WAAqB,CAAC;AAAA,EACtB,OAAiB,CAAC;AAAA,EAClB,eAAoC,CAAC;AAAA,EACrC,gBAA0B,CAAC;AAAA,EAC3B,MAAc;AAAA,EAEtB,YAAYA,UAAqB,CAAC,GAAG;AAEjC,SAAK,UAAUA,QAAO,WAAW,CAAC;AAClC,SAAK,YAAYA,QAAO,aAAa,CAAC;AACtC,SAAK,WAAWA,QAAO,YAAY,CAAC;AACpC,SAAK,WAAWA,QAAO,YAAY,CAAC,OAAO,IAAI;AAG/C,UAAM,OAAOA,QAAO,QAAQ,QAAQ,KAAK,MAAM,CAAC;AAChD,SAAK,UAAU,IAAI;AAGnB,SAAK,MAAM,KAAK,IAAI,KAAK,GAAG,YAAY,KAAK;AAG7C,SAAK,WAAW;AAGhB,SAAK,gBAAgB;AAGrB,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKQ,UAAU,MAAsB;AACpC,QAAI,IAAI;AACR,WAAO,IAAI,KAAK,QAAQ;AACpB,YAAM,MAAM,KAAK,CAAC;AAElB,UAAI,IAAI,WAAW,IAAI,GAAG;AAEtB,cAAM,CAAC,KA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;","names":["config"]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/errors.ts
21
+ var errors_exports = {};
22
+ __export(errors_exports, {
23
+ ControlFlowError: () => ControlFlowError,
24
+ CriticalRequestError: () => CriticalRequestError,
25
+ FrameworkError: () => FrameworkError,
26
+ InitError: () => InitError,
27
+ ParamError: () => ParamError
28
+ });
29
+ module.exports = __toCommonJS(errors_exports);
30
+ var FrameworkError = class extends Error {
31
+ constructor(message) {
32
+ super(message);
33
+ this.name = "FrameworkError";
34
+ }
35
+ };
36
+ var ParamError = class extends FrameworkError {
37
+ constructor(message) {
38
+ super(message);
39
+ this.name = "ParamError";
40
+ }
41
+ };
42
+ var InitError = class extends FrameworkError {
43
+ constructor(message) {
44
+ super(message);
45
+ this.name = "InitError";
46
+ }
47
+ };
48
+ var CriticalRequestError = class extends FrameworkError {
49
+ constructor(message) {
50
+ super(message);
51
+ this.name = "CriticalRequestError";
52
+ }
53
+ };
54
+ var ControlFlowError = class extends Error {
55
+ constructor(message) {
56
+ super(message);
57
+ this.name = "ControlFlowError";
58
+ }
59
+ };
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ ControlFlowError,
63
+ CriticalRequestError,
64
+ FrameworkError,
65
+ InitError,
66
+ ParamError
67
+ });
68
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,YAAN,cAAwB,eAAe;AAAA,EAC1C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,uBAAN,cAAmC,eAAe;AAAA,EACrD,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACxC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;","names":[]}
package/dist/errors.js ADDED
@@ -0,0 +1,39 @@
1
+ // src/errors.ts
2
+ var FrameworkError = class extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "FrameworkError";
6
+ }
7
+ };
8
+ var ParamError = class extends FrameworkError {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = "ParamError";
12
+ }
13
+ };
14
+ var InitError = class extends FrameworkError {
15
+ constructor(message) {
16
+ super(message);
17
+ this.name = "InitError";
18
+ }
19
+ };
20
+ var CriticalRequestError = class extends FrameworkError {
21
+ constructor(message) {
22
+ super(message);
23
+ this.name = "CriticalRequestError";
24
+ }
25
+ };
26
+ var ControlFlowError = class extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = "ControlFlowError";
30
+ }
31
+ };
32
+ export {
33
+ ControlFlowError,
34
+ CriticalRequestError,
35
+ FrameworkError,
36
+ InitError,
37
+ ParamError
38
+ };
39
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\n"],"mappings":";AAIO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,YAAN,cAAwB,eAAe;AAAA,EAC1C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,uBAAN,cAAmC,eAAe;AAAA,EACrD,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACxC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;","names":[]}