git-stack-cli 2.9.7 → 2.9.8
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/js/index.js +70 -70
- package/package.json +1 -1
- package/src/app/DebugOutput.tsx +3 -11
- package/src/app/Output.tsx +2 -1
- package/src/core/render_node.tsx +37 -0
package/package.json
CHANGED
package/src/app/DebugOutput.tsx
CHANGED
|
@@ -3,6 +3,8 @@ import * as React from "react";
|
|
|
3
3
|
import * as Ink from "ink-cjs";
|
|
4
4
|
import { DateTime } from "luxon";
|
|
5
5
|
|
|
6
|
+
import { render_node } from "~/core/render_node";
|
|
7
|
+
|
|
6
8
|
type Props = {
|
|
7
9
|
node: React.ReactNode;
|
|
8
10
|
};
|
|
@@ -14,17 +16,7 @@ export function DebugOutput(props: Props) {
|
|
|
14
16
|
const timestamp = DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
|
15
17
|
const content_width = available_width - timestamp.length - 2;
|
|
16
18
|
|
|
17
|
-
const content = (
|
|
18
|
-
switch (typeof props.node) {
|
|
19
|
-
case "boolean":
|
|
20
|
-
case "number":
|
|
21
|
-
case "string": {
|
|
22
|
-
return <Ink.Text dimColor>{String(props.node)}</Ink.Text>;
|
|
23
|
-
}
|
|
24
|
-
default:
|
|
25
|
-
return props.node;
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
19
|
+
const content = render_node(props.node);
|
|
28
20
|
|
|
29
21
|
return (
|
|
30
22
|
<Ink.Box flexDirection="column">
|
package/src/app/Output.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import * as Ink from "ink-cjs";
|
|
|
4
4
|
|
|
5
5
|
import { DebugOutput } from "~/app/DebugOutput";
|
|
6
6
|
import { Store } from "~/app/Store";
|
|
7
|
+
import { render_node } from "~/core/render_node";
|
|
7
8
|
|
|
8
9
|
export function Output() {
|
|
9
10
|
const output = Store.useState((state) => state.output);
|
|
@@ -14,7 +15,7 @@ export function Output() {
|
|
|
14
15
|
<Ink.Static items={output}>
|
|
15
16
|
{(entry) => {
|
|
16
17
|
const [id, node] = entry;
|
|
17
|
-
return <Ink.Box key={id}>{node}</Ink.Box>;
|
|
18
|
+
return <Ink.Box key={id}>{render_node(node)}</Ink.Box>;
|
|
18
19
|
}}
|
|
19
20
|
</Ink.Static>
|
|
20
21
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import * as Ink from "ink-cjs";
|
|
4
|
+
|
|
5
|
+
import { Store } from "~/app/Store";
|
|
6
|
+
|
|
7
|
+
export function render_node(node: React.ReactNode) {
|
|
8
|
+
const actions = Store.getState().actions;
|
|
9
|
+
|
|
10
|
+
if (node == null) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (React.isValidElement(node)) {
|
|
15
|
+
return node;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (Array.isArray(node)) {
|
|
19
|
+
return (
|
|
20
|
+
<React.Fragment>
|
|
21
|
+
{node.map((entry, index) => (
|
|
22
|
+
<React.Fragment key={index}>{render_node(entry)}</React.Fragment>
|
|
23
|
+
))}
|
|
24
|
+
</React.Fragment>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
switch (typeof node) {
|
|
29
|
+
case "string":
|
|
30
|
+
case "number":
|
|
31
|
+
case "boolean":
|
|
32
|
+
return <Ink.Text>{String(node)}</Ink.Text>;
|
|
33
|
+
default:
|
|
34
|
+
actions.debug(`unhandled node ${typeof node}`);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|