Showing the changes to apps/server/src/project/ProjectSetupScriptRunner.ts (1 of 30 files). Show all
Unified · Split
| @@ -1,4 +1,4 @@ | |||
| 1 | import { ProjectId } from "@t3tools/contracts"; | 1 | import { ProjectId, type ProjectScript } from "@t3tools/contracts"; |
| 2 | import { projectScriptRuntimeEnv, setupProjectScript } from "@t3tools/shared/projectScripts"; | 2 | import { projectScriptRuntimeEnv, setupProjectScript } from "@t3tools/shared/projectScripts"; |
| 3 | import * as Context from "effect/Context"; | 3 | import * as Context from "effect/Context"; |
| 4 | import * as Effect from "effect/Effect"; | 4 | import * as Effect from "effect/Effect"; |
| @@ -31,6 +31,10 @@ export interface ProjectSetupScriptRunnerInput { · 26 unmodified lines | |||
| 31 | readonly projectCwd?: string; | 31 | readonly projectCwd?: string; |
| 32 | readonly worktreePath: string; | 32 | readonly worktreePath: string; |
| 33 | readonly preferredTerminalId?: string; | 33 | readonly preferredTerminalId?: string; |
| 34 | readonly project?: { | ||
| 35 | readonly workspaceRoot: string; | ||
| 36 | readonly scripts: ReadonlyArray<ProjectScript>; | ||
| 37 | }; | ||
| 34 | } | 38 | } |
| 35 | 39 | ||
| 36 | export class ProjectSetupScriptOperationError extends Schema.TaggedErrorClass<ProjectSetupScriptOperationError>()( | 40 | export class ProjectSetupScriptOperationError extends Schema.TaggedErrorClass<ProjectSetupScriptOperationError>()( |
| @@ -91,20 +95,24 @@ export const make = Effect.gen(function* () { · 54 unmodified lines | |||
| 91 | ...(input.projectId === undefined ? {} : { projectId: input.projectId }), | 95 | ...(input.projectId === undefined ? {} : { projectId: input.projectId }), |
| 92 | ...(input.projectCwd === undefined ? {} : { projectCwd: input.projectCwd }), | 96 | ...(input.projectCwd === undefined ? {} : { projectCwd: input.projectCwd }), |
| 93 | }; | 97 | }; |
| 94 | const projectById = input.projectId | 98 | const suppliedProject = input.project; |
| 95 | ? yield* projectionSnapshotQuery.getProjectShellById(ProjectId.make(input.projectId)).pipe( | 99 | const projectById = |
| 96 | Effect.map(Option.getOrUndefined), | 100 | suppliedProject ?? |
| 97 | Effect.mapError( | 101 | (input.projectId |
| 98 | (cause) => | 102 | ? yield* projectionSnapshotQuery.getProjectShellById(ProjectId.make(input.projectId)).pipe( |
| 99 | new ProjectSetupScriptOperationError({ | 103 | Effect.map(Option.getOrUndefined), |
| 100 | ...errorContext, | 104 | Effect.mapError( |
| 101 | operation: "resolveProject", | 105 | (cause) => |
| 102 | cause, | 106 | new ProjectSetupScriptOperationError({ |
| 103 | }), | 107 | ...errorContext, |
| 104 | ), | 108 | operation: "resolveProject", |
| 105 | ) | 109 | cause, |
| 106 | : null; | 110 | }), |
| 111 | ), | ||
| 112 | ) | ||
| 113 | : null); | ||
| 107 | const project = | 114 | const project = |
| 115 | suppliedProject ?? | ||
| 108 | projectById ?? | 116 | projectById ?? |
| 109 | (input.projectCwd | 117 | (input.projectCwd |
| 110 | ? yield* projectionSnapshotQuery.getActiveProjectByWorkspaceRoot(input.projectCwd).pipe( | 118 | ? yield* projectionSnapshotQuery.getActiveProjectByWorkspaceRoot(input.projectCwd).pipe( |