@shell-shock/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/api.cjs +57 -1
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +9 -1
- package/dist/api.d.cts.map +1 -0
- package/dist/api.d.mts +9 -1
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +55 -1
- package/dist/api.mjs.map +1 -0
- package/dist/components/docs.cjs +105 -0
- package/dist/components/docs.cjs.map +1 -0
- package/dist/components/docs.d.cts +56 -0
- package/dist/components/docs.d.cts.map +1 -0
- package/dist/components/docs.d.mts +56 -0
- package/dist/components/docs.d.mts.map +1 -0
- package/dist/components/docs.mjs +102 -0
- package/dist/components/docs.mjs.map +1 -0
- package/dist/components/index.cjs +5 -0
- package/dist/components/index.d.cts +2 -0
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.mjs +3 -0
- package/dist/config.cjs +18 -1
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +2 -1
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +2 -1
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +17 -1
- package/dist/config.mjs.map +1 -0
- package/dist/contexts/command.cjs +21 -0
- package/dist/contexts/command.cjs.map +1 -0
- package/dist/contexts/command.d.cts +18 -0
- package/dist/contexts/command.d.cts.map +1 -0
- package/dist/contexts/command.d.mts +18 -0
- package/dist/contexts/command.d.mts.map +1 -0
- package/dist/contexts/command.mjs +19 -0
- package/dist/contexts/command.mjs.map +1 -0
- package/dist/contexts/index.cjs +4 -0
- package/dist/contexts/index.d.cts +2 -0
- package/dist/contexts/index.d.mts +2 -0
- package/dist/contexts/index.mjs +3 -0
- package/dist/helpers/docs-helpers.cjs +17 -0
- package/dist/helpers/docs-helpers.cjs.map +1 -0
- package/dist/helpers/docs-helpers.mjs +16 -0
- package/dist/helpers/docs-helpers.mjs.map +1 -0
- package/dist/helpers/persistence.cjs +50 -1
- package/dist/helpers/persistence.cjs.map +1 -0
- package/dist/helpers/persistence.mjs +47 -1
- package/dist/helpers/persistence.mjs.map +1 -0
- package/dist/helpers/resolve-command.cjs +177 -1
- package/dist/helpers/resolve-command.cjs.map +1 -0
- package/dist/helpers/resolve-command.mjs +172 -1
- package/dist/helpers/resolve-command.mjs.map +1 -0
- package/dist/helpers/update-package-json.cjs +36 -1
- package/dist/helpers/update-package-json.cjs.map +1 -0
- package/dist/helpers/update-package-json.mjs +34 -1
- package/dist/helpers/update-package-json.mjs.map +1 -0
- package/dist/helpers/utilities.cjs +41 -1
- package/dist/helpers/utilities.cjs.map +1 -0
- package/dist/helpers/utilities.mjs +39 -1
- package/dist/helpers/utilities.mjs.map +1 -0
- package/dist/helpers/validations.cjs +97 -0
- package/dist/helpers/validations.cjs.map +1 -0
- package/dist/helpers/validations.mjs +97 -0
- package/dist/helpers/validations.mjs.map +1 -0
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -18
- package/dist/index.d.mts +6 -18
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -0
- package/dist/plugin-utils/context-helpers.cjs +86 -0
- package/dist/plugin-utils/context-helpers.cjs.map +1 -0
- package/dist/plugin-utils/context-helpers.d.cts +58 -0
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -0
- package/dist/plugin-utils/context-helpers.d.mts +58 -0
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -0
- package/dist/plugin-utils/context-helpers.mjs +79 -0
- package/dist/plugin-utils/context-helpers.mjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.cjs +24 -0
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.d.cts +16 -0
- package/dist/plugin-utils/get-command-tree.d.cts.map +1 -0
- package/dist/plugin-utils/get-command-tree.d.mts +16 -0
- package/dist/plugin-utils/get-command-tree.d.mts.map +1 -0
- package/dist/plugin-utils/get-command-tree.mjs +24 -0
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -0
- package/dist/plugin-utils/index.cjs +16 -0
- package/dist/plugin-utils/index.d.cts +5 -0
- package/dist/plugin-utils/index.d.mts +5 -0
- package/dist/plugin-utils/index.mjs +6 -0
- package/dist/plugin-utils/reflect.cjs +25 -0
- package/dist/plugin-utils/reflect.cjs.map +1 -0
- package/dist/plugin-utils/reflect.d.cts +14 -0
- package/dist/plugin-utils/reflect.d.cts.map +1 -0
- package/dist/plugin-utils/reflect.d.mts +14 -0
- package/dist/plugin-utils/reflect.d.mts.map +1 -0
- package/dist/plugin-utils/reflect.mjs +24 -0
- package/dist/plugin-utils/reflect.mjs.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.cjs +33 -0
- package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.d.cts +23 -0
- package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.d.mts +23 -0
- package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.mjs +31 -0
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -0
- package/dist/plugin.cjs +267 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +13 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +13 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +261 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/types/command.d.cts +13 -4
- package/dist/types/command.d.cts.map +1 -0
- package/dist/types/command.d.mts +13 -4
- package/dist/types/command.d.mts.map +1 -0
- package/dist/types/command.mjs +1 -1
- package/dist/types/config.d.cts +71 -23
- package/dist/types/config.d.cts.map +1 -0
- package/dist/types/config.d.mts +71 -23
- package/dist/types/config.d.mts.map +1 -0
- package/dist/types/config.mjs +1 -1
- package/dist/types/context.d.cts +7 -3
- package/dist/types/context.d.cts.map +1 -0
- package/dist/types/context.d.mts +7 -3
- package/dist/types/context.d.mts.map +1 -0
- package/dist/types/context.mjs +1 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.mjs +1 -1
- package/dist/types/internal.cjs +0 -0
- package/dist/types/internal.d.cts +24 -0
- package/dist/types/internal.d.cts.map +1 -0
- package/dist/types/internal.d.mts +24 -0
- package/dist/types/internal.d.mts.map +1 -0
- package/dist/types/internal.mjs +1 -0
- package/dist/types/options.d.cts +2 -1
- package/dist/types/options.d.cts.map +1 -0
- package/dist/types/options.d.mts +2 -1
- package/dist/types/options.d.mts.map +1 -0
- package/dist/types/options.mjs +1 -1
- package/package.json +230 -55
- package/dist/helpers/get-default-options.cjs +0 -1
- package/dist/helpers/get-default-options.d.cts +0 -15
- package/dist/helpers/get-default-options.d.mts +0 -15
- package/dist/helpers/get-default-options.mjs +0 -1
- package/dist/powerlines.cjs +0 -3
- package/dist/powerlines.d.cts +0 -12
- package/dist/powerlines.d.mts +0 -12
- package/dist/powerlines.mjs +0 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CommandTree } from "../types/command.mjs";
|
|
2
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
3
|
+
import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
|
|
4
|
+
|
|
5
|
+
//#region src/components/docs.d.ts
|
|
6
|
+
interface CommandOptionsDocsProps {
|
|
7
|
+
/**
|
|
8
|
+
* The command to generate options documentation for.
|
|
9
|
+
*/
|
|
10
|
+
command: CommandTree;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generates the options markdown documentation for a command.
|
|
14
|
+
*/
|
|
15
|
+
declare function CommandOptionsDocs(props: CommandOptionsDocsProps): _alloy_js_core0.Children;
|
|
16
|
+
interface CommandDocsProps {
|
|
17
|
+
/**
|
|
18
|
+
* The heading level offset to apply to the generated documentation.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* This is useful when nesting the documentation within other markdown files.
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue 0
|
|
24
|
+
*/
|
|
25
|
+
levelOffset?: number;
|
|
26
|
+
/**
|
|
27
|
+
* The command to generate options documentation for.
|
|
28
|
+
*/
|
|
29
|
+
command: CommandTree;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generates the markdown documentation for a command.
|
|
33
|
+
*/
|
|
34
|
+
declare function CommandDocs(props: CommandDocsProps): _alloy_js_core0.Children;
|
|
35
|
+
interface CommandDocsFileProps extends Partial<MarkdownFileProps> {
|
|
36
|
+
/**
|
|
37
|
+
* The heading level offset to apply to the generated documentation.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* This is useful when nesting the documentation within other markdown files.
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue 0
|
|
43
|
+
*/
|
|
44
|
+
levelOffset?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The command to generate documentation for.
|
|
47
|
+
*/
|
|
48
|
+
command: CommandTree;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Generates the markdown documentation file for a command.
|
|
52
|
+
*/
|
|
53
|
+
declare function CommandDocsFile(props: CommandDocsFileProps): _alloy_js_core0.Children;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandOptionsDocs, CommandOptionsDocsProps };
|
|
56
|
+
//# sourceMappingURL=docs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.mts","names":[],"sources":["../../src/components/docs.tsx"],"sourcesContent":[],"mappings":";;;;;UAqCiB,uBAAA;;;AAAjB;EAUgB,OAAA,EANL,WAMK;AAwBhB;AAoBA;AA2CA;;AAcW,iBArGK,kBAAA,CAqGL,KAAA,EArG+B,uBAqG/B,CAAA,EArGsD,eAAA,CAAA,QAqGtD;AAdmC,UA/D7B,gBAAA,CA+D6B;EAAO;AAoBrD;;;;;;;;;;;WArEW;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UA2ClC,oBAAA,SAA6B,QAAQ;;;;;;;;;;;;;WAc3C;;;;;iBAMK,eAAA,QAAuB,uBAAoB,eAAA,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { CommandContext } from "../contexts/command.mjs";
|
|
2
|
+
import { getDocsOutputPath } from "../helpers/docs-helpers.mjs";
|
|
3
|
+
import { getAppBin, getVariableCommandPathName, isVariableCommandPath } from "../plugin-utils/context-helpers.mjs";
|
|
4
|
+
import { sortOptions } from "../plugin-utils/reflect.mjs";
|
|
5
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
6
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
7
|
+
import { For, code } from "@alloy-js/core";
|
|
8
|
+
import { Heading } from "@alloy-js/markdown";
|
|
9
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
10
|
+
import { MarkdownFile } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
|
|
11
|
+
import { MarkdownTable } from "@powerlines/plugin-alloy/markdown/components/markdown-table";
|
|
12
|
+
import { joinPaths } from "@stryke/path/join";
|
|
13
|
+
|
|
14
|
+
//#region src/components/docs.tsx
|
|
15
|
+
/**
|
|
16
|
+
* Generates the options markdown documentation for a command.
|
|
17
|
+
*/
|
|
18
|
+
function CommandOptionsDocs(props) {
|
|
19
|
+
const { command } = props;
|
|
20
|
+
if (Object.keys(command.options).length === 0) return ["This command does not have any options."];
|
|
21
|
+
return createComponent(MarkdownTable, { get data() {
|
|
22
|
+
return sortOptions(Object.values(command.options)).map((option) => {
|
|
23
|
+
return {
|
|
24
|
+
name: option.name.trim(),
|
|
25
|
+
description: option.description.trim(),
|
|
26
|
+
defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${option.default}\`` : "",
|
|
27
|
+
required: option.optional || option.default ? "" : "✔"
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
} });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Generates the markdown documentation for a command.
|
|
34
|
+
*/
|
|
35
|
+
function CommandDocs(props) {
|
|
36
|
+
const { levelOffset = 0, command } = props;
|
|
37
|
+
const context = usePowerlines();
|
|
38
|
+
return [
|
|
39
|
+
createComponent(Heading, {
|
|
40
|
+
level: 1 + levelOffset,
|
|
41
|
+
get children() {
|
|
42
|
+
return command.name;
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
memo(() => command.description),
|
|
46
|
+
createIntrinsic("hbr", {}),
|
|
47
|
+
createIntrinsic("hbr", {}),
|
|
48
|
+
createComponent(Heading, {
|
|
49
|
+
level: 2 + levelOffset,
|
|
50
|
+
children: "Usage"
|
|
51
|
+
}),
|
|
52
|
+
code`The command can be executed using the following syntax:
|
|
53
|
+
\`\`\`bash `,
|
|
54
|
+
createIntrinsic("hbr", {}),
|
|
55
|
+
memo(() => code`$ ${getAppBin(context)} `),
|
|
56
|
+
createComponent(For, {
|
|
57
|
+
get each() {
|
|
58
|
+
return command.path.segments;
|
|
59
|
+
},
|
|
60
|
+
children: (segment) => isVariableCommandPath(segment) ? `<${command.path.variables[segment]?.variadic ? "..." : ""}${kebabCase(getVariableCommandPathName(segment))}>` : segment
|
|
61
|
+
}),
|
|
62
|
+
code` [options] `,
|
|
63
|
+
createIntrinsic("hbr", {}),
|
|
64
|
+
code`\`\`\``,
|
|
65
|
+
createIntrinsic("hbr", {}),
|
|
66
|
+
createIntrinsic("hbr", {}),
|
|
67
|
+
createComponent(Heading, {
|
|
68
|
+
level: 2 + levelOffset,
|
|
69
|
+
children: "Options"
|
|
70
|
+
}),
|
|
71
|
+
memo(() => code`The following options are available for the ${command.title} command:`),
|
|
72
|
+
createIntrinsic("hbr", {}),
|
|
73
|
+
createIntrinsic("hbr", {}),
|
|
74
|
+
createComponent(CommandOptionsDocs, { command }),
|
|
75
|
+
createIntrinsic("hbr", {}),
|
|
76
|
+
createIntrinsic("hbr", {})
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Generates the markdown documentation file for a command.
|
|
81
|
+
*/
|
|
82
|
+
function CommandDocsFile(props) {
|
|
83
|
+
const { levelOffset = 0, command, ...rest } = props;
|
|
84
|
+
const context = usePowerlines();
|
|
85
|
+
return createComponent(CommandContext.Provider, {
|
|
86
|
+
value: command,
|
|
87
|
+
get children() {
|
|
88
|
+
return createComponent(MarkdownFile, mergeProps({ get path() {
|
|
89
|
+
return joinPaths(getDocsOutputPath(context), `${command.path.value}.md`);
|
|
90
|
+
} }, rest, { get children() {
|
|
91
|
+
return createComponent(CommandDocs, {
|
|
92
|
+
levelOffset,
|
|
93
|
+
command
|
|
94
|
+
});
|
|
95
|
+
} }));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
export { CommandDocs, CommandDocsFile, CommandOptionsDocs };
|
|
102
|
+
//# sourceMappingURL=docs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.mjs","names":["code","For","Heading","usePowerlines","MarkdownFile","MarkdownTable","joinPaths","kebabCase","CommandContext","getDocsOutputPath","getAppBin","getVariableCommandPathName","isVariableCommandPath","sortOptions","CommandOptionsDocs","props","command","Object","keys","options","length","_$createComponent","data","values","map","option","name","trim","description","defaultValue","default","String","includes","required","optional","CommandDocs","levelOffset","context","level","children","_$memo","_$createIntrinsic","each","path","segments","segment","variables","variadic","title","CommandDocsFile","rest","Provider","value","_$mergeProps"],"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 } from \"@alloy-js/core\";\nimport { Heading } from \"@alloy-js/markdown\";\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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { CommandContext } from \"../contexts/command\";\nimport { getDocsOutputPath } from \"../helpers/docs-helpers\";\nimport {\n getAppBin,\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"../plugin-utils/context-helpers\";\nimport { sortOptions } from \"../plugin-utils/reflect\";\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\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 <>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 : `\\`${option.default}\\``\n : \"\",\n required: option.optional || option.default ? \"\" : \"✔\"\n };\n })}\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/**\n * Generates the markdown documentation for a command.\n */\nexport function CommandDocs(props: CommandDocsProps) {\n const { levelOffset = 0, command } = props;\n\n const context = usePowerlines<Context>();\n\n return (\n <>\n <Heading level={1 + levelOffset}>{command.name}</Heading>\n {command.description}\n <hbr />\n <hbr />\n <Heading level={2 + levelOffset}>Usage</Heading>\n {code`The command can be executed using the following syntax:\n \\`\\`\\`bash `}\n <hbr />\n {code`$ ${getAppBin(context)} `}\n <For each={command.path.segments}>\n {segment =>\n isVariableCommandPath(segment)\n ? `<${command.path.variables[segment]?.variadic ? \"...\" : \"\"}${kebabCase(\n getVariableCommandPathName(segment)\n )}>`\n : segment\n }\n </For>\n {code` [options] `}\n <hbr />\n {code`\\`\\`\\``}\n <hbr />\n <hbr />\n <Heading level={2 + levelOffset}>Options</Heading>\n {code`The following options are available for the ${\n command.title\n } command:`}\n <hbr />\n <hbr />\n <CommandOptionsDocs command={command} />\n <hbr />\n <hbr />\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, ...rest } = props;\n\n const context = usePowerlines<Context>();\n\n return (\n <CommandContext.Provider value={command}>\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context), `${command.path.value}.md`)}\n {...rest}>\n <CommandDocs levelOffset={levelOffset} command={command} />\n </MarkdownFile>\n </CommandContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+CA,SAAgBc,mBAAmBC,OAAgC;CACjE,MAAM,EAAEC,YA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A,OAAA,EAAA,CAAA;EAEjBzC,IAAI;EAAQyC,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAApB,gBAGZnB,SAAO;GAACoC,OAAO,IAAIF;GAAWG,UAAA;GAAA,CAAA;EAAAC,WAC9BxC,IAAI,+CACHgB,QAAQgC,MAAK,WACJ;EAAAP,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAApB,gBAGVP,oBAAkB,EAAUE,SAAO,CAAA;EAAAyB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AA2B1C,SAAgBQ,gBAAgBlC,OAA6B;CAC3D,MAAM,EAAEqB,cAAc,GAAGpB,SAAS,GAAGkC,SAASnC;CAE9C,MAAMsB,UAAUlC,eAAwB;AAExC,QAAAkB,gBACGb,eAAe2C,UAAQ;EAACC,OAAOpC;EAAO,IAAAuB,WAAA;AAAA,UAAAlB,gBACpCjB,cAAYiD,WAAA,EAAA,IACXV,OAAI;AAAA,WAAErC,UAAUG,kBAAkB4B,QAAQ,EAAE,GAAGrB,QAAQ2B,KAAKS,MAAK,KAAM;MAAA,EACnEF,MAAI,EAAA,IAAAX,WAAA;AAAA,WAAAlB,gBACPc,aAAW;KAAcC;KAAsBpB;KAAO,CAAA;MAAA,CAAA,CAAA;;EAAA,CAAA"}
|
package/dist/config.cjs
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/config.ts
|
|
3
|
+
/**
|
|
4
|
+
* A utility function to define a Shell Shock user configuration.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This function is used to create a user configuration object for Shell Shock projects. It ensures that the configuration adheres to the expected structure.
|
|
8
|
+
*
|
|
9
|
+
* @param config - A partial user configuration object.
|
|
10
|
+
* @returns A complete user configuration object.
|
|
11
|
+
*/
|
|
12
|
+
function defineConfig(config) {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.defineConfig = defineConfig;
|
|
18
|
+
//# sourceMappingURL=config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.cjs","names":["defineConfig","config"],"sources":["../src/config.ts"],"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 type { UserConfig } from \"./types/config\";\n\n/**\n * A utility function to define a Shell Shock user configuration.\n *\n * @remarks\n * This function is used to create a user configuration object for Shell Shock projects. It ensures that the configuration adheres to the expected structure.\n *\n * @param config - A partial user configuration object.\n * @returns A complete user configuration object.\n */\nexport function defineConfig(config: Partial<UserConfig>): UserConfig {\n return config;\n}\n"],"mappings":";;;;;;;;;;;AA6BA,SAAgBA,aAAaC,QAAyC;AACpE,QAAOA"}
|
package/dist/config.d.cts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"sourcesContent":[],"mappings":";;;;;;AA6BA;;;;;;;iBAAgB,YAAA,SAAqB,QAAQ,cAAc"}
|
package/dist/config.d.mts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"sourcesContent":[],"mappings":";;;;;;AA6BA;;;;;;;iBAAgB,YAAA,SAAqB,QAAQ,cAAc"}
|
package/dist/config.mjs
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/config.ts
|
|
2
|
+
/**
|
|
3
|
+
* A utility function to define a Shell Shock user configuration.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This function is used to create a user configuration object for Shell Shock projects. It ensures that the configuration adheres to the expected structure.
|
|
7
|
+
*
|
|
8
|
+
* @param config - A partial user configuration object.
|
|
9
|
+
* @returns A complete user configuration object.
|
|
10
|
+
*/
|
|
11
|
+
function defineConfig(config) {
|
|
12
|
+
return config;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { defineConfig };
|
|
17
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":["defineConfig","config"],"sources":["../src/config.ts"],"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 type { UserConfig } from \"./types/config\";\n\n/**\n * A utility function to define a Shell Shock user configuration.\n *\n * @remarks\n * This function is used to create a user configuration object for Shell Shock projects. It ensures that the configuration adheres to the expected structure.\n *\n * @param config - A partial user configuration object.\n * @returns A complete user configuration object.\n */\nexport function defineConfig(config: Partial<UserConfig>): UserConfig {\n return config;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBA,aAAaC,QAAyC;AACpE,QAAOA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/command.ts
|
|
5
|
+
/**
|
|
6
|
+
* The reflection parameter context used in template rendering.
|
|
7
|
+
*/
|
|
8
|
+
const CommandContext = (0, __alloy_js_core.createNamedContext)("Command");
|
|
9
|
+
/**
|
|
10
|
+
* Hook to access the Command context.
|
|
11
|
+
*
|
|
12
|
+
* @returns A reactive version of the current reflection.
|
|
13
|
+
*/
|
|
14
|
+
function useCommand() {
|
|
15
|
+
return (0, __alloy_js_core.useContext)(CommandContext);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.CommandContext = CommandContext;
|
|
20
|
+
exports.useCommand = useCommand;
|
|
21
|
+
//# sourceMappingURL=command.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.cjs","names":["createNamedContext","useContext","CommandContext","useCommand"],"sources":["../../src/contexts/command.ts"],"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 type { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport type { CommandTree } from \"../types/command\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const CommandContext: ComponentContext<CommandTree | undefined> =\n createNamedContext<CommandTree | undefined>(\"Command\");\n\n/**\n * Hook to access the Command context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useCommand() {\n return useContext<CommandTree | undefined>(CommandContext)!;\n}\n"],"mappings":";;;;;;;AAyBA,MAAaE,yDACiC,UAAU;;;;;;AAOxD,SAAgBC,aAAa;AAC3B,wCAA2CD,eAAe"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommandTree } from "../types/command.cjs";
|
|
2
|
+
import { ComponentContext } from "@alloy-js/core";
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/command.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The reflection parameter context used in template rendering.
|
|
8
|
+
*/
|
|
9
|
+
declare const CommandContext: ComponentContext<CommandTree | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Hook to access the Command context.
|
|
12
|
+
*
|
|
13
|
+
* @returns A reactive version of the current reflection.
|
|
14
|
+
*/
|
|
15
|
+
declare function useCommand(): CommandTree;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CommandContext, useCommand };
|
|
18
|
+
//# sourceMappingURL=command.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.cts","names":[],"sources":["../../src/contexts/command.ts"],"sourcesContent":[],"mappings":";;;;;;;AAyBA;AAQgB,cARH,cAQa,EARG,gBAQH,CARoB,WAQpB,GAAA,SAAA,CAAA;;;;;;iBAAV,UAAA,CAAA,GAAU"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommandTree } from "../types/command.mjs";
|
|
2
|
+
import { ComponentContext } from "@alloy-js/core";
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/command.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The reflection parameter context used in template rendering.
|
|
8
|
+
*/
|
|
9
|
+
declare const CommandContext: ComponentContext<CommandTree | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Hook to access the Command context.
|
|
12
|
+
*
|
|
13
|
+
* @returns A reactive version of the current reflection.
|
|
14
|
+
*/
|
|
15
|
+
declare function useCommand(): CommandTree;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CommandContext, useCommand };
|
|
18
|
+
//# sourceMappingURL=command.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.mts","names":[],"sources":["../../src/contexts/command.ts"],"sourcesContent":[],"mappings":";;;;;;;AAyBA;AAQgB,cARH,cAQa,EARG,gBAQH,CARoB,WAQpB,GAAA,SAAA,CAAA;;;;;;iBAAV,UAAA,CAAA,GAAU"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createNamedContext, useContext } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/contexts/command.ts
|
|
4
|
+
/**
|
|
5
|
+
* The reflection parameter context used in template rendering.
|
|
6
|
+
*/
|
|
7
|
+
const CommandContext = createNamedContext("Command");
|
|
8
|
+
/**
|
|
9
|
+
* Hook to access the Command context.
|
|
10
|
+
*
|
|
11
|
+
* @returns A reactive version of the current reflection.
|
|
12
|
+
*/
|
|
13
|
+
function useCommand() {
|
|
14
|
+
return useContext(CommandContext);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CommandContext, useCommand };
|
|
19
|
+
//# sourceMappingURL=command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.mjs","names":["createNamedContext","useContext","CommandContext","useCommand"],"sources":["../../src/contexts/command.ts"],"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 type { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport type { CommandTree } from \"../types/command\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const CommandContext: ComponentContext<CommandTree | undefined> =\n createNamedContext<CommandTree | undefined>(\"Command\");\n\n/**\n * Hook to access the Command context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useCommand() {\n return useContext<CommandTree | undefined>(CommandContext)!;\n}\n"],"mappings":";;;;;;AAyBA,MAAaE,iBACXF,mBAA4C,UAAU;;;;;;AAOxD,SAAgBG,aAAa;AAC3B,QAAOF,WAAoCC,eAAe"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_join = require("@stryke/path/join");
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/docs-helpers.ts
|
|
5
|
+
/**
|
|
6
|
+
* Gets the output path for the generated documentation.
|
|
7
|
+
*
|
|
8
|
+
* @param context - The Shell Shock context.
|
|
9
|
+
* @returns The output path for the generated documentation.
|
|
10
|
+
*/
|
|
11
|
+
function getDocsOutputPath(context) {
|
|
12
|
+
return (0, __stryke_path_join.joinPaths)(context.config.projectRoot, "docs", "generated");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.getDocsOutputPath = getDocsOutputPath;
|
|
17
|
+
//# sourceMappingURL=docs-helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-helpers.cjs","names":["joinPaths","getDocsOutputPath","context","config","projectRoot"],"sources":["../../src/helpers/docs-helpers.ts"],"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 { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.projectRoot, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgBC,kBAAkBC,SAA0B;AAC1D,0CAAiBA,QAAQC,OAAOC,aAAa,QAAQ,YAAY"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { joinPaths } from "@stryke/path/join";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/docs-helpers.ts
|
|
4
|
+
/**
|
|
5
|
+
* Gets the output path for the generated documentation.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The Shell Shock context.
|
|
8
|
+
* @returns The output path for the generated documentation.
|
|
9
|
+
*/
|
|
10
|
+
function getDocsOutputPath(context) {
|
|
11
|
+
return joinPaths(context.config.projectRoot, "docs", "generated");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { getDocsOutputPath };
|
|
16
|
+
//# sourceMappingURL=docs-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-helpers.mjs","names":["joinPaths","getDocsOutputPath","context","config","projectRoot"],"sources":["../../src/helpers/docs-helpers.ts"],"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 { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.projectRoot, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgBC,kBAAkBC,SAA0B;AAC1D,QAAOF,UAAUE,QAAQC,OAAOC,aAAa,QAAQ,YAAY"}
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/persistence.ts
|
|
5
|
+
function getCommandsPersistencePath(context) {
|
|
6
|
+
return (0, __stryke_path_join_paths.joinPaths)(context.dataPath, `commands.json`);
|
|
7
|
+
}
|
|
8
|
+
function serializedCommandTree(commands) {
|
|
9
|
+
const serialize = (node, parent = null) => {
|
|
10
|
+
const serializedNode = {
|
|
11
|
+
...node,
|
|
12
|
+
parent,
|
|
13
|
+
children: {}
|
|
14
|
+
};
|
|
15
|
+
for (const [key, child] of Object.entries(node.children || {})) serializedNode.children[key] = serialize(child, node.id);
|
|
16
|
+
return serializedNode;
|
|
17
|
+
};
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const [key, child] of Object.entries(commands)) result[key] = serialize(child, null);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
function deserializeCommandTree(serializedCommands) {
|
|
23
|
+
const deserialize = (node, parent = null) => {
|
|
24
|
+
const deserializedNode = {
|
|
25
|
+
...node,
|
|
26
|
+
parent,
|
|
27
|
+
children: {}
|
|
28
|
+
};
|
|
29
|
+
for (const [key, child] of Object.entries(node.children || {})) deserializedNode.children[key] = deserialize(child, deserializedNode);
|
|
30
|
+
return deserializedNode;
|
|
31
|
+
};
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const [key, child] of Object.entries(serializedCommands)) result[key] = deserialize(child, null);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
async function readCommandsPersistence(context) {
|
|
37
|
+
const reflections = await context.fs.read(getCommandsPersistencePath(context));
|
|
38
|
+
if (!reflections || !reflections.length) throw new Error(`CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`);
|
|
39
|
+
context.commands = deserializeCommandTree(JSON.parse(reflections));
|
|
40
|
+
}
|
|
41
|
+
async function writeCommandsPersistence(context) {
|
|
42
|
+
const filePath = getCommandsPersistencePath(context);
|
|
43
|
+
await context.fs.write(filePath, JSON.stringify(serializedCommandTree(context.commands), null, context.config.mode === "development" ? 2 : 0));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.getCommandsPersistencePath = getCommandsPersistencePath;
|
|
48
|
+
exports.readCommandsPersistence = readCommandsPersistence;
|
|
49
|
+
exports.writeCommandsPersistence = writeCommandsPersistence;
|
|
50
|
+
//# sourceMappingURL=persistence.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.cjs","names":["joinPaths","getCommandsPersistencePath","context","dataPath","serializedCommandTree","commands","serialize","node","parent","serializedNode","children","key","child","Object","entries","id","result","deserializeCommandTree","serializedCommands","deserialize","deserializedNode","readCommandsPersistence","reflections","fs","read","length","Error","JSON","parse","writeCommandsPersistence","filePath","write","stringify","config","mode"],"sources":["../../src/helpers/persistence.ts"],"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 { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, SerializedCommandTree } from \"../types\";\nimport type { Context } from \"../types/context\";\n\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, `commands.json`);\n}\n\nfunction serializedCommandTree(\n commands: Record<string, CommandTree>\n): Record<string, SerializedCommandTree> {\n const serialize = (\n node: CommandTree,\n parent: string | null = null\n ): SerializedCommandTree => {\n const serializedNode: SerializedCommandTree = {\n ...node,\n parent,\n children: {}\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n serializedNode.children[key] = serialize(child, node.id);\n }\n\n return serializedNode;\n };\n\n const result: Record<string, SerializedCommandTree> = {};\n for (const [key, child] of Object.entries(commands)) {\n result[key] = serialize(child, null);\n }\n\n return result;\n}\n\nfunction deserializeCommandTree(\n serializedCommands: Record<string, SerializedCommandTree>\n): Record<string, CommandTree> {\n const deserialize = (\n node: SerializedCommandTree,\n parent: CommandTree | null = null\n ): CommandTree => {\n const deserializedNode: CommandTree = {\n ...node,\n parent,\n children: {}\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n deserializedNode.children[key] = deserialize(child, deserializedNode);\n }\n\n return deserializedNode;\n };\n\n const result: Record<string, CommandTree> = {};\n for (const [key, child] of Object.entries(serializedCommands)) {\n result[key] = deserialize(child, null);\n }\n\n return result;\n}\n\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = deserializeCommandTree(JSON.parse(reflections));\n}\n\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n serializedCommandTree(context.commands),\n null,\n context.config.mode === \"development\" ? 2 : 0\n )\n );\n}\n"],"mappings":";;;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AC/D,MAAM4B,WAAW7B,2BAA2BC,QAAQ;AAEpD,OAAMA,QAAQqB,GAAGQ,MACfD,UACAH,KAAKK,UACH5B,sBAAsBF,QAAQG,SAAS,EACvC,MACAH,QAAQ+B,OAAOC,SAAS,gBAAgB,IAAI,EAEhD,CAAC"}
|
|
@@ -1 +1,47 @@
|
|
|
1
|
-
import{joinPaths
|
|
1
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/persistence.ts
|
|
4
|
+
function getCommandsPersistencePath(context) {
|
|
5
|
+
return joinPaths(context.dataPath, `commands.json`);
|
|
6
|
+
}
|
|
7
|
+
function serializedCommandTree(commands) {
|
|
8
|
+
const serialize = (node, parent = null) => {
|
|
9
|
+
const serializedNode = {
|
|
10
|
+
...node,
|
|
11
|
+
parent,
|
|
12
|
+
children: {}
|
|
13
|
+
};
|
|
14
|
+
for (const [key, child] of Object.entries(node.children || {})) serializedNode.children[key] = serialize(child, node.id);
|
|
15
|
+
return serializedNode;
|
|
16
|
+
};
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const [key, child] of Object.entries(commands)) result[key] = serialize(child, null);
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function deserializeCommandTree(serializedCommands) {
|
|
22
|
+
const deserialize = (node, parent = null) => {
|
|
23
|
+
const deserializedNode = {
|
|
24
|
+
...node,
|
|
25
|
+
parent,
|
|
26
|
+
children: {}
|
|
27
|
+
};
|
|
28
|
+
for (const [key, child] of Object.entries(node.children || {})) deserializedNode.children[key] = deserialize(child, deserializedNode);
|
|
29
|
+
return deserializedNode;
|
|
30
|
+
};
|
|
31
|
+
const result = {};
|
|
32
|
+
for (const [key, child] of Object.entries(serializedCommands)) result[key] = deserialize(child, null);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
async function readCommandsPersistence(context) {
|
|
36
|
+
const reflections = await context.fs.read(getCommandsPersistencePath(context));
|
|
37
|
+
if (!reflections || !reflections.length) throw new Error(`CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`);
|
|
38
|
+
context.commands = deserializeCommandTree(JSON.parse(reflections));
|
|
39
|
+
}
|
|
40
|
+
async function writeCommandsPersistence(context) {
|
|
41
|
+
const filePath = getCommandsPersistencePath(context);
|
|
42
|
+
await context.fs.write(filePath, JSON.stringify(serializedCommandTree(context.commands), null, context.config.mode === "development" ? 2 : 0));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { getCommandsPersistencePath, readCommandsPersistence, writeCommandsPersistence };
|
|
47
|
+
//# sourceMappingURL=persistence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.mjs","names":["joinPaths","getCommandsPersistencePath","context","dataPath","serializedCommandTree","commands","serialize","node","parent","serializedNode","children","key","child","Object","entries","id","result","deserializeCommandTree","serializedCommands","deserialize","deserializedNode","readCommandsPersistence","reflections","fs","read","length","Error","JSON","parse","writeCommandsPersistence","filePath","write","stringify","config","mode"],"sources":["../../src/helpers/persistence.ts"],"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 { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, SerializedCommandTree } from \"../types\";\nimport type { Context } from \"../types/context\";\n\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, `commands.json`);\n}\n\nfunction serializedCommandTree(\n commands: Record<string, CommandTree>\n): Record<string, SerializedCommandTree> {\n const serialize = (\n node: CommandTree,\n parent: string | null = null\n ): SerializedCommandTree => {\n const serializedNode: SerializedCommandTree = {\n ...node,\n parent,\n children: {}\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n serializedNode.children[key] = serialize(child, node.id);\n }\n\n return serializedNode;\n };\n\n const result: Record<string, SerializedCommandTree> = {};\n for (const [key, child] of Object.entries(commands)) {\n result[key] = serialize(child, null);\n }\n\n return result;\n}\n\nfunction deserializeCommandTree(\n serializedCommands: Record<string, SerializedCommandTree>\n): Record<string, CommandTree> {\n const deserialize = (\n node: SerializedCommandTree,\n parent: CommandTree | null = null\n ): CommandTree => {\n const deserializedNode: CommandTree = {\n ...node,\n parent,\n children: {}\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n deserializedNode.children[key] = deserialize(child, deserializedNode);\n }\n\n return deserializedNode;\n };\n\n const result: Record<string, CommandTree> = {};\n for (const [key, child] of Object.entries(serializedCommands)) {\n result[key] = deserialize(child, null);\n }\n\n return result;\n}\n\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = deserializeCommandTree(JSON.parse(reflections));\n}\n\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n serializedCommandTree(context.commands),\n null,\n context.config.mode === \"development\" ? 2 : 0\n )\n );\n}\n"],"mappings":";;;AAsBA,SAAgBC,2BAA2BC,SAA0B;AACnE,QAAOF,UAAUE,QAAQC,UAAU,gBAAgB;;AAGrD,SAASC,sBACPC,UACuC;CACvC,MAAMC,aACJC,MACAC,SAAwB,SACE;EAC1B,MAAMC,iBAAwC;GAC5C,GAAGF;GACHC;GACAE,UAAU,EAAC;GACZ;AAED,OAAK,MAAM,CAACC,KAAKC,UAAUC,OAAOC,QAAQP,KAAKG,YAAY,EAAE,CA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