@markmdev/pebble 0.1.22 → 0.1.24

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/index.js CHANGED
@@ -939,8 +939,9 @@ function formatErrorPretty(error) {
939
939
  function outputMutationSuccess(id, pretty, extra) {
940
940
  if (pretty) {
941
941
  const notes = [];
942
- if (extra?.parentReopened) {
943
- notes.push(`parent ${extra.parentReopened.id} reopened`);
942
+ if (extra?.parentsReopened?.length) {
943
+ const ids = extra.parentsReopened.map((p) => p.id).join(", ");
944
+ notes.push(`reopened: ${ids}`);
944
945
  }
945
946
  if (extra?.blockersReopened?.length) {
946
947
  const ids = extra.blockersReopened.map((b) => b.id).join(", ");
@@ -953,8 +954,8 @@ function outputMutationSuccess(id, pretty, extra) {
953
954
  }
954
955
  } else {
955
956
  const result = { id, success: true };
956
- if (extra?.parentReopened) {
957
- result._parentReopened = extra.parentReopened;
957
+ if (extra?.parentsReopened?.length) {
958
+ result._parentsReopened = extra.parentsReopened;
958
959
  }
959
960
  if (extra?.blockersReopened?.length) {
960
961
  result._blockersReopened = extra.blockersReopened;
@@ -1137,7 +1138,7 @@ function createCommand(program2) {
1137
1138
  const pebbleDir = getOrCreatePebbleDir();
1138
1139
  const config = getConfig(pebbleDir);
1139
1140
  let parentId;
1140
- let parentReopened;
1141
+ const parentsReopened = [];
1141
1142
  if (options.parent) {
1142
1143
  parentId = resolveId(options.parent);
1143
1144
  const parent = getIssue(parentId);
@@ -1147,15 +1148,20 @@ function createCommand(program2) {
1147
1148
  if (parent.type === "verification") {
1148
1149
  throw new Error(`Verification issues cannot be parents`);
1149
1150
  }
1150
- if (parent.status === "closed") {
1151
- const reopenEvent = {
1152
- type: "reopen",
1153
- issueId: parentId,
1154
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1155
- data: { reason: "Reopened to add child" }
1156
- };
1157
- appendEvent(reopenEvent, pebbleDir);
1158
- parentReopened = { id: parentId, title: parent.title };
1151
+ const state = getComputedState();
1152
+ let current = state.get(parentId);
1153
+ while (current) {
1154
+ if (current.status === "closed") {
1155
+ const reopenEvent = {
1156
+ type: "reopen",
1157
+ issueId: current.id,
1158
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1159
+ data: { reason: "Reopened to add descendant" }
1160
+ };
1161
+ appendEvent(reopenEvent, pebbleDir);
1162
+ parentsReopened.push({ id: current.id, title: current.title });
1163
+ }
1164
+ current = current.parent ? state.get(current.parent) : void 0;
1159
1165
  }
1160
1166
  }
1161
1167
  let verifiesId;
@@ -1246,7 +1252,7 @@ function createCommand(program2) {
1246
1252
  };
1247
1253
  appendEvent(depEvent, pebbleDir);
1248
1254
  }
1249
- const extra = parentReopened || blockersReopened.length > 0 ? { parentReopened, blockersReopened: blockersReopened.length > 0 ? blockersReopened : void 0 } : void 0;
1255
+ const extra = parentsReopened.length > 0 || blockersReopened.length > 0 ? { parentsReopened: parentsReopened.length > 0 ? parentsReopened : void 0, blockersReopened: blockersReopened.length > 0 ? blockersReopened : void 0 } : void 0;
1250
1256
  outputMutationSuccess(id, pretty, extra);
1251
1257
  } catch (error) {
1252
1258
  outputError(error, pretty);
@@ -1290,7 +1296,7 @@ function updateCommand(program2) {
1290
1296
  data.description = options.description;
1291
1297
  hasChanges = true;
1292
1298
  }
1293
- let parentReopened;
1299
+ const parentsReopened = [];
1294
1300
  if (options.parent !== void 0) {
1295
1301
  if (options.parent.toLowerCase() === "null") {
1296
1302
  data.parent = "";
@@ -1303,15 +1309,20 @@ function updateCommand(program2) {
1303
1309
  if (parentIssue.type === "verification") {
1304
1310
  throw new Error(`Verification issues cannot be parents`);
1305
1311
  }
1306
- if (parentIssue.status === "closed") {
1307
- const reopenEvent = {
1308
- type: "reopen",
1309
- issueId: parentId,
1310
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1311
- data: { reason: "Reopened to add child" }
1312
- };
1313
- appendEvent(reopenEvent, pebbleDir);
1314
- parentReopened = { id: parentId, title: parentIssue.title };
1312
+ const state = getComputedState();
1313
+ let current = state.get(parentId);
1314
+ while (current) {
1315
+ if (current.status === "closed") {
1316
+ const reopenEvent = {
1317
+ type: "reopen",
1318
+ issueId: current.id,
1319
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1320
+ data: { reason: "Reopened to add descendant" }
1321
+ };
1322
+ appendEvent(reopenEvent, pebbleDir);
1323
+ parentsReopened.push({ id: current.id, title: current.title });
1324
+ }
1325
+ current = current.parent ? state.get(current.parent) : void 0;
1315
1326
  }
1316
1327
  data.parent = parentId;
1317
1328
  }
@@ -1350,7 +1361,7 @@ function updateCommand(program2) {
1350
1361
  if (allIds.length === 1) {
1351
1362
  const result = results[0];
1352
1363
  if (result.success) {
1353
- outputMutationSuccess(result.id, pretty, parentReopened ? { parentReopened } : void 0);
1364
+ outputMutationSuccess(result.id, pretty, parentsReopened.length > 0 ? { parentsReopened } : void 0);
1354
1365
  } else {
1355
1366
  throw new Error(result.error || "Unknown error");
1356
1367
  }
@@ -2850,7 +2861,7 @@ data: ${message}
2850
2861
  res.status(400).json({ error: "Priority must be 0-4" });
2851
2862
  return;
2852
2863
  }
2853
- let parentReopened;
2864
+ const parentsReopened = [];
2854
2865
  if (parent) {
2855
2866
  const parentIssue = getIssue(parent);
2856
2867
  if (!parentIssue) {
@@ -2861,15 +2872,20 @@ data: ${message}
2861
2872
  res.status(400).json({ error: "Verification issues cannot be parents" });
2862
2873
  return;
2863
2874
  }
2864
- if (parentIssue.status === "closed") {
2865
- const reopenEvent = {
2866
- type: "reopen",
2867
- issueId: parent,
2868
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2869
- data: { reason: "Reopened to add child" }
2870
- };
2871
- appendEvent(reopenEvent, pebbleDir);
2872
- parentReopened = { id: parent, title: parentIssue.title };
2875
+ const state = getComputedState();
2876
+ let current = state.get(parent);
2877
+ while (current) {
2878
+ if (current.status === "closed") {
2879
+ const reopenEvent = {
2880
+ type: "reopen",
2881
+ issueId: current.id,
2882
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2883
+ data: { reason: "Reopened to add descendant" }
2884
+ };
2885
+ appendEvent(reopenEvent, pebbleDir);
2886
+ parentsReopened.push({ id: current.id, title: current.title });
2887
+ }
2888
+ current = current.parent ? state.get(current.parent) : void 0;
2873
2889
  }
2874
2890
  }
2875
2891
  const issueId = generateId(config.prefix);
@@ -2897,7 +2913,7 @@ data: ${message}
2897
2913
  appendEvent(parentUpdateEvent, pebbleDir);
2898
2914
  }
2899
2915
  const issue = getIssue(issueId);
2900
- const result = parentReopened ? { ...issue, _parentReopened: parentReopened } : issue;
2916
+ const result = parentsReopened.length > 0 ? { ...issue, _parentsReopened: parentsReopened } : issue;
2901
2917
  res.status(201).json(result);
2902
2918
  } catch (error) {
2903
2919
  res.status(500).json({ error: error.message });