@camaradesuk/git-worktree-tools 1.0.3
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/LICENSE +21 -0
- package/README.md +259 -0
- package/dist/cli/cleanpr.d.ts +13 -0
- package/dist/cli/cleanpr.d.ts.map +1 -0
- package/dist/cli/cleanpr.js +441 -0
- package/dist/cli/cleanpr.js.map +1 -0
- package/dist/cli/lswt.d.ts +11 -0
- package/dist/cli/lswt.d.ts.map +1 -0
- package/dist/cli/lswt.js +313 -0
- package/dist/cli/lswt.js.map +1 -0
- package/dist/cli/newpr.d.ts +11 -0
- package/dist/cli/newpr.d.ts.map +1 -0
- package/dist/cli/newpr.js +888 -0
- package/dist/cli/newpr.js.map +1 -0
- package/dist/cli/wtlink.d.ts +15 -0
- package/dist/cli/wtlink.d.ts.map +1 -0
- package/dist/cli/wtlink.js +124 -0
- package/dist/cli/wtlink.js.map +1 -0
- package/dist/e2e/cli.e2e.test.d.ts +2 -0
- package/dist/e2e/cli.e2e.test.d.ts.map +1 -0
- package/dist/e2e/cli.e2e.test.js +215 -0
- package/dist/e2e/cli.e2e.test.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/git.integration.test.d.ts +2 -0
- package/dist/integration/git.integration.test.d.ts.map +1 -0
- package/dist/integration/git.integration.test.js +333 -0
- package/dist/integration/git.integration.test.js.map +1 -0
- package/dist/lib/colors.d.ts +59 -0
- package/dist/lib/colors.d.ts.map +1 -0
- package/dist/lib/colors.js +145 -0
- package/dist/lib/colors.js.map +1 -0
- package/dist/lib/colors.test.d.ts +2 -0
- package/dist/lib/colors.test.d.ts.map +1 -0
- package/dist/lib/colors.test.js +69 -0
- package/dist/lib/colors.test.js.map +1 -0
- package/dist/lib/config.d.ts +58 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +91 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/config.test.d.ts +2 -0
- package/dist/lib/config.test.d.ts.map +1 -0
- package/dist/lib/config.test.js +84 -0
- package/dist/lib/config.test.js.map +1 -0
- package/dist/lib/constants.d.ts +37 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +37 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/errors.d.ts +88 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +112 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/errors.test.d.ts +2 -0
- package/dist/lib/errors.test.d.ts.map +1 -0
- package/dist/lib/errors.test.js +117 -0
- package/dist/lib/errors.test.js.map +1 -0
- package/dist/lib/git.d.ts +224 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +524 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/git.test.d.ts +2 -0
- package/dist/lib/git.test.d.ts.map +1 -0
- package/dist/lib/git.test.js +402 -0
- package/dist/lib/git.test.js.map +1 -0
- package/dist/lib/github.d.ts +82 -0
- package/dist/lib/github.d.ts.map +1 -0
- package/dist/lib/github.js +254 -0
- package/dist/lib/github.js.map +1 -0
- package/dist/lib/github.test.d.ts +2 -0
- package/dist/lib/github.test.d.ts.map +1 -0
- package/dist/lib/github.test.js +258 -0
- package/dist/lib/github.test.js.map +1 -0
- package/dist/lib/prompts.d.ts +39 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +213 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/prompts.test.d.ts +2 -0
- package/dist/lib/prompts.test.d.ts.map +1 -0
- package/dist/lib/prompts.test.js +250 -0
- package/dist/lib/prompts.test.js.map +1 -0
- package/dist/lib/state-detection.d.ts +65 -0
- package/dist/lib/state-detection.d.ts.map +1 -0
- package/dist/lib/state-detection.js +186 -0
- package/dist/lib/state-detection.js.map +1 -0
- package/dist/lib/state-detection.test.d.ts +2 -0
- package/dist/lib/state-detection.test.d.ts.map +1 -0
- package/dist/lib/state-detection.test.js +164 -0
- package/dist/lib/state-detection.test.js.map +1 -0
- package/dist/lib/wtlink/index.d.ts +5 -0
- package/dist/lib/wtlink/index.d.ts.map +1 -0
- package/dist/lib/wtlink/index.js +7 -0
- package/dist/lib/wtlink/index.js.map +1 -0
- package/dist/lib/wtlink/link-configs.d.ts +10 -0
- package/dist/lib/wtlink/link-configs.d.ts.map +1 -0
- package/dist/lib/wtlink/link-configs.js +411 -0
- package/dist/lib/wtlink/link-configs.js.map +1 -0
- package/dist/lib/wtlink/link-configs.test.d.ts +2 -0
- package/dist/lib/wtlink/link-configs.test.d.ts.map +1 -0
- package/dist/lib/wtlink/link-configs.test.js +179 -0
- package/dist/lib/wtlink/link-configs.test.js.map +1 -0
- package/dist/lib/wtlink/main-menu.d.ts +2 -0
- package/dist/lib/wtlink/main-menu.d.ts.map +1 -0
- package/dist/lib/wtlink/main-menu.js +149 -0
- package/dist/lib/wtlink/main-menu.js.map +1 -0
- package/dist/lib/wtlink/manage-manifest.d.ts +9 -0
- package/dist/lib/wtlink/manage-manifest.d.ts.map +1 -0
- package/dist/lib/wtlink/manage-manifest.js +1262 -0
- package/dist/lib/wtlink/manage-manifest.js.map +1 -0
- package/dist/lib/wtlink/validate-manifest.d.ts +6 -0
- package/dist/lib/wtlink/validate-manifest.d.ts.map +1 -0
- package/dist/lib/wtlink/validate-manifest.js +51 -0
- package/dist/lib/wtlink/validate-manifest.js.map +1 -0
- package/dist/lib/wtlink/validate-manifest.test.d.ts +2 -0
- package/dist/lib/wtlink/validate-manifest.test.d.ts.map +1 -0
- package/dist/lib/wtlink/validate-manifest.test.js +115 -0
- package/dist/lib/wtlink/validate-manifest.test.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.test.js","sourceRoot":"","sources":["../../src/lib/colors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,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-gitops", "infrastructure"]
|
|
8
|
+
*/
|
|
9
|
+
sharedRepos?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Base branch for new PRs (default: "main")
|
|
12
|
+
*/
|
|
13
|
+
baseBranch?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Create PRs as drafts by default
|
|
16
|
+
*/
|
|
17
|
+
draftPr?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Worktree directory naming pattern
|
|
20
|
+
* Placeholders: {repo}, {number}, {branch}
|
|
21
|
+
* Default: "{repo}.pr{number}"
|
|
22
|
+
*/
|
|
23
|
+
worktreePattern?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Parent directory for worktrees
|
|
26
|
+
* Can be absolute or relative to repo root
|
|
27
|
+
* Default: ".." (sibling to main repo)
|
|
28
|
+
*/
|
|
29
|
+
worktreeParent?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Files/directories to sync between worktrees using symlinks
|
|
32
|
+
* e.g., ["node_modules", ".env.local"]
|
|
33
|
+
*/
|
|
34
|
+
syncPatterns?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Branch name prefix for auto-generated branches
|
|
37
|
+
* Default: "claude"
|
|
38
|
+
*/
|
|
39
|
+
branchPrefix?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get default configuration values
|
|
43
|
+
*/
|
|
44
|
+
export declare function getDefaultConfig(): Required<WorktreeConfig>;
|
|
45
|
+
/**
|
|
46
|
+
* Load configuration from repository
|
|
47
|
+
* Merges with defaults, repo config takes precedence
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadConfig(repoRoot: string): Required<WorktreeConfig>;
|
|
50
|
+
/**
|
|
51
|
+
* Generate worktree path based on config pattern
|
|
52
|
+
*/
|
|
53
|
+
export declare function generateWorktreePath(config: Required<WorktreeConfig>, repoRoot: string, repoName: string, prNumber: number, branchName?: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Generate branch name from description
|
|
56
|
+
*/
|
|
57
|
+
export declare function generateBranchName(config: Required<WorktreeConfig>, description: string): string;
|
|
58
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,CAAC,cAAc,CAAC,CAU3D;AAeD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,CAuBrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAmBR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAYhG"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { DEFAULT_BASE_BRANCH, DEFAULT_WORKTREE_PATTERN, DEFAULT_WORKTREE_PARENT, DEFAULT_BRANCH_PREFIX, CONFIG_FILE_NAMES, } from './constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Get default configuration values
|
|
6
|
+
*/
|
|
7
|
+
export function getDefaultConfig() {
|
|
8
|
+
return {
|
|
9
|
+
sharedRepos: [],
|
|
10
|
+
baseBranch: DEFAULT_BASE_BRANCH,
|
|
11
|
+
draftPr: false,
|
|
12
|
+
worktreePattern: DEFAULT_WORKTREE_PATTERN,
|
|
13
|
+
worktreeParent: DEFAULT_WORKTREE_PARENT,
|
|
14
|
+
syncPatterns: [],
|
|
15
|
+
branchPrefix: DEFAULT_BRANCH_PREFIX,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Find config file in repository
|
|
20
|
+
*/
|
|
21
|
+
function findConfigFile(repoRoot) {
|
|
22
|
+
for (const fileName of CONFIG_FILE_NAMES) {
|
|
23
|
+
const configPath = path.join(repoRoot, fileName);
|
|
24
|
+
if (fs.existsSync(configPath)) {
|
|
25
|
+
return configPath;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load configuration from repository
|
|
32
|
+
* Merges with defaults, repo config takes precedence
|
|
33
|
+
*/
|
|
34
|
+
export function loadConfig(repoRoot) {
|
|
35
|
+
const defaults = getDefaultConfig();
|
|
36
|
+
const configPath = findConfigFile(repoRoot);
|
|
37
|
+
if (!configPath) {
|
|
38
|
+
return defaults;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const content = fs.readFileSync(configPath, 'utf8');
|
|
42
|
+
const userConfig = JSON.parse(content);
|
|
43
|
+
// Merge with defaults
|
|
44
|
+
return {
|
|
45
|
+
...defaults,
|
|
46
|
+
...userConfig,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
// If config file exists but is invalid, warn but continue with defaults
|
|
51
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
+
console.warn(`Warning: Failed to parse ${configPath}: ${message}`);
|
|
53
|
+
return defaults;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generate worktree path based on config pattern
|
|
58
|
+
*/
|
|
59
|
+
export function generateWorktreePath(config, repoRoot, repoName, prNumber, branchName) {
|
|
60
|
+
let pattern = config.worktreePattern;
|
|
61
|
+
// Replace placeholders
|
|
62
|
+
pattern = pattern.replace('{repo}', repoName);
|
|
63
|
+
pattern = pattern.replace('{number}', String(prNumber));
|
|
64
|
+
if (branchName) {
|
|
65
|
+
pattern = pattern.replace('{branch}', branchName);
|
|
66
|
+
}
|
|
67
|
+
// Resolve parent directory
|
|
68
|
+
let parentDir;
|
|
69
|
+
if (path.isAbsolute(config.worktreeParent)) {
|
|
70
|
+
parentDir = config.worktreeParent;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
parentDir = path.resolve(repoRoot, config.worktreeParent);
|
|
74
|
+
}
|
|
75
|
+
return path.join(parentDir, pattern);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Generate branch name from description
|
|
79
|
+
*/
|
|
80
|
+
export function generateBranchName(config, description) {
|
|
81
|
+
// Convert to lowercase, replace spaces and special chars with hyphens
|
|
82
|
+
const slug = description
|
|
83
|
+
.toLowerCase()
|
|
84
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
85
|
+
.replace(/^-+|-+$/g, '') // Remove leading/trailing hyphens
|
|
86
|
+
.substring(0, 50); // Limit length
|
|
87
|
+
// Generate a short random suffix for uniqueness
|
|
88
|
+
const suffix = Math.random().toString(36).substring(2, 8);
|
|
89
|
+
return `${config.branchPrefix}/${slug}-${suffix}`;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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C;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,kCAAkC;SAC1D,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe;IAEpC,gDAAgD;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE1D,OAAO,GAAG,MAAM,CAAC,YAAY,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/lib/config.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { getDefaultConfig, generateBranchName, generateWorktreePath } from './config.js';
|
|
3
|
+
// Helper to normalize paths for cross-platform testing
|
|
4
|
+
function normalizePath(p) {
|
|
5
|
+
return p.replace(/\\/g, '/').replace(/^[A-Z]:/, '');
|
|
6
|
+
}
|
|
7
|
+
describe('config', () => {
|
|
8
|
+
describe('getDefaultConfig', () => {
|
|
9
|
+
it('should return default configuration', () => {
|
|
10
|
+
const config = getDefaultConfig();
|
|
11
|
+
expect(config.baseBranch).toBe('main');
|
|
12
|
+
expect(config.draftPr).toBe(false);
|
|
13
|
+
expect(config.worktreePattern).toBe('{repo}.pr{number}');
|
|
14
|
+
expect(config.worktreeParent).toBe('..');
|
|
15
|
+
expect(config.sharedRepos).toEqual([]);
|
|
16
|
+
expect(config.syncPatterns).toEqual([]);
|
|
17
|
+
expect(config.branchPrefix).toBe('claude');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('generateBranchName', () => {
|
|
21
|
+
const config = getDefaultConfig();
|
|
22
|
+
it('should generate branch name from description', () => {
|
|
23
|
+
const branch = generateBranchName(config, 'Add user authentication feature');
|
|
24
|
+
expect(branch).toMatch(/^claude\/add-user-authentication-feature-[a-z0-9]+$/);
|
|
25
|
+
});
|
|
26
|
+
it('should handle uppercase in description', () => {
|
|
27
|
+
const branch = generateBranchName(config, 'Fix BUG in API');
|
|
28
|
+
expect(branch).toMatch(/^claude\/fix-bug-in-api-[a-z0-9]+$/);
|
|
29
|
+
});
|
|
30
|
+
it('should handle special characters', () => {
|
|
31
|
+
const branch = generateBranchName(config, "Add user's profile (v2)!");
|
|
32
|
+
expect(branch).toMatch(/^claude\/add-user-s-profile-v2-[a-z0-9]+$/);
|
|
33
|
+
});
|
|
34
|
+
it('should truncate long descriptions', () => {
|
|
35
|
+
const longDesc = 'This is a very long description that should be truncated to a reasonable length for a git branch name';
|
|
36
|
+
const branch = generateBranchName(config, longDesc);
|
|
37
|
+
// Branch name should not exceed ~100 chars total
|
|
38
|
+
expect(branch.length).toBeLessThan(100);
|
|
39
|
+
});
|
|
40
|
+
it('should handle empty description', () => {
|
|
41
|
+
const branch = generateBranchName(config, '');
|
|
42
|
+
// Empty description results in empty slug, so branch is prefix/-suffix
|
|
43
|
+
expect(branch).toMatch(/^claude\/-[a-z0-9]+$/);
|
|
44
|
+
});
|
|
45
|
+
it('should use custom branch prefix', () => {
|
|
46
|
+
const customConfig = { ...config, branchPrefix: 'feature' };
|
|
47
|
+
const branch = generateBranchName(customConfig, 'new feature');
|
|
48
|
+
expect(branch).toMatch(/^feature\/new-feature-[a-z0-9]+$/);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('generateWorktreePath', () => {
|
|
52
|
+
const config = getDefaultConfig();
|
|
53
|
+
it('should generate worktree path with default pattern', () => {
|
|
54
|
+
const result = generateWorktreePath(config, '/home/user/repos/myproject', 'myproject', 123);
|
|
55
|
+
// Normalize paths for cross-platform comparison
|
|
56
|
+
expect(normalizePath(result)).toBe('/home/user/repos/myproject.pr123');
|
|
57
|
+
});
|
|
58
|
+
it('should use custom worktree pattern', () => {
|
|
59
|
+
const customConfig = {
|
|
60
|
+
...config,
|
|
61
|
+
worktreePattern: '{repo}-pr-{number}',
|
|
62
|
+
};
|
|
63
|
+
const result = generateWorktreePath(customConfig, '/home/user/repos/myproject', 'myproject', 456);
|
|
64
|
+
expect(normalizePath(result)).toBe('/home/user/repos/myproject-pr-456');
|
|
65
|
+
});
|
|
66
|
+
it('should use custom parent directory', () => {
|
|
67
|
+
const customConfig = {
|
|
68
|
+
...config,
|
|
69
|
+
worktreeParent: '/tmp/worktrees',
|
|
70
|
+
};
|
|
71
|
+
const result = generateWorktreePath(customConfig, '/home/user/repos/myproject', 'myproject', 789);
|
|
72
|
+
expect(normalizePath(result)).toBe('/tmp/worktrees/myproject.pr789');
|
|
73
|
+
});
|
|
74
|
+
it('should include branch name when pattern uses it', () => {
|
|
75
|
+
const customConfig = {
|
|
76
|
+
...config,
|
|
77
|
+
worktreePattern: '{repo}.{branch}',
|
|
78
|
+
};
|
|
79
|
+
const result = generateWorktreePath(customConfig, '/home/user/repos/myproject', 'myproject', 123, 'feature-x');
|
|
80
|
+
expect(normalizePath(result)).toBe('/home/user/repos/myproject.feature-x');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.test.js","sourceRoot":"","sources":["../../src/lib/config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGzF,uDAAuD;AACvD,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;I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|
|
1
|
+
/**
|
|
2
|
+
* Centralized constants and defaults for git-worktree-tools
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default remote name for git operations
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_REMOTE = "origin";
|
|
8
|
+
/**
|
|
9
|
+
* Default base branch for PRs and comparisons
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_BASE_BRANCH = "main";
|
|
12
|
+
/**
|
|
13
|
+
* Common base branch names to prefer when auto-detecting
|
|
14
|
+
*/
|
|
15
|
+
export declare const COMMON_BASE_BRANCHES: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Default manifest file name for wtlink
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_MANIFEST_FILE = ".wtlinkrc";
|
|
20
|
+
/**
|
|
21
|
+
* Config file names to look for (in order of priority)
|
|
22
|
+
*/
|
|
23
|
+
export declare const CONFIG_FILE_NAMES: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Default worktree naming pattern
|
|
26
|
+
* Placeholders: {repo}, {number}, {branch}
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_WORKTREE_PATTERN = "{repo}.pr{number}";
|
|
29
|
+
/**
|
|
30
|
+
* Default parent directory for worktrees (sibling to main repo)
|
|
31
|
+
*/
|
|
32
|
+
export declare const DEFAULT_WORKTREE_PARENT = "..";
|
|
33
|
+
/**
|
|
34
|
+
* Default branch name prefix for auto-generated branches
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_BRANCH_PREFIX = "claude";
|
|
37
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,oBAAoB,UAAgC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,qBAAqB,cAAc,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAsC,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,qBAAqB,WAAW,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized constants and defaults for git-worktree-tools
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default remote name for git operations
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_REMOTE = 'origin';
|
|
8
|
+
/**
|
|
9
|
+
* Default base branch for PRs and comparisons
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_BASE_BRANCH = 'main';
|
|
12
|
+
/**
|
|
13
|
+
* Common base branch names to prefer when auto-detecting
|
|
14
|
+
*/
|
|
15
|
+
export const COMMON_BASE_BRANCHES = ['main', 'master', 'develop'];
|
|
16
|
+
/**
|
|
17
|
+
* Default manifest file name for wtlink
|
|
18
|
+
*/
|
|
19
|
+
export const DEFAULT_MANIFEST_FILE = '.wtlinkrc';
|
|
20
|
+
/**
|
|
21
|
+
* Config file names to look for (in order of priority)
|
|
22
|
+
*/
|
|
23
|
+
export const CONFIG_FILE_NAMES = ['.worktreerc', '.worktreerc.json'];
|
|
24
|
+
/**
|
|
25
|
+
* Default worktree naming pattern
|
|
26
|
+
* Placeholders: {repo}, {number}, {branch}
|
|
27
|
+
*/
|
|
28
|
+
export const DEFAULT_WORKTREE_PATTERN = '{repo}.pr{number}';
|
|
29
|
+
/**
|
|
30
|
+
* Default parent directory for worktrees (sibling to main repo)
|
|
31
|
+
*/
|
|
32
|
+
export const DEFAULT_WORKTREE_PARENT = '..';
|
|
33
|
+
/**
|
|
34
|
+
* Default branch name prefix for auto-generated branches
|
|
35
|
+
*/
|
|
36
|
+
export const DEFAULT_BRANCH_PREFIX = 'claude';
|
|
37
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAErE;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for git-worktree-tools
|
|
3
|
+
*
|
|
4
|
+
* These provide structured error handling with specific error types
|
|
5
|
+
* that can be caught and handled differently based on the error kind.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base error class for all git-worktree-tools errors
|
|
9
|
+
*/
|
|
10
|
+
export declare class WorktreeToolsError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when a git command fails
|
|
15
|
+
*/
|
|
16
|
+
export declare class GitCommandError extends WorktreeToolsError {
|
|
17
|
+
readonly command: string;
|
|
18
|
+
readonly exitCode?: number;
|
|
19
|
+
readonly stderr?: string;
|
|
20
|
+
constructor(message: string, options: {
|
|
21
|
+
command: string;
|
|
22
|
+
exitCode?: number;
|
|
23
|
+
stderr?: string;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when GitHub CLI command fails
|
|
28
|
+
*/
|
|
29
|
+
export declare class GitHubCliError extends WorktreeToolsError {
|
|
30
|
+
readonly command: string;
|
|
31
|
+
readonly stderr?: string;
|
|
32
|
+
constructor(message: string, options: {
|
|
33
|
+
command: string;
|
|
34
|
+
stderr?: string;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when configuration is invalid
|
|
39
|
+
*/
|
|
40
|
+
export declare class ConfigurationError extends WorktreeToolsError {
|
|
41
|
+
readonly configFile?: string;
|
|
42
|
+
readonly field?: string;
|
|
43
|
+
constructor(message: string, options?: {
|
|
44
|
+
configFile?: string;
|
|
45
|
+
field?: string;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when a worktree operation fails
|
|
50
|
+
*/
|
|
51
|
+
export declare class WorktreeError extends WorktreeToolsError {
|
|
52
|
+
readonly worktreePath?: string;
|
|
53
|
+
readonly branch?: string;
|
|
54
|
+
constructor(message: string, options?: {
|
|
55
|
+
worktreePath?: string;
|
|
56
|
+
branch?: string;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when manifest validation fails
|
|
61
|
+
*/
|
|
62
|
+
export declare class ManifestError extends WorktreeToolsError {
|
|
63
|
+
readonly manifestPath?: string;
|
|
64
|
+
readonly issues?: string[];
|
|
65
|
+
constructor(message: string, options?: {
|
|
66
|
+
manifestPath?: string;
|
|
67
|
+
issues?: string[];
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Error thrown when user cancels an operation
|
|
72
|
+
*/
|
|
73
|
+
export declare class UserCancelledError extends WorktreeToolsError {
|
|
74
|
+
constructor(message?: string);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Type guard to check if error is a WorktreeToolsError
|
|
78
|
+
*/
|
|
79
|
+
export declare function isWorktreeToolsError(error: unknown): error is WorktreeToolsError;
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if error is a GitCommandError
|
|
82
|
+
*/
|
|
83
|
+
export declare function isGitCommandError(error: unknown): error is GitCommandError;
|
|
84
|
+
/**
|
|
85
|
+
* Type guard to check if error is a GitHubCliError
|
|
86
|
+
*/
|
|
87
|
+
export declare function isGitHubCliError(error: unknown): error is GitHubCliError;
|
|
88
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAM5B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,kBAAkB;IACrD,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClC,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;CAO9F;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,kBAAkB;IACpD,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAA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Custom error classes for git-worktree-tools
|
|
3
|
+
*
|
|
4
|
+
* These provide structured error handling with specific error types
|
|
5
|
+
* that can be caught and handled differently based on the error kind.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base error class for all git-worktree-tools errors
|
|
9
|
+
*/
|
|
10
|
+
export class WorktreeToolsError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'WorktreeToolsError';
|
|
14
|
+
// Maintains proper stack trace for where error was thrown
|
|
15
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when a git command fails
|
|
20
|
+
*/
|
|
21
|
+
export class GitCommandError extends WorktreeToolsError {
|
|
22
|
+
command;
|
|
23
|
+
exitCode;
|
|
24
|
+
stderr;
|
|
25
|
+
constructor(message, options) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'GitCommandError';
|
|
28
|
+
this.command = options.command;
|
|
29
|
+
this.exitCode = options.exitCode;
|
|
30
|
+
this.stderr = options.stderr;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown when GitHub CLI command fails
|
|
35
|
+
*/
|
|
36
|
+
export class GitHubCliError extends WorktreeToolsError {
|
|
37
|
+
command;
|
|
38
|
+
stderr;
|
|
39
|
+
constructor(message, options) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = 'GitHubCliError';
|
|
42
|
+
this.command = options.command;
|
|
43
|
+
this.stderr = options.stderr;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when configuration is invalid
|
|
48
|
+
*/
|
|
49
|
+
export class ConfigurationError extends WorktreeToolsError {
|
|
50
|
+
configFile;
|
|
51
|
+
field;
|
|
52
|
+
constructor(message, options = {}) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = 'ConfigurationError';
|
|
55
|
+
this.configFile = options.configFile;
|
|
56
|
+
this.field = options.field;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when a worktree operation fails
|
|
61
|
+
*/
|
|
62
|
+
export class WorktreeError extends WorktreeToolsError {
|
|
63
|
+
worktreePath;
|
|
64
|
+
branch;
|
|
65
|
+
constructor(message, options = {}) {
|
|
66
|
+
super(message);
|
|
67
|
+
this.name = 'WorktreeError';
|
|
68
|
+
this.worktreePath = options.worktreePath;
|
|
69
|
+
this.branch = options.branch;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Error thrown when manifest validation fails
|
|
74
|
+
*/
|
|
75
|
+
export class ManifestError extends WorktreeToolsError {
|
|
76
|
+
manifestPath;
|
|
77
|
+
issues;
|
|
78
|
+
constructor(message, options = {}) {
|
|
79
|
+
super(message);
|
|
80
|
+
this.name = 'ManifestError';
|
|
81
|
+
this.manifestPath = options.manifestPath;
|
|
82
|
+
this.issues = options.issues;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Error thrown when user cancels an operation
|
|
87
|
+
*/
|
|
88
|
+
export class UserCancelledError extends WorktreeToolsError {
|
|
89
|
+
constructor(message = 'Operation cancelled by user') {
|
|
90
|
+
super(message);
|
|
91
|
+
this.name = 'UserCancelledError';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Type guard to check if error is a WorktreeToolsError
|
|
96
|
+
*/
|
|
97
|
+
export function isWorktreeToolsError(error) {
|
|
98
|
+
return error instanceof WorktreeToolsError;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Type guard to check if error is a GitCommandError
|
|
102
|
+
*/
|
|
103
|
+
export function isGitCommandError(error) {
|
|
104
|
+
return error instanceof GitCommandError;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Type guard to check if error is a GitHubCliError
|
|
108
|
+
*/
|
|
109
|
+
export function isGitHubCliError(error) {
|
|
110
|
+
return error instanceof GitHubCliError;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,0DAA0D;QAC1D,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IACrC,OAAO,CAAS;IAChB,QAAQ,CAAU;IAClB,MAAM,CAAU;IAEhC,YAAY,OAAe,EAAE,OAAgE;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,kBAAkB;IACpC,OAAO,CAAS;IAChB,MAAM,CAAU;IAEhC,YAAY,OAAe,EAAE,OAA6C;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,O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