(body)
| 323 | } |
| 324 | |
| 325 | export function parseExternalPluginIssueBody(body) { |
| 326 | const sections = parseIssueFormSections(body); |
| 327 | const errors = []; |
| 328 | |
| 329 | function requiredField(title) { |
| 330 | const value = stripNoResponse(sections.get(title)); |
| 331 | if (!value) { |
| 332 | errors.push(`submission: "${title}" is required`); |
| 333 | } |
| 334 | return value; |
| 335 | } |
| 336 | |
| 337 | const pluginName = requiredField(FIELD_TITLES.pluginName); |
| 338 | const shortDescription = requiredField(FIELD_TITLES.shortDescription); |
| 339 | const repoInput = normalizeGitHubRepo(requiredField(FIELD_TITLES.githubRepository)); |
| 340 | // Support both the current field title and the legacy title used before the ref/sha split |
| 341 | const immutableRef = stripNoResponse( |
| 342 | sections.get(FIELD_TITLES.immutableRef) ?? sections.get(LEGACY_FIELD_TITLES.immutableRef), |
| 343 | ); |
| 344 | const immutableSha = stripNoResponse(sections.get(FIELD_TITLES.immutableSha)); |
| 345 | const version = requiredField(FIELD_TITLES.version); |
| 346 | const license = requiredField(FIELD_TITLES.license); |
| 347 | const authorName = requiredField(FIELD_TITLES.authorName); |
| 348 | |
| 349 | const pluginPath = stripNoResponse(sections.get(FIELD_TITLES.pluginPath)); |
| 350 | const authorUrl = stripNoResponse(sections.get(FIELD_TITLES.authorUrl)); |
| 351 | const homepageUrl = stripNoResponse(sections.get(FIELD_TITLES.homepageUrl)); |
| 352 | const keywords = parseKeywords(sections.get(FIELD_TITLES.keywords)); |
| 353 | const additionalNotes = stripNoResponse(sections.get(FIELD_TITLES.additionalNotes)); |
| 354 | const checkedItems = parseChecklist(sections.get(FIELD_TITLES.submissionChecklist)); |
| 355 | |
| 356 | if (!immutableRef && !immutableSha) { |
| 357 | errors.push(`submission: one of "${FIELD_TITLES.immutableRef}" or "${FIELD_TITLES.immutableSha}" is required`); |
| 358 | } |
| 359 | |
| 360 | for (const equivalents of REQUIRED_CHECKLIST_ITEMS) { |
| 361 | let isChecked = false; |
| 362 | for (const text of equivalents) { |
| 363 | if (checkedItems.has(text)) { |
| 364 | isChecked = true; |
| 365 | break; |
| 366 | } |
| 367 | } |
| 368 | if (!isChecked) { |
| 369 | // Report using the canonical (first) text in each equivalents Set |
| 370 | const [canonical] = equivalents; |
| 371 | errors.push(`submission: checklist item must be checked: "${canonical}"`); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | const plugin = { |
| 376 | name: pluginName, |
| 377 | description: shortDescription, |
| 378 | version, |
| 379 | author: { |
| 380 | name: authorName, |
| 381 | ...(authorUrl ? { url: authorUrl } : {}), |
| 382 | }, |
no test coverage detected