worktree-flow 0.0.21 → 0.0.23
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.
|
@@ -8,7 +8,7 @@ export async function runCheckout(branchName, useCases, services, deps) {
|
|
|
8
8
|
const config = services.config.load();
|
|
9
9
|
try {
|
|
10
10
|
// 1. Fetch all repos from source-path
|
|
11
|
-
|
|
11
|
+
console.log('');
|
|
12
12
|
await useCases.fetchAllRepos.execute({
|
|
13
13
|
sourcePath,
|
|
14
14
|
fetchCacheTtlSeconds: config.fetchCacheTtlSeconds,
|
|
@@ -19,6 +19,8 @@ export async function runCheckout(branchName, useCases, services, deps) {
|
|
|
19
19
|
branchName,
|
|
20
20
|
});
|
|
21
21
|
// 3. Display only repos that have changes (matching or errored)
|
|
22
|
+
const discoveredCount = discoverResult.branchCheckResults.filter((r) => r.hasBranch).length;
|
|
23
|
+
console.log(chalk.bold(`\nFound ${discoveredCount} repos with branch "${branchName}"`));
|
|
22
24
|
for (const checkResult of discoverResult.branchCheckResults) {
|
|
23
25
|
if (checkResult.error) {
|
|
24
26
|
services.console.log(`${checkResult.repoName}... ${chalk.red(`error: ${checkResult.error}`)}`);
|
|
@@ -34,6 +36,7 @@ export async function runCheckout(branchName, useCases, services, deps) {
|
|
|
34
36
|
// 5. Prompt for post-checkout
|
|
35
37
|
let shouldRunPostCheckout = false;
|
|
36
38
|
if (config.postCheckout) {
|
|
39
|
+
console.log('');
|
|
37
40
|
shouldRunPostCheckout = await deps.confirm({
|
|
38
41
|
message: `Run "${config.postCheckout}" in all workspaces?`,
|
|
39
42
|
default: true,
|
package/dist/lib/fetch.js
CHANGED
|
@@ -68,7 +68,7 @@ export class FetchService {
|
|
|
68
68
|
await Promise.all(workers);
|
|
69
69
|
if (!silent) {
|
|
70
70
|
// Clear the progress line and show summary
|
|
71
|
-
this.console.write('\r');
|
|
71
|
+
this.console.write('\r\x1b[K');
|
|
72
72
|
const cacheInfo = cachedCount > 0 ? ` (${cachedCount} cached)` : '';
|
|
73
73
|
if (failed > 0) {
|
|
74
74
|
this.console.log(`Fetched ${total - failed}/${total} repos${cacheInfo} ${chalk.yellow(`(${failed} failed)`)}`);
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { WorkspaceAlreadyExistsError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Replaces characters that could cause filesystem issues with underscores.
|
|
5
|
+
* e.g. "release/123" → "release_123"
|
|
6
|
+
*/
|
|
7
|
+
export function sanitizeBranchForFolder(branch) {
|
|
8
|
+
return branch.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* WorkspaceDirectoryService handles workspace directory operations.
|
|
5
12
|
* Pure directory management, no orchestration.
|
|
@@ -10,7 +17,7 @@ export class WorkspaceDirectoryService {
|
|
|
10
17
|
this.fs = fs;
|
|
11
18
|
}
|
|
12
19
|
createWorkspaceDir(destPath, branch) {
|
|
13
|
-
const workspacePath = path.join(destPath, branch);
|
|
20
|
+
const workspacePath = path.join(destPath, sanitizeBranchForFolder(branch));
|
|
14
21
|
if (this.fs.existsSync(workspacePath)) {
|
|
15
22
|
throw new WorkspaceAlreadyExistsError(workspacePath);
|
|
16
23
|
}
|
|
@@ -105,6 +112,7 @@ export class WorkspaceDirectoryService {
|
|
|
105
112
|
}
|
|
106
113
|
findWorkspace(destPath, branchName) {
|
|
107
114
|
const workspaces = this.listWorkspaces(destPath);
|
|
108
|
-
|
|
115
|
+
const sanitized = sanitizeBranchForFolder(branchName);
|
|
116
|
+
return workspaces.find(ws => ws.name === sanitized) || null;
|
|
109
117
|
}
|
|
110
118
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { NotInWorkspaceError, WorkspaceNotFoundError } from './errors.js';
|
|
3
|
+
import { sanitizeBranchForFolder } from './workspaceDirectory.js';
|
|
3
4
|
/**
|
|
4
5
|
* Resolves a workspace path from either an explicit branch name or by auto-detecting
|
|
5
6
|
* from the current working directory.
|
|
@@ -17,7 +18,8 @@ export function resolveWorkspace(branchName, workspaceDir, config, process) {
|
|
|
17
18
|
const { destPath } = config.getRequired();
|
|
18
19
|
if (branchName) {
|
|
19
20
|
// Explicit branch provided
|
|
20
|
-
const
|
|
21
|
+
const sanitized = sanitizeBranchForFolder(branchName);
|
|
22
|
+
const workspacePath = path.join(destPath, sanitized);
|
|
21
23
|
const workspace = workspaceDir.findWorkspace(destPath, branchName);
|
|
22
24
|
if (!workspace) {
|
|
23
25
|
throw new WorkspaceNotFoundError(workspacePath);
|