@shell-shock/preset-cli 0.9.14 → 0.9.15
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/components/command-entry.cjs +2 -5
- package/dist/components/command-entry.mjs +2 -5
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +2 -5
- package/dist/components/virtual-command-entry.mjs +2 -5
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/packages/plugin-changelog/dist/components/changelog-command.cjs +1 -1
- package/dist/packages/plugin-changelog/dist/components/changelog-command.mjs +1 -1
- package/dist/packages/plugin-changelog/dist/components/changelog-command.mjs.map +1 -1
- package/dist/packages/plugin-changelog/dist/helpers/resolve-changelog.cjs +51 -0
- package/dist/packages/plugin-changelog/dist/helpers/resolve-changelog.mjs +51 -0
- package/dist/packages/plugin-changelog/dist/helpers/resolve-changelog.mjs.map +1 -0
- package/dist/packages/plugin-changelog/dist/index.cjs +32 -20
- package/dist/packages/plugin-changelog/dist/index.mjs +32 -20
- package/dist/packages/plugin-changelog/dist/index.mjs.map +1 -1
- package/dist/packages/plugin-changelog/dist/types/plugin.d.cts +48 -0
- package/dist/packages/plugin-changelog/dist/types/plugin.d.cts.map +1 -1
- package/dist/packages/plugin-changelog/dist/types/plugin.d.mts +48 -0
- package/dist/packages/plugin-changelog/dist/types/plugin.d.mts.map +1 -1
- package/package.json +15 -15
|
@@ -73,15 +73,12 @@ function CommandEntry(props) {
|
|
|
73
73
|
],
|
|
74
74
|
state: [
|
|
75
75
|
"useGlobal",
|
|
76
|
+
"GlobalOptions",
|
|
76
77
|
"useGlobalOptions",
|
|
77
78
|
"withCommand",
|
|
78
79
|
"useArgs",
|
|
79
80
|
"hasFlag",
|
|
80
|
-
"isHelp"
|
|
81
|
-
{
|
|
82
|
-
name: "GlobalOptions",
|
|
83
|
-
type: true
|
|
84
|
-
}
|
|
81
|
+
"isHelp"
|
|
85
82
|
],
|
|
86
83
|
prompts: [
|
|
87
84
|
"text",
|
|
@@ -70,15 +70,12 @@ function CommandEntry(props) {
|
|
|
70
70
|
],
|
|
71
71
|
state: [
|
|
72
72
|
"useGlobal",
|
|
73
|
+
"GlobalOptions",
|
|
73
74
|
"useGlobalOptions",
|
|
74
75
|
"withCommand",
|
|
75
76
|
"useArgs",
|
|
76
77
|
"hasFlag",
|
|
77
|
-
"isHelp"
|
|
78
|
-
{
|
|
79
|
-
name: "GlobalOptions",
|
|
80
|
-
type: true
|
|
81
|
-
}
|
|
78
|
+
"isHelp"
|
|
82
79
|
],
|
|
83
80
|
prompts: [
|
|
84
81
|
"text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.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, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { CommandHandlerDeclaration } from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"italic\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"createSpinner\"\n ],\n utils: [\"sleep\", \"isMinimal\", \"isInteractive\", \"isUnicodeSupported\"],\n state: [\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\",\n { name: \"GlobalOptions\", type: true }\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner();\n await executeUpgrade(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp() && (${Object.values(\n command.options ?? {}\n )\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\\`The following validation failures were found while processing the user provided input, and must be corrected before the \\${italic(\"${command.title}\")} command can be executed: \\\\n\\\\n\\${failures.map(failure => \" - \" + failure).join(\"\\\\n\")}\\`);\n options.help = true; `}\n </IfStatement>\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;CA8CA,MAAO,EACL,SACC,SACD,gBACA,GAAA,SACF;;CAEE,MAAA,WAAA,eAAA,UAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CACA,MAAK,oBAAoB,eAAc,iBAAa,aAAA,UAAA,QAAA,WAAA,aAAA,SAAA,MAAA,CAAA,EAAA,QAAA,MAAA,OAAA,QAAA,QAAA,MAAA,KAAA,CAAA,CAAA;CACpD,MAAA,iBAAA,gBAAA;EACF,GAAO,QAAQ;EACb,QAAQ,QAAS;;AAEjB,QAAM,CAAA,gBAAU,WAAc,WAAmB,MAAA;EACjD,IAAM,OAAA;AACJ,UAAS,SAAA;;EAET,IAAI,iBAAiB;AACnB,UAAO,eAAK;;EAEd,IAAA,UAAA;AACD,UAAA,KAAA,WAAA,EAAA,EAAA,GACK,kBAAmB,MAAC,WAAa,IAAA,GAAA,kBAAA,QAAA,KAAA,kBAAA,UAAA,SAAA,WAAA,QAAA,KAAA,IACrC,CAAA;;EAEA,IAAI,iBAAiB;AACnB,UAAE,KAAQ,kBAAoB,EAAC,EAAA;IAC/B,KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACF,SAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACD,OAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACK,OAAA;KAAA;KAAiB;KAAgB;KAAA;KAAA;KAAA;KAAA;MAClC,MAAQ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BAAA,UAAA,IAAA,SAAA,sBAAA,WAAA,IAAA;;cAEC,IAAA,WAAe;AACb,sBAAO,gBAAiB,cAAA;gBACtB,IAAI,YAAU;AACZ,wBAAI,IAAA,GAAU,UAAO,IAAM,KAAA,CAAA;;gBAEhC,IAAI,WAAA;AACH,wBAAW,IAAG;;qEAE2B,IAAC,SAAA,sBAAA,SAAA,aAAA,GAAA,6BAAA,IAAA,KAAA;gCACtC,IAAI,cAAS,kBAAA,uBAAA,IAAA,YAAA,CAAA;kCACX,GAAG;;;;;;;kCAOH,IAAI,SAAO,sBAAA,SAAA;;;0CAGR,GAAA;;;;;;;;;8BASP,UAAU,IAAC,KAAQ,CAAC,gEAAsB,IAAA,SAAA,sBAAA,SAAA,iBAAA,GAAA;;;gBAG3C,CAAC;;cAEL,CAAC,CAAC;;YAEN,CAAC,CAAC;WACJ,CAAC;UAAE,IAAI;UAAI,gBAAA,SAAA,EAAA,CAAA;UAAA,gBAAA,wBAAA,EACD,SACV,CAAC;UAAE,gBAAkB,aAAS;WAC7B,WAAU,IAAA;WACV,IAAI,WAAI;;;;WAIT,CAAC;UAAC;;QAEN,CAAC;;MAEL,CAAC,CAAC;;IAEN,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAkB,KAAC;EACtB,IAAI,OAAO;AACT,UAAO,OAAO,OAAM,QAAA,SAAA;;EAEtB,WAAU,UAAG,gBAAA,MAAA;GACX,IAAI,OAAM;AACR,WAAO,MAAA;;GAET,IAAI,WAAW;AACb,WAAO,gBAAI,cAAA,EACT,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAW;AACb,WAAO,gBAAiB,qBAAS,EAC/B,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.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, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { CommandHandlerDeclaration } from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"italic\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"createSpinner\"\n ],\n utils: [\"sleep\", \"isMinimal\", \"isInteractive\", \"isUnicodeSupported\"],\n state: [\n \"useGlobal\",\n \"GlobalOptions\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner();\n await executeUpgrade(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp() && (${Object.values(\n command.options ?? {}\n )\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\\`The following validation failures were found while processing the user provided input, and must be corrected before the \\${italic(\"${command.title}\")} command can be executed: \\\\n\\\\n\\${failures.map(failure => \" - \" + failure).join(\"\\\\n\")}\\`);\n options.help = true; `}\n </IfStatement>\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;CA8CA,MAAO,EACL,SACC,SACD,gBACA,GAAA,SACF;;CAEE,MAAA,WAAA,eAAA,UAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CACA,MAAK,oBAAoB,eAAc,iBAAa,aAAA,UAAA,QAAA,WAAA,aAAA,SAAA,MAAA,CAAA,EAAA,QAAA,MAAA,OAAA,QAAA,QAAA,MAAA,KAAA,CAAA,CAAA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CAAC;UAAE,gBAAiB,aAAS;WAC5B,WAAU,IAAA;WACV,IAAI,WAAM;AACR,mBAAM,IAAI,8IAAiB,QAAA,MAAA;;;;;;QAKlC,CAAC;;MAEL,CAAC,CAAC;;IAEN,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAkB,KAAK;EAC1B,IAAI,OAAO;AACT,UAAO,OAAO,OAAO,QAAA,SAAA;;EAEvB,WAAU,UAAS,gBAAK,MAAA;GACtB,IAAI,OAAO;AACT,WAAO,MAAK;;GAEd,IAAI,WAAS;AACX,WAAO,gBAAS,cAAA,EACd,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAW;AACb,WAAO,gBAAQ,qBAA+B,EAC5C,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -58,15 +58,12 @@ function VirtualCommandEntry(props) {
|
|
|
58
58
|
],
|
|
59
59
|
state: [
|
|
60
60
|
"useGlobal",
|
|
61
|
+
"GlobalOptions",
|
|
61
62
|
"useGlobalOptions",
|
|
62
63
|
"withCommand",
|
|
63
64
|
"useArgs",
|
|
64
65
|
"hasFlag",
|
|
65
|
-
"isHelp"
|
|
66
|
-
{
|
|
67
|
-
name: "GlobalOptions",
|
|
68
|
-
type: true
|
|
69
|
-
}
|
|
66
|
+
"isHelp"
|
|
70
67
|
],
|
|
71
68
|
prompts: [
|
|
72
69
|
"text",
|
|
@@ -55,15 +55,12 @@ function VirtualCommandEntry(props) {
|
|
|
55
55
|
],
|
|
56
56
|
state: [
|
|
57
57
|
"useGlobal",
|
|
58
|
+
"GlobalOptions",
|
|
58
59
|
"useGlobalOptions",
|
|
59
60
|
"withCommand",
|
|
60
61
|
"useArgs",
|
|
61
62
|
"hasFlag",
|
|
62
|
-
"isHelp"
|
|
63
|
-
{
|
|
64
|
-
name: "GlobalOptions",
|
|
65
|
-
type: true
|
|
66
|
-
}
|
|
63
|
+
"isHelp"
|
|
67
64
|
],
|
|
68
65
|
prompts: [
|
|
69
66
|
"text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-command-entry.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 { computed, For, Show } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport { VirtualCommandHandlerDeclaration } from \"@shell-shock/preset-script/components/virtual-command-entry\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\n \"warn\",\n \"error\",\n \"info\",\n \"help\",\n \"table\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"stripAnsi\"\n ],\n utils: [\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"isInteractive\",\n \"findSuggestions\",\n \"sleep\"\n ],\n state: [\n \"useGlobal\",\n \"
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-command-entry.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 { computed, For, Show } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport { VirtualCommandHandlerDeclaration } from \"@shell-shock/preset-script/components/virtual-command-entry\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\n \"warn\",\n \"error\",\n \"info\",\n \"help\",\n \"table\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"stripAnsi\"\n ],\n utils: [\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"isInteractive\",\n \"findSuggestions\",\n \"sleep\"\n ],\n state: [\n \"useGlobal\",\n \"GlobalOptions\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\"\n ],\n prompts: [\"text\", \"numeric\", \"toggle\", \"select\", \"isCancel\"],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"]\n })}>\n <Spacing />\n <VirtualCommandHandlerDeclaration command={command}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,SAAE,oBAAA,OAAA;CACA,MAAK,EACL,SACF,SACE,4BAEA;CACA,MAAM,UAAU,eAAc;CAC9B,MAAE,WAAS,eAAA,UAAA,QAAA,WAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;AACX,QAAI,CAAA,gBAAiB,gBAAA,WAAA,MAAA;EACnB,IAAE,OAAQ;AACR,UAAG,SAAO;;EAEZ,IAAG,UAAQ;AACX,UAAA,KAAA,WAAA,EAAA,EAAA,OAAA,QAAA,QAAA,SAAA,CAAA,QAAA,GAAA,WAAA,MAAA,UAAA,CAAA,QAAA,KAAA,CAAA,MAAA,WAAA;AACD,QAAA,KAAA,MAAA,UAAA,CAAA;;KAEM,OAAA,SAAA,WAAA,KAAA;KACJ,CAAA;AACE,WAAA;MACE,EAAE,CAAK,CAAA;;EAEZ,IAAI,iBAAa;AACf,UAAI,KAAQ,kBAAK,EAAA,EAAA;IACf,KAAE,CAAA,iBAAe,UAAgB;IACjC,SAAK;KAAA;KAAW;KAAW;KAAM;KAAS;KAAA;KAAA;KAAA;KAAA;KAAA;IAC1C,OAAK;KAAA;KAAc;KAAiB;KAAA;KAAA;KAAA;IACpC,OAAM;KAAA;KAAe;KAAU;KAAA;KAAA;KAAA;KAAA;KAAA;IAC/B,SAAS;KAAC;KAAO;KAAU;KAAQ;KAAQ;KAAiB;KAC3D,UAAM,QAAA,GAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,GAAA,CAAA,WAAA;;IAER,CAAC;;EAEJ,IAAI,WAAC;AACH,UAAE,CAAA,gBAAqB,SAAA,EAAc,CAAC,EAAE,gBAAK,kCAAA;IAClC;IACT,IAAE,WAAS;AACT,YAAO,gBAAC,eAAA;MACN,IAAC,WAAM;AACN,cAAK,QAAA;;MAEN,IAAC,WAAM;AACN,cAAA,QAAU;;MAEZ,CAAC;;IAEL,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAgB,KAAA;EACnB,IAAI,OAAK;AACP,UAAO,OAAA,OAAc,QAAA,SAAA;;EAEvB,WAAS,UAAK,gBAAA,MAAA;GACZ,IAAI,OAAC;AACH,WAAO,MAAE;;GAEX,IAAI,WAAG;AACL,WAAK,gBAAiB,cAAA,EACpB,SAAG,OACJ,CAAC;;GAEJ,IAAI,WAAS;AACX,WAAG,gBAAA,qBAAA,EACD,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -104,7 +104,7 @@ function ChangelogCommand() {
|
|
|
104
104
|
return !!result.error;
|
|
105
105
|
},
|
|
106
106
|
get children() {
|
|
107
|
-
return _alloy_js_core.code` return error(\`Failed to load changelog: ${result.error.message.replaceAll(
|
|
107
|
+
return _alloy_js_core.code` return error(\`Failed to load changelog: ${result.error.message.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${").replaceAll("\n", "\\n").replaceAll("\r", "\\r").replaceAll(" ", "\\t")}\`); `;
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
},
|
|
@@ -103,7 +103,7 @@ function ChangelogCommand() {
|
|
|
103
103
|
return !!result.error;
|
|
104
104
|
},
|
|
105
105
|
get children() {
|
|
106
|
-
return code` return error(\`Failed to load changelog: ${result.error.message.replaceAll(
|
|
106
|
+
return code` return error(\`Failed to load changelog: ${result.error.message.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${").replaceAll("\n", "\\n").replaceAll("\r", "\\r").replaceAll(" ", "\\t")}\`); `;
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog-command.mjs","names":["renderMarkdown"],"sources":["../../../../../../plugin-changelog/dist/components/changelog-command.mjs"],"sourcesContent":["import { createComponent } from \"@alloy-js/core/jsx-runtime\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { Show, code, createResource } from \"@alloy-js/core\";\nimport { FunctionDeclaration, InterfaceDeclaration } from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { InterfaceMember, TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { TSDoc, TSDocDefaultValue, TSDocParam } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { renderMarkdown } from \"@shell-shock/unified/markdown\";\nimport { joinPaths } from \"@stryke/path\";\n\n//#region src/components/changelog-command.tsx\n/**\n* The Changelog command's handler wrapper for the Shell Shock project.\n*/\nfunction ChangelogCommand() {\n\tconst context = usePowerlines();\n\tconst result = createResource(async () => {\n\t\tconst content = await context.fs.read(context.config.changelog.file);\n\t\tif (!content) return null;\n\t\treturn renderMarkdown(content);\n\t});\n\treturn createComponent(TypescriptFile, {\n\t\tget path() {\n\t\t\treturn joinPaths(context.entryPath, \"changelog\", \"command.ts\");\n\t\t},\n\t\timports: {\n\t\t\t\"node:os\": \"os\",\n\t\t\t\"node:fs/promises\": [\"readFile\", \"writeFile\"]\n\t\t},\n\t\tbuiltinImports: { console: [\n\t\t\t\"textColors\",\n\t\t\t\"bold\",\n\t\t\t\"writeLine\",\n\t\t\t\"error\",\n\t\t\t\"warn\"\n\t\t] },\n\t\tget children() {\n\t\t\treturn [\n\t\t\t\tcreateComponent(TSDoc, { heading: \"Options for the Changelog command.\" }),\n\t\t\t\tcreateComponent(InterfaceDeclaration, {\n\t\t\t\t\t\"export\": true,\n\t\t\t\t\tname: \"ChangelogOptions\",\n\t\t\t\t\tget children() {\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tcreateComponent(TSDoc, { heading: \"An optional starting version for the changelog. The command will attempt to display changes starting from the specified version. The version should be a valid semantic version string. If not specified, the changelog will start from the earliest version available.\" }),\n\t\t\t\t\t\t\tcreateComponent(InterfaceMember, {\n\t\t\t\t\t\t\t\tname: \"start\",\n\t\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t\t\ttype: \"string\"\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcreateComponent(Spacing, {}),\n\t\t\t\t\t\t\tcreateComponent(TSDoc, {\n\t\t\t\t\t\t\t\theading: \"An optional ending version for the changelog. The command will attempt to display changes up to the specified version. The version should be a valid semantic version string. If not specified, the changelog will display changes up to the latest version available.\",\n\t\t\t\t\t\t\t\tget children() {\n\t\t\t\t\t\t\t\t\treturn createComponent(TSDocDefaultValue, {\n\t\t\t\t\t\t\t\t\t\tget type() {\n\t\t\t\t\t\t\t\t\t\t\treturn ReflectionKind.string;\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdefaultValue: \"latest\"\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcreateComponent(InterfaceMember, {\n\t\t\t\t\t\t\t\tname: \"end\",\n\t\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t\t\ttype: \"string\"\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tcreateComponent(Spacing, {}),\n\t\t\t\tcreateComponent(TSDoc, {\n\t\t\t\t\tget heading() {\n\t\t\t\t\t\treturn `Display the ${getAppTitle(context)} changelog.`;\n\t\t\t\t\t},\n\t\t\t\t\tget children() {\n\t\t\t\t\t\treturn createComponent(TSDocParam, {\n\t\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\t\tchildren: code`An object containing options for displaying the changelog.`\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tcreateComponent(FunctionDeclaration, {\n\t\t\t\t\t\"export\": true,\n\t\t\t\t\t\"default\": true,\n\t\t\t\t\tasync: true,\n\t\t\t\t\tname: \"handler\",\n\t\t\t\t\tparameters: [{\n\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\ttype: \"ChangelogOptions\"\n\t\t\t\t\t}],\n\t\t\t\t\tget children() {\n\t\t\t\t\t\treturn createComponent(Show, {\n\t\t\t\t\t\t\tget when() {\n\t\t\t\t\t\t\t\treturn !result.loading && !result.error;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tget fallback() {\n\t\t\t\t\t\t\t\treturn createComponent(Show, {\n\t\t\t\t\t\t\t\t\tget when() {\n\t\t\t\t\t\t\t\t\t\treturn !!result.error;\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tget children() {\n\t\t\t\t\t\t\t\t\t\treturn code` return error(\\`Failed to load changelog: ${result.error.message.replaceAll(
|
|
1
|
+
{"version":3,"file":"changelog-command.mjs","names":["renderMarkdown"],"sources":["../../../../../../plugin-changelog/dist/components/changelog-command.mjs"],"sourcesContent":["import { createComponent } from \"@alloy-js/core/jsx-runtime\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { Show, code, createResource } from \"@alloy-js/core\";\nimport { FunctionDeclaration, InterfaceDeclaration } from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { InterfaceMember, TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { TSDoc, TSDocDefaultValue, TSDocParam } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { renderMarkdown } from \"@shell-shock/unified/markdown\";\nimport { joinPaths } from \"@stryke/path\";\n\n//#region src/components/changelog-command.tsx\n/**\n* The Changelog command's handler wrapper for the Shell Shock project.\n*/\nfunction ChangelogCommand() {\n\tconst context = usePowerlines();\n\tconst result = createResource(async () => {\n\t\tconst content = await context.fs.read(context.config.changelog.file);\n\t\tif (!content) return null;\n\t\treturn renderMarkdown(content);\n\t});\n\treturn createComponent(TypescriptFile, {\n\t\tget path() {\n\t\t\treturn joinPaths(context.entryPath, \"changelog\", \"command.ts\");\n\t\t},\n\t\timports: {\n\t\t\t\"node:os\": \"os\",\n\t\t\t\"node:fs/promises\": [\"readFile\", \"writeFile\"]\n\t\t},\n\t\tbuiltinImports: { console: [\n\t\t\t\"textColors\",\n\t\t\t\"bold\",\n\t\t\t\"writeLine\",\n\t\t\t\"error\",\n\t\t\t\"warn\"\n\t\t] },\n\t\tget children() {\n\t\t\treturn [\n\t\t\t\tcreateComponent(TSDoc, { heading: \"Options for the Changelog command.\" }),\n\t\t\t\tcreateComponent(InterfaceDeclaration, {\n\t\t\t\t\t\"export\": true,\n\t\t\t\t\tname: \"ChangelogOptions\",\n\t\t\t\t\tget children() {\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tcreateComponent(TSDoc, { heading: \"An optional starting version for the changelog. The command will attempt to display changes starting from the specified version. The version should be a valid semantic version string. If not specified, the changelog will start from the earliest version available.\" }),\n\t\t\t\t\t\t\tcreateComponent(InterfaceMember, {\n\t\t\t\t\t\t\t\tname: \"start\",\n\t\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t\t\ttype: \"string\"\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcreateComponent(Spacing, {}),\n\t\t\t\t\t\t\tcreateComponent(TSDoc, {\n\t\t\t\t\t\t\t\theading: \"An optional ending version for the changelog. The command will attempt to display changes up to the specified version. The version should be a valid semantic version string. If not specified, the changelog will display changes up to the latest version available.\",\n\t\t\t\t\t\t\t\tget children() {\n\t\t\t\t\t\t\t\t\treturn createComponent(TSDocDefaultValue, {\n\t\t\t\t\t\t\t\t\t\tget type() {\n\t\t\t\t\t\t\t\t\t\t\treturn ReflectionKind.string;\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdefaultValue: \"latest\"\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcreateComponent(InterfaceMember, {\n\t\t\t\t\t\t\t\tname: \"end\",\n\t\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t\t\ttype: \"string\"\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tcreateComponent(Spacing, {}),\n\t\t\t\tcreateComponent(TSDoc, {\n\t\t\t\t\tget heading() {\n\t\t\t\t\t\treturn `Display the ${getAppTitle(context)} changelog.`;\n\t\t\t\t\t},\n\t\t\t\t\tget children() {\n\t\t\t\t\t\treturn createComponent(TSDocParam, {\n\t\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\t\tchildren: code`An object containing options for displaying the changelog.`\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tcreateComponent(FunctionDeclaration, {\n\t\t\t\t\t\"export\": true,\n\t\t\t\t\t\"default\": true,\n\t\t\t\t\tasync: true,\n\t\t\t\t\tname: \"handler\",\n\t\t\t\t\tparameters: [{\n\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\ttype: \"ChangelogOptions\"\n\t\t\t\t\t}],\n\t\t\t\t\tget children() {\n\t\t\t\t\t\treturn createComponent(Show, {\n\t\t\t\t\t\t\tget when() {\n\t\t\t\t\t\t\t\treturn !result.loading && !result.error;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tget fallback() {\n\t\t\t\t\t\t\t\treturn createComponent(Show, {\n\t\t\t\t\t\t\t\t\tget when() {\n\t\t\t\t\t\t\t\t\t\treturn !!result.error;\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tget children() {\n\t\t\t\t\t\t\t\t\t\treturn code` return error(\\`Failed to load changelog: ${result.error.message.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\"`\", \"\\\\`\").replaceAll(\"${\", \"\\\\${\").replaceAll(\"\\n\", \"\\\\n\").replaceAll(\"\\r\", \"\\\\r\").replaceAll(\"\t\", \"\\\\t\")}\\`); `;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tget children() {\n\t\t\t\t\t\t\t\treturn createComponent(Show, {\n\t\t\t\t\t\t\t\t\tget when() {\n\t\t\t\t\t\t\t\t\t\treturn !!result.data;\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tfallback: code` return warn(\"There is no changelog available for display.\"); `,\n\t\t\t\t\t\t\t\t\tget children() {\n\t\t\t\t\t\t\t\t\t\treturn result.data;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t];\n\t\t}\n\t});\n}\n\n//#endregion\nexport { ChangelogCommand };\n//# sourceMappingURL=changelog-command.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAS,mBAAmB;CAC3B,MAAM,UAAU,eAAe;CAC/B,MAAM,SAAS,eAAe,YAAY;EACzC,MAAM,UAAU,MAAM,QAAQ,GAAG,KAAK,QAAQ,OAAO,UAAU,KAAK;AACpE,MAAI,CAAC,QAAS,QAAO;AACr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gBAAgB,MAAM;SAC5B,IAAI,OAAO;AACV,iBAAO,CAAC,CAAC,OAAO;;SAEjB,IAAI,WAAW;AACd,iBAAO,IAAI,6CAA6C,OAAO,MAAM,QAAQ,WAAW,MAAM,OAAO,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,MAAM,OAAO,CAAC,WAAW,MAAM,MAAM,CAAC,WAAW,MAAM,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC;;SAE9N,CAAC;;OAEH,IAAI,WAAW;AACd,eAAO,gBAAgB,MAAM;SAC5B,IAAI,OAAO;AACV,iBAAO,CAAC,CAAC,OAAO;;SAEjB,UAAU,IAAI;SACd,IAAI,WAAW;AACd,iBAAO,OAAO;;SAEf,CAAC;;OAEH,CAAC;;KAEH,CAAC;IACF;;EAEF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let _stryke_path = require("@stryke/path");
|
|
3
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
4
|
+
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
|
+
|
|
7
|
+
//#region ../plugin-changelog/dist/helpers/resolve-changelog.mjs
|
|
8
|
+
const CHANGELOG_FILE_EXTENSIONS = [
|
|
9
|
+
"md",
|
|
10
|
+
"markdown",
|
|
11
|
+
"txt"
|
|
12
|
+
];
|
|
13
|
+
const CHANGELOG_FILE_NAMES = [
|
|
14
|
+
"CHANGELOG",
|
|
15
|
+
"changelog",
|
|
16
|
+
"Changelog",
|
|
17
|
+
"RELEASE-NOTES",
|
|
18
|
+
"release-notes",
|
|
19
|
+
"Release-Notes",
|
|
20
|
+
"RELEASE_NOTES",
|
|
21
|
+
"release_notes",
|
|
22
|
+
"Release_Notes",
|
|
23
|
+
"RELEASES",
|
|
24
|
+
"releases",
|
|
25
|
+
"Releases",
|
|
26
|
+
"HISTORY",
|
|
27
|
+
"history",
|
|
28
|
+
"History"
|
|
29
|
+
];
|
|
30
|
+
function resolveChangelogFile(context, fileName) {
|
|
31
|
+
for (const ext of CHANGELOG_FILE_EXTENSIONS) if (fileName && (0, node_fs.existsSync)((0, powerlines_plugin_utils.replacePathTokens)(context, (0, _stryke_path_join.joinPaths)("{root}", (0, _stryke_path.appendExtension)(fileName, ext))))) return (0, _stryke_path_join.joinPaths)("{root}", (0, _stryke_path.appendExtension)(fileName, ext));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the path to the changelog file based on the provided options and context. If a specific file is provided in the options, it will attempt to resolve that file first. If not, it will look for common changelog file names in the application's root directory.
|
|
35
|
+
*
|
|
36
|
+
* @param context - The unresolved context of the plugin, which includes information about the application's root directory and other relevant data for resolving paths.
|
|
37
|
+
* @param options - The options provided for the changelog plugin, which may include a specific file name to look for.
|
|
38
|
+
* @returns The resolved path to the changelog file if found, or undefined if no valid changelog file could be resolved.
|
|
39
|
+
*/
|
|
40
|
+
function resolveChangelog(context, options) {
|
|
41
|
+
let changelogFile = resolveChangelogFile(context, options.file);
|
|
42
|
+
if (changelogFile) return changelogFile;
|
|
43
|
+
for (const name of CHANGELOG_FILE_NAMES) {
|
|
44
|
+
changelogFile = resolveChangelogFile(context, name);
|
|
45
|
+
if (changelogFile) return changelogFile;
|
|
46
|
+
}
|
|
47
|
+
return changelogFile;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.resolveChangelog = resolveChangelog;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { appendExtension } from "@stryke/path";
|
|
2
|
+
import { joinPaths as joinPaths$1 } from "@stryke/path/join";
|
|
3
|
+
import { replacePathTokens } from "powerlines/plugin-utils";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
|
|
6
|
+
//#region ../plugin-changelog/dist/helpers/resolve-changelog.mjs
|
|
7
|
+
const CHANGELOG_FILE_EXTENSIONS = [
|
|
8
|
+
"md",
|
|
9
|
+
"markdown",
|
|
10
|
+
"txt"
|
|
11
|
+
];
|
|
12
|
+
const CHANGELOG_FILE_NAMES = [
|
|
13
|
+
"CHANGELOG",
|
|
14
|
+
"changelog",
|
|
15
|
+
"Changelog",
|
|
16
|
+
"RELEASE-NOTES",
|
|
17
|
+
"release-notes",
|
|
18
|
+
"Release-Notes",
|
|
19
|
+
"RELEASE_NOTES",
|
|
20
|
+
"release_notes",
|
|
21
|
+
"Release_Notes",
|
|
22
|
+
"RELEASES",
|
|
23
|
+
"releases",
|
|
24
|
+
"Releases",
|
|
25
|
+
"HISTORY",
|
|
26
|
+
"history",
|
|
27
|
+
"History"
|
|
28
|
+
];
|
|
29
|
+
function resolveChangelogFile(context, fileName) {
|
|
30
|
+
for (const ext of CHANGELOG_FILE_EXTENSIONS) if (fileName && existsSync(replacePathTokens(context, joinPaths$1("{root}", appendExtension(fileName, ext))))) return joinPaths$1("{root}", appendExtension(fileName, ext));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the path to the changelog file based on the provided options and context. If a specific file is provided in the options, it will attempt to resolve that file first. If not, it will look for common changelog file names in the application's root directory.
|
|
34
|
+
*
|
|
35
|
+
* @param context - The unresolved context of the plugin, which includes information about the application's root directory and other relevant data for resolving paths.
|
|
36
|
+
* @param options - The options provided for the changelog plugin, which may include a specific file name to look for.
|
|
37
|
+
* @returns The resolved path to the changelog file if found, or undefined if no valid changelog file could be resolved.
|
|
38
|
+
*/
|
|
39
|
+
function resolveChangelog(context, options) {
|
|
40
|
+
let changelogFile = resolveChangelogFile(context, options.file);
|
|
41
|
+
if (changelogFile) return changelogFile;
|
|
42
|
+
for (const name of CHANGELOG_FILE_NAMES) {
|
|
43
|
+
changelogFile = resolveChangelogFile(context, name);
|
|
44
|
+
if (changelogFile) return changelogFile;
|
|
45
|
+
}
|
|
46
|
+
return changelogFile;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { resolveChangelog };
|
|
51
|
+
//# sourceMappingURL=resolve-changelog.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-changelog.mjs","names":["joinPaths"],"sources":["../../../../../../plugin-changelog/dist/helpers/resolve-changelog.mjs"],"sourcesContent":["import { joinPaths } from \"@stryke/path/join\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\nimport { appendExtension } from \"@stryke/path\";\nimport { existsSync } from \"node:fs\";\n\n//#region src/helpers/resolve-changelog.ts\nconst CHANGELOG_FILE_EXTENSIONS = [\n\t\"md\",\n\t\"markdown\",\n\t\"txt\"\n];\nconst CHANGELOG_FILE_NAMES = [\n\t\"CHANGELOG\",\n\t\"changelog\",\n\t\"Changelog\",\n\t\"RELEASE-NOTES\",\n\t\"release-notes\",\n\t\"Release-Notes\",\n\t\"RELEASE_NOTES\",\n\t\"release_notes\",\n\t\"Release_Notes\",\n\t\"RELEASES\",\n\t\"releases\",\n\t\"Releases\",\n\t\"HISTORY\",\n\t\"history\",\n\t\"History\"\n];\nfunction resolveChangelogFile(context, fileName) {\n\tfor (const ext of CHANGELOG_FILE_EXTENSIONS) if (fileName && existsSync(replacePathTokens(context, joinPaths(\"{root}\", appendExtension(fileName, ext))))) return joinPaths(\"{root}\", appendExtension(fileName, ext));\n}\n/**\n* Resolves the path to the changelog file based on the provided options and context. If a specific file is provided in the options, it will attempt to resolve that file first. If not, it will look for common changelog file names in the application's root directory.\n*\n* @param context - The unresolved context of the plugin, which includes information about the application's root directory and other relevant data for resolving paths.\n* @param options - The options provided for the changelog plugin, which may include a specific file name to look for.\n* @returns The resolved path to the changelog file if found, or undefined if no valid changelog file could be resolved.\n*/\nfunction resolveChangelog(context, options) {\n\tlet changelogFile = resolveChangelogFile(context, options.file);\n\tif (changelogFile) return changelogFile;\n\tfor (const name of CHANGELOG_FILE_NAMES) {\n\t\tchangelogFile = resolveChangelogFile(context, name);\n\t\tif (changelogFile) return changelogFile;\n\t}\n\treturn changelogFile;\n}\n\n//#endregion\nexport { resolveChangelog };\n//# sourceMappingURL=resolve-changelog.mjs.map"],"mappings":";;;;;;AAMA,MAAM,4BAA4B;CACjC;CACA;CACA;CACA;AACD,MAAM,uBAAuB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,SAAS,qBAAqB,SAAS,UAAU;AAChD,MAAK,MAAM,OAAO,0BAA2B,KAAI,YAAY,WAAW,kBAAkB,SAASA,YAAU,UAAU,gBAAgB,UAAU,IAAI,CAAC,CAAC,CAAC,CAAE,QAAOA,YAAU,UAAU,gBAAgB,UAAU,IAAI,CAAC;;;;;;;;;AASrN,SAAS,iBAAiB,SAAS,SAAS;CAC3C,IAAI,gBAAgB,qBAAqB,SAAS,QAAQ,KAAK;AAC/D,KAAI,cAAe,QAAO;AAC1B,MAAK,MAAM,QAAQ,sBAAsB;AACxC,kBAAgB,qBAAqB,SAAS,KAAK;AACnD,MAAI,cAAe,QAAO;;AAE3B,QAAO"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_changelog_command = require('./components/changelog-command.cjs');
|
|
3
3
|
require('./components/index.cjs');
|
|
4
|
+
const require_resolve_changelog = require('./helpers/resolve-changelog.cjs');
|
|
4
5
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
6
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
6
7
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
7
8
|
let _stryke_path_join = require("@stryke/path/join");
|
|
9
|
+
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
8
10
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
9
11
|
let defu = require("defu");
|
|
10
12
|
defu = require_runtime.__toESM(defu);
|
|
11
|
-
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
12
13
|
|
|
13
14
|
//#region ../plugin-changelog/dist/index.mjs
|
|
14
15
|
/**
|
|
@@ -19,30 +20,41 @@ const plugin = (options = {}) => {
|
|
|
19
20
|
name: "shell-shock:changelog",
|
|
20
21
|
config() {
|
|
21
22
|
this.debug("Providing default configuration for the Shell Shock `changelog` plugin.");
|
|
22
|
-
return { changelog: (0, defu.default)({
|
|
23
|
+
return { changelog: (0, defu.default)({
|
|
24
|
+
file: require_resolve_changelog.resolveChangelog(this, options),
|
|
25
|
+
command: { name: (0, _stryke_type_checks_is_set_string.isSetString)(options.command) ? options.command : "changelog" }
|
|
26
|
+
}, options) };
|
|
23
27
|
},
|
|
24
28
|
configResolved() {
|
|
25
29
|
this.debug("Adding the CLI changelog commands to the application context.");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.changelog.file)) {
|
|
31
|
+
this.config.changelog.file = (0, powerlines_plugin_utils.replacePathTokens)(this, this.config.changelog.file);
|
|
32
|
+
if (!this.fs.existsSync(this.config.changelog.file)) {
|
|
33
|
+
this.warn(`The changelog file could not be found at the resolved path: ${this.config.changelog.file}. The \`${this.config.changelog.command.name}\` command will not be added to the application. Please ensure that the changelog file exists at the specified path or adjust the \`changelog.file\` option to point to the correct location.`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.inputs ??= [];
|
|
37
|
+
if (this.inputs.some((input) => input.id === this.config.changelog.command.name)) this.info("The `changelog` command already exists in the commands list. If you would like the changelog command to be managed by the `@shell-shock/plugin-changelog` package, please remove or rename the command.");
|
|
38
|
+
else this.inputs.push({
|
|
39
|
+
id: this.config.changelog.command.name,
|
|
40
|
+
path: this.config.changelog.command.name,
|
|
41
|
+
segments: [this.config.changelog.command.name],
|
|
42
|
+
title: "Changelog",
|
|
43
|
+
icon: "🗃",
|
|
44
|
+
tags: ["Utility"],
|
|
45
|
+
description: `Display the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(this)} changelog.`,
|
|
46
|
+
entry: {
|
|
47
|
+
file: (0, _stryke_path_join.joinPaths)(this.entryPath, "changelog", "index.ts"),
|
|
48
|
+
input: { file: (0, _stryke_path_join.joinPaths)(this.entryPath, "changelog", "command.ts") }
|
|
49
|
+
},
|
|
50
|
+
isVirtual: false,
|
|
51
|
+
source: "changelog-plugin",
|
|
52
|
+
...this.config.changelog.command
|
|
53
|
+
});
|
|
54
|
+
}
|
|
44
55
|
},
|
|
45
56
|
async prepare() {
|
|
57
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.changelog.file) && !this.fs.existsSync(this.config.changelog.file)) return;
|
|
46
58
|
this.debug("Rendering changelog command module for the Shell Shock `changelog` plugin.");
|
|
47
59
|
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_changelog_command.ChangelogCommand, {}));
|
|
48
60
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ChangelogCommand } from "./components/changelog-command.mjs";
|
|
2
2
|
import "./components/index.mjs";
|
|
3
|
+
import { resolveChangelog } from "./helpers/resolve-changelog.mjs";
|
|
3
4
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
5
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
5
6
|
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
6
7
|
import { joinPaths } from "@stryke/path/join";
|
|
8
|
+
import { replacePathTokens } from "powerlines/plugin-utils";
|
|
7
9
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
8
10
|
import defu from "defu";
|
|
9
|
-
import { replacePathTokens } from "powerlines/plugin-utils";
|
|
10
11
|
|
|
11
12
|
//#region ../plugin-changelog/dist/index.mjs
|
|
12
13
|
/**
|
|
@@ -17,30 +18,41 @@ const plugin = (options = {}) => {
|
|
|
17
18
|
name: "shell-shock:changelog",
|
|
18
19
|
config() {
|
|
19
20
|
this.debug("Providing default configuration for the Shell Shock `changelog` plugin.");
|
|
20
|
-
return { changelog: defu({
|
|
21
|
+
return { changelog: defu({
|
|
22
|
+
file: resolveChangelog(this, options),
|
|
23
|
+
command: { name: isSetString(options.command) ? options.command : "changelog" }
|
|
24
|
+
}, options) };
|
|
21
25
|
},
|
|
22
26
|
configResolved() {
|
|
23
27
|
this.debug("Adding the CLI changelog commands to the application context.");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
if (isSetString(this.config.changelog.file)) {
|
|
29
|
+
this.config.changelog.file = replacePathTokens(this, this.config.changelog.file);
|
|
30
|
+
if (!this.fs.existsSync(this.config.changelog.file)) {
|
|
31
|
+
this.warn(`The changelog file could not be found at the resolved path: ${this.config.changelog.file}. The \`${this.config.changelog.command.name}\` command will not be added to the application. Please ensure that the changelog file exists at the specified path or adjust the \`changelog.file\` option to point to the correct location.`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this.inputs ??= [];
|
|
35
|
+
if (this.inputs.some((input) => input.id === this.config.changelog.command.name)) this.info("The `changelog` command already exists in the commands list. If you would like the changelog command to be managed by the `@shell-shock/plugin-changelog` package, please remove or rename the command.");
|
|
36
|
+
else this.inputs.push({
|
|
37
|
+
id: this.config.changelog.command.name,
|
|
38
|
+
path: this.config.changelog.command.name,
|
|
39
|
+
segments: [this.config.changelog.command.name],
|
|
40
|
+
title: "Changelog",
|
|
41
|
+
icon: "🗃",
|
|
42
|
+
tags: ["Utility"],
|
|
43
|
+
description: `Display the ${getAppTitle(this)} changelog.`,
|
|
44
|
+
entry: {
|
|
45
|
+
file: joinPaths(this.entryPath, "changelog", "index.ts"),
|
|
46
|
+
input: { file: joinPaths(this.entryPath, "changelog", "command.ts") }
|
|
47
|
+
},
|
|
48
|
+
isVirtual: false,
|
|
49
|
+
source: "changelog-plugin",
|
|
50
|
+
...this.config.changelog.command
|
|
51
|
+
});
|
|
52
|
+
}
|
|
42
53
|
},
|
|
43
54
|
async prepare() {
|
|
55
|
+
if (isSetString(this.config.changelog.file) && !this.fs.existsSync(this.config.changelog.file)) return;
|
|
44
56
|
this.debug("Rendering changelog command module for the Shell Shock `changelog` plugin.");
|
|
45
57
|
return render(this, createComponent(ChangelogCommand, {}));
|
|
46
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../plugin-changelog/dist/index.mjs"],"sourcesContent":["import { ChangelogCommand } from \"./components/changelog-command.mjs\";\nimport \"./components/index.mjs\";\nimport { createComponent } from \"@alloy-js/core/jsx-runtime\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\n\n//#region src/index.tsx\n/**\n* The Changelog - Shell Shock plugin to add version check functionality and changelog commands to a Shell Shock application.\n*/\nconst plugin = (options = {}) => {\n\treturn {\n\t\tname: \"shell-shock:changelog\",\n\t\tconfig() {\n\t\t\tthis.debug(\"Providing default configuration for the Shell Shock `changelog` plugin.\");\n\t\t\treturn { changelog: defu({
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../plugin-changelog/dist/index.mjs"],"sourcesContent":["import { ChangelogCommand } from \"./components/changelog-command.mjs\";\nimport \"./components/index.mjs\";\nimport { resolveChangelog } from \"./helpers/resolve-changelog.mjs\";\nimport { createComponent } from \"@alloy-js/core/jsx-runtime\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\n\n//#region src/index.tsx\n/**\n* The Changelog - Shell Shock plugin to add version check functionality and changelog commands to a Shell Shock application.\n*/\nconst plugin = (options = {}) => {\n\treturn {\n\t\tname: \"shell-shock:changelog\",\n\t\tconfig() {\n\t\t\tthis.debug(\"Providing default configuration for the Shell Shock `changelog` plugin.\");\n\t\t\treturn { changelog: defu({\n\t\t\t\tfile: resolveChangelog(this, options),\n\t\t\t\tcommand: { name: isSetString(options.command) ? options.command : \"changelog\" }\n\t\t\t}, options) };\n\t\t},\n\t\tconfigResolved() {\n\t\t\tthis.debug(\"Adding the CLI changelog commands to the application context.\");\n\t\t\tif (isSetString(this.config.changelog.file)) {\n\t\t\t\tthis.config.changelog.file = replacePathTokens(this, this.config.changelog.file);\n\t\t\t\tif (!this.fs.existsSync(this.config.changelog.file)) {\n\t\t\t\t\tthis.warn(`The changelog file could not be found at the resolved path: ${this.config.changelog.file}. The \\`${this.config.changelog.command.name}\\` command will not be added to the application. Please ensure that the changelog file exists at the specified path or adjust the \\`changelog.file\\` option to point to the correct location.`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.inputs ??= [];\n\t\t\t\tif (this.inputs.some((input) => input.id === this.config.changelog.command.name)) this.info(\"The `changelog` command already exists in the commands list. If you would like the changelog command to be managed by the `@shell-shock/plugin-changelog` package, please remove or rename the command.\");\n\t\t\t\telse this.inputs.push({\n\t\t\t\t\tid: this.config.changelog.command.name,\n\t\t\t\t\tpath: this.config.changelog.command.name,\n\t\t\t\t\tsegments: [this.config.changelog.command.name],\n\t\t\t\t\ttitle: \"Changelog\",\n\t\t\t\t\ticon: \"🗃\",\n\t\t\t\t\ttags: [\"Utility\"],\n\t\t\t\t\tdescription: `Display the ${getAppTitle(this)} changelog.`,\n\t\t\t\t\tentry: {\n\t\t\t\t\t\tfile: joinPaths(this.entryPath, \"changelog\", \"index.ts\"),\n\t\t\t\t\t\tinput: { file: joinPaths(this.entryPath, \"changelog\", \"command.ts\") }\n\t\t\t\t\t},\n\t\t\t\t\tisVirtual: false,\n\t\t\t\t\tsource: \"changelog-plugin\",\n\t\t\t\t\t...this.config.changelog.command\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tasync prepare() {\n\t\t\tif (isSetString(this.config.changelog.file) && !this.fs.existsSync(this.config.changelog.file)) return;\n\t\t\tthis.debug(\"Rendering changelog command module for the Shell Shock `changelog` plugin.\");\n\t\t\treturn render(this, createComponent(ChangelogCommand, {}));\n\t\t}\n\t};\n};\n\n//#endregion\nexport { plugin as default, plugin };\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,UAAU,UAAU,EAAE,KAAK;AAChC,QAAO;EACN,MAAM;EACN,SAAS;AACR,QAAK,MAAM,0EAA0E;AACrF,UAAO,EAAE,WAAW,KAAK;IACxB,MAAM,iBAAiB,MAAM,QAAQ;IACrC,SAAS,EAAE,MAAM,YAAY,QAAQ,QAAQ,GAAG,QAAQ,UAAU,aAAa;IAC/E,EAAE,QAAQ,EAAE;;EAEd,iBAAiB;AAChB,QAAK,MAAM,gEAAgE;AAC3E,OAAI,YAAY,KAAK,OAAO,UAAU,KAAK,EAAE;AAC5C,SAAK,OAAO,UAAU,OAAO,kBAAkB,MAAM,KAAK,OAAO,UAAU,KAAK;AAChF,QAAI,CAAC,KAAK,GAAG,WAAW,KAAK,OAAO,UAAU,KAAK,EAAE;AACpD,UAAK,KAAK,+DAA+D,KAAK,OAAO,UAAU,KAAK,UAAU,KAAK,OAAO,UAAU,QAAQ,KAAK,+LAA+L;AAChV;;AAED,SAAK,WAAW,EAAE;AAClB,QAAI,KAAK,OAAO,MAAM,UAAU,MAAM,OAAO,KAAK,OAAO,UAAU,QAAQ,KAAK,CAAE,MAAK,KAAK,0MAA0M;QACjS,MAAK,OAAO,KAAK;KACrB,IAAI,KAAK,OAAO,UAAU,QAAQ;KAClC,MAAM,KAAK,OAAO,UAAU,QAAQ;KACpC,UAAU,CAAC,KAAK,OAAO,UAAU,QAAQ,KAAK;KAC9C,OAAO;KACP,MAAM;KACN,MAAM,CAAC,UAAU;KACjB,aAAa,eAAe,YAAY,KAAK,CAAC;KAC9C,OAAO;MACN,MAAM,UAAU,KAAK,WAAW,aAAa,WAAW;MACxD,OAAO,EAAE,MAAM,UAAU,KAAK,WAAW,aAAa,aAAa,EAAE;MACrE;KACD,WAAW;KACX,QAAQ;KACR,GAAG,KAAK,OAAO,UAAU;KACzB,CAAC;;;EAGJ,MAAM,UAAU;AACf,OAAI,YAAY,KAAK,OAAO,UAAU,KAAK,IAAI,CAAC,KAAK,GAAG,WAAW,KAAK,OAAO,UAAU,KAAK,CAAE;AAChG,QAAK,MAAM,6EAA6E;AACxF,UAAO,OAAO,MAAM,gBAAgB,kBAAkB,EAAE,CAAC,CAAC;;EAE3D"}
|
|
@@ -7,6 +7,54 @@ interface ChangelogPluginOptions {
|
|
|
7
7
|
/**
|
|
8
8
|
* The path to the changelog file to read when executing the `changelog` command. This can be an absolute path or a path relative to the application's root directory.
|
|
9
9
|
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* If not provided, the plugin will attempt to resolve the changelog file by looking for common changelog file names (e.g., `CHANGELOG.md`, `RELEASE-NOTES.md`, etc.) in the application's root directory. If a specific file name is provided but cannot be found, it will fall back to looking for common changelog file names. If no valid changelog file can be resolved, the `changelog` command will not be added to the application. The following list of common changelog file names will be used for resolution:
|
|
12
|
+
* - `CHANGELOG.md`
|
|
13
|
+
* - `changelog.md`
|
|
14
|
+
* - `Changelog.md`
|
|
15
|
+
* - `CHANGELOG.markdown`
|
|
16
|
+
* - `changelog.markdown`
|
|
17
|
+
* - `Changelog.markdown`
|
|
18
|
+
* - `CHANGELOG.txt`
|
|
19
|
+
* - `changelog.txt`
|
|
20
|
+
* - `Changelog.txt`
|
|
21
|
+
* - `RELEASE-NOTES.md`
|
|
22
|
+
* - `release-notes.md`
|
|
23
|
+
* - `Release-Notes.md`
|
|
24
|
+
* - `RELEASE-NOTES.markdown`
|
|
25
|
+
* - `release-notes.markdown`
|
|
26
|
+
* - `Release-Notes.markdown`
|
|
27
|
+
* - `RELEASE-NOTES.txt`
|
|
28
|
+
* - `release-notes.txt`
|
|
29
|
+
* - `Release-Notes.txt`
|
|
30
|
+
* - `RELEASE_NOTES.md`
|
|
31
|
+
* - `release_notes.md`
|
|
32
|
+
* - `Release_Notes.md`
|
|
33
|
+
* - `RELEASE_NOTES.markdown`
|
|
34
|
+
* - `release_notes.markdown`
|
|
35
|
+
* - `Release_Notes.markdown`
|
|
36
|
+
* - `RELEASE_NOTES.txt`
|
|
37
|
+
* - `release_notes.txt`
|
|
38
|
+
* - `Release_Notes.txt`
|
|
39
|
+
* - `RELEASES.md`
|
|
40
|
+
* - `releases.md`
|
|
41
|
+
* - `Releases.md`
|
|
42
|
+
* - `RELEASES.markdown`
|
|
43
|
+
* - `releases.markdown`
|
|
44
|
+
* - `Releases.markdown`
|
|
45
|
+
* - `RELEASES.txt`
|
|
46
|
+
* - `releases.txt`
|
|
47
|
+
* - `Releases.txt`
|
|
48
|
+
* - `HISTORY.md`
|
|
49
|
+
* - `history.md`
|
|
50
|
+
* - `History.md`
|
|
51
|
+
* - `HISTORY.markdown`
|
|
52
|
+
* - `history.markdown`
|
|
53
|
+
* - `History.markdown`
|
|
54
|
+
* - `HISTORY.txt`
|
|
55
|
+
* - `history.txt`
|
|
56
|
+
* - `History.txt`
|
|
57
|
+
*
|
|
10
58
|
* @defaultValue "\{root\}/CHANGELOG.md"
|
|
11
59
|
*/
|
|
12
60
|
file?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":["CommandConfig","Context","ResolvedConfig","UserConfig","RequiredKeys","ChangelogPluginOptions","Partial","file","command","ChangelogPluginUserConfig","changelog","ChangelogPluginResolvedConfig","Omit","Required","ChangelogPluginContext","TResolvedConfig"],"sources":["../../../../../../plugin-changelog/dist/types/plugin.d.cts"],"mappings":";;;;;UAIUK,sBAAAA;EAAsB
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":["CommandConfig","Context","ResolvedConfig","UserConfig","RequiredKeys","ChangelogPluginOptions","Partial","file","command","ChangelogPluginUserConfig","changelog","ChangelogPluginResolvedConfig","Omit","Required","ChangelogPluginContext","TResolvedConfig"],"sources":["../../../../../../plugin-changelog/dist/types/plugin.d.cts"],"mappings":";;;;;UAIUK,sBAAAA;EAAsB;;;;;;;;;AA+DC;;;;;;;;;AAME;;;;;;;;;;;;;;;;;;;;;;;AAUY;;;;;;;;;;;;EAzB7CE,IAAAA;EA4B2HQ;;;;;;;;EAnB3HP,OAAAA,GAAUF,OAAAA,CAAQN,aAAAA;AAAAA;AAAAA,KAEfS,yBAAAA,GAA4BN,UAAAA;;;;EAI/BO,SAAAA,EAAWL,sBAAAA;AAAAA;AAAAA,KAERM,6BAAAA,GAAgCT,cAAAA;;;;EAInCQ,SAAAA,EAAWG,QAAAA,CAASD,IAAAA,CAAKP,sBAAAA;;;;IAIvBG,OAAAA,EAASJ,YAAAA,CAAaE,OAAAA,CAAQN,aAAAA;EAAAA;AAAAA;AAAAA,KAG7Bc,sBAAAA,yBAA+CH,6BAAAA,GAAgCA,6BAAAA,IAAiCV,OAAAA,CAAQc,eAAAA"}
|
|
@@ -7,6 +7,54 @@ interface ChangelogPluginOptions {
|
|
|
7
7
|
/**
|
|
8
8
|
* The path to the changelog file to read when executing the `changelog` command. This can be an absolute path or a path relative to the application's root directory.
|
|
9
9
|
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* If not provided, the plugin will attempt to resolve the changelog file by looking for common changelog file names (e.g., `CHANGELOG.md`, `RELEASE-NOTES.md`, etc.) in the application's root directory. If a specific file name is provided but cannot be found, it will fall back to looking for common changelog file names. If no valid changelog file can be resolved, the `changelog` command will not be added to the application. The following list of common changelog file names will be used for resolution:
|
|
12
|
+
* - `CHANGELOG.md`
|
|
13
|
+
* - `changelog.md`
|
|
14
|
+
* - `Changelog.md`
|
|
15
|
+
* - `CHANGELOG.markdown`
|
|
16
|
+
* - `changelog.markdown`
|
|
17
|
+
* - `Changelog.markdown`
|
|
18
|
+
* - `CHANGELOG.txt`
|
|
19
|
+
* - `changelog.txt`
|
|
20
|
+
* - `Changelog.txt`
|
|
21
|
+
* - `RELEASE-NOTES.md`
|
|
22
|
+
* - `release-notes.md`
|
|
23
|
+
* - `Release-Notes.md`
|
|
24
|
+
* - `RELEASE-NOTES.markdown`
|
|
25
|
+
* - `release-notes.markdown`
|
|
26
|
+
* - `Release-Notes.markdown`
|
|
27
|
+
* - `RELEASE-NOTES.txt`
|
|
28
|
+
* - `release-notes.txt`
|
|
29
|
+
* - `Release-Notes.txt`
|
|
30
|
+
* - `RELEASE_NOTES.md`
|
|
31
|
+
* - `release_notes.md`
|
|
32
|
+
* - `Release_Notes.md`
|
|
33
|
+
* - `RELEASE_NOTES.markdown`
|
|
34
|
+
* - `release_notes.markdown`
|
|
35
|
+
* - `Release_Notes.markdown`
|
|
36
|
+
* - `RELEASE_NOTES.txt`
|
|
37
|
+
* - `release_notes.txt`
|
|
38
|
+
* - `Release_Notes.txt`
|
|
39
|
+
* - `RELEASES.md`
|
|
40
|
+
* - `releases.md`
|
|
41
|
+
* - `Releases.md`
|
|
42
|
+
* - `RELEASES.markdown`
|
|
43
|
+
* - `releases.markdown`
|
|
44
|
+
* - `Releases.markdown`
|
|
45
|
+
* - `RELEASES.txt`
|
|
46
|
+
* - `releases.txt`
|
|
47
|
+
* - `Releases.txt`
|
|
48
|
+
* - `HISTORY.md`
|
|
49
|
+
* - `history.md`
|
|
50
|
+
* - `History.md`
|
|
51
|
+
* - `HISTORY.markdown`
|
|
52
|
+
* - `history.markdown`
|
|
53
|
+
* - `History.markdown`
|
|
54
|
+
* - `HISTORY.txt`
|
|
55
|
+
* - `history.txt`
|
|
56
|
+
* - `History.txt`
|
|
57
|
+
*
|
|
10
58
|
* @defaultValue "\{root\}/CHANGELOG.md"
|
|
11
59
|
*/
|
|
12
60
|
file?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":["CommandConfig","Context","ResolvedConfig","UserConfig","RequiredKeys","ChangelogPluginOptions","Partial","file","command","ChangelogPluginUserConfig","changelog","ChangelogPluginResolvedConfig","Omit","Required","ChangelogPluginContext","TResolvedConfig"],"sources":["../../../../../../plugin-changelog/dist/types/plugin.d.cts"],"mappings":";;;;;UAIUK,sBAAAA;EAAsB
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":["CommandConfig","Context","ResolvedConfig","UserConfig","RequiredKeys","ChangelogPluginOptions","Partial","file","command","ChangelogPluginUserConfig","changelog","ChangelogPluginResolvedConfig","Omit","Required","ChangelogPluginContext","TResolvedConfig"],"sources":["../../../../../../plugin-changelog/dist/types/plugin.d.cts"],"mappings":";;;;;UAIUK,sBAAAA;EAAsB;;;;;;;;;AA+DC;;;;;;;;;AAME;;;;;;;;;;;;;;;;;;;;;;;AAUY;;;;;;;;;;;;EAzB7CE,IAAAA;EA4B2HQ;;;;;;;;EAnB3HP,OAAAA,GAAUF,OAAAA,CAAQN,aAAAA;AAAAA;AAAAA,KAEfS,yBAAAA,GAA4BN,UAAAA;;;;EAI/BO,SAAAA,EAAWL,sBAAAA;AAAAA;AAAAA,KAERM,6BAAAA,GAAgCT,cAAAA;;;;EAInCQ,SAAAA,EAAWG,QAAAA,CAASD,IAAAA,CAAKP,sBAAAA;;;;IAIvBG,OAAAA,EAASJ,YAAAA,CAAaE,OAAAA,CAAQN,aAAAA;EAAAA;AAAAA;AAAAA,KAG7Bc,sBAAAA,yBAA+CH,6BAAAA,GAAgCA,6BAAAA,IAAiCV,OAAAA,CAAQc,eAAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shell-shock/preset-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.15",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Shell Shock plugin to generate source code given a list design tokens.",
|
|
6
6
|
"keywords": [
|
|
@@ -181,24 +181,24 @@
|
|
|
181
181
|
"dependencies": {
|
|
182
182
|
"@alloy-js/core": "0.23.0-dev.8",
|
|
183
183
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
184
|
-
"@powerlines/deepkit": "^0.
|
|
185
|
-
"@powerlines/plugin-alloy": "^0.26.
|
|
186
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
187
|
-
"@shell-shock/core": "^0.17.
|
|
188
|
-
"@shell-shock/plugin-banner": "^0.1.
|
|
189
|
-
"@shell-shock/plugin-completions": "^0.4.
|
|
190
|
-
"@shell-shock/plugin-console": "^0.2.
|
|
191
|
-
"@shell-shock/plugin-help": "^0.2.
|
|
192
|
-
"@shell-shock/plugin-prompts": "^0.3.
|
|
193
|
-
"@shell-shock/plugin-theme": "^0.4.
|
|
194
|
-
"@shell-shock/plugin-upgrade": "^0.1.
|
|
195
|
-
"@shell-shock/preset-script": "^0.6.
|
|
184
|
+
"@powerlines/deepkit": "^0.8.0",
|
|
185
|
+
"@powerlines/plugin-alloy": "^0.26.15",
|
|
186
|
+
"@powerlines/plugin-plugin": "^0.12.347",
|
|
187
|
+
"@shell-shock/core": "^0.17.3",
|
|
188
|
+
"@shell-shock/plugin-banner": "^0.1.30",
|
|
189
|
+
"@shell-shock/plugin-completions": "^0.4.11",
|
|
190
|
+
"@shell-shock/plugin-console": "^0.2.7",
|
|
191
|
+
"@shell-shock/plugin-help": "^0.2.21",
|
|
192
|
+
"@shell-shock/plugin-prompts": "^0.3.44",
|
|
193
|
+
"@shell-shock/plugin-theme": "^0.4.16",
|
|
194
|
+
"@shell-shock/plugin-upgrade": "^0.1.48",
|
|
195
|
+
"@shell-shock/preset-script": "^0.6.58",
|
|
196
196
|
"@stryke/path": "^0.27.4",
|
|
197
197
|
"@stryke/string-format": "^0.17.9",
|
|
198
198
|
"@stryke/type-checks": "^0.6.1",
|
|
199
199
|
"cfonts": "^3.3.1",
|
|
200
200
|
"defu": "^6.1.7",
|
|
201
|
-
"powerlines": "^0.42.
|
|
201
|
+
"powerlines": "^0.42.37"
|
|
202
202
|
},
|
|
203
203
|
"devDependencies": {
|
|
204
204
|
"@stryke/types": "^0.11.3",
|
|
@@ -256,5 +256,5 @@
|
|
|
256
256
|
"uc.micro": "2.1.0",
|
|
257
257
|
"wrap-ansi": "10.0.0"
|
|
258
258
|
},
|
|
259
|
-
"gitHead": "
|
|
259
|
+
"gitHead": "d6ec6746792a83206915332c4eb87c9da70a5148"
|
|
260
260
|
}
|