@joberthel/worktree 0.0.1 → 1.0.1
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 +49 -220
- package/dist/ui/progress.js +10 -5
- package/dist/ui/spinner.js +25 -0
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
# wt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@joberthel/worktree)
|
|
4
|
+
[](https://github.com/joberthel/worktree/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
Work on several branches of a Docker Compose project at the same time, each with its own containers and its own copy of the data.
|
|
8
|
+
|
|
9
|
+
Git worktrees give you a second checkout. They do not give you a second database. `wt` creates a Git worktree and pairs it with its own Docker Compose project. It copies selected files such as `.env` from your checkout and clones the named Docker volumes. Migrations, seed data and experiments in one branch then leave the others alone.
|
|
4
10
|
|
|
5
11
|
## How it works
|
|
6
12
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- State and Compose volume overrides are stored in the repository's shared Git metadata, so they are available from any linked worktree.
|
|
13
|
+
- `wt create` adds a Git worktree under `../worktrees` (configurable) and, by default, a new branch with the same name. A name such as `feature/login` keeps that branch name and uses the flat directory `feature--login`.
|
|
14
|
+
- Each worktree gets its own Compose project name and its own copies of the source project's named volumes. External volumes stay shared.
|
|
15
|
+
- `wt` finds the running Compose project of the checkout you run it from and uses that as the source.
|
|
16
|
+
- Its state is stored in the repository's shared Git metadata, so every command works from any worktree of the repository.
|
|
12
17
|
|
|
13
18
|
## Install
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
You need macOS or Linux, Node.js 22 or newer, Git, and Docker Compose 2.24.4 or newer.
|
|
16
21
|
|
|
17
22
|
```sh
|
|
18
23
|
npm install --global @joberthel/worktree
|
|
24
|
+
wt --version
|
|
19
25
|
```
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
Update with `npm update --global @joberthel/worktree` and uninstall with `npm uninstall --global @joberthel/worktree`. Uninstalling the CLI leaves your worktrees and Docker resources in place, so remove them with `wt rm` first.
|
|
28
|
+
|
|
29
|
+
To install from a clone of this repository instead:
|
|
22
30
|
|
|
23
31
|
```sh
|
|
24
32
|
pnpm install
|
|
@@ -27,49 +35,37 @@ pnpm pack --out /tmp/wt.tgz
|
|
|
27
35
|
pnpm add --global /tmp/wt.tgz
|
|
28
36
|
```
|
|
29
37
|
|
|
30
|
-
Check the installation with:
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
wt --help
|
|
34
|
-
```
|
|
35
|
-
|
|
36
38
|
## Quick start
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
Start the project's Compose environment from the root of your checkout, so that its project directory is the checkout root. Then create a worktree:
|
|
39
41
|
|
|
40
42
|
```sh
|
|
43
|
+
docker compose up -d
|
|
41
44
|
wt create feature/login
|
|
42
45
|
wt ls
|
|
43
46
|
cd ../worktrees/feature--login
|
|
44
47
|
```
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
This creates the branch `feature/login`, the worktree `../worktrees/feature--login`, and a running copy of the Compose project. To check out an existing local or remote branch instead, give the worktree a name and pass `--branch`. To branch off a ref other than `HEAD`, pass `--from`:
|
|
47
50
|
|
|
48
51
|
```sh
|
|
49
|
-
wt create login-review --branch feature/login
|
|
52
|
+
wt create login-review --branch origin/feature/login
|
|
53
|
+
wt create feature/signup --from main
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
A remote branch that has not been fetched yet is fetched automatically. This also works in clones that only track some branches (for example `git clone --single-branch`): the branch is added to the remote's fetch configuration. A shallow clone keeps its existing shallow boundaries when `wt` fetches another branch. Fetching a new branch can bring in more history for that branch.
|
|
55
|
-
|
|
56
|
-
To create a new branch from a ref other than `HEAD`:
|
|
56
|
+
When you are done, remove the worktree and its Docker resources. The branch is kept:
|
|
57
57
|
|
|
58
58
|
```sh
|
|
59
|
-
wt
|
|
59
|
+
wt rm feature/login
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
`--branch` and `--from` cannot be used together.
|
|
63
|
-
|
|
64
62
|
## Commands
|
|
65
63
|
|
|
66
|
-
Run commands from any worktree in the same repository:
|
|
67
|
-
|
|
68
64
|
| Command | What it does |
|
|
69
65
|
| --- | --- |
|
|
70
66
|
| `wt create <name> [--branch <branch> \| --from <ref>]` | Create a worktree, branch, and isolated Compose environment. |
|
|
71
67
|
| `wt ls` | List managed worktrees and their Docker status. |
|
|
72
|
-
| `wt info [name]` |
|
|
68
|
+
| `wt info [name]` | Show a worktree's branch, path, status, services and volumes. |
|
|
73
69
|
| `wt start [name]` | Start its Compose services. |
|
|
74
70
|
| `wt stop [name]` | Stop its Compose services. |
|
|
75
71
|
| `wt restart [name]` | Restart its Compose services. |
|
|
@@ -78,19 +74,23 @@ Run commands from any worktree in the same repository:
|
|
|
78
74
|
| `wt rm <name> [--force]` | Remove the managed environment and Git worktree while keeping its branch. |
|
|
79
75
|
| `wt completion <zsh\|bash>` | Print a shell completion script. |
|
|
80
76
|
|
|
81
|
-
Commands with an optional `[name]` default to the
|
|
82
|
-
|
|
83
|
-
Pass `-w <dir>` (or `--working-dir <dir>`) to run a command as if `wt` was started in that directory, for example for a repository in a subdirectory. It can go before or after the command, but not after `--`:
|
|
77
|
+
Run them from any worktree of the repository. Commands with an optional `[name]` default to the worktree that contains the current directory.
|
|
84
78
|
|
|
85
79
|
```sh
|
|
86
|
-
wt
|
|
87
|
-
wt
|
|
88
|
-
wt docker -w apps/shop feature/login -- logs -f app
|
|
80
|
+
wt docker feature/login -- logs -f app
|
|
81
|
+
wt docker -- exec app sh # from inside the feature/login worktree
|
|
89
82
|
```
|
|
90
83
|
|
|
84
|
+
Two options are shared by the commands:
|
|
85
|
+
|
|
86
|
+
- `-w <dir>` or `--working-dir <dir>` runs `wt` as if it was started in `<dir>`, for example for a repository in a subdirectory. It can go before or after the command, but not after `--`.
|
|
87
|
+
- `--format json` prints the result as JSON on stdout, for every command except `wt docker` and `wt completion`. See [JSON output](docs/json-output.md).
|
|
88
|
+
|
|
89
|
+
`wt reset` and `wt rm` ask before they change anything. Pass `--force` to skip the question, for example in scripts. See [Commands](docs/commands.md) for how branches are resolved, the confirmation prompt, and the progress view.
|
|
90
|
+
|
|
91
91
|
### Shell completion
|
|
92
92
|
|
|
93
|
-
Tab completes commands, options, worktree names
|
|
93
|
+
Tab completes commands, options, worktree names, branches after `--branch` and `--from`, and directories after `-w`. Load it from your shell's startup file:
|
|
94
94
|
|
|
95
95
|
```sh
|
|
96
96
|
# ~/.zshrc, after compinit
|
|
@@ -100,56 +100,9 @@ source <(wt completion zsh)
|
|
|
100
100
|
eval "$(wt completion bash)"
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
In zsh you can instead save the script as `_wt` in a directory on your `fpath`. In bash, use `eval` as shown: the bash 3.2 that ships with macOS cannot `source` a process substitution. Worktree names are read from `wt`'s state files. Only `wt start`, `wt stop` and `wt restart` also ask Docker, to offer just the worktrees that are stopped or running. If Docker does not answer within 1.5 seconds, they offer every worktree.
|
|
104
|
-
|
|
105
|
-
### JSON output
|
|
106
|
-
|
|
107
|
-
Every command except `wt docker` accepts `--format json` (or `--format=json`) to print its result as JSON on stdout. Use it from scripts and coding agents instead of parsing the tables. Progress still goes to stderr, and errors are printed to stderr as text with a non-zero exit status.
|
|
108
|
-
|
|
109
|
-
```sh
|
|
110
|
-
wt ls --format json
|
|
111
|
-
wt info feature/login --format json | jq -r .path
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
`wt ls` prints an array of environments. `wt info` prints one environment. Each container has its `name`, Compose `service`, Docker `state` (such as `running` or `exited`) and human-readable `status` (such as `Up 2 hours (healthy)`). Values that are absent, such as the branch of a detached checkout, are `null`.
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
[
|
|
118
|
-
{
|
|
119
|
-
"name": "feature/login",
|
|
120
|
-
"branch": "feature/login",
|
|
121
|
-
"path": "/code/worktrees/feature--login",
|
|
122
|
-
"status": "ready",
|
|
123
|
-
"dockerStatus": "running",
|
|
124
|
-
"projectName": "wt-1a2b3c-feature--login"
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
`create`, `start`, `stop`, `restart`, `reset`, and `rm` print `{ "name", "action", "completed" }`. `create` also includes `path` and `projectName`. A declined `reset` or `rm` prints `"completed": false` and exits with status 0. Without a terminal, `reset` and `rm` need `--force`.
|
|
130
|
-
|
|
131
|
-
For example, inspect or run a command against a worktree's Compose project:
|
|
132
|
-
|
|
133
|
-
```sh
|
|
134
|
-
wt docker feature/login -- ps
|
|
135
|
-
wt docker feature/login -- logs -f app
|
|
136
|
-
|
|
137
|
-
# from inside the feature/login worktree
|
|
138
|
-
wt docker -- exec app sh
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
`reset` and `rm` ask before destructive changes. Pass `--force` to skip the confirmation:
|
|
142
|
-
|
|
143
|
-
```sh
|
|
144
|
-
wt reset feature/login --force
|
|
145
|
-
wt rm feature/login --force
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Long-running commands show the current step and completed steps, including when each configured hook starts and finishes. For example, the progress view identifies `worktree.before_create` and `source.after_create` hooks by their executable path or as an inline script. Confirmation prompts list the directory, Compose project, paths, and volumes that are affected. Cancel is preselected. Use the arrow keys or `y` to select an action, then press Enter. Esc or `n` cancels. When stdout is redirected, type `yes` at the prompt on stderr to proceed.
|
|
149
|
-
|
|
150
103
|
## Configuration
|
|
151
104
|
|
|
152
|
-
Put `.wt.yml` at the root of
|
|
105
|
+
`wt` works without a configuration file. Put `.wt.yml` at the root of your checkout to copy files into new worktrees, run setup hooks, or change the worktree directory:
|
|
153
106
|
|
|
154
107
|
```yaml
|
|
155
108
|
worktrees:
|
|
@@ -159,157 +112,33 @@ copy:
|
|
|
159
112
|
- .env
|
|
160
113
|
- storage
|
|
161
114
|
|
|
162
|
-
hooks:
|
|
163
|
-
worktree:
|
|
164
|
-
before_create:
|
|
165
|
-
script: |
|
|
166
|
-
set -eu
|
|
167
|
-
echo "Preparing $WORKTREE_NAME at $WORKTREE_PATH"
|
|
168
|
-
# Add any per-worktree setup here.
|
|
169
|
-
after_create:
|
|
170
|
-
script: |
|
|
171
|
-
set -eu
|
|
172
|
-
echo "Started $COMPOSE_PROJECT_NAME"
|
|
173
|
-
source:
|
|
174
|
-
after_create: scripts/register-worktree.sh
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### `worktrees.directory`
|
|
178
|
-
|
|
179
|
-
The directory where worktrees are created. Relative paths are resolved from the main checkout, or from the parent of the Git directory for a bare repository. When an existing linked checkout uses a separate Git directory and Git cannot identify its main checkout, `wt` uses the main checkout recorded in its state or falls back to the current checkout. The default is `../worktrees`.
|
|
180
|
-
|
|
181
|
-
### `copy`
|
|
182
|
-
|
|
183
|
-
Relative files and directories copied from the source checkout into each new worktree. `wt reset` replaces these paths with fresh copies from the source checkout. Paths must stay inside the repository, and overlapping entries are not allowed. Use this for files such as `.env` or seed data; Docker volumes are handled separately.
|
|
184
|
-
|
|
185
|
-
### `hooks`
|
|
186
|
-
|
|
187
|
-
Hooks run while an environment is created by `wt create` and again when it is rebuilt by `wt reset`. They do not run for `wt start`, `wt stop`, or `wt restart`. There are two events:
|
|
188
|
-
|
|
189
|
-
- `before_create`: after the worktree, copied files, and cloned volumes are in place, before Docker Compose starts the services.
|
|
190
|
-
- `after_create`: after Docker Compose has started the services.
|
|
191
|
-
|
|
192
|
-
Hooks are grouped by where they run:
|
|
193
|
-
|
|
194
|
-
- `hooks.worktree`: in the new worktree directory. Use these for per-worktree setup.
|
|
195
|
-
- `hooks.source`: in the source checkout, which is the checkout `wt create` was run from and the same directory as `SOURCE_WORKTREE_PATH`. Use these for work that belongs to the originating repository, such as dumping data or registering the new environment in a shared proxy config.
|
|
196
|
-
|
|
197
|
-
A hook can be an executable path or an inline shell script:
|
|
198
|
-
|
|
199
|
-
```yaml
|
|
200
|
-
hooks:
|
|
201
|
-
worktree:
|
|
202
|
-
before_create: scripts/before-create.sh
|
|
203
|
-
after_create:
|
|
204
|
-
script: |
|
|
205
|
-
./bin/clear-cache
|
|
206
|
-
source:
|
|
207
|
-
after_create:
|
|
208
|
-
script: |
|
|
209
|
-
echo "$WORKTREE_NAME is up at $WORKTREE_PATH" >> .wt-environments.log
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
Executable paths are relative to the directory the hook runs in. Inline scripts run with `/bin/sh` and need `set -e` if they should stop at the first failure. Hooks run with stdin closed and no terminal. Redirect background jobs’ output to a file if you need to keep their logs. Hooks execute repository commands during create and reset, so use them with repositories you trust. Source hooks wrap the worktree hooks in this order.
|
|
213
|
-
|
|
214
|
-
1. `source.before_create`
|
|
215
|
-
2. `worktree.before_create`
|
|
216
|
-
3. Docker Compose startup
|
|
217
|
-
4. `worktree.after_create`
|
|
218
|
-
5. `source.after_create`
|
|
219
|
-
|
|
220
|
-
Because `wt reset` runs every hook again, keep them safe to repeat. Executable source hooks are checked before anything is created or reset.
|
|
221
|
-
|
|
222
|
-
All hooks receive these environment variables:
|
|
223
|
-
|
|
224
|
-
- `WORKTREE_NAME`: a Docker-safe slug derived from the worktree name (for example, `feature/login` becomes `feature--login`).
|
|
225
|
-
- `WORKTREE_ORIGINAL_NAME`: the name accepted by `wt`, including any slashes.
|
|
226
|
-
- `WORKTREE_BRANCH`: the checked-out Git branch.
|
|
227
|
-
- `WORKTREE_PATH`: absolute path to the worktree.
|
|
228
|
-
- `WORKTREE_COMPOSE_PROJECT_NAME`: Compose project name of the new environment.
|
|
229
|
-
- `SOURCE_WORKTREE_PATH`: absolute path to the source checkout.
|
|
230
|
-
- `SOURCE_COMPOSE_PROJECT_NAME`: Compose project name of the running source environment.
|
|
231
|
-
- `WORKTREE_COMPOSE_FILE` and `SOURCE_COMPOSE_FILE` give the Compose files for each project.
|
|
232
|
-
- `COMPOSE_PROJECT_NAME` and `COMPOSE_FILE` identify the project in the hook’s checkout. A worktree hook can use plain `docker compose run` or `docker compose exec` and will use the cloned volumes.
|
|
233
|
-
|
|
234
|
-
The slug is useful in hostnames and resource names. Use the original name for commands such as `wt info "$WORKTREE_ORIGINAL_NAME"`.
|
|
235
|
-
|
|
236
|
-
## Worktrees of a nested repository
|
|
237
|
-
|
|
238
|
-
Some repositories only run inside another one. A Shopware plugin, for example, lives in its own Git repository under `custom/plugins/` of a Shopware checkout and needs that checkout's Docker environment. Set `host` in the nested repository's `.wt.yml` to work on it with `wt`:
|
|
239
|
-
|
|
240
|
-
```yaml
|
|
241
|
-
# custom/plugins/SwagExample/.wt.yml
|
|
242
|
-
host:
|
|
243
|
-
path: ../../.. # root of the host checkout, relative to this checkout
|
|
244
|
-
from: trunk # optional host ref to check out; defaults to the host checkout's HEAD
|
|
245
|
-
|
|
246
|
-
copy:
|
|
247
|
-
- .env.local
|
|
248
|
-
|
|
249
115
|
hooks:
|
|
250
116
|
worktree:
|
|
251
117
|
after_create:
|
|
252
118
|
script: |
|
|
253
119
|
set -eu
|
|
254
|
-
docker compose exec -T
|
|
255
|
-
docker compose exec -T web bin/console plugin:install --activate --reinstall SwagExample
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
Run the commands from the nested repository:
|
|
259
|
-
|
|
260
|
-
```sh
|
|
261
|
-
cd custom/plugins/SwagExample
|
|
262
|
-
wt create feature/checkout
|
|
120
|
+
docker compose exec -T app bin/migrate
|
|
263
121
|
```
|
|
264
122
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
1. Creates a worktree of the host repository with a detached HEAD, so the host repository gets no new branch. It uses the host’s `.wt.yml` for the worktree directory, copied files, cloned volumes, and hooks, just like `wt create` in the host checkout. The host worktree is named after the nested checkout’s directory and the worktree name, for example `swagexample/feature/checkout`.
|
|
268
|
-
2. Adds a worktree of the nested repository on the new branch `feature/checkout` at the same relative path inside the host worktree, such as `custom/plugins/SwagExample`. The host’s Compose bind mounts expose it to the containers.
|
|
269
|
-
3. Copies the nested repository’s `copy` paths into it.
|
|
270
|
-
4. Starts the host environment. Hooks run in this order: the host’s before hooks, the nested repository’s before hooks, Docker Compose startup, the host’s after hooks, then the nested repository’s after hooks. The host is fully set up before the nested hooks run.
|
|
123
|
+
See [Configuration](docs/configuration.md) for every option, the hook order and variables, and how volumes are cloned. For a repository that runs inside another one, such as a Shopware plugin, see [Nested repositories](docs/nested-repositories.md).
|
|
271
124
|
|
|
272
|
-
|
|
125
|
+
Before you clone a database volume, stop writes to it or stop the source services if you need a consistent snapshot. Use dynamic host ports and leave out fixed `container_name` values, so the source and worktree projects can run side by side.
|
|
273
126
|
|
|
274
|
-
|
|
275
|
-
- `HOST_WORKTREE_ORIGINAL_NAME`: its name.
|
|
276
|
-
- `HOST_WORKTREE_PATH`: its absolute path.
|
|
277
|
-
- `HOST_SOURCE_WORKTREE_PATH`: the host checkout it was created from.
|
|
127
|
+
## Documentation
|
|
278
128
|
|
|
279
|
-
|
|
129
|
+
- [Commands](docs/commands.md): branches, confirmations, progress, and shell completion in detail.
|
|
130
|
+
- [Configuration](docs/configuration.md): `.wt.yml`, hooks, environment variables, and Docker volumes.
|
|
131
|
+
- [Nested repositories](docs/nested-repositories.md): worktrees of a repository that lives inside another checkout.
|
|
132
|
+
- [JSON output](docs/json-output.md): the output of `--format json` for scripts and coding agents.
|
|
133
|
+
- [Troubleshooting](docs/troubleshooting.md): recovering from a failed create or reset and stale locks.
|
|
280
134
|
|
|
281
|
-
|
|
135
|
+
## Versioning
|
|
282
136
|
|
|
283
|
-
|
|
137
|
+
`wt` follows [Semantic Versioning](https://semver.org). Breaking changes to the following need a new major version: commands and their options, the `.wt.yml` format, the environment variables passed to hooks, and the JSON output. The state files in the Git metadata are internal and may change in any release. See the [changelog](CHANGELOG.md) for what changed.
|
|
284
138
|
|
|
285
|
-
|
|
139
|
+
## Contributing
|
|
286
140
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
`wt` copies non-external named volumes declared in the source Compose configuration, including volumes that currently have no container attached. Reset can read volumes the source project retained after `docker compose down`. If source data is missing, reset stops before tearing down the target or removing its old volumes. External volumes remain shared. Anonymous volumes start empty and are removed when you reset or remove a worktree.
|
|
290
|
-
|
|
291
|
-
The volume copy runs in a digest-pinned Debian image. Set `WT_VOLUME_COPY_IMAGE` to use a different image that contains Bash and GNU tar with sparse file, extended attribute, and ACL support.
|
|
292
|
-
|
|
293
|
-
Stop writes or stop the source services before cloning a database volume if you need a consistent snapshot. Use dynamic host ports and omit fixed `container_name` values when running the source and worktree projects side by side.
|
|
294
|
-
|
|
295
|
-
## Recovering an environment
|
|
296
|
-
|
|
297
|
-
After a partial create or reset, run `wt info <name>` to see the saved error. Fix the issue and rerun `wt reset <name>` to retry setup, or run `wt rm <name>` to remove the checkout and its Docker resources. Removing a source worktree leaves its children running, but they need that source to reset. Reuse the branch from a removed worktree with `wt create <name> --branch <branch>`.
|
|
298
|
-
|
|
299
|
-
If the process is killed before it can release its lock, verify that the process shown in the error has exited before removing the lock file named in the error.
|
|
300
|
-
|
|
301
|
-
## Development checks
|
|
302
|
-
|
|
303
|
-
```sh
|
|
304
|
-
pnpm build
|
|
305
|
-
pnpm test
|
|
306
|
-
pnpm typecheck
|
|
307
|
-
WT_DOCKER_INTEGRATION=1 pnpm test:e2e
|
|
308
|
-
pnpm test:coverage
|
|
309
|
-
pnpm lint
|
|
310
|
-
pnpm audit
|
|
311
|
-
pinact run --check
|
|
312
|
-
```
|
|
141
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
313
142
|
|
|
314
143
|
## License
|
|
315
144
|
|
package/dist/ui/progress.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { Box, Static } from 'ink';
|
|
2
|
+
import { Box, Static, Text } from 'ink';
|
|
4
3
|
import { HookLogPanel } from './hook-log-panel.js';
|
|
4
|
+
import { Spinner } from './spinner.js';
|
|
5
|
+
function StepStatus({ failed, children }) {
|
|
6
|
+
return (_jsxs(Box, { gap: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: failed
|
|
7
|
+
? 'red'
|
|
8
|
+
: 'green', children: failed
|
|
9
|
+
? '✘'
|
|
10
|
+
: '✔' }) }), _jsx(Text, { children: children })] }));
|
|
11
|
+
}
|
|
5
12
|
export function ProgressView({ progress, fallback, finished = false }) {
|
|
6
13
|
const active = finished
|
|
7
14
|
? undefined
|
|
8
15
|
: progress.current ?? (progress.steps.length === 0
|
|
9
16
|
? fallback
|
|
10
17
|
: undefined);
|
|
11
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: progress.steps, children: (step, index) => (_jsx(
|
|
12
|
-
? 'error'
|
|
13
|
-
: 'success', children: step.label.replace(/^Running /, step.status === 'failed'
|
|
18
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: progress.steps, children: (step, index) => (_jsx(StepStatus, { failed: step.status === 'failed', children: step.label.replace(/^Running /, step.status === 'failed'
|
|
14
19
|
? 'Failed '
|
|
15
20
|
: 'Completed ') }, index)) }), active !== undefined && _jsx(Spinner, { label: active }), progress.hook.label && _jsx(HookLogPanel, { hook: progress.hook })] }));
|
|
16
21
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
/** The frames and timing of the "dots" spinner from cli-spinners. */
|
|
5
|
+
const frames = [
|
|
6
|
+
'⠋',
|
|
7
|
+
'⠙',
|
|
8
|
+
'⠹',
|
|
9
|
+
'⠸',
|
|
10
|
+
'⠼',
|
|
11
|
+
'⠴',
|
|
12
|
+
'⠦',
|
|
13
|
+
'⠧',
|
|
14
|
+
'⠇',
|
|
15
|
+
'⠏',
|
|
16
|
+
];
|
|
17
|
+
const interval = 80;
|
|
18
|
+
export function Spinner({ label }) {
|
|
19
|
+
const [frame, setFrame] = React.useState(0);
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
const timer = setInterval(() => setFrame(previous => (previous + 1) % frames.length), interval);
|
|
22
|
+
return () => clearInterval(timer);
|
|
23
|
+
}, []);
|
|
24
|
+
return (_jsxs(Box, { gap: 1, children: [_jsx(Text, { color: "blue", children: frames[frame] }), _jsx(Text, { children: label })] }));
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joberthel/worktree",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "Isolated development environments from Git worktrees, each with its own Docker Compose project and cloned volumes.",
|
|
6
6
|
"author": "Johannes Berthel",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"node": ">=22"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@inkjs/ui": "^2.0.0",
|
|
35
34
|
"ink": "^8.0.0",
|
|
36
35
|
"react": "^19.3.1",
|
|
37
36
|
"yaml": "^2.9.1",
|