newpr 1.0.18 → 1.0.19
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/package.json +1 -1
- package/src/stack/partition.ts +45 -19
package/package.json
CHANGED
package/src/stack/partition.ts
CHANGED
|
@@ -193,7 +193,25 @@ function parsePartitionResponse(
|
|
|
193
193
|
const warnings: string[] = [];
|
|
194
194
|
const structuredWarnings: StackWarning[] = [];
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
let sharedFoundation: FileGroup | undefined;
|
|
197
|
+
if (data.shared_foundation && typeof data.shared_foundation === "object") {
|
|
198
|
+
const sf = data.shared_foundation as Record<string, unknown>;
|
|
199
|
+
sharedFoundation = {
|
|
200
|
+
name: String(sf.name ?? "Shared Foundation"),
|
|
201
|
+
type: "chore",
|
|
202
|
+
description: String(sf.description ?? "Common infrastructure changes"),
|
|
203
|
+
files: Array.isArray(sf.files) ? sf.files.map(String) : [],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const groupNameLookup = new Map<string, string>();
|
|
208
|
+
for (const group of groups) {
|
|
209
|
+
groupNameLookup.set(group.name.toLowerCase(), group.name);
|
|
210
|
+
}
|
|
211
|
+
if (sharedFoundation) {
|
|
212
|
+
groupNameLookup.set(sharedFoundation.name.toLowerCase(), sharedFoundation.name);
|
|
213
|
+
groupNameLookup.set("shared foundation", sharedFoundation.name);
|
|
214
|
+
}
|
|
197
215
|
|
|
198
216
|
for (const item of assignments) {
|
|
199
217
|
const entry = item as Record<string, unknown>;
|
|
@@ -206,7 +224,26 @@ function parsePartitionResponse(
|
|
|
206
224
|
continue;
|
|
207
225
|
}
|
|
208
226
|
|
|
209
|
-
|
|
227
|
+
const normalizedGroup = group.toLowerCase().replace(/["'`]/g, "").trim();
|
|
228
|
+
const isSharedFoundationAlias = /shared[\s_-]*foundation/.test(normalizedGroup);
|
|
229
|
+
let canonicalGroup = groupNameLookup.get(normalizedGroup);
|
|
230
|
+
if (!canonicalGroup && isSharedFoundationAlias) {
|
|
231
|
+
if (!sharedFoundation) {
|
|
232
|
+
sharedFoundation = {
|
|
233
|
+
name: "Shared Foundation",
|
|
234
|
+
type: "chore",
|
|
235
|
+
description: "Common infrastructure changes",
|
|
236
|
+
files: [],
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
groupNameLookup.set(sharedFoundation.name.toLowerCase(), sharedFoundation.name);
|
|
240
|
+
groupNameLookup.set("shared-foundation", sharedFoundation.name);
|
|
241
|
+
groupNameLookup.set("shared_foundation", sharedFoundation.name);
|
|
242
|
+
groupNameLookup.set("shared foundation", sharedFoundation.name);
|
|
243
|
+
canonicalGroup = sharedFoundation.name;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (!canonicalGroup) {
|
|
210
247
|
warnings.push(`Unknown group "${group}" for file "${path}", skipping`);
|
|
211
248
|
structuredWarnings.push({
|
|
212
249
|
category: "system",
|
|
@@ -224,19 +261,22 @@ function parsePartitionResponse(
|
|
|
224
261
|
reattributed.push({
|
|
225
262
|
path,
|
|
226
263
|
from_groups: ambiguousEntry.groups,
|
|
227
|
-
to_group:
|
|
264
|
+
to_group: canonicalGroup,
|
|
228
265
|
reason,
|
|
229
266
|
});
|
|
230
267
|
} else if (isUnassigned) {
|
|
231
268
|
reattributed.push({
|
|
232
269
|
path,
|
|
233
270
|
from_groups: [],
|
|
234
|
-
to_group:
|
|
271
|
+
to_group: canonicalGroup,
|
|
235
272
|
reason,
|
|
236
273
|
});
|
|
237
274
|
}
|
|
238
275
|
|
|
239
|
-
ownership.set(path,
|
|
276
|
+
ownership.set(path, canonicalGroup);
|
|
277
|
+
if (sharedFoundation && canonicalGroup === sharedFoundation.name && !sharedFoundation.files.includes(path)) {
|
|
278
|
+
sharedFoundation.files.push(path);
|
|
279
|
+
}
|
|
240
280
|
}
|
|
241
281
|
|
|
242
282
|
const stillUnassigned = report.unassigned.filter((p) => !ownership.has(p));
|
|
@@ -274,18 +314,6 @@ function parsePartitionResponse(
|
|
|
274
314
|
});
|
|
275
315
|
}
|
|
276
316
|
|
|
277
|
-
let sharedFoundation: FileGroup | undefined;
|
|
278
|
-
if (data.shared_foundation && typeof data.shared_foundation === "object") {
|
|
279
|
-
const sf = data.shared_foundation as Record<string, unknown>;
|
|
280
|
-
sharedFoundation = {
|
|
281
|
-
name: String(sf.name ?? "Shared Foundation"),
|
|
282
|
-
type: "chore",
|
|
283
|
-
description: String(sf.description ?? "Common infrastructure changes"),
|
|
284
|
-
files: Array.isArray(sf.files) ? sf.files.map(String) : [],
|
|
285
|
-
};
|
|
286
|
-
validGroupNames.add(sharedFoundation.name);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
317
|
return {
|
|
290
318
|
ownership,
|
|
291
319
|
reattributed,
|
|
@@ -294,5 +322,3 @@ function parsePartitionResponse(
|
|
|
294
322
|
structured_warnings: structuredWarnings,
|
|
295
323
|
};
|
|
296
324
|
}
|
|
297
|
-
|
|
298
|
-
|