@shell-shock/core 0.17.17 → 0.17.18

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.
@@ -13,6 +13,7 @@ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin
13
13
  let _powerlines_plugin_alloy_markdown_components_markdown_file = require("@powerlines/plugin-alloy/markdown/components/markdown-file");
14
14
  let _powerlines_plugin_alloy_markdown_components_markdown_table = require("@powerlines/plugin-alloy/markdown/components/markdown-table");
15
15
  let _stryke_path_join = require("@stryke/path/join");
16
+ let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
16
17
 
17
18
  //#region src/components/docs.tsx
18
19
  const __ΩRequired = [
@@ -43,18 +44,20 @@ function CommandOptionsDocs(props) {
43
44
  const { command } = props;
44
45
  if (Object.keys(command.options).length === 0) return _alloy_js_core.code`This command does not have any options.`;
45
46
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
46
- return require_reflect.sortOptions(Object.values(command.options)).map(__assignType((option) => {
47
- return {
47
+ return require_reflect.sortOptions(Object.values(command.options)).reduce(__assignType((ret, option) => {
48
+ ret.push({
48
49
  name: option.name.trim(),
49
50
  description: option.description.trim(),
50
- defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${Array.isArray(option.default) ? option.default.join(", ") : option.default}\`` : "",
51
+ defaultValue: (0, _stryke_type_checks_is_undefined.isUndefined)(option.default) ? "" : JSON.stringify(option.default),
51
52
  required: !option.required || option.default ? "" : "✔"
52
- };
53
+ });
54
+ return ret;
53
55
  }, [
56
+ "ret",
54
57
  "option",
55
58
  "",
56
- "P\"2!\"/\""
57
- ]));
59
+ "P\"2!\"2\"\"/#"
60
+ ]), []);
58
61
  } });
59
62
  }
60
63
  CommandOptionsDocs.__type = [
@@ -75,18 +78,26 @@ const __ΩCommandDocsUsageExampleProps = [
75
78
  "CommandTree",
76
79
  "command",
77
80
  "The command to generate the usage example for.",
81
+ "expand",
82
+ true,
83
+ "Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.",
78
84
  "CommandDocsUsageExampleProps",
79
- "PP.!.\".#.$J4%8>&?'\"w(4)?*Mw+y"
85
+ "PP.!.\".#.$J4%8>&?'\"w(4)?*)4+8>,?-Mw.y"
80
86
  ];
81
87
  /**
82
88
  * Generates the markdown documentation for a command.
83
89
  */
84
90
  function CommandDocsUsageExample(props) {
85
- const { packageManager = "npm", command } = props;
91
+ const { packageManager = "npm", command, expand = true } = props;
86
92
  const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
87
93
  return [
88
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
89
- _alloy_js_core.code`\`\`\`bash `,
94
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
95
+ when: expand,
96
+ fallback: _alloy_js_core.code`\`\`\`bash `,
97
+ children: _alloy_js_core.code`<details>
98
+ <summary>Using ${packageManager}</summary>
99
+ \`\`\`bash `
100
+ }),
90
101
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
91
102
  (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_usage.Usage, {
92
103
  command,
@@ -96,7 +107,12 @@ function CommandDocsUsageExample(props) {
96
107
  packageManager
97
108
  }),
98
109
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
99
- _alloy_js_core.code`\`\`\``,
110
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
111
+ when: expand,
112
+ fallback: _alloy_js_core.code`\`\`\` `,
113
+ children: _alloy_js_core.code`\`\`\`
114
+ </details> `
115
+ }),
100
116
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
101
117
  ];
102
118
  }
@@ -26,6 +26,12 @@ interface CommandDocsUsageExampleProps {
26
26
  * The command to generate the usage example for.
27
27
  */
28
28
  command: CommandTree;
29
+ /**
30
+ * Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.
31
+ *
32
+ * @defaultValue true
33
+ */
34
+ expand?: boolean;
29
35
  }
30
36
  /**
31
37
  * Generates the markdown documentation for a command.
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;UAmCiB,uBAAA;;AAAjB;;EAIE,OAAA,EAAS,WAAW;AAAA;AAAA;AAMtB;;AANsB,iBAMN,kBAAA,CAAmB,KAAA,EAAO,uBAAuB,4BAAA,QAAA;AAAA,UA4BhD,4BAAA;EA5ByB;;;;AAAuB;AA4BjE;;;EASE,cAAA;EAAA;;;EAKA,OAAA,EAAS,WAAW;AAAA;AAMtB;;;AAAA,iBAAgB,uBAAA,CAAwB,KAAA,EAAO,4BAA4B,4BAAA,QAAA;AAAA,UAsB1D,gBAAA;EAtBuB;;;AAAmC;AAsB3E;;;;EASE,WAAA;EAYgB;;;EAPhB,OAAA,EAAS,WAAA;EAAT;;;;;EAOA,aAAA,GAAgB,QAAA,CAAS,4BAAA;AAAA;AAM3B;;;AAAA,iBAAgB,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA;AAAA,UAwClC,oBAAA,SAA6B,OAAA,CAAQ,iBAAA;EAxC1B;;;AAAuB;AAwCnD;;;;EASE,WAAA;EAT4C;;;EAc5C,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,eAAA,CAAgB,KAAA,EAAO,oBAAoB,4BAAA,QAAA"}
1
+ {"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;UAoCiB,uBAAA;;AAAjB;;EAIE,OAAA,EAAS,WAAW;AAAA;AAAA;AAMtB;;AANsB,iBAMN,kBAAA,CAAmB,KAAA,EAAO,uBAAuB,4BAAA,QAAA;AAAA,UAgChD,4BAAA;EAhCyB;;;;AAAuB;AAgCjE;;;EASE,cAAA;EAAA;;;EAKA,OAAA,EAAS,WAAW;EAOd;AAAA;AAMR;;;EANE,MAAA;AAAA;;;;iBAMc,uBAAA,CAAwB,KAAA,EAAO,4BAA4B,4BAAA,QAAA;AAAA,UA4B1D,gBAAA;EAAgB;;;;;;;;EAS/B,WAAA;EAKS;;;EAAT,OAAA,EAAS,WAAA;EAO4C;AAAA;AAMvD;;;EANE,aAAA,GAAgB,QAAA,CAAS,4BAAA;AAAA;;;;iBAMX,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA;AAAA,UAwClC,oBAAA,SAA6B,OAAA,CAAQ,iBAAA;EAAhB;;;;;;;;EASpC,WAAA;EAAA;;;EAKA,OAAA,EAAS,WAAA;AAAA;AAMX;;;AAAA,iBAAgB,eAAA,CAAgB,KAAA,EAAO,oBAAoB,4BAAA,QAAA"}
@@ -26,6 +26,12 @@ interface CommandDocsUsageExampleProps {
26
26
  * The command to generate the usage example for.
27
27
  */
28
28
  command: CommandTree;
29
+ /**
30
+ * Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.
31
+ *
32
+ * @defaultValue true
33
+ */
34
+ expand?: boolean;
29
35
  }
30
36
  /**
31
37
  * Generates the markdown documentation for a command.
@@ -12,6 +12,7 @@ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
12
12
  import { MarkdownFile } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
13
13
  import { MarkdownTable } from "@powerlines/plugin-alloy/markdown/components/markdown-table";
14
14
  import { joinPaths } from "@stryke/path/join";
15
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
15
16
 
16
17
  //#region src/components/docs.tsx
17
18
  const __ΩRequired = [
@@ -42,18 +43,20 @@ function CommandOptionsDocs(props) {
42
43
  const { command } = props;
43
44
  if (Object.keys(command.options).length === 0) return code`This command does not have any options.`;
44
45
  return createComponent(MarkdownTable, { get data() {
45
- return sortOptions(Object.values(command.options)).map(__assignType((option) => {
46
- return {
46
+ return sortOptions(Object.values(command.options)).reduce(__assignType((ret, option) => {
47
+ ret.push({
47
48
  name: option.name.trim(),
48
49
  description: option.description.trim(),
49
- defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${Array.isArray(option.default) ? option.default.join(", ") : option.default}\`` : "",
50
+ defaultValue: isUndefined(option.default) ? "" : JSON.stringify(option.default),
50
51
  required: !option.required || option.default ? "" : "✔"
51
- };
52
+ });
53
+ return ret;
52
54
  }, [
55
+ "ret",
53
56
  "option",
54
57
  "",
55
- "P\"2!\"/\""
56
- ]));
58
+ "P\"2!\"2\"\"/#"
59
+ ]), []);
57
60
  } });
58
61
  }
59
62
  CommandOptionsDocs.__type = [
@@ -74,18 +77,26 @@ const __ΩCommandDocsUsageExampleProps = [
74
77
  "CommandTree",
75
78
  "command",
76
79
  "The command to generate the usage example for.",
80
+ "expand",
81
+ true,
82
+ "Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.",
77
83
  "CommandDocsUsageExampleProps",
78
- "PP.!.\".#.$J4%8>&?'\"w(4)?*Mw+y"
84
+ "PP.!.\".#.$J4%8>&?'\"w(4)?*)4+8>,?-Mw.y"
79
85
  ];
80
86
  /**
81
87
  * Generates the markdown documentation for a command.
82
88
  */
83
89
  function CommandDocsUsageExample(props) {
84
- const { packageManager = "npm", command } = props;
90
+ const { packageManager = "npm", command, expand = true } = props;
85
91
  const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
86
92
  return [
87
- createIntrinsic("hbr", {}),
88
- code`\`\`\`bash `,
93
+ createComponent(Show, {
94
+ when: expand,
95
+ fallback: code`\`\`\`bash `,
96
+ children: code`<details>
97
+ <summary>Using ${packageManager}</summary>
98
+ \`\`\`bash `
99
+ }),
89
100
  createIntrinsic("hbr", {}),
90
101
  createComponent(Usage, {
91
102
  command,
@@ -95,7 +106,12 @@ function CommandDocsUsageExample(props) {
95
106
  packageManager
96
107
  }),
97
108
  createIntrinsic("hbr", {}),
98
- code`\`\`\``,
109
+ createComponent(Show, {
110
+ when: expand,
111
+ fallback: code`\`\`\` `,
112
+ children: code`\`\`\`
113
+ </details> `
114
+ }),
99
115
  createIntrinsic("hbr", {})
100
116
  ];
101
117
  }
@@ -54,11 +54,11 @@ function Usage(props) {
54
54
  "segment",
55
55
  "",
56
56
  "P\"2!\"/\""
57
- ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " [commands]" : ""}${command.args.length > 0 ? ` ${command.args.map(__assignType((param) => `<${(0, _stryke_string_format_snake_case.snakeCase)(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
57
+ ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " <commands>" : ""}${command.args.length > 0 ? command.args.map(__assignType((param) => `<${(0, _stryke_string_format_snake_case.snakeCase)(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
58
58
  "param",
59
59
  "",
60
60
  "P\"2!\"/\""
61
- ])).join(" ")}` : ""} [options]`),
61
+ ])).join(" ") : ""} [options]`),
62
62
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
63
63
  get when() {
64
64
  return command.args.length > 0;
@@ -66,7 +66,9 @@ function Usage(props) {
66
66
  get children() {
67
67
  return [
68
68
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
69
- _alloy_js_core.code`$ `,
69
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
70
+ _alloy_js_core.code`# or with options before arguments: `,
71
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
70
72
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Switch, { get children() {
71
73
  return [
72
74
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Match, {
@@ -91,11 +93,11 @@ function Usage(props) {
91
93
  "segment",
92
94
  "",
93
95
  "P\"2!\"/\""
94
- ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options] ${command.args.length > 0 ? ` ${command.args.map(__assignType((param) => `<${(0, _stryke_string_format_snake_case.snakeCase)(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
96
+ ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " <commands>" : ""} [options] ${command.args.length > 0 ? command.args.map(__assignType((param) => `<${(0, _stryke_string_format_snake_case.snakeCase)(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
95
97
  "param",
96
98
  "",
97
99
  "P\"2!\"/\""
98
- ])).join(" ")}` : ""}`)
100
+ ])).join(" ") : ""}`)
99
101
  ];
100
102
  }
101
103
  })
@@ -53,11 +53,11 @@ function Usage(props) {
53
53
  "segment",
54
54
  "",
55
55
  "P\"2!\"/\""
56
- ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " [commands]" : ""}${command.args.length > 0 ? ` ${command.args.map(__assignType((param) => `<${snakeCase(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
56
+ ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " <commands>" : ""}${command.args.length > 0 ? command.args.map(__assignType((param) => `<${snakeCase(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
57
57
  "param",
58
58
  "",
59
59
  "P\"2!\"/\""
60
- ])).join(" ")}` : ""} [options]`),
60
+ ])).join(" ") : ""} [options]`),
61
61
  createComponent(Show, {
62
62
  get when() {
63
63
  return command.args.length > 0;
@@ -65,7 +65,9 @@ function Usage(props) {
65
65
  get children() {
66
66
  return [
67
67
  createIntrinsic("hbr", {}),
68
- code`$ `,
68
+ createIntrinsic("hbr", {}),
69
+ code`# or with options before arguments: `,
70
+ createIntrinsic("hbr", {}),
69
71
  createComponent(Switch, { get children() {
70
72
  return [
71
73
  createComponent(Match, {
@@ -90,11 +92,11 @@ function Usage(props) {
90
92
  "segment",
91
93
  "",
92
94
  "P\"2!\"/\""
93
- ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options] ${command.args.length > 0 ? ` ${command.args.map(__assignType((param) => `<${snakeCase(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
95
+ ])).join(" ")}` : ""}${Object.values(command.children).length > 0 ? " <commands>" : ""} [options] ${command.args.length > 0 ? command.args.map(__assignType((param) => `<${snakeCase(param.name)}${(param.type === "string" || param.type === "number") && param.variadic ? "..." : ""}>`, [
94
96
  "param",
95
97
  "",
96
98
  "P\"2!\"/\""
97
- ])).join(" ")}` : ""}`)
99
+ ])).join(" ") : ""}`)
98
100
  ];
99
101
  }
100
102
  })
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "0.17.16";
3
+ var version = "0.17.17";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.17.16";
2
+ var version = "0.17.17";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -8,11 +8,12 @@ function __assignType(fn, args) {
8
8
  * Sort command options alphabetically by name, placing boolean options with negatives appropriately.
9
9
  *
10
10
  * @param options - The array of command options to sort.
11
+ * @param skipNegatives - Whether to skip negative options when sorting (default: true).
11
12
  * @returns A new array of sorted command options.
12
13
  */
13
- function sortOptions(options) {
14
+ function sortOptions(options, skipNegatives = true) {
14
15
  if (!options || options.length === 0) return [];
15
- return options.filter(__assignType((arg) => arg.type !== "boolean" || arg.variadic || !arg.isNegativeOf, [
16
+ return options.filter(__assignType((arg) => arg.type !== "boolean" || arg.variadic || !skipNegatives || !arg.isNegativeOf, [
16
17
  "arg",
17
18
  "",
18
19
  "P\"2!\"/\""
@@ -42,9 +43,10 @@ function sortOptions(options) {
42
43
  sortOptions.__type = [
43
44
  "CommandOption",
44
45
  "options",
46
+ "skipNegatives",
45
47
  "sortOptions",
46
48
  "Sort command options alphabetically by name, placing boolean options with negatives appropriately.",
47
- "P\"w!F2\"\"w!F/#?$"
49
+ "P\"w!F2\"\"2#\"w!F/$?%"
48
50
  ];
49
51
 
50
52
  //#endregion
@@ -5,9 +5,10 @@ import { CommandOption } from "../types/command.cjs";
5
5
  * Sort command options alphabetically by name, placing boolean options with negatives appropriately.
6
6
  *
7
7
  * @param options - The array of command options to sort.
8
+ * @param skipNegatives - Whether to skip negative options when sorting (default: true).
8
9
  * @returns A new array of sorted command options.
9
10
  */
10
- declare function sortOptions(options: CommandOption[]): CommandOption[];
11
+ declare function sortOptions(options: CommandOption[], skipNegatives?: boolean): CommandOption[];
11
12
  //#endregion
12
13
  export { sortOptions };
13
14
  //# sourceMappingURL=reflect.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.d.cts","names":[],"sources":["../../src/plugin-utils/reflect.ts"],"mappings":";;;;;AA0BA;;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,aAAA,KAAkB,aAAa"}
1
+ {"version":3,"file":"reflect.d.cts","names":[],"sources":["../../src/plugin-utils/reflect.ts"],"mappings":";;;;;AA2BA;;;;;iBAAgB,WAAA,CACd,OAAA,EAAS,aAAA,IACT,aAAA,aACC,aAAa"}
@@ -5,9 +5,10 @@ import { CommandOption } from "../types/command.mjs";
5
5
  * Sort command options alphabetically by name, placing boolean options with negatives appropriately.
6
6
  *
7
7
  * @param options - The array of command options to sort.
8
+ * @param skipNegatives - Whether to skip negative options when sorting (default: true).
8
9
  * @returns A new array of sorted command options.
9
10
  */
10
- declare function sortOptions(options: CommandOption[]): CommandOption[];
11
+ declare function sortOptions(options: CommandOption[], skipNegatives?: boolean): CommandOption[];
11
12
  //#endregion
12
13
  export { sortOptions };
13
14
  //# sourceMappingURL=reflect.d.mts.map
@@ -7,11 +7,12 @@ function __assignType(fn, args) {
7
7
  * Sort command options alphabetically by name, placing boolean options with negatives appropriately.
8
8
  *
9
9
  * @param options - The array of command options to sort.
10
+ * @param skipNegatives - Whether to skip negative options when sorting (default: true).
10
11
  * @returns A new array of sorted command options.
11
12
  */
12
- function sortOptions(options) {
13
+ function sortOptions(options, skipNegatives = true) {
13
14
  if (!options || options.length === 0) return [];
14
- return options.filter(__assignType((arg) => arg.type !== "boolean" || arg.variadic || !arg.isNegativeOf, [
15
+ return options.filter(__assignType((arg) => arg.type !== "boolean" || arg.variadic || !skipNegatives || !arg.isNegativeOf, [
15
16
  "arg",
16
17
  "",
17
18
  "P\"2!\"/\""
@@ -41,9 +42,10 @@ function sortOptions(options) {
41
42
  sortOptions.__type = [
42
43
  "CommandOption",
43
44
  "options",
45
+ "skipNegatives",
44
46
  "sortOptions",
45
47
  "Sort command options alphabetically by name, placing boolean options with negatives appropriately.",
46
- "P\"w!F2\"\"w!F/#?$"
48
+ "P\"w!F2\"\"2#\"w!F/$?%"
47
49
  ];
48
50
 
49
51
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/core",
3
- "version": "0.17.17",
3
+ "version": "0.17.18",
4
4
  "private": false,
5
5
  "description": "A package containing the core Shell Shock functionality used to build and manage a command-line application.",
6
6
  "keywords": ["shell-shock", "powerlines", "storm-software"],
@@ -407,5 +407,5 @@
407
407
  "typescript": "^6.0.3"
408
408
  },
409
409
  "publishConfig": { "access": "public" },
410
- "gitHead": "8c9f000d243ed0b6ac67b2be112429ddeccd0617"
410
+ "gitHead": "4ca0ac0ff9ada03aea6667c89a04b54dc73ff40b"
411
411
  }