lalph 0.2.13 → 0.2.15

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 CHANGED
@@ -151324,8 +151324,7 @@ var Worktree = class extends Service$1()("lalph/Worktree", { make: gen(function*
151324
151324
  const execHelpers = yield* makeExecHelpers({ directory });
151325
151325
  yield* setupWorktree({
151326
151326
  directory,
151327
- exec: execHelpers.exec,
151328
- pathService
151327
+ exec: execHelpers.exec
151329
151328
  });
151330
151329
  return {
151331
151330
  directory,
@@ -151350,16 +151349,15 @@ const seedSetupScript = fnUntraced(function* (setupPath) {
151350
151349
  const fs = yield* FileSystem;
151351
151350
  const pathService = yield* Path$1;
151352
151351
  if (yield* fs.exists(setupPath)) return;
151353
- const baseBranch = yield* discoverBaseBranch;
151354
151352
  yield* fs.makeDirectory(pathService.dirname(setupPath), { recursive: true });
151355
- yield* fs.writeFileString(setupPath, setupScriptTemplate(baseBranch));
151353
+ yield* fs.writeFileString(setupPath, setupScriptTemplate);
151356
151354
  yield* fs.chmod(setupPath, 493);
151357
151355
  });
151358
151356
  const setupWorktree = fnUntraced(function* (options) {
151359
151357
  const fs = yield* FileSystem;
151358
+ const pathService = yield* Path$1;
151360
151359
  const targetBranch = yield* getTargetBranch;
151361
- const shouldUseWorktree = isSome(targetBranch);
151362
- if (shouldUseWorktree) {
151360
+ if (isSome(targetBranch)) {
151363
151361
  const parsed = parseBranch(targetBranch.value);
151364
151362
  yield* options.exec`git fetch ${parsed.remote}`;
151365
151363
  if ((yield* options.exec`git checkout ${parsed.branchWithRemote}`) !== 0) {
@@ -151367,32 +151365,24 @@ const setupWorktree = fnUntraced(function* (options) {
151367
151365
  yield* options.exec`git push -u ${parsed.remote} ${parsed.branch}`;
151368
151366
  }
151369
151367
  }
151370
- const setupPath = shouldUseWorktree ? options.pathService.join(options.directory, "scripts", "worktree-setup.sh") : options.pathService.resolve("scripts", "worktree-setup.sh");
151371
- yield* seedSetupScript(setupPath);
151372
- if (yield* fs.exists(setupPath)) {
151373
- const setupCwd = shouldUseWorktree ? options.directory : options.pathService.resolve(".");
151374
- yield* make$23({
151375
- cwd: setupCwd,
151376
- shell: process.env.SHELL ?? true
151377
- })`${setupPath}`.pipe(exitCode);
151378
- }
151368
+ const cwdSetupPath = pathService.resolve(".lalph", "worktree-setup.sh");
151369
+ const worktreeSetupPath = pathService.join(options.directory, ".lalph", "worktree-setup.sh");
151370
+ yield* seedSetupScript(cwdSetupPath);
151371
+ const setupPath = (yield* fs.exists(worktreeSetupPath)) ? worktreeSetupPath : cwdSetupPath;
151372
+ yield* make$23({
151373
+ cwd: options.directory,
151374
+ shell: process.env.SHELL ?? true
151375
+ })`${setupPath}`.pipe(exitCode);
151379
151376
  });
151380
151377
  const getTargetBranch = gen(function* () {
151381
151378
  const project = yield* projectById(yield* CurrentProjectId);
151382
151379
  if (isNone(project)) return none$4();
151383
151380
  return project.value.targetBranch;
151384
151381
  });
151385
- const discoverBaseBranch = gen(function* () {
151386
- const originHead = yield* make$23`git symbolic-ref --short refs/remotes/origin/HEAD`.pipe(string, catch_$1((_) => succeed$1("")), map$8((output) => output.trim()));
151387
- if (originHead !== "") return originHead.startsWith("origin/") ? originHead.slice(7) : originHead;
151388
- const currentBranch = yield* make$23`git branch --show-current`.pipe(string, catch_$1((_) => succeed$1("")), map$8((output) => output.trim()));
151389
- return currentBranch === "" ? "main" : currentBranch;
151390
- });
151391
- const setupScriptTemplate = (baseBranch) => `#!/usr/bin/env bash
151382
+ const setupScriptTemplate = `#!/usr/bin/env bash
151392
151383
  set -euo pipefail
151393
151384
 
151394
- git fetch origin
151395
- git checkout origin/${baseBranch}
151385
+ pnpm install
151396
151386
 
151397
151387
  # Seeded by lalph. Customize this to prepare new worktrees.
151398
151388
  `;
@@ -152230,7 +152220,7 @@ const commandSource = make$35("source").pipe(withDescription("Select the issue s
152230
152220
 
152231
152221
  //#endregion
152232
152222
  //#region package.json
152233
- var version = "0.2.13";
152223
+ var version = "0.2.15";
152234
152224
 
152235
152225
  //#endregion
152236
152226
  //#region src/commands/projects/ls.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lalph",
3
3
  "type": "module",
4
- "version": "0.2.13",
4
+ "version": "0.2.15",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
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(baseBranch))
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 (shouldUseWorktree) {
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 setupPath = shouldUseWorktree
132
- ? options.pathService.join(
133
- options.directory,
134
- "scripts",
135
- "worktree-setup.sh",
136
- )
137
- : options.pathService.resolve("scripts", "worktree-setup.sh")
138
- yield* seedSetupScript(setupPath)
139
- if (yield* fs.exists(setupPath)) {
140
- const setupCwd = shouldUseWorktree
141
- ? options.directory
142
- : options.pathService.resolve(".")
143
- yield* ChildProcess.make({
144
- cwd: setupCwd,
145
- shell: process.env.SHELL ?? true,
146
- })`${setupPath}`.pipe(ChildProcess.exitCode)
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 discoverBaseBranch = Effect.gen(function* () {
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
- git fetch origin
187
- git checkout origin/${baseBranch}
159
+ pnpm install
188
160
 
189
161
  # Seeded by lalph. Customize this to prepare new worktrees.
190
162
  `