lalph 0.1.69 → 0.1.70

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.
Files changed (3) hide show
  1. package/dist/cli.mjs +7 -6
  2. package/package.json +1 -1
  3. package/src/Prd.ts +65 -59
package/dist/cli.mjs CHANGED
@@ -141989,6 +141989,7 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
141989
141989
  const yaml = yield* fs.readFileString(prdFile);
141990
141990
  return PrdIssue.arrayFromYaml(yaml);
141991
141991
  });
141992
+ const syncSemaphore = makeSemaphoreUnsafe(1);
141992
141993
  const mergableGithubPrs = gen(function* () {
141993
141994
  const updated = yield* readPrd;
141994
141995
  const prs = empty$11();
@@ -142008,7 +142009,7 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
142008
142009
  issueId: issue.id,
142009
142010
  state: "todo"
142010
142011
  });
142011
- });
142012
+ }, syncSemaphore.withPermit);
142012
142013
  const mergeConflictInstruction = "Next step: Rebase PR and resolve merge conflicts.";
142013
142014
  const flagUnmergable = fnUntraced(function* (options) {
142014
142015
  const issue = current.find((entry) => entry.id === options.issueId);
@@ -142048,7 +142049,7 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
142048
142049
  let current = yield* source.issues;
142049
142050
  yield* fs.writeFileString(prdFile, PrdIssue.arrayToYaml(current));
142050
142051
  const updatedIssues = /* @__PURE__ */ new Map();
142051
- const sync$2 = gen(function* () {
142052
+ const sync$2 = syncSemaphore.withPermit(gen(function* () {
142052
142053
  const updated = yield* readPrd;
142053
142054
  if (!(updated.length !== current.length || updated.some((u, i) => u.isChangedComparedTo(current[i])))) return;
142054
142055
  const githubPrs = /* @__PURE__ */ new Map();
@@ -142081,7 +142082,7 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
142081
142082
  githubPrNumber: prNumber
142082
142083
  });
142083
142084
  })));
142084
- }).pipe(uninterruptible);
142085
+ }).pipe(uninterruptible));
142085
142086
  const updateSyncHandle = yield* make$25();
142086
142087
  const updateSync = gen(function* () {
142087
142088
  const tempFile = yield* fs.makeTempFileScoped();
@@ -142101,7 +142102,7 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
142101
142102
  path: prdFile,
142102
142103
  mergableGithubPrs,
142103
142104
  maybeRevertIssue,
142104
- revertUpdatedIssues: gen(function* () {
142105
+ revertUpdatedIssues: syncSemaphore.withPermit(gen(function* () {
142105
142106
  for (const issue of updatedIssues.values()) {
142106
142107
  if (issue.state === "done") continue;
142107
142108
  yield* source.updateIssue({
@@ -142109,7 +142110,7 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
142109
142110
  state: "todo"
142110
142111
  });
142111
142112
  }
142112
- }),
142113
+ })),
142113
142114
  flagUnmergable,
142114
142115
  findById
142115
142116
  };
@@ -142442,7 +142443,7 @@ const commandSource = make$27("source").pipe(withDescription("Select the issue s
142442
142443
 
142443
142444
  //#endregion
142444
142445
  //#region package.json
142445
- var version = "0.1.69";
142446
+ var version = "0.1.70";
142446
142447
 
142447
142448
  //#endregion
142448
142449
  //#region src/cli.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lalph",
3
3
  "type": "module",
4
- "version": "0.1.69",
4
+ "version": "0.1.70",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/src/Prd.ts CHANGED
@@ -53,6 +53,8 @@ export class Prd extends ServiceMap.Service<
53
53
  return PrdIssue.arrayFromYaml(yaml)
54
54
  })
55
55
 
56
+ const syncSemaphore = Effect.makeSemaphoreUnsafe(1)
57
+
56
58
  const mergableGithubPrs = Effect.gen(function* () {
57
59
  const updated = yield* readPrd
58
60
  const prs = Array.empty<{ issueId: string; prNumber: number }>()
@@ -76,7 +78,7 @@ export class Prd extends ServiceMap.Service<
76
78
  issueId: issue.id!,
77
79
  state: "todo",
78
80
  })
79
- })
81
+ }, syncSemaphore.withPermit)
80
82
 
81
83
  const mergeConflictInstruction =
82
84
  "Next step: Rebase PR and resolve merge conflicts."
@@ -134,64 +136,66 @@ export class Prd extends ServiceMap.Service<
134
136
 
135
137
  const updatedIssues = new Map<string, PrdIssue>()
136
138
 
137
- const sync = Effect.gen(function* () {
138
- const updated = yield* readPrd
139
- const anyChanges =
140
- updated.length !== current.length ||
141
- updated.some((u, i) => u.isChangedComparedTo(current[i]!))
142
- if (!anyChanges) {
143
- return
144
- }
139
+ const sync = syncSemaphore.withPermit(
140
+ Effect.gen(function* () {
141
+ const updated = yield* readPrd
142
+ const anyChanges =
143
+ updated.length !== current.length ||
144
+ updated.some((u, i) => u.isChangedComparedTo(current[i]!))
145
+ if (!anyChanges) {
146
+ return
147
+ }
145
148
 
146
- const githubPrs = new Map<string, number>()
147
- const toRemove = new Set(
148
- current.filter((i) => i.id !== null).map((i) => i.id!),
149
- )
149
+ const githubPrs = new Map<string, number>()
150
+ const toRemove = new Set(
151
+ current.filter((i) => i.id !== null).map((i) => i.id!),
152
+ )
150
153
 
151
- for (const issue of updated) {
152
- toRemove.delete(issue.id!)
154
+ for (const issue of updated) {
155
+ toRemove.delete(issue.id!)
153
156
 
154
- if (issue.id === null) {
155
- yield* source.createIssue(issue)
156
- continue
157
- }
157
+ if (issue.id === null) {
158
+ yield* source.createIssue(issue)
159
+ continue
160
+ }
158
161
 
159
- if (issue.githubPrNumber) {
160
- githubPrs.set(issue.id, issue.githubPrNumber)
161
- }
162
+ if (issue.githubPrNumber) {
163
+ githubPrs.set(issue.id, issue.githubPrNumber)
164
+ }
162
165
 
163
- const existing = current.find((i) => i.id === issue.id)
164
- if (!existing || !existing.isChangedComparedTo(issue)) continue
166
+ const existing = current.find((i) => i.id === issue.id)
167
+ if (!existing || !existing.isChangedComparedTo(issue)) continue
165
168
 
166
- yield* source.updateIssue({
167
- issueId: issue.id,
168
- title: issue.title,
169
- description: issue.description,
170
- state: issue.state,
171
- blockedBy: issue.blockedBy,
172
- })
169
+ yield* source.updateIssue({
170
+ issueId: issue.id,
171
+ title: issue.title,
172
+ description: issue.description,
173
+ state: issue.state,
174
+ blockedBy: issue.blockedBy,
175
+ })
173
176
 
174
- updatedIssues.set(issue.id, issue)
175
- }
177
+ updatedIssues.set(issue.id, issue)
178
+ }
176
179
 
177
- yield* Effect.forEach(
178
- toRemove,
179
- (issueId) => source.cancelIssue(issueId),
180
- { concurrency: "unbounded" },
181
- )
180
+ yield* Effect.forEach(
181
+ toRemove,
182
+ (issueId) => source.cancelIssue(issueId),
183
+ { concurrency: "unbounded" },
184
+ )
182
185
 
183
- current = yield* source.issues
184
- yield* fs.writeFileString(
185
- prdFile,
186
- PrdIssue.arrayToYaml(
187
- current.map((issue) => {
188
- const prNumber = githubPrs.get(issue.id!)
189
- if (!prNumber) return issue
190
- return new PrdIssue({ ...issue, githubPrNumber: prNumber })
191
- }),
192
- ),
193
- )
194
- }).pipe(Effect.uninterruptible)
186
+ current = yield* source.issues
187
+ yield* fs.writeFileString(
188
+ prdFile,
189
+ PrdIssue.arrayToYaml(
190
+ current.map((issue) => {
191
+ const prNumber = githubPrs.get(issue.id!)
192
+ if (!prNumber) return issue
193
+ return new PrdIssue({ ...issue, githubPrNumber: prNumber })
194
+ }),
195
+ ),
196
+ )
197
+ }).pipe(Effect.uninterruptible),
198
+ )
195
199
 
196
200
  const updateSyncHandle = yield* FiberHandle.make()
197
201
  const updateSync = Effect.gen(function* () {
@@ -237,15 +241,17 @@ export class Prd extends ServiceMap.Service<
237
241
  path: prdFile,
238
242
  mergableGithubPrs,
239
243
  maybeRevertIssue,
240
- revertUpdatedIssues: Effect.gen(function* () {
241
- for (const issue of updatedIssues.values()) {
242
- if (issue.state === "done") continue
243
- yield* source.updateIssue({
244
- issueId: issue.id!,
245
- state: "todo",
246
- })
247
- }
248
- }),
244
+ revertUpdatedIssues: syncSemaphore.withPermit(
245
+ Effect.gen(function* () {
246
+ for (const issue of updatedIssues.values()) {
247
+ if (issue.state === "done") continue
248
+ yield* source.updateIssue({
249
+ issueId: issue.id!,
250
+ state: "todo",
251
+ })
252
+ }
253
+ }),
254
+ ),
249
255
  flagUnmergable,
250
256
  findById,
251
257
  }