@solaqua/gji 0.9.0 → 0.11.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.
Files changed (100) hide show
  1. package/README.md +93 -20
  2. package/dist/back.d.ts +3 -0
  3. package/dist/back.js +19 -7
  4. package/dist/bootstrap-output.d.ts +3 -0
  5. package/dist/bootstrap-output.js +27 -0
  6. package/dist/bootstrap-preview.d.ts +10 -0
  7. package/dist/bootstrap-preview.js +21 -0
  8. package/dist/clean.js +25 -3
  9. package/dist/cli.js +105 -19
  10. package/dist/clone-failure-store.d.ts +18 -0
  11. package/dist/clone-failure-store.js +230 -0
  12. package/dist/command-runner.d.ts +6 -0
  13. package/dist/command-runner.js +38 -0
  14. package/dist/completion.js +7 -2
  15. package/dist/config-command.d.ts +1 -0
  16. package/dist/config-command.js +7 -1
  17. package/dist/config.d.ts +26 -1
  18. package/dist/config.js +110 -6
  19. package/dist/dependency-bootstrap-prompt.d.ts +24 -0
  20. package/dist/dependency-bootstrap-prompt.js +103 -0
  21. package/dist/dependency-bootstrap.d.ts +129 -0
  22. package/dist/dependency-bootstrap.js +566 -0
  23. package/dist/dir-clone.d.ts +33 -0
  24. package/dist/dir-clone.js +505 -0
  25. package/dist/done.d.ts +10 -0
  26. package/dist/done.js +208 -0
  27. package/dist/file-sync.js +71 -22
  28. package/dist/format-bytes.d.ts +1 -0
  29. package/dist/format-bytes.js +14 -0
  30. package/dist/fs-utils.d.ts +4 -0
  31. package/dist/fs-utils.js +26 -0
  32. package/dist/git.d.ts +5 -0
  33. package/dist/git.js +50 -0
  34. package/dist/gji-bundle.mjs +5489 -1206
  35. package/dist/go-resolver.d.ts +35 -0
  36. package/dist/go-resolver.js +185 -0
  37. package/dist/go.d.ts +5 -2
  38. package/dist/go.js +262 -62
  39. package/dist/hooks.d.ts +1 -1
  40. package/dist/hooks.js +13 -7
  41. package/dist/init.js +30 -22
  42. package/dist/install-prompt.d.ts +1 -0
  43. package/dist/install-prompt.js +3 -25
  44. package/dist/navigation-output.d.ts +11 -0
  45. package/dist/navigation-output.js +6 -0
  46. package/dist/new.d.ts +14 -2
  47. package/dist/new.js +434 -36
  48. package/dist/open.d.ts +1 -0
  49. package/dist/open.js +14 -2
  50. package/dist/pr.d.ts +6 -2
  51. package/dist/pr.js +135 -30
  52. package/dist/remove.js +20 -0
  53. package/dist/repo.d.ts +3 -0
  54. package/dist/repo.js +57 -6
  55. package/dist/safe-destination.d.ts +15 -0
  56. package/dist/safe-destination.js +166 -0
  57. package/dist/shell-completion.js +47 -14
  58. package/dist/sync-directories.d.ts +33 -0
  59. package/dist/sync-directories.js +97 -0
  60. package/dist/sync-plan.d.ts +16 -0
  61. package/dist/sync-plan.js +128 -0
  62. package/dist/sync.js +7 -13
  63. package/dist/undo.d.ts +36 -0
  64. package/dist/undo.js +392 -0
  65. package/dist/warp.d.ts +3 -1
  66. package/dist/warp.js +32 -125
  67. package/dist/worktree-bootstrap.d.ts +35 -0
  68. package/dist/worktree-bootstrap.js +93 -0
  69. package/dist/worktree-management.d.ts +1 -0
  70. package/dist/worktree-management.js +23 -4
  71. package/dist/worktree-picker.d.ts +21 -8
  72. package/dist/worktree-picker.js +107 -15
  73. package/dist/worktree-prompts.js +1 -1
  74. package/dist/worktree-source.d.ts +6 -0
  75. package/dist/worktree-source.js +1 -0
  76. package/dist/worktree-sources.d.ts +3 -0
  77. package/dist/worktree-sources.js +31 -0
  78. package/man/man1/gji-back.1 +1 -1
  79. package/man/man1/gji-clean.1 +1 -1
  80. package/man/man1/gji-completion.1 +1 -1
  81. package/man/man1/gji-config.1 +1 -1
  82. package/man/man1/gji-doctor.1 +1 -1
  83. package/man/man1/gji-done.1 +19 -0
  84. package/man/man1/gji-go.1 +9 -3
  85. package/man/man1/gji-history.1 +1 -1
  86. package/man/man1/gji-init.1 +1 -1
  87. package/man/man1/gji-ls.1 +1 -1
  88. package/man/man1/gji-new.1 +21 -3
  89. package/man/man1/gji-open.1 +4 -1
  90. package/man/man1/gji-pr.1 +7 -1
  91. package/man/man1/gji-remove.1 +3 -3
  92. package/man/man1/gji-root.1 +1 -1
  93. package/man/man1/gji-run-hook.1 +1 -1
  94. package/man/man1/gji-status.1 +1 -1
  95. package/man/man1/gji-sync-files.1 +1 -1
  96. package/man/man1/gji-sync.1 +1 -1
  97. package/man/man1/gji-undo.1 +16 -0
  98. package/man/man1/gji-warp.1 +3 -6
  99. package/man/man1/gji.1 +13 -5
  100. package/package.json +3 -1
package/dist/init.js CHANGED
@@ -12,49 +12,56 @@ import { SHELL_INTEGRATION_END_MARKER as END_MARKER, executableExists, hasShellI
12
12
  const ZSH_COMPLETION_PATH_LINE = "fpath=(~/.zsh/completions $fpath)";
13
13
  const SHELL_WRAPPED_COMMANDS = [
14
14
  {
15
- bypassOptions: ["--help"],
15
+ bypassOptions: ["--help", "-h", "--json"],
16
16
  commandName: "new",
17
17
  envVar: "GJI_NEW_OUTPUT_FILE",
18
18
  names: ["new"],
19
19
  tempPrefix: "gji-new",
20
20
  },
21
21
  {
22
- bypassOptions: ["--help"],
22
+ bypassOptions: ["--help", "-h", "--json"],
23
23
  commandName: "pr",
24
24
  envVar: "GJI_PR_OUTPUT_FILE",
25
25
  names: ["pr"],
26
26
  tempPrefix: "gji-pr",
27
27
  },
28
28
  {
29
- bypassOptions: ["--print"],
29
+ bypassOptions: ["--print", "--help", "-h"],
30
30
  commandName: "back",
31
31
  envVar: "GJI_BACK_OUTPUT_FILE",
32
32
  names: ["back"],
33
33
  tempPrefix: "gji-back",
34
34
  },
35
35
  {
36
- bypassOptions: ["--print"],
36
+ bypassOptions: ["--print", "--json", "--help", "-h"],
37
37
  commandName: "go",
38
38
  envVar: "GJI_GO_OUTPUT_FILE",
39
39
  names: ["go", "jump"],
40
40
  tempPrefix: "gji-go",
41
41
  },
42
42
  {
43
- bypassOptions: ["--print"],
43
+ bypassOptions: ["--print", "--help", "-h"],
44
44
  commandName: "root",
45
45
  envVar: "GJI_ROOT_OUTPUT_FILE",
46
46
  names: ["root"],
47
47
  tempPrefix: "gji-root",
48
48
  },
49
49
  {
50
- bypassOptions: ["--help"],
50
+ bypassOptions: ["--help", "-h", "--json"],
51
51
  commandName: "remove",
52
52
  envVar: "GJI_REMOVE_OUTPUT_FILE",
53
53
  names: ["remove", "rm"],
54
54
  tempPrefix: "gji-remove",
55
55
  },
56
56
  {
57
- bypassOptions: ["--print", "--json"],
57
+ bypassOptions: ["--help", "-h", "--json"],
58
+ commandName: "done",
59
+ envVar: "GJI_DONE_OUTPUT_FILE",
60
+ names: ["done"],
61
+ tempPrefix: "gji-done",
62
+ },
63
+ {
64
+ bypassOptions: ["--print", "--json", "--help", "-h"],
58
65
  commandName: "warp",
59
66
  envVar: "GJI_WARP_OUTPUT_FILE",
60
67
  names: ["warp"],
@@ -405,16 +412,17 @@ function renderFishWrapper(command) {
405
412
  const nameCondition = nameTests.length === 1
406
413
  ? nameTests[0]
407
414
  : `begin; ${nameTests.join("; or ")}; end`;
408
- const bypassTests = command.bypassOptions.map((opt) => `test $argv[1] = ${opt}`);
409
- const bypassCondition = bypassTests.length === 1
410
- ? bypassTests[0]
411
- : `begin; ${bypassTests.join("; or ")}; end`;
415
+ const bypassBlock = `if test (count $argv) -gt 0
416
+ for arg in $argv
417
+ if ${command.bypassOptions.map((opt) => `test $arg = ${opt}`).join("; or ")}
418
+ command gji ${command.commandName} $argv
419
+ return $status
420
+ end
421
+ end
422
+ end`;
412
423
  return `if test (count $argv) -gt 0; and ${nameCondition}
413
424
  set -e argv[1]
414
- if test (count $argv) -gt 0; and ${bypassCondition}
415
- command gji ${command.commandName} $argv
416
- return $status
417
- end
425
+ ${bypassBlock}
418
426
 
419
427
  set -l output_file (mktemp -t ${command.tempPrefix}.XXXXXX)
420
428
  or return 1
@@ -434,15 +442,15 @@ function renderPosixWrapper(command) {
434
442
  const tests = command.names
435
443
  .map((name) => `[ "$1" = "${name}" ]`)
436
444
  .join(" || ");
437
- const bypassTests = command.bypassOptions
438
- .map((opt) => `[ "\${1:-}" = "${opt}" ]`)
439
- .join(" || ");
445
+ const bypassBlock = `for arg do
446
+ if ${command.bypassOptions.map((opt) => `[ "$arg" = "${opt}" ]`).join(" || ")}; then
447
+ command gji ${command.commandName} "$@"
448
+ return $?
449
+ fi
450
+ done`;
440
451
  return `if ${tests}; then
441
452
  shift
442
- if ${bypassTests}; then
443
- command gji ${command.commandName} "$@"
444
- return $?
445
- fi
453
+ ${bypassBlock}
446
454
 
447
455
  local target
448
456
  local output_file
@@ -9,3 +9,4 @@ export interface InstallPromptDependencies {
9
9
  writeGlobalRepoConfigKey?: (repoRoot: string, key: string, value: unknown) => Promise<void>;
10
10
  }
11
11
  export declare function maybeRunInstallPrompt(worktreePath: string, repoRoot: string, config: GjiConfig, stderr: (chunk: string) => void, dependencies?: InstallPromptDependencies, nonInteractive?: boolean): Promise<void>;
12
+ export declare const runInstallCommand: import("./command-runner.js").CommandRunner;
@@ -1,5 +1,5 @@
1
- import { spawn } from "node:child_process";
2
1
  import { isCancel, select } from "@clack/prompts";
2
+ import { runCommand } from "./command-runner.js";
3
3
  import { loadConfig, loadGlobalConfig, updateGlobalRepoConfigKey, updateLocalConfigKey, } from "./config.js";
4
4
  import { isHeadless } from "./headless.js";
5
5
  import { extractHooks } from "./hooks.js";
@@ -28,7 +28,7 @@ export async function maybeRunInstallPrompt(worktreePath, repoRoot, config, stde
28
28
  return;
29
29
  }
30
30
  if (choice === "yes" || choice === "always") {
31
- const runner = dependencies.runInstallCommand ?? defaultRunInstallCommand;
31
+ const runner = dependencies.runInstallCommand ?? runInstallCommand;
32
32
  try {
33
33
  await runner(pm.installCommand, worktreePath, stderr);
34
34
  }
@@ -88,29 +88,7 @@ export async function maybeRunInstallPrompt(worktreePath, repoRoot, config, stde
88
88
  }
89
89
  }
90
90
  }
91
- async function defaultRunInstallCommand(command, cwd, stderr) {
92
- await new Promise((resolve, reject) => {
93
- const child = spawn(command, {
94
- cwd,
95
- shell: true,
96
- stdio: ["ignore", "inherit", "pipe"],
97
- });
98
- child.stderr.on("data", (chunk) => {
99
- stderr(chunk.toString());
100
- });
101
- child.on("close", (code) => {
102
- if (code !== 0) {
103
- reject(new Error(`exited with code ${code}`));
104
- }
105
- else {
106
- resolve();
107
- }
108
- });
109
- child.on("error", (err) => {
110
- reject(err);
111
- });
112
- });
113
- }
91
+ export const runInstallCommand = runCommand;
114
92
  async function defaultWriteConfigKey(root, key, value) {
115
93
  await updateLocalConfigKey(root, key, value);
116
94
  }
@@ -0,0 +1,11 @@
1
+ export interface NavigationRepository {
2
+ name: string;
3
+ root: string;
4
+ }
5
+ export interface NavigationTarget {
6
+ branch: string | null;
7
+ path: string;
8
+ repository: NavigationRepository;
9
+ }
10
+ export declare function createNavigationTarget(repository: NavigationRepository, path: string, branch: string | null): NavigationTarget;
11
+ export declare function createNavigationRepository(name: string, root: string): NavigationRepository;
@@ -0,0 +1,6 @@
1
+ export function createNavigationTarget(repository, path, branch) {
2
+ return { branch, path, repository };
3
+ }
4
+ export function createNavigationRepository(name, root) {
5
+ return { name, root };
6
+ }
package/dist/new.d.ts CHANGED
@@ -1,21 +1,33 @@
1
1
  import { type PathConflictChoice } from "./conflict.js";
2
- import { type InstallPromptDependencies } from "./install-prompt.js";
2
+ import { type DependencyBootstrapPromptDependencies } from "./dependency-bootstrap-prompt.js";
3
+ import { type CloneDirectory } from "./dir-clone.js";
4
+ import type { InstallPromptDependencies } from "./install-prompt.js";
3
5
  export type { PathConflictChoice };
6
+ export type NewWorktreeMode = "create" | "checkout" | "track";
4
7
  export interface NewCommandOptions {
5
8
  branch?: string;
9
+ copy?: boolean;
6
10
  cwd: string;
7
11
  detached?: boolean;
8
12
  dryRun?: boolean;
9
13
  editor?: string;
14
+ fromCurrent?: boolean;
10
15
  force?: boolean;
16
+ noFetch?: boolean;
11
17
  json?: boolean;
18
+ mode?: NewWorktreeMode;
12
19
  open?: boolean;
20
+ outputEnv?: string;
21
+ remote?: string;
22
+ take?: boolean;
13
23
  stderr: (chunk: string) => void;
14
24
  stdout: (chunk: string) => void;
15
25
  }
16
- export interface NewCommandDependencies extends InstallPromptDependencies {
26
+ export interface NewCommandDependencies extends InstallPromptDependencies, DependencyBootstrapPromptDependencies {
27
+ cloneDir: CloneDirectory;
17
28
  createBranchPlaceholder: () => string;
18
29
  promptForBranch: (placeholder: string) => Promise<string | null>;
30
+ promptForFetchFailure: (message: string) => Promise<boolean>;
19
31
  promptForPathConflict: (path: string) => Promise<PathConflictChoice>;
20
32
  spawnEditor: (cli: string, args: string[]) => Promise<void>;
21
33
  }