@shell-shock/core 0.17.8 → 0.17.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/api.cjs +148 -1
- package/dist/api.d.cts +6 -6
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +6 -6
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +145 -1
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +292 -1
- package/dist/components/command-validation-logic.mjs +289 -1
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +265 -1
- package/dist/components/docs.mjs +256 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +429 -13
- package/dist/components/exec-builtin.mjs +425 -13
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/helpers.cjs +120 -1
- package/dist/components/helpers.mjs +112 -1
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +58 -1
- package/dist/components/index.mjs +10 -1
- package/dist/components/options-parser-logic.cjs +960 -5
- package/dist/components/options-parser-logic.d.cts +1 -1
- package/dist/components/options-parser-logic.mjs +945 -5
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +629 -8
- package/dist/components/state-builtin.mjs +622 -8
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/usage.cjs +117 -1
- package/dist/components/usage.mjs +114 -1
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +838 -33
- package/dist/components/utils-builtin.mjs +828 -33
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +31 -1
- package/dist/config.mjs +29 -1
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +26 -1
- package/dist/contexts/command.mjs +23 -1
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/index.cjs +9 -1
- package/dist/contexts/index.mjs +4 -1
- package/dist/contexts/options.cjs +63 -1
- package/dist/contexts/options.mjs +58 -1
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +71 -1
- package/dist/helpers/automd.mjs +70 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +23 -1
- package/dist/helpers/docs-helpers.mjs +22 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +137 -1
- package/dist/helpers/paths.mjs +133 -1
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +115 -1
- package/dist/helpers/persistence.mjs +112 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +65 -1
- package/dist/helpers/update-package-json.mjs +63 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +95 -1
- package/dist/helpers/utilities.mjs +93 -1
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +71 -1
- package/dist/helpers/validations.mjs +71 -1
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +53 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +7 -1
- package/dist/plugin-utils/compute-bin.cjs +50 -1
- package/dist/plugin-utils/compute-bin.mjs +49 -1
- package/dist/plugin-utils/compute-bin.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +231 -1
- package/dist/plugin-utils/context-helpers.mjs +221 -1
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +71 -1
- package/dist/plugin-utils/deepkit.mjs +69 -1
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +111 -2
- package/dist/plugin-utils/description-helpers.mjs +107 -2
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +117 -1
- package/dist/plugin-utils/get-command-tree.mjs +114 -1
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +39 -1
- package/dist/plugin-utils/index.mjs +10 -1
- package/dist/plugin-utils/reflect.cjs +52 -1
- package/dist/plugin-utils/reflect.mjs +52 -1
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +64 -1
- package/dist/plugin-utils/traverse-command-tree.mjs +62 -1
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +93 -1
- package/dist/plugin-utils/type-checks.mjs +88 -1
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +471 -4
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +465 -4
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +135 -1
- package/dist/resolver/deepkit.mjs +134 -1
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +173 -1
- package/dist/resolver/helpers.mjs +168 -1
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +145 -1
- package/dist/resolver/module.mjs +144 -1
- package/dist/resolver/module.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +222 -1
- package/dist/resolver/resolve.mjs +221 -1
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +441 -1
- package/dist/types/command.d.cts +1 -1
- package/dist/types/command.d.mts +2 -2
- package/dist/types/command.mjs +405 -1
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +134 -1
- package/dist/types/config.d.cts +10 -8
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +10 -8
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +127 -1
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +37 -1
- package/dist/types/context.mjs +34 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/env.cjs +52 -1
- package/dist/types/env.d.cts +1 -1
- package/dist/types/env.d.mts +1 -1
- package/dist/types/env.mjs +50 -1
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +50 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +6 -1
- package/dist/types/options.cjs +12 -1
- package/dist/types/options.mjs +10 -1
- package/package.json +22 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.mjs","names":[],"sources":["../../src/components/docs.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, For, memo, Show } from \"@alloy-js/core\";\nimport { Heading } from \"@alloy-js/markdown\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { MarkdownFileProps } from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownFile } from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownTable } from \"@powerlines/plugin-alloy/markdown/components/markdown-table\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { defu } from \"defu\";\nimport { CommandContext } from \"../contexts/command\";\nimport { getDocsOutputPath } from \"../helpers/docs-helpers\";\nimport { getAppBin } from \"../plugin-utils/context-helpers\";\nimport { sortOptions } from \"../plugin-utils/reflect\";\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { Usage } from \"./usage\";\n\nexport interface CommandOptionsDocsProps {\n /**\n * The command to generate options documentation for.\n */\n command: CommandTree;\n}\n\n/**\n * Generates the options markdown documentation for a command.\n */\nexport function CommandOptionsDocs(props: CommandOptionsDocsProps) {\n const { command } = props;\n if (Object.keys(command.options).length === 0) {\n return code`This command does not have any options.`;\n }\n\n return (\n <MarkdownTable\n data={sortOptions(Object.values(command.options)).map(option => {\n return {\n name: option.name.trim(),\n description: option.description.trim(),\n defaultValue: option.default\n ? String(option.default)?.includes('\"')\n ? option.default\n : `\\`${\n Array.isArray(option.default)\n ? option.default.join(\", \")\n : option.default\n }\\``\n : \"\",\n required: option.optional || option.default ? \"\" : \"✔\"\n };\n })}\n />\n );\n}\n\nexport interface CommandDocsUsageExampleProps {\n /**\n * The package manager to generate the usage example for.\n *\n * @remarks\n * If not specified, examples for all supported package managers will be generated.\n *\n * @defaultValue \"npm\"\n */\n packageManager?: \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\n /**\n * The command to generate the usage example for.\n */\n command: CommandTree;\n}\n\n/**\n * Generates the markdown documentation for a command.\n */\nexport function CommandDocsUsageExample(props: CommandDocsUsageExampleProps) {\n const { packageManager = \"npm\", command } = props;\n\n const context = usePowerlines<Context>();\n\n return (\n <>\n <hbr />\n {code`\\`\\`\\`bash `}\n <hbr />\n <Usage\n command={command}\n bin={getAppBin(context)}\n packageManager={packageManager}\n />\n <hbr />\n {code`\\`\\`\\``}\n <hbr />\n </>\n );\n}\n\nexport interface CommandDocsProps {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n /**\n * The command to generate options documentation for.\n */\n command: CommandTree;\n\n /**\n * Optional usage examples to include in the documentation.\n *\n * @defaultValue `[\"npm\"]`\n */\n usageExamples?: Required<CommandDocsUsageExampleProps>[\"packageManager\"][];\n}\n\n/**\n * Generates the markdown documentation for a command.\n */\nexport function CommandDocs(props: CommandDocsProps) {\n const { levelOffset = 0, command, usageExamples } = props;\n\n return (\n <>\n <Heading level={1 + levelOffset}>{command.title}</Heading>\n <Spacing />\n {code`${command.description}`}\n <Spacing />\n <Heading level={2 + levelOffset}>Usage</Heading>\n <Spacing />\n {code`The ${command.name} command can be executed using the following syntax: `}\n <Spacing />\n <Show\n when={usageExamples && usageExamples.length > 0}\n fallback={\n <CommandDocsUsageExample packageManager=\"npm\" command={command} />\n }>\n <For each={usageExamples!} hardline>\n {packageManager => (\n <CommandDocsUsageExample\n packageManager={packageManager}\n command={command}\n />\n )}\n </For>\n </Show>\n <Spacing />\n <Heading level={2 + levelOffset}>Options</Heading>\n <Spacing />\n {code`The following options are available for the ${\n command.name\n } command:`}\n <Spacing />\n <CommandOptionsDocs command={command} />\n <Spacing />\n </>\n );\n}\n\nexport interface CommandDocsFileProps extends Partial<MarkdownFileProps> {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n /**\n * The command to generate documentation for.\n */\n command: CommandTree;\n}\n\n/**\n * Generates the markdown documentation file for a command.\n */\nexport function CommandDocsFile(props: CommandDocsFileProps) {\n const { levelOffset = 0, command, frontMatter, ...rest } = props;\n\n const context = usePowerlines<Context>();\n const usageExamples = memo(\n () => [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as CommandDocsProps[\"usageExamples\"]\n );\n\n return (\n <CommandContext.Provider value={command}>\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context), `${command.path}.md`)}\n {...rest}\n frontMatter={defu(frontMatter ?? {}, {\n id: command.id,\n name: command.name,\n path: command.path,\n reference: command.reference,\n isVirtual: command.isVirtual,\n title: command.title,\n description: command.description,\n tags: command.tags\n })}>\n <CommandDocs\n levelOffset={levelOffset}\n command={command}\n usageExamples={usageExamples()}\n />\n </MarkdownFile>\n </CommandContext.Provider>\n );\n}\n"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,OAAA,OAAA,MAAA,CAAA,CACP,OAAG,EAAA,EAAA,SAAA,CACD,MAAG,EACH,IAAG,UAAS,CACV,OAAO,EAAS,EAAa,EAAA,CAC5B,IAAA,MAAS,CACT,OAAQ,EAAW,EAAmB,EAAQ,CAAA,GAAA,EAAA,KAAA,KAAA,EAE9C,CAAA,EAAQ,CACR,IAAA,aAAS,CACT,OAAA,EAAA,GAAA,EAAA,CAAA,CACK,GAAE,EAAA,GACN,KAAS,EAAA,KACN,KAAA,EAAA,KACF,UAAA,EAAA,UACG,UAAO,EAAA,UACR,MAAA,EAAgB,MACf,YAAC,EAAA,YACD,KAAE,EAAA,KACH,CAAC,EAEJ,IAAG,UAAA,CACD,OAAG,EAAA,EAAA,CACD,cACI,UACT,IAAQ,eAAW,CACZ,OAAE,GAAA,EAER,CAAA,EAED,CAAA,CAAA,EAEJ,CAAC,CAEJ,EAAG,OAAA,KAAA,EAAA,QAAA,kBAAA,2DAAA,aAAA"}
|
|
1
|
+
{"version":3,"file":"docs.mjs","names":[],"sources":["../../src/components/docs.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, For, memo, Show } from \"@alloy-js/core\";\nimport { Heading } from \"@alloy-js/markdown\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { MarkdownFileProps } from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownFile } from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownTable } from \"@powerlines/plugin-alloy/markdown/components/markdown-table\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { defu } from \"defu\";\nimport { CommandContext } from \"../contexts/command\";\nimport { getDocsOutputPath } from \"../helpers/docs-helpers\";\nimport { getAppBin } from \"../plugin-utils/context-helpers\";\nimport { sortOptions } from \"../plugin-utils/reflect\";\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { Usage } from \"./usage\";\n\nexport interface CommandOptionsDocsProps {\n /**\n * The command to generate options documentation for.\n */\n command: CommandTree;\n}\n\n/**\n * Generates the options markdown documentation for a command.\n */\nexport function CommandOptionsDocs(props: CommandOptionsDocsProps) {\n const { command } = props;\n if (Object.keys(command.options).length === 0) {\n return code`This command does not have any options.`;\n }\n\n return (\n <MarkdownTable\n data={sortOptions(Object.values(command.options)).map(option => {\n return {\n name: option.name.trim(),\n description: option.description.trim(),\n defaultValue: option.default\n ? String(option.default)?.includes('\"')\n ? option.default\n : `\\`${\n Array.isArray(option.default)\n ? option.default.join(\", \")\n : option.default\n }\\``\n : \"\",\n required: option.optional || option.default ? \"\" : \"✔\"\n };\n })}\n />\n );\n}\n\nexport interface CommandDocsUsageExampleProps {\n /**\n * The package manager to generate the usage example for.\n *\n * @remarks\n * If not specified, examples for all supported package managers will be generated.\n *\n * @defaultValue \"npm\"\n */\n packageManager?: \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\n /**\n * The command to generate the usage example for.\n */\n command: CommandTree;\n}\n\n/**\n * Generates the markdown documentation for a command.\n */\nexport function CommandDocsUsageExample(props: CommandDocsUsageExampleProps) {\n const { packageManager = \"npm\", command } = props;\n\n const context = usePowerlines<Context>();\n\n return (\n <>\n <hbr />\n {code`\\`\\`\\`bash `}\n <hbr />\n <Usage\n command={command}\n bin={getAppBin(context)}\n packageManager={packageManager}\n />\n <hbr />\n {code`\\`\\`\\``}\n <hbr />\n </>\n );\n}\n\nexport interface CommandDocsProps {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n /**\n * The command to generate options documentation for.\n */\n command: CommandTree;\n\n /**\n * Optional usage examples to include in the documentation.\n *\n * @defaultValue `[\"npm\"]`\n */\n usageExamples?: Required<CommandDocsUsageExampleProps>[\"packageManager\"][];\n}\n\n/**\n * Generates the markdown documentation for a command.\n */\nexport function CommandDocs(props: CommandDocsProps) {\n const { levelOffset = 0, command, usageExamples } = props;\n\n return (\n <>\n <Heading level={1 + levelOffset}>{command.title}</Heading>\n <Spacing />\n {code`${command.description}`}\n <Spacing />\n <Heading level={2 + levelOffset}>Usage</Heading>\n <Spacing />\n {code`The ${command.name} command can be executed using the following syntax: `}\n <Spacing />\n <Show\n when={usageExamples && usageExamples.length > 0}\n fallback={\n <CommandDocsUsageExample packageManager=\"npm\" command={command} />\n }>\n <For each={usageExamples!} hardline>\n {packageManager => (\n <CommandDocsUsageExample\n packageManager={packageManager}\n command={command}\n />\n )}\n </For>\n </Show>\n <Spacing />\n <Heading level={2 + levelOffset}>Options</Heading>\n <Spacing />\n {code`The following options are available for the ${\n command.name\n } command:`}\n <Spacing />\n <CommandOptionsDocs command={command} />\n <Spacing />\n </>\n );\n}\n\nexport interface CommandDocsFileProps extends Partial<MarkdownFileProps> {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n /**\n * The command to generate documentation for.\n */\n command: CommandTree;\n}\n\n/**\n * Generates the markdown documentation file for a command.\n */\nexport function CommandDocsFile(props: CommandDocsFileProps) {\n const { levelOffset = 0, command, frontMatter, ...rest } = props;\n\n const context = usePowerlines<Context>();\n const usageExamples = memo(\n () => [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as CommandDocsProps[\"usageExamples\"]\n );\n\n return (\n <CommandContext.Provider value={command}>\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context), `${command.path}.md`)}\n {...rest}\n frontMatter={defu(frontMatter ?? {}, {\n id: command.id,\n name: command.name,\n path: command.path,\n reference: command.reference,\n isVirtual: command.isVirtual,\n title: command.title,\n description: command.description,\n tags: command.tags\n })}>\n <CommandDocs\n levelOffset={levelOffset}\n command={command}\n usageExamples={usageExamples()}\n />\n </MarkdownFile>\n </CommandContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,aAAa;CAAC;CAAK;CAAW;CAAO;;AAE1C,IAAI,SAAS;AACb,QAAG;;AAgCJ,MAAK,6BAAwB;CAAO;CAAe;CAAG;CAAA;CAAA;CAAA;;;;AAKtD,SAAE,mBAAA,OAAA;CACA,MAAC,EACD,YACI;AACJ,KAAA,OAAQ,KAAQ,QAAI,QAAK,CAAA,WAAA,EACvB,QAAE,IAAO;AAEX,QAAA,gBAAA,eAAA;AAEA,SAAO,YAAA,OAAA,OAAA,QAAA,QAAA,CAAA,CAAA,IAAA,cAAA,WAAA;AACJ,UAAA;IACK,MAAE,OAAW,KAAC,MAAO;IACvB,aAAO,OAAA,YAAA,MAAA;IACL,cAAa,OAAK,UAAM,OAAA,OAAA,QAAA,EAAA,SAAA,KAAA,GAAA,OAAA,UAAA,KAAA,MAAA,QAAA,OAAA,QAAA,GAAA,OAAA,QAAA,KAAA,KAAA,GAAA,OAAA,QAAA,MAAA;IACxB,UAAA,OAAa,YAAO,OAAgB,UAAE,KAAA;IACvC;KACA;GAAC;GAAU;GAAC;GAAO,CAAO,CAAC;IAEjC,CAAC;;AAEJ,mBAAmB,SAAS;OAAC;CAAiB;CAAA;CAAA;CAAA;CAAA;AAC9C,MAAM,kCAAuB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;AAK7B,SAAQ,wBAAA,OAAA;CACN,MAAG,EACF,iBAAA,OACH;CAEA,MAAO,WAA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AAc,IAAG,+CAAA,QAAA,KAAA,WAAA;EAAA,gBAAA,SAAA,EAAA,CAAA;EAAA,gBAAA,oBAAA,EAClD,SACF,CAAA;EAAA,gBAAoB,SAAA,EAAA,CAAA;EAAA;;AAEtB,YAAI,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACJ,MAAK,0BAA2B;OAAO;CAAQ;CAAa;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;AAK5D,SAAA,gBAAA,OAAA;SAEE,cAAA,GACC,SACD,aACF,GAAO,SACL;;CAEA,MAAM,gBAAC,aAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA;AACP,QAAG,gBAAA,eAAA,UAAA;EACD,OAAG;EACH,IAAG,WAAS;AACV,UAAO,gBAAS,cAAa,WAAA,EAC5B,IAAA,OAAS;AACT,WAAQ,UAAW,kBAAmB,QAAQ,EAAA,GAAA,QAAA,KAAA,KAAA;MAE9C,EAAA,MAAQ;IACR,IAAA,cAAS;AACT,YAAA,KAAA,eAAA,EAAA,EAAA;MACK,IAAE,QAAA;MACN,MAAS,QAAA;MACN,MAAA,QAAA;MACF,WAAA,QAAA;MACG,WAAO,QAAA;MACR,OAAA,QAAgB;MACf,aAAC,QAAA;MACD,MAAE,QAAA;MACH,CAAC;;IAEJ,IAAG,WAAA;AACD,YAAG,gBAAA,aAAA;MACD;MACI;MACT,IAAQ,gBAAW;AACZ,cAAE,eAAA;;MAER,CAAA;;IAED,CAAA,CAAA;;EAEJ,CAAC;;AAEJ,gBAAG,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
@@ -1,4 +1,85 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
5
|
+
let defu = require("defu");
|
|
6
|
+
defu = require_runtime.__toESM(defu);
|
|
7
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
8
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
9
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
10
|
+
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
11
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
12
|
+
|
|
13
|
+
//#region src/components/exec-builtin.tsx
|
|
14
|
+
const __ΩOmit = [
|
|
15
|
+
"T",
|
|
16
|
+
"K",
|
|
17
|
+
() => __ΩPick,
|
|
18
|
+
() => __ΩExclude,
|
|
19
|
+
"Omit",
|
|
20
|
+
"b!b\"e!!e!!ge!\"o$#o##w%y"
|
|
21
|
+
];
|
|
22
|
+
const __ΩPick = [
|
|
23
|
+
"T",
|
|
24
|
+
"K",
|
|
25
|
+
"Pick",
|
|
26
|
+
"l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
|
|
27
|
+
];
|
|
28
|
+
const __ΩExclude = [
|
|
29
|
+
"T",
|
|
30
|
+
"U",
|
|
31
|
+
"Exclude",
|
|
32
|
+
"l6!Re$!RPe#!e$\"qk#%QRb!b\"Pde\"!p)w#y"
|
|
33
|
+
];
|
|
34
|
+
const __ΩExecBuiltinProps = [
|
|
35
|
+
() => __ΩOmit,
|
|
36
|
+
"id",
|
|
37
|
+
"description",
|
|
38
|
+
"ExecBuiltinProps",
|
|
39
|
+
"P!P.\".#Jo!#Mw$y"
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* A built-in module for handling command execution in Shell Shock.
|
|
43
|
+
*/
|
|
44
|
+
function ExecBuiltin(props) {
|
|
45
|
+
const [{ children }, rest] = (0, _alloy_js_core.splitProps)(props, ["children"]);
|
|
46
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
47
|
+
id: "exec",
|
|
48
|
+
description: "A module to handle command execution in a Shell Shock application."
|
|
49
|
+
}, rest, {
|
|
50
|
+
get imports() {
|
|
51
|
+
return (0, defu.default)(rest.imports ?? {}, {
|
|
52
|
+
"node:path": [
|
|
53
|
+
"basename",
|
|
54
|
+
"extname",
|
|
55
|
+
"dirname",
|
|
56
|
+
"join"
|
|
57
|
+
],
|
|
58
|
+
"node:fs": ["existsSync"],
|
|
59
|
+
"node:child_process": [{
|
|
60
|
+
name: "spawn",
|
|
61
|
+
alias: "_spawn"
|
|
62
|
+
}, "execFileSync"],
|
|
63
|
+
"node:stream": [{
|
|
64
|
+
name: "Stream",
|
|
65
|
+
default: true,
|
|
66
|
+
type: true
|
|
67
|
+
}]
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
get builtinImports() {
|
|
71
|
+
return (0, defu.default)(rest.builtinImports ?? {}, { env: ["isWindows", "env"] });
|
|
72
|
+
},
|
|
73
|
+
get children() {
|
|
74
|
+
return [
|
|
75
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
76
|
+
name: "resolveCommandEnv",
|
|
77
|
+
parameters: [{
|
|
78
|
+
name: "params",
|
|
79
|
+
type: "{ argv: string[]; env?: NodeJS.ProcessEnv; }"
|
|
80
|
+
}],
|
|
81
|
+
returnType: "NodeJS.ProcessEnv",
|
|
82
|
+
children: _alloy_js_core.code`const argv = params.argv;
|
|
2
83
|
const shouldSuppressNpmFund = (() => {
|
|
3
84
|
const cmd = basename(argv[0] ?? "");
|
|
4
85
|
if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
|
|
@@ -24,12 +105,32 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
24
105
|
result.NPM_CONFIG_FUND ??= "false";
|
|
25
106
|
result.npm_config_fund ??= "false";
|
|
26
107
|
}
|
|
27
|
-
return result; `
|
|
108
|
+
return result; `
|
|
109
|
+
}),
|
|
110
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
111
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
112
|
+
name: "isWindowsBatchCommand",
|
|
113
|
+
parameters: [{
|
|
114
|
+
name: "resolvedCommand",
|
|
115
|
+
type: "string"
|
|
116
|
+
}],
|
|
117
|
+
returnType: "boolean",
|
|
118
|
+
children: _alloy_js_core.code`if (!isWindows) {
|
|
28
119
|
return false;
|
|
29
120
|
}
|
|
30
121
|
const ext = extname(resolvedCommand).toLowerCase();
|
|
31
122
|
|
|
32
|
-
return ext === ".cmd" || ext === ".bat"; `
|
|
123
|
+
return ext === ".cmd" || ext === ".bat"; `
|
|
124
|
+
}),
|
|
125
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
126
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
127
|
+
name: "escapeForCmdExe",
|
|
128
|
+
parameters: [{
|
|
129
|
+
name: "arg",
|
|
130
|
+
type: "string"
|
|
131
|
+
}],
|
|
132
|
+
returnType: "string",
|
|
133
|
+
children: _alloy_js_core.code`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
|
|
33
134
|
throw new Error(
|
|
34
135
|
\`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
|
|
35
136
|
"Pass an explicit shell-wrapper argv at the call site instead."
|
|
@@ -38,9 +139,33 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
38
139
|
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
39
140
|
return arg;
|
|
40
141
|
}
|
|
41
|
-
return \`"\${arg.replace(/"/g, '""')}"\`; `
|
|
142
|
+
return \`"\${arg.replace(/"/g, '""')}"\`; `
|
|
143
|
+
}),
|
|
144
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
145
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
146
|
+
name: "buildCmdExeCommandLine",
|
|
147
|
+
parameters: [{
|
|
148
|
+
name: "resolvedCommand",
|
|
149
|
+
type: "string"
|
|
150
|
+
}, {
|
|
151
|
+
name: "args",
|
|
152
|
+
type: "string[]"
|
|
153
|
+
}],
|
|
154
|
+
returnType: "string",
|
|
155
|
+
children: _alloy_js_core.code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
|
|
42
156
|
" "
|
|
43
|
-
); `
|
|
157
|
+
); `
|
|
158
|
+
}),
|
|
159
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
160
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
161
|
+
name: "resolveNpmArgvForWindows",
|
|
162
|
+
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.",
|
|
163
|
+
parameters: [{
|
|
164
|
+
name: "argv",
|
|
165
|
+
type: "string[]"
|
|
166
|
+
}],
|
|
167
|
+
returnType: "string[] | null",
|
|
168
|
+
children: _alloy_js_core.code`if (!isWindows || argv.length === 0) {
|
|
44
169
|
return null;
|
|
45
170
|
}
|
|
46
171
|
const base = basename(argv[0] ?? "")
|
|
@@ -60,7 +185,18 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
60
185
|
|
|
61
186
|
return [shimmedCommand, ...argv.slice(1)];
|
|
62
187
|
}
|
|
63
|
-
return [process.execPath, cliPath, ...argv.slice(1)]; `
|
|
188
|
+
return [process.execPath, cliPath, ...argv.slice(1)]; `
|
|
189
|
+
}),
|
|
190
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
191
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
192
|
+
name: "resolveCommand",
|
|
193
|
+
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).",
|
|
194
|
+
parameters: [{
|
|
195
|
+
name: "command",
|
|
196
|
+
type: "string"
|
|
197
|
+
}],
|
|
198
|
+
returnType: "string",
|
|
199
|
+
children: _alloy_js_core.code`if (!isWindows) {
|
|
64
200
|
return command;
|
|
65
201
|
}
|
|
66
202
|
const base = basename(command).toLowerCase();
|
|
@@ -70,13 +206,33 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
70
206
|
if (["pnpm", "yarn"].includes(base)) {
|
|
71
207
|
return \`\${command}.cmd\`;
|
|
72
208
|
}
|
|
73
|
-
return command; `
|
|
209
|
+
return command; `
|
|
210
|
+
}),
|
|
211
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
212
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
213
|
+
name: "resolveCommandStdio",
|
|
214
|
+
parameters: [{
|
|
215
|
+
name: "params",
|
|
216
|
+
type: "{ hasInput: boolean; preferInherit: boolean; }"
|
|
217
|
+
}],
|
|
218
|
+
returnType: "[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]",
|
|
219
|
+
children: _alloy_js_core.code`const stdin = params.hasInput
|
|
74
220
|
? "pipe"
|
|
75
221
|
: params.preferInherit
|
|
76
222
|
? "inherit"
|
|
77
223
|
: "pipe";
|
|
78
224
|
|
|
79
|
-
return [stdin, "pipe", "pipe"]; `
|
|
225
|
+
return [stdin, "pipe", "pipe"]; `
|
|
226
|
+
}),
|
|
227
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
228
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
229
|
+
name: "resolveProcessExitCode",
|
|
230
|
+
parameters: [{
|
|
231
|
+
name: "params",
|
|
232
|
+
type: "{ explicitCode: number | null | undefined; childExitCode: number | null | undefined; resolvedSignal: NodeJS.Signals | null; usesWindowsExitCodeShim: boolean; timedOut: boolean; noOutputTimedOut: boolean; killIssuedByTimeout: boolean; }"
|
|
233
|
+
}],
|
|
234
|
+
returnType: "number | null",
|
|
235
|
+
children: _alloy_js_core.code`return (
|
|
80
236
|
params.explicitCode ??
|
|
81
237
|
params.childExitCode ??
|
|
82
238
|
(params.usesWindowsExitCodeShim &&
|
|
@@ -86,13 +242,187 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
86
242
|
!params.killIssuedByTimeout
|
|
87
243
|
? 0
|
|
88
244
|
: null)
|
|
89
|
-
); `
|
|
245
|
+
); `
|
|
246
|
+
}),
|
|
247
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
248
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
249
|
+
name: "shouldSpawnWithShell",
|
|
250
|
+
parameters: [{
|
|
251
|
+
name: "params",
|
|
252
|
+
type: "{ resolvedCommand: string; platform: NodeJS.Platform; }"
|
|
253
|
+
}],
|
|
254
|
+
returnType: "boolean",
|
|
255
|
+
children: _alloy_js_core.code`// SECURITY: never enable \`shell\` for argv-based execution.
|
|
90
256
|
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
91
257
|
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
92
258
|
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
93
259
|
// and validate/escape at the call site.
|
|
94
260
|
void params;
|
|
95
|
-
return false; `
|
|
261
|
+
return false; `
|
|
262
|
+
}),
|
|
263
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
264
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The result of a spawn operation." }),
|
|
265
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
266
|
+
"export": true,
|
|
267
|
+
name: "SpawnResult",
|
|
268
|
+
get children() {
|
|
269
|
+
return [
|
|
270
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The PID of the spawned child process, if available." }),
|
|
271
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
272
|
+
name: "pid",
|
|
273
|
+
optional: true,
|
|
274
|
+
type: "number"
|
|
275
|
+
}),
|
|
276
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
277
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The standard output produced by the child process." }),
|
|
278
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
279
|
+
name: "stdout",
|
|
280
|
+
type: "string"
|
|
281
|
+
}),
|
|
282
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
283
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The standard error produced by the child process." }),
|
|
284
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
285
|
+
name: "stderr",
|
|
286
|
+
type: "string"
|
|
287
|
+
}),
|
|
288
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
289
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The exit code of the child process, if available." }),
|
|
290
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
291
|
+
name: "code",
|
|
292
|
+
type: "number | null"
|
|
293
|
+
}),
|
|
294
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
295
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The signal that caused the child process to terminate, if it was killed by a signal." }),
|
|
296
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
297
|
+
name: "signal",
|
|
298
|
+
type: "NodeJS.Signals | null"
|
|
299
|
+
}),
|
|
300
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
301
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Whether the child process was killed." }),
|
|
302
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
303
|
+
name: "killed",
|
|
304
|
+
type: "boolean"
|
|
305
|
+
}),
|
|
306
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
307
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The reason for the child process termination." }),
|
|
308
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
309
|
+
name: "termination",
|
|
310
|
+
type: _alloy_js_core.code`"exit" | "timeout" | "no-output-timeout" | "signal"`
|
|
311
|
+
}),
|
|
312
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
313
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Whether the child process timed out due to no output." }),
|
|
314
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
315
|
+
name: "noOutputTimedOut",
|
|
316
|
+
optional: true,
|
|
317
|
+
type: "boolean"
|
|
318
|
+
})
|
|
319
|
+
];
|
|
320
|
+
}
|
|
321
|
+
}),
|
|
322
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
323
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for spawning a child process." }),
|
|
324
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
325
|
+
"export": true,
|
|
326
|
+
name: "SpawnOptions",
|
|
327
|
+
get children() {
|
|
328
|
+
return [
|
|
329
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
330
|
+
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.",
|
|
331
|
+
get children() {
|
|
332
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
333
|
+
get type() {
|
|
334
|
+
return _powerlines_deepkit_vendor_type.ReflectionKind.number;
|
|
335
|
+
},
|
|
336
|
+
defaultValue: "300000"
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}),
|
|
340
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
341
|
+
name: "timeoutMs",
|
|
342
|
+
optional: true,
|
|
343
|
+
type: "number"
|
|
344
|
+
}),
|
|
345
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
346
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The current working directory of the child process." }),
|
|
347
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
348
|
+
name: "cwd",
|
|
349
|
+
optional: true,
|
|
350
|
+
type: "string"
|
|
351
|
+
}),
|
|
352
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
353
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The input to be passed to the child process." }),
|
|
354
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
355
|
+
name: "input",
|
|
356
|
+
optional: true,
|
|
357
|
+
type: "string"
|
|
358
|
+
}),
|
|
359
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
360
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The environment variables for the child process." }),
|
|
361
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
362
|
+
name: "env",
|
|
363
|
+
optional: true,
|
|
364
|
+
type: "NodeJS.ProcessEnv"
|
|
365
|
+
}),
|
|
366
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
367
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Whether to pass arguments to the child process verbatim on Windows." }),
|
|
368
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
369
|
+
name: "windowsVerbatimArguments",
|
|
370
|
+
optional: true,
|
|
371
|
+
type: "boolean"
|
|
372
|
+
}),
|
|
373
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
374
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.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." }),
|
|
375
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
376
|
+
name: "noOutputTimeoutMs",
|
|
377
|
+
optional: true,
|
|
378
|
+
type: "number"
|
|
379
|
+
})
|
|
380
|
+
];
|
|
381
|
+
}
|
|
382
|
+
}),
|
|
383
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
384
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
385
|
+
"const": true,
|
|
386
|
+
name: "WINDOWS_CLOSE_STATE_SETTLE_TIMEOUT_MS",
|
|
387
|
+
initializer: _alloy_js_core.code`250`
|
|
388
|
+
}),
|
|
389
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
390
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
391
|
+
"const": true,
|
|
392
|
+
name: "WINDOWS_CLOSE_STATE_POLL_MS",
|
|
393
|
+
initializer: _alloy_js_core.code`10`
|
|
394
|
+
}),
|
|
395
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
396
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
397
|
+
heading: "Spawns a child process with the given arguments and options, returning a promise that resolves with the result of the spawn operation.",
|
|
398
|
+
get children() {
|
|
399
|
+
return [
|
|
400
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
401
|
+
name: "argv",
|
|
402
|
+
children: "The command and its arguments to spawn."
|
|
403
|
+
}),
|
|
404
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
405
|
+
name: "optionsOrTimeoutMs",
|
|
406
|
+
children: `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.`
|
|
407
|
+
}),
|
|
408
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "A promise that resolves with the result of the spawn operation, including stdout, stderr, exit code, signal, and termination reason." })
|
|
409
|
+
];
|
|
410
|
+
}
|
|
411
|
+
}),
|
|
412
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
413
|
+
"export": true,
|
|
414
|
+
async: true,
|
|
415
|
+
name: "spawn",
|
|
416
|
+
parameters: [{
|
|
417
|
+
name: "argv",
|
|
418
|
+
type: "string[]"
|
|
419
|
+
}, {
|
|
420
|
+
name: "optionsOrTimeoutMs",
|
|
421
|
+
type: "number | SpawnOptions",
|
|
422
|
+
default: "300000"
|
|
423
|
+
}],
|
|
424
|
+
returnType: "Promise<SpawnResult>",
|
|
425
|
+
children: _alloy_js_core.code`const options: SpawnOptions =
|
|
96
426
|
typeof optionsOrTimeoutMs === "number"
|
|
97
427
|
? { timeoutMs: optionsOrTimeoutMs }
|
|
98
428
|
: optionsOrTimeoutMs;
|
|
@@ -315,18 +645,104 @@ return new Promise((resolve, reject) => {
|
|
|
315
645
|
};
|
|
316
646
|
waitForExitState();
|
|
317
647
|
});
|
|
318
|
-
});`
|
|
648
|
+
});`
|
|
649
|
+
}),
|
|
650
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
651
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
652
|
+
heading: "A helper function that executes a command and returns its stdout.",
|
|
653
|
+
get children() {
|
|
654
|
+
return [
|
|
655
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
656
|
+
name: "argv",
|
|
657
|
+
children: `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.`
|
|
658
|
+
}),
|
|
659
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
660
|
+
name: "optionsOrTimeoutMs",
|
|
661
|
+
children: `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.`
|
|
662
|
+
}),
|
|
663
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "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." })
|
|
664
|
+
];
|
|
665
|
+
}
|
|
666
|
+
}),
|
|
667
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
668
|
+
"export": true,
|
|
669
|
+
async: true,
|
|
670
|
+
name: "exec",
|
|
671
|
+
parameters: [{
|
|
672
|
+
name: "argv",
|
|
673
|
+
type: "string[]"
|
|
674
|
+
}, {
|
|
675
|
+
name: "optionsOrTimeoutMs",
|
|
676
|
+
type: "number | SpawnOptions",
|
|
677
|
+
default: "300000"
|
|
678
|
+
}],
|
|
679
|
+
returnType: "Promise<string>",
|
|
680
|
+
children: _alloy_js_core.code`const spawnResult = await spawn(argv, optionsOrTimeoutMs);
|
|
319
681
|
if (spawnResult.code !== 0) {
|
|
320
682
|
throw Object.assign(new Error(
|
|
321
683
|
\`Command "\${argv.join(" ")}" exited with code \${spawnResult.code} and signal \${spawnResult.signal}\`
|
|
322
684
|
), spawnResult);
|
|
323
685
|
}
|
|
324
686
|
|
|
325
|
-
return spawnResult.stdout.trim(); `
|
|
687
|
+
return spawnResult.stdout.trim(); `
|
|
688
|
+
}),
|
|
689
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
690
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
691
|
+
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.",
|
|
692
|
+
get children() {
|
|
693
|
+
return [
|
|
694
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
695
|
+
name: "argv",
|
|
696
|
+
children: `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.`
|
|
697
|
+
}),
|
|
698
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
699
|
+
name: "options",
|
|
700
|
+
children: `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.`
|
|
701
|
+
}),
|
|
702
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "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." })
|
|
703
|
+
];
|
|
704
|
+
}
|
|
705
|
+
}),
|
|
706
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
707
|
+
"export": true,
|
|
708
|
+
name: "execSync",
|
|
709
|
+
parameters: [{
|
|
710
|
+
name: "argv",
|
|
711
|
+
type: "string[]"
|
|
712
|
+
}, {
|
|
713
|
+
name: "options",
|
|
714
|
+
type: "SpawnOptions",
|
|
715
|
+
default: "{}"
|
|
716
|
+
}],
|
|
717
|
+
returnType: "string",
|
|
718
|
+
children: _alloy_js_core.code`return execFileSync(argv.length > 0 ? argv[0] : "", argv.slice(1), {
|
|
326
719
|
encoding: "utf8",
|
|
327
720
|
stdio: ["ignore", "pipe", "ignore"],
|
|
328
721
|
timeout: options.timeoutMs ?? 300000,
|
|
329
722
|
env: resolveCommandEnv({ argv, env: options.env }),
|
|
330
723
|
cwd: options.cwd || process.cwd(),
|
|
331
724
|
windowsHide: true
|
|
332
|
-
}).trim(); `
|
|
725
|
+
}).trim(); `
|
|
726
|
+
}),
|
|
727
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
728
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
729
|
+
get when() {
|
|
730
|
+
return Boolean(children);
|
|
731
|
+
},
|
|
732
|
+
children
|
|
733
|
+
})
|
|
734
|
+
];
|
|
735
|
+
}
|
|
736
|
+
}));
|
|
737
|
+
}
|
|
738
|
+
ExecBuiltin.__type = [
|
|
739
|
+
() => __ΩExecBuiltinProps,
|
|
740
|
+
"props",
|
|
741
|
+
"ExecBuiltin",
|
|
742
|
+
"A built-in module for handling command execution in Shell Shock.",
|
|
743
|
+
"Pn!2\"\"/#?$"
|
|
744
|
+
];
|
|
745
|
+
|
|
746
|
+
//#endregion
|
|
747
|
+
exports.ExecBuiltin = ExecBuiltin;
|
|
748
|
+
exports.__ΩExecBuiltinProps = __ΩExecBuiltinProps;
|