lalph 0.3.13 → 0.3.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
@@ -144157,14 +144157,21 @@ var LinearError = class extends ErrorClass("lalph/LinearError")({
144157
144157
  const selectedProjectId = new ProjectSetting("linear.selectedProjectId", String$1);
144158
144158
  const selectProject$1 = gen(function* () {
144159
144159
  const linear = yield* Linear;
144160
- const projects = yield* runCollect(linear.projects);
144161
- const project = yield* autoComplete({
144160
+ const choices = [{
144161
+ title: "Create new",
144162
+ value: { _tag: "create" }
144163
+ }, ...(yield* runCollect(linear.projects)).map((project) => ({
144164
+ title: project.name,
144165
+ value: {
144166
+ _tag: "existing",
144167
+ project
144168
+ }
144169
+ }))];
144170
+ const selected = yield* autoComplete({
144162
144171
  message: "Select a Linear project",
144163
- choices: projects.map((project) => ({
144164
- title: project.name,
144165
- value: project
144166
- }))
144172
+ choices
144167
144173
  });
144174
+ const project = selected._tag === "existing" ? selected.project : yield* createLinearProject;
144168
144175
  yield* Settings.setProject(selectedProjectId, some$2(project.id));
144169
144176
  return project;
144170
144177
  });
@@ -144172,6 +144179,32 @@ const getOrSelectProject = gen(function* () {
144172
144179
  const linear = yield* Linear;
144173
144180
  return yield* Settings.getProject(selectedProjectId).pipe(flatMap$2((o) => o.asEffect()), flatMap$2((projectId) => linear.use((c) => c.project(projectId))), catch_$1(() => selectProject$1));
144174
144181
  });
144182
+ const createLinearProject = gen(function* () {
144183
+ const linear = yield* Linear;
144184
+ const projects = yield* runCollect(linear.projects);
144185
+ const projectName = yield* text$2({
144186
+ message: "Linear project name",
144187
+ validate(input) {
144188
+ const name = input.trim();
144189
+ if (name.length === 0) return fail$4("Project name cannot be empty");
144190
+ if (projects.some((project) => project.name.toLowerCase() === name.toLowerCase())) return fail$4("A project with this name already exists");
144191
+ return succeed$1(name);
144192
+ }
144193
+ });
144194
+ const teams = yield* linear.use((client) => client.teams()).pipe(map$8((teamConnection) => teamConnection.nodes));
144195
+ const teamId = yield* autoComplete({
144196
+ message: "Select a team for the new project",
144197
+ choices: teams.map((team) => ({
144198
+ title: team.name,
144199
+ value: team.id
144200
+ }))
144201
+ });
144202
+ const created = yield* linear.use((client) => client.createProject({
144203
+ name: projectName,
144204
+ teamIds: [teamId]
144205
+ }));
144206
+ return yield* linear.use(() => created.project);
144207
+ });
144175
144208
  const selectedTeamId = new ProjectSetting("linear.selectedTeamId", String$1);
144176
144209
  const teamSelect = fnUntraced(function* (project) {
144177
144210
  const linear = yield* Linear;
@@ -150474,8 +150507,9 @@ ${generalCommentsXml}
150474
150507
  var GithubCliRepoNotFound = class extends TaggedError("GithubCliRepoNotFound") {
150475
150508
  message = "GitHub repository not found. Ensure the current directory is inside a git repo with a GitHub remote.";
150476
150509
  };
150477
- const renderReviewComments = (comment, followup) => `<comment author="${comment.author.login}" path="${comment.path}"${comment.originalLine ? ` originalLine="${comment.originalLine}"` : ""}>
150510
+ const renderReviewComments = (comment, followup) => `<comment author="${comment.author.login}" path="${comment.path}">
150478
150511
  <diffHunk>${comment.diffHunk}</diffHunk>
150512
+ ${comment.originalLine ? `<lineNumber>${comment.originalLine}</lineNumber>` : ""}
150479
150513
  <body>${comment.body}</body>${followup.length > 0 ? `
150480
150514
 
150481
150515
  <followup>${followup.map((fc) => `
@@ -152323,7 +152357,7 @@ const commandSource = make$35("source").pipe(withDescription("Select the issue s
152323
152357
 
152324
152358
  //#endregion
152325
152359
  //#region package.json
152326
- var version = "0.3.13";
152360
+ var version = "0.3.15";
152327
152361
 
152328
152362
  //#endregion
152329
152363
  //#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.3.13",
4
+ "version": "0.3.15",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/src/Github/Cli.ts CHANGED
@@ -149,10 +149,9 @@ export class GithubCliRepoNotFound extends Data.TaggedError(
149
149
  const renderReviewComments = (
150
150
  comment: ReviewComment,
151
151
  followup: Array<ReviewComment>,
152
- ) => `<comment author="${comment.author.login}" path="${comment.path}"${
153
- comment.originalLine ? ` originalLine="${comment.originalLine}"` : ""
154
- }>
152
+ ) => `<comment author="${comment.author.login}" path="${comment.path}">
155
153
  <diffHunk>${comment.diffHunk}</diffHunk>
154
+ ${comment.originalLine ? `<lineNumber>${comment.originalLine}</lineNumber>` : ""}
156
155
  <body>${comment.body}</body>${
157
156
  followup.length > 0
158
157
  ? `
package/src/Linear.ts CHANGED
@@ -539,19 +539,36 @@ const selectedProjectId = new ProjectSetting(
539
539
  "linear.selectedProjectId",
540
540
  Schema.String,
541
541
  )
542
+
542
543
  const selectProject = Effect.gen(function* () {
543
544
  const linear = yield* Linear
544
545
 
545
546
  const projects = yield* Stream.runCollect(linear.projects)
546
-
547
- const project = yield* Prompt.autoComplete({
548
- message: "Select a Linear project",
549
- choices: projects.map((project) => ({
547
+ const choices: ReadonlyArray<{
548
+ readonly title: string
549
+ readonly value: ProjectSelection
550
+ }> = [
551
+ {
552
+ title: "Create new",
553
+ value: { _tag: "create" },
554
+ },
555
+ ...projects.map((project) => ({
550
556
  title: project.name,
551
- value: project,
557
+ value: {
558
+ _tag: "existing" as const,
559
+ project,
560
+ },
552
561
  })),
562
+ ]
563
+
564
+ const selected = yield* Prompt.autoComplete({
565
+ message: "Select a Linear project",
566
+ choices,
553
567
  })
554
568
 
569
+ const project =
570
+ selected._tag === "existing" ? selected.project : yield* createLinearProject
571
+
555
572
  yield* Settings.setProject(selectedProjectId, Option.some(project.id))
556
573
 
557
574
  return project
@@ -565,6 +582,54 @@ const getOrSelectProject = Effect.gen(function* () {
565
582
  )
566
583
  })
567
584
 
585
+ type ProjectSelection =
586
+ | {
587
+ readonly _tag: "create"
588
+ }
589
+ | {
590
+ readonly _tag: "existing"
591
+ readonly project: LinearProject
592
+ }
593
+
594
+ const createLinearProject = Effect.gen(function* () {
595
+ const linear = yield* Linear
596
+ const projects = yield* Stream.runCollect(linear.projects)
597
+ const projectName = yield* Prompt.text({
598
+ message: "Linear project name",
599
+ validate(input) {
600
+ const name = input.trim()
601
+ if (name.length === 0) {
602
+ return Effect.fail("Project name cannot be empty")
603
+ }
604
+ if (
605
+ projects.some(
606
+ (project) => project.name.toLowerCase() === name.toLowerCase(),
607
+ )
608
+ ) {
609
+ return Effect.fail("A project with this name already exists")
610
+ }
611
+ return Effect.succeed(name)
612
+ },
613
+ })
614
+ const teams = yield* linear
615
+ .use((client) => client.teams())
616
+ .pipe(Effect.map((teamConnection) => teamConnection.nodes))
617
+ const teamId = yield* Prompt.autoComplete({
618
+ message: "Select a team for the new project",
619
+ choices: teams.map((team) => ({
620
+ title: team.name,
621
+ value: team.id,
622
+ })),
623
+ })
624
+ const created = yield* linear.use((client) =>
625
+ client.createProject({
626
+ name: projectName,
627
+ teamIds: [teamId],
628
+ }),
629
+ )
630
+ return yield* linear.use(() => created.project!)
631
+ })
632
+
568
633
  // Team selection
569
634
 
570
635
  const selectedTeamId = new ProjectSetting(