@pablozaiden/terminatui 0.1.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/.devcontainer/devcontainer.json +19 -0
- package/.devcontainer/install-prerequisites.sh +49 -0
- package/.github/workflows/copilot-setup-steps.yml +32 -0
- package/.github/workflows/pull-request.yml +27 -0
- package/.github/workflows/release-npm-package.yml +78 -0
- package/LICENSE +21 -0
- package/README.md +524 -0
- package/examples/tui-app/commands/greet.ts +75 -0
- package/examples/tui-app/commands/index.ts +3 -0
- package/examples/tui-app/commands/math.ts +114 -0
- package/examples/tui-app/commands/status.ts +75 -0
- package/examples/tui-app/index.ts +34 -0
- package/guides/01-hello-world.md +96 -0
- package/guides/02-adding-options.md +103 -0
- package/guides/03-multiple-commands.md +163 -0
- package/guides/04-subcommands.md +206 -0
- package/guides/05-interactive-tui.md +194 -0
- package/guides/06-config-validation.md +264 -0
- package/guides/07-async-cancellation.md +388 -0
- package/guides/08-complete-application.md +673 -0
- package/guides/README.md +74 -0
- package/package.json +32 -0
- package/src/__tests__/application.test.ts +425 -0
- package/src/__tests__/buildCliCommand.test.ts +125 -0
- package/src/__tests__/builtins.test.ts +133 -0
- package/src/__tests__/colors.test.ts +127 -0
- package/src/__tests__/command.test.ts +157 -0
- package/src/__tests__/commandClass.test.ts +130 -0
- package/src/__tests__/context.test.ts +97 -0
- package/src/__tests__/help.test.ts +412 -0
- package/src/__tests__/parser.test.ts +268 -0
- package/src/__tests__/registry.test.ts +195 -0
- package/src/__tests__/registryNew.test.ts +160 -0
- package/src/__tests__/schemaToFields.test.ts +176 -0
- package/src/__tests__/table.test.ts +146 -0
- package/src/__tests__/tui.test.ts +26 -0
- package/src/builtins/help.ts +85 -0
- package/src/builtins/index.ts +4 -0
- package/src/builtins/settings.ts +106 -0
- package/src/builtins/version.ts +72 -0
- package/src/cli/help.ts +174 -0
- package/src/cli/index.ts +3 -0
- package/src/cli/output/colors.ts +74 -0
- package/src/cli/output/index.ts +2 -0
- package/src/cli/output/table.ts +141 -0
- package/src/cli/parser.ts +241 -0
- package/src/commands/help.ts +50 -0
- package/src/commands/index.ts +1 -0
- package/src/components/index.ts +147 -0
- package/src/core/application.ts +461 -0
- package/src/core/command.ts +269 -0
- package/src/core/context.ts +112 -0
- package/src/core/help.ts +214 -0
- package/src/core/index.ts +15 -0
- package/src/core/logger.ts +164 -0
- package/src/core/registry.ts +140 -0
- package/src/hooks/index.ts +131 -0
- package/src/index.ts +137 -0
- package/src/registry/commandRegistry.ts +77 -0
- package/src/registry/index.ts +1 -0
- package/src/tui/TuiApp.tsx +582 -0
- package/src/tui/TuiApplication.tsx +230 -0
- package/src/tui/app.ts +29 -0
- package/src/tui/components/ActionButton.tsx +36 -0
- package/src/tui/components/CliModal.tsx +81 -0
- package/src/tui/components/CommandSelector.tsx +159 -0
- package/src/tui/components/ConfigForm.tsx +148 -0
- package/src/tui/components/EditorModal.tsx +177 -0
- package/src/tui/components/FieldRow.tsx +30 -0
- package/src/tui/components/Header.tsx +31 -0
- package/src/tui/components/JsonHighlight.tsx +128 -0
- package/src/tui/components/LogsPanel.tsx +86 -0
- package/src/tui/components/ResultsPanel.tsx +93 -0
- package/src/tui/components/StatusBar.tsx +59 -0
- package/src/tui/components/index.ts +13 -0
- package/src/tui/components/types.ts +30 -0
- package/src/tui/context/KeyboardContext.tsx +118 -0
- package/src/tui/context/index.ts +7 -0
- package/src/tui/hooks/index.ts +35 -0
- package/src/tui/hooks/useClipboard.ts +66 -0
- package/src/tui/hooks/useCommandExecutor.ts +131 -0
- package/src/tui/hooks/useConfigState.ts +171 -0
- package/src/tui/hooks/useKeyboardHandler.ts +91 -0
- package/src/tui/hooks/useLogStream.ts +96 -0
- package/src/tui/hooks/useSpinner.ts +46 -0
- package/src/tui/index.ts +65 -0
- package/src/tui/theme.ts +21 -0
- package/src/tui/utils/buildCliCommand.ts +90 -0
- package/src/tui/utils/index.ts +13 -0
- package/src/tui/utils/parameterPersistence.ts +96 -0
- package/src/tui/utils/schemaToFields.ts +144 -0
- package/src/types/command.ts +103 -0
- package/src/types/execution.ts +11 -0
- package/src/types/index.ts +1 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Ubuntu",
|
|
3
|
+
"image": "mcr.microsoft.com/devcontainers/base:noble",
|
|
4
|
+
"features": {
|
|
5
|
+
"ghcr.io/devcontainers/features/github-cli:1": {},
|
|
6
|
+
"ghcr.io/devcontainers/features/azure-cli:latest": {},
|
|
7
|
+
"ghcr.io/devcontainers/features/docker-outside-of-docker": {}
|
|
8
|
+
},
|
|
9
|
+
"postCreateCommand": "./.devcontainer/install-prerequisites.sh",
|
|
10
|
+
"customizations": {
|
|
11
|
+
"vscode": {
|
|
12
|
+
"extensions": [
|
|
13
|
+
"oven.bun-vscode",
|
|
14
|
+
"ms-azuretools.vscode-docker",
|
|
15
|
+
"SanjulaGanepola.github-local-actions"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# if bun is not installed, install it
|
|
6
|
+
if ! command -v bun &> /dev/null
|
|
7
|
+
then
|
|
8
|
+
echo "Bun not found, installing..."
|
|
9
|
+
|
|
10
|
+
curl -fsSL https://bun.com/install | bash
|
|
11
|
+
|
|
12
|
+
# manual fix for missing package.json issue
|
|
13
|
+
if [ ! -f "$HOME/.bun/install/global/package.json" ]; then
|
|
14
|
+
echo "Creating missing package.json for bun global..."
|
|
15
|
+
mkdir -p "$HOME/.bun/install/global"
|
|
16
|
+
echo '{}' > "$HOME/.bun/install/global/package.json"
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# add bun to PATH
|
|
21
|
+
export PATH="$HOME/.bun/bin:$PATH"
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
# if there is no symlink for node, create it
|
|
25
|
+
if ! command -v node &> /dev/null
|
|
26
|
+
then
|
|
27
|
+
# discover the bun binary location
|
|
28
|
+
bunBinary=$(which bun)
|
|
29
|
+
echo "Bun binary located at: $bunBinary"
|
|
30
|
+
echo "Creating symlink for node to bun..."
|
|
31
|
+
mkdir -p $HOME/.local/bin
|
|
32
|
+
ln -sf "$bunBinary" "$HOME/.local/bin/node"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
export BUN_INSTALL_BIN=$HOME/.bun/bin
|
|
36
|
+
export BUN_INSTALL_GLOBAL_DIR=$HOME/.bun/global
|
|
37
|
+
|
|
38
|
+
# Ensure dirs exist and are owned by the current user
|
|
39
|
+
mkdir -p "$BUN_INSTALL_BIN" "$BUN_INSTALL_GLOBAL_DIR"
|
|
40
|
+
export PATH="$HOME/.bun/bin:$HOME/.bun/global/bin:${PATH}"
|
|
41
|
+
|
|
42
|
+
# add the paths to bashrc and zshrc
|
|
43
|
+
echo 'export PATH="$HOME/.bun/bin:$HOME/.bun/global/bin:${PATH}" ' >> $HOME/.bashrc
|
|
44
|
+
echo 'export PATH="$HOME/.bun/bin:$HOME/.bun/global/bin:${PATH}" '>> $HOME/.zshrc
|
|
45
|
+
|
|
46
|
+
# ensure $HOME/.local/bin is in PATH for current session and future shells
|
|
47
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
48
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"
|
|
49
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.zshrc"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: "Copilot Setup Steps"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
paths:
|
|
7
|
+
- .github/workflows/copilot-setup-steps.yml
|
|
8
|
+
pull_request:
|
|
9
|
+
paths:
|
|
10
|
+
- .github/workflows/copilot-setup-steps.yml
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
|
|
14
|
+
copilot-setup-steps:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout repository
|
|
22
|
+
uses: actions/checkout@v6
|
|
23
|
+
|
|
24
|
+
- name: Install prerequisites
|
|
25
|
+
run: |
|
|
26
|
+
chmod +x ./.devcontainer/install-prerequisites.sh
|
|
27
|
+
./.devcontainer/install-prerequisites.sh
|
|
28
|
+
echo "$HOME/.bun/bin" >> $GITHUB_PATH
|
|
29
|
+
echo "$HOME/.bun/global/bin" >> $GITHUB_PATH
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: bun install
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Pull Request
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ "main" ]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: PR
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout repository
|
|
14
|
+
uses: actions/checkout@v6
|
|
15
|
+
|
|
16
|
+
- name: Install prerequisites
|
|
17
|
+
run: |
|
|
18
|
+
chmod +x .devcontainer/install-prerequisites.sh
|
|
19
|
+
./.devcontainer/install-prerequisites.sh
|
|
20
|
+
echo "$HOME/.bun/bin" >> $GITHUB_PATH
|
|
21
|
+
echo "$HOME/.bun/global/bin" >> $GITHUB_PATH
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: bun install
|
|
25
|
+
|
|
26
|
+
- name: Run tests
|
|
27
|
+
run: bun test
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: Release NPM Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
tag:
|
|
9
|
+
description: 'Release tag (e.g., v1.2.3)'
|
|
10
|
+
required: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
name: Publish Package
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
packages: write
|
|
19
|
+
steps:
|
|
20
|
+
- name: Determine release tag
|
|
21
|
+
id: get_tag
|
|
22
|
+
run: |
|
|
23
|
+
echo "Event name: ${{ github.event_name }}"
|
|
24
|
+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
25
|
+
TAG="${{ github.event.inputs.tag }}"
|
|
26
|
+
else
|
|
27
|
+
TAG="${{ github.event.release.tag_name }}"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# if the tag is empty, exit with error
|
|
31
|
+
if [ -z "$TAG" ]; then
|
|
32
|
+
echo "Error: Tag is empty"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Strip 'v' prefix if present
|
|
37
|
+
VERSION="${TAG#v}"
|
|
38
|
+
|
|
39
|
+
echo "Using tag: $TAG"
|
|
40
|
+
echo "Using version: $VERSION"
|
|
41
|
+
|
|
42
|
+
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
43
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
44
|
+
|
|
45
|
+
- name: Checkout repository
|
|
46
|
+
uses: actions/checkout@v6
|
|
47
|
+
with:
|
|
48
|
+
ref: ${{ steps.get_tag.outputs.tag }}
|
|
49
|
+
|
|
50
|
+
- name: Install bun
|
|
51
|
+
run: |
|
|
52
|
+
curl -fsSL https://bun.com/install | bash
|
|
53
|
+
echo "$HOME/.bun/bin" >> $GITHUB_PATH
|
|
54
|
+
|
|
55
|
+
- name: Set package version
|
|
56
|
+
run: |
|
|
57
|
+
VERSION="${{ steps.get_tag.outputs.version }}"
|
|
58
|
+
jq --arg version "$VERSION" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
|
|
59
|
+
|
|
60
|
+
- name: Verify package version
|
|
61
|
+
run: |
|
|
62
|
+
EXPECTED_VERSION="${{ steps.get_tag.outputs.version }}"
|
|
63
|
+
ACTUAL_VERSION=$(jq -r '.version' package.json)
|
|
64
|
+
if [ "$EXPECTED_VERSION" != "$ACTUAL_VERSION" ]; then
|
|
65
|
+
echo "Error: Version mismatch. Expected $EXPECTED_VERSION, got $ACTUAL_VERSION"
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
echo "Version verified: $ACTUAL_VERSION"
|
|
69
|
+
|
|
70
|
+
- name: Install dependencies
|
|
71
|
+
run: bun install
|
|
72
|
+
- name: Build package
|
|
73
|
+
run: bun run build
|
|
74
|
+
|
|
75
|
+
- name: Publish Package
|
|
76
|
+
run: bun publish --no-build
|
|
77
|
+
env:
|
|
78
|
+
BUN_PUBLISH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pablo Zaidenvoren
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|