lalph 0.2.13 → 0.2.14
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/dist/cli.mjs +807 -1399
- package/package.json +1 -1
- package/src/Worktree.ts +23 -51
package/package.json
CHANGED
package/src/Worktree.ts
CHANGED
|
@@ -60,7 +60,6 @@ export class Worktree extends ServiceMap.Service<Worktree>()("lalph/Worktree", {
|
|
|
60
60
|
yield* setupWorktree({
|
|
61
61
|
directory,
|
|
62
62
|
exec: execHelpers.exec,
|
|
63
|
-
pathService,
|
|
64
63
|
})
|
|
65
64
|
|
|
66
65
|
return {
|
|
@@ -97,12 +96,10 @@ const seedSetupScript = Effect.fnUntraced(function* (setupPath: string) {
|
|
|
97
96
|
return
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
const baseBranch = yield* discoverBaseBranch
|
|
101
|
-
|
|
102
99
|
yield* fs.makeDirectory(pathService.dirname(setupPath), {
|
|
103
100
|
recursive: true,
|
|
104
101
|
})
|
|
105
|
-
yield* fs.writeFileString(setupPath, setupScriptTemplate
|
|
102
|
+
yield* fs.writeFileString(setupPath, setupScriptTemplate)
|
|
106
103
|
yield* fs.chmod(setupPath, 0o755)
|
|
107
104
|
})
|
|
108
105
|
|
|
@@ -112,13 +109,12 @@ const setupWorktree = Effect.fnUntraced(function* (options: {
|
|
|
112
109
|
template: TemplateStringsArray,
|
|
113
110
|
...args: Array<string | number | boolean>
|
|
114
111
|
) => Effect.Effect<ChildProcessSpawner.ExitCode, PlatformError.PlatformError>
|
|
115
|
-
readonly pathService: Path.Path
|
|
116
112
|
}) {
|
|
117
113
|
const fs = yield* FileSystem.FileSystem
|
|
114
|
+
const pathService = yield* Path.Path
|
|
118
115
|
const targetBranch = yield* getTargetBranch
|
|
119
|
-
const shouldUseWorktree = Option.isSome(targetBranch)
|
|
120
116
|
|
|
121
|
-
if (
|
|
117
|
+
if (Option.isSome(targetBranch)) {
|
|
122
118
|
const parsed = parseBranch(targetBranch.value)
|
|
123
119
|
yield* options.exec`git fetch ${parsed.remote}`
|
|
124
120
|
const code = yield* options.exec`git checkout ${parsed.branchWithRemote}`
|
|
@@ -128,23 +124,24 @@ const setupWorktree = Effect.fnUntraced(function* (options: {
|
|
|
128
124
|
}
|
|
129
125
|
}
|
|
130
126
|
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
yield* seedSetupScript(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
127
|
+
const cwdSetupPath = pathService.resolve(".lalph", "worktree-setup.sh")
|
|
128
|
+
const worktreeSetupPath = pathService.join(
|
|
129
|
+
options.directory,
|
|
130
|
+
".lalph",
|
|
131
|
+
"worktree-setup.sh",
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
yield* seedSetupScript(cwdSetupPath)
|
|
135
|
+
|
|
136
|
+
// worktree setup script takes precedence
|
|
137
|
+
const setupPath = (yield* fs.exists(worktreeSetupPath))
|
|
138
|
+
? worktreeSetupPath
|
|
139
|
+
: cwdSetupPath
|
|
140
|
+
|
|
141
|
+
yield* ChildProcess.make({
|
|
142
|
+
cwd: options.directory,
|
|
143
|
+
shell: process.env.SHELL ?? true,
|
|
144
|
+
})`${setupPath}`.pipe(ChildProcess.exitCode)
|
|
148
145
|
})
|
|
149
146
|
|
|
150
147
|
const getTargetBranch = Effect.gen(function* () {
|
|
@@ -156,35 +153,10 @@ const getTargetBranch = Effect.gen(function* () {
|
|
|
156
153
|
return project.value.targetBranch
|
|
157
154
|
})
|
|
158
155
|
|
|
159
|
-
const
|
|
160
|
-
const originHead =
|
|
161
|
-
yield* ChildProcess.make`git symbolic-ref --short refs/remotes/origin/HEAD`.pipe(
|
|
162
|
-
ChildProcess.string,
|
|
163
|
-
Effect.catch((_) => Effect.succeed("")),
|
|
164
|
-
Effect.map((output) => output.trim()),
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
if (originHead !== "") {
|
|
168
|
-
return originHead.startsWith("origin/")
|
|
169
|
-
? originHead.slice("origin/".length)
|
|
170
|
-
: originHead
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const currentBranch =
|
|
174
|
-
yield* ChildProcess.make`git branch --show-current`.pipe(
|
|
175
|
-
ChildProcess.string,
|
|
176
|
-
Effect.catch((_) => Effect.succeed("")),
|
|
177
|
-
Effect.map((output) => output.trim()),
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
return currentBranch === "" ? "main" : currentBranch
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
const setupScriptTemplate = (baseBranch: string) => `#!/usr/bin/env bash
|
|
156
|
+
const setupScriptTemplate = `#!/usr/bin/env bash
|
|
184
157
|
set -euo pipefail
|
|
185
158
|
|
|
186
|
-
|
|
187
|
-
git checkout origin/${baseBranch}
|
|
159
|
+
pnpm install
|
|
188
160
|
|
|
189
161
|
# Seeded by lalph. Customize this to prepare new worktrees.
|
|
190
162
|
`
|