wt-manager 1.4.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -43
- package/dist/cli.js +25273 -26
- package/dist/cli.js.map +1 -1
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +69 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +39 -78
- package/dist/commands/new.js.map +1 -1
- package/dist/utils/config.d.ts +50 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +192 -0
- package/dist/utils/config.js.map +1 -0
- package/package.json +17 -19
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,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A,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,wBAAgB,aAAa,YAqE5B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { getMainWorktreePath, getRepoName } from '../utils/git.js';
|
|
5
|
+
import { loadConfig } from '../utils/config.js';
|
|
6
|
+
export function configCommand() {
|
|
7
|
+
const cmd = new Command('config');
|
|
8
|
+
cmd.description('Display current .wtrc.json configuration').action(async () => {
|
|
9
|
+
try {
|
|
10
|
+
const mainWorktreePath = await getMainWorktreePath();
|
|
11
|
+
const repoName = await getRepoName();
|
|
12
|
+
const configPath = join(mainWorktreePath, '.wtrc.json');
|
|
13
|
+
const { config, source } = await loadConfig(mainWorktreePath);
|
|
14
|
+
if (source === 'defaults') {
|
|
15
|
+
console.log(chalk.gray('Config: No .wtrc.json found (using defaults)'));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log(chalk.gray(`Config: ${configPath}`));
|
|
19
|
+
}
|
|
20
|
+
console.log();
|
|
21
|
+
console.log(chalk.bold('worktreePath:'), config.worktreePath);
|
|
22
|
+
const exampleDir = config.worktreePath
|
|
23
|
+
.replace(/\$REPO\b/g, repoName)
|
|
24
|
+
.replace(/\$DIR\b/g, '<branch>');
|
|
25
|
+
console.log(chalk.gray(` → ${exampleDir}`));
|
|
26
|
+
console.log();
|
|
27
|
+
console.log(chalk.bold('copy:'));
|
|
28
|
+
if (config.copy.length > 0) {
|
|
29
|
+
for (const pattern of config.copy) {
|
|
30
|
+
console.log(` - ${pattern}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log(chalk.gray(' (none)'));
|
|
35
|
+
}
|
|
36
|
+
console.log();
|
|
37
|
+
console.log(chalk.bold('symlink:'));
|
|
38
|
+
if (config.symlink.length > 0) {
|
|
39
|
+
for (const pattern of config.symlink) {
|
|
40
|
+
console.log(` - ${pattern}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log(chalk.gray(' (none)'));
|
|
45
|
+
}
|
|
46
|
+
console.log();
|
|
47
|
+
console.log(chalk.bold('postCreate:'));
|
|
48
|
+
if (config.postCreate.length > 0) {
|
|
49
|
+
for (const command of config.postCreate) {
|
|
50
|
+
console.log(` - ${command}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.log(chalk.gray(' (none)'));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof Error) {
|
|
59
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
console.error(chalk.red('An unknown error occurred'));
|
|
63
|
+
}
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return cmd;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAA;IAEjC,GAAG,CAAC,WAAW,CAAC,0CAA0C,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QAC5E,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,mBA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I,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAqBnC,wBAAgB,UAAU,YAiIzB"}
|
package/dist/commands/new.js
CHANGED
|
@@ -2,11 +2,9 @@ import { Command } from 'commander';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
import { join, dirname, basename } from 'node:path';
|
|
5
|
-
import { symlink, copyFile, mkdir, readFile, cp, readdir } from 'node:fs/promises';
|
|
6
|
-
import { existsSync, statSync } from 'node:fs';
|
|
7
|
-
import { execa } from 'execa';
|
|
8
5
|
import { getMainWorktreePath, getDefaultBranch, branchExists, ensureDir, createWorktree, fetchOrigin, } from '../utils/git.js';
|
|
9
6
|
import { copyToClipboard } from '../utils/clipboard.js';
|
|
7
|
+
import { loadConfig, resolveTemplate, copyConfigFiles, runPostCreateCommands, } from '../utils/config.js';
|
|
10
8
|
export function newCommand() {
|
|
11
9
|
const cmd = new Command('new');
|
|
12
10
|
cmd
|
|
@@ -23,9 +21,18 @@ export function newCommand() {
|
|
|
23
21
|
spinner.start('Creating worktree...');
|
|
24
22
|
const mainWorktreePath = await getMainWorktreePath();
|
|
25
23
|
const repoName = basename(mainWorktreePath);
|
|
26
|
-
const
|
|
24
|
+
const { config } = await loadConfig(mainWorktreePath);
|
|
27
25
|
const dirName = branchName.replace(/\//g, '-');
|
|
28
|
-
const
|
|
26
|
+
const templateVars = {
|
|
27
|
+
PATH: '',
|
|
28
|
+
BRANCH: branchName,
|
|
29
|
+
DIR: dirName,
|
|
30
|
+
REPO: repoName,
|
|
31
|
+
};
|
|
32
|
+
const resolvedWorktreePath = resolveTemplate(config.worktreePath, templateVars);
|
|
33
|
+
const worktreePath = join(dirname(mainWorktreePath), resolvedWorktreePath);
|
|
34
|
+
const worktreeBaseDir = dirname(worktreePath);
|
|
35
|
+
templateVars.PATH = worktreePath;
|
|
29
36
|
const base = baseBranch || (await getDefaultBranch());
|
|
30
37
|
let useRemoteBase = true;
|
|
31
38
|
try {
|
|
@@ -43,84 +50,38 @@ export function newCommand() {
|
|
|
43
50
|
await createWorktree(branchName, worktreePath, actualBase);
|
|
44
51
|
spinner.stop();
|
|
45
52
|
console.log(chalk.green(`✓ Created worktree for branch '${branchName}'`));
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
if (config.copy.length > 0 || config.symlink.length > 0) {
|
|
54
|
+
const result = await copyConfigFiles({
|
|
55
|
+
mainWorktreePath,
|
|
56
|
+
worktreePath,
|
|
57
|
+
copyPatterns: config.copy,
|
|
58
|
+
symlinkPatterns: config.symlink,
|
|
59
|
+
});
|
|
60
|
+
if (result.copied.length > 0) {
|
|
61
|
+
console.log(chalk.gray(` Copied ${result.copied.length} file(s) from main worktree`));
|
|
53
62
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (existsSync(sourceSettingsPath)) {
|
|
57
|
-
await mkdir(dirname(targetSettingsPath), { recursive: true });
|
|
58
|
-
await copyFile(sourceSettingsPath, targetSettingsPath);
|
|
59
|
-
console.log(chalk.gray(' Copied .claude/settings.local.json from main worktree'));
|
|
63
|
+
if (result.symlinked.length > 0) {
|
|
64
|
+
console.log(chalk.gray(` Symlinked ${result.symlinked.length} file(s) from main worktree`));
|
|
60
65
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
if (existsSync(sourceIdeaPath)) {
|
|
64
|
-
let copiedAny = false;
|
|
65
|
-
await mkdir(targetIdeaPath, { recursive: true });
|
|
66
|
-
const dirsTocp = ['runConfigurations', 'codeStyles', 'inspectionProfiles', 'scopes'];
|
|
67
|
-
for (const dir of dirsTocp) {
|
|
68
|
-
const sourceDir = join(sourceIdeaPath, dir);
|
|
69
|
-
const targetDir = join(targetIdeaPath, dir);
|
|
70
|
-
if (existsSync(sourceDir) && statSync(sourceDir).isDirectory()) {
|
|
71
|
-
await cp(sourceDir, targetDir, { recursive: true });
|
|
72
|
-
copiedAny = true;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const filesToCopy = ['modules.xml', 'vcs.xml', 'encodings.xml', 'misc.xml'];
|
|
76
|
-
for (const file of filesToCopy) {
|
|
77
|
-
const sourceFile = join(sourceIdeaPath, file);
|
|
78
|
-
const targetFile = join(targetIdeaPath, file);
|
|
79
|
-
if (existsSync(sourceFile)) {
|
|
80
|
-
await copyFile(sourceFile, targetFile);
|
|
81
|
-
copiedAny = true;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const ideaFiles = await readdir(sourceIdeaPath);
|
|
85
|
-
for (const file of ideaFiles) {
|
|
86
|
-
if (file.endsWith('.iml')) {
|
|
87
|
-
const sourceFile = join(sourceIdeaPath, file);
|
|
88
|
-
const targetFile = join(targetIdeaPath, file);
|
|
89
|
-
if (existsSync(sourceFile)) {
|
|
90
|
-
await copyFile(sourceFile, targetFile);
|
|
91
|
-
copiedAny = true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (copiedAny) {
|
|
96
|
-
console.log(chalk.gray(' Copied WebStorm settings from main worktree'));
|
|
97
|
-
}
|
|
66
|
+
for (const warning of result.warnings) {
|
|
67
|
+
console.log(chalk.yellow(` ⚠ ${warning}`));
|
|
98
68
|
}
|
|
99
69
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
spinner.stop();
|
|
116
|
-
console.log(chalk.green('✓ Post-worktree hook completed'));
|
|
117
|
-
}
|
|
70
|
+
if (config.postCreate.length > 0) {
|
|
71
|
+
const resolvedCommands = config.postCreate.map(cmd => resolveTemplate(cmd, templateVars));
|
|
72
|
+
const result = await runPostCreateCommands({
|
|
73
|
+
worktreePath,
|
|
74
|
+
commands: resolvedCommands,
|
|
75
|
+
onCommand: (command) => {
|
|
76
|
+
console.log(chalk.blue(`→ ${command}`));
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
if (result.failed) {
|
|
80
|
+
console.log(chalk.yellow(`⚠ Command failed: ${result.failed.error}`));
|
|
81
|
+
}
|
|
82
|
+
else if (result.executed.length > 0) {
|
|
83
|
+
console.log(chalk.green('✓ Post-create commands completed'));
|
|
118
84
|
}
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
spinner.stop();
|
|
122
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
123
|
-
console.log(chalk.yellow(`⚠ Warning: Post-worktree hook failed: ${errorMessage}`));
|
|
124
85
|
}
|
|
125
86
|
console.log();
|
|
126
87
|
const copied = await copyToClipboard(worktreePath);
|
package/dist/commands/new.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.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D,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CAAA;IAEJ,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface WtConfig {
|
|
3
|
+
worktreePath: string;
|
|
4
|
+
copy: string[];
|
|
5
|
+
symlink: string[];
|
|
6
|
+
postCreate: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface LoadConfigResult {
|
|
9
|
+
config: WtConfig;
|
|
10
|
+
source: 'file' | 'defaults';
|
|
11
|
+
}
|
|
12
|
+
export declare function getDefaults(): WtConfig;
|
|
13
|
+
export declare function loadConfig(mainWorktreePath: string): Promise<LoadConfigResult>;
|
|
14
|
+
export declare class ConfigValidationError extends Error {
|
|
15
|
+
readonly configPath: string;
|
|
16
|
+
readonly zodError?: z.ZodError | undefined;
|
|
17
|
+
constructor(message: string, configPath: string, zodError?: z.ZodError | undefined);
|
|
18
|
+
}
|
|
19
|
+
export interface TemplateVariables {
|
|
20
|
+
PATH: string;
|
|
21
|
+
BRANCH: string;
|
|
22
|
+
DIR: string;
|
|
23
|
+
REPO: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function resolveTemplate(template: string, vars: TemplateVariables): string;
|
|
26
|
+
export declare function resolveConfig(config: WtConfig, vars: TemplateVariables): WtConfig;
|
|
27
|
+
export interface CopyConfigFilesOptions {
|
|
28
|
+
mainWorktreePath: string;
|
|
29
|
+
worktreePath: string;
|
|
30
|
+
copyPatterns: string[];
|
|
31
|
+
symlinkPatterns: string[];
|
|
32
|
+
}
|
|
33
|
+
export declare function copyConfigFiles(options: CopyConfigFilesOptions): Promise<{
|
|
34
|
+
copied: string[];
|
|
35
|
+
symlinked: string[];
|
|
36
|
+
warnings: string[];
|
|
37
|
+
}>;
|
|
38
|
+
export interface RunPostCreateCommandsOptions {
|
|
39
|
+
worktreePath: string;
|
|
40
|
+
commands: string[];
|
|
41
|
+
onCommand?: (command: string) => void;
|
|
42
|
+
}
|
|
43
|
+
export declare function runPostCreateCommands(options: RunPostCreateCommandsOptions): Promise<{
|
|
44
|
+
executed: string[];
|
|
45
|
+
failed?: {
|
|
46
|
+
command: string;
|
|
47
|
+
error: string;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAevB,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAKD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,QAAQ,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;CAC5B;AAOD,wBAAgB,WAAW,IAAI,QAAQ,CAOtC;AAOD,wBAAsB,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiDpF;AAKD,qBAAa,qBAAsB,SAAQ,KAAK;aAG5B,UAAU,EAAE,MAAM;aAClB,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ;gBAFrC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,YAAA;CAKxC;AAgBD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAMD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAMjF;AAOD,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,iBAAiB,GAAG,QAAQ,CAOjF;AAKD,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAOD,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC;IAC9E,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CA2DD;AAKD,MAAM,WAAW,4BAA4B;IAC3C,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACtC;AAOD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC;IAC1F,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAC5C,CAAC,CAkDD"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { readFile, copyFile, symlink, mkdir } from 'node:fs/promises';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { globby } from 'globby';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
const WtConfigSchema = z.object({
|
|
7
|
+
worktreePath: z.string().optional(),
|
|
8
|
+
copy: z.array(z.string()).optional(),
|
|
9
|
+
symlink: z.array(z.string()).optional(),
|
|
10
|
+
postCreate: z.array(z.string()).optional(),
|
|
11
|
+
});
|
|
12
|
+
const CONFIG_FILENAME = '.wtrc.json';
|
|
13
|
+
export function getDefaults() {
|
|
14
|
+
return {
|
|
15
|
+
worktreePath: '$REPO-worktrees/$DIR',
|
|
16
|
+
copy: [],
|
|
17
|
+
symlink: [],
|
|
18
|
+
postCreate: [],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export async function loadConfig(mainWorktreePath) {
|
|
22
|
+
const defaults = getDefaults();
|
|
23
|
+
const configPath = join(mainWorktreePath, CONFIG_FILENAME);
|
|
24
|
+
try {
|
|
25
|
+
const content = await readFile(configPath, 'utf-8');
|
|
26
|
+
let parsed;
|
|
27
|
+
try {
|
|
28
|
+
parsed = JSON.parse(content);
|
|
29
|
+
}
|
|
30
|
+
catch (jsonError) {
|
|
31
|
+
throw new ConfigValidationError(`Invalid JSON in ${CONFIG_FILENAME}: ${jsonError.message}`, configPath);
|
|
32
|
+
}
|
|
33
|
+
const result = WtConfigSchema.safeParse(parsed);
|
|
34
|
+
if (!result.success) {
|
|
35
|
+
throw new ConfigValidationError(formatZodErrors(result.error), configPath, result.error);
|
|
36
|
+
}
|
|
37
|
+
const validated = result.data;
|
|
38
|
+
return {
|
|
39
|
+
config: {
|
|
40
|
+
worktreePath: validated.worktreePath ?? defaults.worktreePath,
|
|
41
|
+
copy: validated.copy ?? defaults.copy,
|
|
42
|
+
symlink: validated.symlink ?? defaults.symlink,
|
|
43
|
+
postCreate: validated.postCreate ?? defaults.postCreate,
|
|
44
|
+
},
|
|
45
|
+
source: 'file',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error.code === 'ENOENT') {
|
|
50
|
+
return { config: defaults, source: 'defaults' };
|
|
51
|
+
}
|
|
52
|
+
if (error instanceof ConfigValidationError) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export class ConfigValidationError extends Error {
|
|
59
|
+
configPath;
|
|
60
|
+
zodError;
|
|
61
|
+
constructor(message, configPath, zodError) {
|
|
62
|
+
super(message);
|
|
63
|
+
this.configPath = configPath;
|
|
64
|
+
this.zodError = zodError;
|
|
65
|
+
this.name = 'ConfigValidationError';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function formatZodErrors(error) {
|
|
69
|
+
const lines = error.issues.map(issue => {
|
|
70
|
+
const path = issue.path.length > 0 ? issue.path.join('.') : 'root';
|
|
71
|
+
return ` - ${path}: ${issue.message}`;
|
|
72
|
+
});
|
|
73
|
+
return `Invalid ${CONFIG_FILENAME}:\n${lines.join('\n')}`;
|
|
74
|
+
}
|
|
75
|
+
export function resolveTemplate(template, vars) {
|
|
76
|
+
return template
|
|
77
|
+
.replace(/\$PATH\b/g, vars.PATH)
|
|
78
|
+
.replace(/\$BRANCH\b/g, vars.BRANCH)
|
|
79
|
+
.replace(/\$DIR\b/g, vars.DIR)
|
|
80
|
+
.replace(/\$REPO\b/g, vars.REPO);
|
|
81
|
+
}
|
|
82
|
+
export function resolveConfig(config, vars) {
|
|
83
|
+
return {
|
|
84
|
+
worktreePath: resolveTemplate(config.worktreePath, vars),
|
|
85
|
+
copy: config.copy,
|
|
86
|
+
symlink: config.symlink,
|
|
87
|
+
postCreate: config.postCreate.map(cmd => resolveTemplate(cmd, vars)),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export async function copyConfigFiles(options) {
|
|
91
|
+
const { mainWorktreePath, worktreePath, copyPatterns, symlinkPatterns } = options;
|
|
92
|
+
const copied = [];
|
|
93
|
+
const symlinked = [];
|
|
94
|
+
const warnings = [];
|
|
95
|
+
if (copyPatterns.length > 0) {
|
|
96
|
+
try {
|
|
97
|
+
const filesToCopy = await globby(copyPatterns, {
|
|
98
|
+
cwd: mainWorktreePath,
|
|
99
|
+
dot: true,
|
|
100
|
+
onlyFiles: true,
|
|
101
|
+
});
|
|
102
|
+
for (const file of filesToCopy) {
|
|
103
|
+
const sourcePath = join(mainWorktreePath, file);
|
|
104
|
+
const targetPath = join(worktreePath, file);
|
|
105
|
+
try {
|
|
106
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
107
|
+
await copyFile(sourcePath, targetPath);
|
|
108
|
+
copied.push(file);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
warnings.push(`Failed to copy ${file}: ${error.message}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
warnings.push(`Failed to process copy patterns: ${error.message}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (symlinkPatterns.length > 0) {
|
|
120
|
+
try {
|
|
121
|
+
const filesToSymlink = await globby(symlinkPatterns, {
|
|
122
|
+
cwd: mainWorktreePath,
|
|
123
|
+
dot: true,
|
|
124
|
+
onlyFiles: true,
|
|
125
|
+
});
|
|
126
|
+
for (const file of filesToSymlink) {
|
|
127
|
+
const sourcePath = join(mainWorktreePath, file);
|
|
128
|
+
const targetPath = join(worktreePath, file);
|
|
129
|
+
try {
|
|
130
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
131
|
+
await symlink(sourcePath, targetPath);
|
|
132
|
+
symlinked.push(file);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
warnings.push(`Failed to symlink ${file}: ${error.message}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
warnings.push(`Failed to process symlink patterns: ${error.message}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { copied, symlinked, warnings };
|
|
144
|
+
}
|
|
145
|
+
export async function runPostCreateCommands(options) {
|
|
146
|
+
const { worktreePath, commands, onCommand } = options;
|
|
147
|
+
const executed = [];
|
|
148
|
+
for (const command of commands) {
|
|
149
|
+
onCommand?.(command);
|
|
150
|
+
if (command.endsWith(' &')) {
|
|
151
|
+
const cmd = command.slice(0, -2).trim();
|
|
152
|
+
spawn(cmd, {
|
|
153
|
+
cwd: worktreePath,
|
|
154
|
+
shell: true,
|
|
155
|
+
detached: true,
|
|
156
|
+
stdio: 'ignore',
|
|
157
|
+
}).unref();
|
|
158
|
+
executed.push(command);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
try {
|
|
162
|
+
await new Promise((resolve, reject) => {
|
|
163
|
+
const child = spawn(command, {
|
|
164
|
+
cwd: worktreePath,
|
|
165
|
+
shell: true,
|
|
166
|
+
stdio: 'inherit',
|
|
167
|
+
});
|
|
168
|
+
child.on('close', (code) => {
|
|
169
|
+
if (code === 0) {
|
|
170
|
+
resolve();
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
reject(new Error(`Command exited with code ${code}`));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
child.on('error', (error) => {
|
|
177
|
+
reject(error);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
executed.push(command);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
return {
|
|
184
|
+
executed,
|
|
185
|
+
failed: { command, error: error.message },
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { executed };
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,MAAM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,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;aAAM,CAAC;YAEN,IAAI,CAAC;gBACH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;oBAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE;wBAC3B,GAAG,EAAE,YAAY;wBACjB,KAAK,EAAE,IAAI;wBACX,KAAK,EAAE,SAAS;qBACjB,CAAC,CAAA;oBAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;wBACzB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;4BACf,OAAO,EAAE,CAAA;wBACX,CAAC;6BAAM,CAAC;4BACN,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC,CAAA;wBACvD,CAAC;oBACH,CAAC,CAAC,CAAA;oBAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;wBAC1B,MAAM,CAAC,KAAK,CAAC,CAAA;oBACf,CAAC,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;gBACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACxB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,QAAQ;oBACR,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE;iBACrD,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,CAAA;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wt-manager",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "CLI tool for managing Git worktrees efficiently with GitHub integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"wt": "
|
|
9
|
+
"wt": "dist/cli.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/",
|
|
@@ -22,13 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/daviddurika/git-worktree-manager#readme",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"build": "bun build ./src/cli.ts --outdir=dist --target=bun",
|
|
27
|
+
"build:binaries": "bun run scripts/build-binaries.ts",
|
|
28
|
+
"dev": "bun --watch src/cli.ts",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"check": "biome check src/",
|
|
31
|
+
"check:fix": "biome check --write src/",
|
|
32
|
+
"prepublishOnly": "bun run build",
|
|
33
|
+
"post-worktree-created": "bun install"
|
|
32
34
|
},
|
|
33
35
|
"keywords": [
|
|
34
36
|
"git",
|
|
@@ -40,22 +42,18 @@
|
|
|
40
42
|
"author": "David Durika",
|
|
41
43
|
"license": "MIT",
|
|
42
44
|
"engines": {
|
|
43
|
-
"
|
|
45
|
+
"bun": ">=1.0.0"
|
|
44
46
|
},
|
|
45
47
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"chalk": "^5.3.0",
|
|
48
|
+
"@clack/prompts": "^0.7.0",
|
|
48
49
|
"commander": "^12.1.0",
|
|
49
|
-
"execa": "^9.5.2",
|
|
50
50
|
"octokit": "^4.0.2",
|
|
51
|
-
"
|
|
51
|
+
"picocolors": "^1.1.1",
|
|
52
|
+
"zod": "^4.3.4"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@typescript-eslint/parser": "^8.15.0",
|
|
57
|
-
"eslint": "^9.15.0",
|
|
58
|
-
"prettier": "^3.3.3",
|
|
55
|
+
"@biomejs/biome": "^2.3.10",
|
|
56
|
+
"@types/bun": "^1.1.14",
|
|
59
57
|
"typescript": "^5.7.2"
|
|
60
58
|
}
|
|
61
59
|
}
|