@joberthel/worktree 1.0.1 → 1.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/README.md CHANGED
@@ -64,8 +64,8 @@ wt rm feature/login
64
64
  | Command | What it does |
65
65
  | --- | --- |
66
66
  | `wt create <name> [--branch <branch> \| --from <ref>]` | Create a worktree, branch, and isolated Compose environment. |
67
- | `wt ls` | List managed worktrees and their Docker status. |
68
- | `wt info [name]` | Show a worktree's branch, path, status, services and volumes. |
67
+ | `wt ls [--filter <key=value>...]` | List managed worktrees, their Docker status and, with OrbStack, their main URL. Filter by `name`, `branch` or `state`. |
68
+ | `wt info [name]` | Show a worktree's branch, path, status, services, OrbStack domains and volumes. |
69
69
  | `wt start [name]` | Start its Compose services. |
70
70
  | `wt stop [name]` | Stop its Compose services. |
71
71
  | `wt restart [name]` | Restart its Compose services. |
package/dist/cli-spec.js CHANGED
@@ -1,18 +1,27 @@
1
1
  import { stat } from 'node:fs/promises';
2
2
  import { resolve } from 'node:path';
3
3
  import process from 'node:process';
4
+ const force = {
5
+ type: 'boolean',
6
+ description: 'Skip the confirmation',
7
+ };
4
8
  export const commands = {
5
9
  create: {
6
10
  usage: '<name> [--branch <branch> | --from <ref>]',
7
11
  summary: 'Create an environment',
8
- options: { branch: 'string', from: 'string' },
12
+ options: {
13
+ branch: { type: 'string', value: '<branch>', description: 'Check out an existing local or remote branch' },
14
+ from: { type: 'string', value: '<ref>', description: 'Create the new branch from this ref (default: HEAD)' },
15
+ },
9
16
  environment: false,
10
17
  shared: true,
11
18
  },
12
19
  ls: {
13
- usage: '',
20
+ usage: '[--filter <key=value>...]',
14
21
  summary: 'List managed environments',
15
- options: {},
22
+ options: {
23
+ filter: { type: 'strings', value: '<key=value>', description: 'Show only environments matching name=, branch= or state=; repeatable' },
24
+ },
16
25
  environment: false,
17
26
  shared: true,
18
27
  },
@@ -54,14 +63,14 @@ export const commands = {
54
63
  reset: {
55
64
  usage: '[name] [--force]',
56
65
  summary: 'Refresh files and volumes from the source',
57
- options: { force: 'boolean' },
66
+ options: { force },
58
67
  environment: 'any',
59
68
  shared: true,
60
69
  },
61
70
  rm: {
62
71
  usage: '<name> [--force]',
63
72
  summary: 'Remove an environment and keep its branch',
64
- options: { force: 'boolean' },
73
+ options: { force },
65
74
  environment: 'any',
66
75
  shared: true,
67
76
  },
@@ -77,11 +86,16 @@ export const shells = ['zsh', 'bash'];
77
86
  export function isCommand(value) {
78
87
  return Object.hasOwn(commands, value);
79
88
  }
89
+ /** Options of a command without the shared ones, as name and spec. */
90
+ export function commandOptions(command) {
91
+ const spec = commands[command];
92
+ return Object.entries(spec.options);
93
+ }
80
94
  /** Options of a command as `parseArgs` expects them, including `--format` where it applies. */
81
95
  export function parseOptions(command) {
82
96
  const spec = commands[command];
83
97
  return Object.fromEntries([
84
- ...Object.entries(spec.options),
98
+ ...commandOptions(command).map(([name, { type }]) => [name, type]),
85
99
  ...(spec.shared
86
100
  ? [
87
101
  ['format', 'string'],
@@ -89,7 +103,9 @@ export function parseOptions(command) {
89
103
  : []),
90
104
  ].map(([name, type]) => [
91
105
  name,
92
- { type },
106
+ type === 'strings'
107
+ ? { type: 'string', multiple: true }
108
+ : { type },
93
109
  ]));
94
110
  }
95
111
  export class UsageError extends Error {
package/dist/cli.js CHANGED
@@ -2,9 +2,10 @@
2
2
  import { readFileSync } from 'node:fs';
3
3
  import process from 'node:process';
4
4
  import { parseArgs } from 'node:util';
5
- import { commands, extractWorkingDir, isCommand, parseOptions, shells, UsageError, workingDirectory } from './cli-spec.js';
5
+ import { commandOptions, commands, extractWorkingDir, isCommand, parseOptions, shells, UsageError, workingDirectory } from './cli-spec.js';
6
6
  import { complete, completionScripts, formatCompletion } from './completion.js';
7
7
  import { listBranches } from './git/repository.js';
8
+ import { hasListFilter, matchesListFilter, parseListFilter } from './list-filter.js';
8
9
  import { composeOperation, createEnvironment, inspectEnvironment, listEnvironmentNames, listEnvironments, removeEnvironment, resetEnvironment, resolveEnvironmentName, runningEnvironmentNames } from './operations/commands.js';
9
10
  import { ProcessFailure, withOperationSignal } from './operations/process.js';
10
11
  import { formatEnvironmentInfo } from './ui/environment-info.js';
@@ -24,15 +25,26 @@ function usage(command) {
24
25
  if (command !== undefined) {
25
26
  const { usage: args, summary, shared } = commands[command];
26
27
  const options = [
28
+ ...commandOptions(command).map(([name, { value, description }]) => [
29
+ value === undefined
30
+ ? `--${name}`
31
+ : `--${name} ${value}`,
32
+ description,
33
+ ]),
27
34
  ...(command === 'completion'
28
35
  ? []
29
- : [' -w, --working-dir <dir> Run as if wt was started in <dir>']),
36
+ : [
37
+ ['-w, --working-dir <dir>', 'Run as if wt was started in <dir>'],
38
+ ]),
30
39
  ...(shared
31
- ? [' --format <text|json> Output format (default: text)']
40
+ ? [
41
+ ['--format <text|json>', 'Output format (default: text)'],
42
+ ]
32
43
  : []),
33
44
  ];
45
+ const width = Math.max(...options.map(([flags]) => flags.length));
34
46
  const optionList = options.length
35
- ? `\n\nOptions:\n${options.join('\n')}`
47
+ ? `\n\nOptions:\n${options.map(([flags, text]) => ` ${flags.padEnd(width)} ${text}`).join('\n')}`
36
48
  : '';
37
49
  return `Usage: ${`wt ${command} ${args}`.trimEnd()}\n\n${summary}${optionList}`;
38
50
  }
@@ -109,8 +121,9 @@ async function main(argv, signal, interrupt) {
109
121
  await dispatchDocker(args, cwd);
110
122
  return;
111
123
  }
112
- const { format, positionals, values } = parseCommandArgs(action, args);
124
+ const { format, filter, positionals, values } = parseCommandArgs(action, args);
113
125
  const result = await showOperation(`Running wt ${action}`, async (report, confirm) => withOperationSignal(signal, async () => runCommand(action, positionals, values, cwd, {
126
+ filter,
114
127
  report,
115
128
  confirm,
116
129
  signal,
@@ -152,12 +165,15 @@ function parseCommandArgs(action, args) {
152
165
  const format = values.format ?? 'text';
153
166
  if (!isFormat(format))
154
167
  throw new UsageError(`Unknown format ${String(format)}. Use --format text or --format json.`);
155
- return { format, positionals, values };
168
+ const filter = parseListFilter(Array.isArray(values.filter)
169
+ ? values.filter
170
+ : []);
171
+ return { format, filter, positionals, values };
156
172
  }
157
173
  function isFormat(value) {
158
174
  return value === 'text' || value === 'json';
159
175
  }
160
- async function runCommand(action, [name], values, cwd, { report, confirm, signal }) {
176
+ async function runCommand(action, [name], values, cwd, { filter, report, confirm, signal }) {
161
177
  if (action === 'create') {
162
178
  const options = { branch: values.branch, from: values.from };
163
179
  const result = await createEnvironment(name, options, cwd, report);
@@ -173,11 +189,13 @@ async function runCommand(action, [name], values, cwd, { report, confirm, signal
173
189
  };
174
190
  }
175
191
  if (action === 'ls') {
176
- const states = await listEnvironments(cwd);
192
+ const states = (await listEnvironments(cwd)).filter(state => matchesListFilter(state, filter));
177
193
  return {
178
194
  text: states.length
179
195
  ? formatEnvironmentTable(states)
180
- : 'No managed worktrees. Create one with wt create <name>.',
196
+ : hasListFilter(filter)
197
+ ? 'No managed worktrees match the filter.'
198
+ : 'No managed worktrees. Create one with wt create <name>.',
181
199
  json: environmentListJson(states),
182
200
  };
183
201
  }
@@ -1,4 +1,5 @@
1
- import { commands, extractWorkingDir, isCommand, shells, workingDirectory } from './cli-spec.js';
1
+ import { commandOptions, commands, extractWorkingDir, isCommand, shells, workingDirectory } from './cli-spec.js';
2
+ import { filterStates } from './list-filter.js';
2
3
  const none = { kind: 'values', values: [] };
3
4
  const workingDirOptions = ['-w', '--working-dir'];
4
5
  const globalOptions = [
@@ -16,7 +17,7 @@ function commandCandidates() {
16
17
  function valueOptions(command) {
17
18
  const spec = commands[command];
18
19
  return new Set([
19
- ...Object.entries(spec.options).filter(([, type]) => type === 'string').map(([name]) => `--${name}`),
20
+ ...commandOptions(command).filter(([, { type }]) => type !== 'boolean').map(([name]) => `--${name}`),
20
21
  ...(spec.shared
21
22
  ? ['--format']
22
23
  : []),
@@ -24,7 +25,7 @@ function valueOptions(command) {
24
25
  }
25
26
  function optionCandidates(command) {
26
27
  const spec = commands[command];
27
- return values(...Object.keys(spec.options).map(name => ({ value: `--${name}`, description: '' })), ...(spec.shared
28
+ return values(...commandOptions(command).map(([name, { description }]) => ({ value: `--${name}`, description })), ...(spec.shared
28
29
  ? [
29
30
  { value: '--format', description: 'Output format' },
30
31
  ]
@@ -50,6 +51,14 @@ async function applicableEnvironments(command, cwd, sources) {
50
51
  ? environments
51
52
  : environments.filter(({ name }) => running.has(name) === (wanted === 'running'));
52
53
  }
54
+ /** Complete filters for `wt ls --filter`: every state, and the names and branches of the environments. */
55
+ async function filterCandidates(cwd, sources) {
56
+ const environments = await sources.environments(cwd);
57
+ const branches = [
58
+ ...new Set(environments.map(({ branch }) => branch).filter(Boolean)),
59
+ ];
60
+ return values(...filterStates.map(state => ({ value: `state=${state}`, description: '' })), ...environments.map(({ name, branch }) => ({ value: `name=${name}`, description: branch || '(detached)' })), ...branches.map(branch => ({ value: `branch=${branch}`, description: '' })));
61
+ }
53
62
  async function environmentCandidates(command, cwd, sources) {
54
63
  const environments = await applicableEnvironments(command, cwd, sources);
55
64
  return values(...environments.map(({ name, branch }) => ({ value: name, description: branch || '(detached)' })), ...(command === 'docker'
@@ -101,6 +110,8 @@ async function completeArguments(command, args, current, { cwd, sources }) {
101
110
  const takesValue = valueOptions(command);
102
111
  if (previous === '--format' && takesValue.has('--format'))
103
112
  return values({ value: 'text', description: 'For people (default)' }, { value: 'json', description: 'For scripts and agents' });
113
+ if (previous === '--filter' && takesValue.has('--filter'))
114
+ return filterCandidates(await cwd(), sources);
104
115
  if (previous !== undefined && takesValue.has(previous))
105
116
  return values(...(await sources.branches(await cwd())).map(value => ({ value, description: '' })));
106
117
  if (current.startsWith('-'))
@@ -0,0 +1,77 @@
1
+ import { run } from '../operations/process.js';
2
+ import { docker } from './compose.js';
3
+ /** Container label that gives a container custom OrbStack domains. */
4
+ export const domainsLabel = 'dev.orbstack.domains';
5
+ /**
6
+ * OrbStack's network settings when the Docker engine is OrbStack, otherwise
7
+ * undefined. HTTPS is OrbStack's default, so it is assumed when `orbctl`
8
+ * cannot answer.
9
+ */
10
+ export async function orbstackNetwork(cwd) {
11
+ const [system, https] = await Promise.all([
12
+ docker(['info', '--format', '{{.OperatingSystem}}'], cwd).catch(() => ''),
13
+ run('orbctl', ['config', 'get', 'network.https'], cwd, { timeout: 2000 }).catch(() => ''),
14
+ ]);
15
+ if (system !== 'OrbStack')
16
+ return undefined;
17
+ return {
18
+ scheme: https === 'false'
19
+ ? 'http'
20
+ : 'https',
21
+ };
22
+ }
23
+ /** Domains of a `dev.orbstack.domains` label. Wildcards are not addresses, so they are left out. */
24
+ export function parseDomains(label) {
25
+ return label.split(',').map(domain => domain.trim()).filter(domain => domain !== '' && !domain.includes('*'));
26
+ }
27
+ /**
28
+ * Addresses of a Compose project's containers. A service is reached as
29
+ * `<service>.<project>.orb.local`; a service with several containers falls
30
+ * back to `<container>.orb.local` so each address stays unique.
31
+ */
32
+ export function containerAddresses(containers, project, { scheme }) {
33
+ const counts = new Map();
34
+ for (const { service } of containers)
35
+ counts.set(service, (counts.get(service) ?? 0) + 1);
36
+ return containers.map(({ name, service, domains }) => ({
37
+ hostname: counts.get(service) === 1
38
+ ? `${service}.${project}.orb.local`
39
+ : `${name}.orb.local`,
40
+ urls: domains.map(domain => `${scheme}://${domain}`),
41
+ }));
42
+ }
43
+ /**
44
+ * The main URL of each Compose project: its custom domain closest to the
45
+ * root, so `shop.orb.local` wins over `admin.shop.orb.local`. Among domains
46
+ * of equal depth, the one listed first in its label wins.
47
+ */
48
+ export async function projectUrls(cwd) {
49
+ const network = await orbstackNetwork(cwd);
50
+ if (network === undefined)
51
+ return () => undefined;
52
+ const output = await docker([
53
+ 'ps',
54
+ '-a',
55
+ '--filter',
56
+ `label=${domainsLabel}`,
57
+ '--format',
58
+ `{{.Label "com.docker.compose.project"}}\t{{.Label "${domainsLabel}"}}`,
59
+ ], cwd);
60
+ const domains = new Map();
61
+ for (const line of output.split('\n').filter(Boolean)) {
62
+ const [project, label = ''] = line.split('\t');
63
+ domains.set(project, [
64
+ ...domains.get(project) ?? [],
65
+ ...parseDomains(label).map((domain, position) => ({ domain, position })),
66
+ ]);
67
+ }
68
+ const depth = (domain) => domain.split('.').length;
69
+ return (project) => {
70
+ const [main] = [
71
+ ...domains.get(project) ?? [],
72
+ ].sort((a, b) => depth(a.domain) - depth(b.domain) || a.position - b.position || a.domain.localeCompare(b.domain));
73
+ return main === undefined
74
+ ? undefined
75
+ : `${network.scheme}://${main.domain}`;
76
+ };
77
+ }
@@ -0,0 +1,57 @@
1
+ import { UsageError } from './cli-spec.js';
2
+ /*
3
+ * Filters for `wt ls --filter key=value`, modeled on `docker ps --filter`.
4
+ * Values of the same key match if any of them does, and different keys must
5
+ * all match.
6
+ */
7
+ export const filterKeys = ['name', 'branch', 'state'];
8
+ /** Values `state=` accepts: the setup states other than `ready`, and the Docker states. */
9
+ export const filterStates = [
10
+ 'running',
11
+ 'stopped',
12
+ 'finished',
13
+ 'missing',
14
+ 'creating',
15
+ 'resetting',
16
+ 'removing',
17
+ 'failed',
18
+ ];
19
+ function isFilterKey(value) {
20
+ return filterKeys.includes(value);
21
+ }
22
+ export function parseListFilter(expressions) {
23
+ const filter = {};
24
+ for (const expression of expressions) {
25
+ const separator = expression.indexOf('=');
26
+ const key = expression.slice(0, separator);
27
+ const value = expression.slice(separator + 1);
28
+ if (separator === -1 || !isFilterKey(key))
29
+ throw new UsageError(`Unknown filter ${expression}. Use ${filterKeys.map(name => `${name}=<value>`).join(', ')}.`);
30
+ if (value === '')
31
+ throw new UsageError(`Filter ${key}= needs a value.`);
32
+ if (key === 'state' && !filterStates.includes(value))
33
+ throw new UsageError(`Unknown state ${value}. Use one of ${filterStates.join(', ')}.`);
34
+ const values = filter[key] ?? [];
35
+ values.push(value);
36
+ filter[key] = values;
37
+ }
38
+ return filter;
39
+ }
40
+ /** The state shown in the STATE column: the setup state until it is ready, then the Docker state without its exited count. */
41
+ function displayedState(item) {
42
+ const status = item.status !== undefined && item.status !== 'ready'
43
+ ? item.status
44
+ : item.dockerStatus;
45
+ return status.split(' ')[0];
46
+ }
47
+ export function matchesListFilter(item, filter) {
48
+ const tests = {
49
+ name: value => item.name.includes(value),
50
+ branch: value => item.branch.includes(value),
51
+ state: value => displayedState(item) === value,
52
+ };
53
+ return filterKeys.every(key => filter[key] === undefined || filter[key].some(tests[key]));
54
+ }
55
+ export function hasListFilter(filter) {
56
+ return Object.keys(filter).length > 0;
57
+ }
@@ -1,5 +1,6 @@
1
1
  import { realpath } from 'node:fs/promises';
2
2
  import { resolve } from 'node:path';
3
+ import { projectUrls } from '../docker/orbstack.js';
3
4
  import { repositoryInfo } from '../git/repository.js';
4
5
  import { AttachedStore, StateStore } from '../state/store.js';
5
6
  import { attachedHost, createAttached, removeAttached, resetAttached } from './attached.js';
@@ -37,6 +38,16 @@ export async function resolveEnvironmentName(name, cwd) {
37
38
  return manage.resolveEnvironmentName(undefined, cwd);
38
39
  }
39
40
  export async function listEnvironments(cwd) {
41
+ const [rows, url] = await Promise.all([
42
+ listedEnvironments(cwd),
43
+ projectUrls(cwd),
44
+ ]);
45
+ return rows.map(row => ({
46
+ ...row,
47
+ url: url(row.projectName),
48
+ }));
49
+ }
50
+ async function listedEnvironments(cwd) {
40
51
  const own = await manage.listEnvironments(cwd);
41
52
  const { gitCommonDir } = await repositoryInfo(cwd);
42
53
  const states = await new AttachedStore(gitCommonDir).list();
@@ -5,6 +5,7 @@ import process from 'node:process';
5
5
  import { createInterface } from 'node:readline/promises';
6
6
  import { configPath, loadConfig } from '../config/load.js';
7
7
  import { cloneNamedVolumes, composeFilesForWorktree, docker, prepareVolumeCopy, resolveSourceVolumes, runCompose, writeVolumeOverride } from '../docker/compose.js';
8
+ import { containerAddresses, domainsLabel, orbstackNetwork, parseDomains } from '../docker/orbstack.js';
8
9
  import { git, repositoryInfo } from '../git/repository.js';
9
10
  import { AttachedStore, StateStore } from '../state/store.js';
10
11
  import { formatConfirmation } from './confirmation.js';
@@ -107,27 +108,35 @@ export async function inspectEnvironment(name, cwd) {
107
108
  }
108
109
  export function parseContainers(output) {
109
110
  return output.split('\n').filter(Boolean).map((line) => {
110
- const [name, service, state, ...status] = line.split('\t');
111
+ const [name, service, domains = '', state, ...status] = line.split('\t');
111
112
  return {
112
113
  name,
113
114
  service: service || name,
114
115
  state: state ?? '',
115
116
  status: status.join('\t'),
117
+ domains: parseDomains(domains),
116
118
  };
117
119
  }).sort((a, b) => a.service.localeCompare(b.service) || a.name.localeCompare(b.name));
118
120
  }
119
121
  export async function inspectState(state, cwd) {
120
- const containers = await docker([
121
- 'ps',
122
- '-a',
123
- '--filter',
124
- `label=com.docker.compose.project=${state.projectName}`,
125
- '--format',
126
- '{{.Names}}\t{{.Label "com.docker.compose.service"}}\t{{.State}}\t{{.Status}}',
127
- ], cwd);
122
+ const [output, network] = await Promise.all([
123
+ docker([
124
+ 'ps',
125
+ '-a',
126
+ '--filter',
127
+ `label=com.docker.compose.project=${state.projectName}`,
128
+ '--format',
129
+ `{{.Names}}\t{{.Label "com.docker.compose.service"}}\t{{.Label "${domainsLabel}"}}\t{{.State}}\t{{.Status}}`,
130
+ ], cwd),
131
+ orbstackNetwork(cwd),
132
+ ]);
133
+ const containers = parseContainers(output);
134
+ const addresses = network && containerAddresses(containers, state.projectName, network);
128
135
  return {
129
136
  ...state,
130
- containers: parseContainers(containers),
137
+ containers: addresses
138
+ ? containers.map((container, index) => ({ ...container, address: addresses[index] }))
139
+ : containers,
131
140
  };
132
141
  }
133
142
  export async function resolveEnvironmentName(name, cwd) {
@@ -73,6 +73,20 @@ export function formatEnvironmentInfo(info) {
73
73
  const { icon, variant } = containerIndicator(container);
74
74
  return `${colorize(icon, variant)} ${names[index].padEnd(nameWidth)} ${container.status}`;
75
75
  });
76
+ const addresses = info.containers.flatMap((container, index) => container.address === undefined
77
+ ? []
78
+ : [
79
+ {
80
+ name: names[index],
81
+ values: container.address.urls.length
82
+ ? container.address.urls
83
+ : [container.address.hostname],
84
+ },
85
+ ]);
86
+ const addressWidth = Math.max(0, ...addresses.map(({ name }) => name.length));
87
+ const domains = addresses.flatMap(({ name, values }) => values.map((value, index) => `${(index === 0
88
+ ? name
89
+ : '').padEnd(addressWidth)} ${value}`));
76
90
  const volumes = Object.entries(info.volumes);
77
91
  const volumeWidth = Math.max(0, ...volumes.map(([logical]) => logical.length));
78
92
  return [
@@ -80,6 +94,12 @@ export function formatEnvironmentInfo(info) {
80
94
  '',
81
95
  ...section('Services', services),
82
96
  '',
97
+ ...(domains.length
98
+ ? [
99
+ ...section('Domains', domains),
100
+ '',
101
+ ]
102
+ : []),
83
103
  ...section('Volumes', volumes.map(([logical, volume]) => `${logical.padEnd(volumeWidth)} → ${volume}`)),
84
104
  ].join('\n');
85
105
  }
@@ -6,9 +6,11 @@ const states = {
6
6
  const unknownState = { icon: '!', variant: 'error' };
7
7
  /**
8
8
  * Formats managed worktrees as an aligned table. Cells are padded before they
9
- * are colored so escape sequences never shift the columns.
9
+ * are colored so escape sequences never shift the columns. The URL column only
10
+ * appears when at least one environment has a URL.
10
11
  */
11
12
  export function formatEnvironmentTable(items) {
13
+ const withUrls = items.some(item => item.url !== undefined);
12
14
  const rows = items.map((item) => {
13
15
  const status = item.status !== undefined && item.status !== 'ready'
14
16
  ? item.status
@@ -22,11 +24,22 @@ export function formatEnvironmentTable(items) {
22
24
  item.branch || '(detached)',
23
25
  `${state.icon} ${status}`,
24
26
  item.projectName,
27
+ ...(withUrls
28
+ ? [item.url ?? '-']
29
+ : []),
25
30
  ],
26
31
  variant: state.variant,
27
32
  };
28
33
  });
29
- const header = ['NAME', 'BRANCH', 'STATE', 'PROJECT'];
34
+ const header = [
35
+ 'NAME',
36
+ 'BRANCH',
37
+ 'STATE',
38
+ 'PROJECT',
39
+ ...(withUrls
40
+ ? ['URL']
41
+ : []),
42
+ ];
30
43
  const widths = header.map((title, column) => Math.max(title.length, ...rows.map(row => row.cells[column].length)));
31
44
  const line = (cells, variant) => cells.map((cell, column) => {
32
45
  const padded = column === cells.length - 1
@@ -11,6 +11,7 @@ export function environmentListJson(items) {
11
11
  status: missing(item.status),
12
12
  dockerStatus: item.dockerStatus,
13
13
  projectName: missing(item.projectName),
14
+ url: item.url ?? null,
14
15
  }));
15
16
  }
16
17
  export function environmentInfoJson(info) {
@@ -27,11 +28,13 @@ export function environmentInfoJson(info) {
27
28
  name: info.host.name,
28
29
  path: missing(info.host.path),
29
30
  },
30
- containers: info.containers.map(({ name, service, state, status }) => ({
31
+ containers: info.containers.map(({ name, service, state, status, address }) => ({
31
32
  name,
32
33
  service,
33
34
  state,
34
35
  status,
36
+ hostname: address?.hostname ?? null,
37
+ urls: address?.urls ?? [],
35
38
  })),
36
39
  volumes: info.volumes,
37
40
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joberthel/worktree",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
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",