@shell-shock/core 0.17.0 → 0.17.1

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.
Files changed (41) hide show
  1. package/dist/components/command-validation-logic.cjs +1 -1
  2. package/dist/components/command-validation-logic.cjs.map +1 -1
  3. package/dist/components/command-validation-logic.mjs +1 -1
  4. package/dist/components/command-validation-logic.mjs.map +1 -1
  5. package/dist/components/exec-builtin.cjs +38 -39
  6. package/dist/components/exec-builtin.cjs.map +1 -1
  7. package/dist/components/exec-builtin.mjs +38 -39
  8. package/dist/components/exec-builtin.mjs.map +1 -1
  9. package/dist/components/options-parser-logic.cjs +14 -6
  10. package/dist/components/options-parser-logic.cjs.map +1 -1
  11. package/dist/components/options-parser-logic.d.cts +2 -5
  12. package/dist/components/options-parser-logic.d.cts.map +1 -1
  13. package/dist/components/options-parser-logic.d.mts +2 -5
  14. package/dist/components/options-parser-logic.d.mts.map +1 -1
  15. package/dist/components/options-parser-logic.mjs +14 -6
  16. package/dist/components/options-parser-logic.mjs.map +1 -1
  17. package/dist/components/state-builtin.cjs +43 -8
  18. package/dist/components/state-builtin.cjs.map +1 -1
  19. package/dist/components/state-builtin.d.cts.map +1 -1
  20. package/dist/components/state-builtin.d.mts.map +1 -1
  21. package/dist/components/state-builtin.mjs +44 -9
  22. package/dist/components/state-builtin.mjs.map +1 -1
  23. package/dist/components/utils-builtin.cjs +10 -3
  24. package/dist/components/utils-builtin.cjs.map +1 -1
  25. package/dist/components/utils-builtin.d.cts.map +1 -1
  26. package/dist/components/utils-builtin.d.mts.map +1 -1
  27. package/dist/components/utils-builtin.mjs +10 -3
  28. package/dist/components/utils-builtin.mjs.map +1 -1
  29. package/dist/resolver/resolve.cjs +1 -1
  30. package/dist/resolver/resolve.cjs.map +1 -1
  31. package/dist/resolver/resolve.mjs +1 -1
  32. package/dist/resolver/resolve.mjs.map +1 -1
  33. package/dist/types/env.cjs +1 -1
  34. package/dist/types/env.cjs.map +1 -1
  35. package/dist/types/env.d.cts +7 -1
  36. package/dist/types/env.d.cts.map +1 -1
  37. package/dist/types/env.d.mts +7 -1
  38. package/dist/types/env.d.mts.map +1 -1
  39. package/dist/types/env.mjs +1 -1
  40. package/dist/types/env.mjs.map +1 -1
  41. package/package.json +2 -2
@@ -38,7 +38,14 @@ function ExecBuiltin(props) {
38
38
  });
39
39
  },
40
40
  get builtinImports() {
41
- return defu$1(rest.builtinImports ?? {}, { env: ["isWindows"] });
41
+ return defu$1(rest.builtinImports ?? {}, { env: [
42
+ "isWindows",
43
+ "env",
44
+ {
45
+ name: "Env",
46
+ type: true
47
+ }
48
+ ] });
42
49
  },
43
50
  get children() {
44
51
  return [
@@ -46,11 +53,10 @@ function ExecBuiltin(props) {
46
53
  name: "resolveCommandEnv",
47
54
  parameters: [{
48
55
  name: "params",
49
- type: "{ argv: string[]; env?: NodeJS.ProcessEnv; baseEnv?: NodeJS.ProcessEnv; }"
56
+ type: "{ argv: string[]; env?: NodeJS.ProcessEnv; }"
50
57
  }],
51
58
  returnType: "NodeJS.ProcessEnv",
52
- children: code`const baseEnv = params.baseEnv ?? process.env;
53
- const argv = params.argv;
59
+ children: code`const argv = params.argv;
54
60
  const shouldSuppressNpmFund = (() => {
55
61
  const cmd = basename(argv[0] ?? "");
56
62
  if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
@@ -64,17 +70,19 @@ const shouldSuppressNpmFund = (() => {
64
70
  return false;
65
71
  })();
66
72
 
67
- const mergedEnv = params.env ? { ...baseEnv, ...params.env } : { ...baseEnv };
68
- const resolvedEnv = Object.fromEntries(
69
- Object.entries(mergedEnv)
70
- .filter(([, value]) => value !== undefined)
71
- .map(([key, value]) => [key, String(value)])
73
+ const result = Object.fromEntries(
74
+ Object.entries({
75
+ ...env,
76
+ ...(params.env ?? {})
77
+ })
78
+ .filter(([, value]) => value !== undefined)
79
+ .map(([key, value]) => [key, String(value)])
72
80
  );
73
81
  if (shouldSuppressNpmFund) {
74
- resolvedEnv.NPM_CONFIG_FUND ??= "false";
75
- resolvedEnv.npm_config_fund ??= "false";
82
+ result.NPM_CONFIG_FUND ??= "false";
83
+ result.npm_config_fund ??= "false";
76
84
  }
77
- return resolvedEnv;`
85
+ return result; `
78
86
  }),
79
87
  createComponent(Spacing, {}),
80
88
  createComponent(FunctionDeclaration, {
@@ -308,6 +316,7 @@ return false;`
308
316
  }),
309
317
  createComponent(InterfaceMember, {
310
318
  name: "timeoutMs",
319
+ optional: true,
311
320
  type: "number"
312
321
  }),
313
322
  createComponent(Spacing, {}),
@@ -394,43 +403,40 @@ return false;`
394
403
  typeof optionsOrTimeoutMs === "number"
395
404
  ? { timeoutMs: optionsOrTimeoutMs }
396
405
  : optionsOrTimeoutMs;
397
- const { timeoutMs, cwd, input, env, noOutputTimeoutMs } = options;
398
- const hasInput = input !== undefined;
399
- const resolvedEnv = resolveCommandEnv({ argv, env });
400
- const stdio = resolveCommandStdio({ hasInput, preferInherit: true });
406
+ const { timeoutMs = 300000, cwd, input, noOutputTimeoutMs } = options;
401
407
 
402
- const finalArgv =
408
+ const resolvedArgv =
403
409
  isWindows
404
410
  ? (resolveNpmArgvForWindows(argv) ?? argv)
405
411
  : argv;
406
412
  const resolvedCommand =
407
- finalArgv !== argv
408
- ? (finalArgv[0] ?? "")
413
+ resolvedArgv !== argv
414
+ ? (resolvedArgv[0] ?? "")
409
415
  : resolveCommand(argv[0] ?? "");
410
416
  const useCmdWrapper = isWindowsBatchCommand(resolvedCommand);
411
417
 
412
418
  const child = _spawn(
413
419
  useCmdWrapper
414
- ? (process.env.ComSpec ?? "cmd.exe")
420
+ ? (env.COMSPEC ?? "cmd.exe")
415
421
  : resolvedCommand,
416
422
  useCmdWrapper
417
423
  ? [
418
424
  "/d",
419
425
  "/s",
420
426
  "/c",
421
- buildCmdExeCommandLine(resolvedCommand, finalArgv.slice(1))
427
+ buildCmdExeCommandLine(resolvedCommand, resolvedArgv.slice(1))
422
428
  ]
423
- : finalArgv.slice(1), {
424
- stdio,
429
+ : resolvedArgv.slice(1), {
430
+ stdio: resolveCommandStdio({ hasInput: input !== undefined, preferInherit: true }),
425
431
  cwd,
426
- env: resolvedEnv,
432
+ env: resolveCommandEnv({ argv, env: options.env }),
427
433
  windowsHide: true,
428
434
  windowsVerbatimArguments: useCmdWrapper
429
435
  ? true
430
436
  : options.windowsVerbatimArguments,
431
437
  ...(shouldSpawnWithShell({
432
438
  resolvedCommand: useCmdWrapper
433
- ? (process.env.ComSpec ?? "cmd.exe")
439
+ ? (env.COMSPEC ?? "cmd.exe")
434
440
  : resolvedCommand,
435
441
  platform: process.platform
436
442
  })
@@ -500,7 +506,7 @@ return new Promise((resolve, reject) => {
500
506
  }, timeoutMs >= 0 ? timeoutMs : Number.POSITIVE_INFINITY);
501
507
  armNoOutputTimer();
502
508
 
503
- if (hasInput && child.stdin) {
509
+ if (input !== undefined && child.stdin) {
504
510
  child.stdin.write(input ?? "");
505
511
  child.stdin.end();
506
512
  }
@@ -553,7 +559,7 @@ return new Promise((resolve, reject) => {
553
559
  explicitCode: childExitState?.code ?? code,
554
560
  childExitCode: child.exitCode,
555
561
  resolvedSignal,
556
- usesWindowsExitCodeShim: isWindows && (useCmdWrapper || finalArgv !== argv),
562
+ usesWindowsExitCodeShim: isWindows && (useCmdWrapper || resolvedArgv !== argv),
557
563
  timedOut,
558
564
  noOutputTimedOut,
559
565
  killIssuedByTimeout
@@ -683,23 +689,16 @@ return new Promise((resolve, reject) => {
683
689
  }, {
684
690
  name: "options",
685
691
  type: "SpawnOptions",
686
- optional: true
692
+ default: "{}"
687
693
  }],
688
694
  returnType: "string",
689
695
  children: code`return execFileSync(argv.length > 0 ? argv[0] : "", argv.slice(1), {
690
696
  encoding: "utf8",
691
697
  stdio: ["ignore", "pipe", "ignore"],
692
- timeout: options?.timeoutMs ?? 300000,
693
- env: options?.env ? resolveCommandEnv({ argv, env: options.env }) : process.env,
694
- cwd: options?.cwd,
695
- windowsHide: true,
696
- windowsVerbatimArguments: options?.windowsVerbatimArguments,
697
- ...(shouldSpawnWithShell({
698
- resolvedCommand: argv[0] ?? "",
699
- platform: process.platform
700
- })
701
- ? { shell: true }
702
- : {})
698
+ timeout: options.timeoutMs ?? 300000,
699
+ env: resolveCommandEnv({ argv, env: options.env }),
700
+ cwd: options.cwd || process.cwd(),
701
+ windowsHide: true
703
702
  }).trim(); `
704
703
  }),
705
704
  createComponent(Spacing, {}),
@@ -1 +1 @@
1
- {"version":3,"file":"exec-builtin.mjs","names":[],"sources":["../../src/components/exec-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\n\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TSDocParam,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\n\nexport interface ExecBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * A built-in module for handling command execution in Shell Shock.\n */\nexport function ExecBuiltin(props: ExecBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"exec\"\n description=\"A module to handle command execution in a Shell Shock application.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:path\": [\"basename\", \"extname\", \"dirname\", \"join\"],\n \"node:fs\": [\"existsSync\"],\n \"node:child_process\": [\n { name: \"spawn\", alias: \"_spawn\" },\n \"execFileSync\"\n ],\n \"node:stream\": [{ name: \"Stream\", default: true, type: true }]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n env: [\"isWindows\"]\n })}>\n <FunctionDeclaration\n name=\"resolveCommandEnv\"\n parameters={[\n {\n name: \"params\",\n type: \"{ argv: string[]; env?: NodeJS.ProcessEnv; baseEnv?: NodeJS.ProcessEnv; }\"\n }\n ]}\n returnType=\"NodeJS.ProcessEnv\">\n {code`const baseEnv = params.baseEnv ?? process.env;\nconst argv = params.argv;\nconst shouldSuppressNpmFund = (() => {\n const cmd = basename(argv[0] ?? \"\");\n if (cmd === \"npm\" || cmd === \"npm.cmd\" || cmd === \"npm.exe\") {\n return true;\n }\n if (cmd === \"node\" || cmd === \"node.exe\") {\n const script = argv[1] ?? \"\";\n\n return script.includes(\"npm-cli.js\");\n }\n return false;\n})();\n\nconst mergedEnv = params.env ? { ...baseEnv, ...params.env } : { ...baseEnv };\nconst resolvedEnv = Object.fromEntries(\n Object.entries(mergedEnv)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => [key, String(value)])\n);\nif (shouldSuppressNpmFund) {\n resolvedEnv.NPM_CONFIG_FUND ??= \"false\";\n resolvedEnv.npm_config_fund ??= \"false\";\n}\nreturn resolvedEnv;`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"isWindowsBatchCommand\"\n parameters={[{ name: \"resolvedCommand\", type: \"string\" }]}\n returnType=\"boolean\">\n {code`if (!isWindows) {\n return false;\n}\nconst ext = extname(resolvedCommand).toLowerCase();\n\nreturn ext === \".cmd\" || ext === \".bat\";`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"escapeForCmdExe\"\n parameters={[{ name: \"arg\", type: \"string\" }]}\n returnType=\"string\">\n {code`if (/[&|<>^%\\\\\\\\r\\\\\\\\n]/.test(arg)) {\n throw new Error(\n \\`Unsafe Windows cmd.exe argument detected: \\${JSON.stringify(arg)}. \\` +\n \"Pass an explicit shell-wrapper argv at the call site instead.\"\n );\n}\nif (!arg.includes(\" \") && !arg.includes('\"')) {\n return arg;\n}\nreturn \\`\"\\${arg.replace(/\"/g, '\"\"')}\"\\`;`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"buildCmdExeCommandLine\"\n parameters={[\n { name: \"resolvedCommand\", type: \"string\" },\n { name: \"args\", type: \"string[]\" }\n ]}\n returnType=\"string\">\n {code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(\n \" \"\n);`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveNpmArgvForWindows\"\n doc=\"On Windows, Node 18.20.2+ (CVE-2024-27980) rejects spawning .cmd/.bat directly without shell, causing EINVAL. Resolve npm/npx to node + cli script so we spawn node.exe instead of npm.cmd.\"\n parameters={[{ name: \"argv\", type: \"string[]\" }]}\n returnType=\"string[] | null\">\n {code`if (!isWindows || argv.length === 0) {\n return null;\n}\nconst base = basename(argv[0] ?? \"\")\n .toLowerCase()\n .replace(/\\.(?:cmd|exe|bat)$/, \"\");\nconst cliName =\n base === \"npx\" ? \"npx-cli.js\" : base === \"npm\" ? \"npm-cli.js\" : null;\nif (!cliName) {\n return null;\n}\nconst nodeDir = dirname(process.execPath);\nconst cliPath = join(nodeDir, \"node_modules\", \"npm\", \"bin\", cliName);\nif (!existsSync(cliPath)) {\n const command = argv[0] ?? \"\";\n const ext = extname(command).toLowerCase();\n const shimmedCommand = ext ? command : \\`\\${command}.cmd\\`;\n\n return [shimmedCommand, ...argv.slice(1)];\n}\nreturn [process.execPath, cliPath, ...argv.slice(1)];`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveCommand\"\n doc=\"Resolves a command for Windows compatibility. On Windows, non-.exe commands (like pnpm, yarn) are resolved to .cmd; npm/npx are handled by resolveNpmArgvForWindows to avoid spawn EINVAL (no direct .cmd).\"\n parameters={[{ name: \"command\", type: \"string\" }]}\n returnType=\"string\">\n {code`if (!isWindows) {\n return command;\n}\nconst base = basename(command).toLowerCase();\nif (extname(base)) {\n return command;\n}\nif ([\"pnpm\", \"yarn\"].includes(base)) {\n return \\`\\${command}.cmd\\`;\n}\nreturn command;`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveCommandStdio\"\n parameters={[\n {\n name: \"params\",\n type: \"{ hasInput: boolean; preferInherit: boolean; }\"\n }\n ]}\n returnType='[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]'>\n {code`const stdin = params.hasInput\n ? \"pipe\"\n : params.preferInherit\n ? \"inherit\"\n : \"pipe\";\n\nreturn [stdin, \"pipe\", \"pipe\"];`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveProcessExitCode\"\n parameters={[\n {\n name: \"params\",\n type: \"{ explicitCode: number | null | undefined; childExitCode: number | null | undefined; resolvedSignal: NodeJS.Signals | null; usesWindowsExitCodeShim: boolean; timedOut: boolean; noOutputTimedOut: boolean; killIssuedByTimeout: boolean; }\"\n }\n ]}\n returnType=\"number | null\">\n {code`return (\n params.explicitCode ??\n params.childExitCode ??\n (params.usesWindowsExitCodeShim &&\n params.resolvedSignal == null &&\n !params.timedOut &&\n !params.noOutputTimedOut &&\n !params.killIssuedByTimeout\n ? 0\n : null)\n);`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"shouldSpawnWithShell\"\n parameters={[\n {\n name: \"params\",\n type: \"{ resolvedCommand: string; platform: NodeJS.Platform; }\"\n }\n ]}\n returnType=\"boolean\">\n {code`// SECURITY: never enable \\`shell\\` for argv-based execution.\n// \\`shell\\` routes through cmd.exe on Windows, which turns untrusted argv values\n// (like chat prompts passed as CLI args) into command-injection primitives.\n// If you need a shell, use an explicit shell-wrapper argv (e.g. \\`cmd.exe /c ...\\`)\n// and validate/escape at the call site.\nvoid params;\nreturn false;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"The result of a spawn operation.\" />\n <InterfaceDeclaration export name=\"SpawnResult\">\n <TSDoc heading=\"The PID of the spawned child process, if available.\" />\n <InterfaceMember name=\"pid\" optional type=\"number\" />\n <Spacing />\n <TSDoc heading=\"The standard output produced by the child process.\" />\n <InterfaceMember name=\"stdout\" type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The standard error produced by the child process.\" />\n <InterfaceMember name=\"stderr\" type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The exit code of the child process, if available.\" />\n <InterfaceMember name=\"code\" type=\"number | null\" />\n <Spacing />\n <TSDoc heading=\"The signal that caused the child process to terminate, if it was killed by a signal.\" />\n <InterfaceMember name=\"signal\" type=\"NodeJS.Signals | null\" />\n <Spacing />\n <TSDoc heading=\"Whether the child process was killed.\" />\n <InterfaceMember name=\"killed\" type=\"boolean\" />\n <Spacing />\n <TSDoc heading=\"The reason for the child process termination.\" />\n <InterfaceMember\n name=\"termination\"\n type={code`\"exit\" | \"timeout\" | \"no-output-timeout\" | \"signal\"`}\n />\n <Spacing />\n <TSDoc heading=\"Whether the child process timed out due to no output.\" />\n <InterfaceMember name=\"noOutputTimedOut\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Options for spawning a child process.\" />\n <InterfaceDeclaration export name=\"SpawnOptions\">\n <TSDoc heading=\"The timeout in milliseconds for the spawn operation. If the process runs longer than this, it will be killed and the spawn promise will reject. This can also be provided as a number directly to the spawn function for convenience. Providing \\`-1\\` will disable the timeout.\">\n <TSDocDefaultValue\n type={ReflectionKind.number}\n defaultValue=\"300000\"\n />\n </TSDoc>\n <InterfaceMember name=\"timeoutMs\" type=\"number\" />\n <Spacing />\n <TSDoc heading=\"The current working directory of the child process.\" />\n <InterfaceMember name=\"cwd\" optional type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The input to be passed to the child process.\" />\n <InterfaceMember name=\"input\" optional type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The environment variables for the child process.\" />\n <InterfaceMember name=\"env\" optional type=\"NodeJS.ProcessEnv\" />\n <Spacing />\n <TSDoc heading=\"Whether to pass arguments to the child process verbatim on Windows.\" />\n <InterfaceMember\n name=\"windowsVerbatimArguments\"\n optional\n type=\"boolean\"\n />\n <Spacing />\n <TSDoc heading=\"The timeout in milliseconds for the child process to produce output on stdout or stderr. If the process produces no output for this duration, it will be killed and the spawn promise will reject with a no-output-timeout termination reason.\" />\n <InterfaceMember name=\"noOutputTimeoutMs\" optional type=\"number\" />\n </InterfaceDeclaration>\n <Spacing />\n <VarDeclaration\n const\n name=\"WINDOWS_CLOSE_STATE_SETTLE_TIMEOUT_MS\"\n initializer={code`250`}\n />\n <Spacing />\n <VarDeclaration\n const\n name=\"WINDOWS_CLOSE_STATE_POLL_MS\"\n initializer={code`10`}\n />\n <Spacing />\n <TSDoc heading=\"Spawns a child process with the given arguments and options, returning a promise that resolves with the result of the spawn operation.\">\n <TSDocParam name=\"argv\">\n {\"The command and its arguments to spawn.\"}\n </TSDocParam>\n <TSDocParam name=\"optionsOrTimeoutMs\">\n {`The options for spawning the command, or a number representing the timeout in milliseconds. This allows for a convenient shorthand when only a timeout is needed. Providing \\`-1\\` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used.`}\n </TSDocParam>\n <TSDocReturns>\n {\n \"A promise that resolves with the result of the spawn operation, including stdout, stderr, exit code, signal, and termination reason.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"spawn\"\n parameters={[\n { name: \"argv\", type: \"string[]\" },\n {\n name: \"optionsOrTimeoutMs\",\n type: \"number | SpawnOptions\",\n default: \"300000\"\n }\n ]}\n returnType=\"Promise<SpawnResult>\">\n {code`const options: SpawnOptions =\n typeof optionsOrTimeoutMs === \"number\"\n ? { timeoutMs: optionsOrTimeoutMs }\n : optionsOrTimeoutMs;\nconst { timeoutMs, cwd, input, env, noOutputTimeoutMs } = options;\nconst hasInput = input !== undefined;\nconst resolvedEnv = resolveCommandEnv({ argv, env });\nconst stdio = resolveCommandStdio({ hasInput, preferInherit: true });\n\nconst finalArgv =\n isWindows\n ? (resolveNpmArgvForWindows(argv) ?? argv)\n : argv;\nconst resolvedCommand =\n finalArgv !== argv\n ? (finalArgv[0] ?? \"\")\n : resolveCommand(argv[0] ?? \"\");\nconst useCmdWrapper = isWindowsBatchCommand(resolvedCommand);\n\nconst child = _spawn(\n useCmdWrapper\n ? (process.env.ComSpec ?? \"cmd.exe\")\n : resolvedCommand,\n useCmdWrapper\n ? [\n \"/d\",\n \"/s\",\n \"/c\",\n buildCmdExeCommandLine(resolvedCommand, finalArgv.slice(1))\n ]\n : finalArgv.slice(1), {\n stdio,\n cwd,\n env: resolvedEnv,\n windowsHide: true,\n windowsVerbatimArguments: useCmdWrapper\n ? true\n : options.windowsVerbatimArguments,\n ...(shouldSpawnWithShell({\n resolvedCommand: useCmdWrapper\n ? (process.env.ComSpec ?? \"cmd.exe\")\n : resolvedCommand,\n platform: process.platform\n })\n ? { shell: true }\n : {})\n});\n\nreturn new Promise((resolve, reject) => {\n let stdout = \"\";\n let stderr = \"\";\n let settled = false;\n let timedOut = false;\n let noOutputTimedOut = false;\n let killIssuedByTimeout = false;\n let childExitState: {\n code: number | null;\n signal: NodeJS.Signals | null;\n } | null = null;\n let closeFallbackTimer: NodeJS.Timeout | null = null;\n let noOutputTimer: NodeJS.Timeout | null = null;\n const shouldTrackOutputTimeout =\n typeof noOutputTimeoutMs === \"number\" &&\n Number.isFinite(noOutputTimeoutMs) &&\n noOutputTimeoutMs > 0;\n\n const clearNoOutputTimer = () => {\n if (!noOutputTimer) {\n return;\n }\n clearTimeout(noOutputTimer);\n noOutputTimer = null;\n };\n\n const clearCloseFallbackTimer = () => {\n if (!closeFallbackTimer) {\n return;\n }\n clearTimeout(closeFallbackTimer);\n closeFallbackTimer = null;\n };\n\n const killChild = () => {\n if (settled || typeof child?.kill !== \"function\") {\n return;\n }\n killIssuedByTimeout = true;\n child.kill(\"SIGKILL\");\n };\n\n const armNoOutputTimer = () => {\n if (!shouldTrackOutputTimeout || settled) {\n return;\n }\n clearNoOutputTimer();\n noOutputTimer = setTimeout(() => {\n if (settled) {\n return;\n }\n noOutputTimedOut = true;\n killChild();\n }, Math.floor(noOutputTimeoutMs));\n };\n\n const timer = setTimeout(() => {\n timedOut = true;\n killChild();\n }, timeoutMs >= 0 ? timeoutMs : Number.POSITIVE_INFINITY);\n armNoOutputTimer();\n\n if (hasInput && child.stdin) {\n child.stdin.write(input ?? \"\");\n child.stdin.end();\n }\n\n child.stdout?.on(\"data\", (d: Stream) => {\n stdout += d.toString();\n armNoOutputTimer();\n });\n child.stderr?.on(\"data\", (d: Stream) => {\n stderr += d.toString();\n armNoOutputTimer();\n });\n child.on(\"error\", err => {\n if (settled) {\n return;\n }\n settled = true;\n clearTimeout(timer);\n clearNoOutputTimer();\n clearCloseFallbackTimer();\n reject(err);\n });\n child.on(\"exit\", (code, signal) => {\n childExitState = { code, signal };\n if (settled || closeFallbackTimer) {\n return;\n }\n closeFallbackTimer = setTimeout(() => {\n if (settled) {\n return;\n }\n child.stdout?.destroy();\n child.stderr?.destroy();\n }, 250);\n });\n const resolveFromClose = (\n code: number | null,\n signal: NodeJS.Signals | null\n ) => {\n if (settled) {\n return;\n }\n settled = true;\n clearTimeout(timer);\n clearNoOutputTimer();\n clearCloseFallbackTimer();\n const resolvedSignal =\n childExitState?.signal ?? signal ?? child.signalCode ?? null;\n const resolvedCode = resolveProcessExitCode({\n explicitCode: childExitState?.code ?? code,\n childExitCode: child.exitCode,\n resolvedSignal,\n usesWindowsExitCodeShim: isWindows && (useCmdWrapper || finalArgv !== argv),\n timedOut,\n noOutputTimedOut,\n killIssuedByTimeout\n });\n const termination = noOutputTimedOut\n ? \"no-output-timeout\"\n : timedOut\n ? \"timeout\"\n : resolvedSignal != null\n ? \"signal\"\n : \"exit\";\n const normalizedCode =\n termination === \"timeout\" || termination === \"no-output-timeout\"\n ? resolvedCode === 0\n ? 124\n : resolvedCode\n : resolvedCode;\n resolve({\n pid: child.pid ?? undefined,\n stdout,\n stderr,\n code: normalizedCode,\n signal: resolvedSignal,\n killed: child.killed,\n termination,\n noOutputTimedOut\n });\n };\n child.on(\"close\", (code, signal) => {\n if (\n !isWindows ||\n childExitState != null ||\n code != null ||\n signal != null ||\n child.exitCode != null ||\n child.signalCode != null\n ) {\n resolveFromClose(code, signal);\n return;\n }\n\n const startedAt = Date.now();\n const waitForExitState = () => {\n if (settled) {\n return;\n }\n if (\n childExitState != null ||\n child.exitCode != null ||\n child.signalCode != null\n ) {\n resolveFromClose(code, signal);\n return;\n }\n if (Date.now() - startedAt >= WINDOWS_CLOSE_STATE_SETTLE_TIMEOUT_MS) {\n resolveFromClose(code, signal);\n return;\n }\n setTimeout(waitForExitState, WINDOWS_CLOSE_STATE_POLL_MS);\n };\n waitForExitState();\n });\n});`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A helper function that executes a command and returns its stdout.\">\n <TSDocParam name=\"argv\">\n {`The command and its arguments to spawn. This is passed directly to the spawn function. Remember that on Windows, commands like \\`npm\\` or \\`pnpm\\` will be resolved to their .cmd shims, so you can just pass \\`npm\\` without worrying about the extension.`}\n </TSDocParam>\n <TSDocParam name=\"optionsOrTimeoutMs\">\n {`The options for spawning the command, or a number representing the timeout in milliseconds. This is passed directly to the spawn function. Providing \\`-1\\` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used.`}\n </TSDocParam>\n <TSDocReturns>\n {\n \"A promise that resolves with the result of the spawn operation if the command exits with code 0, or rejects with an error if the command exits with a non-zero code or if there is a problem spawning the process.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"exec\"\n parameters={[\n { name: \"argv\", type: \"string[]\" },\n {\n name: \"optionsOrTimeoutMs\",\n type: \"number | SpawnOptions\",\n default: \"300000\"\n }\n ]}\n returnType=\"Promise<string>\">\n {code`const spawnResult = await spawn(argv, optionsOrTimeoutMs);\n if (spawnResult.code !== 0) {\n throw Object.assign(new Error(\n \\`Command \"\\${argv.join(\" \")}\" exited with code \\${spawnResult.code} and signal \\${spawnResult.signal}\\`\n ), spawnResult);\n }\n\n return spawnResult.stdout.trim(); `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A helper function that executes a command synchronously and returns its stdout. This is a thin wrapper around \\`child_process.execFileSync\\` with some added Windows compatibility handling.\">\n <TSDocParam name=\"argv\">\n {`The command and its arguments to spawn. This is passed directly to \\`execFileSync\\` after Windows-specific resolution. Remember that on Windows, commands like \\`npm\\` or \\`pnpm\\` will be resolved to their .cmd shims, so you can just pass \\`npm\\` without worrying about the extension.`}\n </TSDocParam>\n <TSDocParam name=\"options\">\n {`The options for spawning the command. This is passed directly to \\`execFileSync\\` after some processing. The timeout option is supported, but note that it will throw an error if the process runs longer than the specified timeout. If no options are provided, a default timeout of 5 minutes will be used.`}\n </TSDocParam>\n <TSDocReturns>\n {\n \"The standard output produced by the command if it exits with code 0. If the command exits with a non-zero code or if there is a problem spawning the process, an error will be thrown.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"execSync\"\n parameters={[\n { name: \"argv\", type: \"string[]\" },\n { name: \"options\", type: \"SpawnOptions\", optional: true }\n ]}\n returnType=\"string\">\n {code`return execFileSync(argv.length > 0 ? argv[0] : \"\", argv.slice(1), {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n timeout: options?.timeoutMs ?? 300000,\n env: options?.env ? resolveCommandEnv({ argv, env: options.env }) : process.env,\n cwd: options?.cwd,\n windowsHide: true,\n windowsVerbatimArguments: options?.windowsVerbatimArguments,\n ...(shouldSpawnWithShell({\n resolvedCommand: argv[0] ?? \"\",\n platform: process.platform\n })\n ? { shell: true }\n : {})\n }).trim(); `}\n </FunctionDeclaration>\n <Spacing />\n\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAAE,YAAiB,OAAA;CACjB,MAAA,CAAA,EACA,YACA,QAAO,WAAW,OAAO,CAAK,WAAW,CAAC;AAC5C,QAAO,gBAAgB,aAAA,WAAA;;EAEvB,aAAiB;EACf,EAAA,MAAA;EACC,IAAK,UAAE;AACP,UAAA,OAAA,KAAA,WAAA,EAAA,EAAA;;;;;;;IAED,WAAA,CAAA,aAAA;IACG,sBAAoB,CAAA;KACvB,MAAA;KACK,OAAS;KACP,EAAE,eAAY;;KAEd,MAAA;KACJ,SAAA;KACK,MAAI;KACR,CAAA;IACC,CAAC;;EAEJ,IAAI,iBAAe;AACjB,UAAO,OAAK,KAAG,kBAAY,EAAA,EAAA,EACzB,KAAK,CAAC,YAAA,EACP,CAAC;;EAEJ,IAAI,WAAC;AACH,UAAO;IAAC,gBAAkB,qBAAmB;KAC3C,MAAA;KACF,YAAc,CAAC;MACb,MAAO;MACN,MAAA;MACF,CAAA;KACC,YAAM;KACN,UAAU,IAAE;;;;;;;;;;;;;;;;;;;;;;;;;;KA0Bf,CAAG;IAAE,gBAAkB,SAAK,EAAM,CAAC;IAAA,gBAAO,qBAAA;KAC9C,MAAA;KACG,YAAA,CAAA;MACF,MAAY;MACZ,MAAY;MACd,CAAA;KACO,YAAa;KACZ,UAAA,IAAA;;;;;;KAMD,CAAC;IAAC,gBAAmB,SAAE,EAAA,CAAA;IAAA,gBAAA,qBAAA;KACtB,MAAM;KACd,YAAA,CAAA;MACU,MAAE;;MAEL,CAAG;KACF,YAAA;KACD,UAAS,IAAA;;;;;;;;;;KAUhB,CAAA;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,qBAAA;KACQ,MAAC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AAM;MACN,MAAM;MACR,EAAA;MACD,MAAS;;MAET,UAAW;MACZ,CAAA;KACH,YAAA;KACH,UAAA,IAAA"}
1
+ {"version":3,"file":"exec-builtin.mjs","names":[],"sources":["../../src/components/exec-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\n\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TSDocParam,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\n\nexport interface ExecBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * A built-in module for handling command execution in Shell Shock.\n */\nexport function ExecBuiltin(props: ExecBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"exec\"\n description=\"A module to handle command execution in a Shell Shock application.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:path\": [\"basename\", \"extname\", \"dirname\", \"join\"],\n \"node:fs\": [\"existsSync\"],\n \"node:child_process\": [\n { name: \"spawn\", alias: \"_spawn\" },\n \"execFileSync\"\n ],\n \"node:stream\": [{ name: \"Stream\", default: true, type: true }]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n env: [\"isWindows\", \"env\", { name: \"Env\", type: true }]\n })}>\n <FunctionDeclaration\n name=\"resolveCommandEnv\"\n parameters={[\n {\n name: \"params\",\n type: \"{ argv: string[]; env?: NodeJS.ProcessEnv; }\"\n }\n ]}\n returnType=\"NodeJS.ProcessEnv\">\n {code`const argv = params.argv;\nconst shouldSuppressNpmFund = (() => {\n const cmd = basename(argv[0] ?? \"\");\n if (cmd === \"npm\" || cmd === \"npm.cmd\" || cmd === \"npm.exe\") {\n return true;\n }\n if (cmd === \"node\" || cmd === \"node.exe\") {\n const script = argv[1] ?? \"\";\n\n return script.includes(\"npm-cli.js\");\n }\n return false;\n})();\n\nconst result = Object.fromEntries(\n Object.entries({\n ...env,\n ...(params.env ?? {})\n})\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => [key, String(value)])\n);\nif (shouldSuppressNpmFund) {\n result.NPM_CONFIG_FUND ??= \"false\";\n result.npm_config_fund ??= \"false\";\n}\nreturn result; `}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"isWindowsBatchCommand\"\n parameters={[{ name: \"resolvedCommand\", type: \"string\" }]}\n returnType=\"boolean\">\n {code`if (!isWindows) {\n return false;\n}\nconst ext = extname(resolvedCommand).toLowerCase();\n\nreturn ext === \".cmd\" || ext === \".bat\";`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"escapeForCmdExe\"\n parameters={[{ name: \"arg\", type: \"string\" }]}\n returnType=\"string\">\n {code`if (/[&|<>^%\\\\\\\\r\\\\\\\\n]/.test(arg)) {\n throw new Error(\n \\`Unsafe Windows cmd.exe argument detected: \\${JSON.stringify(arg)}. \\` +\n \"Pass an explicit shell-wrapper argv at the call site instead.\"\n );\n}\nif (!arg.includes(\" \") && !arg.includes('\"')) {\n return arg;\n}\nreturn \\`\"\\${arg.replace(/\"/g, '\"\"')}\"\\`;`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"buildCmdExeCommandLine\"\n parameters={[\n { name: \"resolvedCommand\", type: \"string\" },\n { name: \"args\", type: \"string[]\" }\n ]}\n returnType=\"string\">\n {code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(\n \" \"\n);`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveNpmArgvForWindows\"\n doc=\"On Windows, Node 18.20.2+ (CVE-2024-27980) rejects spawning .cmd/.bat directly without shell, causing EINVAL. Resolve npm/npx to node + cli script so we spawn node.exe instead of npm.cmd.\"\n parameters={[{ name: \"argv\", type: \"string[]\" }]}\n returnType=\"string[] | null\">\n {code`if (!isWindows || argv.length === 0) {\n return null;\n}\nconst base = basename(argv[0] ?? \"\")\n .toLowerCase()\n .replace(/\\.(?:cmd|exe|bat)$/, \"\");\nconst cliName =\n base === \"npx\" ? \"npx-cli.js\" : base === \"npm\" ? \"npm-cli.js\" : null;\nif (!cliName) {\n return null;\n}\nconst nodeDir = dirname(process.execPath);\nconst cliPath = join(nodeDir, \"node_modules\", \"npm\", \"bin\", cliName);\nif (!existsSync(cliPath)) {\n const command = argv[0] ?? \"\";\n const ext = extname(command).toLowerCase();\n const shimmedCommand = ext ? command : \\`\\${command}.cmd\\`;\n\n return [shimmedCommand, ...argv.slice(1)];\n}\nreturn [process.execPath, cliPath, ...argv.slice(1)];`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveCommand\"\n doc=\"Resolves a command for Windows compatibility. On Windows, non-.exe commands (like pnpm, yarn) are resolved to .cmd; npm/npx are handled by resolveNpmArgvForWindows to avoid spawn EINVAL (no direct .cmd).\"\n parameters={[{ name: \"command\", type: \"string\" }]}\n returnType=\"string\">\n {code`if (!isWindows) {\n return command;\n}\nconst base = basename(command).toLowerCase();\nif (extname(base)) {\n return command;\n}\nif ([\"pnpm\", \"yarn\"].includes(base)) {\n return \\`\\${command}.cmd\\`;\n}\nreturn command;`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveCommandStdio\"\n parameters={[\n {\n name: \"params\",\n type: \"{ hasInput: boolean; preferInherit: boolean; }\"\n }\n ]}\n returnType='[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]'>\n {code`const stdin = params.hasInput\n ? \"pipe\"\n : params.preferInherit\n ? \"inherit\"\n : \"pipe\";\n\nreturn [stdin, \"pipe\", \"pipe\"];`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"resolveProcessExitCode\"\n parameters={[\n {\n name: \"params\",\n type: \"{ explicitCode: number | null | undefined; childExitCode: number | null | undefined; resolvedSignal: NodeJS.Signals | null; usesWindowsExitCodeShim: boolean; timedOut: boolean; noOutputTimedOut: boolean; killIssuedByTimeout: boolean; }\"\n }\n ]}\n returnType=\"number | null\">\n {code`return (\n params.explicitCode ??\n params.childExitCode ??\n (params.usesWindowsExitCodeShim &&\n params.resolvedSignal == null &&\n !params.timedOut &&\n !params.noOutputTimedOut &&\n !params.killIssuedByTimeout\n ? 0\n : null)\n);`}\n </FunctionDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"shouldSpawnWithShell\"\n parameters={[\n {\n name: \"params\",\n type: \"{ resolvedCommand: string; platform: NodeJS.Platform; }\"\n }\n ]}\n returnType=\"boolean\">\n {code`// SECURITY: never enable \\`shell\\` for argv-based execution.\n// \\`shell\\` routes through cmd.exe on Windows, which turns untrusted argv values\n// (like chat prompts passed as CLI args) into command-injection primitives.\n// If you need a shell, use an explicit shell-wrapper argv (e.g. \\`cmd.exe /c ...\\`)\n// and validate/escape at the call site.\nvoid params;\nreturn false;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"The result of a spawn operation.\" />\n <InterfaceDeclaration export name=\"SpawnResult\">\n <TSDoc heading=\"The PID of the spawned child process, if available.\" />\n <InterfaceMember name=\"pid\" optional type=\"number\" />\n <Spacing />\n <TSDoc heading=\"The standard output produced by the child process.\" />\n <InterfaceMember name=\"stdout\" type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The standard error produced by the child process.\" />\n <InterfaceMember name=\"stderr\" type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The exit code of the child process, if available.\" />\n <InterfaceMember name=\"code\" type=\"number | null\" />\n <Spacing />\n <TSDoc heading=\"The signal that caused the child process to terminate, if it was killed by a signal.\" />\n <InterfaceMember name=\"signal\" type=\"NodeJS.Signals | null\" />\n <Spacing />\n <TSDoc heading=\"Whether the child process was killed.\" />\n <InterfaceMember name=\"killed\" type=\"boolean\" />\n <Spacing />\n <TSDoc heading=\"The reason for the child process termination.\" />\n <InterfaceMember\n name=\"termination\"\n type={code`\"exit\" | \"timeout\" | \"no-output-timeout\" | \"signal\"`}\n />\n <Spacing />\n <TSDoc heading=\"Whether the child process timed out due to no output.\" />\n <InterfaceMember name=\"noOutputTimedOut\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Options for spawning a child process.\" />\n <InterfaceDeclaration export name=\"SpawnOptions\">\n <TSDoc heading=\"The timeout in milliseconds for the spawn operation. If the process runs longer than this, it will be killed and the spawn promise will reject. This can also be provided as a number directly to the spawn function for convenience. Providing \\`-1\\` will disable the timeout.\">\n <TSDocDefaultValue\n type={ReflectionKind.number}\n defaultValue=\"300000\"\n />\n </TSDoc>\n <InterfaceMember name=\"timeoutMs\" optional type=\"number\" />\n <Spacing />\n <TSDoc heading=\"The current working directory of the child process.\" />\n <InterfaceMember name=\"cwd\" optional type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The input to be passed to the child process.\" />\n <InterfaceMember name=\"input\" optional type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The environment variables for the child process.\" />\n <InterfaceMember name=\"env\" optional type=\"NodeJS.ProcessEnv\" />\n <Spacing />\n <TSDoc heading=\"Whether to pass arguments to the child process verbatim on Windows.\" />\n <InterfaceMember\n name=\"windowsVerbatimArguments\"\n optional\n type=\"boolean\"\n />\n <Spacing />\n <TSDoc heading=\"The timeout in milliseconds for the child process to produce output on stdout or stderr. If the process produces no output for this duration, it will be killed and the spawn promise will reject with a no-output-timeout termination reason.\" />\n <InterfaceMember name=\"noOutputTimeoutMs\" optional type=\"number\" />\n </InterfaceDeclaration>\n <Spacing />\n <VarDeclaration\n const\n name=\"WINDOWS_CLOSE_STATE_SETTLE_TIMEOUT_MS\"\n initializer={code`250`}\n />\n <Spacing />\n <VarDeclaration\n const\n name=\"WINDOWS_CLOSE_STATE_POLL_MS\"\n initializer={code`10`}\n />\n <Spacing />\n <TSDoc heading=\"Spawns a child process with the given arguments and options, returning a promise that resolves with the result of the spawn operation.\">\n <TSDocParam name=\"argv\">\n {\"The command and its arguments to spawn.\"}\n </TSDocParam>\n <TSDocParam name=\"optionsOrTimeoutMs\">\n {`The options for spawning the command, or a number representing the timeout in milliseconds. This allows for a convenient shorthand when only a timeout is needed. Providing \\`-1\\` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used.`}\n </TSDocParam>\n <TSDocReturns>\n {\n \"A promise that resolves with the result of the spawn operation, including stdout, stderr, exit code, signal, and termination reason.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"spawn\"\n parameters={[\n { name: \"argv\", type: \"string[]\" },\n {\n name: \"optionsOrTimeoutMs\",\n type: \"number | SpawnOptions\",\n default: \"300000\"\n }\n ]}\n returnType=\"Promise<SpawnResult>\">\n {code`const options: SpawnOptions =\n typeof optionsOrTimeoutMs === \"number\"\n ? { timeoutMs: optionsOrTimeoutMs }\n : optionsOrTimeoutMs;\nconst { timeoutMs = 300000, cwd, input, noOutputTimeoutMs } = options;\n\nconst resolvedArgv =\n isWindows\n ? (resolveNpmArgvForWindows(argv) ?? argv)\n : argv;\nconst resolvedCommand =\n resolvedArgv !== argv\n ? (resolvedArgv[0] ?? \"\")\n : resolveCommand(argv[0] ?? \"\");\nconst useCmdWrapper = isWindowsBatchCommand(resolvedCommand);\n\nconst child = _spawn(\n useCmdWrapper\n ? (env.COMSPEC ?? \"cmd.exe\")\n : resolvedCommand,\n useCmdWrapper\n ? [\n \"/d\",\n \"/s\",\n \"/c\",\n buildCmdExeCommandLine(resolvedCommand, resolvedArgv.slice(1))\n ]\n : resolvedArgv.slice(1), {\n stdio: resolveCommandStdio({ hasInput: input !== undefined, preferInherit: true }),\n cwd,\n env: resolveCommandEnv({ argv, env: options.env }),\n windowsHide: true,\n windowsVerbatimArguments: useCmdWrapper\n ? true\n : options.windowsVerbatimArguments,\n ...(shouldSpawnWithShell({\n resolvedCommand: useCmdWrapper\n ? (env.COMSPEC ?? \"cmd.exe\")\n : resolvedCommand,\n platform: process.platform\n })\n ? { shell: true }\n : {})\n});\n\nreturn new Promise((resolve, reject) => {\n let stdout = \"\";\n let stderr = \"\";\n let settled = false;\n let timedOut = false;\n let noOutputTimedOut = false;\n let killIssuedByTimeout = false;\n let childExitState: {\n code: number | null;\n signal: NodeJS.Signals | null;\n } | null = null;\n let closeFallbackTimer: NodeJS.Timeout | null = null;\n let noOutputTimer: NodeJS.Timeout | null = null;\n const shouldTrackOutputTimeout =\n typeof noOutputTimeoutMs === \"number\" &&\n Number.isFinite(noOutputTimeoutMs) &&\n noOutputTimeoutMs > 0;\n\n const clearNoOutputTimer = () => {\n if (!noOutputTimer) {\n return;\n }\n clearTimeout(noOutputTimer);\n noOutputTimer = null;\n };\n\n const clearCloseFallbackTimer = () => {\n if (!closeFallbackTimer) {\n return;\n }\n clearTimeout(closeFallbackTimer);\n closeFallbackTimer = null;\n };\n\n const killChild = () => {\n if (settled || typeof child?.kill !== \"function\") {\n return;\n }\n killIssuedByTimeout = true;\n child.kill(\"SIGKILL\");\n };\n\n const armNoOutputTimer = () => {\n if (!shouldTrackOutputTimeout || settled) {\n return;\n }\n clearNoOutputTimer();\n noOutputTimer = setTimeout(() => {\n if (settled) {\n return;\n }\n noOutputTimedOut = true;\n killChild();\n }, Math.floor(noOutputTimeoutMs));\n };\n\n const timer = setTimeout(() => {\n timedOut = true;\n killChild();\n }, timeoutMs >= 0 ? timeoutMs : Number.POSITIVE_INFINITY);\n armNoOutputTimer();\n\n if (input !== undefined && child.stdin) {\n child.stdin.write(input ?? \"\");\n child.stdin.end();\n }\n\n child.stdout?.on(\"data\", (d: Stream) => {\n stdout += d.toString();\n armNoOutputTimer();\n });\n child.stderr?.on(\"data\", (d: Stream) => {\n stderr += d.toString();\n armNoOutputTimer();\n });\n child.on(\"error\", err => {\n if (settled) {\n return;\n }\n settled = true;\n clearTimeout(timer);\n clearNoOutputTimer();\n clearCloseFallbackTimer();\n reject(err);\n });\n child.on(\"exit\", (code, signal) => {\n childExitState = { code, signal };\n if (settled || closeFallbackTimer) {\n return;\n }\n closeFallbackTimer = setTimeout(() => {\n if (settled) {\n return;\n }\n child.stdout?.destroy();\n child.stderr?.destroy();\n }, 250);\n });\n const resolveFromClose = (\n code: number | null,\n signal: NodeJS.Signals | null\n ) => {\n if (settled) {\n return;\n }\n settled = true;\n clearTimeout(timer);\n clearNoOutputTimer();\n clearCloseFallbackTimer();\n const resolvedSignal =\n childExitState?.signal ?? signal ?? child.signalCode ?? null;\n const resolvedCode = resolveProcessExitCode({\n explicitCode: childExitState?.code ?? code,\n childExitCode: child.exitCode,\n resolvedSignal,\n usesWindowsExitCodeShim: isWindows && (useCmdWrapper || resolvedArgv !== argv),\n timedOut,\n noOutputTimedOut,\n killIssuedByTimeout\n });\n const termination = noOutputTimedOut\n ? \"no-output-timeout\"\n : timedOut\n ? \"timeout\"\n : resolvedSignal != null\n ? \"signal\"\n : \"exit\";\n const normalizedCode =\n termination === \"timeout\" || termination === \"no-output-timeout\"\n ? resolvedCode === 0\n ? 124\n : resolvedCode\n : resolvedCode;\n resolve({\n pid: child.pid ?? undefined,\n stdout,\n stderr,\n code: normalizedCode,\n signal: resolvedSignal,\n killed: child.killed,\n termination,\n noOutputTimedOut\n });\n };\n child.on(\"close\", (code, signal) => {\n if (\n !isWindows ||\n childExitState != null ||\n code != null ||\n signal != null ||\n child.exitCode != null ||\n child.signalCode != null\n ) {\n resolveFromClose(code, signal);\n return;\n }\n\n const startedAt = Date.now();\n const waitForExitState = () => {\n if (settled) {\n return;\n }\n if (\n childExitState != null ||\n child.exitCode != null ||\n child.signalCode != null\n ) {\n resolveFromClose(code, signal);\n return;\n }\n if (Date.now() - startedAt >= WINDOWS_CLOSE_STATE_SETTLE_TIMEOUT_MS) {\n resolveFromClose(code, signal);\n return;\n }\n setTimeout(waitForExitState, WINDOWS_CLOSE_STATE_POLL_MS);\n };\n waitForExitState();\n });\n});`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A helper function that executes a command and returns its stdout.\">\n <TSDocParam name=\"argv\">\n {`The command and its arguments to spawn. This is passed directly to the spawn function. Remember that on Windows, commands like \\`npm\\` or \\`pnpm\\` will be resolved to their .cmd shims, so you can just pass \\`npm\\` without worrying about the extension.`}\n </TSDocParam>\n <TSDocParam name=\"optionsOrTimeoutMs\">\n {`The options for spawning the command, or a number representing the timeout in milliseconds. This is passed directly to the spawn function. Providing \\`-1\\` will disable the timeout. If no options or timeout are provided, a default timeout of 5 minutes will be used.`}\n </TSDocParam>\n <TSDocReturns>\n {\n \"A promise that resolves with the result of the spawn operation if the command exits with code 0, or rejects with an error if the command exits with a non-zero code or if there is a problem spawning the process.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"exec\"\n parameters={[\n { name: \"argv\", type: \"string[]\" },\n {\n name: \"optionsOrTimeoutMs\",\n type: \"number | SpawnOptions\",\n default: \"300000\"\n }\n ]}\n returnType=\"Promise<string>\">\n {code`const spawnResult = await spawn(argv, optionsOrTimeoutMs);\n if (spawnResult.code !== 0) {\n throw Object.assign(new Error(\n \\`Command \"\\${argv.join(\" \")}\" exited with code \\${spawnResult.code} and signal \\${spawnResult.signal}\\`\n ), spawnResult);\n }\n\n return spawnResult.stdout.trim(); `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A helper function that executes a command synchronously and returns its stdout. This is a thin wrapper around \\`child_process.execFileSync\\` with some added Windows compatibility handling.\">\n <TSDocParam name=\"argv\">\n {`The command and its arguments to spawn. This is passed directly to \\`execFileSync\\` after Windows-specific resolution. Remember that on Windows, commands like \\`npm\\` or \\`pnpm\\` will be resolved to their .cmd shims, so you can just pass \\`npm\\` without worrying about the extension.`}\n </TSDocParam>\n <TSDocParam name=\"options\">\n {`The options for spawning the command. This is passed directly to \\`execFileSync\\` after some processing. The timeout option is supported, but note that it will throw an error if the process runs longer than the specified timeout. If no options are provided, a default timeout of 5 minutes will be used.`}\n </TSDocParam>\n <TSDocReturns>\n {\n \"The standard output produced by the command if it exits with code 0. If the command exits with a non-zero code or if there is a problem spawning the process, an error will be thrown.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"execSync\"\n parameters={[\n { name: \"argv\", type: \"string[]\" },\n { name: \"options\", type: \"SpawnOptions\", default: \"{}\" }\n ]}\n returnType=\"string\">\n {code`return execFileSync(argv.length > 0 ? argv[0] : \"\", argv.slice(1), {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n timeout: options.timeoutMs ?? 300000,\n env: resolveCommandEnv({ argv, env: options.env }),\n cwd: options.cwd || process.cwd(),\n windowsHide: true\n }).trim(); `}\n </FunctionDeclaration>\n <Spacing />\n\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAAE,YAAiB,OAAA;CACjB,MAAA,CAAA,EACA,YACA,QAAO,WAAW,OAAO,CAAK,WAAW,CAAC;AAC5C,QAAO,gBAAgB,aAAA,WAAA;;EAEvB,aAAiB;EACf,EAAA,MAAA;EACC,IAAK,UAAE;AACP,UAAA,OAAA,KAAA,WAAA,EAAA,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgOD,CAAC;IAAE,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,OAAA;KACF,SAAC;KACD,IAAA,WAAY;AACX,aAAK;OAAA,gBAAoB,YAAY;QAClC,MAAE;QACF,UAAM;QACP,CAAC;OAAE,gBAAkB,YAAY;QAChC,MAAG;QACL,UAAA;;uCAEA,UAAO,sNACT,CAAA;OAAA;;KAED,CAAA;IAAA,gBAAiB,qBAAqB;KACrC,UAAC;KACD,OAAO;KACP,MAAE;KACF,YAAY,CAAA;MACV,MAAM;MACN,MAAA;MACD,EAAA;MACC,MAAA;MACA,MAAM;MACN,SAAA;MACD,CAAC;KACF,YAAK;KACN,UAAA,IAAA;;;;;;;;KAQA,CAAC;IAAC,gBAAY,SAAa,EAAK,CAAA;IAAA,gBAAqB,OAAM;KAC1D,SAAE;KACF,IAAE,WAAS;AACT,aAAO;OAAC,gBAAkB,YAAU;QACpC,MAAK;QACL,UAAY;QACZ,CAAA;OAAA,gBAAa,YAAA;QACZ,MAAO;QACV,UAAA;QACD,CAAA;OAAO,gBAAE,cAAA,sMAEL,CAAC;OAAA;;KAET,CAAA;IAAA,gBAAA,qBAAA;KACH,UAAA"}
@@ -592,8 +592,8 @@ function OptionsInterfaceDeclaration(props) {
592
592
  * The command options parser logic.
593
593
  */
594
594
  function OptionsParserLogic(props) {
595
- const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;
596
- const options = (0, _alloy_js_core.computed)(() => require_contexts_options.computedOptions(Object.entries(command.options).map(([name, option]) => ({
595
+ const { segments = [], options: _options, name: _name, appSpecificEnvPrefix, isCaseSensitive = false } = props;
596
+ const options = (0, _alloy_js_core.computed)(() => require_contexts_options.computedOptions(Object.entries(_options).map(([name, option]) => ({
597
597
  ...option,
598
598
  name
599
599
  }))));
@@ -603,17 +603,17 @@ function OptionsParserLogic(props) {
603
603
  name: "options",
604
604
  get initializer() {
605
605
  return _alloy_js_core.code` {
606
- ${Object.entries(options.value).filter(([, option]) => option.env || option.default !== void 0 || (option.kind === require_types_command.CommandParameterKinds.string || option.kind === require_types_command.CommandParameterKinds.number) && option.variadic).map(([name, option]) => {
606
+ ${segments.length > 0 ? "...useGlobalOptions(), " : ""}${Object.entries(options.value).filter(([, option]) => option.env || option.default !== void 0 || (option.kind === require_types_command.CommandParameterKinds.string || option.kind === require_types_command.CommandParameterKinds.number) && option.variadic).map(([name, option]) => {
607
607
  if (option.kind === require_types_command.CommandParameterKinds.string) return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default !== void 0 ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}"${option.default}"` : ""}, `;
608
608
  else if (option.kind === require_types_command.CommandParameterKinds.number) return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default && Array.isArray(option.default) ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}${option.default}` : ""}, `;
609
609
  else if (option.kind === require_types_command.CommandParameterKinds.boolean) return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env} ?? ` : ""}${option.default ? "true" : "false"},`;
610
610
  return "";
611
611
  }).join("")}
612
- } as unknown as ${(0, _stryke_string_format_pascal_case.pascalCase)(command.name)}Options;`;
612
+ } as unknown as ${segments.length > 0 ? (0, _stryke_string_format_pascal_case.pascalCase)(_name) : "Global"}Options;`;
613
613
  }
614
614
  }),
615
615
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
616
- (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`for (let i = 0; i < args.slice(${command.segments.filter((segment) => require_context_helpers.isDynamicPathSegment(segment)).length}).length; i++) { `),
616
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`for (let i = 0; i < args.slice(${segments.filter((segment) => require_context_helpers.isDynamicPathSegment(segment)).length}).length; i++) { `),
617
617
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
618
618
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
619
619
  "const": true,
@@ -692,7 +692,15 @@ function CommandParserLogic(props) {
692
692
  }),
693
693
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
694
694
  (0, _alloy_js_core_jsx_runtime.createComponent)(OptionsParserLogic, {
695
- command,
695
+ get name() {
696
+ return command.name;
697
+ },
698
+ get options() {
699
+ return command.options;
700
+ },
701
+ get segments() {
702
+ return command.segments;
703
+ },
696
704
  appSpecificEnvPrefix,
697
705
  isCaseSensitive
698
706
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"options-parser-logic.cjs","names":[],"sources":["../../src/components/options-parser-logic.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { computedOptions } from \"../contexts/options\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { BooleanInputParserLogic, CommandParameterType } from \"./helpers\";\n\nexport interface DynamicSegmentsParserLogicProps {\n /**\n * The command to generate the dynamic path segments parser logic for. This is used to access the command options and parameters when generating the parser logic for dynamic path segments.\n */\n command: CommandTree;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function DynamicSegmentsParserLogic(\n props: DynamicSegmentsParserLogicProps\n) {\n const { command } = props;\n\n return (\n <For each={command.segments ?? []}>\n {(segment, index) => (\n <Show when={isDynamicPathSegment(segment)}>\n <VarDeclaration\n let\n name={camelCase(getDynamicPathSegmentName(segment))}\n type=\"string | undefined\"\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${2 + index} && args[${2 + index}]`}>\n {code`${camelCase(\n getDynamicPathSegmentName(segment)\n )} = args[${2 + index}];`}\n </IfStatement>\n <hbr />\n <hbr />\n </Show>\n )}\n </For>\n );\n}\n\nexport interface ArgumentsParserLogicProps {\n /**\n * The command to generate the positional parameters parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function ArgumentsParserLogic(props: ArgumentsParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive } = props;\n\n return (\n <Show when={command.args && command.args.length > 0}>\n <VarDeclaration\n let\n name=\"optionsIndex\"\n type=\"number\"\n initializer={code`Math.max(0, args.slice(${\n command.segments.length + 1\n }).findIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1};`}\n />\n <Spacing />\n <VarDeclaration\n let\n name=\"argsIndex\"\n type=\"number\"\n initializer={code`optionsIndex > ${\n command.segments.length + 1\n } ? ${command.segments.length + 1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1});`}\n />\n <Spacing />\n <For each={command.args ?? []} hardline>\n {(arg, index) => (\n <>\n <Show\n when={\n isSetString(arg.env) ||\n arg.default !== undefined ||\n ((arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic)\n }\n fallback={\n <>\n {code`let ${camelCase(arg.name)}!: `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }>\n <VarDeclaration\n let\n name={camelCase(arg.name)}\n type={<CommandParameterType parameter={arg} />}\n initializer={\n <>\n {code` ( `}\n <Show when={isSetString(arg.env)}>\n {code`env.${appSpecificEnvPrefix}_${constantCase(String(arg.env))} ?? `}\n </Show>\n <Show\n when={arg.default !== undefined}\n fallback={arg.variadic ? code`[]` : code`undefined`}>\n {arg.kind === CommandParameterKinds.string\n ? code`\"${arg.default}\"`\n : code`${arg.default}`}\n </Show>\n {code`) as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }\n />\n </Show>\n <Spacing />\n <IfStatement\n condition={code`argsIndex + ${index} < args.length && argsIndex + ${index} !== optionsIndex`}>\n {code`${camelCase(arg.name)} = `}\n <Show\n when={\n arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number\n }\n fallback={\n <BooleanInputParserLogic\n name={`args[argsIndex + ${index}] `}\n />\n }>\n <Show\n when={arg.variadic}\n fallback={\n <Show\n when={arg.kind === CommandParameterKinds.number}\n fallback={code`args[argsIndex + ${index}] `}>\n {code`Number(args[argsIndex + ${index}]) `}\n </Show>\n }>\n {code`args.slice(argsIndex + ${\n index\n }, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${\n command.args.length - index\n }).join(\" \").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean)`}\n </Show>\n </Show>\n {code` as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </IfStatement>\n <Spacing />\n </>\n )}\n </For>\n </Show>\n );\n}\n\n/**\n * The command option interface property.\n */\nexport function OptionsMember({ option }: { option: CommandOption }) {\n const doc = option.description || `The ${option.title} command option.`;\n\n return (\n <>\n <Show when={Boolean(option.name)}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserLogicProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * The command option to generate the parser logic for.\n */\n option: CommandOption;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\n/**\n * The command option property parser logic.\n */\nexport function OptionsMemberParserLogic(props: OptionsMemberParserLogicProps) {\n const { name, option, isCaseSensitive } = props;\n\n const equalsRegex = `/^--?(${\n isCaseSensitive || name.length === 1\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")})=/`;\n\n return (\n <>\n <Show\n when={\n option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number\n }>\n <Show\n when={\n (option as StringCommandParameter | NumberCommandParameter).variadic\n }>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} ??= []; `}>\n {code`options[\"${name}\"] ??= []; `}\n </Show>\n <hbr />\n <IfStatement\n condition={`${equalsRegex}.test(${\n isCaseSensitive\n ? \"arg\"\n : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n })`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </ElseIfClause>\n </Show>\n <Show\n when={\n !(option as StringCommandParameter | NumberCommandParameter)\n .variadic\n }>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices\n ?.map(choice => `\"${choice}\"`)\n .join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices?.map(choice => `\"${choice}\"`).join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </ElseIfClause>\n <hbr />\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\").toLowerCase(); `}\n />\n <hbr />\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = `}>\n {code`options[\"${name}\"] = `}\n </Show>\n <BooleanInputParserLogic name=\"value\" />\n </IfStatement>\n <ElseClause>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = true; `}>\n {code`options[\"${name}\"] = true; `}\n </Show>\n </ElseClause>\n <Show when={Boolean((option as BooleanCommandOption).isNegativeOf)}>\n <hbr />\n <Show\n when={\n (option as BooleanCommandOption).isNegativeOf!.includes(\"?\") ||\n (option as BooleanCommandOption).isNegativeOf!.includes(\"-\")\n }\n fallback={code`options.${(option as BooleanCommandOption).isNegativeOf} = false; `}>\n {code`options[\"${(option as BooleanCommandOption).isNegativeOf}\"] = false; `}\n </Show>\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserConditionProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * Aliases for the option, which will also be parsed in the generated code. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n alias?: string[];\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\nexport function OptionsMemberParserCondition(\n props: OptionsMemberParserConditionProps\n) {\n const { name, alias: aliasProp, isCaseSensitive } = props;\n\n return (\n <>\n {code`${\n isCaseSensitive\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`}\n <Show when={aliasProp && aliasProp.length > 0}>\n <For each={aliasProp ?? []}>\n {alias =>\n code` || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`\n }\n </For>\n </Show>\n </>\n );\n}\n\nexport function OptionsInterfaceDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(command.options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <InterfaceDeclaration\n export\n name={`${pascalCase(command.name)}Options`}\n extends=\"GlobalOptions\">\n <For each={Object.values(options.value)} hardline>\n {option => <OptionsMember option={option} />}\n </For>\n </InterfaceDeclaration>\n );\n}\n\nexport interface OptionsParserLogicProps {\n /**\n * The command to generate the options parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command options parser logic.\n */\nexport function OptionsParserLogic(props: OptionsParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(command.options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <>\n <VarDeclaration\n const\n name=\"options\"\n initializer={code` {\n ${Object.entries(options.value)\n .filter(\n ([, option]) =>\n option.env ||\n option.default !== undefined ||\n ((option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic)\n )\n .map(([name, option]) => {\n if (option.kind === CommandParameterKinds.string) {\n return ` ${\n name.includes(\"?\") || name.includes(\"-\")\n ? `\"${name}\"`\n : `${name}`\n }: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default !== undefined\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}\"${option.default}\"`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.number) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default && Array.isArray(option.default)\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}${option.default}`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.boolean) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env\n ? `env.${appSpecificEnvPrefix}_${option.env} ?? `\n : \"\"\n }${option.default ? \"true\" : \"false\"},`;\n }\n\n return \"\";\n })\n .join(\"\")}\n } as unknown as ${pascalCase(command.name)}Options;`}\n />\n <Spacing />\n {code`for (let i = 0; i < args.slice(${\n command.segments.filter(segment => isDynamicPathSegment(segment)).length\n }).length; i++) { `}\n <hbr />\n <VarDeclaration\n const\n name=\"arg\"\n type=\"string\"\n initializer={code` args[i].length > 3 && args[i].startsWith(\"--\")\n ? \\`--\\${args[i].slice(2).replaceAll(\"-\", \"\")${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }}\\`\n : args[i].length > 2 && args[i].startsWith(\"-\")\n ? \\`-\\${args[i].slice(1).replaceAll(\"-\", \"\")}\\`\n : args[i]; `}\n />\n <hbr />\n\n <For each={Object.entries(options.value)} hardline>\n {([name, option], i) => (\n <Show\n when={i === 0}\n fallback={\n <ElseIfClause\n condition={\n <>\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n </>\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </ElseIfClause>\n }>\n <IfStatement\n condition={\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </IfStatement>\n </Show>\n )}\n </For>\n\n <hbr />\n {code` } `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandParserLogicProps {\n /**\n * The command to generate the parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.\n */\nexport function CommandParserLogic(props: CommandParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;\n\n return (\n <>\n <DynamicSegmentsParserLogic\n command={command}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <OptionsParserLogic\n command={command}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <ArgumentsParserLogic\n command={command}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,SAAE,2BAAA,OAAA;CACA,MAAM,EACR,YACM;;EAEN,IAAO,OAAA;AACH,UAAA,QAAA,YAAA,EAAA;;EAEA,WAAA,SAAA,0DAAA,qBAAA;GACF,IAAQ,OAAC;;;GAGN,IAAA,WAAY;AACb,WAAA;qDAAA,qCAAA;MACF,OAAe;MACjB,IAAA,OAAA;;;MAGS,MAAA;MACP,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,kCAAA;MACQ,WAAW,mBAAC,iBAAK,IAAA,MAAA,WAAA,IAAA,MAAA;;A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AAC;kDAAoB,0DAAQ,EAAA,CAAA;kDAAsB,sBAAwB;GACjE;GACa;GACL;GAClB,CAAC;kDAAe,0DAAc,EAAE,CAAC;EAAC"}
1
+ {"version":3,"file":"options-parser-logic.cjs","names":[],"sources":["../../src/components/options-parser-logic.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { PartialKeys } from \"@stryke/types/base\";\nimport { computedOptions } from \"../contexts/options\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { BooleanInputParserLogic, CommandParameterType } from \"./helpers\";\n\nexport interface DynamicSegmentsParserLogicProps {\n /**\n * The command to generate the dynamic path segments parser logic for. This is used to access the command options and parameters when generating the parser logic for dynamic path segments.\n */\n command: CommandTree;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function DynamicSegmentsParserLogic(\n props: DynamicSegmentsParserLogicProps\n) {\n const { command } = props;\n\n return (\n <For each={command.segments ?? []}>\n {(segment, index) => (\n <Show when={isDynamicPathSegment(segment)}>\n <VarDeclaration\n let\n name={camelCase(getDynamicPathSegmentName(segment))}\n type=\"string | undefined\"\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${2 + index} && args[${2 + index}]`}>\n {code`${camelCase(\n getDynamicPathSegmentName(segment)\n )} = args[${2 + index}];`}\n </IfStatement>\n <hbr />\n <hbr />\n </Show>\n )}\n </For>\n );\n}\n\nexport interface ArgumentsParserLogicProps {\n /**\n * The command to generate the positional parameters parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function ArgumentsParserLogic(props: ArgumentsParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive } = props;\n\n return (\n <Show when={command.args && command.args.length > 0}>\n <VarDeclaration\n let\n name=\"optionsIndex\"\n type=\"number\"\n initializer={code`Math.max(0, args.slice(${\n command.segments.length + 1\n }).findIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1};`}\n />\n <Spacing />\n <VarDeclaration\n let\n name=\"argsIndex\"\n type=\"number\"\n initializer={code`optionsIndex > ${\n command.segments.length + 1\n } ? ${command.segments.length + 1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1});`}\n />\n <Spacing />\n <For each={command.args ?? []} hardline>\n {(arg, index) => (\n <>\n <Show\n when={\n isSetString(arg.env) ||\n arg.default !== undefined ||\n ((arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic)\n }\n fallback={\n <>\n {code`let ${camelCase(arg.name)}!: `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }>\n <VarDeclaration\n let\n name={camelCase(arg.name)}\n type={<CommandParameterType parameter={arg} />}\n initializer={\n <>\n {code` ( `}\n <Show when={isSetString(arg.env)}>\n {code`env.${appSpecificEnvPrefix}_${constantCase(String(arg.env))} ?? `}\n </Show>\n <Show\n when={arg.default !== undefined}\n fallback={arg.variadic ? code`[]` : code`undefined`}>\n {arg.kind === CommandParameterKinds.string\n ? code`\"${arg.default}\"`\n : code`${arg.default}`}\n </Show>\n {code`) as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }\n />\n </Show>\n <Spacing />\n <IfStatement\n condition={code`argsIndex + ${index} < args.length && argsIndex + ${index} !== optionsIndex`}>\n {code`${camelCase(arg.name)} = `}\n <Show\n when={\n arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number\n }\n fallback={\n <BooleanInputParserLogic\n name={`args[argsIndex + ${index}] `}\n />\n }>\n <Show\n when={arg.variadic}\n fallback={\n <Show\n when={arg.kind === CommandParameterKinds.number}\n fallback={code`args[argsIndex + ${index}] `}>\n {code`Number(args[argsIndex + ${index}]) `}\n </Show>\n }>\n {code`args.slice(argsIndex + ${\n index\n }, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${\n command.args.length - index\n }).join(\" \").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean)`}\n </Show>\n </Show>\n {code` as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </IfStatement>\n <Spacing />\n </>\n )}\n </For>\n </Show>\n );\n}\n\n/**\n * The command option interface property.\n */\nexport function OptionsMember({ option }: { option: CommandOption }) {\n const doc = option.description || `The ${option.title} command option.`;\n\n return (\n <>\n <Show when={Boolean(option.name)}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserLogicProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * The command option to generate the parser logic for.\n */\n option: CommandOption;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\n/**\n * The command option property parser logic.\n */\nexport function OptionsMemberParserLogic(props: OptionsMemberParserLogicProps) {\n const { name, option, isCaseSensitive } = props;\n\n const equalsRegex = `/^--?(${\n isCaseSensitive || name.length === 1\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")})=/`;\n\n return (\n <>\n <Show\n when={\n option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number\n }>\n <Show\n when={\n (option as StringCommandParameter | NumberCommandParameter).variadic\n }>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} ??= []; `}>\n {code`options[\"${name}\"] ??= []; `}\n </Show>\n <hbr />\n <IfStatement\n condition={`${equalsRegex}.test(${\n isCaseSensitive\n ? \"arg\"\n : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n })`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </ElseIfClause>\n </Show>\n <Show\n when={\n !(option as StringCommandParameter | NumberCommandParameter)\n .variadic\n }>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices\n ?.map(choice => `\"${choice}\"`)\n .join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices?.map(choice => `\"${choice}\"`).join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </ElseIfClause>\n <hbr />\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\").toLowerCase(); `}\n />\n <hbr />\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = `}>\n {code`options[\"${name}\"] = `}\n </Show>\n <BooleanInputParserLogic name=\"value\" />\n </IfStatement>\n <ElseClause>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = true; `}>\n {code`options[\"${name}\"] = true; `}\n </Show>\n </ElseClause>\n <Show when={Boolean((option as BooleanCommandOption).isNegativeOf)}>\n <hbr />\n <Show\n when={\n (option as BooleanCommandOption).isNegativeOf!.includes(\"?\") ||\n (option as BooleanCommandOption).isNegativeOf!.includes(\"-\")\n }\n fallback={code`options.${(option as BooleanCommandOption).isNegativeOf} = false; `}>\n {code`options[\"${(option as BooleanCommandOption).isNegativeOf}\"] = false; `}\n </Show>\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserConditionProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * Aliases for the option, which will also be parsed in the generated code. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n alias?: string[];\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\nexport function OptionsMemberParserCondition(\n props: OptionsMemberParserConditionProps\n) {\n const { name, alias: aliasProp, isCaseSensitive } = props;\n\n return (\n <>\n {code`${\n isCaseSensitive\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`}\n <Show when={aliasProp && aliasProp.length > 0}>\n <For each={aliasProp ?? []}>\n {alias =>\n code` || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`\n }\n </For>\n </Show>\n </>\n );\n}\n\nexport function OptionsInterfaceDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(command.options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <InterfaceDeclaration\n export\n name={`${pascalCase(command.name)}Options`}\n extends=\"GlobalOptions\">\n <For each={Object.values(options.value)} hardline>\n {option => <OptionsMember option={option} />}\n </For>\n </InterfaceDeclaration>\n );\n}\n\nexport interface OptionsParserLogicProps extends PartialKeys<\n Pick<CommandTree, \"segments\" | \"options\" | \"name\">,\n \"segments\" | \"name\"\n> {\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command options parser logic.\n */\nexport function OptionsParserLogic(props: OptionsParserLogicProps) {\n const {\n segments = [],\n options: _options,\n name: _name,\n appSpecificEnvPrefix,\n isCaseSensitive = false\n } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(_options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <>\n <VarDeclaration\n const\n name=\"options\"\n initializer={code` {\n ${\n segments.length > 0 ? \"...useGlobalOptions(), \" : \"\"\n }${Object.entries(options.value)\n .filter(\n ([, option]) =>\n option.env ||\n option.default !== undefined ||\n ((option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic)\n )\n .map(([name, option]) => {\n if (option.kind === CommandParameterKinds.string) {\n return ` ${\n name.includes(\"?\") || name.includes(\"-\")\n ? `\"${name}\"`\n : `${name}`\n }: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default !== undefined\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}\"${option.default}\"`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.number) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default && Array.isArray(option.default)\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}${option.default}`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.boolean) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env\n ? `env.${appSpecificEnvPrefix}_${option.env} ?? `\n : \"\"\n }${option.default ? \"true\" : \"false\"},`;\n }\n\n return \"\";\n })\n .join(\"\")}\n } as unknown as ${segments.length > 0 ? pascalCase(_name) : \"Global\"}Options;`}\n />\n <Spacing />\n {code`for (let i = 0; i < args.slice(${\n segments.filter(segment => isDynamicPathSegment(segment)).length\n }).length; i++) { `}\n <hbr />\n <VarDeclaration\n const\n name=\"arg\"\n type=\"string\"\n initializer={code` args[i].length > 3 && args[i].startsWith(\"--\")\n ? \\`--\\${args[i].slice(2).replaceAll(\"-\", \"\")${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }}\\`\n : args[i].length > 2 && args[i].startsWith(\"-\")\n ? \\`-\\${args[i].slice(1).replaceAll(\"-\", \"\")}\\`\n : args[i]; `}\n />\n <hbr />\n <For each={Object.entries(options.value)} hardline>\n {([name, option], i) => (\n <Show\n when={i === 0}\n fallback={\n <ElseIfClause\n condition={\n <>\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n </>\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </ElseIfClause>\n }>\n <IfStatement\n condition={\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </IfStatement>\n </Show>\n )}\n </For>\n <hbr />\n {code` } `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandParserLogicProps {\n /**\n * The command to generate the parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.\n */\nexport function CommandParserLogic(props: CommandParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;\n\n return (\n <>\n <DynamicSegmentsParserLogic\n command={command}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <OptionsParserLogic\n name={command.name}\n options={command.options}\n segments={command.segments}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <ArgumentsParserLogic\n command={command}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2CA,SAAE,2BAAA,OAAA;CACA,MAAM,EACR,YACM;;EAEN,IAAO,OAAA;AACH,UAAA,QAAA,YAAA,EAAA;;EAEA,WAAA,SAAA,0DAAA,qBAAA;GACF,IAAQ,OAAC;;;GAGN,IAAA,WAAY;AACb,WAAA;qDAAA,qCAAA;MACF,OAAe;MACjB,IAAA,OAAA;;;MAGS,MAAA;MACP,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,kCAAA;MACQ,WAAW,mBAAC,iBAAK,IAAA,MAAA,WAAA,IAAA,MAAA;;AAElB,cAAA,mBAAA,mDAAA,kDAAA,QAAA,CAAA,CAAA,UAAA,IAAA,MAAA;;MAED,CAAA;qDAAmB,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;KAAA;;GAEtB,CAAC;EACH,CAAC;;;CAmBJ,MAAO,EACH,SACA,sBACA,oBACF;;EAEE,IAAA,OAAA;AACC,UAAI,QAAY,QAAQ,QAAQ,KAAG,SAAQ;;EAE9C,IAAA,WAAA;;;KAEE,OAAA;KACC,MAAQ;KACT,MAAA;KACF,IAAA,cAAwB;AAC1B,aAAA,mBAAA,0BAAA,QAAA,SAAA,SAAA,EAAA,+CAAA,OAAA,OAAA,QAAA,WAAA,EAAA,CAAA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