@solaqua/gji 0.12.4 → 0.13.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 +12 -0
- package/dist/application/worktree/catalog.d.ts +31 -0
- package/dist/application/worktree/catalog.js +88 -0
- package/dist/application/worktree/context-card.d.ts +14 -0
- package/dist/application/worktree/context-card.js +12 -0
- package/dist/{go-resolver.d.ts → application/worktree/go-resolution.d.ts} +12 -4
- package/dist/{go-resolver.js → application/worktree/go-resolution.js} +46 -44
- package/dist/application/worktree/read-models.d.ts +31 -0
- package/dist/application/worktree/sources.d.ts +7 -0
- package/dist/{worktree-sources.js → application/worktree/sources.js} +12 -24
- package/dist/{back.d.ts → cli/commands/back.d.ts} +3 -1
- package/dist/{back.js → cli/commands/back.js} +8 -6
- package/dist/{clean.d.ts → cli/commands/clean.d.ts} +4 -2
- package/dist/{clean.js → cli/commands/clean.js} +32 -24
- package/dist/{completion.js → cli/commands/completion.js} +2 -2
- package/dist/{config-command.d.ts → cli/commands/config-command.d.ts} +2 -0
- package/dist/{config-command.js → cli/commands/config-command.js} +7 -5
- package/dist/{doctor.d.ts → cli/commands/doctor.d.ts} +2 -0
- package/dist/{doctor.js → cli/commands/doctor.js} +23 -25
- package/dist/{done.d.ts → cli/commands/done.d.ts} +2 -0
- package/dist/{done.js → cli/commands/done.js} +26 -23
- package/dist/{go.d.ts → cli/commands/go.d.ts} +6 -1
- package/dist/{go.js → cli/commands/go.js} +57 -41
- package/dist/{history-command.d.ts → cli/commands/history-command.d.ts} +2 -0
- package/dist/{history-command.js → cli/commands/history-command.js} +3 -1
- package/dist/{hub.d.ts → cli/commands/hub.d.ts} +7 -3
- package/dist/{hub.js → cli/commands/hub.js} +23 -33
- package/dist/{init.d.ts → cli/commands/init.d.ts} +3 -1
- package/dist/{init.js → cli/commands/init.js} +37 -34
- package/dist/{ls.d.ts → cli/commands/ls.d.ts} +4 -2
- package/dist/{ls.js → cli/commands/ls.js} +8 -5
- package/dist/{new.d.ts → cli/commands/new.d.ts} +6 -2
- package/dist/{new.js → cli/commands/new.js} +237 -109
- package/dist/{open.d.ts → cli/commands/open.d.ts} +4 -2
- package/dist/{open.js → cli/commands/open.js} +19 -12
- package/dist/{pr-open.d.ts → cli/commands/pr-open.d.ts} +4 -2
- package/dist/{pr-open.js → cli/commands/pr-open.js} +20 -18
- package/dist/{pr.d.ts → cli/commands/pr.d.ts} +5 -3
- package/dist/{pr.js → cli/commands/pr.js} +34 -41
- package/dist/{remove.d.ts → cli/commands/remove.d.ts} +4 -2
- package/dist/{remove.js → cli/commands/remove.js} +23 -17
- package/dist/{root.d.ts → cli/commands/root.d.ts} +2 -0
- package/dist/{root.js → cli/commands/root.js} +4 -2
- package/dist/{run-hook.d.ts → cli/commands/run-hook.d.ts} +2 -0
- package/dist/{run-hook.js → cli/commands/run-hook.js} +7 -4
- package/dist/{status.d.ts → cli/commands/status.d.ts} +2 -0
- package/dist/{status.js → cli/commands/status.js} +10 -7
- package/dist/{sync-files-command.d.ts → cli/commands/sync-files-command.d.ts} +2 -0
- package/dist/{sync-files-command.js → cli/commands/sync-files-command.js} +11 -9
- package/dist/{sync.d.ts → cli/commands/sync.d.ts} +2 -0
- package/dist/{sync.js → cli/commands/sync.js} +7 -4
- package/dist/{task-command.d.ts → cli/commands/task-command.d.ts} +2 -0
- package/dist/{task-command.js → cli/commands/task-command.js} +4 -2
- package/dist/{undo.d.ts → cli/commands/undo.d.ts} +8 -6
- package/dist/{undo.js → cli/commands/undo.js} +44 -34
- package/dist/{warp.d.ts → cli/commands/warp.d.ts} +5 -2
- package/dist/{warp.js → cli/commands/warp.js} +20 -10
- package/dist/cli/dependencies.d.ts +114 -0
- package/dist/cli/dependencies.js +118 -0
- package/dist/{cli.d.ts → cli/program.d.ts} +4 -2
- package/dist/{cli.js → cli/program.js} +108 -124
- package/dist/domain/repository/context.d.ts +6 -0
- package/dist/domain/repository/context.js +1 -0
- package/dist/domain/repository/registry.d.ts +5 -0
- package/dist/domain/repository/registry.js +1 -0
- package/dist/domain/shared/concurrency.d.ts +1 -0
- package/dist/domain/shared/concurrency.js +15 -0
- package/dist/domain/worktree/matching.d.ts +4 -0
- package/dist/domain/worktree/matching.js +79 -0
- package/dist/domain/worktree/policy.d.ts +2 -0
- package/dist/domain/worktree/policy.js +58 -0
- package/dist/domain/worktree/pr-reference.d.ts +1 -0
- package/dist/domain/worktree/pr-reference.js +9 -0
- package/dist/{worktree-source.d.ts → domain/worktree/source.d.ts} +1 -1
- package/dist/domain/worktree/source.js +1 -0
- package/dist/domain/worktree/types.d.ts +5 -0
- package/dist/domain/worktree/types.js +1 -0
- package/dist/gji-bundle.mjs +7100 -6265
- package/dist/index.js +3 -3
- package/dist/{dependency-bootstrap.d.ts → infrastructure/bootstrap/dependency-bootstrap.d.ts} +3 -30
- package/dist/{dependency-bootstrap.js → infrastructure/bootstrap/dependency-bootstrap.js} +4 -4
- package/dist/infrastructure/git/health.d.ts +9 -0
- package/dist/infrastructure/git/health.js +44 -0
- package/dist/infrastructure/git/refs.d.ts +6 -0
- package/dist/{git.js → infrastructure/git/refs.js} +1 -51
- package/dist/infrastructure/git/runner.d.ts +2 -0
- package/dist/infrastructure/git/runner.js +16 -0
- package/dist/{editor.d.ts → infrastructure/integrations/editor.d.ts} +2 -6
- package/dist/{pull-requests.d.ts → infrastructure/integrations/pull-requests.d.ts} +3 -11
- package/dist/{config.d.ts → infrastructure/persistence/config.d.ts} +3 -17
- package/dist/{config.js → infrastructure/persistence/config.js} +2 -17
- package/dist/{history.d.ts → infrastructure/persistence/history.d.ts} +2 -5
- package/dist/{task.js → infrastructure/persistence/task.js} +1 -1
- package/dist/infrastructure/process/command-runner.d.ts +3 -0
- package/dist/{hooks.d.ts → infrastructure/process/hooks.d.ts} +2 -12
- package/dist/infrastructure/repository/adapters.d.ts +7 -0
- package/dist/infrastructure/repository/adapters.js +23 -0
- package/dist/infrastructure/repository/context.d.ts +3 -0
- package/dist/infrastructure/repository/context.js +20 -0
- package/dist/infrastructure/repository/refs.d.ts +3 -0
- package/dist/infrastructure/repository/refs.js +37 -0
- package/dist/{repo-registry.d.ts → infrastructure/repository/registry.d.ts} +1 -5
- package/dist/{repo-registry.js → infrastructure/repository/registry.js} +1 -1
- package/dist/infrastructure/repository/worktrees.d.ts +2 -0
- package/dist/infrastructure/repository/worktrees.js +48 -0
- package/dist/{uv-validation.d.ts → infrastructure/validation/uv.d.ts} +1 -1
- package/dist/{uv-validation.js → infrastructure/validation/uv.js} +1 -1
- package/dist/infrastructure/worktree/bootstrap.d.ts +3 -0
- package/dist/{worktree-bootstrap.js → infrastructure/worktree/bootstrap.js} +7 -10
- package/dist/infrastructure/worktree/info.d.ts +6 -0
- package/dist/infrastructure/worktree/info.js +61 -0
- package/dist/{worktree-management.d.ts → infrastructure/worktree/lifecycle.d.ts} +0 -6
- package/dist/{worktree-management.js → infrastructure/worktree/lifecycle.js} +1 -9
- package/dist/ports/bootstrap.d.ts +61 -0
- package/dist/ports/bootstrap.js +1 -0
- package/dist/ports/config.d.ts +21 -0
- package/dist/ports/config.js +17 -0
- package/dist/ports/editor.d.ts +6 -0
- package/dist/ports/editor.js +1 -0
- package/dist/ports/git.d.ts +8 -0
- package/dist/ports/git.js +1 -0
- package/dist/ports/history.d.ts +5 -0
- package/dist/ports/history.js +1 -0
- package/dist/ports/hooks.d.ts +12 -0
- package/dist/ports/hooks.js +1 -0
- package/dist/{command-runner.d.ts → ports/process.d.ts} +0 -1
- package/dist/ports/process.js +1 -0
- package/dist/ports/pull-requests.d.ts +11 -0
- package/dist/ports/pull-requests.js +1 -0
- package/dist/ports/repository.d.ts +17 -0
- package/dist/ports/repository.js +1 -0
- package/dist/{bootstrap-output.d.ts → presentation/bootstrap/output.d.ts} +1 -1
- package/dist/presentation/bootstrap/preview.d.ts +2 -0
- package/dist/{bootstrap-preview.js → presentation/bootstrap/preview.js} +0 -4
- package/dist/{shell-completion.js → presentation/shell/completion.js} +5 -4
- package/dist/presentation/terminal/context-card.d.ts +2 -0
- package/dist/{context-card.js → presentation/terminal/context-card.js} +3 -12
- package/dist/presentation/worktree/format.d.ts +4 -0
- package/dist/presentation/worktree/format.js +41 -0
- package/dist/{worktree-picker.d.ts → presentation/worktree/picker.d.ts} +7 -11
- package/dist/{worktree-picker.js → presentation/worktree/picker.js} +36 -191
- package/man/man1/gji-back.1 +1 -1
- package/man/man1/gji-clean.1 +1 -1
- package/man/man1/gji-completion.1 +1 -1
- package/man/man1/gji-config.1 +1 -1
- package/man/man1/gji-doctor.1 +1 -1
- package/man/man1/gji-done.1 +1 -1
- package/man/man1/gji-go.1 +1 -1
- package/man/man1/gji-history.1 +1 -1
- package/man/man1/gji-init.1 +1 -1
- package/man/man1/gji-ls.1 +1 -1
- package/man/man1/gji-new.1 +6 -3
- package/man/man1/gji-open.1 +1 -1
- package/man/man1/gji-pr.1 +1 -1
- package/man/man1/gji-remove.1 +1 -1
- package/man/man1/gji-root.1 +1 -1
- package/man/man1/gji-run-hook.1 +1 -1
- package/man/man1/gji-status.1 +1 -1
- package/man/man1/gji-sync-files.1 +1 -1
- package/man/man1/gji-sync.1 +1 -1
- package/man/man1/gji-task.1 +1 -1
- package/man/man1/gji-undo.1 +1 -1
- package/man/man1/gji-warp.1 +1 -1
- package/man/man1/gji.1 +2 -2
- package/package.json +1 -1
- package/dist/bootstrap-preview.d.ts +0 -9
- package/dist/context-card.d.ts +0 -1
- package/dist/format-bytes.d.ts +0 -1
- package/dist/format-bytes.js +0 -14
- package/dist/git.d.ts +0 -18
- package/dist/repo.d.ts +0 -20
- package/dist/repo.js +0 -161
- package/dist/worktree-bootstrap.d.ts +0 -24
- package/dist/worktree-info.d.ts +0 -37
- package/dist/worktree-info.js +0 -123
- package/dist/worktree-sources.d.ts +0 -4
- /package/dist/{worktree-source.js → application/worktree/read-models.js} +0 -0
- /package/dist/{completion.d.ts → cli/commands/completion.d.ts} +0 -0
- /package/dist/{headless.d.ts → cli/runtime/headless.d.ts} +0 -0
- /package/dist/{headless.js → cli/runtime/headless.js} +0 -0
- /package/dist/{paths.d.ts → domain/shared/paths.d.ts} +0 -0
- /package/dist/{paths.js → domain/shared/paths.js} +0 -0
- /package/dist/{file-sync.d.ts → infrastructure/filesystem/file-sync.d.ts} +0 -0
- /package/dist/{file-sync.js → infrastructure/filesystem/file-sync.js} +0 -0
- /package/dist/{fs-utils.d.ts → infrastructure/filesystem/fs-utils.d.ts} +0 -0
- /package/dist/{fs-utils.js → infrastructure/filesystem/fs-utils.js} +0 -0
- /package/dist/{safe-destination.d.ts → infrastructure/filesystem/safe-destination.d.ts} +0 -0
- /package/dist/{safe-destination.js → infrastructure/filesystem/safe-destination.js} +0 -0
- /package/dist/{browser.d.ts → infrastructure/integrations/browser.d.ts} +0 -0
- /package/dist/{browser.js → infrastructure/integrations/browser.js} +0 -0
- /package/dist/{editor.js → infrastructure/integrations/editor.js} +0 -0
- /package/dist/{pull-requests.js → infrastructure/integrations/pull-requests.js} +0 -0
- /package/dist/{history.js → infrastructure/persistence/history.js} +0 -0
- /package/dist/{slots.d.ts → infrastructure/persistence/slots.d.ts} +0 -0
- /package/dist/{slots.js → infrastructure/persistence/slots.js} +0 -0
- /package/dist/{task.d.ts → infrastructure/persistence/task.d.ts} +0 -0
- /package/dist/{command-runner.js → infrastructure/process/command-runner.js} +0 -0
- /package/dist/{hooks.js → infrastructure/process/hooks.js} +0 -0
- /package/dist/{bootstrap-output.js → presentation/bootstrap/output.js} +0 -0
- /package/dist/{conflict.d.ts → presentation/prompts/path-conflict.d.ts} +0 -0
- /package/dist/{conflict.js → presentation/prompts/path-conflict.js} +0 -0
- /package/dist/{shell-completion.d.ts → presentation/shell/completion.d.ts} +0 -0
- /package/dist/{shell-handoff.d.ts → presentation/shell/handoff.d.ts} +0 -0
- /package/dist/{shell-handoff.js → presentation/shell/handoff.js} +0 -0
- /package/dist/{shell-setup.d.ts → presentation/shell/setup.d.ts} +0 -0
- /package/dist/{shell-setup.js → presentation/shell/setup.js} +0 -0
- /package/dist/{shell.d.ts → presentation/shell/shell.d.ts} +0 -0
- /package/dist/{shell.js → presentation/shell/shell.js} +0 -0
- /package/dist/{navigation-output.d.ts → presentation/terminal/navigation.d.ts} +0 -0
- /package/dist/{navigation-output.js → presentation/terminal/navigation.js} +0 -0
- /package/dist/{terminal-text.d.ts → presentation/terminal/text.d.ts} +0 -0
- /package/dist/{terminal-text.js → presentation/terminal/text.js} +0 -0
- /package/dist/{worktree-prompts.d.ts → presentation/worktree/prompts.d.ts} +0 -0
- /package/dist/{worktree-prompts.js → presentation/worktree/prompts.js} +0 -0
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { Command } from "commander";
|
|
3
2
|
import updateNotifier from "update-notifier";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { runHistoryCommand } from "./history-command.js";
|
|
13
|
-
import { runHubCommand } from "./hub.js";
|
|
14
|
-
import { runInitCommand } from "./init.js";
|
|
15
|
-
import { runLsCommand } from "./ls.js";
|
|
16
|
-
import { runNewCommand } from "./new.js";
|
|
17
|
-
import { runOpenCommand } from "./open.js";
|
|
18
|
-
import { runPrCommand } from "./pr.js";
|
|
19
|
-
import { createPrOpenCommand, } from "./pr-open.js";
|
|
20
|
-
import { runRemoveCommand } from "./remove.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
3
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
4
|
+
import { runBackCommand } from "./commands/back.js";
|
|
5
|
+
import { runCleanCommand } from "./commands/clean.js";
|
|
6
|
+
import { runCompletionCommand } from "./commands/completion.js";
|
|
7
|
+
import { runConfigCommand } from "./commands/config-command.js";
|
|
8
|
+
import { runDoctorCommand } from "./commands/doctor.js";
|
|
9
|
+
import { runDoneCommand } from "./commands/done.js";
|
|
10
|
+
import { runGoCommand } from "./commands/go.js";
|
|
11
|
+
import { runHistoryCommand } from "./commands/history-command.js";
|
|
12
|
+
import { runHubCommand } from "./commands/hub.js";
|
|
13
|
+
import { runInitCommand } from "./commands/init.js";
|
|
14
|
+
import { runLsCommand } from "./commands/ls.js";
|
|
15
|
+
import { runNewCommand } from "./commands/new.js";
|
|
16
|
+
import { runOpenCommand } from "./commands/open.js";
|
|
17
|
+
import { runPrCommand } from "./commands/pr.js";
|
|
18
|
+
import { createPrOpenCommand, } from "./commands/pr-open.js";
|
|
19
|
+
import { runRemoveCommand } from "./commands/remove.js";
|
|
20
|
+
import { runRootCommand } from "./commands/root.js";
|
|
21
|
+
import { runHookCommand } from "./commands/run-hook.js";
|
|
22
|
+
import { runStatusCommand } from "./commands/status.js";
|
|
23
|
+
import { runSyncCommand } from "./commands/sync.js";
|
|
24
|
+
import { runSyncFilesCommand } from "./commands/sync-files-command.js";
|
|
25
|
+
import { runTaskCommand } from "./commands/task-command.js";
|
|
26
|
+
import { runUndoCommand } from "./commands/undo.js";
|
|
27
|
+
import { runWarpCommand } from "./commands/warp.js";
|
|
28
|
+
import { createCliDependencies } from "./dependencies.js";
|
|
29
|
+
import { isHeadless } from "./runtime/headless.js";
|
|
31
30
|
export function createProgram() {
|
|
32
31
|
const program = new Command();
|
|
33
32
|
const packageMetadata = readPackageMetadata();
|
|
@@ -40,14 +39,13 @@ export function createProgram() {
|
|
|
40
39
|
registerCommands(program);
|
|
41
40
|
program.addHelpText("after", "\nCommon workflows:\n" +
|
|
42
41
|
" gji new <branch> create a worktree\n" +
|
|
42
|
+
" gji new --branch-only <branch> reuse the current worktree\n" +
|
|
43
43
|
" gji go <branch> navigate to a worktree\n" +
|
|
44
44
|
" gji go choose; press Tab for all repositories\n" +
|
|
45
45
|
" gji go - return to the previous worktree\n");
|
|
46
46
|
return program;
|
|
47
47
|
}
|
|
48
48
|
function readPackageMetadata() {
|
|
49
|
-
const require = createRequire(import.meta.url);
|
|
50
|
-
const packageJson = require("../package.json");
|
|
51
49
|
return {
|
|
52
50
|
name: typeof packageJson.name === "string" ? packageJson.name : "gji",
|
|
53
51
|
version: typeof packageJson.version === "string" ? packageJson.version : "0.0.0",
|
|
@@ -58,8 +56,9 @@ export async function runCli(argv, options = {}) {
|
|
|
58
56
|
const cwd = options.cwd ?? process.cwd();
|
|
59
57
|
const stdout = options.stdout ?? (() => undefined);
|
|
60
58
|
const stderr = options.stderr ?? (() => undefined);
|
|
59
|
+
const dependencies = options.dependencies ?? createCliDependencies();
|
|
61
60
|
if (shouldRegisterCurrentRepo(argv) || isHubInvocation(argv)) {
|
|
62
|
-
await maybeRegisterCurrentRepo(cwd);
|
|
61
|
+
await maybeRegisterCurrentRepo(cwd, dependencies);
|
|
63
62
|
}
|
|
64
63
|
const program = createProgram();
|
|
65
64
|
program.configureOutput({
|
|
@@ -75,12 +74,14 @@ export async function runCli(argv, options = {}) {
|
|
|
75
74
|
now: options.now,
|
|
76
75
|
stderr,
|
|
77
76
|
stdout,
|
|
77
|
+
runtime: dependencies,
|
|
78
78
|
}, options.hubDependencies);
|
|
79
79
|
return { exitCode };
|
|
80
80
|
}
|
|
81
81
|
try {
|
|
82
82
|
attachCommandActions(program, {
|
|
83
83
|
cwd,
|
|
84
|
+
dependencies,
|
|
84
85
|
prOpenDependencies: options.prOpenDependencies,
|
|
85
86
|
stderr,
|
|
86
87
|
stdout,
|
|
@@ -143,10 +144,10 @@ function shouldRegisterCurrentRepo(argv) {
|
|
|
143
144
|
function isHubInvocation(argv) {
|
|
144
145
|
return argv.length === 0 || (argv.length === 1 && argv[0] === "--json");
|
|
145
146
|
}
|
|
146
|
-
async function maybeRegisterCurrentRepo(cwd) {
|
|
147
|
+
async function maybeRegisterCurrentRepo(cwd, dependencies) {
|
|
147
148
|
try {
|
|
148
|
-
const { repoRoot } = await detectRepository(cwd);
|
|
149
|
-
await registerRepo(repoRoot);
|
|
149
|
+
const { repoRoot } = await dependencies.repositoryContext.detectRepository(cwd);
|
|
150
|
+
await dependencies.registry.registerRepo(repoRoot);
|
|
150
151
|
}
|
|
151
152
|
catch {
|
|
152
153
|
// Registration is best effort; command behaviour should not depend on it.
|
|
@@ -155,7 +156,8 @@ async function maybeRegisterCurrentRepo(cwd) {
|
|
|
155
156
|
function registerCommands(program) {
|
|
156
157
|
program
|
|
157
158
|
.command("new [branch]")
|
|
158
|
-
.description("create a
|
|
159
|
+
.description("create a branch with an optional linked worktree")
|
|
160
|
+
.option("--branch-only", "update the default branch and create the new branch in the current worktree")
|
|
159
161
|
.option("-f, --force", "remove and recreate the worktree if the target path already exists")
|
|
160
162
|
.option("--detached", "create a detached worktree without a branch")
|
|
161
163
|
.option("--from-current", "base the new branch on the current worktree instead of the main worktree (cannot be combined with --detached)")
|
|
@@ -335,12 +337,11 @@ function registerCommands(program) {
|
|
|
335
337
|
.action(notImplemented("config unset"));
|
|
336
338
|
}
|
|
337
339
|
function attachCommandActions(program, options) {
|
|
338
|
-
program.
|
|
339
|
-
.find((command) => command.name() === "new")
|
|
340
|
-
?.action(async (branch, commandOptions) => {
|
|
340
|
+
requireCommand(program, "new").action(async (branch, commandOptions) => {
|
|
341
341
|
const exitCode = await runNewCommand({
|
|
342
342
|
...options,
|
|
343
343
|
branch,
|
|
344
|
+
branchOnly: commandOptions.branchOnly,
|
|
344
345
|
copy: commandOptions.copy,
|
|
345
346
|
detached: commandOptions.detached,
|
|
346
347
|
dryRun: commandOptions.dryRun,
|
|
@@ -353,73 +354,68 @@ function attachCommandActions(program, options) {
|
|
|
353
354
|
open: commandOptions.open,
|
|
354
355
|
take: commandOptions.take,
|
|
355
356
|
task: commandOptions.task,
|
|
357
|
+
runtime: options.dependencies,
|
|
356
358
|
});
|
|
357
359
|
if (exitCode !== 0) {
|
|
358
360
|
throw commanderExit(exitCode);
|
|
359
361
|
}
|
|
360
362
|
});
|
|
361
|
-
program.
|
|
362
|
-
.find((command) => command.name() === "done")
|
|
363
|
-
?.action(async (branch, commandOptions) => {
|
|
363
|
+
requireCommand(program, "done").action(async (branch, commandOptions) => {
|
|
364
364
|
const exitCode = await runDoneCommand({
|
|
365
365
|
branch,
|
|
366
366
|
cwd: options.cwd,
|
|
367
367
|
force: commandOptions.force,
|
|
368
368
|
json: commandOptions.json,
|
|
369
369
|
keepBranch: commandOptions.keepBranch,
|
|
370
|
+
runtime: options.dependencies,
|
|
370
371
|
stderr: options.stderr,
|
|
371
372
|
stdout: options.stdout,
|
|
372
373
|
});
|
|
373
374
|
if (exitCode !== 0)
|
|
374
375
|
throw commanderExit(exitCode);
|
|
375
376
|
});
|
|
376
|
-
program.
|
|
377
|
-
.find((command) => command.name() === "undo")
|
|
378
|
-
?.action(async (id, commandOptions) => {
|
|
377
|
+
requireCommand(program, "undo").action(async (id, commandOptions) => {
|
|
379
378
|
const exitCode = await runUndoCommand({
|
|
380
379
|
cwd: options.cwd,
|
|
381
380
|
id,
|
|
382
381
|
json: commandOptions.json,
|
|
383
382
|
list: commandOptions.list,
|
|
383
|
+
runtime: options.dependencies,
|
|
384
384
|
stderr: options.stderr,
|
|
385
385
|
stdout: options.stdout,
|
|
386
386
|
});
|
|
387
387
|
if (exitCode !== 0)
|
|
388
388
|
throw commanderExit(exitCode);
|
|
389
389
|
});
|
|
390
|
-
program.
|
|
391
|
-
.find((command) => command.name() === "init")
|
|
392
|
-
?.action(async (shell, commandOptions) => {
|
|
390
|
+
requireCommand(program, "init").action(async (shell, commandOptions) => {
|
|
393
391
|
const exitCode = await runInitCommand({
|
|
394
392
|
cwd: options.cwd,
|
|
395
393
|
json: commandOptions.json,
|
|
396
394
|
shell,
|
|
397
395
|
stderr: options.stderr,
|
|
398
396
|
stdout: options.stdout,
|
|
397
|
+
runtime: options.dependencies,
|
|
399
398
|
write: commandOptions.write,
|
|
400
399
|
});
|
|
401
400
|
if (exitCode !== 0) {
|
|
402
401
|
throw commanderExit(exitCode);
|
|
403
402
|
}
|
|
404
403
|
});
|
|
405
|
-
program.
|
|
406
|
-
.find((command) => command.name() === "doctor")
|
|
407
|
-
?.action(async (commandOptions) => {
|
|
404
|
+
requireCommand(program, "doctor").action(async (commandOptions) => {
|
|
408
405
|
const exitCode = await runDoctorCommand({
|
|
409
406
|
cwd: options.cwd,
|
|
410
407
|
fix: commandOptions.fix,
|
|
411
408
|
json: commandOptions.json,
|
|
412
409
|
stderr: options.stderr,
|
|
413
410
|
stdout: options.stdout,
|
|
411
|
+
runtime: options.dependencies,
|
|
414
412
|
yes: commandOptions.yes,
|
|
415
413
|
});
|
|
416
414
|
if (exitCode !== 0) {
|
|
417
415
|
throw commanderExit(exitCode);
|
|
418
416
|
}
|
|
419
417
|
});
|
|
420
|
-
program.
|
|
421
|
-
.find((command) => command.name() === "completion")
|
|
422
|
-
?.action(async (shell) => {
|
|
418
|
+
requireCommand(program, "completion").action(async (shell) => {
|
|
423
419
|
const exitCode = await runCompletionCommand({
|
|
424
420
|
shell,
|
|
425
421
|
stderr: options.stderr,
|
|
@@ -429,9 +425,7 @@ function attachCommandActions(program, options) {
|
|
|
429
425
|
throw commanderExit(exitCode);
|
|
430
426
|
}
|
|
431
427
|
});
|
|
432
|
-
program.
|
|
433
|
-
.find((command) => command.name() === "pr")
|
|
434
|
-
?.action(async (number, commandOptions) => {
|
|
428
|
+
requireCommand(program, "pr").action(async (number, commandOptions) => {
|
|
435
429
|
const exitCode = await runPrCommand({
|
|
436
430
|
cwd: options.cwd,
|
|
437
431
|
dryRun: commandOptions.dryRun,
|
|
@@ -440,30 +434,28 @@ function attachCommandActions(program, options) {
|
|
|
440
434
|
number,
|
|
441
435
|
stderr: options.stderr,
|
|
442
436
|
stdout: options.stdout,
|
|
437
|
+
runtime: options.dependencies,
|
|
443
438
|
});
|
|
444
439
|
if (exitCode !== 0) {
|
|
445
440
|
throw commanderExit(exitCode);
|
|
446
441
|
}
|
|
447
442
|
});
|
|
448
|
-
const prOpenCommand = program
|
|
449
|
-
.find((command) => command.name() === "pr")
|
|
450
|
-
?.commands.find((command) => command.name() === "open");
|
|
443
|
+
const prOpenCommand = requireCommand(requireCommand(program, "pr"), "open");
|
|
451
444
|
const runPrOpenCommand = createPrOpenCommand(options.prOpenDependencies);
|
|
452
|
-
prOpenCommand
|
|
445
|
+
prOpenCommand.action(async (target, commandOptions) => {
|
|
453
446
|
const exitCode = await runPrOpenCommand({
|
|
454
447
|
cwd: options.cwd,
|
|
455
448
|
stderr: options.stderr,
|
|
456
449
|
stdout: options.stdout,
|
|
457
450
|
select: commandOptions.select,
|
|
458
451
|
target,
|
|
452
|
+
runtime: options.dependencies,
|
|
459
453
|
});
|
|
460
454
|
if (exitCode !== 0) {
|
|
461
455
|
throw commanderExit(exitCode);
|
|
462
456
|
}
|
|
463
457
|
});
|
|
464
|
-
program.
|
|
465
|
-
.find((command) => command.name() === "back")
|
|
466
|
-
?.action(async (n, commandOptions) => {
|
|
458
|
+
requireCommand(program, "back").action(async (n, commandOptions) => {
|
|
467
459
|
if (n !== undefined && !/^\d+$/.test(n)) {
|
|
468
460
|
options.stderr(`gji back: invalid step count: ${n}\n`);
|
|
469
461
|
throw commanderExit(1);
|
|
@@ -473,6 +465,7 @@ function attachCommandActions(program, options) {
|
|
|
473
465
|
cwd: options.cwd,
|
|
474
466
|
n: steps,
|
|
475
467
|
print: commandOptions.print,
|
|
468
|
+
runtime: options.dependencies,
|
|
476
469
|
stderr: options.stderr,
|
|
477
470
|
stdout: options.stdout,
|
|
478
471
|
});
|
|
@@ -480,27 +473,25 @@ function attachCommandActions(program, options) {
|
|
|
480
473
|
throw commanderExit(exitCode);
|
|
481
474
|
}
|
|
482
475
|
});
|
|
483
|
-
program.
|
|
484
|
-
.find((command) => command.name() === "history")
|
|
485
|
-
?.action(async (commandOptions) => {
|
|
476
|
+
requireCommand(program, "history").action(async (commandOptions) => {
|
|
486
477
|
const exitCode = await runHistoryCommand({
|
|
487
478
|
cwd: options.cwd,
|
|
488
479
|
json: commandOptions.json,
|
|
480
|
+
runtime: options.dependencies,
|
|
489
481
|
stdout: options.stdout,
|
|
490
482
|
});
|
|
491
483
|
if (exitCode !== 0) {
|
|
492
484
|
throw commanderExit(exitCode);
|
|
493
485
|
}
|
|
494
486
|
});
|
|
495
|
-
program.
|
|
496
|
-
.find((command) => command.name() === "open")
|
|
497
|
-
?.action(async (branch, commandOptions) => {
|
|
487
|
+
requireCommand(program, "open").action(async (branch, commandOptions) => {
|
|
498
488
|
const exitCode = await runOpenCommand({
|
|
499
489
|
branch,
|
|
500
490
|
cwd: options.cwd,
|
|
501
491
|
editor: commandOptions.editor,
|
|
502
492
|
save: commandOptions.save,
|
|
503
493
|
select: commandOptions.select,
|
|
494
|
+
runtime: options.dependencies,
|
|
504
495
|
stderr: options.stderr,
|
|
505
496
|
stdout: options.stdout,
|
|
506
497
|
workspace: commandOptions.workspace,
|
|
@@ -509,9 +500,7 @@ function attachCommandActions(program, options) {
|
|
|
509
500
|
throw commanderExit(exitCode);
|
|
510
501
|
}
|
|
511
502
|
});
|
|
512
|
-
program.
|
|
513
|
-
.find((command) => command.name() === "go")
|
|
514
|
-
?.action(async (branch, commandOptions) => {
|
|
503
|
+
requireCommand(program, "go").action(async (branch, commandOptions) => {
|
|
515
504
|
const exitCode = await runGoCommand({
|
|
516
505
|
branch,
|
|
517
506
|
cwd: options.cwd,
|
|
@@ -521,56 +510,53 @@ function attachCommandActions(program, options) {
|
|
|
521
510
|
root: commandOptions.root,
|
|
522
511
|
stderr: options.stderr,
|
|
523
512
|
stdout: options.stdout,
|
|
513
|
+
runtime: options.dependencies,
|
|
524
514
|
});
|
|
525
515
|
if (exitCode !== 0) {
|
|
526
516
|
throw commanderExit(exitCode);
|
|
527
517
|
}
|
|
528
518
|
});
|
|
529
|
-
program.
|
|
530
|
-
.find((command) => command.name() === "root")
|
|
531
|
-
?.action(async (commandOptions) => {
|
|
519
|
+
requireCommand(program, "root").action(async (commandOptions) => {
|
|
532
520
|
const exitCode = await runRootCommand({
|
|
533
521
|
cwd: options.cwd,
|
|
534
522
|
print: commandOptions.print,
|
|
523
|
+
runtime: options.dependencies,
|
|
535
524
|
stdout: options.stdout,
|
|
536
525
|
});
|
|
537
526
|
if (exitCode !== 0) {
|
|
538
527
|
throw commanderExit(exitCode);
|
|
539
528
|
}
|
|
540
529
|
});
|
|
541
|
-
program.
|
|
542
|
-
.find((command) => command.name() === "status")
|
|
543
|
-
?.action(async (commandOptions) => {
|
|
530
|
+
requireCommand(program, "status").action(async (commandOptions) => {
|
|
544
531
|
const exitCode = await runStatusCommand({
|
|
545
532
|
cwd: options.cwd,
|
|
546
533
|
json: commandOptions.json,
|
|
534
|
+
runtime: options.dependencies,
|
|
547
535
|
stdout: options.stdout,
|
|
548
536
|
});
|
|
549
537
|
if (exitCode !== 0) {
|
|
550
538
|
throw commanderExit(exitCode);
|
|
551
539
|
}
|
|
552
540
|
});
|
|
553
|
-
program.
|
|
554
|
-
.find((command) => command.name() === "task")
|
|
555
|
-
?.action(async (task, commandOptions) => {
|
|
541
|
+
requireCommand(program, "task").action(async (task, commandOptions) => {
|
|
556
542
|
const exitCode = await runTaskCommand({
|
|
557
543
|
clear: commandOptions.clear,
|
|
558
544
|
cwd: options.cwd,
|
|
559
545
|
json: commandOptions.json,
|
|
560
546
|
stderr: options.stderr,
|
|
547
|
+
runtime: options.dependencies,
|
|
561
548
|
task,
|
|
562
549
|
stdout: options.stdout,
|
|
563
550
|
});
|
|
564
551
|
if (exitCode !== 0)
|
|
565
552
|
throw commanderExit(exitCode);
|
|
566
553
|
});
|
|
567
|
-
program.
|
|
568
|
-
.find((command) => command.name() === "sync")
|
|
569
|
-
?.action(async (commandOptions) => {
|
|
554
|
+
requireCommand(program, "sync").action(async (commandOptions) => {
|
|
570
555
|
const exitCode = await runSyncCommand({
|
|
571
556
|
all: commandOptions.all,
|
|
572
557
|
cwd: options.cwd,
|
|
573
558
|
json: commandOptions.json,
|
|
559
|
+
runtime: options.dependencies,
|
|
574
560
|
stderr: options.stderr,
|
|
575
561
|
stdout: options.stdout,
|
|
576
562
|
});
|
|
@@ -578,12 +564,13 @@ function attachCommandActions(program, options) {
|
|
|
578
564
|
throw commanderExit(exitCode);
|
|
579
565
|
}
|
|
580
566
|
});
|
|
581
|
-
const syncFilesCommand = program
|
|
582
|
-
syncFilesCommand
|
|
567
|
+
const syncFilesCommand = requireCommand(program, "sync-files");
|
|
568
|
+
syncFilesCommand.action(async (commandOptions) => {
|
|
583
569
|
const exitCode = await runSyncFilesCommand({
|
|
584
570
|
action: "list",
|
|
585
571
|
cwd: options.cwd,
|
|
586
572
|
json: commandOptions.json,
|
|
573
|
+
runtime: options.dependencies,
|
|
587
574
|
stderr: options.stderr,
|
|
588
575
|
stdout: options.stdout,
|
|
589
576
|
});
|
|
@@ -591,13 +578,12 @@ function attachCommandActions(program, options) {
|
|
|
591
578
|
throw commanderExit(exitCode);
|
|
592
579
|
}
|
|
593
580
|
});
|
|
594
|
-
syncFilesCommand
|
|
595
|
-
.find((command) => command.name() === "list")
|
|
596
|
-
?.action(async (commandOptions) => {
|
|
581
|
+
requireCommand(syncFilesCommand, "list").action(async (commandOptions) => {
|
|
597
582
|
const exitCode = await runSyncFilesCommand({
|
|
598
583
|
action: "list",
|
|
599
584
|
cwd: options.cwd,
|
|
600
|
-
json: commandOptions.json || syncFilesCommand
|
|
585
|
+
json: commandOptions.json || syncFilesCommand.opts().json,
|
|
586
|
+
runtime: options.dependencies,
|
|
601
587
|
stderr: options.stderr,
|
|
602
588
|
stdout: options.stdout,
|
|
603
589
|
});
|
|
@@ -605,14 +591,13 @@ function attachCommandActions(program, options) {
|
|
|
605
591
|
throw commanderExit(exitCode);
|
|
606
592
|
}
|
|
607
593
|
});
|
|
608
|
-
syncFilesCommand
|
|
609
|
-
.find((command) => command.name() === "add")
|
|
610
|
-
?.action(async (paths, commandOptions) => {
|
|
594
|
+
requireCommand(syncFilesCommand, "add").action(async (paths, commandOptions) => {
|
|
611
595
|
const exitCode = await runSyncFilesCommand({
|
|
612
596
|
action: "add",
|
|
613
597
|
cwd: options.cwd,
|
|
614
|
-
json: commandOptions.json || syncFilesCommand
|
|
598
|
+
json: commandOptions.json || syncFilesCommand.opts().json,
|
|
615
599
|
paths,
|
|
600
|
+
runtime: options.dependencies,
|
|
616
601
|
stderr: options.stderr,
|
|
617
602
|
stdout: options.stdout,
|
|
618
603
|
});
|
|
@@ -624,8 +609,9 @@ function attachCommandActions(program, options) {
|
|
|
624
609
|
const exitCode = await runSyncFilesCommand({
|
|
625
610
|
action: "remove",
|
|
626
611
|
cwd: options.cwd,
|
|
627
|
-
json: commandOptions.json || syncFilesCommand
|
|
612
|
+
json: commandOptions.json || syncFilesCommand.opts().json,
|
|
628
613
|
paths,
|
|
614
|
+
runtime: options.dependencies,
|
|
629
615
|
stderr: options.stderr,
|
|
630
616
|
stdout: options.stdout,
|
|
631
617
|
});
|
|
@@ -633,31 +619,27 @@ function attachCommandActions(program, options) {
|
|
|
633
619
|
throw commanderExit(exitCode);
|
|
634
620
|
}
|
|
635
621
|
};
|
|
636
|
-
syncFilesCommand
|
|
637
|
-
|
|
638
|
-
?.action(runSyncFilesRemoveCommand);
|
|
639
|
-
program.commands
|
|
640
|
-
.find((command) => command.name() === "ls")
|
|
641
|
-
?.action(async (commandOptions) => {
|
|
622
|
+
requireCommand(syncFilesCommand, "remove").action(runSyncFilesRemoveCommand);
|
|
623
|
+
requireCommand(program, "ls").action(async (commandOptions) => {
|
|
642
624
|
const exitCode = await runLsCommand({
|
|
643
625
|
compact: commandOptions.compact,
|
|
644
626
|
cwd: options.cwd,
|
|
645
627
|
json: commandOptions.json,
|
|
628
|
+
runtime: options.dependencies,
|
|
646
629
|
stdout: options.stdout,
|
|
647
630
|
});
|
|
648
631
|
if (exitCode !== 0) {
|
|
649
632
|
throw commanderExit(exitCode);
|
|
650
633
|
}
|
|
651
634
|
});
|
|
652
|
-
program.
|
|
653
|
-
.find((command) => command.name() === "clean")
|
|
654
|
-
?.action(async (commandOptions) => {
|
|
635
|
+
requireCommand(program, "clean").action(async (commandOptions) => {
|
|
655
636
|
const exitCode = await runCleanCommand({
|
|
656
637
|
cwd: options.cwd,
|
|
657
638
|
dryRun: commandOptions.dryRun,
|
|
658
639
|
force: commandOptions.force,
|
|
659
640
|
json: commandOptions.json,
|
|
660
641
|
stale: commandOptions.stale,
|
|
642
|
+
runtime: options.dependencies,
|
|
661
643
|
stderr: options.stderr,
|
|
662
644
|
stdout: options.stdout,
|
|
663
645
|
});
|
|
@@ -672,6 +654,7 @@ function attachCommandActions(program, options) {
|
|
|
672
654
|
dryRun: commandOptions.dryRun,
|
|
673
655
|
force: commandOptions.force,
|
|
674
656
|
json: commandOptions.json,
|
|
657
|
+
runtime: options.dependencies,
|
|
675
658
|
stderr: options.stderr,
|
|
676
659
|
stdout: options.stdout,
|
|
677
660
|
});
|
|
@@ -679,29 +662,24 @@ function attachCommandActions(program, options) {
|
|
|
679
662
|
throw commanderExit(exitCode);
|
|
680
663
|
}
|
|
681
664
|
};
|
|
682
|
-
program.
|
|
683
|
-
.find((command) => command.name() === "remove")
|
|
684
|
-
?.action(async (branch, commandOptions) => {
|
|
665
|
+
requireCommand(program, "remove").action(async (branch, commandOptions) => {
|
|
685
666
|
if (!commandOptions.json) {
|
|
686
667
|
options.stderr("gji remove is deprecated; use 'gji done' for one worktree or 'gji clean' for bulk cleanup.\n");
|
|
687
668
|
}
|
|
688
669
|
return runRemovalCommand(branch, commandOptions);
|
|
689
670
|
});
|
|
690
|
-
program.
|
|
691
|
-
.find((command) => command.name() === "run-hook")
|
|
692
|
-
?.action(async (hook) => {
|
|
671
|
+
requireCommand(program, "run-hook").action(async (hook) => {
|
|
693
672
|
const exitCode = await runHookCommand({
|
|
694
673
|
cwd: options.cwd,
|
|
695
674
|
hook,
|
|
675
|
+
runtime: options.dependencies,
|
|
696
676
|
stderr: options.stderr,
|
|
697
677
|
});
|
|
698
678
|
if (exitCode !== 0) {
|
|
699
679
|
throw commanderExit(exitCode);
|
|
700
680
|
}
|
|
701
681
|
});
|
|
702
|
-
program.
|
|
703
|
-
.find((command) => command.name() === "warp")
|
|
704
|
-
?.action(async (branch, commandOptions) => {
|
|
682
|
+
requireCommand(program, "warp").action(async (branch, commandOptions) => {
|
|
705
683
|
if (!commandOptions.json) {
|
|
706
684
|
options.stderr("gji warp is deprecated; use 'gji go' (press Tab for all repositories).\n");
|
|
707
685
|
}
|
|
@@ -709,6 +687,7 @@ function attachCommandActions(program, options) {
|
|
|
709
687
|
branch,
|
|
710
688
|
cwd: options.cwd,
|
|
711
689
|
json: commandOptions.json,
|
|
690
|
+
runtime: options.dependencies,
|
|
712
691
|
stderr: options.stderr,
|
|
713
692
|
stdout: options.stdout,
|
|
714
693
|
});
|
|
@@ -716,58 +695,63 @@ function attachCommandActions(program, options) {
|
|
|
716
695
|
throw commanderExit(exitCode);
|
|
717
696
|
}
|
|
718
697
|
});
|
|
719
|
-
const configCommand = program
|
|
720
|
-
configCommand
|
|
698
|
+
const configCommand = requireCommand(program, "config");
|
|
699
|
+
configCommand.action(async () => {
|
|
721
700
|
const exitCode = await runConfigCommand({
|
|
722
701
|
cwd: options.cwd,
|
|
723
702
|
stdout: options.stdout,
|
|
703
|
+
runtime: options.dependencies,
|
|
724
704
|
});
|
|
725
705
|
if (exitCode !== 0) {
|
|
726
706
|
throw commanderExit(exitCode);
|
|
727
707
|
}
|
|
728
708
|
});
|
|
729
|
-
configCommand
|
|
730
|
-
.find((command) => command.name() === "get")
|
|
731
|
-
?.action(async (key) => {
|
|
709
|
+
requireCommand(configCommand, "get").action(async (key) => {
|
|
732
710
|
const exitCode = await runConfigCommand({
|
|
733
711
|
action: "get",
|
|
734
712
|
cwd: options.cwd,
|
|
735
713
|
key,
|
|
736
714
|
stdout: options.stdout,
|
|
715
|
+
runtime: options.dependencies,
|
|
737
716
|
});
|
|
738
717
|
if (exitCode !== 0) {
|
|
739
718
|
throw commanderExit(exitCode);
|
|
740
719
|
}
|
|
741
720
|
});
|
|
742
|
-
configCommand
|
|
743
|
-
.find((command) => command.name() === "set")
|
|
744
|
-
?.action(async (key, value) => {
|
|
721
|
+
requireCommand(configCommand, "set").action(async (key, value) => {
|
|
745
722
|
const exitCode = await runConfigCommand({
|
|
746
723
|
action: "set",
|
|
747
724
|
cwd: options.cwd,
|
|
748
725
|
key,
|
|
749
726
|
stderr: options.stderr,
|
|
750
727
|
stdout: options.stdout,
|
|
728
|
+
runtime: options.dependencies,
|
|
751
729
|
value,
|
|
752
730
|
});
|
|
753
731
|
if (exitCode !== 0) {
|
|
754
732
|
throw commanderExit(exitCode);
|
|
755
733
|
}
|
|
756
734
|
});
|
|
757
|
-
configCommand
|
|
758
|
-
.find((command) => command.name() === "unset")
|
|
759
|
-
?.action(async (key) => {
|
|
735
|
+
requireCommand(configCommand, "unset").action(async (key) => {
|
|
760
736
|
const exitCode = await runConfigCommand({
|
|
761
737
|
action: "unset",
|
|
762
738
|
cwd: options.cwd,
|
|
763
739
|
key,
|
|
764
740
|
stdout: options.stdout,
|
|
741
|
+
runtime: options.dependencies,
|
|
765
742
|
});
|
|
766
743
|
if (exitCode !== 0) {
|
|
767
744
|
throw commanderExit(exitCode);
|
|
768
745
|
}
|
|
769
746
|
});
|
|
770
747
|
}
|
|
748
|
+
function requireCommand(parent, name) {
|
|
749
|
+
const command = parent.commands.find((candidate) => candidate.name() === name);
|
|
750
|
+
if (command === undefined) {
|
|
751
|
+
throw new Error(`Command registration is missing: ${name}`);
|
|
752
|
+
}
|
|
753
|
+
return command;
|
|
754
|
+
}
|
|
771
755
|
function notImplemented(commandName) {
|
|
772
756
|
return () => {
|
|
773
757
|
throw new Error(`'${commandName}' is not implemented yet.`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mapWithConcurrency<Input, Output>(items: readonly Input[], limit: number, mapper: (item: Input) => Promise<Output>): Promise<Output[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export async function mapWithConcurrency(items, limit, mapper) {
|
|
2
|
+
const results = new Array(items.length);
|
|
3
|
+
let nextIndex = 0;
|
|
4
|
+
async function readNext() {
|
|
5
|
+
for (;;) {
|
|
6
|
+
const index = nextIndex;
|
|
7
|
+
nextIndex += 1;
|
|
8
|
+
if (index >= items.length)
|
|
9
|
+
return;
|
|
10
|
+
results[index] = await mapper(items[index]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => readNext()));
|
|
14
|
+
return results;
|
|
15
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorktreeSource } from "./source.js";
|
|
2
|
+
export declare function resolveWorktreeQuery(sources: WorktreeSource[], query: string): WorktreeSource | null;
|
|
3
|
+
export declare function resolveWorktreeQueryMatches(sources: WorktreeSource[], query: string): WorktreeSource[];
|
|
4
|
+
export declare function resolveExactWorktreeQueryMatches(sources: WorktreeSource[], query: string): WorktreeSource[];
|