1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/script/update-enterprise-dates.js
Jason Etcovitch 8d4f3e65fe Move test & script utils out of /lib (#17517)
* Remove an unused file

* Move authenticate-to-aws to scripts/utils

* Move crowdin-config to tests/utils

* Remove add-frontmatter-to-file

* Move find-unused-assets

* Move git-utils to script/utils

* Move lib/github to script/utils

* Revert "Remove an unused file"

This reverts commit cd93ad846a0354e957359f23124eb0724c9147cf.

* Move find-extraneous-translation-files to script/utils

* We already have tests/helpers

* Rename script/utils => helpers for consistency

* Forgot a path

* Fix path to crowdin-config

Co-authored-by: Chiedo John <2156688+chiedo@users.noreply.github.com>
2021-01-29 10:30:51 -05:00

45 lines
1.5 KiB
JavaScript
Executable File

#!/usr/bin/env node
const { getContents } = require('./helpers/git-utils')
const fs = require('fs')
const path = require('path')
const enterpriseDatesFile = path.join(__dirname, '../lib/enterprise-dates.json')
const enterpriseDatesString = fs.readFileSync(enterpriseDatesFile, 'utf8')
// [start-readme]
//
// This script fetches data from https://github.com/github/enterprise-releases/blob/master/releases.json
// and updates `lib/enterprise-dates.json`, which the site uses for various functionality.
//
// [end-readme]
// check for required PAT
if (!process.env.GITHUB_TOKEN) {
console.error('Error! You must have a GITHUB_TOKEN set in an .env file to run this script.')
process.exit(1)
}
main()
async function main () {
// send owner, repo, ref, path
const rawDates = JSON.parse(await getContents('github', 'enterprise-releases', 'master', 'releases.json'))
const formattedDates = {}
Object.entries(rawDates).forEach(([releaseNumber, releaseObject]) => {
formattedDates[releaseNumber] = {
releaseDate: releaseObject.release_candidate || releaseObject.start,
deprecationDate: releaseObject.end
}
})
const formattedDatesString = JSON.stringify(formattedDates, null, 2)
if (formattedDatesString === enterpriseDatesString) {
console.log('This repo is already in sync with enterprise-releases!')
} else {
fs.writeFileSync(enterpriseDatesFile, formattedDatesString)
console.log(`${enterpriseDatesFile} has been updated!`)
}
}