| 426 | } |
| 427 | |
| 428 | function generateLicenseMetadata(outRoot: string) { |
| 429 | const chooseALicense = path.join(outRoot, 'static', 'choosealicense.com') |
| 430 | const licensesDir = path.join(chooseALicense, '_licenses') |
| 431 | |
| 432 | const files = readdirSync(licensesDir) |
| 433 | |
| 434 | const licenses = new Array<ILicense>() |
| 435 | for (const file of files) { |
| 436 | const fullPath = path.join(licensesDir, file) |
| 437 | const contents = readFileSync(fullPath, 'utf8') |
| 438 | const result = frontMatter<IChooseALicense>(contents) |
| 439 | |
| 440 | const licenseText = result.body.trim() |
| 441 | // ensure that any license file created in the app does not trigger the |
| 442 | // "no newline at end of file" warning when viewing diffs |
| 443 | const licenseTextWithNewLine = `${licenseText}\n` |
| 444 | |
| 445 | const license: ILicense = { |
| 446 | name: result.attributes.nickname || result.attributes.title, |
| 447 | featured: result.attributes.featured || false, |
| 448 | hidden: |
| 449 | result.attributes.hidden === undefined || result.attributes.hidden, |
| 450 | body: licenseTextWithNewLine, |
| 451 | } |
| 452 | |
| 453 | if (!license.hidden) { |
| 454 | licenses.push(license) |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | const licensePayload = path.join(outRoot, 'static', 'available-licenses.json') |
| 459 | const text = JSON.stringify(licenses) |
| 460 | writeFileSync(licensePayload, text, 'utf8') |
| 461 | |
| 462 | // embed the license alongside the generated license payload |
| 463 | const chooseALicenseLicense = path.join(chooseALicense, 'LICENSE.md') |
| 464 | const licenseDestination = path.join( |
| 465 | outRoot, |
| 466 | 'static', |
| 467 | 'LICENSE.choosealicense.md' |
| 468 | ) |
| 469 | |
| 470 | const licenseText = readFileSync(chooseALicenseLicense, 'utf8') |
| 471 | const licenseWithHeader = `GitHub Desktop uses licensing information provided by choosealicense.com. |
| 472 | |
| 473 | The bundle in available-licenses.json has been generated from a source list provided at https://github.com/github/choosealicense.com, which is made available under the below license: |
| 474 | |
| 475 | ------------ |
| 476 | |
| 477 | ${licenseText}` |
| 478 | |
| 479 | writeFileSync(licenseDestination, licenseWithHeader, 'utf8') |
| 480 | |
| 481 | // sweep up the choosealicense directory as the important bits have been bundled in the app |
| 482 | rmSync(chooseALicense, { recursive: true, force: true }) |
| 483 | } |
| 484 | |
| 485 | function getNotarizationOptions(): OsxNotarizeOptions | undefined { |